Skip to content

LT-21402: Part 3 - Move MasterRefresh to Pub/Sub (Insert/Delete) - #1039

Open
mark-sil wants to merge 1 commit into
mainfrom
MasterRefreshPubSub3
Open

LT-21402: Part 3 - Move MasterRefresh to Pub/Sub (Insert/Delete)#1039
mark-sil wants to merge 1 commit into
mainfrom
MasterRefreshPubSub3

Conversation

@mark-sil

@mark-sil mark-sil commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Converts the last two synchronous MasterRefresh senders —
InsertEntryDlgListener.DialogInsertItemInVector (Insert Entry) and
RecordClerk.OnDeleteRecord (Delete Record) — completing the synchronous half of the
LT-21402 migration (follows #1033 and #1038).

These two were deliberately excluded from Part 1: both commands update the cache directly
(UOW + PropChanged), so when an XHTML document view is active, the Mediator's
High-priority stop-when-handled intercept correctly satisfied the refresh with a fast
content-only reload; the full master refresh was only needed in the other tools.
Converting them to a plain Publish(MasterRefresh) would have turned that fast, correct
reload into a needless full refresh.

Design: two-stage refresh request

Pub/Sub has no priority or stop-when-handled, so the intercept is replaced with a
two-stage request, using the same ReturnObject idiom as the DialogInsertItemInVector
conversions (see RecordClerk.OnInsertItemInVector):

  • New event RefreshCurrentView. The sender publishes it (window-scoped) with a
    ReturnObject; a subscriber that can satisfy the request by regenerating its own
    content sets ReturnValue. If no subscriber claims the request, the sender publishes
    MasterRefresh instead.
  • XhtmlDocView subscribes while it exists (Init/Dispose) — i.e. exactly while its tool
    is the active content control — so the subscription lifetime does the routing that
    colleague priority used to do.
  • XhtmlRecordDocView (the Lexicon Edit preview pane) deliberately does not
    subscribe: in Lexicon Edit these commands do the full refresh today, and that is
    preserved.

Behavior is unchanged: content-only reload when a Dictionary, Reversal Indexes, or
Classified Dictionary document view is active; full master refresh everywhere else.

The JumpToRecord send next to the Insert Entry site stays on the Mediator; that message
is a separate conversion.

Remaining MasterRefresh work (future PRs)

Still on the Mediator: the F5/CmdRefresh menu command (which can reuse this two-stage
pattern when converted), four deferred BroadcastMessage senders, and one PostMessage
sender — each needs per-site timing analysis before conversion.

Testing

  • Build clean; no automated-test changes (dispatch-only change; behavior covered by
    manual tests).
  • Manual: Insert Entry and Delete Record from the Dictionary view (content-only reload,
    FwXWindow.OnMasterRefresh not invoked, jump-to-new-entry intact) and from Lexicon
    Edit (full refresh, unchanged); reversal document view delete; multi-window scoping
    (single dispatch, focus retained).

🤖 Generated with Claude Code


This change is Reviewable

These two senders (InsertEntryDlgListener.DialogInsertItemInVector and
RecordClerk.OnDeleteRecord) both update the cache directly
(UOW + PropChanged), so when an XHTML document view is active, the
Mediator's High-priority stop-when-handled intercept correctly
satisfied the refresh with a fast content-only reload; the full
master refresh was only needed in the other tools.

Pub/Sub has no stop-when-handled, so the intercept is replaced with a
two-stage refresh request.
- New event RefreshCurrentView. The sender publishes it (window-scoped)
  with a ReturnObject; a subscriber that can satisfy the request by
  regenerating its own content sets ReturnValue. If no subscriber
  claims the request, the sender publishes MasterRefresh instead.
- XhtmlDocView subscribes while it exists (Init/Dispose), i.e. exactly
  while its tool is the active content control - the subscription
  lifetime does the routing that colleague priority used to do.
- XhtmlRecordDocView (the Lexicon Edit preview pane) deliberately does
  NOT subscribe: in Lexicon Edit these commands do the full refresh
  today, and that is preserved.

Behavior is unchanged: content-only reload when a Dictionary, Reversal
Indexes, or Classified Dictionary document view is active; full master
refresh everywhere else.

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

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

NUnit Tests

    1 files  ±0      1 suites  ±0   10m 11s ⏱️ - 1m 5s
4 316 tests ±0  4 243 ✅ ±0  73 💤 ±0  0 ❌ ±0 
4 325 runs  ±0  4 252 ✅ ±0  73 💤 ±0  0 ❌ ±0 

Results for commit 794c166. ± Comparison against base commit a43fae5.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 4.00000% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 33.04%. Comparing base (a43fae5) to head (794c166).

Files with missing lines Patch % Lines
Src/xWorks/XhtmlDocView.cs 7.69% 10 Missing and 2 partials ⚠️
Src/LexText/LexTextControls/EntryDlgListener.cs 0.00% 5 Missing and 1 partial ⚠️
Src/xWorks/RecordClerk.cs 0.00% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1039      +/-   ##
==========================================
- Coverage   33.05%   33.04%   -0.01%     
==========================================
  Files        1202     1202              
  Lines      278342   278365      +23     
  Branches    37191    37195       +4     
==========================================
  Hits        91994    91994              
- Misses     158493   158511      +18     
- Partials    27855    27860       +5     
Files with missing lines Coverage Δ
Src/LexText/LexTextControls/EntryDlgListener.cs 0.00% <0.00%> (ø)
Src/xWorks/RecordClerk.cs 38.69% <0.00%> (-0.11%) ⬇️
Src/xWorks/XhtmlDocView.cs 6.13% <7.69%> (+0.01%) ⬆️

... and 1 file 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.

Debug.Assert(false, "Received unexpected object type.");
return;
}
// Return if already handled by another Subscriber.

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.

Would there ever be two current views that need to handle this (e.g. multiple panes or windows)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good question — no, by design, on both counts:

Multiple windows: both ends are window-scoped (m_propertyTable.GetWindow()), so a publish from window A's clerk only reaches window A's subscribers. A second window showing the Dictionary view never sees the request (matching the old per-window Mediator behavior).

Multiple panes in one window: XhtmlDocView only exists as the main content control of the three document tools (Dictionary, Reversal Indexes, Classified Dictionary), and a window has exactly one main content control at a time (this is similar to what the Mediator relied on) — the view is disposed (and unsubscribed) on tool switch. The one view that can coexist alongside another content control, XhtmlRecordDocView (the Lexicon Edit preview pane), deliberately doesn't subscribe: in Lexicon Edit these commands should do the full refresh, and the preview updates via PropChanged. So at most one subscriber can receive any given request today.

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