Stop agent prompts renaming existing workspaces

This commit is contained in:
Mohamed Boudra
2026-06-28 19:10:59 +07:00
committed by GitHub
parent cb212b4e5c
commit 3288e1cfb9
3 changed files with 18 additions and 28 deletions

View File

@@ -2411,6 +2411,7 @@ export class Session {
initialTitle: workspacePromptTitle,
},
);
const createdDirectoryWorkspaceForAgent = !createdWorktree && !msg.workspaceId;
const { snapshot, liveSnapshot } = await createAgentCommand(
{
@@ -2441,11 +2442,8 @@ export class Session {
},
);
createdAgentId = snapshot.id;
if (!createdWorktree && msg.workspaceId) {
await this.writeInitialWorkspaceTitleIfUntitled(workspaceId, workspacePromptTitle);
}
await this.agentUpdates.forwardLiveAgent(snapshot);
if (!createdWorktree && trimmedPrompt) {
if (createdDirectoryWorkspaceForAgent && trimmedPrompt) {
await this.scheduleAutoNameLocalWorkspaceTitleForFirstAgent({
workspaceId,
cwd: createAgentConfig.cwd,
@@ -2906,24 +2904,6 @@ export class Session {
});
}
private async writeInitialWorkspaceTitleIfUntitled(
workspaceId: string,
title: string | null,
): Promise<void> {
if (!title) {
return;
}
const current = await this.workspaceRegistry.get(workspaceId);
if (!current || current.title) {
return;
}
await this.workspaceRegistry.upsert({
...current,
title,
updatedAt: new Date().toISOString(),
});
}
// Wraps the injected workspace-name generator for a directory workspace.
private async generateWorkspaceTitleFromContext(input: {
cwd: string;

View File

@@ -830,7 +830,8 @@ test("create_agent_request keeps requested child cwd when grouped under an exist
}
});
test("create_agent_request writes the first prompt title onto an untitled existing workspace", async () => {
test("create_agent_request does not title an existing workspace from the agent prompt", async () => {
vi.useFakeTimers();
const workdir = mkdtempSync(path.join(tmpdir(), "paseo-create-agent-existing-title-"));
try {
const cwd = path.join(workdir, "repo");
@@ -883,6 +884,7 @@ test("create_agent_request writes the first prompt title onto an untitled existi
}),
);
let generateCalls = 0;
const session = asTestSession(
new Session({
clientId: "test-client",
@@ -922,6 +924,10 @@ test("create_agent_request writes the first prompt title onto an untitled existi
mcpBaseUrl: null,
stt: null,
tts: null,
generateWorkspaceName: async () => {
generateCalls += 1;
return { title: "Generated title that must not be written", branch: null };
},
providerSnapshotManager: createProviderSnapshotManagerStub().manager,
terminalManager: null,
}),
@@ -935,13 +941,17 @@ test("create_agent_request writes the first prompt title onto an untitled existi
initialPrompt: "Fix login bug\nwith better validation",
attachments: [],
});
await vi.runAllTimersAsync();
const [createdAgent] = agentManager.listAgents();
expect(createdAgent?.workspaceId).toBe("ws-existing");
expect(generateCalls).toBe(0);
await expect(workspaceRegistry.get("ws-existing")).resolves.toMatchObject({
title: "Fix login bug",
title: null,
updatedAt: "2026-05-07T00:00:00.000Z",
});
} finally {
vi.useRealTimers();
rmSync(workdir, { recursive: true, force: true });
}
});

View File

@@ -410,7 +410,7 @@ test("local workspace auto-title does not broadcast provider snapshot warm-up to
}
}, 20_000);
test("create_agent_request with initialPrompt generates a daemon-visible workspace title", async () => {
test("create_agent_request with workspaceId does not retitle an existing workspace", async () => {
const cwd = mkdtempSync(path.join(tmpdir(), "paseo-agent-submit-title-"));
const daemon = await createTestPaseoDaemon({
agentClients: { mock: new MockLoadTestAgentClient() },
@@ -433,6 +433,8 @@ test("create_agent_request with initialPrompt generates a daemon-visible workspa
if (!workspaceId) {
throw new Error(created.error ?? "Expected workspace to be created");
}
const originalName = await workspaceName(client, workspaceId);
expect(originalName).toBe(path.basename(cwd));
const agent = await client.createAgent({
provider: "mock",
@@ -443,9 +445,7 @@ test("create_agent_request with initialPrompt generates a daemon-visible workspa
});
expect(agent.workspaceId).toBe(workspaceId);
await expect
.poll(() => workspaceName(client, workspaceId), { timeout: 10_000 })
.toBe("Fix login bug");
expect(await workspaceName(client, workspaceId)).toBe(originalName);
} finally {
await client.close().catch(() => undefined);
await daemon.close();