Skip to content

Add Tools > Apply Motif changes - #1162

Open
johnml1135 wants to merge 2 commits into
mainfrom
feature/apply-motif-changes
Open

johnml1135 wants to merge 2 commits into
mainfrom
feature/apply-motif-changes

Conversation

@johnml1135

@johnml1135 johnml1135 commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Linguists can review parser results in Motif, a separate tool for checking a project's analyses. Motif lets them approve or disapprove analyses and add new ones. Until now, the only way to get those decisions back into the FieldWorks project was to close FieldWorks and run Motif against the project.

This adds Tools > Apply Motif changes…. It is available in every area, like Send/Receive. FieldWorks asks for confirmation, saves the project, and releases its lock. It then runs Motif once, the same way it runs FLEx Bridge:

motif apply --all-pending --project "<project>.fwdata" --json

What happens next depends on Motif's result:

Motif's result What FieldWorks does What the linguist sees
Changes applied (exit 0) Reloads the project "Motif changes were applied…", with Motif's short summary
Nothing to apply (exit 0) Relocks, no reload "There are no Motif changes waiting to be applied."
Refused because the changes no longer fit (exit 2) Relocks; nothing changed "Open Motif to review them, then try again."
Motif is busy with this project (exit 3) Relocks A Motif-busy message
Motif could not confirm the result (exit 4), or any unexpected result Reloads, never retries "Open Motif to see what happened before you try again."

If relocking fails, FieldWorks reloads instead, so it never keeps editing a project that Motif may have written to. A wait cursor shows while Motif runs.

Finding Motif.

  1. The MOTIF_DIR environment variable, a folder containing motif.exe.
  2. Otherwise InstallationDir under HKLM\SOFTWARE\SIL\Motif, in both registry views, which Motif's installer writes.

FieldWorks never searches PATH and writes nothing to the registry. If Motif is not installed, the command says so. The lookup is cached, so the menu doesn't query the registry on every idle update.

FieldWorks references nothing of Motif's. It reads the exit code and a few stable JSON fields, ok, applied, summary and code, and ignores anything else, so Motif can extend its output without breaking FieldWorks. There is no Undo for applied changes. The confirmation doesn't promise one.

Code.

  • MotifExecutableResolver and MotifApplyRunner are in FwUtils. Discovery and the process are injected.
  • MotifApplyWorkflow holds the save, run, and reload-or-relock decisions, plus message selection.
  • FLExBridgeListener wires the command, reusing FLEx Bridge's save, unlock and reopen steps.
  • The strings are in LexEdStrings.resx, with translator comments.

Tests. They need no Motif installation. FwUtilsTests cover discovery (environment variable, registry, not found), argument quoting, and every exit code and JSON case: malformed, missing, unknown fields, and a single invocation on exit 4. A real-process test drains more than 64 KB from both output streams. LexEdDllTests cover the save and unlock order, reload versus relock for each outcome, a relock that throws, reload failure, message selection, and the menu configuration.

The matching Motif change, which releases apply --all-pending and gives the result an exit code, is in Motif's repository. It will be available before this is used outside development.

🤖 Generated with Claude Code


This change is Reviewable

johnml1135 and others added 2 commits September 26, 2026 23:35
Co-Authored-By: GPT-6 Luna <noreply@openai.com>
Run Motif at the save boundary and restore the cache according to its result.

Co-Authored-By: GPT-6 Luna <noreply@openai.com>
@codecov-commenter

codecov-commenter commented Sep 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 53.95189% with 134 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.03%. Comparing base (30564cc) to head (7a62222).

Files with missing lines Patch % Lines
Src/LexText/Lexicon/FLExBridgeListener.cs 0.00% 77 Missing and 6 partials ⚠️
Src/Common/FwUtils/MotifApplyRunner.cs 77.57% 14 Missing and 10 partials ⚠️
Src/Common/FwUtils/MotifExecutableResolver.cs 51.16% 14 Missing and 7 partials ⚠️
Src/LexText/Lexicon/MotifApplyWorkflow.cs 89.65% 0 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1162      +/-   ##
==========================================
+ Coverage   39.02%   39.03%   +0.01%     
==========================================
  Files        1522     1525       +3     
  Lines      352937   353227     +290     
  Branches    40726    40779      +53     
==========================================
+ Hits       137741   137898     +157     
- Misses     185893   185997     +104     
- Partials    29303    29332      +29     
Files with missing lines Coverage Δ
Src/LexText/Lexicon/MotifApplyWorkflow.cs 89.65% <89.65%> (ø)
Src/Common/FwUtils/MotifExecutableResolver.cs 51.16% <51.16%> (ø)
Src/Common/FwUtils/MotifApplyRunner.cs 77.57% <77.57%> (ø)
Src/LexText/Lexicon/FLExBridgeListener.cs 4.03% <0.00%> (-0.39%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown

NUnit Tests

    1 files  ± 0      1 suites  ±0   13m 33s ⏱️ +33s
6 340 tests +39  6 255 ✅ +39  85 💤 ±0  0 ❌ ±0 
6 349 runs  +39  6 264 ✅ +39  85 💤 ±0  0 ❌ ±0 

Results for commit 7a62222. ± Comparison against base commit 30564cc.

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