Repository navigation
Description
What happened
In the Desktop app, when an agent calls AskUserQuestion while the user is viewing another session (or another section), the question prompt bar is never shown — even after switching back to that session. The transcript shows the tool call, but the interactive prompt (UserQuestionPrompt) is missing. The session stays parked waiting for an answer that the UI can never provide, so the run stalls indefinitely.
The same defect does not exist for sandbox-boundary requests: switching away and back re-hydrates them.
Root cause
Session events are delivered only to the renderer's subscription for the currently active session:
apps/desktop/src/renderer/app-shell-effects.ts—useActiveSessionEventssubscribeswindow.maka.sessions.subscribeEvents(activeId, ...)and unsubscribes whenactiveIdchanges.apps/desktop/src/main/session-stream.ts— main sendssessions:event:<sessionId>to the renderer unconditionally; Electron drops IPC messages with no listener.
So a user_question_request event that arrives while the session is not the active view is dropped. The prompt state lives only in the renderer's in-memory interactionBySession queue (app-shell-session-events.ts), fed exclusively by live events; there is no query, no replay, and no re-derivation from persisted messages when the session is re-focused.
The invariant violated:
The event stream is a notification, not state. Any pending interaction must be re-queryable from an authoritative source, not dependent on the recipient being present when the event fires.
Maka already upholds this invariant for sandbox-boundary requests: the kernel keeps a sandboxBoundaryRequestOwners registry (packages/runtime/src/runtime-kernel.ts:422), registers/clears via the event observation hook (observeSandboxBoundaryEvent, :2593), exposes listActiveSandboxBoundaryRequests (:2346), and the renderer reconciles the queue on activeId change (apps/desktop/src/renderer/app-shell.tsx:1045-1067). AskUserQuestion is the single exception to this invariant.
How to reproduce
- Start a session with a real backend and trigger an AskUserQuestion while the session is active — prompt appears (baseline works).
- Send a new request that will call AskUserQuestion, then switch to another session (or another section such as 扩展/设置) before it fires.
- Switch back to the first session.
- Expected: the question prompt bar is visible and answerable.
- Actual: the transcript shows the tool call, but
.maka-user-question-promptis absent; the run is parked waiting onrespondToUserQuestionforever.
A deterministic reproduction is available with the fake backend (FAKE_ASK_USER_QUESTION_PROMPT): trigger the prompt, switch away, switch back — the prompt does not re-appear. The existing E2E apps/desktop/e2e/ask-user-question.spec.ts only covers the active-view case.
Environment
- Maka commit:
fab124577 - OS: macOS
- Surface: Desktop
Proposed fix (root-cause, category-level)
Make pending interactions a queryable resource instead of a one-shot event, mirroring the sandbox-boundary path and absorbing it as one mechanism:
- Runtime kernel (
packages/runtime/src/runtime-kernel.ts): generalizeobserveSandboxBoundaryEvent→observeInteractionEventsosandbox_boundary_request/user_question_requestregister, andsandbox_boundary_decision_ack/ thetool_resultanswering a question unregister;clearSandboxBoundaryRequestOwners(sessionId, turnId)already clears per turn and covers both. AddlistActiveInteractions(sessionId). - SessionManager + IPC + preload: replace
sessions:listActiveSandboxBoundaryRequestswithsessions:listActiveInteractions(keep the old channel as an alias or remove it). - UI (
packages/ui/src/interaction-queue.ts): generalizereconcileSandboxBoundaryInteractions→reconcileInteractions(the current implementation already passes through non-boundary entries; theComposerInteractiontype is already the union of both event types). - Renderer (
apps/desktop/src/renderer/app-shell.tsx:1045-1067): the existing boundary hydration effect becomes one fetch + one reconcile for both interaction types, keeping the epoch guard. - Tests: kernel registry unit tests (register/unregister/query/conflict), IPC contract, UI reconcile tests, and an E2E (fake backend → prompt → switch away → switch back →
.maka-user-question-promptvisible).
This fixes the whole category (switch away/back, prompt pending at startup, renderer reload, background/child-session questions), not just the reported scenario. The event stream then remains purely incremental.
Alternative (minimal) path
If a small diff is preferred first: subscribe to all session events (add a sessions:event broadcast alongside the per-session channels in session-stream.ts, plus a subscribeAllSessionEvents in preload), feeding the existing per-session handleEvent — ~40 lines, no state-model change. It fixes the reported scenario but not the whole category (renderer not present at event time, e.g. startup/reload).
Non-goals
- No disk persistence of pending interactions: their lifecycle belongs to the in-process parked continuation; after a main-process restart the continuation itself no longer exists, so persisting the request body has nothing to answer it. Peer implementations (Paseo, opencode) use in-memory registries + query endpoints.
Evidence
- Subscription scope:
apps/desktop/src/renderer/app-shell-effects.ts(useActiveSessionEvents,subscribeEvents(activeId, ...)) - Drop without listener:
apps/desktop/src/main/session-stream.ts:420/556/586(safeSendToRenderer('sessions:event:<id>', ...)) - Renderer-only prompt state:
apps/desktop/src/renderer/app-shell-session-events.ts:128-131(enqueue on live event),apps/desktop/src/renderer/app-shell.tsx:602(activeQuestion) - Existing boundary hydration (the pattern to mirror):
apps/desktop/src/renderer/app-shell.tsx:1045-1067+packages/runtime/src/runtime-kernel.ts:2593/2346/422 - Related peer analysis (hermes-agent documents the identical bug for its
clarify.requestone-shot events; OpenHands/lobehub/opencode/paseo all model pending interactions as re-queryable snapshots or persisted message fields)
Activity
fix: rehydrate an unanswered user question the surface never received
fix: rehydrate an unanswered user question the surface never received (…