Skip to content

Deliver the Filters menu choice to its clerk through Pub/Sub - #1267

Merged
mark-sil merged 1 commit into
mainfrom
claude/pubsub-current-filter-a7bef8
Nov 25, 2026
Merged

mark-sil merged 1 commit into
mainfrom
claude/pubsub-current-filter-a7bef8

Conversation

@mark-sil

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

Copy link
Copy Markdown
Contributor

A choice in the View > Filters menu now reaches its record clerk as a Pub/Sub message, published in the main window where it was made, and the clerk filters its list before the menu click returns. Until now the clerk heard it from the Mediator's queued OnPropertyChanged broadcast of currentFilterForRecordClerk_<clerk id>, which the menu no longer sends.

This sets the pattern for the other property-table names that still broadcast. The message is the property name behind the prefix PropertyChanged:, with the new value as its data, published only when the value changed; PropertyTable.SetProperty now returns whether it did. The menu code that stores a list choice publishes the properties named in its own check and broadcasts the rest as before, so each later property moves by joining that check.

In an unrelated fix, the Filters menu now names a word set by its best analysis name. A set named only in a second analysis writing system was listed as "Error generating label!".


Reviewer notes

Start here: ChoiceGroup.ChooseSinglePropertyAtomicValue in Src/XCore/xCoreInterfaces/ChoiceGroup.cs. It is the sender: one check decides, per property name, between a Pub/Sub publish and the Mediator broadcast. Then read RecordClerk.ActivateUI and RemoveNotification for the listener.

Does anything still need the Mediator to hear this property? No. The clerk was its only OnPropertyChanged listener, and every other property the menu code serves is set and broadcast exactly as before.

Where to look

  • Change-only delivery: choosing the item that is already checked must not filter again. Pinned by MenuChoice_OfTheCheckedItem_DoesNotFilterAgain.
  • Window scope: two windows hold clerks with the same id. Pinned by MenuChoice_InAnotherWindow_LeavesThisWindowsClerkAlone.
  • Timing: the filter change now runs inside the menu click instead of from the queue after it.
  • Lifetime: the clerk listens between ActivateUI and BecomeInactive, as it does for its three other subscriptions.
  • SetProperty returns bool instead of void: source compatible, not binary compatible for an assembly built outside this repository.

Deliberately not here

  • The <name>Parameters set in the same method still broadcasts for every property.
  • LinkListener.FollowActiveLink still sets link-carried properties with the broadcast flag.
  • The other broadcasting property names. Each moves in its own PR.

Verification

  • Build with the comment and token hygiene gates: clean.
  • Full suites: xWorksTests 2038 passed and 2 skipped, xCoreTests 30, xCoreInterfacesTests 28, FiltersTests 25, FwUtilsTests 494.
  • New tests: four in RecordClerkFilterSelectionTests, three in the new ChoiceGroupPropertyChoiceTests, and one each in PropertyTableTests, PubSubSystemTests and WordformFiltersTests. Each new clerk test was confirmed to fail with its rule removed.
  • Manual, on Sena 3 in both UI modes: View > Filters in Word Analyses and Bulk Edit Wordforms (choose, choose again, clear, No Filter), the same with two windows open, and a Lexicon Edit column filter cleared by No Filter.

Next: approve, or tell me what to change.

What stopped happening
  1. The menu no longer queues OnPropertyChanged for currentFilterForRecordClerk_<clerk id>. The clerk was the only listener, and it now subscribes.
  2. The filter change no longer waits for the Mediator queue. It runs inside the menu click, after the property and its persistence flag are set.
  3. A clerk that is a message target but is not active in the GUI no longer hears its menu. No tool was found that leaves a shown view's clerk inactive, and such a clerk does not reload its list anyway (RecordList.ReloadList puts the reload off while Clerk.IsActiveInGui is false).
  4. A link whose URL carries currentFilterForRecordClerk_<clerk id> sets the menu's check mark without filtering the list. No code builds such a link; the link producers add only InterlinearTab, ConcordOn, SuspendLoadListUntilOnChangeFilter, LinkSetupInfo and HvoOfAnthroItem.
Decisions, and why

The sender publishes; the property table does not. A flag on SetProperty (no notice, publish now, publish later) was the alternative. It lost for three reasons. Some later names need one notice after two sets, which a flag on a single set cannot express. Publishing at the end of an action needs a fixed order entry per message, which a property name taken from configuration cannot have. And the intended end state is a property table that stores values and notifies nobody.

