Skip to content

LT-22691: Answer the reorder-vector menu natively in the Avalonia detail view - #1143

Merged
mark-sil merged 1 commit into
mainfrom
LT-22691-reorder-vector-authority
Sep 23, 2026
Merged

mark-sil merged 1 commit into
mainfrom
LT-22691-reorder-vector-authority

Conversation

@mark-sil

@mark-sil mark-sil commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

The first step of retiring the hidden DataTree command adapter one menu id at a time: each menu id gets a native authority, proven equivalent, then flipped.

What changes

The Avalonia detail view still builds a hidden WinForms DataTree so xCore menu commands can be answered by its slices and DTMenuHandler through the mediator. This PR gives one menu id, mnuReorderVector (Move Left, Move Right, Alphabetical Order on reference-vector rows), a native authority that owns display and execution, so the mediator and the hidden tree play no part in it.

  • IDetailMenuAuthority: answers every leaf under the menu ids it owns. A hidden leaf is null; a leaf it does not know throws, so an owned id can never leak an item as visible-but-disabled.
  • XCoreMenuBridge consults the authority before the mediator display query, so owned leaves cost no Display round trip. OwnsAll lets the host skip building the adapter when every id in a request is owned. Today the label menu always merges mnuDataTree-Object, so that skip is inert until the shared menu is native.
  • ReorderVectorMenuAuthority answers from the row: Move Left and Right from CanReorderItems and the request's current item, Alphabetical Order from the new DetailField.CanResetItemOrder (the layout's reorder="true"). Alphabetical Order executes natively through the new IDetailEditContext.TryResetReferenceOrder, backed by VirtualOrderingServices.ResetVO.
  • The label-menu interceptor entries for the Move commands are gone; the item menu keeps them, sharing one item builder.

Tests (xWorksTests, the two touched fixtures: 36 pass)

  • Equivalence: the label menu rendered through the adapter and through the authority is textually identical, for the Subentries row with no current item and for the read-only Complex Forms row.
  • Without the adapter, the mediator renders the three items greyed out because no handler answers them; the authority renders them correctly.
  • A real reference sequence offers the moves but no Alphabetical Order.
  • Alphabetical Order through the host discards the virtual ordering as one undo step.
  • Contract: every leaf under mnuReorderVector in the shipped configuration is one the authority answers and carries a configuration node.

Known and deferred (recorded in the retirement notes, to be decided with the next menu ids)

  • List-populated leaves have no configuration node, so ownership by XML ancestry cannot claim them. Bites at mnuDataTree-MultiStringSlice.
  • Nested submenu leaves are displayed by xCore before the bridge sees them. Bites at mnuDataTree-Object.
  • The Undo label after Alphabetical Order is the edit session's per-field label, not "Undo Alphabetical Order"; the Move path has had the same divergence since LT-22691: Menus for reference-vector rows in the Avalonia detail view #1133.

🤖 Generated with Claude Code


This change is Reviewable

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

NUnit Tests

    1 files  ±0      1 suites  ±0   12m 58s ⏱️ +35s
6 206 tests +9  6 121 ✅ +9  85 💤 ±0  0 ❌ ±0 
6 215 runs  +9  6 130 ✅ +9  85 💤 ±0  0 ❌ ±0 

Results for commit 751bea1. ± Comparison against base commit 2f1d9db.

♻️ This comment has been updated with latest results.

@codecov-commenter

codecov-commenter commented Sep 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.22901% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.90%. Comparing base (2f1d9db) to head (751bea1).

Files with missing lines Patch % Lines
...xWorks/Avalonia/Hosting/RecordEditView.Avalonia.cs 0.00% 13 Missing and 1 partial ⚠️
...rks/Avalonia/Hosting/ReorderVectorMenuAuthority.cs 78.37% 3 Missing and 5 partials ⚠️
Src/xWorks/Avalonia/Hosting/XCoreMenuBridge.cs 81.81% 1 Missing and 5 partials ⚠️
.../Common/FwAvalonia/Preview/DetailPreviewSupport.cs 0.00% 4 Missing ⚠️
...rks/Avalonia/Composer/ComposedDetailEditContext.cs 50.00% 1 Missing and 2 partials ⚠️
...mon/FwAvaloniaDialogs/InMemoryDetailEditContext.cs 0.00% 1 Missing ⚠️
Src/xWorks/Avalonia/DetailEditContextBase.cs 0.00% 1 Missing ⚠️
...nia/Hosting/RecordEditView.ReferenceVectorMenus.cs 90.00% 0 Missing and 1 partial ⚠️
...Works/Avalonia/Plugins/ReversalIndexEntryPlugin.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1143   +/-   ##
=======================================
  Coverage   38.89%   38.90%           
=======================================
  Files        1518     1519    +1     
  Lines      352262   352356   +94     
  Branches    40597    40618   +21     
