Skip to content

drag and drop for import table#382

Merged
eagleoflqj merged 2 commits into
masterfrom
table
Jun 19, 2026
Merged

drag and drop for import table#382
eagleoflqj merged 2 commits into
masterfrom
table

Conversation

@eagleoflqj

@eagleoflqj eagleoflqj commented Jun 19, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features
    • Added multi-file support for importing customized input method tables.
    • Updated the import experience to a tab-based interface for easier access and selection.
  • Bug Fixes
    • Improved import-table UI reliability on macOS (more robust file selection and scrolling behavior).
  • Tests
    • Added an automated test covering the customized table import flow, including persistence checks.
  • Chores
    • Updated bundled dependency versions used by the project.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: df2fe856-0538-4223-9dad-925d8e97c4e1

📥 Commits

Reviewing files that changed from the base of the PR and between 6d2892a and b1fcd67.

📒 Files selected for processing (4)
  • appium/test_import_customized_table.py
  • appium/util/window.py
  • fcitx5-webview
  • src/config/util.swift
✅ Files skipped from review due to trivial changes (1)
  • fcitx5-webview
🚧 Files skipped from review as they are similar to previous changes (3)
  • appium/test_import_customized_table.py
  • appium/util/window.py
  • src/config/util.swift

📝 Walkthrough

Walkthrough

Adds a multi-file import flow for customized table input methods: ImportTableVM gains selectedFiles, addFiles, and importFiles methods; ImportTableView renders a removable file list with a revised Import action; SelectInputMethod replaces the sheet with a TabView. util.swift adds environment-variable-backed directory resolution. Appium test utilities and an end-to-end import test are introduced alongside fixture files. Submodule pointers for fcitx5 and fcitx5-webview are also updated.

Changes

Import Customized Table Feature and Tests

Layer / File(s) Summary
Environment-variable-backed directory resolution
src/config/util.swift
Adds envDir helper reading a directory URL from an environment variable with fallback; updates configDir and localDir to use FCITX_CONFIG_HOME and FCITX_DATA_HOME.
ImportTableVM: multi-file selection and import logic
src/config/ImportTable.swift
Introduces selectedFiles: [URL], addFiles(_:) for suffix-filtered dedup append, importFiles() for directory creation, destination routing, overwrite checks, file copy, and error callbacks, and rewrites convertTxt to accept a URL list and return failures.
ImportTableView UI and import action
src/config/ImportTable.swift
Switches to @StateObject, moves setup to .onAppear, renders a removable selected-file list with empty-state placeholder, and reworks the Import button to call convertTxt, importFiles, reload Fcitx, compute new IMs, and invoke onAdd/onError/finalize.
SelectInputMethod: sheet replaced with TabView
src/config/SelectInputMethod.swift
Extracts NavigationSplitView into a reusable splitView constant, removes the "Import customized table" button and sheet state, and conditionally wraps the layout in a two-tab TabView when zh_CN/pinyin is available.
Appium window and file-panel utilities
appium/util/window.py, appium/util/file.py
Rewrites find_element_by_id with timeout-based explicit wait and uniqueness validation, adds scrollTo for scroll-until-found navigation, and adds go_inside/select_files for macOS open-panel directory traversal and multi-file selection with modifier-key clicks.
Appium test fixtures and end-to-end import test
appium/table/customized.conf.in, appium/table/customized.txt, appium/test_import_customized_table.py
Adds config template and key mapping fixture files; implements test_import_customized_table which navigates the import tab, drags in three files, removes one, triggers import, and asserts UI state and filesystem output.

Submodule Pointer Updates