Not every broadcasting set publishes. Having the table publish on every set that broadcasts would have needed no sender changes. It was rejected because LinkListener.FollowActiveLink sets property names taken from a link URL, so a link could publish a message named like a real event, and because sets that still depend on queued delivery would be published at once.

The message name carries a prefix. Property names come from configuration files, so a bare name could equal the name of an existing event. PropertyChangedMessages_ShareNoNameWithAnotherMessage fails if an EventConstants name ever starts with the prefix.

The shared setter publishes listed names only. Publishing every property it serves would also tell subscribers about names whose other senders are not ready for immediate delivery. The same check turns the Mediator broadcast off for a listed name, so no dead job is queued for it.

The clerk reads the property table, not the message data. The table is what the menu's check mark reads, so the two cannot disagree.

Only the new unsubscribe is guarded by !m_isDisposed. Its message name is built from the clerk's id, which throws after disposal, and BecomeInactive can reach a disposed clerk. The other three use fixed names.

Found in passing
  • Fixed here: the word-set label, described above.
  • Not fixed: WordSetFilter.SameFilter compares the display name as well as the id, and the name is saved with the filter. Renaming a set after a filter on it was saved leaves its Filters menu item unchecked after a restart, although the list opens filtered. The id is the set's hvo, which has the same effect when the hvo changes between sessions.
  • Not fixed: xWindow.LoadDefaultProperties runs before the window stores itself in its property table. A default property with a list attribute would be chosen with no window to scope a publish. No configuration has such a default.
Preflight review details

Code Review Summary

Branch: claude/pubsub-current-filter-a7bef8
Base: main (merge base 183be7c)
Date: 2026-11-25
Review model: Claude Fable 5.2
Files changed: 10 (1 commit)

Overview

The branch moves currentFilterForRecordClerk_<clerk id> off the Mediator's
queued OnPropertyChanged broadcast. A choice in View > Filters is now published
through Pub/Sub, scoped to the main window, and the record clerk subscribes to its
own property's message while it is active in the GUI. It is the first of the
property-table names to move this way and sets the pattern for the rest: the
message is the property name behind the prefix PropertyChanged:, the value is
the data, and the sender publishes only when the value changed.

One unrelated one-line fix rides along at the author's request: a word set named
only in a non-default analysis writing system was listed in the Filters menu as
"Error generating label!".

Contract/API Changes

  • PropertyTable.SetProperty (both public overloads) returns bool (true when the
    property is new or its value changed) instead of void. Source compatible;
    binary incompatible for an assembly built outside the repository.
  • PropertyConstants gains ChangedMessagePrefix, CurrentFilterForRecordClerkPrefix
    and PropertyChanged(string propertyName).
  • ChoiceGroup.ChooseSinglePropertyAtomicValue publishes the properties named in
    its own check (today the currentFilterForRecordClerk_ prefix) and no longer
    broadcasts those through the Mediator; every other property is unchanged.
  • RecordClerk.OnPropertyChanged no longer answers its filter property.

Findings

Critical - Must address before merge

None.

Important - Should address before merge

  • Src/xWorks/RecordClerk.cs: the clerk hears the menu only between
    ActivateUI and BecomeInactive, where the Mediator reached it whenever its
    view was a message target.
    (Kept: this is the lifetime of the clerk's three
    other subscriptions; no tool path was found that leaves a live view's clerk
    inactive; InfoPane and PopupToolWindow re-activate it.)
  • Src/xWorks/RecordClerk.cs: a link whose URL carries
    currentFilterForRecordClerk_<id> now changes the menu's check mark without
    filtering.
    (Accepted: no code builds such a link; inventory item 10.30 stops
    LinkListener broadcasting those sets.)

