Repository navigation
feat(web-shell): expose assistant turn settlement #10398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 3 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
fac47ff
feat(web-shell): expose assistant turn settlement
dreamWB e4e4880
docs(web-shell): clarify settlement message availability
dreamWB 5bcf741
fix(web-shell): harden turn settlement delivery
dreamWB 945c806
fix(web-shell): harden prompt settlement recovery
dreamWB bc1d3b6
fix(web-shell): settle assistant turns in split view
dreamWB bc2961b
fix(web-shell): fail closed restored prompt correlation
dreamWB bb0139e
fix(webui): settle production-shaped replay terminals
dreamWB 981cc54
Merge remote-tracking branch 'origin/main' into codex/assistant-turn-…
wenshao b3b8ab8
fix(web-shell): follow in-package daemon relocation
dreamWB 668fdfd
fix(web-shell): harden assistant turn settlement delivery
dreamWB 5605d2c
fix(web-shell): scope journal incompleteness to one turn
dreamWB 4b34ad3
Merge branch 'main' into codex/assistant-turn-settled-event
wenshao 9ad7be2
fix(web-shell): stabilize journal marker ownership
dreamWB 78dc634
Merge remote-tracking branch 'origin/main' into codex/assistant-turn-…
dreamWB 201ad84
fix(web-shell): preserve live journal marker claims
dreamWB b106023
Merge branch 'main' into codex/assistant-turn-settled-event
dreamWB 822e464
Merge branch 'main' into codex/assistant-turn-settled-event
dreamWB 63678c6
Merge branch 'main' into codex/assistant-turn-settled-event
dreamWB 4ca4e4c
Merge branch 'main' into codex/assistant-turn-settled-event
dreamWB 97026b5
Merge remote-tracking branch 'origin/main' into codex/assistant-turn-…
dreamWB 288118c
fix(web-shell): correct turn settlement across resyncs and replacements
dreamWB File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
docs/design/2026-08-28-web-shell-assistant-turn-settlement.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Web Shell assistant turn settlement | ||
|
|
||
| ## Goal | ||
|
|
||
| Expose a host callback for the semantic end of an assistant turn without requiring consumers to infer completion from prompt-status transitions or scan a changing transcript. | ||
|
|
||
| The callback is a generic Web Shell lifecycle contract. It is not tied to any embedding product, artifact projection, or workspace side effect. | ||
|
|
||
| ## Contract | ||
|
|
||
| `onAssistantTurnSettled` receives: | ||
|
|
||
| - `sessionId` and daemon-assigned `promptId`; their tuple is the stable idempotency key; | ||
| - `outcome`: `completed`, `cancelled`, or `failed`; | ||
| - the daemon `stopReason` when a turn completed; | ||
| - `transcriptComplete`, which is false when replay integrity is degraded or bounded live-journal repair could not restore the complete turn before failing or being discarded; | ||
| - the final visible assistant message when it remains available in the committed current-session transcript; turns without assistant content and events delivered across a session switch omit it, while cancelled and failed turns may carry partial content. | ||
|
|
||
| The callback is optional. Existing `onSessionChange({ type: 'turn_complete' })` behavior remains unchanged. | ||
|
|
||
| ## Lifecycle and ordering | ||
|
|
||
| The daemon prompt terminal (`turn_complete` or `turn_error`) is authoritative. Prompt-status `idle`, render completion, and history replay are not terminal signals. | ||
|
|
||
| If a process or transport fails without delivering either terminal event, no settlement is published. This fail-closed behavior avoids reporting an unproven completion; connection health remains a separate lifecycle. | ||
|
|
||
| The daemon session provider publishes a settlement only after it has: | ||
|
|
||
| 1. flushed buffered transcript deltas; | ||
| 2. applied `assistant.done` and the terminal event's own transcript projection; | ||
| 3. completed live-journal repair when a truncated active turn can be repaired, or classified the retained transcript as incomplete before discarding an unsuccessful repair. | ||
|
|
||
| Ordinary session load, branch/split transcript replay, and older-history pagination never publish settlements. A terminal received while reconnecting an already active prompt may publish because it is a previously unseen live lifecycle transition, not history playback. | ||
|
|
||
| Duplicate terminal delivery is suppressed for the lifetime of a mounted session provider using `(sessionId, promptId)`. Hosts must use the same key for durable idempotency across remounts. | ||
|
|
||
| `prompt_cancelled` is a cancellation request, not a confirmed prompt terminal, and does not publish a settlement by itself. Waiting for permission or `ask_user_question` also does not publish. | ||
|
|
||
| Listener failures are isolated from daemon stream processing. Artifact, tool-result persistence, and workspace projection keep their independent lifecycle. | ||
|
|
||
| ## Implementation boundary | ||
|
|
||
| The WebUI daemon session layer owns authoritative terminal observation, transcript ordering, replay suppression, repair, and duplicate suppression. It exposes a subscription hook with prompt-level settlement metadata. | ||
|
|
||
| Web Shell owns projection of the final visible assistant message and the public callback type. It does not add daemon routes or change daemon event payloads. | ||
|
|
||
| ## Tests | ||
|
|
||
| - `TC-01`: normal terminal publishes once with the complete final message. | ||
| - `TC-02`: assistant/tool/assistant turn returns the final assistant message. | ||
| - `TC-03`: permission or `ask_user_question` waiting does not publish. | ||
| - `TC-04`: confirmed cancellation publishes `cancelled`; cancellation request alone does not. | ||
| - `TC-05`: `turn_error` publishes `failed` and preserves any partial assistant message. | ||
| - `TC-06`: reconnect catch-up for an active local prompt publishes once. | ||
| - `TC-07`: ordinary history replay and older-history pagination do not publish. | ||
| - `TC-08`: duplicate terminal events publish once for a mounted provider. | ||
| - `TC-09`: session switch cannot attribute an old terminal to the new session. | ||
| - `TC-10`: successful live-journal repair delays publication until the repaired transcript is committed; failed repair marks `transcriptComplete: false`. | ||
| - `TC-11`: listener exceptions do not interrupt subsequent daemon events or listeners. | ||
| - `TC-12`: clearing or replacing a repair episode releases its held settlement once with `transcriptComplete: false`. | ||
| - `TC-13`: degraded catch-up replay and unrecoverable live-journal markers publish with `transcriptComplete: false`. | ||
| - `TC-14`: a terminal after reconnect consumes the restored-active snapshot and allows live or catch-up repair to finish. | ||
|
|
||
| No visual UI changes are introduced, so browser screenshot validation is not applicable. Package unit tests, build, typecheck, and repository preflight are the delivery gates. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.