macos: quick-terminal - dock hide/unhide logic changes#13039
Conversation
298af4b to
1366301
Compare
There was a problem hiding this comment.
First of all, it doesn't fix the issue for me using this branch.
Then it lacks proper documentation about why in the code, it’s a lot of maintenance for us to understand it.
And you removed the per-screen check without explaining why, it will now automatically hide the dock even if I open the quick terminal on a screen without a dock.
I suggest you check all the lines you deleted or changed; you can blame the changes and check whether your changes would break anything.
Thanks for trying tho!
NOTE
I sense your pr description is generated by AI which contains a lot noise, please take a look at our AI policy, and edit it yourself. It will be closed if it keeps like this.
| } | ||
| } | ||
|
|
||
| /// Log Quick Terminal debug messages from the embedding layer. |
There was a problem hiding this comment.
You don't need add logging function here, just use OSLog like in other places in Swift.
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.