Repository navigation
Fix capped session pane interaction paths - #8250
Conversation
📝 WalkthroughWalkthroughThe changes refactor terminal background event forwarding and context-menu construction, and add persisted width/alignment presentation state for sizing and interacting with hosted agent-session web views. ChangesTerminal interaction handling
Session content presentation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant AgentSessionPanelView
participant AgentSessionWebRenderer
participant AgentSessionWebHostView
AgentSessionPanelView->>AgentSessionWebRenderer: provide sessionContentWidthPresentation
AgentSessionWebRenderer->>AgentSessionWebHostView: update presentation
AgentSessionWebHostView->>AgentSessionWebHostView: compute contentFrame and layout hosted web view
AgentSessionWebHostView->>AgentSessionWebHostView: forward pointer and scroll events
Possibly related PRs
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 2 warnings)
✅ Passed checks (22 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Greptile SummaryThis PR fixes interaction gaps introduced by capped-width session panes by retargeting gutter events to the correct terminal and agent-chat surfaces. It also splits the shared
Confidence Score: 5/5Safe to merge — the changes are a focused interaction-routing fix with no regressions identified and a passing test suite. All actor-isolation boundaries are respected (the whole web host is @mainactor; the JS completion handler re-enters via Task { @mainactor in }). Scroll coalescing uses Task.yield() rather than a fixed sleep. Weak references are used correctly throughout. The paneContextMenu method is a real production entrypoint, not a test seam. No expensive synchronous loads, no ambient global state, and no allocating formatting on hot paths were introduced. No files require special attention. Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Gutter as TerminalPaneBackgroundView (gutter)
participant TermSurface as GhosttyNSView (terminal)
participant ScrollView as GhosttyScrollView
Note over Gutter,ScrollView: Terminal pane – capped width interaction paths
Gutter->>TermSurface: mouseDown → focusFromPointerDown()
Gutter->>ScrollView: scrollWheel → scrollWheel(event)
Gutter->>TermSurface: rightMouseDown → focusFromPointerDown() + super
Gutter->>TermSurface: menu(for:) → paneContextMenu(for:)
Note over TermSurface: paneContextMenu skips ghostty_surface_mouse_pos/button
participant AgentHost as AgentSessionWebHostView (gutter)
participant WebView as WKWebView (agent chat)
participant JS as DOM .agent-thread
Note over AgentHost,JS: Agent pane – capped width interaction paths
AgentHost->>WebView: mouseDown → makeFirstResponder(webView)
AgentHost->>AgentHost: scrollWheel → accumulate pendingScrollDelta (clamped)
AgentHost->>AgentHost: scheduleScrollFlush (Task.yield coalesce)
AgentHost->>JS: evaluateJavaScript scrollBy(−Δx, −Δy)
JS-->>AgentHost: "completion → isScrollJavaScriptInFlight=false → scheduleScrollFlush"
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Gutter as TerminalPaneBackgroundView (gutter)
participant TermSurface as GhosttyNSView (terminal)
participant ScrollView as GhosttyScrollView
Note over Gutter,ScrollView: Terminal pane – capped width interaction paths
Gutter->>TermSurface: mouseDown → focusFromPointerDown()
Gutter->>ScrollView: scrollWheel → scrollWheel(event)
Gutter->>TermSurface: rightMouseDown → focusFromPointerDown() + super
Gutter->>TermSurface: menu(for:) → paneContextMenu(for:)
Note over TermSurface: paneContextMenu skips ghostty_surface_mouse_pos/button
participant AgentHost as AgentSessionWebHostView (gutter)
participant WebView as WKWebView (agent chat)
participant JS as DOM .agent-thread
Note over AgentHost,JS: Agent pane – capped width interaction paths
AgentHost->>WebView: mouseDown → makeFirstResponder(webView)
AgentHost->>AgentHost: scrollWheel → accumulate pendingScrollDelta (clamped)
AgentHost->>AgentHost: scheduleScrollFlush (Task.yield coalesce)
AgentHost->>JS: evaluateJavaScript scrollBy(−Δx, −Δy)
JS-->>AgentHost: "completion → isScrollJavaScriptInFlight=false → scheduleScrollFlush"
Reviews (4): Last reviewed commit: "Preserve capped gutter fallback interact..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3c23676f07
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Sources/Panels/AgentSessionWebHostView.swift`:
- Around line 39-43: Update mouseDown(with:) in AgentSessionWebHostView so that
when hostedWebView cannot be cast to AgentSessionWebView, it calls
super.mouseDown(with: event) before returning. Preserve the existing pointer
callback and first-responder behavior for successful casts.
- Around line 45-47: Update AgentSessionWebHostView.scrollWheel(with:) with a
re-entrancy guard around forwarding events to hostedWebView. Forward only when
the view is not already forwarding and the subview exists; otherwise call
super.scrollWheel(with:) to prevent recursive forwarding.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 04b79205-19d8-4ef7-9eb2-8f2543a38b7b
📒 Files selected for processing (8)
Sources/GhosttyTerminalView.swiftSources/Panels/AgentSessionPanelView.swiftSources/Panels/AgentSessionWebHostView.swiftSources/Panels/AgentSessionWebRenderer.swiftSources/Panels/SessionContentWidthModifier.swiftSources/Panels/SessionContentWidthPresentation.swiftSources/TerminalPaneBackgroundView.swiftcmux.xcodeproj/project.pbxproj
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Sources/Panels/AgentSessionWebHostView.swift`:
- Around line 46-51: Update the scroll-wheel handling around hostedWebView and
delta validation so both early-return paths call super.scrollWheel(with: event)
before returning. Preserve the existing hosted-web-view handling for valid,
finite deltas.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: b05666a8-99a2-4264-9ac6-ecc09e723fd6
📒 Files selected for processing (1)
Sources/Panels/AgentSessionWebHostView.swift
Follow-up to #8222.
Preserves full-pane terminal overlays and Canvas width caps, keeps terminal gutter focus, scrolling, and context menus on existing interaction paths, and keeps agent-chat gutter scrolling active. Splits shared geometry and gutter-host types into policy-compliant files.
Verification:
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Fixes interaction gaps around capped session content so clicking, scrolling, and context menus work in terminal and agent chat panes. Keeps full‑pane overlays and Canvas width caps while retargeting gutter events to the right surface and coalescing agent gutter scrolls.
Bug Fixes
Refactors
SessionContentWidthPresentationfor shared width/alignment logic across SwiftUI and AppKit hosts.TerminalPaneBackgroundViewand wires it into the Ghostty surface scroll view.Written for commit 005ca30. Summary will update on new commits.
Summary by CodeRabbit