Repository navigation
refactor(tui): consolidate runtime ownership - #117368
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 9:31 AM ET / 13:31 UTC. ClawSweeper reviewWhat this changesThe PR removes duplicate embedded-TUI goal, history, session-setting, state, and run-ID handling by delegating each behavior to its existing shared runtime owner. Merge readinessNo blocking correctness finding was established. This is a coherent owner-boundary refactor with strong real TUI/Gateway proof, but the Priority: P3 Review scores
Verification
How this fits togetherThe terminal UI uses either the Gateway or an embedded local backend to read session history, mutate session settings, and submit runs. The embedded backend turns those TUI requests into session and Gateway operations, then returns projected history and command results to the UI loop. flowchart LR
User[Terminal UI input] --> Handlers[Command handlers]
Handlers --> Backend[Embedded local backend]
Backend --> GoalOwner[Goal command owner]
Backend --> HistoryOwner[Gateway history owner]
GoalOwner --> SessionState[Session state]
HistoryOwner --> Transcript[Session transcript]
Backend --> View[Terminal UI output]
Decision needed
Why: The branch is explicitly maintainer-labeled and overlaps a later behavior fix in the same file; only the generated landing result can settle that final integration check. Before merge
Agent review detailsSecurityNone. PR surfaceSource -303, Tests +9. Total -294 across 10 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one canonical owner for each goal, history, setting, state, and run-tracking invariant, then land only the fresh-base merge result that preserves current submit-burst shutdown disposal. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR is a behavior-preserving refactor. The relevant verification is parity coverage through goal-command tests, embedded-backend tests, command-handler tests, and the reported real local PTY/Gateway run. Is this the best way to solve the issue? Yes. Consolidating the embedded TUI behind the established goal and Gateway-history owners is the best maintainable direction; retaining parallel transcript and goal implementations would create drift and duplicate policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 355295bfef4a. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via squash.
|
* origin/main: (491 commits) feat(gateway): advertise chat attachment limits on hello-ok (#116188) fix(ui): preserve full graphemes in session owner initials (#117350) refactor(tui): consolidate runtime ownership (#117368) fix(update): return failure when dirty checkout blocks update (#117452) fix(auto-reply): apply mixed chat directives in one session transaction (#117542) refactor(ui): unify channel status and setup controls (#117499) fix(doctor): preserve surviving lint selections (#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464) refactor(channels): consolidate lightweight plugin discovery (#117541) fix(imessage): prevent duplicate messages after delayed sends (#110853) refactor(memory): unify authoritative dreaming state and presentation (#117538) refactor(agents): consolidate main-session recovery ownership (#117383) fix(proxy-capture): make path-based session cleanup atomic (#98852) refactor(agents): consolidate compaction and context-engine ownership (#117482) fix(gateway): preserve Responses usage details (#117533) perf(gateway): skip empty session recovery stores (#117498) fix(ci): update canonical Kova performance pin (#117508) fix(system-agent): emit the wizard cancel hint once per message (#113731) refactor: dedupe secrets runtime snapshot fixtures (#117502) test(google): cover ready callback close precedence ...
* origin/main: (325 commits) fix(skills): preserve profile in ClawHub command hints (#117555) fix(cli): explain filtered plugin policy without unsafe recovery (#117556) fix(irc): strip markdown from outbound text (#112961) refactor(plugins): consolidate registry snapshots (#117561) fix(plugins): fail blocked enable commands (#117536) test(secrets): dedupe runtime state fixtures (#117563) feat(gateway): advertise chat attachment limits on hello-ok (#116188) fix(ui): preserve full graphemes in session owner initials (#117350) refactor(tui): consolidate runtime ownership (#117368) fix(update): return failure when dirty checkout blocks update (#117452) fix(auto-reply): apply mixed chat directives in one session transaction (#117542) refactor(ui): unify channel status and setup controls (#117499) fix(doctor): preserve surviving lint selections (#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464) refactor(channels): consolidate lightweight plugin discovery (#117541) fix(imessage): prevent duplicate messages after delayed sends (#110853) refactor(memory): unify authoritative dreaming state and presentation (#117538) refactor(agents): consolidate main-session recovery ownership (#117383) fix(proxy-capture): make path-based session cleanup atomic (#98852) refactor(agents): consolidate compaction and context-engine ownership (#117482) ... # Conflicts: # extensions/xai/realtime-voice-bridge.ts
* origin/main: (491 commits) feat(gateway): advertise chat attachment limits on hello-ok (openclaw#116188) fix(ui): preserve full graphemes in session owner initials (openclaw#117350) refactor(tui): consolidate runtime ownership (openclaw#117368) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) fix(gateway): preserve Responses usage details (openclaw#117533) perf(gateway): skip empty session recovery stores (openclaw#117498) fix(ci): update canonical Kova performance pin (openclaw#117508) fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731) refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502) test(google): cover ready callback close precedence ...
* origin/main: (325 commits) fix(skills): preserve profile in ClawHub command hints (openclaw#117555) fix(cli): explain filtered plugin policy without unsafe recovery (openclaw#117556) fix(irc): strip markdown from outbound text (openclaw#112961) refactor(plugins): consolidate registry snapshots (openclaw#117561) fix(plugins): fail blocked enable commands (openclaw#117536) test(secrets): dedupe runtime state fixtures (openclaw#117563) feat(gateway): advertise chat attachment limits on hello-ok (openclaw#116188) fix(ui): preserve full graphemes in session owner initials (openclaw#117350) refactor(tui): consolidate runtime ownership (openclaw#117368) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) ... # Conflicts: # extensions/xai/realtime-voice-bridge.ts
Summary
Root cause and owner boundary
The embedded TUI had accumulated parallel implementations of behavior already owned elsewhere: goal command execution in auto-reply, chat history projection in the gateway, repeated session-setting transactions in command handlers, and bounded run tracking in the run coordinator. The duplicate paths could drift while making the same state transitions harder to reason about.
This change keeps one canonical owner for each invariant and removes the connected shadow logic. TUI-specific selection invalidation and notification accessors remain in
tui.ts, because they own UI lifecycle behavior rather than ordinary storage.Removed paths
LOC
Behavior and sibling coverage
Proof
OPENCLAW_TUI_PTY_INCLUDE_LOCAL=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.tui-pty.config.tsgit diff --check: passedNo protocol, config, schema, dependency, or user-visible TUI contract changes.
Current-main integration disposition
39ed6db7d18328a372b44da03e0b62e263368468afe024e8c7990e9ced295f544c3cc5502c7136d4origin/main:b5a59e0a7d948a8b9021b97ab5c66248f12303d2src/tui/tui.tsgit merge-file -pfor that overlap exited 0, andgit merge-tree --write-tree origin/main HEADproduced clean merged tree701f35ce6f9048ee6e6ae7b8426f659abf3d3693createTuiRunIdTrackerowner cleanup and main’sdisposeSubmitBurstshutdown behavior fromcd4bd7c6c0ca860babbcbf0b68a066f3627ad547src/tui/tui.submit-handler.test.tspassed 25/25, including pending/future submission disposal coverageNo branch rebase or push is needed: the overlap composes cleanly, and the native SHA-pinned squash landing against a fresh base will preserve both sides. Maintainers should still inspect the native generated result before landing.