macos: quick-terminal - dock hide/unhide logic changes#13039
Open
exlee wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Quick Terminal Dock / Space Handling
Notes
This PR addresses macOS: quick terminal auto hiding dock not restored when keyboard used to switch spaces #5685
Exposure of a logging function to Swift is an extra and could be separated
I have another PR in preparation that allows enabling/disabling dock. It should be stacked on top of this PR though.
LLM disclaimer
Contextual information
Initial State
Quick Terminal could hide the Dock when shown in a position that conflicts with
the Dock, but the restore path was tied mostly to quick-terminal toggle
and window focus events.
That left a few awkward Space-change cases:
or animation callbacks did not restore it.
flash when the same Quick Terminal window was about to regain focus.
even when user Dock auto-hide is off, so using "Dock is hidden" as the only
signal could make Quick Terminal mutate user Dock settings at the wrong time.
State Machine
The Dock logic now has two layers.
The first layer is the desired state:
shouldBeHidden == true: Quick Terminal currently wants the Dock hidden.shouldBeHidden == false: Quick Terminal no longer wants to own Dock hiding.The second layer is the managed side-effect state:
managedHidden == true: Quick Terminal changed global Dock auto-hide and isresponsible for restoring it later.
managedHidden == false: Quick Terminal has not changed global Dock auto-hide.The pure reducer is
QuickTerminalDockState:shouldBeHiddenbecomes true, transition tohideand markmanagedHidden.shouldBeHiddenbecomesfalse on a normal Space, transition to
showand clearmanagedHidden.managed and does not restore it later.
showtransition. It preserves
managedHiddenso the restore can happen later afterreturning to a normal Space.
flowchart LR request["setShouldHide(value) or apply()"] desired["Update / read shouldBeHidden"] hidden{"Dock hidden?\nDock.autoHide || fullscreen"} wantsHide{"shouldBeHidden?"} managed{"managedHidden?"} fullscreen{"fullscreen Space?"} hide["transition: hide\nmanagedHidden = true\nDock.autoHide = true"] show["transition: show\nmanagedHidden = false\nDock.autoHide = false"] defer["transition: none\nkeep managedHidden = true\nrestore later"] noop["transition: none\nno Dock side effect"] request --> desired --> wantsHide wantsHide -- true --> hidden hidden -- false --> hide hidden -- true --> noop wantsHide -- false --> managed managed -- false --> noop managed -- true --> fullscreen fullscreen -- false --> show fullscreen -- true --> deferHiddenDockwraps that reducer and performs the AppKit/global Dock side effectsonly when the reducer returns
hideorshow.Changes
Added
Dock hiding, it immediately refocuses the same Quick Terminal window instead
of waiting for the delayed restore path.
read-only for Dock restore, so Quick Terminal never unhides the Dock while
fullscreen is active.
Changed
HiddenDocknow delegates hide / show decisions toQuickTerminalDockState,a testable pure state machine.
HiddenDockonly performs AppKit/global Dock side effects when the reducerreturns an explicit
hideorshowtransition.windowDidResignKeyno longer restores the Dock during transient focus lossfrom Space movement, avoiding a flash before the same Quick Terminal window is
re-keyed.
Maintenance
shouldBeHiddenis applied if the Dock later becomes visibleRationale
shouldBeHiddenrecords whether Quick Terminal wants the Dock hidden;managedHiddenrecords whether Quick Terminal actually changed global Dock auto-hide and must restore it later. This avoids interfering with users who already keep the Dock hidden.quickterm -> Space changecan briefly produce a non-focused Quick Terminal window. If Quick Terminal still owns focus / Dock hiding, it immediately re-keys the same window instead of restoring the Dock and causing a flash.