Skip to content

refactor(tui): consolidate runtime ownership - #117368

Merged
steipete merged 1 commit into
mainfrom
codex/goal100k-tui-runtime-owner-0801-2d45
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/goal100k-tui-runtime-owner-0801-2d45

Conversation

@steipete

@steipete steipete commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • make the auto-reply goal command executor the canonical owner for both auto-reply and embedded TUI goal behavior
  • route embedded history through the gateway history owner instead of duplicating transcript reads, CLI merge, compaction enrichment, and display projection
  • collapse TUI session-setting updates behind one transaction helper and ordinary mutable TUI state behind the canonical state object
  • share bounded run-id tracking through the session run coordinator

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

  • embedded goal parsing, status mutation, prompt reconstruction, and continuation formatting
  • embedded direct transcript/CLI history merging and local display-message projection
  • repeated model/think/verbose/trace/fast/reasoning/usage/elevated/activation mutation scaffolding
  • ordinary TUI shadow locals plus getter/setter forwarding facade
  • duplicate local and BTW bounded run-id set implementations

LOC

  • production: +376 / -679 = -303 LOC
  • tests: +67 / -58 = +9 LOC
  • total: +443 / -737 = -294 LOC

Behavior and sibling coverage

  • goal start/resume/edit/status/clear behavior remains covered through the canonical command handler and embedded-backend delegation
  • embedded history preserves runtime prewarm, selected-agent scoping, in-flight run projection, thinking defaults, compaction markers, hard history budgets, and session metadata
  • session-setting error text, stale-selection suppression, refresh hooks, and per-setting projections remain unchanged
  • TUI selection-generation accessors still own run invalidation and approval/suggestion notifications
  • run trackers preserve FIFO eviction at 200 entries, forget, clear, and local/BTW independence

Proof

  • focused unit tests: 327 passed across TUI and goal command suites
  • final focused regression run after parity adjustments: 239 passed
  • real Linux PTY suite with local embedded backend and real Gateway WebSocket: 65 passed across 3 files
    • OPENCLAW_TUI_PTY_INCLUDE_LOCAL=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.tui-pty.config.ts
  • full changed gate on Blacksmith Testbox: passed, exit 0
  • git diff --check: passed
  • formatter: passed using the prepared normal checkout dependency install
  • fresh xhigh autoreview on the final diff: clean, 0.98 correctness confidence, no actionable findings

No protocol, config, schema, dependency, or user-visible TUI contract changes.

Current-main integration disposition

  • PR head: 39ed6db7d18328a372b44da03e0b62e263368468
  • merge base: afe024e8c7990e9ced295f544c3cc5502c7136d4
  • audited origin/main: b5a59e0a7d948a8b9021b97ab5c66248f12303d2
  • current main changed 200 paths since the merge base; exactly one intersects the 10 paths changed by this PR: src/tui/tui.ts
  • git merge-file -p for that overlap exited 0, and git merge-tree --write-tree origin/main HEAD produced clean merged tree 701f35ce6f9048ee6e6ae7b8426f659abf3d3693
  • inspection of the merged file preserves both this PR’s canonical createTuiRunIdTracker owner cleanup and main’s disposeSubmitBurst shutdown behavior from cd4bd7c6c0ca860babbcbf0b68a066f3627ad547
  • exact synthetic merged-result Testbox proof: src/tui/tui.submit-handler.test.ts passed 25/25, including pending/future submission disposal coverage

No 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.

@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Aug 1, 2026
@steipete
steipete marked this pull request as ready for review August 1, 2026 10:59
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 9:31 AM ET / 13:31 UTC.

ClawSweeper review

What this changes

The 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 readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking correctness finding was established. This is a coherent owner-boundary refactor with strong real TUI/Gateway proof, but the maintainer label requires a human landing review of the fresh-base generated result because current main also changed src/tui/tui.ts.

Priority: P3
Reviewed head: 39ed6db7d18328a372b44da03e0b62e263368468
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong real TUI/Gateway proof and a coherent ownership cleanup are present; human inspection of the fresh-base generated merge result remains appropriate.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body provides after-fix real Linux PTY proof for tui --local with the local embedded backend and a real Gateway WebSocket, reporting 65 passing tests; this directly exercises the changed terminal UI path.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body provides after-fix real Linux PTY proof for tui --local with the local embedded backend and a real Gateway WebSocket, reporting 65 passing tests; this directly exercises the changed terminal UI path.
Evidence reviewed 6 items Canonical goal owner: The proposed shared executor preserves action-specific goal mutations, continuation prompts for start/resume, and auto-reply metadata synchronization, replacing duplicated embedded handling with one owner.
History contract reuse: The embedded backend calls the Gateway history-page owner before applying its existing compaction-marker and byte-budget steps; that owner handles transcript reads, CLI-import merging, and display projection.
Gateway history behavior: The Gateway history-page owner reads the session transcript, handles imported CLI history, projects display messages, and preserves pagination/budget behavior that the embedded path previously duplicated.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Decision needed

