Skip to content

Commit 4d4b961

Browse files
matt2eclaude
andcommitted
fix: update thread persona_id on every message send
The frontend already passes personaId into acpSendMessage, but it was only used for session tracker lookup — never forwarded to the backend. After a mid-session persona switch and page reload, the session list showed the stale persona from session creation. Forward personaId in the prompt request's _meta field and extract it in on_prompt to update the thread's persona_id metadata, mirroring how model_id and provider_id are already kept in sync. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent dfaaa67 commit 4d4b961

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

crates/goose/src/acp/server.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,6 +2227,21 @@ impl GooseAcpAgent {
22272227
let t_start = std::time::Instant::now();
22282228
debug!(target: "perf", sid = %sid, "perf: prompt start");
22292229

2230+
// Update persona_id on the thread if the client sent one in _meta.
2231+
let prompt_persona_id = args
2232+
.meta
2233+
.as_ref()
2234+
.and_then(|m| m.get("personaId"))
2235+
.and_then(|v| v.as_str())
2236+
.map(|s| s.to_string());
2237+
if let Some(ref pid) = prompt_persona_id {
2238+
let pid = pid.clone();
2239+
self.update_thread_metadata(&thread_id, move |meta| {
2240+
meta.persona_id = Some(pid);
2241+
})
2242+
.await?;
2243+
}
2244+
22302245
let cancel_token = CancellationToken::new();
22312246
let internal_session_id = self.internal_session_id(&thread_id).await?;
22322247

ui/goose2/src/shared/api/acp.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ export async function acpSendMessage(
9595
`[perf:send] ${sid} acpSendMessage → prompt(len=${prompt.length}, imgs=${images?.length ?? 0})`,
9696
);
9797
const tPrompt = performance.now();
98-
await directAcp.prompt(gooseSessionId, content);
98+
const meta: Record<string, unknown> = {};
99+
if (personaId) meta.personaId = personaId;
100+
await directAcp.prompt(
101+
gooseSessionId,
102+
content,
103+
Object.keys(meta).length > 0 ? meta : undefined,
104+
);
99105
const tDone = performance.now();
100106
perfLog(
101107
`[perf:send] ${sid} prompt() resolved in ${(tDone - tPrompt).toFixed(1)}ms (total acpSendMessage ${(tDone - tStart).toFixed(1)}ms)`,

ui/goose2/src/shared/api/acpApi.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ export async function loadSession(
231231
export async function prompt(
232232
sessionId: string,
233233
content: ContentBlock[],
234+
meta?: Record<string, unknown>,
234235
): Promise<PromptResponse> {
235236
const client = await getClient();
236-
return client.prompt({ sessionId, prompt: content });
237+
return client.prompt({ sessionId, prompt: content, _meta: meta });
237238
}

0 commit comments

Comments
 (0)