Skip to content

refactor(tui): remove test-only shutdown timer hooks - #140432

Merged
steipete merged 1 commit into
mainfrom
steipete/deletion-tui-shutdown-test-hooks
Sep 6, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/deletion-tui-shutdown-test-hooks

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

TUI shutdown maintained custom timer and process-sink variants used only by its tests. That duplicated the native Node path that standalone TUI and setup actually execute.

Why This Change Was Made

Use native timers, stderr, and process exit in the shutdown owner; exercise timer state and process sinks through Vitest instead of injecting alternative implementations. Repository-wide callers use none of the removed hooks. Setup's delayMs override remains, preserving its longer local cleanup budget. The TUI helpers have no declared package or plugin SDK subpath contract.

History: dc8f90197e6 introduced the drained-teardown exit path; f4871eb86b4 added custom/native timer branching for test typing; 78796d8e230 established the setup cleanup budget that this change retains. Follow-up deletion work for #135868.

User Impact

No intended behavior change. Shutdown ordering, terminal restoration after transport failure, error reporting, watchdog deadlines, unref behavior, and cancellation remain unchanged. Net production −37 lines; tests −7 lines.

Evidence

  • Baseline: 88 TUI tests passed. After: 88 TUI and 75 setup-finalization tests passed.
  • Fake-backend PTY lane: 99 tests across 8 files passed. This runs the real TUI loop with a fake backend; it does not establish live Gateway/provider or embedded-persistence behavior.
  • Full node scripts/check-changed.mjs: exit 0, including typechecking, lint, guards, dead exports, and import cycles. Independent Codex review: scoped-clean through P2.
  • No test cases were removed. Coverage mappings for removed injected-hook assertions: src/tui/tui.test.ts:1007 retains terminal cleanup after transport rejection and now verifies the native timer is removed; :1093 checks the real watchdog's unreferenced state; :1102 retains deadline/diagnostic/exit proof through fake timers and process spies. The embedded shutdown cancellation case at :1080 remains.
  • ClawSweeper reviewed exact head ef7823423d84d62bfcfa8322162ae768a4c28f49: no findings, security concerns, or rank-up changes requested. Maintainer source review agrees.

@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 6, 2026 20:37
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 6, 2026
@steipete
steipete force-pushed the steipete/deletion-tui-shutdown-test-hooks branch from 8a73e19 to ef78234 Compare September 6, 2026 20:38
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 4:52 PM ET / 20:52 UTC.

ClawSweeper review

What this changes

Removes test-only timer and process-output hooks from terminal UI shutdown and updates tests to observe native timers and process spies.

Merge readiness

✅ Ready for maintainer review

This remains useful, bounded cleanup: current main retains the test-only hooks, and the reviewed patch preserves production shutdown behavior. No actionable findings remain from this review or the supplied prior review.

Priority: P3
Reviewed head: ef7823423d84d62bfcfa8322162ae768a4c28f49

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused simplification with preserved caller contracts, meaningful retained tests, and no concrete correctness or security findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER status exempts this maintainer-authored cleanup from the external proof gate. Reported TUI/setup tests and fake-backend PTY checks support shutdown coverage without establishing live Gateway or provider behavior; no authority boundary changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER status exempts this maintainer-authored cleanup from the external proof gate. Reported TUI/setup tests and fake-backend PTY checks support shutdown coverage without establishing live Gateway or provider behavior; no authority boundary changes.
Evidence reviewed 7 items Verified introduced change: The local diff matches the complete host-provided introduction patch. It removes injection branches while preserving shutdown ordering, error aggregation, timer cancellation, delay calculation, diagnostic text, and exit codes.
Production callers preserve the existing contract: The base-tree caller search finds removed injection arguments only in TUI tests. Production callers use native behavior; setup passes the retained delayMs and cancels its cleanup timer before scheduling the standalone fallback.
Current main and release still retain the hooks: Inspected the shutdown implementation at fetched main and v2026.9.2; both retain custom timer injection. The cleanup is therefore still distinct work, with no supplied merged replacement.
Findings None None.
Security None None.

How this fits together

The terminal UI shutdown owner stops active work, releases the terminal, and bounds cleanup with an exit watchdog. Standalone CLI and setup callers use it, with setup retaining a longer temporary-Gateway cleanup deadline.

flowchart TD
  A[Terminal exit request] --> B[Shutdown owner]
  B --> C[Stop active work and connection]
  C --> D[Restore terminal]
  D --> E[Finish terminal UI]
  B --> F[Unreferenced exit watchdog]
  E --> G[Standalone return or setup cleanup]
  F --> H[Force exit at deadline]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -37, Tests -7. Total -44 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 11 48 -37
