Skip to content

fix(trees): keep deep flattened paths readable (#941)#997

Open
pablofdezr wants to merge 1 commit into
pierrecomputer:mainfrom
pablofdezr:fix/flattened-path-truncation
Open

fix(trees): keep deep flattened paths readable (#941)#997
pablofdezr wants to merge 1 commit into
pierrecomputer:mainfrom
pablofdezr:fix/flattened-path-truncation

Conversation

@pablofdezr

@pablofdezr pablofdezr commented Jul 15, 2026

Copy link
Copy Markdown

Description

In the file tree, a deep path gets flattened onto a single line and each segment gets truncated on its own. The result is ı… / k… / … / hanne… / … / s…: nothing but ellipses that don't tell you which folder the row actually opens.

A flattened row rendering as nothing but ellipses

The fix splits the path at the last separator. The head half (the intermediate directories) absorbs the shrinking, while the terminal directory (the one the row actually opens) keeps its full width. That way impl or server show up complete instead of s….

Flattened rows keeping their terminal directory readable

MiddleTruncate renders each half twice, once hidden to detect overflow, which would have duplicated the per-segment data attributes that drag and drop and the tests query. Only the text metrics of the hidden copy matter, so OverflowText takes a measureChildren stand-in and MiddleTruncate a measureContents pair.

The \u00a0 detail

The first version dropped the space before the final slash: the separator opens the second half, its leading space lands at the start of the line, and the browser collapses it. Fixed with \u00a0 (non-breaking space) so it doesn't collapse, and so it's visible in the diff instead of being an invisible character.

Motivation & Context

Fixes #941. A deeply nested single-child path is exactly the case where the row's text matters most, and it was the case that rendered worst: on a narrow enough row, nothing readable survived.

Two things worth flagging:

  1. [trees][wip] MiddleTruncation from css grid hack to text-overflow: ellipsis #939 removes OverflowContent/OverflowMarker, right where measureChildren lives, so if [trees][wip] MiddleTruncation from css grid hack to text-overflow: ellipsis #939 lands first, this fix gets simpler.
  2. leaf-path was already written and unused (OverflowText.tsx:141), a sign you'd already thought about this case. This PR splits at the same boundary, though it splits in FileTreeView rather than passing split="leaf-path", since the halves need to stay as nodes rather than a string.

Type of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Documentation update

Checklist

  • I have read the contributing guidelines
  • My code follows the code style of the project (oxlint --type-aware and stylelint clean)
  • My code is formatted properly (oxfmt --check: all matched files use the correct format)
  • I have updated the documentation accordingly (not applicable)
  • I have added tests to cover my changes (a unit assertion on the rendered run, and a Playwright test that narrows the row and checks the terminal directory keeps its width)
  • All new and existing tests pass (bun test in packages/trees: 324 pass, 0 fail)

How was AI used in generating this PR

Disclosing this in full, since the guidelines ask for the extent and not just the fact.

  • The code and the tests were AI-generated. The implementation (OverflowText.tsx, FileTreeView.tsx, style.css) and both test files were written by Claude (Opus 4.8) working under my direction, not typed by me. This is recorded in the Co-Authored-By trailer on the commit.
  • This description is my own writing. The prose here is mine, not a generated summary.
  • The title started as the AI-drafted commit subject, so I'm flagging it rather than claiming it.
  • The decisions were mine: picking Bug(trees): deeply nested single folder paths don't render nicely #941 as the target, choosing to reuse the existing leaf-path split boundary instead of inventing a custom one, and checking whether [trees][wip] MiddleTruncation from css grid hack to text-overflow: ellipsis #939 already covered this before any code was written.
  • Testing: the unit suite, lint, stylelint and formatting were run and pass, as quoted above. The screenshots are captures of the real component, not generated images.

Related issues

Closes #941.

Related: #939 (touches the same OverflowText internals).

Every segment of a flattened directory row rendered its own Truncate, so
each one shrank and truncated independently. A deep single-child path
spent the row on ellipses instead of on the path ("t… / kc… / … / se…"),
and a narrow enough row showed nothing else.

Split the path where the `leaf-path` split does, at the last separator,
and hand the halves to MiddleTruncate with the terminal directory
prioritised. The leading run absorbs the shrinking while the directory
the row actually opens holds its width: "test / kotlin / com… / server".

MiddleTruncate renders each half twice, once hidden to detect overflow,
which would have duplicated the per-segment data attributes that drag and
drop and the tests query. Only the text metrics of the hidden copy matter,
so OverflowText takes a `measureChildren` stand-in for it and
MiddleTruncate a `measureContents` pair.

Renaming keeps the flex line it had, where the input sizes itself against
a flex item.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

@pablofdezr is attempting to deploy a commit to the Pierre Computer Company Team on Vercel.

A member of the Team first needs to authorize it.

@vercel vercel Bot temporarily deployed to Preview – pierrejs-diff-demo July 15, 2026 18:17 Inactive
@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
pierrejs-diff-demo Skipped Skipped Jul 15, 2026 6:17pm

Request Review

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.

Bug(trees): deeply nested single folder paths don't render nicely

1 participant