fix: fast-fail on_load_session when thread ID is missing or wrong

When the UI sends a legacy session ID (e.g. "20260415_1") instead of a
thread UUID, on_load_session previously hung indefinitely because
get_thread returned an error that was silently swallowed or never
reached the client. This caused a 30-second frontend timeout and a
blank conversation view.

Now the handler checks whether the requested ID corresponds to a known
session in the sessions table, and returns an immediate, diagnostic
error explaining what went wrong:
- "Session X has linked thread Y, but was sent as the session_id
  instead of the thread UUID" — tells the engineer the UI needs to
  send the thread UUID instead.
- "Session X exists but has no linked thread" — the session was not
  fully created via ACP (thread creation failed or was skipped).
- "Session not found" — the ID doesn't match anything.

Also bumps tauri-plugin-dialog to "2" to fix a version mismatch
warning with @tauri-apps/plugin-dialog v2.7.

Signed-off-by: morgmart <98432065+morgmart@users.noreply.github.com>
This commit is contained in:
morgmart
2026-04-14 19:59:11 -07:00
parent 529d6f7195
commit 290870ad2a
2 changed files with 32 additions and 9 deletions
+31 -8
View File
@@ -1473,14 +1473,37 @@ impl GooseAcpAgent {
// The ACP session_id IS the thread ID.
let thread_id = args.session_id.0.to_string();
let thread = self
.thread_manager
.get_thread(&thread_id)
.await
.map_err(|_| {
sacp::Error::resource_not_found(Some(thread_id.clone()))
.data(format!("Session not found: {}", thread_id))
})?;
let thread = match self.thread_manager.get_thread(&thread_id).await {
Ok(thread) => thread,
Err(_) => {
// Check if the requested ID is a legacy session ID (e.g.
// "20260415_1") that was sent instead of a thread UUID.
// Return a diagnostic error so the caller knows what happened.
if let Ok(session) = self
.session_manager
.get_session(&thread_id, false)
.await
{
let detail = match &session.thread_id {
Some(tid) => format!(
"Session {} has linked thread {}, but was sent as the \
session_id instead of the thread UUID",
thread_id, tid
),
None => format!(
"Session {} exists but has no linked thread — \
it may not have been fully created via ACP",
thread_id
),
};
return Err(sacp::Error::resource_not_found(Some(thread_id)).data(detail));
}
return Err(
sacp::Error::resource_not_found(Some(thread_id.clone()))
.data(format!("Session not found: {}", thread_id)),
);
}
};
// Reuse the thread's current internal session so the agent retains
// conversation context (compaction state, full message history, etc.).
+1 -1
View File
@@ -20,7 +20,7 @@ tauri-build = { version = "2", features = [] }
tauri = { version = "2", features = ["protocol-asset"] }
tauri-plugin-app-test-driver = { path = "plugins/app-test-driver" }
tauri-plugin-opener = "2"
tauri-plugin-dialog = ">=2,<2.7"
tauri-plugin-dialog = "2"
tauri-plugin-window-state = "2"
tauri-plugin-log = "2"
serde = { version = "1", features = ["derive"] }