From 6bc342cfc5e317cdebf505f4ff87bd37b01c505f Mon Sep 17 00:00:00 2001 From: Soroush Baraouf Date: Thu, 19 Nov 2026 03:35:35 -0500 Subject: [PATCH 1/2] test(web): cover home paths in work log path display A path like ~/.claude/CLAUDE.md names a file in the user's home folder, but the work log treats it as workspace-relative: the row label shows t3code/~/.claude/CLAUDE.md and the expanded Read output shows /workspace/t3code/~/.claude/CLAUDE.md. These tests fail on main. Co-Authored-By: Claude Opus 5.5 --- .../chat/MessagesTimeline.logic.test.ts | 12 ++ apps/web/src/filePathDisplay.test.ts | 9 ++ ...home-path-tool-rows-show-as-written.e2e.ts | 115 ++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 scripts/scenarios/home-path-tool-rows-show-as-written.e2e.ts diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts index f834c7cc355b9..f9ade6d60dc9c 100644 --- a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts +++ b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts @@ -36,6 +36,7 @@ import { resolveAssistantMessageCopyState, type MessagesTimelineRow, workEntryDisplayLabel, + workEntryReadOutput, } from "./MessagesTimeline.logic"; import { workEntryIconName } from "./TimelineWorkEntryRow.logic"; @@ -5158,3 +5159,14 @@ describe("isTimelineMinimapTurnVisible", () => { expect(isTimelineMinimapTurnVisible(10, 500, null, null)).toBe(false); }); }); + +describe("workEntryReadOutput", () => { + it("joins relative paths to the workspace root but keeps home paths as written", () => { + expect( + workEntryReadOutput( + { changedFiles: ["src/app.ts", "~/.claude/CLAUDE.md", "~\\.gitconfig"] }, + "/workspace/t3code", + ), + ).toBe("/workspace/t3code/src/app.ts\n~/.claude/CLAUDE.md\n~/.gitconfig"); + }); +}); diff --git a/apps/web/src/filePathDisplay.test.ts b/apps/web/src/filePathDisplay.test.ts index 08295e540eb95..79310cf42521b 100644 --- a/apps/web/src/filePathDisplay.test.ts +++ b/apps/web/src/filePathDisplay.test.ts @@ -13,4 +13,13 @@ describe("formatWorkspaceRelativePath", () => { ); expect(formatWorkspaceRelativePath("src/app.ts", workspaceRoot)).toBe("t3code/src/app.ts"); }); + + it("keeps home paths as written instead of labelling them as workspace paths", () => { + expect(formatWorkspaceRelativePath("~/.claude/CLAUDE.md", "/workspace/t3code")).toBe( + "~/.claude/CLAUDE.md", + ); + expect(formatWorkspaceRelativePath("~\\.claude\\CLAUDE.md:3", "C:\\dev\\t3code")).toBe( + "~/.claude/CLAUDE.md:3", + ); + }); }); diff --git a/scripts/scenarios/home-path-tool-rows-show-as-written.e2e.ts b/scripts/scenarios/home-path-tool-rows-show-as-written.e2e.ts new file mode 100644 index 0000000000000..3e5191137dac3 --- /dev/null +++ b/scripts/scenarios/home-path-tool-rows-show-as-written.e2e.ts @@ -0,0 +1,115 @@ +// @effect-diagnostics nodeBuiltinImport:off -- The scenario stages a local ACP executable. +import * as NodeFSP from "node:fs/promises"; +import * as NodePath from "node:path"; + +import { expect } from "e2e"; + +import { T3_HOME } from "../e2e.config.ts"; +import { makeState, runPromise, test, WEB } from "./t3.ts"; + +const HOME_PATH = "~/.claude/CLAUDE.md"; +const REPLY = "Updated your global instructions."; +const ACP = ` +import { createInterface } from "node:readline"; + +const sessionId = "home-path-scenario"; +const path = ${JSON.stringify(HOME_PATH)}; +const send = (message) => process.stdout.write(JSON.stringify({ jsonrpc: "2.0", ...message }) + "\\n"); +const update = (value) => send({ method: "session/update", params: { sessionId, update: value } }); +for await (const line of createInterface({ input: process.stdin })) { + const { id, method } = JSON.parse(line); + if (id === undefined) continue; + if (method === "initialize") { + send({ id, result: { protocolVersion: 1, agentCapabilities: {}, authMethods: [] } }); + } else if (method === "session/new") { + send({ id, result: { sessionId } }); + } else if (method === "session/prompt") { + update({ sessionUpdate: "tool_call", toolCallId: "read", kind: "read", title: "Read", status: "pending", rawInput: { path } }); + update({ + sessionUpdate: "tool_call_update", + toolCallId: "read", + status: "completed", + content: [{ type: "content", content: { type: "text", text: "# Global instructions" } }], + }); + update({ + sessionUpdate: "tool_call", + toolCallId: "edit", + kind: "edit", + title: "Edit global instructions", + status: "completed", + content: [{ + type: "diff", + path, + oldText: "# Global instructions\\n", + newText: "# Global instructions\\nPrefer small diffs.\\n", + changes: [{ operation: "update", path }], + }], + }); + update({ sessionUpdate: "agent_message_chunk", content: { type: "text", text: ${JSON.stringify(REPLY)} } }); + send({ id, result: { stopReason: "end_turn" } }); + } else { + send({ id, error: { code: -32601, message: "Method not found" } }); + } +} +`; + +test( + "Files an agent read and edited in the home folder show their ~/ paths, not paths under the project", + WEB, + async ({ t3, app, screen }) => { + const project = await t3.project("demo"); + const script = NodePath.join(project, "home-path-acp.mjs"); + const settingsPath = NodePath.join(T3_HOME, "userdata/settings.json"); + const originalSettings = await NodeFSP.readFile(settingsPath, "utf8"); + const settings = JSON.parse(originalSettings); + await NodeFSP.writeFile(script, ACP); + settings.providerInstances["home-path-agent"] = { + driver: "acpRegistry", + displayName: "Home path agent", + enabled: true, + config: { source: "local", commandPath: process.execPath, commandArgs: [script] }, + }; + try { + await NodeFSP.writeFile(settingsPath, JSON.stringify(settings)); + const { cli } = makeState(T3_HOME); + // The watcher reloads settings asynchronously. Retry only before a thread was created. + let threadId: string | undefined; + for (let attempt = 0; attempt < 8 && threadId === undefined; attempt++) { + const started = await runPromise( + cli( + [ + "thread", + "start", + project, + "Tidy up my global instructions", + "--title", + "Home path tools", + "--provider", + "home-path-agent", + "--model", + "default", + "--wait", + "--json", + ], + [0, 1], + ), + ); + if (!started.stdout.includes("threadId")) continue; + threadId = (JSON.parse(started.stdout) as { threadId: string }).threadId; + } + if (threadId === undefined) throw new Error("Could not start the home path turn."); + + await t3.open({ threadId }); + await screen.getByText(REPLY, { exact: true }).waitFor({ timeout: 60_000 }); + await screen.getByRole("button", "Worked for", { exact: false }).tap(); + await screen.getByRole("button", "Read 1 file and changed 1 file").tap(); + await screen.getByRole("button", /^Read .*CLAUDE\.md/).tap(); + await screen.getByText('"# Global instructions"', { exact: true }).waitFor(); + await app.screenshot("read-and-edit-rows"); + await expect(screen.getByText("/~/", { exact: false })).toHaveCount(0); + await expect(screen.getByText(HOME_PATH, { exact: true })).toHaveCount(2); + } finally { + await NodeFSP.writeFile(settingsPath, originalSettings); + } + }, +); From b7761361b84d2603f054c634e57459f3b28e33ff Mon Sep 17 00:00:00 2001 From: Soroush Baraouf Date: Thu, 19 Nov 2026 03:40:11 -0500 Subject: [PATCH 2/2] fix(web): home paths like ~/.claude/CLAUDE.md no longer show under the workspace folder formatWorkspaceRelativePath and workEntryReadOutput treated any path that does not start with / or a drive letter as workspace-relative, so ~/ and ~\ paths got the workspace name or root put in front of them. Both now use isHostPath, the shared helper that already counts home paths as host paths, and leave those paths as written. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/chat/MessagesTimeline.logic.ts | 4 ++-- apps/web/src/filePathDisplay.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.ts b/apps/web/src/components/chat/MessagesTimeline.logic.ts index 8d282aff42689..9cb887d95443f 100644 --- a/apps/web/src/components/chat/MessagesTimeline.logic.ts +++ b/apps/web/src/components/chat/MessagesTimeline.logic.ts @@ -79,7 +79,7 @@ import { formatReadToolLabel, formatSearchToolLabel, } from "@t3tools/shared/toolActivityCopy"; -import { isWindowsAbsolutePath } from "@t3tools/shared/path"; +import { isHostPath } from "@t3tools/shared/path"; export function timelineEntryRunId(entry: TimelineEntry): RunId | null { if (entry.kind === "message") { @@ -231,7 +231,7 @@ export function workEntryReadOutput( workEntryReadRawPaths(entry as WorkLogEntry) .map((path) => { const trimmed = path.trim().replaceAll("\\", "/"); - if (!workspaceRoot || trimmed.startsWith("/") || isWindowsAbsolutePath(trimmed)) { + if (!workspaceRoot || isHostPath(trimmed)) { return trimmed; } const root = workspaceRoot.replaceAll("\\", "/").replace(/\/+$/, ""); diff --git a/apps/web/src/filePathDisplay.ts b/apps/web/src/filePathDisplay.ts index b2b31365bfa30..ebe88625eb68f 100644 --- a/apps/web/src/filePathDisplay.ts +++ b/apps/web/src/filePathDisplay.ts @@ -2,6 +2,7 @@ import { pipe } from "effect/Function"; import { fileBasename, stripSlashPrefixedWindowsDrive, + isHostPath, isWindowsAbsolutePath, } from "@t3tools/shared/path"; import { formatFilePathPosition, splitFilePathPosition } from "@t3tools/shared/fileLinks"; @@ -46,7 +47,7 @@ export function formatWorkspaceRelativePath( } else if (pathForCompare.startsWith(workspaceWithSeparator)) { const relativeSuffix = normalizedPath.slice(normalizedWorkspaceRoot.length + 1); displayPath = `${workspaceLabel}/${relativeSuffix}`; - } else if (!normalizedPath.startsWith("/") && !isWindowsAbsolutePath(normalizedPath)) { + } else if (!isHostPath(normalizedPath)) { const relativePath = stripRelativePrefixes(normalizedPath); displayPath = pathForCompare.startsWith(workspaceLabelWithSeparator) ? normalizedPath