Repository navigation
fix(web): files panel rows that group same-named folders act on their real folder - #339
Conversation
… real folder When two listed folders share a name, their labels grow a parent segment (`dupe-a/docs`) and the tree shows a `dupe-a` row that only groups them. Its right-click actions and drag mention joined that segment to the workspace folder, or during a search to the grouped root, so they pointed at a path that doesn't exist. Such a row now resolves to the folder its roots sit in. When they don't share one, as with an isolated run's worktree, the row has no menu and no mention. Refs LoganRupe#335 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LoganRupe
left a comment
There was a problem hiding this comment.
Looks good for the same-name case it targets. I found two things worth fixing first:
1. A Windows drive-letter group row resolves to a nonsense path (filePath.ts, rootGroupFolder)
Take roots C:\docs and D:\docs. buildRootLabels labels them C:/docs and D:/docs, so the tree shows a C: row. rootGroupFolder returns C: for that row. fileTreeEntryTarget then finds no separator and returns workspaceRoot: "C", filePath: "C:", so Reveal/Open act on the wrong thing and the mention is drive-relative. Returning null when the candidate has no separator left would cover it:
if (!/[\\/]/.test(candidate)) return null;2. Dragging only unresolvable rows leaves the row selected (fileTreeDragMention.ts)
When every dragged row's mentionPath is null, handleDragStart returns before draggedPaths = dragged. handleDragEnd then has nothing to deselect, and the gesture's selection stays highlighted. Moving the assignment above the mentions.length === 0 return fixes it. The new test could also assert that deselect was called after handleDragEnd().
Two smaller ones, not blocking:
- Right-clicking a group row that resolves to
null(mixed worktree, or roots in different folders) closes the menu without any feedback, so the row looks broken. A disabled item like "No single folder for this group" would explain it. - The search merge still writes
root: <docs root>, relativePath: "dupe-a"intoentryInfofor the group segment it synthesizes.entryTargetnow routes around that, and the only other reader (the file open path) skips directories, so nothing breaks today. Settingrootonly on segments at or below the root's label would remove the trap.
…nd no shared folder Review follow-ups for the files panel group rows: - A group row that is a drive (`C:` over `C:/docs` and `D:/docs`) or a network host (`\\server`) now resolves to no folder, rather than one the file actions turned into a nonsense path and a drive-relative mention. - Dragging only rows that can't be mentioned no longer starts a drag. It used to select them and drop their tree path into the composer as text. - Right-clicking a group row with no single folder shows a disabled "No single folder for this group" item instead of no menu at all. - A search no longer gives the group segments it adds above a root's own node that root, so nothing can mistake them for a folder inside it. Refs LoganRupe#335 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
LoganRupe
left a comment
There was a problem hiding this comment.
Thanks for turning this around so quickly. All four points are covered, and moving the search fix to where the group segments get built is better than what I suggested. Cancelling the drag before the tree sees it is a nice touch too, since it means nothing gets left selected.
I checked out the new commit and ran both test files (32 passing) plus a typecheck on apps/web. Both came back clean.
Approving. Thanks again!
5b16e42
into
LoganRupe:multi-repo-workspaces
|
Thanks for the review! All four points are fixed in 7939537. 1. Drive-letter row. A row that is a drive ( 2. Row left selected after a drag. Deselecting at drag end wasn't enough. The tree also puts the row's label on the drag as plain text, so 3. Silent right-click. These rows now show a disabled "No single folder for this group" item. It works in both the desktop and web menus. 4. Search segments. During a search, only the segments from a folder's own row down get its All 5,525 web tests pass and the typecheck is clean. I tested the drag and the menu on macOS. The drive and network cases are covered by unit tests only. |
This finishes #335. #336 fixed the right-click actions and drags on files; this fixes the one case left over, a row that groups same-named folders. With both, everything reported in #335 now points at the right file. I re-tested the issue's full example below.
It targets the old files panel code (
multi-repo-workspaces-pre-v2). That branch doesn't exist yet, so this targetsmulti-repo-workspacesat7e164c78b, the commit it will be cut from. Retarget it once the branch is there.Problem
When two listed folders share a name, their labels get a parent segment (
dupe-a/docs,dupe-b/docs). The tree then shows adupe-arow that only groups them. Right-click and drag on that row used a path that doesn't exist:<workspace>/dupe-a, or<docs folder>/dupe-aduring a search.Fix
A grouping row now acts on the real folder it stands for, e.g.
~/dev/dupe-test/dupe-a.Sometimes there is no single folder. The grouped folders can live in different places, belong to an isolated run's worktree, or sit on a drive like
C:. Then the row's right-click menu says "No single folder for this group", and dragging the row does nothing. Before, both used a path that doesn't exist.Testing
All in a macOS build of this branch.
The #335 example (
scope-test-four:api,web,notes/2026,../notes):ideas.md→ Reveal in Finderscope-test-four/notes, noideas.mdthere~/dev/noteswithideas.mdselectedideas.md→ Open with → VS Codeideas.md→ Copy mention[ideas.md](notes/ideas.md)[ideas.md](/Users/<user>/dev/notes/ideas.md)ideas.md→ Add to chatideas.mdwas meant~/dev/notes/ideas.mddirectlyplan.md→ Reveal in Finderscope-test-four/notes/2026withplan.mdselectedplan.md→ Copy mention[plan.md](2026/plan.md)Isolated run of
scope-test,api→WORKTREE.md(a file only in the worktree):apifolder with the file selected[WORKTREE.md](api/WORKTREE.md)[WORKTREE.md](/Users/<user>/.t3/worktrees/<…>/api/WORKTREE.md)Same-named folders (
dupe-a/docs,dupe-a/notes,dupe-b/docs,dupe-b/notes):dupe-arow → action[dupe-a](/Users/<user>/dev/dupe-test/dupe-a)dupe-test/withdupe-aselected. During a search it used to do nothingNew unit tests cover the grouping row, a Windows path, a worktree and folders in different places. All web tests pass (5525). In the full suite, a few
scriptsandservertests fail, but they fail the same way on7e164c78bwithout this change.Found while testing, left for after v2: with same-named folders, clearing a search empties the files panel until it's reopened. That bug is older than this PR, and I have a fix ready.
Fixes #335
Model: Claude Opus 5.5, harness: Claude Code.