Skip to content

feat(chat): read tool-file labels from the pane's folder - #1837

Merged
devswha merged 9 commits into
mainfrom
feat/chat-relative-tool-paths
Oct 24, 2026
Merged

devswha merged 9 commits into
mainfrom
feat/chat-relative-tool-paths

Conversation

@devswha

@devswha devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner

What it does for the user

A chat tool card names its files from the pane's folder, the way the file browser already does. In a pane on /work/app, an edit to /work/app/src/a.ts reads app/src/a.ts instead of the whole absolute path, so the part that matters fits on a phone.

Only the label gets shorter:

  • the tooltip (Open /work/app/src/a.ts), the file the viewer opens and a copy's text keep the path as written; selecting the whole label copies /work/app/src/a.ts (data-raw-path), a part of it copies that part;
  • a file outside the folder, in a sibling (/work/app-2), a relative or Windows/UNC path, or a pane with no known folder reads as written;
  • on a touch screen each file link grows to --touch-target, so the files of a patch never share a hit area.

Follows T3 Code's workspace-relative paths (formatWorkspaceRelativePath), already credited for the file browser.

Why

Absolute paths in tool cards repeat the pane's folder on every row and wrap on phones; the file browser already reads paths from the pane folder, and the chat now matches it.

How it was verified

  • bun test src/lib/workspacePath.test.ts (root/sibling/outside/relative/Windows/UNC cases) and scripts/ci-browser.test.ts pass.
  • scripts/chat-tool-paths-demo-regression.ts (added to the browser lane) passes on the rebased branch: labels, titles, viewer requests, whole/partial/all-cards copies, another PC's same pane id, no-folder and Windows-folder panes, 44px touch targets with no overlap at 390 px, no sideways scroll for a Unicode path and a 300-character name; 48 captures at 390 and 1440, light and dark, plus Korean.
  • bun run check fast passes.
  • Reviewed by a code-review agent and Codex. The one HIGH (the regression's demo override did not rewrite the /api/machines/events roster, so panes kept the demo folder after the rebase) is fixed in this branch.

Known follow-up (not in this PR)

A rich-text (text/html) copy leaves a clickable file label out entirely, as it already does on main for every tool-file button; the plain-text copy carries the whole path. The docs here say "a copy's text" for that reason.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 2db8d37 and d1f8614.

Files selected for processing: 10
  • DESIGN.md
  • changelog.d/chat-relative-tool-paths.md
  • scripts/chat-tool-paths-demo-regression.ts
  • scripts/ci-browser.sh
  • src/components/ChatView.css
  • src/components/ChatView.tsx
  • src/components/PaneTerminal.tsx
  • src/lib/markdownClipboard.ts
  • src/lib/workspacePath.test.ts
  • src/lib/workspacePath.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

📝 Summary

Summary by CodeRabbit

  • New Features
    • Chat tool file names now display relative to the pane’s folder when the file is within it. Paths outside the folder, or paths that can’t be safely shortened, remain unchanged.
    • Tooltips, file opening, and copying the full label retain the original path; selecting part of a shortened label copies only the selected text.
  • Improvements
    • File links have larger touch targets on touch devices.

Chat tool-file labels can display paths relative to the pane folder. Opening files and copying a fully selected label retain the original path. The change also adds touch-target styling and browser regression checks.

Changes: Chat tool path labels

Layer / File(s) Summary
Path root and label formatting
src/lib/workspacePath.ts, src/lib/workspacePath.test.ts, DESIGN.md, changelog.d/chat-relative-tool-paths.md
Added helpers to derive a POSIX pane root and format eligible paths relative to it. Tests cover roots and path cases. Documentation describes the display and raw-path behavior.
Tool-file rendering and pane integration
src/components/ChatView.tsx, src/components/PaneTerminal.tsx, src/components/ChatView.css
ChatView receives the pane working directory and provides its derived root to tool-file rendering. Tool-file titles and opening continue to use the raw path. Coarse-pointer links receive a minimum touch target.
Clipboard path preservation
src/lib/markdownClipboard.ts
Fully selected shortened labels temporarily expand to their raw paths while generating the selection payload. The label text is restored afterward.
Browser regression coverage
scripts/chat-tool-paths-demo-regression.ts, scripts/ci-browser.sh
Added browser checks for labels, opening, copying, pane and machine switching, touch targets, and viewer states. The sequential browser CI lane runs the new script.

Priority: Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Possibly related issues

  • Issue 1606 in devswha/herdr-web-ui requests relative tool-card file labels with full paths retained in tooltips and paths outside the pane folder left unchanged. This PR implements those objectives.

Suggested reviewers: yoonwoo-ha, demrom

Merge Risk: Minimal · up to d1f86

No concrete issue remains that should block merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 7 files. (3 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title "feat(chat): read tool-file labels from the pane's folder" names the main change: chat tool-file labels are now shortened relative to the pane's folder. It matches the changeset, which adds …
Description check Passed The description follows the template. It has a Change section that describes the problem and resulting behavior, and it links no issue. The description states the feature's motivation but does not lin…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(chat): read tool-file labels from the pane's folder" names the main change: chat tool-file labels are now shortened relative to the pane's folder. It matches the changeset, which adds toolPathRoot/toolPathLabel, passes cwd to ChatView, and changes ToolFile rendering. It is specific and follows a conventional commit style.

Full details: Description check

Explanation

The description follows the template. It has a Change section that describes the problem and resulting behavior, and it links no issue. The description states the feature's motivation but does not link a maintainer-agreed issue, which the template asks for on features. The Validation section lists the commands run and their results, including the browser regression and check fast. The description also covers the known follow-up on rich-text copy. The missing issue link is a minor gap, so the description is mostly complete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 7 files. (3 skipped: 3 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Merge pass review-work for 51c9d1e: REVIEW FAILED on one outside-the-folder case.

Blocker: a tool path with .. that leaves the pane's folder gets a label that looks inside it. With cwd /work/app, the path /work/app/../etc/passwd is shown as app/../etc/passwd. That label suggests a file inside the folder, but the path resolves outside it. The description says a file outside the folder "reads as written". The gate reproduced this through the helper and in a rendered ChatView.

The cause is workspaceRelativePath (src/lib/workspacePath.ts:33-37, called from ChatView.tsx:308), which tests with startsWith(root + "/"). That helper is older than this PR, and for the file browser it is fine: that browser's paths come from its own listing and never contain ... Tool paths come from agent output and can.

Please keep a path containing a . or .. segment as written. For example, check the segments in toolPathRoot's caller or in a small wrapper, then add a unit case and one regression step. The tooltip and the opened file already use the full path, so this is a display bug, not an access problem.

Checked and passing:

  • Tests: 26 unit, ci-browser and conventions tests pass, and the typecheck passes. chat-tool-paths-demo-regression passes 15 on an isolated herdr.
  • Code review (programming and remove-ai-slops): PASS. Four mutants are caught: no sibling guard, / as root, no raw-path copy, and no touch CSS.
    • Trailing slashes and / are handled.
    • A symlinked folder, a case difference, //, Windows and UNC paths fall back to the full path.
    • The folder comes from that PC's own pane list.
    • Whole, partial and multi-card copies give the right text.
    • Touch targets don't overlap, and the desktop layout is unchanged.
  • Gate: a cwd that changes mid-session is followed. The accessible name and description carry the full path. The existing file-browser formatter is reused, not duplicated. git merge-tree against main is clean.

Non-blocking:

  • The another-PC check only shows that the folder it is given is used.
  • The copy briefly swaps the label's text.
  • The demo helpers repeat ones in other scripts, including the 4500 ms timer hold.

@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Fixed the blocker from the merge-pass review in cac4e3510: a tool path with a . or .. segment now reads as written.

  • New toolPathLabel (src/lib/workspacePath.ts) wraps workspaceRelativePath for chat tool labels: any ./.. segment keeps the raw path, so /work/app/../etc/passwd in a pane on /work/app reads /work/app/../etc/passwd, not app/../etc/passwd. The file browser's formatter is unchanged.
  • Unit cases: /work/app/../etc/passwd, /work/app/src/../a.ts, /work/app/./src/a.ts stay as written; /work/app/src/..a.ts (a name, not a segment) still reads app/src/..a.ts. The .. cases fail on the previous commit.
  • Regression step: chat-tool-paths-demo-regression now carries a /work/app/../etc/passwd read card and asserts it reads as written (PASS, 48 captures).
  • DESIGN.md names the case. bun run check fast passes (6386 pass, 0 fail).

@devswha
devswha force-pushed the feat/chat-relative-tool-paths branch from cac4e35 to bbb2c0a Compare October 24, 2026 12:29
@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Rebased onto current origin/main (8fe7da9a1, no conflicts) and fixed Fast checks in bbb2c0afd: main's #1828 added scripts/plan-chip-demo-regression.ts to the browser lane, so with this PR's chat-tool-paths-demo-regression.ts the lane has 84 scripts and scripts/ci-browser.test.ts now expects 84 (it said 83). Test-only change. bun run check fast passes locally (6388 pass, 0 fail).

devswha added a commit that referenced this pull request Oct 24, 2026
… a pinned count (#1874)

## What
`scripts/ci-browser.test.ts` pinned the number of browser scripts
(`toHaveLength(83)`), a list of `toContain` lines and the last script.
So every PR that adds a browser script edited the same lines, and
parallel PRs conflicted on them just for that (#1831, #1837, #1849 and
#1852 needed rebases for it). This PR removes those pins and checks the
same things against the files on disk:

- The serial lane's summary must equal `scripts/demo-build.ts` followed
by the list parsed from `scripts/ci-browser.sh`
(`serialBrowserScripts()`), in order. This checks more than the old
count did.
- The lane must not repeat a script or name one that does not exist.
- Every `scripts/*-regression.ts` and `scripts/*-browser-qa.ts` must be
run by the lane in one of three ways: it has its own `run_script` line;
it is imported by a script the lane runs (transitively, e.g. through
`ui-regression.ts` or `ui-contexts-checks.ts`); or it is spawned by one
(`join(import.meta.dir, "x.ts")`). Spawns are followed only from files
that run as scripts, not from imported helpers, because those spawns sit
under `import.meta.main`. A script CI does not run has to be named in a
new `MANUAL_BROWSER_SCRIPTS` list. Today that list holds 13 scripts that
are run by hand (Android emulator, SSH fixture, native Windows, update
QA, ...).
- The manual list must only name scripts that exist and that CI does not
reach, so it cannot go stale.

A PR that adds a browser script now adds only its `run_script` line in
`scripts/ci-browser.sh` (or a line in the manual list), so two such PRs
no longer touch the same line. `docs/development.md` describes the
check.

Test-only change: CI behaviour is unchanged.

## Verification
- `bun test scripts/ci-browser.test.ts`: 7 pass.
- Mutation checks, each restored afterwards:
- Deleting the `run_script scripts/workspace-rows-regression.ts` line
fails "runs every browser script on disk ..." and lists that script as
unassigned.
- Adding `run_script scripts/does-not-exist-regression.ts` fails "runs
each script once, and only scripts that exist".
- Adding an untracked `scripts/brand-new-regression.ts` fails the
assignment check.
  - The restored tree passes.
- `bun run check fast`: green (typecheck, build, 6396 unit tests).
- Reviewed by a code-review agent. Its one HIGH finding (a spawn inside
an imported helper's `import.meta.main` block was being counted as run
by CI, hiding `keyboard-viewport-demo-regression.ts`) is fixed in this
commit.

---------

Co-authored-by: mp <mp@local>
@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Merge pass: one rebase needed. #1874 is merged on main. scripts/ci-browser.test.ts no longer pins the browser lane's count; it checks the scripts on disk. This branch still edits the old toHaveLength(…) line, so it now conflicts with main. Rebase onto main and drop this PR's change to scripts/ci-browser.test.ts, keeping its run_script line in scripts/ci-browser.sh. The new test checks that line automatically. This is the last rebase a lane count will cause. The merge pass checks that the rebase changed only that file, then re-queues the PR. A rebase needs no new CodeRabbit review.

@devswha
devswha force-pushed the feat/chat-relative-tool-paths branch from bbb2c0a to 521b76c Compare October 24, 2026 15:07
@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Rebased onto main after #1874 and pushed 521b76c (was bbb2c0a). I dropped this PR's change to scripts/ci-browser.test.ts and kept its run_script line in scripts/ci-browser.sh. Apart from that file, the branch's patch is identical to before (git patch-id matches). scripts/ci-browser.test.ts passes 7/7, and bun run check fast passed before the push. This is a rebase only, so it doesn't need another CodeRabbit review.

@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Merge pass: this PR now conflicts with main, in src/components/ChatView.tsx and scripts/ci-browser.sh, after this batch (#1831, #1890, #1895 and #1897 merged). Please rebase onto main and push. The merge pass then rechecks only the rebase delta and requeues it.

devswha and others added 9 commits October 25, 2026 05:24
A tool card's file labels (an edit's or a read's file, each file of a
patch, a multi-edit, a sent file) now read from the pane's folder the way
the file browser does: in a pane on /work/app, /work/app/src/a.ts reads
app/src/a.ts. PaneTerminal passes its already-known cwd to ChatView as an
optional presentation prop; a chat-local context hands it to ToolFile,
which reuses workspaceRelativePath. Only an absolute POSIX folder counts
(trailing slashes trimmed, never "/"); no folder, a Windows drive or UNC
folder, or a path outside the folder, in a sibling (/work/app-2) or
relative leaves the label as written. The button's title, the path the
viewer opens, the transcript and every copy keep the path as written.
No server, wire or transcript change.

Checked with new workspacePath unit cases and a new browser regression,
scripts/chat-tool-paths-demo-regression.ts (enrolled in the browser lane),
which drives the demo build: short labels, whole-path titles, the viewer's
exact request, raw MD/TXT copies, raw fallbacks for sibling, outside,
relative, Windows, UNC, Unicode and 300-character paths, pane switches,
and a bare ChatView with nothing to open files in (text, whole-path title,
no button) moved between PCs.
The phone viewer minimizes on Escape instead of closing, so the capture
run left the first file's viewer docked under the next one: close it with
its Close file button. A work block folds by itself when its turn settles,
which can land between reading its state and clicking it: click once to
make it the reader's choice, which the block keeps, and again if that
folded it. Ran the regression three times in a row, each passing.
The phone viewer slides in and out, so a capture taken right after it
opened or closed caught it mid-way. Wait for every running, finite
animation to finish before each screenshot; checks are unchanged.
At 1440 the pointer stayed where the last expanding click left it, so a
rest, focus or viewer capture showed a row's hover plate. Park it on
empty page before every capture except hover and pressed.
A copy that takes a whole tool-file label now copies the path as written
(data-raw-path, swapped into the label's text for the copy alone), so a
shortened label never changes what the clipboard gets; a part of a label
still copies that part. On a coarse pointer the file link grows to
--touch-target both ways.

The regression holds the demo's 4500 ms turn timer so the folder-less pane
cannot finish its turn mid-check, holds a file's content to show the
viewer's loading state at both widths before releasing it, copies the real
labels in both forms, and measures every phone file link at 44x44 or more
without overlap.
@devswha
devswha force-pushed the feat/chat-relative-tool-paths branch from 521b76c to d1f8614 Compare October 24, 2026 20:26
@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Rebased onto main after #1831, #1890, #1895 and #1897, and pushed d1f8614 (was 521b76c). The two conflicts were additive and both sides are kept. In ChatView, main's new localSend and navigation props stay and this PR's cwd = null is added after them. In scripts/ci-browser.sh, both run_script lines are kept (chat-local-send-follow and chat-tool-paths). Nothing else changed. bun run check fast passed before the push. This is a rebase only, so it doesn't need another CodeRabbit review.

@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Merge pass review-work report. Overall: PASSED.

Lane Verdict Confidence
Manual QA (rows 1-4, 5r; artifacts kept) PASS at cac4e35 -
Code review (omo-native-code-reviewer, programming and remove-ai-slops) PASS (WATCH) -
Gate round 1 (51c9d1e) REJECT: /work/app/../etc/passwd was labelled app/../etc/passwd HIGH
Gate round 2 (cac4e35, fresh reviewer) APPROVE HIGH (0.97)
Rebase onto main (bbb2c0a) The PR's own diff differs only in the browser lane's script count in scripts/ci-browser.test.ts (83 → 84) -

Manual QA:

  • The workspacePath, ci-browser and conventions tests pass, and so does the typecheck.
  • chat-tool-paths-demo-regression gets 16 PASS on an isolated herdr session.
  • git merge-tree is clean against main.

Code review: four mutants are each caught:

  • no sibling guard;
  • / as the root;
  • no raw-path copy;
  • no touch CSS.

Trailing slashes and / are handled. A symlinked folder, a case difference, //, and Windows/UNC paths fall back to the full path. Whole, partial and multi-card copies give the right text.

Round 1 finding, fixed in cac4e35: toolPathLabel keeps any path with a . or .. segment as written.

  • All 19 adversarial path probes pass, and a valid ... file name is still shortened.
  • Removing the guard fails both the unit test (workspacePath.test.ts:48) and the regression (chat-tool-paths-demo-regression.ts:380).
  • The file browser is unaffected.

MINOR follow-ups:

  • The another-PC check only shows that the given folder is used.
  • The copy briefly swaps the label text.
  • The demo helpers are repeated across scripts, including the 4500 ms timer hold.

All required checks are green and no review thread is open.

@devswha
devswha merged commit 1a456c1 into main Oct 24, 2026
11 checks passed
@devswha
devswha deleted the feat/chat-relative-tool-paths branch October 24, 2026 21:05
devswha added a commit that referenced this pull request Oct 28, 2026
…//server folder's paths as written (#1606) (#2195)

## What it does for the user

Closes the two gaps #1606 left open after #1837 (chat tool-card file
labels read from the pane's folder):

- **Select All, or any selection that reaches past the chat, copies the
whole paths.** Before, a copy that started outside the chat (Select All
from the page, a drag from a card out past the chat) was the browser's
own copy and took the short labels (`app/src/b.ts`). Now such a copy
carries the paths as written (`/work/app/src/b.ts`) whenever it takes a
shown, shortened label whole. A selection past the chat that takes no
shortened label stays the browser's own copy.
- **A UNC folder written with forward slashes reads paths as written.**
A pane on `//server/share/app` was treated as a POSIX folder, so its
paths were shortened. It now reads like `\\server\share\app` already
did: every path as written.

## How

- `toolPathRoot` refuses a `//` start (`src/lib/workspacePath.ts`).
- The chat's copy listener sits on the document: Chrome dispatches
`copy` where the selection starts, so a Select All never reached the
chat scroller. A copy from a field (the composer, a copy button's hidden
textarea, xterm's textarea) stays native.
- For a selection that reaches past the chat,
`chatSelectionClipboardPayload` grows each **visible** shortened label
the selection takes whole, and puts the browser's own
`selection.toString()` on the clipboard as **plain text only**. It
rebuilds no HTML from the page, so a composer's unsent draft, a hidden
chat under a terminal peek, or folded sidebar lists cannot leak into a
rich copy. A selection wholly inside the chat works as before (plain
text + rebuilt HTML). Each chat on the page has its own document
listener, so a chat declines a selection that has no part in it: with
two chats mounted (split halves, herdr splits, a chat kept under a
terminal peek), a copy wholly inside one is that chat's own, rich HTML
included, whichever listener runs first.

Follows T3 Code's workspace-relative paths, as #1837 did; the copy keeps
the raw path the way its file labels do.

## How it was verified

- `bun test src/lib/workspacePath.test.ts`: new `//server/share/app`
cases fail on main (`toolPathRoot` returned the string) and pass here.
- `scripts/chat-tool-paths-demo-regression.ts` (real Chromium, demo
build, in the browser CI lane), new checks for both forms (link and bare
label):
- Select All and a drag from the first card past the chat copy every raw
path, no `app/…` line, and no rebuilt HTML;
- a selection past the chat with no shortened label is not claimed
(native copy);
- a bare chat on `//server/share/app` and a `//server/share/app/fwd.ts`
card read as written;
- with a second chat mounted, a copy wholly inside either chat keeps its
raw paths and its rich HTML (fails on e3d095e: `the second chat: the
copy keeps the chat's rich HTML: ""`).
On main's code, the copy half fails (`the link, Select All: the copy
keeps /work/app/src/b.ts`, clipboard held `app/src/b.ts`) and the UNC
half fails (`machine unc`); both pass here.
- `scripts/chat-selection-copy-regression.ts` and
`scripts/replay-clipboard-demo-regression.ts` pass.
- `bun run check fast` passes.
- Reviews: omo-native-code-reviewer (APPROVE, no HIGH; its MEDIUM about
hidden content in the rebuilt HTML is the plain-text-only change above)
and Codex Sol 6.1 Fast xhigh (first round: one HIGH, a composer draft
entering the rebuilt HTML, and two MEDIUMs, a hidden chat triggering the
claim and the HTML dropping the labels; all fixed by the plain-text-only
claim and the visibility check; re-review PASS). The merge pass's review
of e3d095e found a MEDIUM (two mounted chats: the first-registered one
took the other's copy and dropped its HTML) and a LOW (a `display:none`
label counted as shown); both are fixed in the second commit.

## Left out

- `[contenteditable=true]` in the field check does not match
`contenteditable=""`/`plaintext-only`; nothing in `src` uses those
today.
- A rich (`text/html`) copy *inside* the chat still leaves a clickable
tool-file label out, as on main (the follow-up #1837 named); the plain
text carries the whole path.

Closes #1606.
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.

1 participant