Skip to content

LT-22661: Hide Publish In rows with no exclusions in Avalonia view - #1234

Open
thejambi wants to merge 2 commits into
mainfrom
LT-22661-detail-view-honor-visfield
Open

thejambi wants to merge 2 commits into
mainfrom
LT-22661-detail-view-honor-visfield

Conversation

@thejambi

@thejambi thejambi commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

In the New UI detail view, the "Publish Sense In" and "Publish Example In" rows now appear only when the sense or example is excluded from a publication, or when View > Show Hidden Fields is on, as in the WinForms view. Until now they showed on every record, listing "Main Dictionary", because the new view checked the publications a row lists rather than the exclusions that decide whether it has data.

Reviewer notes

Root cause. These parts are visibility="ifdata", and their slices in LexSenseParts.xml and LexEntryParts.xml name visField="DoNotPublishIn". A "Publish ... In" row lists every publication not in DoNotPublishIn, so the virtual PublishIn it displays always holds Main Dictionary. The WinForms DataTree.AddSimpleNode judges an ifdata reference collection on the visField property when one is named. XmlLayoutImporter dropped the attribute, so DetailComposer judged the displayed field and the row always showed.

Deliberate rules.

  • ViewNode.VisibilityField carries the slice's visField. The JSON serializer and both ViewDefinitionOverrideApplier rebuilds (CloneWith, CloneWithId) keep it, so a user override or a duplicated row still hides correctly. visField joins HandledSliceAttributes, so it is no longer reported as unhandled.
  • WalkReferenceVectorField makes the ifdata decision once, before choosing an editor, on the visField count when one is named, otherwise on the displayed count. That replaces four identical per-branch checks. For every row without a visField the outcome is unchanged; the lookups now skipped for hidden rows are reads with no side effects. A row with an exclusion but nothing left to list (every publication excluded) shows, empty, as in WinForms.
  • VisibilityCount uses the visField count only when that field is an owning or reference sequence or collection. When the name does not resolve, or names an atomic or string field, it falls back to the displayed count, as if the part named no visField. WinForms would throw from GetFieldId2 on an unknown name and read the wrong kind of property on a non-list field; no shipped part does either.
  • DetailComposer.Compose hands its compiled layout to a new internal ComposeModel, which does the walk. It changes nothing for callers and lets a test compose a hand-built layout node.
  • visField is honoured on reference sequences as well as reference collections; WinForms applies it to collections only, and no shipped sequence part names one. Grouping nodes do not carry it, since no shipped part needs it.
  • No canonical JSON is committed and the JSON load path is gated off by default, so no stored definitions lack the new key.

Not changed: rows that are always shown. Only the LexSense and LexExampleSentence layouts in LexSense.fwlayout mark PublishIn as ifdata. The ticket's acceptance step 2 expects no entry-level "Publish Entry In" row, but LexEntry.fwlayout marks it and "Show As Headword In" visibility="always", and the CmPicture and LexPronunciation layouts reference PublishIn with no visibility, which defaults to always. Both UIs always show those four rows; this keeps parity with the WinForms view, and QA should look for the change on senses and examples. For the same reason the ticket's Show As Headword In composer check cannot be written against the shipped layouts.

Tests. ViewDefinitionTests.Import_VisField_RidesTheNode_AndIsNotReportedUnhandled covers the import. The JSON round-trip test in CanonicalJsonTests and both override-rebuild tests in ViewDefinitionOverrideApplierTests now assert the property survives. Two new composer tests in DetailComposerReferenceChooserTests use the shipped layouts: a sense excluded from nothing has no Publish Sense In row (and has one, listing Main Dictionary, with hidden fields shown), and a sense excluded from Main Dictionary shows the row with no items. Both fail against the old code. ComposeModel_VisFieldNotAVector_FallsBackToTheDisplayedField composes a Publish Sense In node whose visField names Gloss, a multistring, and expects the row judged on what it lists. Help_OnPublishSenseIn_OpensTheRowsOwnTopic now composes with hidden fields shown, because its row was visible only because of this bug. FwAvaloniaTests: 952 passed, 1 skipped (first commit). xWorksTests on the first commit: 1910 passed, 2 skipped. xWorksTests on the second commit: 1909 passed, 2 skipped, run while the Windows session was locked, which crashed the BulkEditBarUiaSmokeTests host and failed TextDrag_FromAvaloniaPayload_LegacyClipboardBridgeReadsBothRichAndNeutralLanes for want of a clipboard; rerun on the unlocked desktop, both pass. Build, comment hygiene and token hygiene are clean.

