fix(tui): lifecycle-safe suspend and session-leave prune (ADR-047)#366
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the ADR-047 TUI stability hardening program (Phases 1–3 code):
process.once("SIGCONT")withcreateTerminalSuspendController(dispose on unmount, re-suspend replaces handler, resume/stop errors swallowed).putJsonWithTimeoutusesscheduleTuiTimeoutinstead of rawsetTimeout.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.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