fix: make NSOpenPanel singleton#361
Merged
eagleoflqj merged 2 commits intomasterfrom Apr 19, 2026
Merged
Conversation
arm64 comparisonNo difference. x86_64 comparisonNo difference. |
There was a problem hiding this comment.
Pull request overview
This PR centralizes macOS file picker usage behind a single selectFile(...) helper to avoid simultaneous NSOpenPanel usage, and refactors config UI surfaces to use that helper consistently.
Changes:
- Added
PanelManager.swiftwith a@MainActorselectFile(...)wrapper that prevents multiple open panels at once. - Migrated existing
NSOpenPanelusages in config views (file/app selection, dict/data import/export, plugin manual install) to useselectFile(...). - Updated
scripts/check-code-style.shto forbid new directNSOpenPanelconstruction outsidePanelManager.swift.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/config/ui.swift | Refactors SelectFileButton and selectApplication to use selectFile(...). |
| src/config/plugin.swift | Replaces per-view NSOpenPanel with selectFile(...) for manual plugin install. |
| src/config/VimModeView.swift | Switches app picker to new selectApplication signature (no injected panel). |
| src/config/AppIMView.swift | Switches app picker to new selectApplication signature (no injected panel). |
| src/config/DictManager.swift | Uses selectFile(...) for dictionary imports and tracks selected directory via callback. |
| src/config/DataManager.swift | Uses selectFile(...) for zip import and export destination selection. |
| src/config/PanelManager.swift | Introduces the shared selectFile(...) implementation and singleton-like gating. |
| scripts/check-code-style.sh | Enforces using selectFile(...) instead of direct NSOpenPanel creation. |
Comments suppressed due to low confidence (1)
src/config/DataManager.swift:110
- With
selectFile, the callback only runs on.OK, soimportDataSelectedDirectoryis now updated only when the user confirms a file selection. Previously the directory preference was updated even when the panel was cancelled (capturing the last browsed directory). If that behavior is still desired,selectFilelikely needs to report the response (or invoke a callback on cancel) so this preference can be updated consistently.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
No description provided.