Repository navigation
fix(desktop): stop the file tree truncating names that fit - #6264
Merged
Merged
Conversation
Pierre detects overflow purely in CSS: it lays out a hidden `word-break: break-all` copy of each row's label next to the visible one and reveals the middle-truncation marker — the `…` + fade painted in the row's own background colour — via `@container measure (height > 1lh)` on the marker cell. That comparison ships with zero margin. On a 28px row a name that fits measures exactly 28.00px against a `1lh` of exactly 28px, and only the strict `>` keeps the marker hidden. Anything that rounds the used line box up — sub-pixel snapping under fractional page zoom, a display scale that doesn't divide evenly — flips every row at once, and the marker then covers ~3 characters mid-name at any sidebar width. Because the text underneath is still laid out at full width, this reads as the tree ignoring the width it has rather than as truncation, and widening the sidebar changes nothing. Give the container query 1.5 lines of slack so rounding can't reach it while a genuine second line (2lh) still trips it, and pin the marker's own `lh`-sized box back to a single row so it doesn't grow with the inflated line-height when it is legitimately shown. Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
📝 WalkthroughWalkthroughThe Pierre tree stylesheet adds middle-truncation overflow CSS. The measurement cell uses a 1.5-row threshold. The truncation marker remains one row high. The new CSS is included in ChangesMiddle-truncation overflow handling
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 1 file
Architecture diagram
sequenceDiagram
participant Renderer as "Electron Renderer (React)"
participant Style as "createPierreTreeStyle"
participant Pierre as "Pierre Tree (@pierre/trees)"
participant Layout as "Chromium Layout Engine"
Note over Renderer,Layout: Entire flow runs inside the desktop renderer process
Note over Pierre: Shared CSS serves both the Files tab and the Changes tab trees
Renderer->>Style: request tree styles
Style-->>Renderer: CSS including PIERRE_TREE_UNSAFE_CSS
Renderer->>Pierre: apply styles and row data (name, --trees-row-height)
Pierre->>Pierre: per row: lay out visible label, hidden break-all copy, marker cell
Pierre->>Layout: marker cell line-height 1.5x row height
Pierre->>Layout: marker pinned to 1x row height
Note over Layout: Sub-pixel line-box rounding under fractional zoom / non-integer display scale
Layout->>Layout: evaluate @container measure (height > 1lh) on the marker cell
alt line box stays within the 1.5-row slack (name fits)
Layout-->>Pierre: query does not match - marker hidden, name drawn at full natural width
else genuine second line reached (2lh overflow)
Layout-->>Pierre: query matches - ellipsis + row-coloured fade painted over the middle
end
Tip: cubic used a learning from your PR history. Let your coding agent read cubic learnings directly with the cubic MCP.
Re-trigger cubic
Drops the measured numbers and the environment speculation; the reproduction detail lives in the PR description and the fix commit. Co-Authored-By: Claude <noreply@anthropic.com>
Member
|
Lovely, thank you @aiwebb ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
The Files tab (and the Changes tab's section trees) middle-truncate names that comfortably fit —
CLAUDE.mdrenders asCLAUD…d,.githubas….thub— and widening the sidebar changes nothing, which is the tell that this isn't a layout problem.Nothing is actually being truncated. The text underneath is laid out at its full natural width; Pierre's middle-truncation marker (the
…+ fade, painted in the row's own background colour) is being drawn over the middle of it. I measured a user-reported screenshot pixel by pixel: every row's on-screen text width was exactly its natural width × the page-zoom factor, long names and short names alike. Nothing was shrunk — ~3 characters were simply covered up.The cause is that Pierre detects overflow entirely in CSS. It lays out a hidden
word-break: break-allcopy of the label beside the visible one and reveals the marker via@container measure (height > 1lh)on the marker cell. That comparison ships with zero margin: on a 28px row a name that fits measures exactly28.00pxagainst a1lhof exactly28px, and only the strict>keeps the marker hidden. Anything that rounds the used line box up by any amount — sub-pixel snapping under fractional page zoom, a display scale that doesn't divide evenly — flips every row at once.The fix gives the query 1.5 lines of slack, so rounding can't reach it while a genuine second line (
2lh) still trips it. The marker's own box is sized inlhtoo, so it's pinned back to one row or it grows with the inflated line-height when legitimately shown. Two rules, in the existing sharedPIERRE_TREE_UNSAFE_CSS, so both the Files tab and the Changes trees get it and the threshold scales with each tree's row height.How I tested it
Drove the dev desktop app over CDP (renderer on this workspace's
DESKTOP_VITE_PORT3005, target identity confirmed against/json/listbefore testing — another worktree's app was live on the port I first tried), signed in, opened a workspace pointed at this repo, and navigated to Files →.github/workflowswith real clicks. The screenshots above are that session, cropped to the panel withPage.captureScreenshot'sclip.How the before/after was produced — please read this before trusting the pair. The failure did not reproduce spontaneously on my machine: at Electron page zoom 1.3145 on a 2× display the tree measured
cellH 28.00against1lh 28pxand the markers stayed off, i.e. it sat exactly on the knife edge without falling off it. Emulating DPR 1 over CDP wasn't enough to tip it either. So rather than claim a native repro, I measured the margin directly: I nudged the line box by 0.53% —28.147px, the size of a one-device-pixel snap at zoom ~1.31 on a 1× display, which is where the original report came from — and captured both states under that identical nudge.….thubandclaud……ills.I also built a standalone harness around the shipped
@pierre/trees@1.0.0-beta.5CSS and row markup to sweep the threshold independently. There, CSSzoomdoes trip the real thing without any nudge — broken at 0.9 / 1.3 / 1.3145, fine at 1.0 / 1.2 / 1.25 / 1.44 / 1.728 — and the fix is correct at every factor tested. Note that CSSzoomand Electron page zoom are different mechanisms, so I'm citing that as evidence the threshold is genuinely reachable, not as the trigger.Gates:
bun run lintclean,bun run typecheck37/37,bun run test2551 pass / 0 fail.Not verified: the exact environmental condition that tips a real user's machine over the line. I know the margin is zero and that a 0.53% nudge is enough; I could not reproduce the tip natively on my hardware.
Authorship
Written by Claude (Claude Code, Opus 5) running in a Superset workspace, prompted and reviewed by @aiwebb. Claude diagnosed the bug from a screenshot, wrote the fix, ran the gates, drove the CDP verification, and captured the screenshots. @aiwebb reported it, confirmed the fix in the running dev app, and directed the screenshots be taken against this repo rather than their own codebase. Claude's first root-cause explanation was wrong — it blamed page-zoom rounding based on the standalone harness, then disproved that in the real app and corrected both the code comment and this description. The commit carries a
Co-Authored-By: Claudetrailer.Checklist
type(scope): subject)bun run lintandbun run typecheckpass (CI fails on lint warnings too)Summary by cubic
Fixes incorrect middle‑truncation in the Files and Changes trees when names actually fit. Gives the overflow check slack and pins the marker to one row so only real overflows are truncated.
@container (height > 1lh)let rounding show markers over names that fit.lhslack and pin the marker box to1lh, shipped viaPIERRE_TREE_UNSAFE_CSSfor both trees; also trimmed the inline comment to the core rationale.Written for commit 3cd6ddd. Summary will update on new commits.
Summary by CodeRabbit