Repository navigation
View tree: entity cards don't fill width, tree overflows splitter, bottom corners should be square when has children #1006
Description
Summary
Three related layout bugs in the View tree (entity browser panel):
- Entity cards don't fill tree width — cards shrink to content width instead of stretching to fill the available panel column.
- Tree overflows the splitter area — card content can exceed the splitter-constrained column width, producing a horizontal scrollbar.
- Card bottom corners always rounded — the entity card
Borderalways usesCornerRadius="6"on all corners; when an item has children the bottom corners should be square (CornerRadius="6 6 0 0") so the card connects flush to the expander button below it.
Root Cause
Issue 1 — Cards don't fill width
File: Phantom.Workspaces.Gui.Shared/Styles/SharedStyles.axaml, Border.entity-card style, line 88
<Setter Property="HorizontalAlignment" Value="Left" />HorizontalAlignment="Left" causes every entity card to shrink-wrap to its content instead of stretching to fill the tree column. The same attribute is also set inline on the Border in:
File: Phantom.Workspaces/Controls/EntityCardControl.axaml, line 14
<Border Classes="entity-card"
HorizontalAlignment="Left" <!-- overrides / duplicates the style -->
...>Neither the TreeView nor the TreeViewItem template's inner StackPanel (StackPanel.entity-card-tree-item) sets HorizontalAlignment="Stretch" or HorizontalContentAlignment="Stretch", so the stretch signal is never propagated to the card.
Issue 2 — Tree overflows splitter
File: Phantom.Workspaces.Gui.Shared/Styles/SharedStyles.axaml, Border.entity-card style, line 89
<Setter Property="MaxWidth" Value="760" />A hardcoded MaxWidth="760" allows cards to grow up to 760 px regardless of the actual column width. Combined with HorizontalAlignment="Left" (Issue 1), nothing prevents card content from pushing past the splitter-constrained *-column boundary. The ScrollViewer in MainWindow.axaml already sets HorizontalScrollBarVisibility="Disabled" (line 172), which clips the scrollbar but does not prevent layout overflow; the underlying content still measures wider than its column.
File: Phantom.Workspaces/MainWindow.axaml, Grid column definitions, line 154
<Grid Grid.Row="1" ColumnDefinitions="*,Auto,2*">The left tree panel occupies a *-width column (Column 0). No MaxWidth or MinWidth is placed on the panel <Grid> or <ScrollViewer>, so the column can grow to accommodate over-wide content rather than clipping it.
Issue 3 — Bottom corners always rounded
File: Phantom.Workspaces/Controls/EntityCardControl.axaml, line 14
<Border Classes="entity-card"
CornerRadius="6" <!-- hardcoded; overrides class-based style -->
...>The inline CornerRadius="6" overrides the class-based style Border.entity-card.branch-header defined in SharedStyles.axaml (lines 112–114):
<Style Selector="Border.entity-card.branch-header">
<Setter Property="CornerRadius" Value="6,6,0,0" />
</Style>Because the CornerRadius is set directly on the element it takes precedence over the style setter, so the 6,6,0,0 value is never applied even when the card is a branch header.
Note: this issue is also relevant to the
TreeViewItemControlTemplate introduced in #1001, where the cardBorderin row 0 of the 2-row × 2-column Grid should conditionally useCornerRadius="6 6 0 0"whenHasChildrenis true.
Affected Files
| File | Area |
|---|---|
Phantom.Workspaces.Gui.Shared/Styles/SharedStyles.axaml |
Border.entity-card style (lines 82–91), Border.entity-card.branch-header style (lines 112–114), TreeViewItem ControlTemplate (lines 180–216) |
Phantom.Workspaces/Controls/EntityCardControl.axaml |
Inline HorizontalAlignment and CornerRadius on the root Border (line 14) |
Phantom.Workspaces/MainWindow.axaml |
Left-panel Grid and ScrollViewer (lines 154–184) |
Design / Fix
Fix 1 — Fill width
-
In
SharedStyles.axaml, changeBorder.entity-card:<!-- Before --> <Setter Property="HorizontalAlignment" Value="Left" /> <Setter Property="MaxWidth" Value="760" /> <!-- After --> <Setter Property="HorizontalAlignment" Value="Stretch" /> <!-- remove MaxWidth or replace with a column-relative constraint -->
-
In
EntityCardControl.axaml, remove the inlineHorizontalAlignment="Left"(line 14) so the style setter governs alignment. -
In the
TreeViewItemControlTemplate (SharedStyles.axaml, lines 180–216), ensure the rootGridand the innerStackPanel.entity-card-tree-itemboth propagate stretch:<Grid HorizontalAlignment="Stretch" ...> <StackPanel HorizontalAlignment="Stretch" ...>
-
On the
TreeViewandTreeViewItemelements themselves, set:HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"
Fix 2 — Constrain to splitter
-
Remove the hardcoded
MaxWidth="760"fromBorder.entity-cardinSharedStyles.axaml(line 89). WithHorizontalAlignment="Stretch"applied (Fix 1) the card will be naturally bounded by its column. -
The
ScrollViewerinMainWindow.axamlalready hasHorizontalScrollBarVisibility="Disabled"(line 172) — this is correct and should be kept. -
Optionally add
HorizontalAlignment="Stretch"to the left-panel<Grid>(line 155) to make the intent explicit, though the*column definition should already enforce this.
Fix 3 — Conditional corner radius
Remove the inline CornerRadius="6" from EntityCardControl.axaml (line 14) so that the class-based style Border.entity-card.branch-header (which sets CornerRadius="6,6,0,0") can take effect.
For the TreeViewItem ControlTemplate (as part of #1001's template, the card Border in row 0):
- When
HasChildrenistrue→CornerRadius="6 6 0 0"(square bottom corners so the card connects flush to the expander button) - When
HasChildrenisfalse→CornerRadius="6"(all corners rounded)
Implement via a new IValueConverter (e.g. BoolToCornerRadiusConverter) registered in the resource dictionary, binding the Border.CornerRadius to {Binding HasChildren, Converter={StaticResource BoolToCornerRadiusConverter}}. Alternatively, use a Style with a condition on HasChildren:
<!-- default — all rounded -->
<Style Selector="Border.entity-card">
<Setter Property="CornerRadius" Value="6" />
</Style>
<!-- when item has children — square bottom -->
<Style Selector="TreeViewItem:has-children Border.entity-card">
<Setter Property="CornerRadius" Value="6 6 0 0" />
</Style>Dependencies
- The corner-radius fix (Issue 3) is additive to the
TreeViewItemControlTemplate designed in View tree view: subitem indent border on left side is not centered; agent chat editor control binding broken #1001 (2-row × 2-column Grid, card in row 0 spanning both columns, expander button below). TheCornerRadiusbinding or conditional style must be applied to the cardBorderin that template's row 0. - Fix 1 and Fix 2 are independent of View tree view: subitem indent border on left side is not centered; agent chat editor control binding broken #1001 but complement it.
- View tree view: items duplicated, leaf expanders, border placement, background color, and children re-population on expand/collapse #994 previously noted the width overflow and scrollbar symptoms; this issue supersedes that investigation with concrete root causes and fixes.
Expected Tests
Tests should follow the Subject_Scenario_ExpectedOutcome naming convention used throughout Phantom.Workspaces.Agent.Gui.Tests\.
| Test name | What it validates |
|---|---|
EntityCardControl_WhenRendered_StretchesToContainerWidth |
Card Border HorizontalAlignment resolves to Stretch |
EntityCardControl_WhenHasChildren_BottomCornersAreSquare |
CornerRadius bottom values are 0 when item has children |
EntityCardControl_WhenHasNoChildren_AllCornersAreRounded |
CornerRadius is uniform 6 when item has no children |
TreeViewItem_WhenRendered_DoesNotExceedColumnWidth |
Measured width of TreeViewItem does not exceed the column's allocated width |
BoolToCornerRadiusConverter_True_ReturnsSquareBottomRadius |
Converter returns CornerRadius(6,6,0,0) for true |
BoolToCornerRadiusConverter_False_ReturnsFullyRoundedRadius |
Converter returns CornerRadius(6) for false |
Activity
JoshuaRowePhantom commentedon Jul 15, 2026
Design
Root cause: entity card layout is constrained by left alignment and a hardcoded MaxWidth, while EntityCardControl inline values override the shared branch-header corner style.
Approach: update SharedStyles.axaml so entity cards and tree item templates stretch through the TreeView column and remove the fixed MaxWidth. Remove inline HorizontalAlignment/CornerRadius overrides from EntityCardControl so shared styles control width and branch/leaf corners. Keep the TreeView horizontal scrollbar disabled and add explicit stretch alignment on the left panel/tree. Update/add tests that assert cards stretch, no MaxWidth remains, branch cards have square bottom corners, and leaf cards remain rounded.
Alternatives considered: a converter for HasChildren was unnecessary because the current template already applies branch-header/leaf classes via separate ContentPresenters.
Files expected to change: Phantom.Workspaces.Gui.Shared/Styles/SharedStyles.axaml, Phantom.Workspaces/Controls/EntityCardControl.axaml, Phantom.Workspaces/MainWindow.axaml, GUI style tests.
JoshuaRowePhantom commentedon Jul 15, 2026
MAxWidth is wrong.
JoshuaRowePhantom commentedon Jul 15, 2026
Fix 3 - Alternatively, use a Style with a condition on HasChildren: Do this!
JoshuaRowePhantom commentedon Jul 15, 2026
Diagnosis: test failure is unrelated to this change
Failing tests:
Phantom.Workspaces.Agent.Gui.Tests.ChatOutputHtmlModelTests.Regression_BugD_OnInsert_UsesContainerPath_NotLoadAfterHardcodePhantom.Workspaces.Agent.Gui.Tests.ChatOutputHtmlModelTests.HistoryLoad_NewestChunkInsertedFirstWhy unrelated: The branch for #1006 only modifies UI layout files (
SharedStyles.axaml,EntityCardControl.axaml,MainWindow.axaml) and theMainWindowAxamlTests.cstest (renaming a test and updating HorizontalAlignment/MaxWidth assertions). None of these touch threading, the Avalonia dispatcher, or theChatOutputHtmlModelTestslogic.The failures are both
[Test Case Cleanup Failure]— the tests themselves passed in 1 ms — caused byHeadlessUnitTestSession.EnsureIsolatedApplication()calling intoDefaultRenderLoop.Addfrom the wrong thread (Dispatcher.VerifyAccess()throwsInvalidOperationException). This is a recurrence of #815 (closed 2026-07-14).Filed/updated bug: #1012
No dump files were present.
JoshuaRowePhantom commentedon Jul 15, 2026
Implementation notes
Commit: 87a989b992f0e9f3f4eece36732af84d5d992bb9
Deviations from proposed design
Used the existing branch-header/leaf class styles instead of adding a converter because the current TreeView template already exposes the HasChildren split via separate presenters.
Scope changes
None
Files changed
JoshuaRowePhantom commentedon Jul 15, 2026
Verification result
Status: ✅ Verified
Commits checked: 87a989b9 Fix #1006: stretch entity cards in view tree
Outstanding gaps
None — all criteria satisfied.
Tests
Executed : 65
Passed : 65
Failed : 0
Relevant test classes: SharedStylesTests, MainWindowAxamlTests
Coverage:
Features implemented (all three fixes):
Border.entity-cardstyle setsHorizontalAlignment="Stretch"; inline override removed fromEntityCardControl.axaml;TreeViewandTreeViewItempropagate stretch alignmentMaxWidthremoved fromBorder.entity-cardstyle; cards now bounded by column width;HorizontalScrollBarVisibility="Disabled"retainedBorder.entity-card.branch-headerstyle appliesCornerRadius="6,6,0,0";Border.entity-card.leafappliesCornerRadius="6"; inline override removed so class-based styles governCode quality:
JoshuaRowePhantom commentedon Jul 15, 2026
Verification result
Status: ✅ Verified
Commits checked:
efcc2e3 Fix #1006: stretch entity cards in view tree
Outstanding gaps
None — all criteria satisfied within the owner-authorized scope.
Feature coverage
Border.entity-cardstyle nowHorizontalAlignment=Stretch; inlineHorizontalAlignment=Leftremoved fromEntityCardControl.axaml;StackPanel.entity-card-tree-item, theTreeViewItemControlTemplate Grid/StackPanel/ContentPresenters,TreeView, and the left-panel Grid/ScrollViewer all propagateStretch.MaxWidth=760removed fromBorder.entity-card;HorizontalScrollBarVisibility=Disabledretained; explicitStretchadded to left panel.CornerRadius=6removed fromEntityCardControl.axamlso class-based styles govern —Border.entity-card.branch-header→6,6,0,0(square bottom when has children),Border.entity-card.leaf→6. Implemented via the HasChildren-conditioned style approach the owner requested (Do this!), not a converter — the owner's design comment explicitly deemedBoolToCornerRadiusConverterunnecessary because the template splits branch/leaf via separate presenters.Notes on test scope (owner-authorized)
BoolToCornerRadiusConvertertests are not required (converter not used per owner's design comment).Stretch+no MaxWidthassertions, matching the owner's re-scoped test list (stretch, no MaxWidth, branch square, leaf rounded). Tests follow the existing string-based AXAML assertion pattern used throughout these test classes.Coverage
6,6,0,0and leaf6)Tests
Relevant classes: SharedStylesTests, MainWindowAxamlTests
Fix #1006: stretch entity cards in view tree
JoshuaRowePhantom commentedon Jul 15, 2026
Checked in
Commit: 298e972
Branch fast-forwarded: features -> 298e972
Wrap entity card header and actions together (#1213)