From 8babb9b8b6205770d690f68faacf744befa1167c Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Tue, 4 Aug 2026 14:53:57 -0700 Subject: [PATCH] fix: normalize worktree filter separators; skip pre-typing on terminal reattach Windows resolves paths with backslashes, so the configured-worktreesDir prefix match failed there; both sides now normalize to forward slashes. Reopening the onboarding install terminal reattaches to the still-live PTY, so the pre-typed command is only written into a session with empty history. Co-Authored-By: Claude Fable 5 --- apps/server/src/project/AgentSessionScanner.ts | 11 +++++------ apps/web/src/components/onboarding/WelcomeWizard.tsx | 5 +++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/server/src/project/AgentSessionScanner.ts b/apps/server/src/project/AgentSessionScanner.ts index dd78482f8a..7badf75194 100644 --- a/apps/server/src/project/AgentSessionScanner.ts +++ b/apps/server/src/project/AgentSessionScanner.ts @@ -86,14 +86,13 @@ const decoder = new TextDecoder(); * transcripts look exactly like user sessions, but re-importing the app's own * sandboxes as projects is never right. Matches this server's configured * worktrees directory plus the conventional `.t3/worktrees` layout, which - * also catches sandboxes from other T3 homes on the same machine. + * also catches sandboxes from other T3 homes on the same machine. Separators + * are normalized so the prefix match holds on Windows too. */ function isT3ManagedWorktree(resolvedPath: string, worktreesDir: string): boolean { - const withSeparator = `${resolvedPath}/`; - return ( - withSeparator.startsWith(`${worktreesDir}/`) || - /[/\\]\.t3[/\\]worktrees[/\\]/.test(withSeparator) - ); + const normalized = `${resolvedPath.replaceAll("\\", "/")}/`; + const worktreesPrefix = `${worktreesDir.replaceAll("\\", "/")}/`; + return normalized.startsWith(worktreesPrefix) || normalized.includes("/.t3/worktrees/"); } /** Extract `cwd` from a session-meta record, tolerating the shapes each CLI writes. */ diff --git a/apps/web/src/components/onboarding/WelcomeWizard.tsx b/apps/web/src/components/onboarding/WelcomeWizard.tsx index 3e584606bd..3e2852ccd4 100644 --- a/apps/web/src/components/onboarding/WelcomeWizard.tsx +++ b/apps/web/src/components/onboarding/WelcomeWizard.tsx @@ -673,6 +673,11 @@ function AgentInstallTerminal({ if (opened._tag !== "Success") return; preparedRef.current = true; if (command.length === 0) return; + // Closing and reopening the drawer reattaches to the still-live PTY + // (Done never kills the session). A session with history already got + // its command — pre-typing again would duplicate it, or feed stdin to + // whatever is running. + if (opened.value.history.length > 0) return; // Pre-type without the trailing carriage return; the user submits. await writeTerminal({ environmentId,