Tests 1 18 25 -7
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 29 73 -44

Review metrics

None.

Technical review

Best possible solution:

Keep one native shutdown timer path while preserving standalone watchdog behavior and setup's longer, cancelable cleanup budget.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR removes unused test seams rather than reporting a runtime defect; caller inspection confirms production already uses the native path.

Is this the best way to solve the issue?

Yes. Removing the alternate implementations and testing native timer state preserves the existing owner and avoids maintaining test-only production branches.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 800846921e1b.

Labels

Label justifications:

  • P3: This is a focused internal cleanup with no intended user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER status exempts this maintainer-authored cleanup from the external proof gate. Reported TUI/setup tests and fake-backend PTY checks support shutdown coverage without establishing live Gateway or provider behavior; no authority boundary changes.

Evidence

What I checked:

  • Verified introduced change: The local diff matches the complete host-provided introduction patch. It removes injection branches while preserving shutdown ordering, error aggregation, timer cancellation, delay calculation, diagnostic text, and exit codes. (src/tui/tui.ts:513, ef7823423d84)
  • Production callers preserve the existing contract: The base-tree caller search finds removed injection arguments only in TUI tests. Production callers use native behavior; setup passes the retained delayMs and cancels its cleanup timer before scheduling the standalone fallback. (src/wizard/setup.finalize.ts:1058, f6c36b651f43)
  • Current main and release still retain the hooks: Inspected the shutdown implementation at fetched main and v2026.9.2; both retain custom timer injection. The cleanup is therefore still distinct work, with no supplied merged replacement. (src/tui/tui.ts:511, 800846921e1b)
  • Release comparison: The latest supplied release retains TuiProcessExitTimer, TuiProcessExitTimeout, and the custom/native shutdown timer branch. (src/tui/tui.ts:511, 3928bad9badf)
  • Retained behavioral coverage: Read the complete changed tests and neighboring shutdown cases. They retain terminal restoration after transport failure, embedded cancellation, unreferenced timers, and the 2000 ms diagnostic/exit deadline. afterEach restores real timers and process spies. (src/tui/tui.test.ts:1007, ef7823423d84)
  • Validation and review continuity: The captured PR body reports 88 TUI tests, 75 setup-finalization tests, 99 fake-backend PTY tests, and a successful changed-file gate. These were not rerun during this read-only review. The supplied prior review covers the same head and contains no findings or published rank-up moves. Scoped TUI policy explicitly limits fake-backend PTY evidence to that boundary. (src/tui/AGENTS.md:3, ef7823423d84)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Leon-SK668: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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-09-06T20:43:47.540Z sha ef78234 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-06T20:48:37.565Z sha ef78234 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 7d1dc25 into main Sep 6, 2026
186 checks passed
@steipete
steipete deleted the steipete/deletion-tui-shutdown-test-hooks branch September 6, 2026 20:55
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 6, 2026
…ig-ref

* origin/main: (31 commits)
  docs(web): split the Control UI page into task pages (#140437)
  fix: tool_search rejects calls that send both query and queries (#140310)
  fix(update): preserve rollback and truthful serving reports (#140419)
  fix: restore context when CLI recovery starts a fresh session (#140294)
  refactor(tests): retain transport-driven auth dismissal coverage (#140430)
  fix: stop unfinished subagents before resetting a conversation (#140417)
  fix(models): cap configured output at the final context window (#140436)
  refactor(mcp): reuse transport config normalization (#140439)
  test(gateway): preserve saved config in auth reload fixture (#140433)
  fix(plugins): inherit active config for embedded agent runs (#140435)
  refactor(tui): remove test-only shutdown timer hooks (#140432)
  fix(agents): preserve channel silent-reply guidance (#138345)
  fix(tasks): cancel resumed yielded subagent tasks (#140410)
  refactor(doctor): share compaction config traversal (#140330)
  fix(doctor): restore LINE and Mattermost account promotion (#136045)
  docs: remove the empty release-sections nav group (#140427)
  fix(tooling): omit Codex machine squash credit (#140420)
  chore(ui): refresh control ui locales (#140384)
  refactor(plugin-sdk): reuse native approval input contracts (#140415)
  fix: silent model WebSocket streams hang past the idle timeout (#140335)
  ...

# Conflicts:
#	docs/web/control-ui.md
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
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. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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