feat: add persistent switches to PopupBuilder#122
Merged
actionshrimp merged 2 commits intomainfrom Mar 12, 2026
Merged
Conversation
Introduces magit-style sticky popup switches that remember their enabled
state across popup invocations. A switch with a `persist_key` saves its
state to stdpath("data")/gitlad/popup_switches.json on every toggle and
loads it back when the popup is built.
- New `lua/gitlad/utils/persist.lua` — lightweight JSON key-value store
with `_override_path` for test isolation
- `PopupBuilder:switch()` gains `persist_key?` opt
- `PopupData:build()` loads persisted state, overriding `opts.enabled`
- `PopupData:toggle_switch()` saves state; also persists exclusive
switches that get force-disabled by mutual exclusion
- New `GitladPopupSwitchPersistent` highlight group (DiagnosticHint)
visually distinguishes persistent-on from transient-on switches
- 14 unit tests + 4 e2e tests
Will be used by the worktrunk `--copy-ignored` switch in PR 2.
Owner
Author
|
Re: testing this PR — there's nothing to observe with |
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
persist_keyopt onPopupBuilder:switch()lua/gitlad/utils/persist.lua— lightweight JSON key-value store (stdpath("data")/gitlad/popup_switches.json)PopupData:build()loads persisted state (overridesopts.enabled);toggle_switch()saves on every toggle, including force-disabled exclusive switchesGitladPopupSwitchPersistenthighlight group (DiagnosticHint) visually distinguishes persistent-on from transient-on switches in the popup UIThis is PR 1 of the worktrunk integration plan (
WORKTRUNK_PLAN.md). The persistent switch infrastructure will be used by the--copy-ignoredflag in PR 2.Test plan
make testpasses (1610 unit + 647 e2e, all green)make lintpassespersist_key, close and reopen — switch should still be enabled