Minor - Consider

  • No test asserted what the shared setter publishes (fixed during
    review: ChoiceGroupPropertyChoiceTests.cs checks the message, value, scope,
    the unchanged-value case and that an unlisted property goes to the Mediator
    only)
  • RecordClerk.CurrentFilterChosen ignores the published value and re-reads
    the property table.
    (Kept: the table is what the menu's check mark reads.)
  • ChoiceGroup.PublishesChoice throws on a null property name. (All three
    callers pass a non-null name.)
  • The publish is process-wide when no window is registered
    (xWindow.LoadDefaultProperties runs before the window property is set).

    (No configuration has a list default property.)
  • The filter change now runs inside the menu click, under
    ListPropertyChoice's click guard.
    (Manual runs on a 7,059-wordform list
    behaved normally.)
  • WordSetFilter.SameFilter compares the display name, so renaming a set
    after saving a filter leaves its menu item unchecked on restart.

    (Pre-existing; belongs with the known hvo-as-id problem.)

Required Validation / Evidence

  • .\build.ps1 -CommentHygiene -TokenHygiene: clean, 0 warnings.
  • Full suites on the committed code: xWorksTests 2038 passed, 2 skipped;
    xCoreTests 30; xCoreInterfacesTests 28; FiltersTests 25; FwUtilsTests 494.
  • Control runs: each of the four new clerk tests fails when its rule is removed
    (no subscription, unscoped subscription, unconditional publish, no
    unsubscribe).
  • Manual, performed by the author on Sena 3: Filters menu in Word Analyses and
    Bulk Edit Wordforms (choose, re-choose, clear, No Filter), two windows, and
    Lexicon Edit column filter cleared by No Filter, in both UI modes.

Positive Observations

  • The own-clerk rule and the own-window rule both fall out of the message name
    and the scope; the handler needs no "is this mine?" test.
  • A converted name leaves the Mediator at the shared sender at once, so no dead
    job is queued for it.
  • A test guards the message prefix against ever matching an EventConstants
    name.

Interview Notes

  • Delivery mechanism: the sender publishes (not a table-level flag); decided by
    the author before any code.
  • SetProperty returns bool so the sender can keep change-only delivery.
  • Message names carry a prefix; the author asked for it over bare property
    names, and for the prefix and builder to live in PropertyConstants.
  • The shared setter publishes only listed names and stops their Mediator
    broadcast; the author asked for this in place of publishing every member.
  • The !m_isDisposed guard around the new unsubscribe stays on that one call.
  • The word-set label fix was added at the author's request.
  • No Jira ticket: standing decision for the Pub/Sub work.

Suggested Review Focus

  • ChoiceGroup.ChooseSinglePropertyAtomicValue: the per-name check and the
    order of set, persistence and publish.
  • RecordClerk.ActivateUI / RemoveNotification: the subscription lifetime.
  • PropertyTable.SetProperty: the return value.

🤖 Generated with Claude Code


This change is Reviewable

A choice in the View > Filters menu now reaches its record clerk as a
Pub/Sub message, published in the main window where it was made, and
the clerk filters its list before the menu click returns. Until now
the clerk heard it from the Mediator's queued OnPropertyChanged
broadcast of currentFilterForRecordClerk_<clerk id>, which the menu
no longer sends.

This sets the pattern for the other property-table names that still
broadcast. The message is the property name behind the prefix
"PropertyChanged:", with the new value as its data, published only
when the value changed; PropertyTable.SetProperty now returns whether
it did. The menu code that stores a list choice publishes the
properties named in its own check and broadcasts the rest as before,
so each later property moves by joining that check.

In an unrelated fix, the Filters menu now names a word set by its
best analysis name. A set named only in a second analysis writing
system was listed as "Error generating label!".

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 13s ⏱️ +21s
7 430 tests +10  7 351 ✅ +10  79 💤 ±0  0 ❌ ±0 
7 439 runs  +10  7 360 ✅ +10  79 💤 ±0  0 ❌ ±0 

Results for commit ab7faa9. ± Comparison against base commit 183be7c.

@codecov-commenter

codecov-commenter commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 40.93%. Comparing base (183be7c) to head (ab7faa9).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1267   +/-   ##
=======================================
  Coverage   40.92%   40.93%           
=======================================
  Files        1602     1603    +1     
  Lines      360800   360816   +16     
  Branches    42245    42246    +1     
=======================================
+ Hits       147648   147682   +34     
+ Misses     183655   183639   -16     
+ Partials    29497    29495    -2     
Files with missing lines Coverage Δ
Src/Common/Filters/WordFormFilters.cs 79.20% <100.00%> (+3.96%) ⬆️
Src/Common/FwUtils/PropertyConstants.cs 100.00% <100.00%> (ø)
Src/XCore/xCoreInterfaces/ChoiceGroup.cs 54.77% <100.00%> (+1.17%) ⬆️
Src/XCore/xCoreInterfaces/PropertyTable.cs 79.15% <100.00%> (+0.04%) ⬆️
Src/xWorks/RecordClerk.cs 63.11% <100.00%> (+1.02%) ⬆️

... and 4 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 10 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 afe82d2 into main Nov 25, 2026
9 checks passed
@mark-sil
mark-sil deleted the claude/pubsub-current-filter-a7bef8 branch November 25, 2026 20:16
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