Skip to content

test(terminal): add direct coverage for session state machine and auto-restart cap - #560

Open
Atman36 wants to merge 1 commit into
cline:mainfrom
Atman36:test/session-state-machine-coverage
Open

test(terminal): add direct coverage for session state machine and auto-restart cap#560
Atman36 wants to merge 1 commit into
cline:mainfrom
Atman36:test/session-state-machine-coverage

Conversation

@Atman36

@Atman36 Atman36 commented Jul 7, 2026

Copy link
Copy Markdown

Why

reduceSessionTransition (src/terminal/session-state-machine.ts) is the single reducer that maps process/hook events to reviewReason + session state — the chain that decides whether a finished run waits for review. It currently has no dedicated test file (it is only exercised indirectly through session-manager mocks). Likewise, the PTY auto-restart cap (MAX_AUTO_RESTARTS_PER_WINDOW) is never exercised at its boundary — the "stuck retrying" scenario from #105.

This PR adds tests only — zero behavior changes — to lock in the current contract of that state chain (context: #524 and #105 both hinge on it).

What's covered

  • New test/runtime/terminal/session-state-machine.test.ts (15 tests): every switch case of reduceSessionTransition incl. default, process.exit with exit 0 → reviewReason: "exit", nonzero → "error", null exit code → "error", interrupted flag → "interrupted" + state "interrupted", pid clearing, and the canReturnToRunning value branch (reviewReason: "error" is resumable back to running).
  • session-manager-auto-restart.test.ts (append-only): cap boundary — 3 qualifying exits within the 5s window restart, the 4th is refused.

Verification

npm run check fully green (biome, typecheck, full root suite — 60 files / 597 tests); npm run build exit 0; no src/ changes in the diff.

…o-restart cap

reduceSessionTransition had zero dedicated tests despite being the single
reducer mapping process exit/hook events to reviewReason/state that issues
cline#524 and cline#105 hinge on. Also exercise the MAX_AUTO_RESTARTS_PER_WINDOW
boundary (the "stuck retry" scenario from cline#105) so both mechanisms have a
documented, reviewable spec. No behavior changes.
@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown

PR author is not in the allowed authors list.

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