From 9c56f7823dfae211616c4b2e5d6a9ca3adedc81d Mon Sep 17 00:00:00 2001 From: Codeman maintainer Date: Tue, 13 Oct 2026 18:09:08 +0200 Subject: [PATCH] fix(preview): a shell prompt's trailing `$` or `#` stays out of its folder link (#604 merge-time fix) The folder link pattern treats `:` as a boundary and allows `$`/`#` in a path, so every default bash prompt (`user@host:~/proj$`, `root@c:/workspace#`) became a folder link to a path that does not exist, and clicking it showed "Folder not found". folderLinkPath now strips them, so the link opens the prompt's cwd. Co-Authored-By: Claude Opus 5.5 (1M context) --- src/web/public/constants.js | 4 +++- test/file-path-link-forms.test.ts | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/web/public/constants.js b/src/web/public/constants.js index 2d65ad1c..71995cbd 100644 --- a/src/web/public/constants.js +++ b/src/web/public/constants.js @@ -2163,7 +2163,9 @@ const FOLDER_PATH_LINK_PATTERN = * without a slash at the end is prose, not a folder. */ function folderLinkPath(candidate) { - const path = String(candidate || '').replace(/[.,:;!?'"]+$/, ''); + // `$` and `#` too: a shell prompt (`user@host:~/proj$ `, `root@c:/app# `) ends + // its cwd with one. A folder whose name really ends in one links one short. + const path = String(candidate || '').replace(/[.,:;!?'"$#]+$/, ''); if (!path || path === '~/' || /^\/[^/]+\/$/.test(path)) return null; if (path.endsWith('/')) return /[^/.]/.test(path) ? path : null; if (!path.startsWith('/') && !path.startsWith('~/')) return null; diff --git a/test/file-path-link-forms.test.ts b/test/file-path-link-forms.test.ts index 3399873c..3e6f23a5 100644 --- a/test/file-path-link-forms.test.ts +++ b/test/file-path-link-forms.test.ts @@ -90,6 +90,11 @@ describe('findFilePathLinks', () => { expect(paths('see src/a.ts:120.')).toEqual(['src/a.ts']); }); + it("keeps a shell prompt's trailing `$` or `#` out of the folder it links", () => { + expect(paths('arkon@tnode:~/default/claudeman$ ls')).toEqual(['~/default/claudeman']); + expect(paths('root@c:/workspace/app# ls')).toEqual(['/workspace/app']); + }); + it('still finds rooted absolute paths, and never a relative path inside one', () => { expect(paths('sign-off from /mnt/raid1/x/refs/look_montage.png.')).toEqual(['/mnt/raid1/x/refs/look_montage.png']); // Unknown root: not linked at all (no `nix/store/…` cut out of it).