Skip to content

fix: make NSOpenPanel singleton#361

Merged
eagleoflqj merged 2 commits intomasterfrom
openpanel
Apr 19, 2026
Merged

fix: make NSOpenPanel singleton#361
eagleoflqj merged 2 commits intomasterfrom
openpanel

Conversation

@eagleoflqj
Copy link
Copy Markdown
Member

No description provided.

@github-actions
Copy link
Copy Markdown

arm64 comparison

No difference.

x86_64 comparison

No difference.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.swift with a @MainActor selectFile(...) wrapper that prevents multiple open panels at once.
  • Migrated existing NSOpenPanel usages in config views (file/app selection, dict/data import/export, plugin manual install) to use selectFile(...).
  • Updated scripts/check-code-style.sh to forbid new direct NSOpenPanel construction outside PanelManager.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, so importDataSelectedDirectory is 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, selectFile likely 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.

Comment thread src/config/PanelManager.swift
Comment thread src/config/PanelManager.swift
Comment thread src/config/plugin.swift
Comment thread src/config/DictManager.swift
@eagleoflqj eagleoflqj merged commit a1430d8 into master Apr 19, 2026
7 checks passed
@eagleoflqj eagleoflqj deleted the openpanel branch April 19, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants