← Back to Pull requests

fix(cli): fence in-flight retractions across session re-keys and switches #6070

Closed
unknown closed this pull request without merging on Oct 12, 2026 01:22 UTC
View on GitHub
unknown unknown commented on Oct 11, 2026 14:49 UTC
Author

Split from #5265 per @liugddx's scope review: the retraction/switch fencing for pre-existing plain-text races lives on its own branch, so each half can be reviewed and reverted independently.

What's here


  • settleRetractions / trackRetraction and the retraction fences keyed on the owning session

  • holdSwitchWindow across session re-keys: /session, side open/close, /rewind, and now /new

  • the detaching pre-guards on goToSession / openSideConversation / newSession

  • drain-before-re-key wrappers on runSessionSwitch / runMidTurnSwitch / rewind / openSide / closeSide

  • the side-close kept-draft abort and live-draft merge; side-open moves the editor to the side draft

  • Shift+Left stays blocked while a navigation re-key is in flight

  • new in this split: /new parks behind an in-flight retraction and holds the switch window the way /session does — the P3 from the #5265 review of 4d7764420 (586759fc7)
  • The quote-staging half stays in #5265; this branch removes it, so the net diff here is fencing-only (runner + its tests + one check-tui-copy.mjs whitelist line). Roughly 19 plain-text race tests, none involving quotes. Per the review suggestion, the four "drains a retraction before X" tests and the three "blocks Shift+Left while X" tests are consolidated into two table-driven tests (assertion semantics unchanged).

    Relationship to #5265


  • Known layering: the side-close abort region is split across the two PRs — the plain-text kept-draft abort here, the quote-only "staged quotes were kept" abort in #5265. Whichever of the two merges second gets rebased so both halves survive; handled at merge time.

  • Same pattern for the check-tui-copy.mjs whitelist: each PR adds its own line.
  • Verification


  • pi-tui-runner 257/257 (at 4d7764420 the suite was 278 with 2 Windows-only SIGTERM fails noted by the reviewer; not reproduced locally — the 17 quote tests moved to #5265, 9 tests consolidated into 2 table-driven ones, +1 new /new test)

  • runtime-host-session-driver 85/85, tui-copy-catalog 8/8, pi-transcript 113 pass / 3 skip

  • biome check on the changed files clean; check:asf-headers pass; check-tui-copy ok

  • TDD: drains a retraction started before /new re-keys runs red before 586759fc7 (/new executed immediately: 1 !== 0) and green after
  • Two test assertions were re-graded to plain-text equivalents when the quote half left: discards a retraction after a mid-turn switch now asserts the editor does not contain the restored text (instead of a status-line quote count), and serializes a mid-turn switch asserts retractedTexts.at(-1) instead of a quote payload. Happy to tighten either back up.

    cc @liugddx for the scope re-check.

    AI use

    Select exactly one:

  • No generative tool made a substantive contribution

  • Generative tooling made a substantive contribution
  • Tool(s) and scope: GLM-5.3-Flash (ZCode) implemented the retraction/switch fencing changes and their tests under human direction and review. The affected commits carry Generated-by: GLM-5.3-Flash (ZCode) trailers, and the final squash commit should keep that trailer.

    Checklist

  • Tests cover the change and fail without it

  • Lint, format, typecheck and the affected suites pass locally
  • Does this PR entail a change in behavior?

  • Yes — in-flight Shift+Left retractions are drained before session re-keys (/session, /new, side open/close, /rewind), so their text is no longer lost or applied to the wrong session.

  • No
  • Diff: 439 lines (+329 / -110) across 5 files Reviewer: liugddx Review duration: 632m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 439 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.364
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #6070"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.3% (MEDIUM) · Higher = larger blast radius
    45.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.9% · Safe to merge
    17.9%
    Repository