Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

fix(good-session): preserve home path checks

yasakeic271d2a0d4be
diff --git a/apps/app/src/app/lib/good-session.ts b/apps/app/src/app/lib/good-session.ts
index 2f286409..ac725859 100644
--- a/apps/app/src/app/lib/good-session.ts
+++ b/apps/app/src/app/lib/good-session.ts
@@ -350,8 +350,13 @@ export function outsideProject(file: unknown, root: unknown): boolean {
const normSplit = homeSplit(norm);
if (baseSplit && normSplit && (baseSplit.home === "~" || normSplit.home === "~" || baseSplit.home === normSplit.home)) {
// Both sides sit under the same home folder (`~/...` matches its absolute form):
- // compare the part below the home folder.
- return normSplit.rest !== baseSplit.rest && !normSplit.rest.startsWith(`${baseSplit.rest}/`);
+ // expand the home prefix again so dot segments and scratch paths use the
+ // same rules as ordinary absolute paths.
+ const home = baseSplit.home === "~" ? normSplit.home : baseSplit.home;
+ norm = resolveDots(`${home}/${normSplit.rest}`);
+ const resolvedBase = resolveDots(`${home}/${baseSplit.rest}`);
+ if (isScratch(`${norm}/`)) return false;
+ return norm !== resolvedBase && !norm.startsWith(`${resolvedBase}/`);
}
if (/^(~|\$home|\$\{home\})(\/|$)/.test(norm)) {
// `~/x`: under the home folder the project folder sits in, when it sits in one.
@@ -484,6 +489,8 @@ export type GoodSessionInput = {
lastTurn?: "pass" | "cut";
/** Native Windows (not WSL). */
nativeWindows?: boolean;
+ /** Remote workspaces do not necessarily have a local project folder. */
+ isRemoteWorkspace?: boolean;
/** The server checked this session after upload and it is a Good session ★. */
serverGood?: boolean;
};
@@ -494,7 +501,7 @@ function plural(count: number, word: string): string {
/** The checklist for a session, from its tool calls. */
export function goodSessionChecklist({
- calls = [], workspaceRoot = "", turnRunning = false, lastTurn = "cut", nativeWindows = false, serverGood = false,
+ calls = [], workspaceRoot = "", turnRunning = false, lastTurn = "cut", nativeWindows = false, isRemoteWorkspace = false, serverGood = false,
}: GoodSessionInput = {}): GoodSessionChecklist {
const codeFiles = new Map<string, number>();
let testRuns = 0;
@@ -552,7 +559,7 @@ export function goodSessionChecklist({
? ` (${fileCount} of ${FLOOR_FILES} files)`
: lines < FLOOR_LINES ? ` (${lines} of ${FLOOR_LINES} lines)` : "";
const finished = turnRunning ? "pending" : lastTurn === "pass" ? "pass" : "cut";
- const noRoot = unknownRoot && calls.some((call) => !call.notRun);
+ const noRoot = !isRemoteWorkspace && unknownRoot && calls.some((call) => !call.notRun);
const checks: GoodSessionCheck[] = [
{
id: "code",
diff --git a/apps/app/src/react-app/domains/quality/good-session.tsx b/apps/app/src/react-app/domains/quality/good-session.tsx
index 3fc37c7c..d4114668 100644
--- a/apps/app/src/react-app/domains/quality/good-session.tsx
+++ b/apps/app/src/react-app/domains/quality/good-session.tsx
@@ -108,6 +108,7 @@ export type GoodSessionChecklistBarProps = {
sessionId: string;
messages: readonly UIMessage[];
workspaceRoot: string;
+ isRemoteWorkspace: boolean;
turnRunning: boolean;
};
@@ -156,9 +157,10 @@ export function GoodSessionChecklistBar(props: GoodSessionChecklistBarProps) {
const local = useMemo(() => goodSessionChecklist({
...facts,
workspaceRoot: props.workspaceRoot,
+ isRemoteWorkspace: props.isRemoteWorkspace,
turnRunning: props.turnRunning,
nativeWindows,
- }), [facts, nativeWindows, props.turnRunning, props.workspaceRoot]);
+ }), [facts, nativeWindows, props.isRemoteWorkspace, props.turnRunning, props.workspaceRoot]);
const serverGood = useServerGood(props.sessionId, local.onTrack);
const checklist = useMemo(
() => (serverGood && local.onTrack ? { ...local, verdict: "good" as const, text: checklistText(local.checks, "good") } : local),
diff --git a/apps/app/src/react-app/domains/session/surface/session-surface.tsx b/apps/app/src/react-app/domains/session/surface/session-surface.tsx
index b9767329..a90ac356 100644
--- a/apps/app/src/react-app/domains/session/surface/session-surface.tsx
+++ b/apps/app/src/react-app/domains/session/surface/session-surface.tsx
@@ -3299,6 +3299,7 @@ export function SessionSurface(props: SessionSurfaceProps) {
sessionId={props.sessionId}
messages={renderedMessages}
workspaceRoot={props.workspaceRoot}
+ isRemoteWorkspace={props.isRemoteWorkspace}
turnRunning={chatStreaming || (effectiveActivityStatus !== "idle" && effectiveActivityStatus !== "error")}
/>
<ReactSessionComposer
diff --git a/apps/app/tests/good-session.test.tsx b/apps/app/tests/good-session.test.tsx
index 2d460e58..3c385d48 100644
--- a/apps/app/tests/good-session.test.tsx
+++ b/apps/app/tests/good-session.test.tsx
@@ -52,10 +52,11 @@ function transcript(...assistantParts: unknown[][]): UIMessage[] {
return messages;
}
-function states(messages: UIMessage[], options: { turnRunning?: boolean; nativeWindows?: boolean; root?: string; serverGood?: boolean } = {}) {
+function states(messages: UIMessage[], options: { turnRunning?: boolean; nativeWindows?: boolean; root?: string; serverGood?: boolean; remote?: boolean } = {}) {
const result = goodSessionChecklist({
...messageFacts(messages),
workspaceRoot: options.root ?? ROOT,
+ isRemoteWorkspace: options.remote ?? false,
turnRunning: options.turnRunning ?? false,
nativeWindows: options.nativeWindows ?? false,
serverGood: options.serverGood ?? false,
@@ -162,6 +163,10 @@ describe("folders", () => {
expect(outsideProject("~/projects/todo-api/src/a.ts", ROOT)).toBe(false);
expect(outsideProject("$HOME/.zshrc", ROOT)).toBe(true);
expect(outsideProject(`${ROOT}/../secret`, ROOT)).toBe(true);
+ expect(outsideProject("/home/yasakei/proj/a.ts", "~/proj")).toBe(false);
+ expect(outsideProject("~/proj/../other/a.ts", "/home/yasakei/proj")).toBe(true);
+ expect(outsideProject("/home/yasakei/proj/../other/a.ts", "/home/yasakei/proj")).toBe(true);
+ expect(outsideProject("c:/users/yasakei/appdata/local/temp/x.txt", "c:/users/yasakei/proj")).toBe(false);
});
});
@@ -252,6 +257,10 @@ describe("the live checklist", () => {
expect(states(transcript([tool("read", { filePath: "/etc/hosts" }), tool("write", { filePath: "/tmp/x.py" })])).by.project).toBe("pass");
});
+ test("a remote workspace without a local root is not treated as missing a project", () => {
+ expect(states(transcript([tool("write", { filePath: "src/a.ts", content: BODY })]), { root: "", remote: true }).by.project).toBe("pass");
+ });
+
test("localhost: fine once the session started the server, not before", () => {
const started = states(transcript([tool("bash", { command: "npm run dev &" }), tool("bash", { command: "curl localhost:3000" }), tool("webfetch", { url: "http://localhost:3000" })]));
expect(started.by.project).toBe("pass");