Skip to content

fix(window): preserve titlebar dragging while terminal is focused - #27429

Open
aerox0 wants to merge 2 commits into
stablyai:mainfrom
aerox0:fix/terminal-focus-first-drag
Open

aerox0 wants to merge 2 commits into
stablyai:mainfrom
aerox0:fix/terminal-focus-first-drag

Conversation

@aerox0

@aerox0 aerox0 commented Oct 11, 2026 •

Copy link
Copy Markdown

ELI5

After clicking a terminal, moving the Orca window currently takes two attempts: the first press releases terminal focus, and only the second drags the window. Keep the title bar draggable so the first press works.

What Changed

Remove the terminal-focus-dependent no-drag override from main.css (11 lines). The existing drag regions remain active while xterm owns focus; buttons and other interactive controls retain their existing no-drag rules. No component, focus-handler, or IPC changes.

Add an Electron regression test that focuses a real xterm helper, verifies the focus flag, checks every visible matching drag surface and interactive control, and clicks a sidebar toggle to verify terminal focus is still released. It attaches computed region values and a renderer screenshot.

Why

Electron chooses whether the press belongs to a window drag before the renderer's pointerdown handler can clear terminal focus. Re-enabling dragging in that handler is too late for the current press.

Keeping caption regions draggable fixes the ordering problem without replacing the title bar or adding platform-specific window-movement IPC. Tradeoff: pressing empty caption space preserves terminal keyboard/zoom ownership, like dragging a native window. Interactive chrome still releases it.

Linked Issue

Fixes #17425

Fixes #19184

Related open PR: #17426 addresses the same root cause. This is a deliberately minimal alternative with executed before/after regression evidence and a Windows user-confirmed installed-build test; it does not include the marker rename or selection-style changes from that PR.

Visual Proof

Native mouse recording (24 seconds): click the terminal, press and hold the left mouse button on the title bar, and drag. The visible pointer and captions show each attempt.

Watch/download the MP4

Native mouse recording: before first drag fails, second works; after first drag works

The recording uses real Electron 43.7.5, native X11 mouse input, and Openbox on an isolated Linux Xvfb desktop. The before segment restores the exact removed upstream CSS rule in the fixed renderer; the after segment removes that rule in the same session. Only explanatory captions are overlaid; the mouse and window movement are actual screen capture.

Measured native window positions (raw results):

  • Before, attempt 1: (60, 120) → (60, 120) — no movement.
  • Before, attempt 2: (60, 120) → (212, 196) — moved.
  • After, attempt 1: (60, 120) → (212, 196) — moved after refocusing the terminal.

The recording script asserted [false, true, true] for these three movements and passed. This is Linux native-window evidence, separate from the Windows reporter confirmation below. Recording script is attached as evidence, not added to the PR's CI tests.

Earlier renderer screenshots and computed-style evidence

Both screenshots below come from the actual hidden Electron renderer on an isolated Linux Xvfb display, with terminal focus active. They are appearance evidence, not proof of native window movement: this change affects hit testing rather than pixels.

Before: original upstream CSS After: CSS override removed
Before, terminal focused After, terminal focused
Measured while the terminal is focused Before After
Left title bar no-drag drag
Right sidebar header no-drag drag
Both visible terminal drag strips no-drag drag
All 10 visible matching interactive controls/containers no-drag no-drag
Regression test Fails on the four drag surfaces Passes

Evidence attachments: original screenshots, computed-style JSON, before/after test results, and validation notes. These are hosted on the fork; no evidence binaries are included in the PR diff.

Windows manual evidence: on installed Orca 1.4.224 / Electron 43.7.5, the reporter reproduced the two-attempt behavior, then confirmed “Yes, first drag works” after an equivalent CSS-only patch and restart. This is a user-performed native drag check, not an automated Windows source-build test. The assistant's earlier Windows automation did not establish native movement and is not counted as a pass.

Testing

  • Original upstream source at c69f9d2f625c: new regression test fails with four Expected: drag / Received: no-drag assertions. The control/focus-release checks pass.
  • Fixed source: the same regression test passes in real Electron 43.7.5 on Fedora WSL with isolated Xvfb and ORCA_BACKGROUND_LAUNCH=1.
  • pnpm test on regular-terminal-focus-ownership.test.ts, right-sidebar-titlebar-drag-regions.test.ts, and right-sidebar-titlebar-drag-regions.render.test.tsx: 30 tests pass.
  • pnpm tc:web: passes.
  • pnpm run check:code-quality:changed: passes all changed-code gates.
  • Targeted oxlint, oxfmt --check, and git diff --check: pass.
  • pnpm exec electron-vite build --mode e2e: passes (existing CSS/chunk-size warnings).
  • Separate native Linux recording run: passed, asserting failed first / successful second drag before, and successful first drag after. Full repository lint/test/package builds, macOS, and SSH interaction were not run. The committed regression test verifies focus and computed drag regions; the isolated recording script separately exercises OS window movement.

Reproduce the regression test after building in E2E mode:

