Skip to content

feat: middle-truncate long file paths in diff panel#1603

Open
reverb256 wants to merge 2 commits intoPostHog:mainfrom
reverb256:fix/1600-middle-truncate-filepaths
Open

feat: middle-truncate long file paths in diff panel#1603
reverb256 wants to merge 2 commits intoPostHog:mainfrom
reverb256:fix/1600-middle-truncate-filepaths

Conversation

@reverb256
Copy link
Copy Markdown
Contributor

Problem

File paths in the diff/edit tool view wrap poorly when too long, as described in #1600.

Fixes #1600

Solution

Uses @chenglou/pretext to measure text width and middle-truncate when the path overflows:

  • Fits? Show full path: src/renderer/components/action-selector/ActionSelector.tsx
  • Too long? Middle-truncate on slashes: src/.../action-selector/ActionSelector.tsx
  • Very long? Last resort: .../ActionSelector.tsx
  • Tooltip: Full path shown on hover, only when truncated (per adboio preference)

Truncation always breaks between / segments — never mid-directory-name.

Files Changed

  • FileMentionChip.tsx — added middleTruncatePath with pretext measurement + conditional Tooltip
  • package.json / pnpm-lock.yaml — added @chenglou/pretext dependency

Uses @chenglou/pretext to measure file path width and
middle-truncate when it overflows. Truncation always breaks
between slashes (e.g. src/.../ActionSelector.tsx).

- Shows full path when it fits
- Middle-truncates with '...' between slashes when too long
- Tooltip with full path appears on hover, only when truncated
- Falls back to '.../filename' if nothing else fits

Fixes PostHog#1600
@reverb256
Copy link
Copy Markdown
Contributor Author

Visual Evidence

Before → After: Middle-truncation for long file paths

PR #1603 visual evidence

Short paths show fully. Long paths truncate from the middle, preserving the filename and the nearest directory. Uses @chenglou/pretext for text measurement.

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.

fix filepath text wrapping in diff panel

1 participant