Skip to content

fix(titlebar): keep chrome drag regions live while a terminal is focused - #17426

Open
vodves-vodves wants to merge 2 commits into
stablyai:mainfrom
vodves-vodves:fix/titlebar-drag-while-terminal-focused
Open

vodves-vodves wants to merge 2 commits into
stablyai:mainfrom
vodves-vodves:fix/titlebar-drag-while-terminal-focused

Conversation

@vodves-vodves

@vodves-vodves vodves-vodves commented Aug 30, 2026 •

Copy link
Copy Markdown

ELI5

The strip of chrome at the top of the Orca window is what you grab to move the window around, the way you would grab a native titlebar. While a terminal has focus — which is almost always — that strip quietly stopped being a window handle. The first press on it went into the app instead of to the operating system: the window did not move, and the app started selecting text under the pointer. You had to let go and do the exact same drag a second time before the window moved. This PR makes those surfaces window handles at all times, so the first press drags.

What Changed

  • src/renderer/src/assets/main.css: removed the :root[data-regular-terminal-input-focused] block that flipped .titlebar, .titlebar-left, .window-controls-titlebar-spacer, .right-sidebar-header-drag, and the tab strips to -webkit-app-region: no-drag while xterm owned input focus. Each of those surfaces keeps its unconditional drag declaration.
  • Renamed the marker attribute data-terminal-focus-release-surface to data-window-drag-strip (TabGroupPanel.tsx, TabGroupSplitLayout.tsx, main.css). The surface no longer releases anything; it is the window drag strip, and the old name would have described a mechanism that no longer exists.
  • Gave that strip user-select: none, matching .titlebar and .right-sidebar-header-drag, so no press on it can start a selection.
  • New regression spec tests/e2e/titlebar-drag-with-terminal-focus.spec.ts.

No other behavior is touched. TerminalPane.tsx still publishes terminal input focus to the main process and still releases focus on the document-level pointerdown; resolve-zoom-target.ts is unchanged.

Why

The tab strip stands in for a native titlebar, so it carries the window drag region. #6301 gated that region on terminal focus: while a regular terminal owned input focus, every top-chrome drag surface became no-drag so that the click releasing terminal zoom ownership would be delivered to the renderer.

The problem is the ordering. Electron hit-tests -webkit-app-region at mousedown, so a surface that is no-drag when the press lands swallows that press into the page. The document-level pointerdown handler in TerminalPane.tsx then blurs the xterm helper textarea, the attribute clears, and the surface becomes draggable — but for the press that already happened it is too late. The window does not move, Chromium instead begins a selection drag (the strip had no user-select: none), and only the second gesture moves the window.

So the rule cost every user the first press of every window drag, in the app's most common focus state, on all three platforms.

Trade-off this accepts. With the drag region always live, a press on the empty part of the caption is consumed by the OS and no longer hands Cmd/Ctrl +/- from the terminal font to app zoom. That is defensible on its own terms: a native window drag does not move keyboard focus, so after dragging the window the terminal is still where typing goes, and zoom following it is consistent. Every genuinely interactive piece of chrome is no-drag and still releases terminal focus through the unchanged pointerdown handler — tabs, the "+" button, pane action buttons, the app name, the sidebar, the editor, the status bar. The affordance #6301 added is still reachable; it just no longer collides with dragging the window.

Alternative considered and rejected. Keeping the release by having the main process report a window drag (BrowserWindow will-move) would restore the #6301 behavior only for drags that actually move the window, not for a click that does not, and will-move is not emitted on Linux. It adds an IPC path and platform-specific behavior to recover a case that already has many other entry points.

Linked Issue

Fixes #17425

Visual Proof

No pixels change. The change is in how the OS hit-tests the same pixels, so a before/after screenshot pair would be identical. The observable difference is the first press:

before after
computed -webkit-app-region on the tab strip while xterm has focus no-drag drag
first press-and-drag on the strip selects text, window stays put window moves
second press-and-drag window moves window moves

The "before" column is the reported behavior on Windows 11. The "after" column follows from the region being live when the press lands; see Testing for what was and was not executed locally.

Reproduce on either branch: focus a terminal, then press and drag the empty part of the tab strip.

Testing

  • New regression spec tests/e2e/titlebar-drag-with-terminal-focus.spec.ts — focuses the active terminal, asserts data-regular-terminal-input-focused is actually published (so the test cannot pass vacuously if focus reporting regresses), then asserts the computed -webkit-app-region of the tab strip and .titlebar-left is drag and their user-select is none. Restoring the deleted CSS block makes it fail with no-drag on both.

  • tsc --noEmit passes for the node, cli, and web projects; oxlint is clean on the changed files.

  • Unit tests for the touched areas pass: regular-terminal-focus-ownership.test.ts plus the whole components/tab-group suite (17 files, 117 tests).

  • Not run locally: the E2E suite. This environment cannot download the Electron binary (objects.githubusercontent.com is unreachable from it), so the new spec and the manual first-press drag are unverified in a running build here and rely on CI. The bug itself was reproduced by a user on Windows 11 and traced to the rule removed here; a reviewer who can launch the app should confirm the first press drags on macOS (hiddenInset), Linux, and Windows.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Investigated and written with Claude Code (Claude Opus 5). The root cause, the trade-off analysis, and the test were reviewed by hand against the code before opening this PR.

Review

  • Cross-platform: pure CSS, no platform branch. Removes rules; adds none that are platform-specific. .window-controls stays no-drag, so the Windows/Linux custom window buttons remain clickable, and the spacer they overlay is covered by the titlebar's own drag rect.
  • SSH / remote: no execution-host or wire surface touched; renderer chrome only.
  • Mobile: main.css is desktop renderer styling; mobile/ is untouched.
  • Agents / integrations / git providers: not involved.
  • Backwards compatibility: no persisted state, no IPC contract, no wire format. The removed attribute selector is renderer-internal.
  • Performance: strictly fewer selectors to match, and one fewer style recalculation trigger on every terminal focus change.
  • Security: none.
  • UI quality: no visual change; restores standard OS window-drag behavior.

Agent skill upstream boundary

  • Not applicable.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • tsc --noEmit (node/cli/web) and oxlint pass locally; the E2E spec runs in CI (see Testing)

🤖 Generated with Claude Code

https://claude.ai/code/session_014PYpYoxCtNbgaGGMnLexVZ

@coderabbitai

coderabbitai Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 33ea7fa0-f7fe-42d5-95af-0bdfe253af71

📥 Commits

Reviewing files that changed from the base of the PR and between e2dfd0dec4f38d392231654029779458981fc01c and bfd853d.

📒 Files selected for processing (1)
  • tests/e2e/titlebar-drag-with-terminal-focus.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/e2e/titlebar-drag-with-terminal-focus.spec.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The change replaces terminal-focus-specific drag-surface attributes with data-window-drag-strip="true" in both tab-group layouts. CSS keeps these strips draggable and disables text selection without renderer-state overrides. A new end-to-end test focuses the terminal, waits for xterm focus, and verifies styles on the tab strip and titlebar-left surface.

Merge Risk: ⚪ Minimal · up to bfd85

This PR keeps titlebar drag regions active while a terminal is focused and prevents text selection on those surfaces. No actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix: keeping titlebar drag regions active while a terminal has focus.
Description check ✅ Passed The description covers the required sections, explains the root cause and trade-off, identifies linked issue #17425, documents testing limits, and includes the required checklist information.
Linked Issues check ✅ Passed The changes satisfy issue #17425 by keeping titlebar and tab-strip surfaces as drag regions during terminal focus, preventing text selection with user-select: none, and adding a regression test.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue and PR objectives. The CSS updates, attribute rename, and regression test are focused on titlebar dragging during terminal focus.
  • Fix all pre-merge checks with AI

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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bf4bb451-12e9-4bbb-9c89-3389c4bb6671

📥 Commits

Reviewing files that changed from the base of the PR and between 89a4d67 and e2dfd0dec4f38d392231654029779458981fc01c.

📒 Files selected for processing (4)
  • src/renderer/src/assets/main.css
  • src/renderer/src/components/tab-group/TabGroupPanel.tsx
  • src/renderer/src/components/tab-group/TabGroupSplitLayout.tsx
  • tests/e2e/titlebar-drag-with-terminal-focus.spec.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@greptile-apps

greptile-apps Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR keeps Electron titlebar and tab-strip drag regions active while terminal input is focused and updates the regression test to cover every rendered strip.

  • Removes the terminal-focus CSS override that changed chrome surfaces to no-drag.
  • Renames the strip marker to data-window-drag-strip and disables text selection there.
  • Verifies all matching drag strips and the left titlebar retain the expected computed styles.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/renderer/src/assets/main.css Removes the focus-dependent no-drag override and consistently styles marked window-drag strips as draggable and non-selectable.
