refactor: decouple config ui and IMK#362
Merged
eagleoflqj merged 3 commits intomasterfrom May 2, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors config-window plumbing to reduce direct coupling between the IMK input controller and the SwiftUI config UI, while relocating menu/config window actions into a dedicated entry point.
Changes:
- Centralized config window lifecycle operations under
ConfigWindowController(open/close/refresh) and updated call sites. - Moved
FcitxInputControllermenu action selectors into a newsrc/menu.swift. - Adjusted build/test wiring for the relocated color helper (
src/config/color.swift) and movedModifierStateinto the config UI area.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/CMakeLists.txt | Updates ColorSwift test source path to src/config/color.swift. |
| src/CMakeLists.txt | Adds menu.swift to the app target sources. |
| src/server.swift | Switches refresh call to ConfigWindowController.refreshAll(). |
| src/menu.swift | New file housing FcitxInputController @objc menu action handlers. |
| src/controller.swift | Removes ModifierState declaration from the IMK controller file. |
| src/config/ConfigWindowController.swift | Moves window management helpers onto ConfigWindowController and reorganizes restartProcess. |
| src/config/plugin.swift | Routes refresh/close operations through ConfigWindowController. |
| src/config/SplitConfig.swift | Replaces direct window dictionary access with ConfigWindowController.closeWindow. |
| src/config/InputMethod.swift | Updates close action to ConfigWindowController.closeWindow. |
| src/config/Advanced.swift | Updates close actions to ConfigWindowController.closeWindow. |
| src/config/color.swift | Adjusts visibility of color helpers (nsColorToString, getAccentColor). |
| src/config/KeyboardViewer.swift | Relocates ModifierState into config UI code. |
Comments suppressed due to low confidence (2)
src/config/ConfigWindowController.swift:10
ConfigWindowController.controllersis a mutable global dictionary but the class/methods that access it aren’t consistently MainActor-isolated (e.g.windowShouldCloseis not annotated). This can trigger Swift concurrency warnings and risks data races if any call happens off the main thread. Consider markingConfigWindowControlleras@MainActor(or at least isolatingcontrollersandwindowShouldCloseto@MainActor), and makingcontrollersprivatesince all access goes through the static helpers.
src/config/color.swift:19getAccentColoris nowpublicwhile it mutates a sharednonisolated(unsafe)cache (colorMap) without synchronization. Making this API public increases the chance it’s called from multiple threads/contexts and introduces a real data-race risk. Consider keeping it internal, or making it@MainActor/ protecting the cache with an actor or lock to ensure thread safety.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
arm64 comparisonNo difference. x86_64 comparisonNo difference. |
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.