Layer / File(s) Summary
fcitx5 submodule pointer update
fcitx5
The fcitx5 submodule reference is updated to a new commit hash.
fcitx5-webview submodule pointer update
fcitx5-webview
The fcitx5-webview submodule reference is updated to a new commit hash.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ImportTableView
  participant ImportTableVM
  participant FileSystem
  participant Fcitx

  User->>ImportTableView: drag/click to select files
  ImportTableView->>ImportTableVM: addFiles(urls)
  ImportTableVM->>ImportTableVM: filter suffixes, deduplicate, append to selectedFiles
  ImportTableView-->>User: renders removable file list

  User->>ImportTableView: click Import
  ImportTableView->>ImportTableVM: convertTxt(selectedFiles)
  ImportTableVM-->>ImportTableView: [failedTxtNames]
  ImportTableView->>ImportTableVM: importFiles()
  ImportTableVM->>FileSystem: create dirs, copy files
  FileSystem-->>ImportTableVM: results / errors
  ImportTableVM-->>ImportTableView: [importedBaseNames]
  ImportTableView->>Fcitx: reloadConfig()
  ImportTableView->>ImportTableView: compute newIMs, call onAdd / onError / finalize
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 Hop, hop, drop your files in a row,
The panel scrolls and the imports flow!
No more sheets — a tab takes their place,
Env vars now set the config space.
The bunny approves each .conf laid neat,
With Appium tests to make it complete! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'drag and drop for import table' accurately summarizes the main change, which adds drag-and-drop file selection functionality to the import table feature across multiple files (UI, utilities, and tests).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch table

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@appium/test_import_customized_table.py`:
- Line 19: The table_path variable construction at line 19 relies on os.getcwd()
which makes the test fragile and dependent on the execution context. Replace the
current path construction that uses os.getcwd() with one that uses __file__ to
get the directory of the current test file itself, then navigate relatively from
there to reach the "appium/table" directory. This ensures the path is always
resolved correctly regardless of the working directory when the test runs.

In `@appium/util/window.py`:
- Around line 67-80: The scrollTo function contains an unbounded while True loop
that can hang indefinitely if the element with the given ID is never found
during scrolling. Add a bounded exit mechanism by introducing a counter variable
to track the number of scroll attempts, and break from the loop after reaching a
maximum attempt limit. When the limit is exceeded, either raise an appropriate
exception or handle the case gracefully to prevent the test from hanging.
- Around line 19-30: The find_element_by_id function currently catches all
exceptions and converts them to a generic timeout message, which masks
actionable failures like the ValueError raised when duplicate elements are found
on line 27. Replace the broad except Exception block with a specific exception
handler that only catches the timeout exception (TimeoutException from
selenium.common.exceptions), allowing other exceptions like the ValueError for
duplicate matches to propagate with their original error messages. This
preserves meaningful error information while still providing a timeout-specific
message when the wait condition actually times out.

In `@src/config/ImportTable.swift`:
- Around line 211-227: The convertTxt function returns failures, but the code
currently reports these failures only after performing the import operations
including importTableVM.importFiles(), Fcitx.reload(), and onAdd(newIMs), which
leaves the system in a partial import state. Move the failure check immediately
after the convertTxt call at the beginning of the block, construct the error
message if failures are not empty, call onError with that message, and return
early before proceeding with importTableVM.importFiles(), importTableVM.load(),
filtering, Fcitx.reload(), onAdd, and dismiss operations. This ensures the
import process fails fast and does not proceed if txt conversion failed.
- Around line 83-85: The conversion operation at the exec call (where the
converter is invoked with url.localPath() and dest.localPath()) lacks protection
against overwriting existing destination files. Before executing the converter,
check whether the destination file (stored in the dest variable which is created
from tableLocalDir.appendingPathComponent) already exists, and handle this case
appropriately by either skipping the conversion, raising an error, or using an
explicit overwrite flag to prevent unintended data loss or ambiguous converter
failures.

In `@src/config/util.swift`:
- Around line 6-7: In the ProcessInfo.processInfo.environment lookup for FCITX_*
environment variables, the current code accepts empty string values and creates
a path from them, which bypasses the fallback logic. Modify the condition that
checks if let value exists to also verify that the value is not empty
(value.isEmpty is false), ensuring that empty environment variables are treated
as unset and allow the fallback to be used instead of creating a URL from an
empty string.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1e3cd242-70f1-4ce6-9bc2-1cb573663b10

📥 Commits

Reviewing files that changed from the base of the PR and between 2734b3c and 6d2892a.

📒 Files selected for processing (12)
  • appium/table/customized.conf.in
  • appium/table/customized.dict
  • appium/table/customized.txt
  • appium/test_import_customized_table.py
  • appium/util/file.py
  • appium/util/window.py
  • assets/zh-Hans.lproj/Localizable.strings
  • assets/zh-Hant.lproj/Localizable.strings
  • fcitx5
  • src/config/ImportTable.swift
  • src/config/SelectInputMethod.swift
  • src/config/util.swift

Comment thread appium/test_import_customized_table.py Outdated
Comment thread appium/util/window.py
Comment thread appium/util/window.py
Comment thread src/config/ImportTable.swift
Comment thread src/config/ImportTable.swift
Comment thread src/config/util.swift Outdated
@github-actions

Copy link
Copy Markdown

arm64 comparison

No difference.

x86_64 comparison

No difference.

@eagleoflqj eagleoflqj merged commit f4b3907 into master Jun 19, 2026
8 checks passed
@eagleoflqj eagleoflqj deleted the table branch June 19, 2026 03:44
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.

1 participant