src/renderer/src/components/tab-group/TabGroupPanel.tsx Renames the tab-row marker to reflect its permanent window-drag behavior.
src/renderer/src/components/tab-group/TabGroupSplitLayout.tsx Applies the renamed permanent drag-strip marker to the split layout’s top strip.
tests/e2e/titlebar-drag-with-terminal-focus.spec.ts The regression test now checks every matching strip, resolving the previously reported first-element-only coverage gap.

Reviews (3): Last reviewed commit: "test(e2e): assert every chrome drag surf..." | Re-trigger Greptile

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Removed terminal-focus drag gating — src/renderer/src/assets/main.css drops the :root[data-regular-terminal-input-focused] block that flipped .titlebar, .titlebar-left, .window-controls-titlebar-spacer, .right-sidebar-header-drag, and the tab strips to -webkit-app-region: no-drag while xterm owned input focus. Each surface keeps its unconditional drag declaration.
  • Renamed the tab-strip marker — data-terminal-focus-release-surface → data-window-drag-strip in TabGroupPanel.tsx and TabGroupSplitLayout.tsx, with user-select: none added to the strip to match .titlebar / .right-sidebar-header-drag.
  • Regression spec — tests/e2e/titlebar-drag-with-terminal-focus.spec.ts first asserts data-regular-terminal-input-focused is actually published (so it can't pass vacuously), then checks the tab strip and .titlebar-left compute -webkit-app-region: drag and user-select: none.

I verified the supporting claims: every interactive chrome surface carries its own no-drag (the tab wrapper in tab-bar-surface.tsx, the + button, scroll arrows, pane-action buttons, .sidebar-toggle, .titlebar-app-name, and the reserved spacers), so clicks still route through the unchanged document-level pointerdown release in TerminalPane.tsx; and resolveZoomTarget continues to own Cmd/Ctrl +/- for the terminal until focus leaves xterm, which is the tradeoff the PR documents and the reasoning holds.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

While xterm owned input focus, every top-chrome drag surface flipped to
-webkit-app-region: no-drag so the click that releases terminal zoom
ownership (stablyai#6301) would reach the renderer. Electron hit-tests app-region
at mousedown, so that press was consumed by the page: it started a text
selection, the window did not move, and only a second press dragged it.

Drop the focus-gated override. Interactive chrome is no-drag anyway and
still releases terminal focus through the unchanged pointerdown handler;
a press on the empty caption is now an OS window drag, which does not move
keyboard focus, so zoom staying with the terminal is consistent.

Rename data-terminal-focus-release-surface to data-window-drag-strip and
give it user-select: none, matching the other drag surfaces.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_014PYpYoxCtNbgaGGMnLexVZ
@vodves-vodves
vodves-vodves force-pushed the fix/titlebar-drag-while-terminal-focused branch from e2dfd0d to a161ecf Compare August 30, 2026 18:48
querySelector checked only the split layout's leading 4px strip, so a
regression that returned the tab rows themselves to no-drag would have
passed. Collect every match per selector and fail on any that is not
draggable or selectable-free.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_014PYpYoxCtNbgaGGMnLexVZ

@pullfrog pullfrog 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.

ℹ️ No critical issues — one minor suggestion inline.

Reviewed changes

a161ecf is a byte-identical re-author of the previously reviewed e2dfd0d; the only new code is bfd853d, which hardens the regression spec:

  • Expanded the drag-surface assertion to every match — the spec now collects all [data-window-drag-strip] and .titlebar-left elements and filters offenders, so the split layout's 4px strip can no longer satisfy the check while a tab row the user actually grabs stays no-drag.
  • Added a loud-failure path for empty selectors — a per-selector missing placeholder feeds the offender filter, so a selector that matches nothing can no longer pass as an empty offender list.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏


// Why: a selector that matches nothing must fail loudly instead of leaving
// an empty list that trivially satisfies the offender check below.
expect(new Set(dragRegions.map((region) => region.selector))).toEqual(

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.

This Set-equality check can never fail: flatMap always emits at least one entry per selector (a real match or the missing placeholder), so the returned selector set always equals the input set. The loud failure the comment above describes is actually the offenders filter catching the missing placeholder — consider dropping the tautological assertion or moving that comment to the offenders filter.

This branch has not been deployed

No deployments
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]: First press on the tab strip selects text instead of dragging the window

1 participant