Repository navigation
feat(tui): report program status with OSC 7501 - #471
yujiachen-y wants to merge 2 commits into
Conversation
hetaoBackend
left a comment
There was a problem hiding this comment.
Requesting changes for one blocking issue; the rest are smaller points.
Blocking: blocked:permission and blocked:question are not reported with the default configuration.
app.ts wires agentInteraction to interactionFlow.agentReadback(), and agentReadback() returns undefined unless agentStatusEnabled is true. That flag is only set when the status line config lists build-mode, which status-line-config.md documents as not a default and as taking over the whole status line. So in a normal setup a permission prompt or a question reaches the terminal as working, not blocked. Only auth works, because it reads the account directly. The new tests inject agentInteraction straight into the flow, so they do not cover the default createTuiApp path, and docs/tui-capabilities.md currently claims more than the code does. Please decouple the interaction readback from build-mode (or give OSC 7501 its own readback) and add a test through the default path. I read this statically and have not triggered a real permission prompt, so please confirm on a real TUI.
Smaller points
- The spec is now at revision 0.4 (2026-10-10). The 0.3 to 0.4 change only affects feature-detection replies and removes terminfo, so it does not change behavior here, but the docs reference and link could be updated.
- There is no way to turn the sequence off. An env var or config switch would help for terminals that do not ignore unknown OSC cleanly. In tmux the sequence is silently dropped, since there is no DCS passthrough like
wrapForTmuxPassthroughin the notification code. - Missing login is computed in two places: the status store returns
errorwhilechrome-flow.tsmaps it toauth, so the title and notifications seeerrorwhile the terminal seesblocked:auth. Derivingauthin the status projection would keep them consistent. - Tests: the same-session login recovery change in
status-store.tshas no unit test, and there is no assertion that the emitted sequence contains onlystate,kindandapp. - Nit: the
report === undefinedcheck inupdateis unreachable.
The write path, de-duplication, exit handling, no content leakage and spec syntax all look right to me. Not verified: a real supporting terminal such as Rex, screen, Linux and Windows.
Interaction readback was gated on the build-mode status line item, so with the default configuration a pending permission or question was reported as working in both the terminal title and OSC 7501. The readback now always feeds the status projection; build-mode only controls rendering the [V] line. Missing login is derived once in the status projection as an error with loginRequired, so the [V] line keeps state=error while the title shows "Needs login" and OSC 7501 reports blocked:kind=auth from the same fact. Add tui.programStatus (default true) to disable OSC 7501 reports, document why reports are not wrapped for tmux passthrough, and reference protocol revision 0.4.
|
@hetaoBackend Thanks for the careful review. Addressed in 23f3a8e: Blocking: permission/question with the default configuration. Confirmed. A manual run in Ghostty showed Smaller points
|
Change
Report the interactive TUI's current program state through OSC 7501 revision 0.4, so supporting terminals can distinguish running work, approval/question/login waits, completion and failure without scraping titles or screen content.
The emitter reuses the existing runtime status projection and sends only fixed
state,kindandapp=mcodemetadata on changes. Cancellation/suspension report idle; resume reapplies the current state; done/error survive normal exit. Output is TTY-only and absent from headless exec and ACP, and can be disabled withtui.programStatus: false. Existing title and notification settings are independent. No dependencies, heartbeat, terminal-brand checks, capability round trips or tmux passthrough wrapping are added; the protocol treats each multiplexer pane as its own terminal.Interaction readback no longer depends on the
build-modestatus line item. Previously, with the default configuration, a pending permission or question was projected as running, so both the terminal title and OSC 7501 reported working instead ofNeeds approval/blocked:kind=permission.build-modenow only controls rendering of the[V]line.Make missing login a recoverable account-derived condition in the existing projection, so authenticating in the same session restores working/completed reports instead of permanently latching an error. The projection derives it once: the
[V]line keepsstate=error, the title showsNeeds login, and OSC 7501 reportsblocked:kind=auth. Genuine fatal errors retain their existing behavior and are not downgraded to a login wait.enhancement,cli,tui.tui.programStatussetting, and the[V]contract note that a login block clears after sign-in.Validation
createTuiAppwithoutbuild-mode: a permission prompt sets the title toNeeds approvaland reportsblocked:kind=permission; after approval the question setsNeeds inputand reportsblocked:kind=question. Reverting the readback gate makes this test fail withWorking.[V]error,Needs logintitle,blocked:kind=auth, recovery to ready/run/done, fatal error not downgraded), emitted sequences limited tostate/kind/appkeys,tui.programStatusconfig loading, and disabled reports.pnpm typecheck;pnpm lint.pnpm verifyfull profile on clean commit23f3a8e(macOS arm64), all 15 applicable gates. Skipped as not applicable:test:windows,test:release-package.main.Publication and contribution checks
release/public-source.json; tests extend existing declared suites.Maintainer handoff
Publication scope: one first-party TUI terminal-output module added; no license changes or imported implementation.
Shared-source port: pending.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.