ORCA_BACKGROUND_LAUNCH=1 SKIP_BUILD=1 xvfb-run -a pnpm run test:e2e \
  tests/e2e/titlebar-terminal-focus-drag.spec.ts \
  --project electron-headless --workers=1

Manual reproduction: focus a terminal, then press and hold an empty title-bar/terminal-strip area and move the pointer. Before: first gesture does not move the window. After: first gesture moves it. Confirm the window controls still work and clicking a sidebar control releases terminal input focus.

  • I manually tested these changes locally (reporter's Windows installed-build CSS patch, as qualified above)
  • Automated tests added/updated

AI Disclosure

Investigated, implemented, and tested with OpenAI Codex (GPT-6). The reporter supplied the Windows reproduction and confirmed the installed-build fix.

Review

The production diff only removes a CSS override. Existing focus synchronization, terminal zoom routing, and control hit regions remain in place. The test guards both the focused-state regression and the interactive-control behavior.

Agent skill upstream boundary

  • Not applicable; no upstream skill source or assets copied.

Notes

Platform-neutral desktop CSS; no path, shortcut, security, persistence, remote protocol, or mobile changes. The fix applies to desktop chrome regardless of whether the terminal runs locally, in WSL, or over SSH; Windows manual, Linux renderer, and isolated Linux native-window behavior were exercised. Caption zoom ownership is the intentional behavior change described above.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Before/after native mouse video, screenshots, and measured behavior attached
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • Relevant local tests, renderer typecheck, changed-code lint, and Electron build pass; broader checks left to CI

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: bb3ed43a-5630-45cf-87c1-32de8fe12030

📥 Commits

Reviewing files that changed from the base of the PR and between 7501eb1 and af3e2be.


📒 Files selected for processing (1)
  • tests/e2e/titlebar-terminal-focus-drag.spec.ts

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



📝 Walkthrough

Walkthrough

The focused-terminal CSS override that set titlebar and terminal focus-release surfaces to no-drag was removed. An end-to-end test checks drag-region values while terminal input is focused, then verifies that clicking the sidebar toggle releases terminal focus.


Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to af3e2

Terminal focus no longer disables the reachable title-bar and sidebar drag regions, while interactive controls remain non-draggable. No concrete merge-blocking behavior remains identified.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary fix: preserving titlebar dragging while the terminal has focus.
Description check Passed The description is complete and matches the repository template. It explains the user impact, implementation, rationale, linked issues, visual evidence, testing, limitations, and checklist status.
Linked Issues check Passed Issues #17425 and #19184 require the first title-bar drag attempt to move the window while terminal input has focus. The PR removes the focused-terminal no-drag override from `src/renderer/src/asset…
Out of Scope Changes check Passed The production diff removes only the terminal-focus drag-region override. The added E2E test directly covers the linked issues and protects interactive controls and focus release. The diff contains no…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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)
tests/e2e/titlebar-terminal-focus-drag.spec.ts (1)

53-57: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the right-sidebar drag header after opening it.

The workspace layout uses .titlebar-left, not .titlebar: terminal workspace state sets shouldMount, so the full-width .titlebar is not mounted. Do not require .titlebar.

The test does not require .right-sidebar-header-drag. Open the right sidebar before collecting regions, then assert that selector has a visible match.

Suggested fix
   await waitForActiveWorktree(orcaPage)
   await ensureTerminalVisible(orcaPage)
+  await orcaPage.evaluate(() => window.__store?.getState().setRightSidebarOpen(true))
+  await expect(orcaPage.locator('.right-sidebar-header-drag:visible').first()).toBeVisible()
 
   const helper = orcaPage.locator('.xterm:visible .xterm-helper-textarea').first()
@@
   expect(
     regions.drag.some(({ selector }) => selector === '[data-terminal-focus-release-surface="true"]')
   ).toBe(true)
+  expect(regions.drag.some(({ selector }) => selector === '.right-sidebar-header-drag')).toBe(true)

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 91b9d457-7971-40f9-a5a2-f7bc4fb58f11
📥 Commits

Reviewing files that changed from the base of the PR and between e3d747b and 7501eb1.

📒 Files selected for processing (2)
  • src/renderer/src/assets/main.css
  • tests/e2e/titlebar-terminal-focus-drag.spec.ts
💤 Files with no reviewable changes (1)
  • src/renderer/src/assets/main.css

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

@aerox0

aerox0 commented Oct 11, 2026

Copy link
Copy Markdown
Author

Addressed CodeRabbit's right-sidebar coverage finding in af3e2be.

This was worth fixing: without an explicit visible-match assertion, the loop could skip the right-sidebar header entirely if it were closed. The test now opens the sidebar, waits for its drag header to be visible, and requires that header in the measured regions before checking drag. It continues to require .titlebar-left, without requiring the unmounted full-width .titlebar.

Validation: the focused Electron E2E test passes on isolated Xvfb (1 passed); changed-code quality gates, formatting, and git diff --check pass. Production CSS is unchanged by this follow-up.

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

1 participant