Repository navigation
Fix terminal scroll intent across workspace switches - #6319
Conversation
Co-authored-by: Orca <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughThe PR adds a terminal scroll-intent architecture spec and a new scroll-intent module with unit tests. It wires scroll-intent tracking into pane creation, keyboard and pointer scrolling, output writes, fit/resume paths, and snapshot replay. It also moves long-table e2e fixtures into a shared helper and adds e2e coverage for pinned viewport behavior during worktree switching. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/terminal-pane/terminal-visibility-resume.ts (1)
46-50: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winStale comment: restore path was replaced by intent enforcement.
The comment still explains a content-matching-free restore of numeric viewport positions, but resume now enforces scroll intent via
enforceTerminalViewportIntentsand thecaptureViewportPositions(!wasVisible)return value is discarded. The call is now retained only for its snapshot/epoch side effect — please update the comment to reflect that so the discarded return value doesn't read as a mistake.
🧹 Nitpick comments (3)
tests/e2e/terminal-long-table-fixtures.ts (1)
77-80: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: extract the duplicated
writeStdouttemplate helper.The same
writeStdoutasync helper is inlined inlongMarkdownTableScript(Lines 77-80),emojiFixtureMarkdownTableScript(Lines 199-202),narrowSignerMarkdownTableScript(Lines 240-243), and again inscrollbackFixtureScriptinterminal-pinned-viewport-worktree-switch.spec.ts. A sharedwriteStdoutSnippetstring constant would keep the win32 flush delay consistent in one place.tests/e2e/terminal-pinned-viewport-worktree-switch.spec.ts (1)
147-152: 🎯 Functional Correctness | 🔵 TrivialAdd a comment explaining the necessity of the large
charLimitargument.The second argument
30_000is correctly passed ascharLimit(not a timeout), but the value significantly exceeds the function's default of4000. Add a brief inline note or local comment justifying why such a large buffer capture is required (e.g., "Ensures scrollback capacity to catch the DONE marker after viewport switch") to prevent future confusion regarding this hard-coded threshold.src/renderer/src/lib/pane-manager/pane-terminal-output-scheduler.ts (1)
607-621: 📐 Maintainability & Code Quality | 🔵 TrivialDocument the
terminal.write.length < 2arity branch.The
terminal.write.lengthcheck detects if the target supports the optional parse-completion callback. Verified:@xterm/xtermdefineswrite(data, callback?), sowrite.lengthis 2 only when the callback is expected. This branch distinguishes standard async xterm handles (requiring the callback path) from mock or callback-less targets that settle synchronously. Add an inline comment explaining this non-obvious intent detection.📝 Suggested fix
const scrollIntent = captureTerminalWriteScrollIntent(terminal) if (!scrollIntent) { terminal.write(data) return } + // xterm's write(data, cb) parses asynchronously, so intent enforcement + // must wait for the callback. Callback-less targets (arity < 2) settle + // immediately, allowing inline enforcement. if (terminal.write.length < 2) { terminal.write(data) enforceTerminalWriteScrollIntent(terminal, scrollIntent) return }Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: bea9860b-0fa7-46c4-9ebd-aa9d0fa40e8e
📒 Files selected for processing (18)
docs/terminal-scroll-intent-architecture.mdsrc/renderer/src/components/terminal-pane/keyboard-handlers.tssrc/renderer/src/components/terminal-pane/pty-connection.test.tssrc/renderer/src/components/terminal-pane/pty-connection.tssrc/renderer/src/components/terminal-pane/terminal-visibility-resume.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-global-effects.test.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.tssrc/renderer/src/components/terminal-pane/use-terminal-scroll-visibility-memory.tssrc/renderer/src/lib/pane-manager/pane-dom-creation.tssrc/renderer/src/lib/pane-manager/pane-lifecycle.tssrc/renderer/src/lib/pane-manager/pane-manager-types.tssrc/renderer/src/lib/pane-manager/pane-terminal-output-scheduler.tssrc/renderer/src/lib/pane-manager/pane-tree-ops.tssrc/renderer/src/lib/pane-manager/terminal-scroll-intent.test.tssrc/renderer/src/lib/pane-manager/terminal-scroll-intent.tstests/e2e/terminal-long-table-fixtures.tstests/e2e/terminal-long-table-scroll-restore.spec.tstests/e2e/terminal-pinned-viewport-worktree-switch.spec.ts
Co-authored-by: Orca <[email protected]>
|
Follow-up after live repro reports:
Validation run locally:
Note: the running dev profile did not contain the named |
Co-authored-by: Orca <[email protected]>
Summary
Verification
Made with Orca 🐋