8000 fix(diff): show an agent's edit on an ssh workspace instead of "Invalid path" by stlindenau · Pull Request #476 · amirlehmam/wmux · GitHub
[go: up one dir, main page]

Skip to content

fix(diff): show an agent's edit on an ssh workspace instead of "Invalid path" - #476

Merged
amirlehmam merged 2 commits into
amirlehmam:masterfrom
stlindenau:fix-diff-hook-absolute-path
Nov 25, 2026
Merged

amirlehmam merged 2 commits into
amirlehmam:masterfrom
stlindenau:fix-diff-hook-absolute-path

Conversation

@stlindenau
@stlindenau stlindenau commented Nov 24, 2026 •
Copy link
Copy Markdown
Contributor

Fixes Invalid path in the Diff tab of an ssh workspace after an agent edits a file.

Cause

The agent's edit hook reports the file it wrote as an absolute path in the agent's own file system (tool_input.file_path). The Diff tab selected that path and asked for it. An ssh workspace only takes a path relative to the checkout (remoteFileDiff → canonicalRemoteRelPath), so every edit ended in Invalid path.

The two roots need not even be the same directory: a devbox session edits /workspaces/<repo>/... inside its container, while the ssh target's path is the checkout on the devbox host.

Fix

  • diff-hook-file.ts (pickHookFile): the Diff tab now selects the changed file whose relative path the hook path ends with (at a path segment, \ read as a separator, longest match wins, folder entries never match), taken from the list git printed. It never asks for the hook's own path, so the checkout jail is unchanged, and a file the list lacks leaves the selection alone.
  • ssh-diff.ts (relativeToCheckout): an absolute path under target.path is also taken as the relative one, so the remote handler accepts it directly. The result still goes through canonicalRemoteRelPath, so <root>/../x, <root>-evil/x and paths outside the checkout stay refused. This is a second line of defence: the Diff tab no longer sends such a path.

Verification

  • New unit tests for pickHookFile and relativeToCheckout, and a component test that mounts DiffPane, fires an edit event with a container path and checks the file asked for. The component test and the ssh-diff tests fail without their change.
  • tsc and eslint clean; the related Diff and ssh suites pass; merges cleanly onto master at d1eda84.

Confirmed

Checked in a live ssh workspace (devbox session) on Windows from this branch: after the agent edits a file, the Diff tab shows that file's diff and no longer shows Invalid path.

🤖 Generated with Claude Code

stlindenau and others added 2 commits November 24, 2026 08:22
…ead of Invalid path

An agent's edit hook reports the file as an absolute path on its host, and the
Diff tab asks for exactly that on the next refresh. On an ssh workspace the
remote diff only took a relative path, so every edit ended in 'Invalid path'.
A path below the target's checkout is now taken as the relative one; anything
outside it, or not canonical after the prefix is cut, is still refused.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…s raw path

The hook reports the file by an absolute path in the agent's own file system.
For a devbox session that is the container's mount (/workspaces/<repo>), not
the checkout path of the ssh target on the host, so stripping the target path
(the previous commit) cannot always work. The Diff tab now picks the changed
file the hook path ends with from the list git printed, and leaves the
selection alone when none matches.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@stlindenau
stlindenau marked this pull request as ready for review November 24, 2026 09:02
@amirlehmam
amirlehmam merged commit 71de785 into amirlehmam:master Nov 25, 2026
@stlindenau
stlindenau deleted the fix-diff-hook-absolute-path branch November 26, 2026 21:37
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.

2 participants

0