← Back to Pull requests

fix(tui): preview Open terminals with the composition the window opener checks #1167

Closed
unknown closed this pull request without merging on Oct 11, 2026 20:44 UTC
View on GitHub
unknown unknown commented on Oct 11, 2026 20:19 UTC
Author

The TUI's Open terminals action was refused on every attempt on a machine without Herdr where cmux is running: "The terminal view changed since preview. Refresh the preview before opening." This makes it reach the plain-tmux window again, as on 0.6.9.

The cause:

  • The TUI previews a view and passes the preview's planId to rig terminal open --window --expected-plan <planId> -- <view>.

  • That window opener previews with Herdr's composition (provider=herdr), falls back to plain tmux when Herdr is missing, and refuses when the plans differ.

  • The provider is part of the plan hash. A provider-less preview now picks the first available provider, Herdr then cmux (#1071). So with no Herdr and a live cmux, the TUI's plan was cmux's while the window opener's was Herdr's.
  • The change:

  • The TUI's preview asks for Herdr's composition (&provider=herdr), the one the window opener checks against: one line in packages/tui/src/daemon-client.ts.

  • The window launch still names no provider, so a missing Herdr still takes the plain-tmux fallback.

  • The plan check, --expected-plan and the plan hash are unchanged. A provider-less open that isn't a window still chooses cmux.

  • This doesn't add cmux windows: the TUI's window path opens with Herdr, or plain tmux without Herdr.
  • Measured before and after, one test on three commits in CI. It uses the real daemon terminal routes and terminal service over localhost (provider selection, composition, plan hashing), the real TUI preview client, and the real CLI window opener with its plain-tmux fallback on an isolated tmux server. The stubs are named: the provider adapters' availability (no Herdr, cmux available and alive), the Herdr binary probe (absent), and the macOS desktop launcher, which records its command instead of opening a window.

    | | 0.6.9 release commit 4b48ca21 (run) | main at the content cut 67efb111 (run) | this PR (run) |
    |---|---|---|---|
    | TUI preview's provider | herdr | cmux | herdr |
    | window open | opened both seats, in plain tmux | refused: "The terminal view changed since preview" | opened both seats, in plain tmux |
    | plain-tmux view created / desktop launches | yes / 1 | no / 0 | yes / 1 |

    Tests (packages/cli/test/terminal-window-tui-preview.test.ts, the same real composition):

  • With no Herdr and a live cmux, Open terminals reaches the plain-tmux window: both seats open, one desktop launch, and no provider openView.

  • With Herdr available, the TUI preview's plan equals the provider-less preview's and the window opener's, as before.

  • A view that really changed after the preview is still refused, with no window and no tmux view.

  • A provider-less open that isn't a window still chooses cmux.
  • Not exercised: a real desktop window, and Herdr's own window path, which existing tests cover. The plan Herdr checks against is shown unchanged above.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01WfCu2MmcrSGRNX9Rjv1h6u

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    Improvements
    Terminal previews now explicitly select the Herdr provider when available, keeping preview plans consistent with window-opening requests.
    When Herdr is unavailable, window opening can use plain tmux, while non-window opens can select cmux.
    Opening a window is prevented if the view has changed since its preview, helping avoid acting on an outdated plan.
    Tests
    Added end-to-end coverage for terminal previews and window-opening behavior across provider availability and view changes.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 493 lines (+369 / -124) across 6 files Reviewer: mvschwarz Review duration: 24m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 493 lines diff across 6 files
    0.47
    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.371
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1167"
    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: 47.4% (MEDIUM) · Higher = larger blast radius
    47.4%
    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: 18.7% · Safe to merge
    18.7%