Skip to content

feat(sidebar): show sidebar only in the active window#285

Merged
umputun merged 2 commits into
masterfrom
sidebar-autohide
Jul 24, 2026
Merged

feat(sidebar): show sidebar only in the active window#285
umputun merged 2 commits into
masterfrom
sidebar-autohide

Conversation

@umputun

@umputun umputun commented Jul 24, 2026

Copy link
Copy Markdown
Owner

opt-in Interface setting: with multiple windows open, only the frontmost window shows its sidebar and every other collapses. Sidebar visibility follows window focus, so switching windows moves the sidebar with focus; switching to another app leaves every sidebar untouched. Off by default.

Behavior

  • absolute rule, no per-window memory: a manual ⌃⌘S hide on the active window is transient and re-shows on refocus
  • fires only when an agterm window becomes frontmost (never on resign), so app-switching doesn't touch any sidebar
  • turning it on applies immediately; turning it off leaves background windows collapsed until reopened

Implementation

  • AppSettings.autoHideSidebarInactiveWindows (nil = off), mirrored into GhosttyApp (the non-observable chrome-mirror pattern the other toggles use)
  • host-free driver WindowLibrary.applyInactiveWindowSidebarHiding() sets the active window's sidebar visible and the rest hidden
  • driven from WindowAccessor.reportFrontmost on every window activation, and once when the toggle flips on, so new-window and launch reconcile too
  • companion fix: acceptsFirstMouse returns false while the setting is on, so the click that activates an inactive window doesn't press the terminal button and turn the mid-gesture sidebar-resize into a phantom selection
  • lives under Settings ▸ Interface ▸ Multiple Windows

GUI-only, keep-in-sync exempt like the other settings toggles (the sidebar capability already has full control coverage via sidebar + sidebarVisible).

verified: host-free round-trip + driver tests (swift test, 1737 pass), app build + swiftlint strict clean, and by hand in a dev instance.

umputun added 2 commits July 24, 2026 02:37
opt-in Interface setting: with multiple windows open, only the frontmost
window shows its sidebar and every other collapses. Sidebar visibility
follows window focus, so switching windows moves the sidebar with focus;
switching to another app leaves every sidebar untouched.

- AppSettings.autoHideSidebarInactiveWindows (nil = off), mirrored into
  GhosttyApp; host-free driver WindowLibrary.applyInactiveWindowSidebarHiding
  sets the active window's sidebar visible and the rest hidden
- WindowAccessor.reportFrontmost fires the driver on real frontmost changes
  only (never on resign); the toggle applies immediately when flipped on
- absolute rule, no per-window intent: a manual hide on the active window is
  transient and re-shows on refocus

acceptsFirstMouse returns false while the setting is on: the click that
activates an inactive window would otherwise press the terminal button, and
the sidebar expanding mid-gesture resized the surface under the held press
into a phantom selection. Now the activating click only raises the window.

GUI-only, keep-in-sync exempt like every other settings toggle (the sidebar
capability already has full control coverage via `sidebar` + sidebarVisible).
- [major] [WindowAccessor.swift] run the auto-hide sidebar driver on every window
  activation report, not only on a frontmost-id change. newWindow() pre-sets
  frontmostWindowID before the window keys and launch restores it, so the old
  guard skipped those paths and left the prior window's sidebar showing (or the
  restored frontmost collapsed). Persist + frontmost-changed post stay gated to a
  real change; the driver is idempotent so an unchanged re-key is cheap.
- [major] [WindowLibraryTests.swift] strengthen the single-window driver test to
  hide the sidebar first, then assert the driver re-shows it (was passing even
  with the driver deleted, since sidebarVisible defaults to true).
- [minor] [WindowLibrary.swift] correct the driver doc comment: a single-window
  library force-shows the sole window's sidebar, it is not a no-op.
- [docs] [windows.md] inventory the new applyInactiveWindowSidebarHiding method.
Copilot AI review requested due to automatic review settings July 24, 2026 08:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@umputun
umputun merged commit 5fc8009 into master Jul 24, 2026
7 checks passed
@umputun
umputun deleted the sidebar-autohide branch July 24, 2026 08:07
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.

2 participants