Skip to content

fix: rehydrate an unanswered user question the surface never received - #2086

Merged
Astro-Han merged 2 commits into
mainfrom
fix/2072-user-question-rehydration
Aug 4, 2026
Merged

Astro-Han merged 2 commits into
mainfrom
fix/2072-user-question-rehydration

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A run that parks on AskUserQuestion could become permanently unanswerable. The session view subscribes only to the session it shows, so a request raised while another session was active — or before the window existed — never reached the surface, and nothing read it back. The prompt was gone for good; the run stayed parked on a question the UI could not answer.

Sandbox-boundary requests already hold this invariant: RuntimeKernel keeps every unanswered request in a registry, and the shell reads it back whenever the active session changes. AskUserQuestion was the one exception. This generalizes that single path to both request kinds rather than adding a parallel mechanism:

  • RuntimeKernel registers user_question_request alongside sandbox_boundary_request and drops each on its settlement ack (user_question_answer_ack / sandbox_boundary_decision_ack); the existing per-turn cleanup already covers both.
  • listActiveSandboxBoundaryRequests becomes listActiveInteractions through SessionManager, IPC, and preload, returning the shared ActiveInteractionRequestEvent union now exported from @maka/core.
  • The composer queue's reconcileInteractions reconciles against the full live set instead of passing questions through untouched, and the renderer's hydration epoch is now bumped by question events too, so an in-flight read-back cannot resurrect a settled prompt.

Hosted sessions are unaffected: the kernel registry stays an embedded-side in-memory index, and the Question fact remains owned by the Host's interactionAuthority.

Closes #2072

Verification

The new E2E is red before the fix and green after — reload discards every event the surface saw while the runtime keeps the turn parked:

# fix stashed, spec kept
  1 failed
    e2e/ask-user-question.spec.ts:4:1 › rehydrates a prompt the surface never received live
  1 passed

# fix restored
  ✓  1 e2e/ask-user-question.spec.ts:4:1 › rehydrates a prompt the surface never received live (1.2s)
  ✓  2 e2e/ask-user-question.spec.ts:27:1 › answers three questions and continues the same fake-backend turn (1.3s)
  2 passed

All green locally:

  • npm run build, npm run lint, npm run format:check, @maka/desktop typecheck
  • runtime 3098 pass · runtime-host 628 pass · headless 1338 pass · desktop main 1585 pass · ui 317 pass · core 772 pass
  • full Playwright E2E: 64 passed
  • scripts/audit-alignment.mjs: all fixtures clean
  • Storybook build + smoke: 68 manifest checks, 73 catalog renders

New coverage: a runtime test asserting a question is listed until its answer ack lands, and two reconcileInteractions unit tests (order preservation + a question the surface never saw live).

Review follow-ups

Three external review passes (first-principles / correctness / test-quality) returned no P0–P1. Handled in 37ba26cf2:

  • Ack asymmetry. The renderer left an answered question queued until its tool_result, while the boundary sibling dequeued on the ack. The ack is where the runtime drops its owner, so both kinds settle there now; the two identical request cases fold into one.
  • Read-back shadowing. sessions:listActiveInteractions returned only the E2E fixture request when one was present — harmless while questions passed through reconciliation untouched, but now that the live set owns the whole queue it would drop a real unanswered request. Concatenated instead. Probed against the running fixture app: the fixture session's readHeader succeeds, so the added runtime call is safe.
  • Untested registry contracts. Added: a stopped turn releases the question it abandoned (mutation-verified — commenting out the turn-end release turns it red), and a boundary response aimed at a question's requestId settles nothing and leaves the entry intact.

Deferred with reason:

  • Stop-window ghost prompt. Between a stop and the run's turn-end release, a hydration can surface a prompt for a dead run, and answering it is silently dropped (respondToUserQuestion fans out to non-terminated generations only). This window predates the change and applies equally to sandbox-boundary requests; closing it means releasing owners on abort/complete, which is its own intent. Not in scope here.
  • Epoch-guard unit test. Would require extracting the guard into a helper that exists only to be tested; the read-back path it protects is covered by the E2E and the runtime tests.
  • Multi-question FIFO ordering at the kernel level needs two concurrently parked turns to construct — cost exceeds the risk for a ts sort.

Re-verified after the follow-ups: runtime 3099 pass, desktop main 1585 pass, full E2E 64 passed, format:check and lint clean.

A run that parks on AskUserQuestion could become unanswerable. The
session view only subscribes to the session it shows, so a request
raised while another session was active — or before the window
existed — never reached the surface, and nothing read it back.

Sandbox-boundary requests already held this invariant through a kernel
registry the shell reads on session change. Generalize that one path to
both request kinds instead of adding a second mechanism: RuntimeKernel
now registers `user_question_request` alongside
`sandbox_boundary_request` and drops each on its settlement ack, and
`listActiveSandboxBoundaryRequests` becomes `listActiveInteractions`
through SessionManager, IPC, and preload. The composer queue reconciles
against the full live set rather than passing questions through
untouched.

Closes #2072
…ing the read-back

Three follow-ups from review, all in the same seam the read-back created.

The renderer left an answered question in the composer queue until its tool
result arrived, while its boundary sibling already dequeued on the ack. The
ack is where the runtime drops its owner — the point the request stops being
answerable — so both kinds settle there now, and the two identical request
cases fold into one.

The IPC read-back returned only the E2E fixture request when one was present.
That was harmless while questions passed through reconciliation untouched;
now that the live set owns the whole queue, shadowing the runtime's list
would drop a real unanswered request. Concatenate instead.

Cover the two registry contracts the tests left open: a stopped turn releases
the question it abandoned (verified by mutation — commenting out the
turn-end release turns the test red), and a boundary response aimed at a
question's requestId settles nothing and leaves the entry intact.
@Astro-Han
Astro-Han force-pushed the fix/2072-user-question-rehydration branch from 37ba26c to 96ac14b Compare August 4, 2026 06:23
@Astro-Han
Astro-Han marked this pull request as ready for review August 4, 2026 06:34
@Astro-Han
Astro-Han merged commit eae1976 into main Aug 4, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(desktop): AskUserQuestion prompt is lost when the session is not the active view when the request arrives

1 participant