Manual tests (done). In FLEx with the New UI, Lexicon Edit, Show Hidden Fields off: a sense excluded from nothing has no Publish Sense In row and an example has no Publish Example In row, while Publish Entry In and Show As Headword In still show. With hidden fields on, removing Main Dictionary from Publish Sense In and then turning hidden fields off leaves the row showing, empty; adding Main Dictionary back hides it again, so the view re-composes after the edit.

Out of scope. Changing the entry, picture or pronunciation rows to ifdata would change the WinForms view as well and is a layout decision, not part of this parity fix.

🤖 Generated with Claude Code


This change is Reviewable

The Avalonia detail view showed every "Publish ... In" row on every
record. Those parts are visibility="ifdata", and their slices name a
visField (DoNotPublishIn) whose data decides visibility: Publish In
displays the publications not excluded, so it always holds Main
Dictionary. The view never read visField and judged the displayed
field instead.

The layout importer now carries visField onto the ViewNode, the JSON
serializer and override rebuilds keep it, and the composer judges an
ifdata reference-vector row on that field's count. A row with an
exclusion shows even though it lists no publications.

The Publish Sense In Help test now composes with hidden fields shown,
since a sense excluded from nothing no longer shows that row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

NUnit Tests

    1 files  ±0      1 suites  ±0   14m 24s ⏱️ +12s
7 061 tests +4  6 976 ✅ +4  85 💤 ±0  0 ❌ ±0 
7 070 runs  +4  6 985 ✅ +4  85 💤 ±0  0 ❌ ±0 

Results for commit 98e6410. ± Comparison against base commit 412ee26.

♻️ This comment has been updated with latest results.

@codecov-commenter

codecov-commenter commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 40.52%. Comparing base (9c931ec) to head (98e6410).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1234   +/-   ##
=======================================
  Coverage   40.51%   40.52%           
=======================================
  Files        1559     1559           
  Lines      356080   356107   +27     
  Branches    41586    41588    +2     
=======================================
+ Hits       144280   144306   +26     
- Misses     182489   182490    +1     
  Partials    29311    29311           
Files with missing lines Coverage Δ
...nia/ViewDefinition/ViewDefinitionJsonSerializer.cs 93.65% <100.00%> (+0.06%) ⬆️
...n/FwAvalonia/ViewDefinition/ViewDefinitionModel.cs 89.68% <100.00%> (+0.09%) ⬆️
...ia/ViewDefinition/ViewDefinitionOverrideApplier.cs 93.83% <100.00%> (+0.05%) ⬆️
...mon/FwAvalonia/ViewDefinition/XmlLayoutImporter.cs 86.65% <100.00%> (+0.02%) ⬆️
Src/xWorks/Avalonia/Composer/DetailComposer.cs 72.28% <100.00%> (+0.27%) ⬆️

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

VisibilityCount counted the visField property with get_VecSize whatever
its type, so a part whose visField named an atomic or string field
would read the wrong kind of property. The count now comes from
visField only when it is an owning or reference sequence or collection;
otherwise the row is judged on the field it displays, as if the part
named no visField. No shipped part is affected.

DetailComposer.Compose now hands its compiled layout to an internal
ComposeModel, so a test can compose a hand-built layout node.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thejambi
thejambi marked this pull request as ready for review November 6, 2026 02:44
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