Question Recommendation
Does the native merge result against current main retain both this ownership consolidation and the current submit-burst shutdown disposal before landing? Inspect and land the fresh-base result: Confirm disposeSubmitBurst() remains in the shutdown path and land if the exact generated result preserves it alongside the run-tracker cleanup.

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

  • Resolve merge risk (P1) - Current main changed src/tui/tui.ts after the PR base; although the read-only three-way output contained no conflict marker, the native generated result must retain disposeSubmitBurst() shutdown behavior before landing.
Agent review details

Security

None.

PR surface

Source -303, Tests +9. Total -294 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 6 376 679 -303
Tests 4 67 58 +9
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 443 737 -294

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    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.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best 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.

Labels

Label justifications:

  • P3: This is a behavior-preserving internal ownership cleanup with strong focused proof, not an urgent user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides after-fix real Linux PTY proof for tui --local with the local embedded backend and a real Gateway WebSocket, reporting 65 passing tests; this directly exercises the changed terminal UI path.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix real Linux PTY proof for tui --local with the local embedded backend and a real Gateway WebSocket, reporting 65 passing tests; this directly exercises the changed terminal UI path.

Evidence

What I checked:

  • Canonical goal owner: The proposed shared executor preserves action-specific goal mutations, continuation prompts for start/resume, and auto-reply metadata synchronization, replacing duplicated embedded handling with one owner. (src/auto-reply/reply/commands-goal.ts:131, 39ed6db7d183)
  • History contract reuse: The embedded backend calls the Gateway history-page owner before applying its existing compaction-marker and byte-budget steps; that owner handles transcript reads, CLI-import merging, and display projection. (src/tui/embedded-backend.ts:618, 39ed6db7d183)
  • Gateway history behavior: The Gateway history-page owner reads the session transcript, handles imported CLI history, projects display messages, and preserves pagination/budget behavior that the embedded path previously duplicated. (src/gateway/server-methods/chat-history-pages.ts:206, bba7b939ce3d)
  • Fresh-main overlap: Current main commit 355295b has one subsequent TUI change: commit cd4bd7c adds submit-burst disposal on shutdown. A read-only three-way merge-tree marks the file changed on both sides but emitted no conflict markers; the native generated merge result remains the final landing artifact to inspect. (src/tui/tui.ts:1533, 355295bfef4a)
  • Diff hygiene and focused coverage: The proposed revision is whitespace-clean; its updated tests cover delegated history reads, embedded goal continuation prompts, command-handler delivery, and FIFO run-ID cleanup. The PR body additionally reports 65 passing real local PTY/Gateway checks and green exact-head CI. (src/tui/embedded-backend.test.ts:1018, 39ed6db7d183)
  • Area provenance: The current-main TUI shutdown behavior overlapping this file dates to commit cd4bd7c, authored by Peter Steinberger; the refactor head is also authored by Peter Steinberger, making this the strongest current routing candidate. (src/tui/tui.ts:1533, cd4bd7c6c0ca)

Likely related people:

  • steipete: Authored the proposed ownership refactor and the subsequent current-main TUI shutdown fix in the same central file. (role: recent TUI-area contributor; confidence: high; commits: 39ed6db7d183, cd4bd7c6c0ca; files: src/tui/tui.ts, src/tui/embedded-backend.ts, src/auto-reply/reply/commands-goal.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Inspect the native merge result against current main and confirm the submit-burst shutdown regression remains covered before landing.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-01T11:35:43.081Z sha 39ed6db :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T11:54:25.341Z sha 39ed6db :: needs maintainer review before merge. :: none

@steipete
steipete merged commit d876a83 into main Aug 1, 2026
198 of 207 checks passed
@steipete
steipete deleted the codex/goal100k-tui-runtime-owner-0801-2d45 branch August 1, 2026 18:21
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 1, 2026
* 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
  ...
vincentkoc added a commit that referenced this pull request Aug 1, 2026
* 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
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* 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
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant