Skip to content

Run the record list's menu commands without the Mediator - #1262

Merged
mark-sil merged 1 commit into
mainfrom
claude/clerk-menu-authority-9a9652
Nov 25, 2026
Merged

mark-sil merged 1 commit into
mainfrom
claude/clerk-menu-authority-9a9652

Conversation

@mark-sil

@mark-sil mark-sil commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

The main menu, toolbars, pane bar and keyboard shortcuts now ask the
window's active record clerk directly to show and run the commands
that send InsertItemInVector, DuplicateItemInVector, FirstRecord,
PreviousRecord, NextRecord or LastRecord. Until now the Mediator
delivered those six messages to every record clerk the window could
reach.

Only the active clerk answers, and that changes two things. In Collect
Words, First, Previous, Next and Last Record now move through the
semantic domains; they moved the selected row of the word list. With
the pop-up Lexicon Edit window open, Insert > Entry in a main window
tool of another area is no longer offered; the pop-up's clerk offered
it.

DuplicateItemInVector has no Mediator receiver any more. The other
five messages keep theirs: two right-click menus of the WinForms
Notebook detail view still send InsertItemInVector through the
Mediator, and all five still arrive that way when the window has no
active clerk to answer.


Reviewer notes

Start here: Src/xWorks/RecordClerkCommandAuthority.cs, the whole change in one small class. RecordClerk only registers it in ActivateUI and removes it in RemoveNotification.

The rules.

  • A clerk's authority is registered exactly while the clerk is subscribed to JumpToRecord.
  • Only the active clerk answers (IsActiveClerk). A dependent clerk registers and declines.
  • An answer is final: a disabled command is answered as disabled, and no other clerk is asked.
  • The detail view's DetailCommandAuthority and a clerk never answer the same message, because their order changes whenever a clerk is activated again.

Where to look

  • Collect Words changes. The Mediator reached the word list's clerk first, so the record commands moved its selected row. InCollectWords_TheRecordCommands_MoveTheSemanticDomains_NotTheWords pins the new behaviour.
  • Pop-up Lexicon Edit. Its entries clerk no longer enables Insert > Entry for a main-window tool of another area.
  • Same answers everywhere else. TheActiveClerk_ShowsItsCommands_AsTheMediatorShowsThem compares both routes for the 39 commands the Mediator still reaches, in five tools. A Collect Words variant covers the 35 inserts.
  • Duplicate has no fallback. If a Lists clerk were deactivated while its tool shows, the Duplicate button would hide. Delete Record and published jumps already fail in that state.
  • Order of the two authorities. NoNewUiTool_AnswersAMessageItsRecordClerkAnswers pins the disjoint-messages rule.

Converted

  • InsertItemInVector: 35 commands, on the Insert menu and toolbar, Ctrl+I, Ctrl+E, the Notebook pane bar and the WinForms Notebook hotlinks.
  • DuplicateItemInVector: 10 Lists toolbar commands. Its two receivers are now plain methods.
  • FirstRecord, PreviousRecord, NextRecord, LastRecord: Data menu, Standard toolbar, Alt+P and Alt+N.

Not here: DuplicateSelectedItem, raised only from browse-view object menus, which skip authorities. The record arrows still follow a sorted list's stored order, not its on-screen order (Category Edit, the Lists tools).

Verification. Build and both hygiene gates clean. 333 targeted xWorks tests pass. By hand on Sena 3, in the WinForms UI and in the New UI where the tool has one: Collect Words, Record Edit (Insert menu, toolbar, Ctrl+I, pane bar, hotlink, right-click menu), Category Edit, Phonemes, Academic Domains and Locations, Lexicon Edit (Ctrl+E), two windows, and the pop-up Lexicon Edit window. Full suites not run. Not re-tested on a merge with main after #1261, which merges cleanly.

Next: approve, or say which rule to change.

Preflight review details

Code Review Summary

Branch: claude/clerk-menu-authority-9a9652
Base: main
Date: 2026-11-24
Review model: Claude Fable 5.2
Files changed: 5 (1 commit)

Overview

A record clerk now registers a command authority (RecordClerkCommandAuthority) while it is
in use in its window. The main menu, toolbars, pane bar and keyboard shortcuts ask it, ahead
of the Mediator, to show and run the commands that send InsertItemInVector,
DuplicateItemInVector, FirstRecord, PreviousRecord, NextRecord and LastRecord.
Only the window's active clerk answers.

The Mediator used to offer those messages to every clerk the window could reach, so two
states behave differently: Collect Words, where the record commands now move the semantic
domains and not the word list, and a main-window tool beside the pop-up Lexicon Edit window,
where Insert > Entry is no longer offered.

Contract/API Changes

  • New internal RecordClerkCommandAuthority : ICommandAuthority, registered in
    RecordClerk.ActivateUI and removed in RecordClerk.RemoveNotification.
  • RecordClerk.OnDisplayDuplicateItemInVector(object, ref UIItemDisplayProperties) and
    RecordClerk.OnDuplicateItemInVector(object), public Mediator receivers, are replaced by
    the internal DisplayDuplicateItemInVector(Command, UIItemDisplayProperties) and
    DuplicateItemInVector(Command). DuplicateItemInVector has no Mediator receiver.
  • RecordEditView.InsertItemInVectorMessage is defined as
    RecordClerkCommandAuthority.InsertItemMessage.
  • The Mediator receivers for the other five messages are unchanged.

Findings

Critical - Must address before merge

None.

Important - Should address before merge

  • In Collect Words the record commands move the semantic domains, not the word
    list
    (intended: the author chose the active-clerk rule for navigation; confirmed by
    hand and pinned by a test)
  • With the pop-up Lexicon Edit window open, Insert > Entry is no longer offered in a
    main-window tool of another area
    (accepted by the author; confirmed by hand)
  • The duplicate commands have no Mediator fallback (kept by the author's choice:
    it only matters if a Lists clerk is deactivated while its tool shows, a state in which
    Delete Record and published jumps already fail)

Minor - Consider

  • The authority runs while the Mediator is not processing messages (only while a
    window closes; DetailCommandAuthority behaves the same, and the clerk unregisters when
    it is disposed)
  • Registration preceded CheckDisposed in ActivateUI (fixed during review:
    registration moved after it)
  • IsActiveClerk was read before the message lookup (fixed during review: the
    dictionary lookup comes first)
  • A second constant named the InsertItemInVector message (fixed during review:
    RecordEditView.InsertItemInVectorMessage refers to the clerk authority's constant)
  • Insert equivalence was not tested in Collect Words (fixed during review:
    InCollectWords_TheInsertCommands_ShowAsTheMediatorShowsThem)

Required Validation / Evidence

  • ./build.ps1 -CommentHygiene -TokenHygiene: 0 warnings, 0 errors, both gates clean.
  • ./test.ps1 -CommentHygiene -TokenHygiene -TestProject Src\xWorks\xWorksTests -TestFilter
    over the clerk, menu, record-view, navigation, bulk-edit and authority fixtures: 333
    passed. Full suites not run.
  • A throwaway probe on the base showed that the Mediator moves the RDEwords clerk in
    Collect Words and the concordanceWords clerk in Word List Concordance; the authority
    moves SemanticDomainList and concordanceWords.
  • Manual tests on Sena 3, confirmed by the author, in the WinForms UI and in the New UI for
    the tools that have one: Collect Words, Record Edit (Insert menu, toolbar, Ctrl+I, pane
    bar, hotlink, right-click menu, record commands), Category Edit, Grammar Sketch, Phonemes,
    Academic Domains, Locations, Lexicon Edit (Ctrl+E), two windows, and the pop-up Lexicon
    Edit window.
  • Branch point is fae5de0. origin/main is at 19f02c1; LT-22691: Answer Jump to field and new-record focus in the New UI #1261 changed
    RecordClerk.OnInsertItemInVector and OnDuplicateSelectedItem. The branch merges
    cleanly and was not re-tested on that merge.

Positive Observations

  • One message leaves the Mediator outright, and five more leave it for every route but two
    WinForms right-click menus and the no-active-clerk fallback.
  • No new user-visible strings.
  • The two routes are compared command by command in five tools.

Interview Notes

  • Jira: user-visible, but by the author's standing rule this Mediator-retirement work gets
    no ticket.
  • The author chose the per-clerk authority over one authority per window, chose to include
    the four record commands under the active-clerk rule, and chose to drop the duplicate
    pair's Mediator receivers.
  • While testing, the author saw Previous go from "Preposição" to "Conjunção" in Category
    Edit. That is PossibilityRecordList following the stored order of a sorted list; it is
    the same on main and is outside this PR.

Suggested Review Focus

  • RecordClerkCommandAuthority and its registration in RecordClerk
  • The Collect Words behaviour change
  • The rule that the detail view's authority and the clerk's answer disjoint messages

🤖 Generated with Claude Code


This change is Reviewable

The main menu, toolbars, pane bar and keyboard shortcuts now ask the
window's active record clerk directly to show and run the commands
that send InsertItemInVector, DuplicateItemInVector, FirstRecord,
PreviousRecord, NextRecord or LastRecord. Until now the Mediator
delivered those six messages to every record clerk the window could
reach.

Only the active clerk answers, and that changes two things. In Collect
Words, First, Previous, Next and Last Record now move through the
semantic domains; they moved the selected row of the word list. With
the pop-up Lexicon Edit window open, Insert > Entry in a main window
tool of another area is no longer offered; the pop-up's clerk offered
it.

DuplicateItemInVector has no Mediator receiver any more. The other
five messages keep theirs: two right-click menus of the WinForms
Notebook detail view still send InsertItemInVector through the
Mediator, and all five still arrive that way when the window has no
active clerk to answer.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

NUnit Tests

    1 files  ± 0      1 suites  ±0   15m 24s ⏱️ +55s
7 420 tests +18  7 341 ✅ +18  79 💤 ±0  0 ❌ ±0 
7 429 runs  +18  7 350 ✅ +18  79 💤 ±0  0 ❌ ±0 

Results for commit 036275d. ± Comparison against base commit 19f02c1.

@codecov-commenter

codecov-commenter commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.92%. Comparing base (fae5de0) to head (036275d).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
Src/xWorks/RecordClerkCommandAuthority.cs 95.58% 1 Missing and 2 partials ⚠️
Src/xWorks/RecordClerk.cs 71.42% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1262      +/-   ##
==========================================
+ Coverage   40.34%   40.92%   +0.57%     
==========================================
  Files        1597     1602       +5     
  Lines      360082   360800     +718     
  Branches    42148    42245      +97     
==========================================
+ Hits       145282   147650    +2368     
+ Misses     185121   183653    -1468     
+ Partials    29679    29497     -182     
Files with missing lines Coverage Δ
...s/Avalonia/Hosting/RecordEditView.NotebookMenus.cs 74.03% <ø> (ø)
Src/xWorks/RecordClerk.cs 62.09% <71.42%> (+9.20%) ⬆️
Src/xWorks/RecordClerkCommandAuthority.cs 95.58% <95.58%> (ø)

... and 88 files with indirect coverage changes

🚀 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.

@thejambi thejambi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:lgtm:

@thejambi reviewed 5 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on mark-sil).

@mark-sil
mark-sil merged commit 183be7c into main Nov 25, 2026
9 checks passed
@mark-sil
mark-sil deleted the claude/clerk-menu-authority-9a9652 branch November 25, 2026 00:28
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.

3 participants