Skip to content

fix(web): keep the final segment of directory paths with a trailing separator - #5460

Open
jorvarea wants to merge 3 commits into
pingdotgg:mainfrom
jorvarea:fix/directory-chip-trailing-separator
Open

fix(web): keep the final segment of directory paths with a trailing separator#5460
jorvarea wants to merge 3 commits into
pingdotgg:mainfrom
jorvarea:fix/directory-chip-trailing-separator

Conversation

@jorvarea

@jorvarea jorvarea commented Aug 6, 2026

Copy link
Copy Markdown

Summary

  • keep the final path segment when a directory is written with a trailing / or \
  • chips for paths like /tmp/favicons/ rendered with no label at all

Closes #5291

Why

basenameOfPath in markdown-links.ts took everything after the last separator. A trailing separator is a valid way to write a directory, so the final segment came back as the empty string and the chip rendered as a bare folder icon with no text. The same path without the trailing separator rendered correctly.

Change

Trim trailing separators before taking the final segment. Four lines in one function.

Tests

Four cases added to markdown-links.test.ts, all failing before the change:

  • POSIX directory path with a trailing slash keeps its final segment
  • Windows directory path with a trailing backslash keeps its final segment
  • a path with and without a trailing separator produce the same label
  • a directory path does not produce an empty label

vp test run apps/web/src/markdown-links.test.ts — 37 passed
vp lint — clean

Bare / and // still return an empty segment, but they never reach this function: resolveMarkdownFileLinkTarget rejects them because a root prefix such as /tmp/ or /Users/ is required. Verified with a throwaway test.

Notes

filePathDisplay.ts and pierre-icons.ts each carry their own copy of this helper with the same behaviour. They are not on the path this issue describes, so this change leaves them alone rather than growing into a refactor. Consolidating the three is worth a separate change.

Verified via unit tests rather than in the running app.

🤖 Generated with Claude Code

Note

Fix basenameOfPath to return the final segment of directory paths with a trailing separator

basenameOfPath in markdown-links.ts previously returned an empty string for paths ending with / or \. It now trims trailing separators before extracting the last segment, falling back to the original path if trimming produces an empty string.

Macroscope summarized 3af0e7a.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ed521690-b57d-4ec0-b3d0-6ec1689c7ec4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Aug 6, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved a8908e0

Straightforward bug fix for a display issue where directory paths with trailing separators rendered with empty labels. The change is a simple string trim with fallback, isolated to a single utility function, and well-covered by new unit tests.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Directory chips can drop the final path segment and display the parent directory

1 participant