Skip to content

fix(terminal): restore OpenCode mouse-wheel scroll after session restore - #11176

Closed
innocarpe wants to merge 3 commits into
stablyai:mainfrom
innocarpe:fix/opencode-mouse-wheel-restore
Closed

innocarpe wants to merge 3 commits into
stablyai:mainfrom
innocarpe:fix/opencode-mouse-wheel-restore

Conversation

@innocarpe

Copy link
Copy Markdown
Contributor

Description

After Orca restart/session restore, OpenCode tabs keep live-agent reattach mode (mouse tracking preserved) so the wheel scrolls session history again instead of shell prompt history.

Focused fix

  • In scope: recognize status-less OpenCode OSC titles (OC | …) as live-agent reattach signals (alongside Cursor); pure helper + pty-connection tests
  • Out of scope: changing shell reattach reset for non-agent PTYs

Preserves

  • Shell reattach still disarms mouse reporting
  • Cursor reattach path unchanged
  • Fresh OpenCode launch behavior unchanged

Evidence

  • live-agent-reattach-title-signal + pty-connection reattach cases + related replay suites green

User-regression-tradeoffs

  • Any title matching OC | pattern is treated as OpenCode live agent for reattach mode selection

Fixes #11123

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3befc6ee-5e33-4c66-9e21-adad850f8d0f
📥 Commits

Reviewing files that changed from the base of the PR and between 36b25fb7113230faede287cbe15dc734e3f7926b and e6ad897.

📒 Files selected for processing: 2
  • src/renderer/src/components/terminal-pane/pty-connection-reattach-mode-reset.spec.ts
  • src/renderer/src/components/terminal-pane/pty-connection/shell-command-inference.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

📝 Walkthrough

The change adds shared helpers that identify native Cursor and OpenCode titles when status detection returns null. PTY reattach detection uses these helpers alongside detected status. Tests cover title recognition and verify that a restored OpenCode session retains mouse and focus modes.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to e6ad8

