Skip to content

fix(desktop): stop the file tree truncating names that fit - #6264

Merged
Kitenite merged 2 commits into
ParadevAI:mainfrom
aiwebb:fix-sidebar-width-truncat
Aug 20, 2026
Merged

Kitenite merged 2 commits into
ParadevAI:mainfrom
aiwebb:fix-sidebar-width-truncat

Conversation

@aiwebb

@aiwebb aiwebb commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

What & why

The Files tab (and the Changes tab's section trees) middle-truncate names that comfortably fit — CLAUDE.md renders as CLAUD…d, .github as ….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-all copy 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 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 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 in lh too, so it's pinned back to one row or it grows with the inflated line-height when legitimately shown. Two rules, in the existing shared PIERRE_TREE_UNSAFE_CSS, so both the Files tab and the Changes trees get it and the threshold scales with each tree's row height.

Before After
before after

How I tested it

Drove the dev desktop app over CDP (renderer on this workspace's DESKTOP_VITE_PORT 3005, target identity confirmed against /json/list before 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/workflows with real clicks. The screenshots above are that session, cropped to the panel with Page.captureScreenshot's clip.

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.00 against 1lh 28px and 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.

  • Before (fix stashed, nudge applied): 59 of 59 rows show markers. Matches the reported screenshot exactly, down to ….thub and claud……ills.
  • After (fix applied, same nudge): 0 of 59.
  • A name genuinely too long for the lane still truncates, marker and all — checked with a 110-character filename.
  • At the default zoom with no nudge, both builds are identical; this changes nothing in the common case.

I also built a standalone harness around the shipped @pierre/trees@1.0.0-beta.5 CSS and row markup to sweep the threshold independently. There, CSS zoom does 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 CSS zoom and 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 lint clean, bun run typecheck 37/37, bun run test 2551 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: Claude trailer.

Checklist

  • PR title follows conventional commits (type(scope): subject)
  • bun run lint and bun run typecheck pass (CI fails on lint warnings too)
  • "Allow edits from maintainers" is checked on fork PRs

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.

  • Bug Fixes
    • Root cause: zero‑margin @container (height > 1lh) let rounding show markers over names that fit.
    • Change: add 1.5 lh slack and pin the marker box to 1lh, shipped via PIERRE_TREE_UNSAFE_CSS for both trees; also trimmed the inline comment to the core rationale.

Written for commit 3cd6ddd. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Improved detection of overflowing tree labels that use middle truncation.
    • Prevented false overflow indicators caused by sub-pixel rendering differences.
    • Preserved consistent marker sizing while supporting multi-line content.

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>
@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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 PIERRE_TREE_UNSAFE_CSS.

Changes

Middle-truncation overflow handling

Layer / File(s) Summary
Overflow measurement styling
apps/desktop/src/renderer/lib/pierreTree/createPierreTreeStyle.ts
Adds CSS that tolerates sub-pixel rounding during overflow measurement and includes the CSS in PIERRE_TREE_UNSAFE_CSS.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title uses conventional commit format and clearly describes the fix for incorrect file-name truncation.
Description check ✅ Passed The description includes the required sections, explains the cause and fix, documents testing, and completes the checklist.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot 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.

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
Loading

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>
@Kitenite
Kitenite merged commit d89d1d7 into ParadevAI:main Aug 20, 2026
12 checks passed
@Kitenite

Copy link
Copy Markdown
Member

Lovely, thank you @aiwebb !

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