Skip to content

fix(tui): lifecycle-safe suspend and session-leave prune (ADR-047)#366

Merged
automatosx merged 3 commits into
mainfrom
fix/tui-stability-adr-047
Jul 11, 2026
Merged

fix(tui): lifecycle-safe suspend and session-leave prune (ADR-047)#366
automatosx merged 3 commits into
mainfrom
fix/tui-stability-adr-047

Conversation

@automatosx

Copy link
Copy Markdown
Contributor

Summary

Implements the ADR-047 TUI stability hardening program (Phases 1–3 code):

  • Lifecycle-safe terminal suspend — replace raw process.once("SIGCONT") with createTerminalSuspendController (dispose on unmount, re-suspend replaces handler, resume/stop errors swallowed).
  • Timer consistencyputJsonWithTimeout uses scheduleTuiTimeout instead of raw setTimeout.
  • Session-leave prune — when leaving a session (or switching sessionID), drop heavy transcript projection (message/part/diff/todo/risk/goal) while keeping list rows and permission/question/status. Re-entry reloads via existing session sync + generation guards.
  • Regression locks — unit tests for suspend + leave prune, plus wiring checks so call sites do not regress.

Internal PRD/ADR/tech-spec live under gitignored .internal/tui-stability/.

Note: pre-commit hook also refreshed models-snapshot.json (repo-standard models.dev update).

Test plan

  • pnpm --dir packages/ax-code exec vitest run test/cli/tui/terminal-suspend.test.ts test/cli/tui/sync-session-store.test.ts test/cli/tui/stability-phase-wiring.test.ts test/cli/tui/timer.test.ts
  • CI green
  • Manual: open session A → session B → confirm A transcript reloads after re-open
  • Manual (optional): terminal suspend/resume keybind if available

Harden OpenTUI lifecycle and long-session memory: manage SIGCONT via a
named suspend controller, route putJson abort through scheduleTuiTimeout,
and drop heavy transcript projection when leaving a session while keeping
list rows and permission/question state. Add unit and wiring regression
tests for the new paths.
Leave-prune wiring shifted line numbers in session/index.tsx and
introduced a lifecycle_scan map_growth hit on the prune produce path
(which shrinks maps). Accept the rebased findings so repo-structure
audit matches the ADR-047 TUI stability change.
Leave prune dropped heavy store fields but left fullSyncedSessions set,
so the next session.sync without force early-returned and showed an empty
transcript. Wire sync.session.clear on leave, epoch-gate applySnapshot
when clear races an in-flight fetch, and cover leave→re-enter with
integrated controller+store tests.
@automatosx
automatosx merged commit cfe872c into main Jul 11, 2026
12 checks passed
@automatosx
automatosx deleted the fix/tui-stability-adr-047 branch July 11, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant