Reset panel state after inactivity timeout#7
Merged
Conversation
Panel was holding the previous search, scroll position, and selection across hide/show because PanelController caches the FloatingPanel and SearchViewModel for the app's lifetime. After a long gap that 'resume' behaviour is friction, not a feature. On show, if the panel has been hidden longer than the new panelResetTimeout preference (default 2 minutes), reset the view-model back to a clean state — empty query, results re-queried from scratch, first item selected. Configurable in Settings → Behaviour, with a Never option for anyone who liked the old behaviour. Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: GitButler <gitbutler@gitbutler.com>
There was a problem hiding this comment.
Pull request overview
Adds an inactivity-based reset so the search panel doesn’t retain stale query/selection state across long gaps, with a new user preference to configure (or disable) the timeout.
Changes:
- Add
PanelResetTimeoutpreference (default 2 minutes) and expose it in Settings → Behaviour. - Add
SearchViewModel.resetState()to clear the query and refresh results immediately. - Track panel hide time in
PanelControllerand reset state on show when hidden longer than the configured timeout.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Sources/Vista/SettingsView.swift | Adds a Behaviour-tab picker for the new “Reset after” preference. |
| Sources/Vista/SearchViewModel.swift | Introduces resetState() used to clear and re-run an empty query. |
| Sources/Vista/Preferences.swift | Adds PanelResetTimeout enum + persisted panelResetTimeout preference. |
| Sources/Vista/PanelController.swift | Centralizes hiding via hidePanel(), stamps lastHiddenAt, and resets state on show after timeout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Cover AppKit's hidesOnDeactivate auto-hide path: route every dismissal through a new FloatingPanel.onHide hook so lastHiddenAt is also stamped when the panel hides on focus loss, not just explicit calls. - Cancel the debounced query inside SearchViewModel.resetState() so we don't run store.search twice (sync + 120 ms debounced replay). - Reword the 'Reset after' caption to 'between panel opens' — the previous 'across sessions' wording implied state survived an app relaunch, which it doesn't. Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: GitButler <gitbutler@gitbutler.com>
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.
Summary
PanelControllercaches theFloatingPanelandSearchViewModelfor the app's lifetime, so the previous query, scroll position, and selected cell survived every dismiss. Within a single train of thought that's "resume where I left off". Come back an hour later and a stale query is friction, not a feature.panelResetTimeoutpreference (default 2 minutes, configurable in Settings → Behaviour). On show, if the panel has been hidden longer than the timeout,SearchViewModel.resetState()clears the query and runs an empty search synchronously —selectedIndex = 0andscrollProxy.scrollToalready snap the grid back to the first cell, so no view-layer change.Neverkeeps the old behaviour for anyone who liked it.hidePanel()helper (waspanel?.orderOut(nil)in three places) solastHiddenAtstays accurate whether dismissal comes from the hotkey, the dismiss closure, or the paste-to-front-app flow.Test plan
swift buildpasses.lastHiddenAt(verify by mixing dismissal paths and observing reset on the next show).