No actionable merge-blocking risk was established. The added OpenCode reattach test covers behavior that already worked for its chosen title.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description explains the fix, scope, preserved behavior, evidence, trade-off, and linked issue. It does not follow the repository template and omits required sections such as ELI5, What Changed, W… Rewrite the description using the repository template. Complete all applicable sections, including ELI5, What Changed, Why, Visual Proof or N/A with a reason, Testing steps and platforms, Review, Notes, and Checklist. Retain the Fixes #1112…
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly identifies the primary change: restoring OpenCode mouse-wheel scrolling after session restore. It is concise and matches the implementation and tests.
Linked Issues check Passed Issue [#11123] requires OpenCode session-history scrolling after restart and session restore. The change recognizes status-less OC | ... titles through isOpenCodeNativeTitle, includes wrapped titl…
Out of Scope Changes check Passed The changed source is limited to the reattach title-signal helper and its pty reattach integration. The added tests cover the helper and the OpenCode restored-session case. The diff does not change sh…
Full details: Linked Issues check

Explanation

Issue [#11123] requires OpenCode session-history scrolling after restart and session restore. The change recognizes status-less OC | ... titles through isOpenCodeNativeTitle, includes wrapped titles, and passes the result to titleSignalsLiveAgentReattach. The reattach path therefore selects the live-agent reset instead of the shell reset. The new pty-connection test verifies focus re-entry, the live-agent reset, and preservation of mouse and focus modes. Existing non-null status signals remain accepted.

Full details: Out of Scope Changes check

Explanation

The changed source is limited to the reattach title-signal helper and its pty reattach integration. The added tests cover the helper and the OpenCode restored-session case. The diff does not change shell reattach reset behavior for non-agent PTYs, fresh launch behavior, or the Cursor title path.

Full details: Description check

Explanation

The description explains the fix, scope, preserved behavior, evidence, trade-off, and linked issue. It does not follow the repository template and omits required sections such as ELI5, What Changed, Why, Visual Proof or an explicit N/A, detailed Testing, and the checklist.

Resolution

Rewrite the description using the repository template. Complete all applicable sections, including ELI5, What Changed, Why, Visual Proof or N/A with a reason, Testing steps and platforms, Review, Notes, and Checklist. Retain the Fixes #11123 reference and complete AI Disclosure only if applicable.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/shared/live-agent-reattach-title-signal.ts (1)

5-12: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Condense the new TypeScript comments. Keep only the non-obvious rationale; the current multi-line walkthroughs are more detailed than needed.

  • src/shared/live-agent-reattach-title-signal.ts#L5-L12: reduce to a brief statusless-title rationale.
  • src/shared/live-agent-reattach-title-signal.ts#L17-L24: keep only the status-injection contract.
  • src/shared/live-agent-reattach-title-signal.test.ts#L13-L14: reduce to one concise test rationale.
  • src/shared/live-agent-reattach-title-signal.test.ts#L49-L50: reduce to one concise false-positive rationale.
  • src/renderer/src/components/terminal-pane/pty-connection.ts#L1743-L1746: retain one sentence explaining statusless OSC titles.
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts#L7759-L7761: retain one concise regression rationale.
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts#L7767-L7768: remove or shorten the implementation walkthrough.
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts#L7804-L7804: keep as a short rationale if retained.

As per coding guidelines, comments must be concise, limited to non-obvious information, and preferably one line.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a227bc6d-0662-41af-b760-ab347a7a70d7

📥 Commits

Reviewing files that changed from the base of the PR and between 0404f27 and 1e858b47e983a9ef5c0f554dad3f798d8522155c.

📒 Files selected for processing (4)
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/shared/live-agent-reattach-title-signal.test.ts
  • src/shared/live-agent-reattach-title-signal.ts

@AmethystLiang
AmethystLiang requested a review from OrcaWin July 28, 2026 16:48
@innocarpe
innocarpe force-pushed the fix/opencode-mouse-wheel-restore branch from 1e858b4 to 89b55a6 Compare August 6, 2026 02:17
@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (89b55a64bc)

Rebase onto latest upstream/main: keep worker-terminal-takeover import from main; retain OpenCode/Cursor statusless reattach title signal for mouse-wheel restore (#11123).

@innocarpe

Copy link
Copy Markdown
Contributor Author

Noting that #11123 was closed as a duplicate of #8563.

This PR stays scoped to the restore path: after Orca restart, an adopted OpenCode pane no longer has mouse reporting, so the wheel becomes history arrows. It does not attempt the broader normal-buffer wheel-to-arrow case in #8563. Happy to retarget Fixes #8563 or close if you would rather one PR for both.

@innocarpe
innocarpe force-pushed the fix/opencode-mouse-wheel-restore branch from 89b55a6 to f45465b Compare August 26, 2026 05:48
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Note

The previously reviewed commits are no longer reachable (likely due to a force-push or rebase), so CodeRabbit is performing a full review instead of an incremental one. This review may take a little longer.

@innocarpe

Copy link
Copy Markdown
Contributor Author

Rebased onto current main after #11123 was reopened as distinct from #8563 (fresh start OK, session-restore breaks wheel). The restore path now lives on the split pty-connection barrel. Focused tests: 25 passed.

@innocarpe
innocarpe force-pushed the fix/opencode-mouse-wheel-restore branch from f45465b to f1b8bf3 Compare August 29, 2026 01:13
@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@greptile-apps

greptile-apps Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR restores mouse-wheel scrolling for reattached OpenCode terminal sessions by recognizing native status-less OC | … titles as live-agent signals.

  • Adds a shared helper for status and native-title reattach classification.
  • Uses that helper when selecting the post-replay terminal mode reset.
  • Adds focused unit and PTY reattach coverage for OpenCode while retaining Cursor and shell behavior.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/shared/live-agent-reattach-title-signal.ts Introduces a pure helper that combines explicit agent status with exact Cursor and OpenCode native-title recognition.
src/renderer/src/components/terminal-pane/pty-connection/shell-command-inference.ts Applies the shared title signal when deciding whether reattach should preserve live-agent mouse and focus modes.
src/shared/live-agent-reattach-title-signal.test.ts Covers accepted native titles, status-based signals, and rejected shell or lookalike titles.
src/renderer/src/components/terminal-pane/pty-connection-reattach-mode-reset.test.ts Verifies restored OpenCode sessions retain mouse and focus modes without receiving the shell reset.

Reviews (2): Last reviewed commit: "test(terminal): align OpenCode reattach ..." | Re-trigger Greptile

@innocarpe
innocarpe force-pushed the fix/opencode-mouse-wheel-restore branch from f1b8bf3 to 36b25fb Compare August 31, 2026 13:40
@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (36b25fb71)

Rebased onto current upstream/main with scope unchanged: preserve mouse reporting for restored native OpenCode sessions only. This remains distinct from the broader normal-buffer behavior in #8563. Evidence: 24 focused regression tests, Node typecheck, Oxlint, and Oxfmt pass.

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Re-establish the TUI mouse/focus state on reattach so wheel scrolls
session history again instead of shell prompt history.

Fixes stablyai#11123
isOpenCodeNativeTitle requires a spaced `OC |` marker. Compact `OC|x`
titles belong to other tools and must not preserve mouse modes on reattach.
The reattach gate now uses titleSignalsLiveAgentReattach, so an OC | title
keeps mouse modes and a compact OC| title still does not.
@innocarpe
innocarpe force-pushed the fix/opencode-mouse-wheel-restore branch from 36b25fb to e6ad897 Compare October 22, 2026 04:03
@nwparker

Copy link
Copy Markdown
Contributor

Thank you for this PR and for the repeated rebases. The same fix, recognizing OpenCode's native OC | titles as a live agent on reattach, landed in #13957, so we're closing this as superseded. Appreciate the clear diagnosis of the restore path.

@nwparker nwparker closed this Oct 24, 2026
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.

[Bug]: After Orca restart and restoring session, mouse wheel no longer scrolls opencode sessions history, but command/prompt history

3 participants