Skip to content

refactor: decouple config ui and IMK#362

Merged
eagleoflqj merged 3 commits intomasterfrom
dev
May 2, 2026
Merged

refactor: decouple config ui and IMK#362
eagleoflqj merged 3 commits intomasterfrom
dev

Conversation

@eagleoflqj
Copy link
Copy Markdown
Member

No description provided.

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

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 FcitxInputController menu action selectors into a new src/menu.swift.
  • Adjusted build/test wiring for the relocated color helper (src/config/color.swift) and moved ModifierState into 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.controllers is a mutable global dictionary but the class/methods that access it aren’t consistently MainActor-isolated (e.g. windowShouldClose is not annotated). This can trigger Swift concurrency warnings and risks data races if any call happens off the main thread. Consider marking ConfigWindowController as @MainActor (or at least isolating controllers and windowShouldClose to @MainActor), and making controllers private since all access goes through the static helpers.
    src/config/color.swift:19
  • getAccentColor is now public while it mutates a shared nonisolated(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.

Comment thread src/config/KeyboardViewer.swift
Comment thread src/controller.swift
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

arm64 comparison

No difference.

x86_64 comparison

No difference.

@eagleoflqj eagleoflqj merged commit 7f2a5c3 into master May 2, 2026
11 checks passed
@eagleoflqj eagleoflqj deleted the dev branch May 2, 2026 18:23
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