cmux/Sources
Lawrence Chen 17bcbcc1cb
Fix all split panes appearing focused after layout restoration (#2088)
* Fix all split panes appearing focused after layout restoration

Ghostty C surfaces default to focused=true (Terminal.zig), but
TerminalSurface.lastFocusState was initialized to false. During
restoration, unfocus() is called before C surfaces exist (views not in
window yet), so the ghostty_surface_set_focus(false) call was silently
dropped. When surfaces were later created, the dedup guard
(false != false) prevented the unfocus from ever reaching the renderer.

Three changes:
- Initialize lastFocusState=true to match Ghostty's default
- In setFocus(), update lastFocusState before the surface-nil guard so
  the desired state is tracked even when the C surface doesn't exist yet
- In createSurface(), sync focus state after creation so surfaces that
  were logically unfocused before the C surface existed get the correct
  state applied

Fixes https://github.com/manaflow-ai/cmux/issues/2080

* Sync focus state unconditionally in createSurface

Per review feedback: always call ghostty_surface_set_focus(createdSurface,
lastFocusState) instead of only syncing when !lastFocusState. This avoids
coupling to Ghostty's default focused=true and is more robust if the
upstream default ever changes.

* Keep lastFocusState in sync with AppKit responder focus calls

The becomeFirstResponder, resignFirstResponder, and ctrl-key fast paths
call ghostty_surface_set_focus directly without updating lastFocusState.
This could cause the dedup guard in setFocus() to skip a needed call, or
createSurface() to replay a stale state on surface recreation.

Add recordExternalFocusState() and call it alongside each direct C focus
call so lastFocusState stays authoritative.

* Rename lastFocusState to desiredFocusState

The variable now tracks focus intent (may be set before the C surface
exists), not just the last-applied state. Update the name and doc
comment to reflect this.

---------

Co-authored-by: Lawrence Chen <lawrencecchen@users.noreply.github.com>
2026-03-24 20:36:35 -07:00
..
Find Add failing regression test for browser find focus (#1891) 2026-03-20 22:12:26 -07:00
Panels Fix splitter hitbox overlap and terminal scrollbar width resync (#1950) 2026-03-22 18:06:11 -07:00
Update fix: harden Sparkle manual update dialog flow 2026-03-21 15:19:31 -07:00
AppDelegate.swift Force windows visible on headless CI runners for UI test rendering 2026-03-23 03:53:19 -07:00
AppleScriptSupport.swift fix: read working directory from panelDirectories instead of TerminalPanel 2026-03-20 04:15:44 +08:00
Backport.swift Resync terminal portals after sidebar changes (#1253) 2026-03-12 02:46:30 -07:00
BrowserWindowPortal.swift Fix splitter hitbox overlap and terminal scrollbar width resync (#1950) 2026-03-22 18:06:11 -07:00
cmuxApp.swift Customizable number shortcuts (#1951) 2026-03-22 14:54:54 -07:00
ContentView.swift Fix sidebar badges not refreshing on workspace state change (#2046) 2026-03-24 19:18:18 -07:00
GhosttyConfig.swift Add configurable sidebar tint color with light/dark mode support (#1465) 2026-03-15 15:48:57 -07:00
GhosttyTerminalView.swift Fix all split panes appearing focused after layout restoration (#2088) 2026-03-24 20:36:35 -07:00
KeyboardLayout.swift Fix keyboard shortcuts not working with Korean (한글) input mode 2026-03-21 21:16:10 +09:00
KeyboardShortcutSettings.swift Customizable number shortcuts (#1951) 2026-03-22 14:54:54 -07:00
NotificationsPage.swift Add Jump to Latest to the notifications popover (#1167) 2026-03-10 19:30:17 -07:00
PortScanner.swift Avoid main-thread hops for explicit socket scope 2026-02-20 23:58:47 -08:00
PostHogAnalytics.swift Flush PostHog hourly active events immediately (#934) 2026-03-05 04:00:04 -08:00
RemoteRelayZshBootstrap.swift Support image drag-and-drop into SSH terminals (#1838) 2026-03-20 18:31:19 -07:00
SentryHelper.swift Auto-heal missing CLI listener socket (#679) 2026-02-28 01:19:38 -08:00
SessionPersistence.swift fix: skip identical session autosave writes (#1732) 2026-03-18 03:24:40 -07:00
SidebarSelectionState.swift Implement session persistence pass 1 with multi-window restore 2026-02-22 15:39:59 -08:00
SocketControlSettings.swift Merge remote-tracking branch 'origin/main' into pr-ssh-stack-main 2026-03-13 17:56:38 -07:00
TabManager.swift Fix sidebar badges not refreshing on workspace state change (#2046) 2026-03-24 19:18:18 -07:00
TerminalController.swift feat: expose per-surface TTY in tree output (#2040) 2026-03-24 20:27:23 -07:00
TerminalImageTransfer.swift Fix SSH image transfer followups (#1904) 2026-03-20 21:32:21 -07:00
TerminalNotificationStore.swift Fix tmux notification attention routing 2026-03-20 20:20:54 -07:00
TerminalSSHSessionDetector.swift Fix SSH image transfer cleanup and IPv6 followups (#1907) 2026-03-20 22:04:52 -07:00
TerminalView.swift Add sidebar blur effect with withinWindow blending (#9) 2026-02-04 03:04:45 -08:00
TerminalWindowPortal.swift fix: hide stale terminal portal after restore churn 2026-03-23 19:19:05 -07:00
UITestRecorder.swift Fix frozen terminals after split churn (#12) 2026-02-13 16:45:31 -08:00
WindowAccessor.swift Polish browser suggestions, focus, and tagged reload flow 2026-02-14 21:33:28 -08:00
WindowDecorationsController.swift Refine settings/about titlebar styling and controls alignment 2026-02-14 02:11:35 -08:00
WindowDragHandleView.swift Fix re-entrant exclusive-access crash in drag handle hit test (#771) 2026-03-02 19:20:14 -08:00
WindowToolbarController.swift Reapply "Merge pull request #239 from manaflow-ai/issue-151-ssh-remote-port-proxying" 2026-03-12 15:54:26 -07:00
Workspace.swift Merge pull request #1915 from elvistranhere/fix/split-crash-intel-1870 2026-03-22 17:14:03 -07:00
WorkspaceContentView.swift Merge pull request #1834 from lifrary/fix/replace-force-unwrapped-utf8-data-encoding 2026-03-22 15:38:40 -07:00