=======================================
+ Hits       137005   137075   +70     
- Misses     185976   185990   +14     
- Partials    29281    29291   +10     
Files with missing lines Coverage Δ
Src/Common/FwAvalonia/Detail/DetailModel.cs 78.29% <100.00%> (+0.05%) ⬆️
Src/xWorks/Avalonia/Composer/DetailComposer.cs 69.35% <100.00%> (+0.15%) ⬆️
...mon/FwAvaloniaDialogs/InMemoryDetailEditContext.cs 54.83% <0.00%> (-1.83%) ⬇️
Src/xWorks/Avalonia/DetailEditContextBase.cs 65.38% <0.00%> (-0.85%) ⬇️
...nia/Hosting/RecordEditView.ReferenceVectorMenus.cs 55.47% <90.00%> (+0.15%) ⬆️
...Works/Avalonia/Plugins/ReversalIndexEntryPlugin.cs 54.46% <0.00%> (-0.50%) ⬇️
...rks/Avalonia/Composer/ComposedDetailEditContext.cs 55.42% <50.00%> (-0.43%) ⬇️
.../Common/FwAvalonia/Preview/DetailPreviewSupport.cs 65.90% <0.00%> (-2.06%) ⬇️
Src/xWorks/Avalonia/Hosting/XCoreMenuBridge.cs 80.00% <81.81%> (-1.09%) ⬇️
...rks/Avalonia/Hosting/ReorderVectorMenuAuthority.cs 78.37% <78.37%> (ø)
... and 1 more

... and 8 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.

@mark-sil
mark-sil force-pushed the LT-22691-reorder-vector-authority branch from db9c83f to a382684 Compare September 17, 2026 12:23
The Avalonia detail view builds a hidden WinForms DataTree so xCore menu
commands can be answered by its slices and DTMenuHandler through the
mediator. This is the first menu id to leave that path.

XCoreMenuBridge gains an IDetailMenuAuthority: for every leaf under a
menu id the authority owns, it is consulted before the mediator, so those
leaves cost no Display round trip and never reach the hidden tree. An
owned id must be answered in full: an unknown leaf throws instead of
leaking as a visible-but-disabled item. XCoreMenuBridge.OwnsAll lets
RecordEditView skip EnsureMenuCommandAdapter when every id in a request
is owned; the label menu still merges mnuDataTree-Object, so the skip is
inert until that id is native.

Tests render the label menu through the adapter and through the
authority and assert the trees are identical.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@mark-sil
mark-sil force-pushed the LT-22691-reorder-vector-authority branch from a382684 to 751bea1 Compare September 22, 2026 14:53
@mark-sil
mark-sil marked this pull request as ready for review September 22, 2026 14:53

@jasonleenaylor jasonleenaylor 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.

Approving. The adapter-versus-native equivalence tests are the right way to prove a swap like this. One divergence in the Move visibility rule, not for this PR:

CanReorderItems is (real ReferenceSequence && !virtual) || node.Reorder (DetailComposer.cs:2369-2374). VectorReferenceView.cs:348-350 hides the moves for three more cases: m_rootFieldName == "Complex Forms", == "Compare", and the LexReferenceCollectionView / LexReferenceTreeBranchesView views. m_rootFieldName is the localized label (ReferenceSlice.cs:55), and LexEntryParts.xml:824 is label="Complex Forms" menu="mnuReorderVector" reorder="true" — so WinForms hides Move Left and Move Right on that row and the authority's rule does not.

Not reachable today — that row composes as read-only Text, CanReorderRow is false, and both paths hide the moves, which is what ReorderVectorLabelMenu_ReadOnlyComplexFormsRow_RendersTheSameTreeAsTheAdapter pins. It bites only if ComplexFormEntries ever composes editable.

Not a straight port either: that condition matches on a localized label, so it already misses under a non-English UI. Noting it as something to either say at the rule or carry into a Jira issue when the next menu id moves across.

@mark-sil
mark-sil merged commit e278320 into main Sep 23, 2026
8 of 9 checks passed
@mark-sil
mark-sil deleted the LT-22691-reorder-vector-authority branch September 23, 2026 12:00

@mark-sil mark-sil left a comment

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.

If I understand this correctly, the divergence is theoretical today, and from what I know there are no plans for ComplexFormEntries to compose editable.

If that is correct, then I think this falls in the category of 'busy work'. The Complex Forms equivalence test already asserts that the row composes read-only and that the moves are hidden. If that row ever composes editable, the test fails and points at exactly this.

Claude confirmed a note at the rule would add nothing the test does not already do, and logging a Jira issue for a theoretical problem doesn't seem like a good idea.

My preference would be to do nothing with issues like this. If you see a reason this one is different I'm glad to hear it, but otherwise I'd like to treat divergences that are unreachable today as needing no follow-up.

@mark-sil made 1 comment.
Reviewable status: 0 of 15 files reviewed, all discussions resolved.

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