Skip to content

Zoom the app after leaving terminal focus - #6301

Merged
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/reset-terminal-zoom
Jun 24, 2026
Merged

brennanb2025 merged 3 commits into
mainfrom
brennanb2025/reset-terminal-zoom

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Tracks regular terminal input focus as the owner of terminal font zoom.
  • Releases that ownership when the user clicks app chrome, empty tab-group space, the right sidebar header, or other outside surfaces, so the next Cmd/Ctrl +/- zoom event adjusts the app UI.
  • Keeps terminal font zoom scoped to the pane that owns the focused xterm helper textarea.

Design And Review

  • Design approach: make terminal zoom focus-owned instead of tab-owned, mirror regular terminal focus to the main-process shortcut context and a root DOM attribute, and temporarily make drag-region chrome observable while xterm owns focus so the first click can release ownership.
  • Design review: completed clean after the doc was tightened around focus ownership, drag-region behavior, cross-platform shortcut handling, SSH/runtime implications, and validation.
  • Implementation deviations: the top chrome drag styles moved from inline WebkitAppRegion to a CSS data attribute so the focused-terminal no-drag override can win.

Verification

  • Completeness verification: clean after gating terminal font zoom to the pane that owns the focused xterm helper and after adding release behavior for chrome/sidebar/tab-row clicks.
  • Performance audit: clean. Touched hot paths are pointer/focus listeners on mounted terminal panes and zoom event handling; deterministic tests cover listener cleanup/ownership behavior. Accepted residual risk is bounded listener fanout across mounted panes.
  • Code review: two review rounds. Latest round had one staging-hygiene note about untracked new files and one clean review; the files are included in this commit.

Product Validation

  • Merge-confidence validation verdict: land.
  • Live Electron validation attached to the dev app on branch brennanb2025/reset-terminal-zoom with demo-project active.
  • Verified terminal focus sets data-regular-terminal-input-focused and focuses TEXTAREA.xterm-helper-textarea.
  • Verified clicks on right sidebar/header, tab-row release surface, and 4px top drag strip clear terminal ownership; refocusing the terminal restores ownership.
  • Console check: 0 errors, 1 unrelated dev warning.
  • Screenshot evidence captured locally: .playwright-cli/page-2026-06-24T22-23-16-741Z.png.

Checks

  • git diff --check
  • pnpm exec oxlint on touched files
  • pnpm run typecheck
  • pnpm run lint
  • Focused Vitest:
    • Browser guest zoom forwarding: browser-guest-ui.test.ts, browser-manager.test.ts, and useIpcEvents.test.ts regular-terminal-focus-ownership.test.ts, useTerminalFontZoom.test.ts, useIpcEvents.test.ts, createMainWindow.test.ts, window-shortcut-policy.test.ts, TabGroupSplitLayout.test.ts, TabGroupPanel.context-menu.test.ts, right-sidebar-titlebar-drag-regions.render.test.tsx (8 files, 176 tests passed)
  • Additional merge-confidence focused suites: 4 zoom/focus files (128 tests) and neighboring focus/chrome suites (72 tests)

Assumptions And Gaps

  • Native shortcut injection could not be completed in this environment: CDP key events did not trigger app zoom and macOS System Events was blocked with Not authorized to send Apple events to System Events. (-1743).
  • This is not considered blocking because deterministic tests cover native shortcut dispatch to terminal:zoom and renderer routing from released terminal focus to app UI zoom, while live Electron validation proves the focus-release state transition in the running app.
  • Post-PR stabilization: waited 8 minutes after opening the PR, fixed CodeRabbit's actionable cleanup finding in 7d56c278a, and later added 2974f7703 so focused browser guests forward keyboard zoom to app zoom instead of browser page zoom. Waited 8 minutes after each push; refreshed CodeRabbit reported no actionable comments, and final gh pr checks reports verify passing.

Made with Orca 🐋

@coderabbitai

coderabbitai Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The renderer adds shared regular-terminal focus ownership helpers and wires TerminalPane to use them for pointerdown, blur, and focus handling. Terminal zoom now depends on pane-owned helper textarea focus, while zoom shortcuts forward through terminal:zoom and resolveZoomTarget routes terminal, editor, simulator, and UI targets by focus state. Tab-group drag regions now use terminal focus-release markers and CSS switches drag behavior based on the document focus attribute.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. 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 is concise and accurately reflects the main change: switching from terminal focus to app zoom.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description is detailed and covers summary, validation, testing, and review context, with only template-specific sections needing reformatting.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

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/TerminalPane.tsx (1)

1419-1486: 🎯 Functional Correctness | 🟠 Major

Don't key the teardown cleanup off document.activeElement.

If this pane unmounts while it owns terminal focus, the helper can disappear before the effect cleanup runs. Then lines 1482-1486 skip syncFocused(false), leaving both data-regular-terminal-input-focused and window.api.ui.setTerminalInputFocused stuck true. The next zoom shortcut still routes to terminal, and the top chrome can stay no-drag after closing or switching away from the focused terminal.

Suggested fix
   useEffect(() => {
     const container = containerRef.current
     if (!container) {
       return
     }
+    let ownsRegularTerminalFocus = false
     const syncFocused = (focused: boolean): void => {
+      ownsRegularTerminalFocus = focused
       setRegularTerminalInputFocusAttribute(focused)
       window.api.ui.setTerminalInputFocused?.(focused)
     }
@@
     return () => {
       container.removeEventListener('focusin', onFocusIn)
       container.removeEventListener('focusout', onFocusOut)
       document.removeEventListener('pointerdown', onPointerDown, true)
       window.removeEventListener('blur', onWindowBlur)
       window.removeEventListener('focus', onWindowFocus)
-      if (
-        isXtermHelperTextarea(document.activeElement) &&
-        container.contains(document.activeElement)
-      ) {
+      if (ownsRegularTerminalFocus) {
         syncFocused(false)
       }
     }
   }, [])

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a5af6bff-29f3-47d2-b66c-2448108ee868

📥 Commits

Reviewing files that changed from the base of the PR and between ce2a9a8 and 1652011.

📒 Files selected for processing (10)
  • src/renderer/src/assets/main.css
  • src/renderer/src/components/tab-group/TabGroupPanel.tsx
  • src/renderer/src/components/tab-group/TabGroupSplitLayout.tsx
  • src/renderer/src/components/terminal-pane/TerminalPane.tsx
  • src/renderer/src/components/terminal-pane/regular-terminal-focus-ownership.test.ts
  • src/renderer/src/components/terminal-pane/regular-terminal-focus-ownership.ts
  • src/renderer/src/components/terminal-pane/useTerminalFontZoom.test.ts
  • src/renderer/src/components/terminal-pane/useTerminalFontZoom.ts
  • src/renderer/src/hooks/resolve-zoom-target.ts
  • src/renderer/src/hooks/useIpcEvents.test.ts

@brennanb2025
brennanb2025 merged commit 14afd13 into main Jun 24, 2026
1 check passed
@brennanb2025
brennanb2025 deleted the brennanb2025/reset-terminal-zoom branch June 24, 2026 23:31
vodves-vodves added a commit to vodves-vodves/orca that referenced this pull request Aug 30, 2026
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
@AmethystLiang

Copy link
Copy Markdown
Contributor

thanks for reporting. looking into it

@AmethystLiang

Copy link
Copy Markdown
Contributor

thanks for reporting. looking into it

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.

3 participants