mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
Stop agent prompts renaming existing workspaces
This commit is contained in:
@@ -2411,6 +2411,7 @@ export class Session {
|
|||||||
initialTitle: workspacePromptTitle,
|
initialTitle: workspacePromptTitle,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
const createdDirectoryWorkspaceForAgent = !createdWorktree && !msg.workspaceId;
|
||||||
|
|
||||||
const { snapshot, liveSnapshot } = await createAgentCommand(
|
const { snapshot, liveSnapshot } = await createAgentCommand(
|
||||||
{
|
{
|
||||||
@@ -2441,11 +2442,8 @@ export class Session {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
createdAgentId = snapshot.id;
|
createdAgentId = snapshot.id;
|
||||||
if (!createdWorktree && msg.workspaceId) {
|
|
||||||
await this.writeInitialWorkspaceTitleIfUntitled(workspaceId, workspacePromptTitle);
|
|
||||||
}
|
|
||||||
await this.agentUpdates.forwardLiveAgent(snapshot);
|
await this.agentUpdates.forwardLiveAgent(snapshot);
|
||||||
if (!createdWorktree && trimmedPrompt) {
|
if (createdDirectoryWorkspaceForAgent && trimmedPrompt) {
|
||||||
await this.scheduleAutoNameLocalWorkspaceTitleForFirstAgent({
|
await this.scheduleAutoNameLocalWorkspaceTitleForFirstAgent({
|
||||||
workspaceId,
|
workspaceId,
|
||||||
cwd: createAgentConfig.cwd,
|
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.
|
// Wraps the injected workspace-name generator for a directory workspace.
|
||||||
private async generateWorkspaceTitleFromContext(input: {
|
private async generateWorkspaceTitleFromContext(input: {
|
||||||
cwd: string;
|
cwd: string;
|
||||||
|
|||||||
@@ -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-"));
|
const workdir = mkdtempSync(path.join(tmpdir(), "paseo-create-agent-existing-title-"));
|
||||||
try {
|
try {
|
||||||
const cwd = path.join(workdir, "repo");
|
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(
|
const session = asTestSession(
|
||||||
new Session({
|
new Session({
|
||||||
clientId: "test-client",
|
clientId: "test-client",
|
||||||
@@ -922,6 +924,10 @@ test("create_agent_request writes the first prompt title onto an untitled existi
|
|||||||
mcpBaseUrl: null,
|
mcpBaseUrl: null,
|
||||||
stt: null,
|
stt: null,
|
||||||
tts: null,
|
tts: null,
|
||||||
|
generateWorkspaceName: async () => {
|
||||||
|
generateCalls += 1;
|
||||||
|
return { title: "Generated title that must not be written", branch: null };
|
||||||
|
},
|
||||||
providerSnapshotManager: createProviderSnapshotManagerStub().manager,
|
providerSnapshotManager: createProviderSnapshotManagerStub().manager,
|
||||||
terminalManager: null,
|
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",
|
initialPrompt: "Fix login bug\nwith better validation",
|
||||||
attachments: [],
|
attachments: [],
|
||||||
});
|
});
|
||||||
|
await vi.runAllTimersAsync();
|
||||||
|
|
||||||
const [createdAgent] = agentManager.listAgents();
|
const [createdAgent] = agentManager.listAgents();
|
||||||
expect(createdAgent?.workspaceId).toBe("ws-existing");
|
expect(createdAgent?.workspaceId).toBe("ws-existing");
|
||||||
|
expect(generateCalls).toBe(0);
|
||||||
await expect(workspaceRegistry.get("ws-existing")).resolves.toMatchObject({
|
await expect(workspaceRegistry.get("ws-existing")).resolves.toMatchObject({
|
||||||
title: "Fix login bug",
|
title: null,
|
||||||
|
updatedAt: "2026-05-07T00:00:00.000Z",
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
|
vi.useRealTimers();
|
||||||
rmSync(workdir, { recursive: true, force: true });
|
rmSync(workdir, { recursive: true, force: true });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -410,7 +410,7 @@ test("local workspace auto-title does not broadcast provider snapshot warm-up to
|
|||||||
}
|
}
|
||||||
}, 20_000);
|
}, 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 cwd = mkdtempSync(path.join(tmpdir(), "paseo-agent-submit-title-"));
|
||||||
const daemon = await createTestPaseoDaemon({
|
const daemon = await createTestPaseoDaemon({
|
||||||
agentClients: { mock: new MockLoadTestAgentClient() },
|
agentClients: { mock: new MockLoadTestAgentClient() },
|
||||||
@@ -433,6 +433,8 @@ test("create_agent_request with initialPrompt generates a daemon-visible workspa
|
|||||||
if (!workspaceId) {
|
if (!workspaceId) {
|
||||||
throw new Error(created.error ?? "Expected workspace to be created");
|
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({
|
const agent = await client.createAgent({
|
||||||
provider: "mock",
|
provider: "mock",
|
||||||
@@ -443,9 +445,7 @@ test("create_agent_request with initialPrompt generates a daemon-visible workspa
|
|||||||
});
|
});
|
||||||
expect(agent.workspaceId).toBe(workspaceId);
|
expect(agent.workspaceId).toBe(workspaceId);
|
||||||
|
|
||||||
await expect
|
expect(await workspaceName(client, workspaceId)).toBe(originalName);
|
||||||
.poll(() => workspaceName(client, workspaceId), { timeout: 10_000 })
|
|
||||||
.toBe("Fix login bug");
|
|
||||||
} finally {
|
} finally {
|
||||||
await client.close().catch(() => undefined);
|
await client.close().catch(() => undefined);
|
||||||
await daemon.close();
|
await daemon.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user