feat(web): first-run welcome wizard with agent setup and project import #5362
Mergedt3dotgg(GitHub profile, opens in a new tab)merged 43 commits into
main fromrefs/pull/5362/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- packages/contracts/src/agentSessions.ts lines 36 to 46OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +26,21 @@26+ alreadyImported: Schema.Boolean,27+});28+export type AgentSessionProjectCandidate = typeof AgentSessionProjectCandidate.Type;29+30+export const AgentSessionScanResult = Schema.Struct({31+ candidates: Schema.Array(AgentSessionProjectCandidate),32+ scannedAt: IsoDateTime,33+});34+export type AgentSessionScanResult = typeof AgentSessionScanResult.Type;35+36+export const AgentSessionScanFailure = Schema.Literals(["scan_failed"]);37+export type AgentSessionScanFailure = typeof AgentSessionScanFailure.Type;38+39+export class AgentSessionScanError extends Schema.TaggedErrorClass<AgentSessionScanError>()(40+ "AgentSessionScanError",41+ {42+ failure: AgentSessionScanFailure,43+ message: TrimmedNonEmptyString,44+ cause: Schema.optional(Schema.Defect()),45+ },46+) {}apps/server/src/ws.ts lines 1712 to 1713OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1699,3 +1702,12 @@16991702 ),17001703 { "rpc.aggregate": "workspace" },17011704 ),1705+ [WS_METHODS.agentSessionsScan]: () =>1706+ observeRpcEffect(1707+ WS_METHODS.agentSessionsScan,1708+ agentSessionScanner.scan.pipe(1709+ Effect.mapError(1710+ (cause) =>1711+ new AgentSessionScanError({1712+ failure: "scan_failed",1713+ message: cause.message,apps/server/src/project/AgentSessionScanner.ts lines 117 to 117OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +97,21 @@97+ } catch {98+ return null;99+ }100+ if (typeof parsed !== "object" || parsed === null) return null;101+102+ const record = parsed as Record<string, unknown>;103+ if (typeof record.cwd === "string" && record.cwd.trim().length > 0) {104+ return record.cwd;105+ }106+ // Codex nests session metadata under `payload`.107+ const payload = record.payload;108+ if (typeof payload === "object" && payload !== null) {109+ const nested = (payload as Record<string, unknown>).cwd;110+ if (typeof nested === "string" && nested.trim().length > 0) {111+ return nested;112+ }113+ }114+ return null;115+}116+117+const make = Effect.gen(function* () {
- apps/server/src/project/AgentSessionScanner.ts lines 374 to 382OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +362,21 @@362+363+ const candidates: Array<AgentSessionProjectCandidate> = [];364+ for (const entry of merged.values()) {365+ const existingProject = yield* projectionSnapshotQuery366+ .getActiveProjectByWorkspaceRoot(entry.path)367+ .pipe(368+ Effect.mapError(369+ (cause) => new AgentSessionScanFailedError({ operation: "read-projects", cause }),370+ ),371+ );372+ candidates.push({373+ path: entry.path,374+ title: path.basename(entry.path) || entry.path,375+ sources: entry.sources,376+ threadCount: entry.threadCount,377+ lastActiveAt:378+ entry.lastActiveAtMs === null379+ ? null380+ : DateTime.formatIso(DateTime.makeUnsafe(entry.lastActiveAtMs)),381+ alreadyImported: Option.isSome(existingProject),382+ });apps/server/src/project/AgentSessionScanner.ts line 205OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +185,21 @@185+ }186+ const fromEnvironment = process.env.CLAUDE_CONFIG_DIR?.trim() ?? "";187+ if (fromEnvironment.length > 0) {188+ return path.resolve(fromEnvironment);189+ }190+ return path.join(NodeOS.homedir(), ".claude");191+ };192+193+ /**194+ * Claude keeps one directory per project under `projects/`, named after a195+ * lossy slug of the path. The slug can't be decoded (both `/` and `.` become196+ * `-`), so the real path comes from the `cwd` recorded in the newest197+ * transcript inside it.198+ */199+ const scanClaude = Effect.fn("AgentSessionScanner.scanClaude")(function* (homePath: string) {200+ const projectsDir = path.join(resolveClaudeConfigDir(homePath), "projects");201+ const projectDirectories = yield* listDirectory(projectsDir);202+ const candidates: Array<RawCandidate> = [];203+ let budget = MAX_TRANSCRIPTS_PER_SOURCE;204+205+ for (const projectDirectory of projectDirectories) {apps/web/src/components/onboarding/WelcomeWizard.tsx lines 762 to 767OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +747,21 @@747+ const result = await createProject({748+ environmentId,749+ input: {750+ projectId: newProjectId(),751+ title: candidate.title,752+ workspaceRoot: candidate.path,753+ createWorkspaceRootIfMissing: false,754+ defaultModelSelection,755+ },756+ });757+ if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {758+ failures += 1;759+ }760+ }761+ setIsImporting(false);762+ if (failures > 0 && failures === selection.length) {763+ setImportError("Import failed. You can add projects manually from the command palette.");764+ return;765+ }766+ onDone();767+ };apps/web/src/components/onboarding/FirstRunGate.tsx line 61OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +41,21 @@41+ const [decision, setDecision] = useState<FirstRunDecision>(() =>42+ hydrated && onboardingCompletedAt !== null ? "app" : "pending",43+ );44+45+ // A workspace still counts as fresh when its only content is the server's46+ // own cwd auto-bootstrap: web mode creates a project + thread from cwd at47+ // startup (`autoBootstrapProjectFromCwd` defaults on there), so "no48+ // projects at all" would mean `npx t3` users never see the wizard. Any49+ // other project, or more than one thread, is real user state.50+ const serverCwd = serverConfig?.cwd ?? null;51+ const workspaceFresh =52+ projects.every((project) => serverCwd !== null && project.workspaceRoot === serverCwd) &&53+ threads.length <= 1;54+55+ useEffect(() => {56+ if (decision !== "pending" || !hydrated) return;57+ if (onboardingCompletedAt !== null) {58+ setDecision("app");59+ return;60+ }61+ if (!bootstrapped) return;apps/web/src/components/onboarding/WelcomeWizard.tsx lines 254 to 255OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +235,21 @@235+ * Continue once their machine appears; existing machines show a confirmation236+ * list with the command folded away. There is deliberately no "primary237+ * machine" selection.238+ */239+function ConnectMachinesStep({240+ onBack,241+ onContinue,242+}: {243+ readonly onBack: () => void;244+ readonly onContinue: () => void;245+}) {246+ // Mirrors ManagedRelayAuthProvider: a pending Clerk session must not read247+ // as signed-out mid-transition.248+ const { isLoaded, isSignedIn } = useAuth({ treatPendingAsSignedOut: false });249+ const { openAuthPrompt } = useT3ConnectAuthPrompt();250+ const { environments } = useEnvironments();251+ const primaryEnvironment = usePrimaryEnvironment();252+ const savedEnvironments = environments.filter(253+ (environment) => environment.entry.target._tag !== "PrimaryConnectionTarget",254+ );255+ const hasRemoteMachines = savedEnvironments.length > 0;apps/server/src/project/AgentSessionScanner.ts line 88OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +68,21 @@68+ }69+>()("t3/project/AgentSessionScanner") {}70+71+type AgentSessionSource = AgentSessionProjectCandidate["sources"][number];72+73+/** A single directory's worth of evidence from one source. */74+interface RawCandidate {75+ readonly cwd: string;76+ readonly source: AgentSessionSource;77+ readonly threadCount: number;78+ readonly lastActiveAtMs: number | null;79+}80+81+const decoder = new TextDecoder();82+83+/**84+ * T3 Code runs its own agent sessions inside disposable worktrees under85+ * `<t3-home>/worktrees/`. Their transcripts look exactly like user sessions,86+ * but re-importing the app's own sandboxes as projects is never right.87+ */88+function isT3ManagedWorktree(resolvedPath: string): boolean {apps/web/src/components/onboarding/WelcomeWizard.tsx lines 647 to 662OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +642,21 @@642+643+ const command = installed644+ ? (AGENT_LOGIN_COMMANDS[driver] ?? "")645+ : (AGENT_INSTALL_COMMANDS[driver] ?? "");646+647+ useEffect(() => {648+ if (preparedRef.current || cwd === null) return;649+ preparedRef.current = true;650+ void (async () => {651+ const opened = await openTerminal({652+ environmentId,653+ input: { threadId: AGENT_ONBOARDING_THREAD_ID, terminalId, cwd },654+ });655+ if (opened._tag !== "Success" || command.length === 0) return;656+ // Pre-type without the trailing carriage return; the user submits.657+ await writeTerminal({658+ environmentId,659+ input: { threadId: AGENT_ONBOARDING_THREAD_ID, terminalId, data: command },660+ });661+ })();662+ }, [command, cwd, environmentId, openTerminal, terminalId, writeTerminal]);docs/user/welcome-wizard.md lines 4 to 4OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,4 @@1+# Welcome Wizard2+3+On a fresh install, T3 Code opens a short setup flow before the main app.4+Existing installs never see it.docs/user/welcome-wizard.md line 19OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,19 @@1+# Welcome Wizard2+3+On a fresh install, T3 Code opens a short setup flow before the main app.4+Existing installs never see it.5+6+## Choose how to connect7+8+**Local Only** — agents run on this machine. No account needed. Shown on the9+ desktop app and locally served web app.10+**T3 Connect** — sign in and reach any of your machines from anywhere.11+ Machines signed into your account connect automatically. If none are12+ connected yet, the wizard shows the command to run on the machine with your13+ code (`npx t3 connect`) and advances when it appears.14+**Direct** — connect to a server by URL. Works over LAN and Tailscale. Run15+ `npx t3 pair` on the server and paste the pairing URL it prints.16+17+## Set up your agents18+19+The wizard checks the connected machine for Claude Code and Codex and showsapps/web/src/components/onboarding/WelcomeWizard.tsx lines 577 to 578OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +558,21 @@558+ </StepShell>559+ );560+}561+562+function AgentCard({563+ driver,564+ provider,565+ terminalOpen,566+ onOpenTerminal,567+}: {568+ readonly driver: string;569+ readonly provider: ServerProvider | undefined;570+ readonly terminalOpen: boolean;571+ readonly onOpenTerminal: () => void;572+}) {573+ const meta = getDriverOption(driver as never);574+ const Icon = meta?.icon;575+ const displayName = driver === "claudeAgent" ? "Claude Code" : (meta?.label ?? driver);576+ const summary = getProviderSummary(provider);577+ const ready = provider?.installed === true && provider.auth.status === "authenticated";578+ const needsLogin = provider?.installed === true && provider.auth.status !== "authenticated";
- apps/web/src/components/onboarding/FirstRunGate.tsx line 63OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +43,21 @@43+ );44+45+ // A workspace still counts as fresh when its only content is the server's46+ // own cwd auto-bootstrap: web mode creates a project + thread from cwd at47+ // startup (`autoBootstrapProjectFromCwd` defaults on there), so "no48+ // projects at all" would mean `npx t3` users never see the wizard. Any49+ // other project, or more than one thread, is real user state.50+ const serverCwd = serverConfig?.cwd ?? null;51+ const workspaceFresh =52+ projects.every((project) => serverCwd !== null && project.workspaceRoot === serverCwd) &&53+ threads.length <= 1;54+55+ useEffect(() => {56+ if (decision !== "pending" || !hydrated) return;57+ if (onboardingCompletedAt !== null) {58+ setDecision("app");59+ return;60+ }61+ if (!bootstrapped) return;62+ setDecision(workspaceFresh ? "wizard" : "app");63+ }, [bootstrapped, decision, hydrated, onboardingCompletedAt, workspaceFresh]);apps/web/src/components/onboarding/WelcomeWizard.tsx line 534Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +304,21 @@304+ </>305+ ) : (306+ <>307+ <CommandBlock command={CONNECT_LOGIN_COMMAND} className="mt-6" prominent />308+ <div className="mt-5 overflow-hidden rounded-lg border border-dashed border-border/60">309+ <CloudEnvironmentConnectRows310+ primaryEnvironmentId={primaryEnvironment?.environmentId ?? null}311+ savedEnvironments={savedEnvironments}312+ showSavedEnvironments313+ empty={314+ <p className="px-4 py-4 text-center text-xs text-muted-foreground">315+ Waiting for a machine. It appears here the moment it signs in.316+ </p>317+ }318+ />319+ </div>320+ <div className="mt-6 flex items-center justify-end gap-3">321+ <span className="text-xs text-muted-foreground">Waiting for a machine…</span>322+ <Button disabled>Continue</Button>323+ </div>324+ </>apps/server/src/project/AgentSessionScanner.ts line 901Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +218,21 @@218+ const stats = yield* statOption(filePath);219+ if (Option.isNone(stats) || Option.isNone(stats.value.mtime)) continue;220+ withMtimes.push({ filePath, mtimeMs: stats.value.mtime.value.getTime() });221+ }222+ withMtimes.sort((left, right) => right.mtimeMs - left.mtimeMs);223+224+ // The newest transcript is the most likely to still name a live path.225+ let cwd: string | null = null;226+ for (const entry of withMtimes) {227+ cwd = yield* readCwd(entry.filePath);228+ if (cwd !== null) break;229+ }230+ if (cwd === null) continue;231+232+ candidates.push({233+ cwd,234+ source: "claudeAgent",235+ threadCount: transcripts.length,236+ lastActiveAtMs: withMtimes[0]?.mtimeMs ?? null,237+ });238+ }
- apps/web/src/components/onboarding/WelcomeWizard.tsx line 650OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +630,21 @@630+ * Inline install terminal. Opens a PTY on the connected environment under a631+ * synthetic onboarding thread id (terminals are keyed by free-form thread id;632+ * the server validates only the cwd) and pre-types the install or login633+ * command without submitting, so the user reviews and presses Enter.634+ */635+function AgentInstallTerminal({636+ environmentId,637+ driver,638+ installed,639+ onClose,640+}: {641+ readonly environmentId: EnvironmentId;642+ readonly driver: string;643+ readonly installed: boolean;644+ readonly onClose: () => void;645+}) {646+ const keybindings = useAtomValue(primaryServerKeybindingsAtom);647+ const serverConfig = useAtomValue(serverEnvironment.configValueAtom(environmentId));648+ const openTerminal = useAtomCommand(terminalEnvironment.open, { reportFailure: false });649+ const writeTerminal = useAtomCommand(terminalEnvironment.write, { reportFailure: false });650+ const preparedRef = useRef(false);
- apps/server/src/project/AgentSessionScanner.ts line 505OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +76,21 @@76+ readonly cwd: string;77+ readonly source: AgentSessionSource;78+ readonly threadCount: number;79+ readonly lastActiveAtMs: number | null;80+}81+82+const decoder = new TextDecoder();83+84+/**85+ * T3 Code runs its own agent sessions inside disposable worktrees. Their86+ * transcripts look exactly like user sessions, but re-importing the app's own87+ * sandboxes as projects is never right. Matches this server's configured88+ * worktrees directory plus the conventional `.t3/worktrees` layout, which89+ * also catches sandboxes from other T3 homes on the same machine.90+ */91+function isT3ManagedWorktree(resolvedPath: string, worktreesDir: string): boolean {92+ const withSeparator = `${resolvedPath}/`;93+ return (94+ withSeparator.startsWith(`${worktreesDir}/`) ||95+ /[/\\]\.t3[/\\]worktrees[/\\]/.test(withSeparator)96+ );
- apps/server/src/project/AgentSessionScanner.ts line 29OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +9,21 @@9+ * The scan is read-only and best-effort: an unreadable home, a malformed10+ * transcript, or a directory that has since been deleted is skipped rather11+ * than failing the scan. Project creation stays with the client, which12+ * dispatches `project.create` for whichever candidates the user picks.13+ *14+ * @module project/AgentSessionScanner15+ */16+import * as NodeOS from "node:os";17+18+import type { AgentSessionProjectCandidate, AgentSessionScanResult } from "@t3tools/contracts";19+import * as Context from "effect/Context";20+import * as DateTime from "effect/DateTime";21+import * as Effect from "effect/Effect";22+import * as FileSystem from "effect/FileSystem";23+import * as Layer from "effect/Layer";24+import * as Option from "effect/Option";25+import * as Path from "effect/Path";26+import * as Schema from "effect/Schema";27+28+import * as ServerConfig from "../config.ts";29+import { ProjectionSnapshotQuery } from "../orchestration/Services/ProjectionSnapshotQuery.ts";
- apps/server/src/project/AgentSessionScanner.ts line 92OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +72,21 @@72+type AgentSessionSource = AgentSessionProjectCandidate["sources"][number];73+74+/** A single directory's worth of evidence from one source. */75+interface RawCandidate {76+ readonly cwd: string;77+ readonly source: AgentSessionSource;78+ readonly threadCount: number;79+ readonly lastActiveAtMs: number | null;80+}81+82+const decoder = new TextDecoder();83+84+/**85+ * T3 Code runs its own agent sessions inside disposable worktrees. Their86+ * transcripts look exactly like user sessions, but re-importing the app's own87+ * sandboxes as projects is never right. Matches this server's configured88+ * worktrees directory plus the conventional `.t3/worktrees` layout, which89+ * also catches sandboxes from other T3 homes on the same machine. Separators90+ * are normalized so the prefix match holds on Windows too.91+ */92+function isT3ManagedWorktree(resolvedPath: string, worktreesDir: string): boolean {
- apps/web/src/components/onboarding/WelcomeWizard.tsx line 680OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +660,21 @@660+ const command = installed661+ ? (AGENT_LOGIN_COMMANDS[driver] ?? "")662+ : (AGENT_INSTALL_COMMANDS[driver] ?? "");663+664+ useEffect(() => {665+ if (preparedRef.current || cwd === null) return;666+ void (async () => {667+ const opened = await openTerminal({668+ environmentId,669+ input: { threadId: AGENT_ONBOARDING_THREAD_ID, terminalId, cwd },670+ });671+ // Only a successful open ends the attempts, so a transient RPC failure672+ // retries on the next render instead of leaving a dead terminal.673+ if (opened._tag !== "Success") return;674+ preparedRef.current = true;675+ if (command.length === 0) return;676+ // Closing and reopening the drawer reattaches to the still-live PTY677+ // (Done never kills the session). A session with history already got678+ // its command — pre-typing again would duplicate it, or feed stdin to679+ // whatever is running.680+ if (opened.value.history.length > 0) return;
- apps/server/src/project/AgentSessionScanner.ts lines 212 to 212OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +192,21 @@192+ if (Option.isNone(mtime)) continue;193+ const value = mtime.value.getTime();194+ if (latest === null || value > latest) {195+ latest = value;196+ }197+ }198+ return latest;199+ });200+201+ /**202+ * Resolve the Claude config directory the CLI would use, matching the203+ * precedence the spawned CLI sees: the instance's `homePath` (exported as204+ * `CLAUDE_CONFIG_DIR`), then a `CLAUDE_CONFIG_DIR` already in the205+ * environment, then `~/.claude`.206+ */207+ const resolveClaudeConfigDir = (homePath: string): string => {208+ const configured = homePath.trim();209+ if (configured.length > 0) {210+ return path.resolve(expandHomePath(configured));211+ }212+ const fromEnvironment = process.env.CLAUDE_CONFIG_DIR?.trim() ?? "";apps/server/src/project/AgentSessionScanner.ts lines 49 to 59OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +39,21 @@39+ * cheap even when a transcript is hundreds of megabytes.40+ */41+const TRANSCRIPT_PREFIX_BYTES = 32 * 1024;42+43+/**44+ * Upper bound on transcripts inspected per source. Newest-first ordering means45+ * the cap drops only stale sessions when a home directory is unusually large.46+ */47+const MAX_TRANSCRIPTS_PER_SOURCE = 5000;48+49+export class AgentSessionScanFailedError extends Schema.TaggedErrorClass<AgentSessionScanFailedError>()(50+ "AgentSessionScanFailedError",51+ {52+ operation: Schema.Literals(["read-settings", "read-projects"]),53+ cause: Schema.Defect(),54+ },55+) {56+ override get message(): string {57+ return `Failed to scan agent sessions during ${this.operation}.`;58+ }59+}
- apps/web/src/components/onboarding/WelcomeWizard.tsx line 702OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +682,21 @@682+ if (opened._tag !== "Success") return;683+ preparedRef.current = true;684+ if (command.length === 0) return;685+ // Pre-type without the trailing carriage return; the user submits.686+ // The terminal id is unique to this mount, so this session has never687+ // been written to before.688+ await writeTerminal({689+ environmentId,690+ input: { threadId: AGENT_ONBOARDING_THREAD_ID, terminalId, data: command },691+ });692+ })();693+ }, [command, cwd, environmentId, openTerminal, terminalId, writeTerminal]);694+695+ // Done kills the PTY rather than orphaning it behind the drawer.696+ const closeAndDismiss = () => {697+ void closeTerminal({698+ environmentId,699+ input: { threadId: AGENT_ONBOARDING_THREAD_ID, terminalId },700+ });701+ onClose();702+ };
- apps/web/src/components/onboarding/WelcomeWizard.tsx line 688OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +668,21 @@668+669+ const command = installed670+ ? (AGENT_LOGIN_COMMANDS[driver] ?? "")671+ : (AGENT_INSTALL_COMMANDS[driver] ?? "");672+673+ useEffect(() => {674+ if (preparedRef.current || cwd === null) return;675+ void (async () => {676+ const opened = await openTerminal({677+ environmentId,678+ input: { threadId: AGENT_ONBOARDING_THREAD_ID, terminalId, cwd },679+ });680+ // Only a successful open ends the attempts, so a transient RPC failure681+ // retries on the next render instead of leaving a dead terminal.682+ if (opened._tag !== "Success") return;683+ preparedRef.current = true;684+ if (command.length === 0) return;685+ // Pre-type without the trailing carriage return; the user submits.686+ // The terminal id is unique to this mount, so this session has never687+ // been written to before.688+ await writeTerminal({
- apps/server/src/project/AgentSessionScanner.ts line 244OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +224,21 @@224+ for (const projectDirectory of projectDirectories) {225+ if (budget <= 0) break;226+ const directory = path.join(projectsDir, projectDirectory);227+ const transcripts = (yield* listDirectory(directory))228+ .filter((entry) => entry.endsWith(".jsonl"))229+ .map((entry) => path.join(directory, entry));230+ if (transcripts.length === 0) continue;231+232+ // Stat everything, then spend the budget newest-first, so the cap only233+ // ever drops the oldest transcripts.234+ const withMtimes: Array<{ filePath: string; mtimeMs: number }> = [];235+ for (const filePath of transcripts) {236+ const stats = yield* statOption(filePath);237+ if (Option.isNone(stats) || Option.isNone(stats.value.mtime)) continue;238+ withMtimes.push({ filePath, mtimeMs: stats.value.mtime.value.getTime() });239+ }240+ withMtimes.sort((left, right) => right.mtimeMs - left.mtimeMs);241+ withMtimes.splice(budget);242+ budget -= withMtimes.length;243+244+ // The newest transcript is the most likely to still name a live path.apps/server/src/project/AgentSessionScanner.ts line 235OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +215,21 @@215+ * `-`), so the real path comes from the `cwd` recorded in the newest216+ * transcript inside it.217+ */218+ const scanClaude = Effect.fn("AgentSessionScanner.scanClaude")(function* (homePath: string) {219+ const projectsDir = path.join(resolveClaudeConfigDir(homePath), "projects");220+ const projectDirectories = yield* listDirectory(projectsDir);221+ const candidates: Array<RawCandidate> = [];222+ let budget = MAX_TRANSCRIPTS_PER_SOURCE;223+224+ for (const projectDirectory of projectDirectories) {225+ if (budget <= 0) break;226+ const directory = path.join(projectsDir, projectDirectory);227+ const transcripts = (yield* listDirectory(directory))228+ .filter((entry) => entry.endsWith(".jsonl"))229+ .map((entry) => path.join(directory, entry));230+ if (transcripts.length === 0) continue;231+232+ // Stat everything, then spend the budget newest-first, so the cap only233+ // ever drops the oldest transcripts.234+ const withMtimes: Array<{ filePath: string; mtimeMs: number }> = [];235+ for (const filePath of transcripts) {
- packages/contracts/src/agentSessions.ts lines 40 to 40OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +20,21 @@20+export const AgentSessionProjectCandidate = Schema.Struct({21+ path: TrimmedNonEmptyString,22+ title: TrimmedNonEmptyString,23+ sources: Schema.Array(AgentSessionSource),24+ threadCount: NonNegativeInt,25+ lastActiveAt: Schema.NullOr(IsoDateTime),26+ alreadyImported: Schema.Boolean,27+});28+export type AgentSessionProjectCandidate = typeof AgentSessionProjectCandidate.Type;29+30+export const AgentSessionScanResult = Schema.Struct({31+ candidates: Schema.Array(AgentSessionProjectCandidate),32+ scannedAt: IsoDateTime,33+});34+export type AgentSessionScanResult = typeof AgentSessionScanResult.Type;35+36+export class AgentSessionScanError extends Schema.TaggedErrorClass<AgentSessionScanError>()(37+ "AgentSessionScanError",38+ {39+ operation: Schema.Literals(["read-settings", "read-projects"]),40+ cause: Schema.optional(Schema.Defect()),
- apps/web/src/components/onboarding/WelcomeWizard.tsx lines 668 to 673OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +653,21 @@653+ const openTerminal = useAtomCommand(terminalEnvironment.open, { reportFailure: false });654+ const writeTerminal = useAtomCommand(terminalEnvironment.write, { reportFailure: false });655+ const closeTerminal = useAtomCommand(terminalEnvironment.close, { reportFailure: false });656+ const preparedRef = useRef(false);657+ const [terminalId] = useState(() => {658+ onboardingTerminalSequence += 1;659+ return `onboarding-${driver}-${onboardingTerminalSequence}`;660+ });661+ const threadRef = useMemo(662+ () => scopeThreadRef(environmentId, AGENT_ONBOARDING_THREAD_ID),663+ [environmentId],664+ );665+ // The terminal manager stats the cwd verbatim (no tilde expansion), so use666+ // the server process's own working directory — always real on that machine.667+ const cwd = serverConfig?.cwd ?? null;668+669+ const command = installed670+ ? (AGENT_LOGIN_COMMANDS[driver] ?? "")671+ : (AGENT_INSTALL_COMMANDS[driver] ?? "");672+ const [preTypeFailed, setPreTypeFailed] = useState(false);673+
- apps/web/src/components/onboarding/FirstRunGate.tsx lines 91 to 91OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +71,21 @@71+ // Both shells AND the server config must be in before the workspace can72+ // be judged: shells bootstrap and config load independently, and a73+ // disconnected environment reports bootstrapped with empty projections.74+ // Without the config a fresh cwd-bootstrapped install would read as75+ // non-fresh (projects but no cwd yet), and an offline existing install76+ // would read as fresh (nothing at all). Config never arriving means the77+ // timeout below falls back to the app.78+ if (!bootstrapped || serverConfig === null) return;79+ setDecision(workspaceFresh ? "wizard" : "app");80+ }, [81+ bootstrapped,82+ decision,83+ enabled,84+ hydrated,85+ onboardingCompletedAt,86+ serverConfig,87+ workspaceFresh,88+ ]);89+90+ useEffect(() => {91+ if (decision !== "pending") return;docs/user/welcome-wizard.md line 12OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,12 @@1+# Welcome Wizard2+3+On a fresh install, T3 Code opens a short setup flow before the main app.4+Installs with existing projects or completed onboarding skip it.5+6+## Choose how to connect7+8+**Local Only** — agents run on this machine. No account needed. Shown on the9+ desktop app and locally served web app.10+**T3 Connect** — sign in and reach any of your machines from anywhere.11+ Machines signed into your account connect automatically. If none are12+ connected yet, the wizard shows the command to run on the machine with yourapps/web/src/components/onboarding/WelcomeWizard.tsx lines 812 to 814OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +794,21 @@794+ onDone();795+ return;796+ }797+ setIsImporting(true);798+ setImportError("");799+ const defaultModelSelection = resolveDefaultProviderModelSelection(providers ?? [], null);800+ let failures = 0;801+ for (const candidate of selection) {802+ const result = await createProject({803+ environmentId,804+ input: {805+ projectId: newProjectId(),806+ title: candidate.title,807+ workspaceRoot: candidate.path,808+ createWorkspaceRootIfMissing: false,809+ defaultModelSelection,810+ },811+ });812+ if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {813+ failures += 1;814+ }
- apps/web/src/components/onboarding/WelcomeWizard.tsx line 710OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +690,21 @@690+ environmentId,691+ input: { threadId: AGENT_ONBOARDING_THREAD_ID, terminalId, data: command },692+ });693+ // A silent failure would leave a blank prompt under copy that says694+ // "review the command" — fall back to telling the user what to type.695+ if (wrote._tag !== "Success") setPreTypeFailed(true);696+ })();697+ }, [command, cwd, environmentId, openTerminal, terminalId, writeTerminal]);698+699+ // Every exit path unmounts the drawer (Done, Continue/Skip, card switch,700+ // session exit), so unmount cleanup is the single place the PTY dies —701+ // nothing is left running behind the wizard. An interrupted install is702+ // re-runnable from the card.703+ useEffect(() => {704+ return () => {705+ void closeTerminal({706+ environmentId,707+ input: { threadId: AGENT_ONBOARDING_THREAD_ID, terminalId },708+ });709+ };710+ }, [closeTerminal, environmentId, terminalId]);
- apps/web/src/components/onboarding/WelcomeWizard.tsx line 720OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +700,21 @@700+ environmentId,701+ input: { threadId: AGENT_ONBOARDING_THREAD_ID, terminalId, data: command },702+ });703+ // A silent failure would leave a blank prompt under copy that says704+ // "review the command" — fall back to telling the user what to type.705+ if (!cancelled && wrote._tag !== "Success") setPreTypeFailed(true);706+ })();707+ }708+ // Every exit path unmounts the drawer (Done, Continue/Skip, card switch,709+ // session exit), so this cleanup is the single place the PTY dies —710+ // nothing is left running behind the wizard. An interrupted install is711+ // re-runnable from the card.712+ return () => {713+ cancelled = true;714+ preparedRef.current = false;715+ void closeTerminal({716+ environmentId,717+ input: { threadId: AGENT_ONBOARDING_THREAD_ID, terminalId },718+ });719+ };720+ }, [closeTerminal, command, cwd, environmentId, openTerminal, terminalId, writeTerminal]);
- docs/user/welcome-wizard.md line 34OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +14,21 @@14+ and **Continue** becomes available.15+**Direct** — connect to a server by URL. Works over LAN and Tailscale. Run16+ `npx t3 pair` on the server and paste the pairing URL it prints.17+18+## Set up your agents19+20+The wizard checks the connected machine for Claude Code and Codex and shows21+their install and sign-in status. If one is missing, an inline terminal opens22+with the install command pre-typed — press Enter to run it, then click23+**Done**. Once the agent is detected, its card offers **Sign in**, which opens24+a fresh terminal with the CLI's login command ready to run. Other supported25+agents are configured in Settings → Providers.26+27+## Import your projects28+29+T3 Code scans the connected machine for directories where Claude Code or Codex30+have already run and offers them as projects. The default imports projects31+active in the last 30 days; **Choose** lists everything found. Imports create32+projects only — thread history import is coming later.33+34+Every step after the connection choice can be skipped. Projects can always beapps/web/src/components/onboarding/WelcomeWizard.tsx lines 1036 to 1039OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1019,21 @@1019+ return (1020+ <div1021+ className={cn(1022+ "flex items-center justify-between gap-3 rounded-lg border border-border/70 bg-background/60 font-mono",1023+ prominent ? "px-4 py-3.5 text-base" : "px-3 py-2.5 text-sm",1024+ className,1025+ )}1026+ >1027+ <span className="min-w-0 truncate">1028+ <span className="mr-2 text-muted-foreground">$</span>1029+ {command}1030+ </span>1031+ <Button1032+ size="icon-xs"1033+ variant="ghost"1034+ aria-label="Copy command"1035+ onClick={() => {1036+ void navigator.clipboard.writeText(command);1037+ setCopied(true);1038+ window.setTimeout(() => setCopied(false), 1500);1039+ }}
- apps/server/src/project/AgentSessionScanner.ts line 425OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +405,21 @@405+ }406+407+ const candidates: Array<AgentSessionProjectCandidate> = [];408+ for (const [key, entry] of merged.entries()) {409+ // Projects may have been created under either the recorded spelling or410+ // the resolved realpath (e.g. a symlinked home) — check both.411+ const lookupPaths = key === entry.path ? [entry.path] : [entry.path, key];412+ let alreadyImported = false;413+ for (const lookupPath of lookupPaths) {414+ const existingProject = yield* projectionSnapshotQuery415+ .getActiveProjectByWorkspaceRoot(lookupPath)416+ .pipe(417+ Effect.mapError(418+ (cause) => new AgentSessionScanError({ operation: "read-projects", cause }),419+ ),420+ );421+ if (Option.isSome(existingProject)) {422+ alreadyImported = true;423+ break;424+ }425+ }apps/web/src/components/onboarding/WelcomeWizard.tsx line 729OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +709,21 @@709+ environmentId,710+ input: { threadId: AGENT_ONBOARDING_THREAD_ID, terminalId, data: command },711+ });712+ // A silent failure would leave a blank prompt under copy that says713+ // "review the command" — fall back to telling the user what to type.714+ if (!cancelled && wrote._tag !== "Success") setPreTypeFailed(true);715+ })();716+ }717+ // Every exit path unmounts the drawer (Done, Continue/Skip, card switch,718+ // session exit), so this cleanup is the single place the PTY dies —719+ // nothing is left running behind the wizard. An interrupted install is720+ // re-runnable from the card.721+ return () => {722+ cancelled = true;723+ preparedRef.current = false;724+ void closeTerminal({725+ environmentId,726+ input: { threadId: AGENT_ONBOARDING_THREAD_ID, terminalId },727+ });728+ };729+ }, [closeTerminal, command, cwd, environmentId, openTerminal, terminalId, writeTerminal]);
- apps/web/src/components/onboarding/WelcomeWizard.tsx line 843OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +823,21 @@823+ let imported = 0;824+ let failed = 0;825+ for (const candidate of selection) {826+ const result = await createProject({827+ environmentId,828+ input: {829+ projectId: newProjectId(),830+ title: candidate.title,831+ workspaceRoot: candidate.path,832+ createWorkspaceRootIfMissing: false,833+ defaultModelSelection,834+ },835+ });836+ if (result._tag === "Success") {837+ imported += 1;838+ } else if (!isAtomCommandInterrupted(result)) {839+ failed += 1;840+ }841+ }842+ setIsImporting(false);843+ if (imported < selection.length) {apps/web/src/components/onboarding/WelcomeWizard.tsx line 899Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +668,21 @@668+ return `onboarding-${driver}-${onboardingTerminalSequence}`;669+ });670+ const threadRef = useMemo(671+ () => scopeThreadRef(environmentId, AGENT_ONBOARDING_THREAD_ID),672+ [environmentId],673+ );674+ // The terminal manager stats the cwd verbatim (no tilde expansion), so use675+ // the server process's own working directory — always real on that machine.676+ const cwd = serverConfig?.cwd ?? null;677+678+ const command = installed679+ ? (AGENT_LOGIN_COMMANDS[driver] ?? "")680+ : (AGENT_INSTALL_COMMANDS[driver] ?? "");681+ const [preTypeFailed, setPreTypeFailed] = useState(false);682+683+ // Open + pre-type, and tear the PTY down again on cleanup. Both live in one684+ // effect so a Strict Mode setup/cleanup/setup cycle (or any remount) always685+ // re-opens: the previous run's session is closed and `preparedRef` is reset686+ // together, instead of the ref surviving a teardown and leaving the drawer687+ // attached to a dead session.688+ useEffect(() => {
- apps/server/src/project/AgentSessionScanner.ts line 183OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +163,21 @@163+ ): Effect.fn.Return<string | null> {164+ const prefix = yield* Effect.scoped(165+ fileSystem166+ .open(filePath, { flag: "r" })167+ .pipe(Effect.flatMap((file) => file.readAlloc(TRANSCRIPT_PREFIX_BYTES))),168+ ).pipe(Effect.orElseSucceed(Option.none<Uint8Array>));169+ if (Option.isNone(prefix)) return null;170+171+ const text = decoder.decode(prefix.value);172+ const newlineIndex = text.indexOf("\n");173+ if (newlineIndex === -1) {174+ // Either a single-line file smaller than the prefix, or a first record175+ // too large to trust as complete JSON.176+ return prefix.value.length < TRANSCRIPT_PREFIX_BYTES ? text : null;177+ }178+ return text.slice(0, newlineIndex);179+ });180+181+ const readCwd = Effect.fn("AgentSessionScanner.readCwd")(function* (filePath: string) {182+ const line = yield* readFirstLine(filePath);183+ return line === null ? null : extractCwd(line.trim());apps/web/src/components/onboarding/WelcomeWizard.tsx line 111Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +48,21 @@48+ * Every step past the connection gate is skippable; the whole wizard is49+ * re-runnable by clearing the flag.50+ */51+52+type WizardStep = "connection" | "connect-machines" | "pair-direct" | "agents" | "import";53+54+/**55+ * The machine the agent and import steps run against: the primary environment56+ * when it's connected, otherwise the first connected environment (the remote57+ * paths on web/hosted have no primary). Deliberately not a persisted "primary58+ * machine" concept — just whichever machine is reachable right now, labeled59+ * inline on each step.60+ */61+function useOnboardingTargetEnvironment() {62+ const { environments } = useEnvironments();63+ const primaryEnvironment = usePrimaryEnvironment();64+ if (primaryEnvironment !== null && primaryEnvironment.connection.phase === "connected") {65+ return primaryEnvironment;66+ }67+ return environments.find((environment) => environment.connection.phase === "connected") ?? null;68+}apps/web/src/components/onboarding/WelcomeWizard.tsx line 729OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +709,21 @@709+ environmentId,710+ input: { threadId: AGENT_ONBOARDING_THREAD_ID, terminalId, data: command },711+ });712+ // A silent failure would leave a blank prompt under copy that says713+ // "review the command" — fall back to telling the user what to type.714+ if (!cancelled && wrote._tag !== "Success") setPreTypeFailed(true);715+ })();716+ }717+ // Every exit path unmounts the drawer (Done, Continue/Skip, card switch,718+ // session exit), so this cleanup is the single place the PTY dies —719+ // nothing is left running behind the wizard. An interrupted install is720+ // re-runnable from the card.721+ return () => {722+ cancelled = true;723+ preparedRef.current = false;724+ void closeTerminal({725+ environmentId,726+ input: { threadId: AGENT_ONBOARDING_THREAD_ID, terminalId },727+ });728+ };729+ }, [closeTerminal, command, cwd, environmentId, openTerminal, terminalId, writeTerminal]);
- apps/web/src/components/onboarding/FirstRunGate.tsx line 63OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +43,21 @@43+ const navigate = useNavigate();44+ const hydrated = useClientSettingsHydrated();45+ const onboardingCompletedAt = useClientSettings((settings) => settings.onboardingCompletedAt);46+ const bootstrapped = useAllEnvironmentShellsBootstrapped();47+ const projects = useProjects();48+ const threads = useThreadShells();49+ const serverConfig = useAtomValue(primaryServerConfigAtom);50+ // Within a session settings stay hydrated, so remounts (e.g. returning from51+ // the wizard) resolve synchronously instead of blanking a frame.52+ const [decision, setDecision] = useState<FirstRunDecision>(() =>53+ !enabled || (hydrated && onboardingCompletedAt !== null) ? "app" : "pending",54+ );55+56+ // A workspace still counts as fresh when its only content is the server's57+ // own cwd auto-bootstrap: web mode creates a project + thread from cwd at58+ // startup (`autoBootstrapProjectFromCwd` defaults on there), so "no59+ // projects at all" would mean `npx t3` users never see the wizard. Any60+ // other project, or more than one thread, is real user state.61+ const serverCwd = serverConfig?.cwd ?? null;62+ const workspaceFresh =63+ projects.every((project) => project.workspaceRoot === serverCwd) && threads.length <= 1;apps/web/src/components/onboarding/WelcomeWizard.tsx lines 1042 to 1043Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +774,21 @@774+775+/**776+ * One-decision import (4B): a summary line with Import recent / Choose /777+ * Skip. The default imports only projects touched in the last 30 days;778+ * Choose expands a checklist including older ones. Projects only — thread779+ * history import is a follow-up.780+ */781+function ImportStep({ onDone }: { readonly onDone: () => void }) {782+ const targetEnvironment = useOnboardingTargetEnvironment();783+ const environmentId = targetEnvironment?.environmentId ?? null;784+ const machineLabel = targetEnvironment?.label ?? "this machine";785+ const providers = useAtomValue(786+ serverEnvironment.providersValueAtom(environmentId ?? ("" as EnvironmentId)),787+ );788+ const scan = useEnvironmentQuery(789+ environmentId === null ? null : agentSessionScan({ environmentId, input: {} }),790+ );791+ const createProject = useAtomCommand(projectEnvironment.create, { reportFailure: false });792+ const [choosing, setChoosing] = useState(false);793+ const [deselected, setDeselected] = useState<ReadonlySet<string>>(new Set());794+ const [isImporting, setIsImporting] = useState(false);apps/web/src/components/onboarding/WelcomeWizard.tsx line 504OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +484,21 @@484+ onContinue,485+ onSkip,486+}: {487+ readonly environmentId: EnvironmentId;488+ readonly machineLabel: string;489+ readonly onContinue: () => void;490+ readonly onSkip: () => void;491+}) {492+ const providers = useAtomValue(serverEnvironment.providersValueAtom(environmentId));493+ const refreshProviders = useAtomCommand(serverEnvironment.refreshProviders, {494+ reportFailure: false,495+ });496+ const [terminalAgent, setTerminalAgent] = useState<string | null>(null);497+498+ // Re-probe on entry so freshly installed CLIs show up without a manual499+ // refresh; harmless when nothing changed (single-flighted per environment).500+ useEffect(() => {501+ void refreshProviders({ environmentId, input: {} });502+ }, [environmentId, refreshProviders]);503+504+ const byDriver = useMemo(() => {
- apps/web/src/components/onboarding/WelcomeWizard.tsx line 654OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +634,21 @@634+ * synthetic onboarding thread id (terminals are keyed by free-form thread id;635+ * the server validates only the cwd) and pre-types the install or login636+ * command without submitting, so the user reviews and presses Enter.637+ */638+// Each drawer mount gets its own PTY: install and sign-in for the same639+// driver must not share a session, or the second open would reattach and640+// either duplicate the pre-typed command or feed it to a running process.641+let onboardingTerminalSequence = 0;642+643+function AgentInstallTerminal({644+ environmentId,645+ driver,646+ installed,647+ onClose,648+}: {649+ readonly environmentId: EnvironmentId;650+ readonly driver: string;651+ readonly installed: boolean;652+ readonly onClose: () => void;653+}) {654+ const keybindings = useAtomValue(primaryServerKeybindingsAtom);
- apps/web/src/components/onboarding/WelcomeWizard.tsx lines 984 to 991OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +971,21 @@971+ title,972+ description,973+ onBack,974+ children,975+}: {976+ readonly title: string;977+ readonly description?: string;978+ readonly onBack?: () => void;979+ readonly children?: React.ReactNode;980+}) {981+ return (982+ <>983+ {onBack ? (984+ <button985+ type="button"986+ onClick={onBack}987+ className="mt-3 inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground"988+ >989+ <ChevronLeftIcon className="size-3.5" />990+ Back991+ </button>apps/web/src/components/onboarding/WelcomeWizard.tsx lines 379 to 382Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +191,21 @@191+ </>192+ );193+}194+195+function ConnectionCard({196+ title,197+ description,198+ tag,199+ selected,200+ onSelect,201+}: {202+ readonly title: string;203+ readonly description: string;204+ readonly tag: string;205+ readonly selected: boolean;206+ readonly onSelect: () => void;207+}) {208+ return (209+ <button210+ type="button"211+ onClick={onSelect}apps/web/src/components/onboarding/WelcomeWizard.tsx lines 602 to 615OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +595,21 @@595+ const ready = usable && provider.auth.status === "authenticated";596+ const needsLogin = usable && provider.auth.status !== "authenticated";597+598+ return (599+ <div600+ className={cn(601+ "rounded-xl border p-4",602+ ready ? "border-emerald-500/40" : terminalOpen ? "border-primary" : "border-border/70",603+ )}604+ >605+ <div className="flex items-center gap-2.5">606+ {Icon ? <Icon className="size-6" /> : null}607+ <span className="text-sm font-semibold">{displayName}</span>608+ </div>609+ <p className="mt-2 text-xs text-muted-foreground">610+ {summary.headline}611+ {summary.detail ? ` · ${summary.detail}` : ""}612+ </p>613+ <div className="mt-3">614+ {ready ? (615+ <span className="inline-flex items-center gap-1 text-xs font-semibold text-emerald-500">
- apps/web/src/components/onboarding/WelcomeWizard.tsx lines 379 to 389Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +197,21 @@197+ description,198+ tag,199+ selected,200+ onSelect,201+}: {202+ readonly title: string;203+ readonly description: string;204+ readonly tag: string;205+ readonly selected: boolean;206+ readonly onSelect: () => void;207+}) {208+ return (209+ <button210+ type="button"211+ onClick={onSelect}212+ className={cn(213+ "flex flex-col rounded-xl border p-4 text-left transition-colors",214+ selected215+ ? "border-primary bg-primary/5 ring-1 ring-primary/25"216+ : "border-border/70 bg-background/40 hover:border-border",217+ )}apps/web/src/components/onboarding/WelcomeWizard.tsx lines 983 to 991OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +971,21 @@971+ title,972+ description,973+ onBack,974+ children,975+}: {976+ readonly title: string;977+ readonly description?: string;978+ readonly onBack?: () => void;979+ readonly children?: React.ReactNode;980+}) {981+ return (982+ <>983+ {onBack ? (984+ <button985+ type="button"986+ onClick={onBack}987+ className="mt-3 inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground"988+ >989+ <ChevronLeftIcon className="size-3.5" />990+ Back991+ </button>
- apps/web/src/components/onboarding/WelcomeWizard.tsx lines 423 to 433OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +413,21 @@413+ <span className="text-muted-foreground">On the server:</span>414+ </p>415+ <CommandBlock command="npx t3 pair" className="mt-2" />416+ <p className="mt-1 text-xs text-muted-foreground">417+ Prints a one-time pairing URL. Add{" "}418+ <code className="rounded bg-muted px-1 font-mono">--tailscale</code> to publish on your419+ tailnet.420+ </p>421+ </div>422+ <div>423+ <p className="text-sm">424+ <span className="font-semibold">2.</span>{" "}425+ <span className="text-muted-foreground">Paste the URL it prints:</span>426+ </p>427+ <Input428+ className="mt-2"429+ autoCapitalize="none"430+ autoComplete="off"431+ autoCorrect="off"432+ spellCheck={false}433+ nativeInput
- apps/web/src/components/onboarding/WelcomeWizard.tsx lines 1102 to 1115OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1095,21 @@1095+ readonly className?: string;1096+ readonly prominent?: boolean;1097+}) {1098+ const [copied, setCopied] = useState(false);1099+ // The Clipboard API only exists in secure contexts; the wizard's Direct1100+ // path explicitly supports plain-HTTP LAN servers, so fall back to the1101+ // selection-based copy there.1102+ const copyCommand = () => {1103+ if (navigator.clipboard !== undefined) {1104+ void navigator.clipboard.writeText(command);1105+ } else {1106+ const scratch = document.createElement("textarea");1107+ scratch.value = command;1108+ document.body.append(scratch);1109+ scratch.select();1110+ document.execCommand("copy");1111+ scratch.remove();1112+ }1113+ setCopied(true);1114+ window.setTimeout(() => setCopied(false), 1500);1115+ };
- apps/web/src/components/onboarding/FirstRunGate.tsx line 88OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +68,21 @@68+ (project) =>69+ project.environmentId === primaryEnvironmentId && project.workspaceRoot === serverCwd,70+ ) &&71+ threads.length <= 1 &&72+ threads.every((thread) => thread.environmentId === primaryEnvironmentId);73+74+ useEffect(() => {75+ if (decision !== "pending" || !hydrated) return;76+ if (!enabled || onboardingCompletedAt !== null) {77+ setDecision("app");78+ return;79+ }80+ // Both shells AND the server config must be in before the workspace can81+ // be judged: shells bootstrap and config load independently, and a82+ // disconnected environment reports bootstrapped with empty projections.83+ // Without the config a fresh cwd-bootstrapped install would read as84+ // non-fresh (projects but no cwd yet), and an offline existing install85+ // would read as fresh (nothing at all). Config never arriving means the86+ // timeout below falls back to the app.87+ if (!bootstrapped || serverConfig === null) return;88+ setDecision(workspaceFresh ? "wizard" : "app");
- apps/web/src/components/onboarding/WelcomeWizard.tsx lines 335 to 340OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +320,21 @@320+ hasRemoteMachines321+ ? "These machines connected automatically from your account."322+ : "SSH in if you need to. The machine signs into your account and connects on its own."323+ }324+ onBack={onBack}325+ >326+ {hasRemoteMachines ? (327+ <>328+ <div className="mt-5 overflow-hidden rounded-lg border">329+ <CloudEnvironmentConnectRows330+ primaryEnvironmentId={primaryEnvironment?.environmentId ?? null}331+ savedEnvironments={savedEnvironments}332+ showSavedEnvironments333+ empty={null}334+ />335+ </div>336+ <details className="mt-4">337+ <summary className="cursor-pointer text-xs text-muted-foreground">338+ Add another machine339+ </summary>340+ <CommandBlock command={CONNECT_LOGIN_COMMAND} className="mt-2" />
- apps/web/src/components/onboarding/WelcomeWizard.tsx line 1116OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +1096,21 @@1096+ readonly command: string;1097+ readonly className?: string;1098+ readonly prominent?: boolean;1099+}) {1100+ // The Clipboard API only exists in secure contexts; the wizard's Direct1101+ // path explicitly supports plain-HTTP LAN servers, so the unavailable-API1102+ // error falls back to selection-based copy. Both paths mark copied only on1103+ // an actual success.1104+ const [fallbackCopied, setFallbackCopied] = useState(false);1105+ const { copyToClipboard, isCopied } = useCopyToClipboard({1106+ timeout: 1500,1107+ target: "command",1108+ onError: (error) => {1109+ if (!isClipboardApiUnavailableError(error)) return;1110+ const scratch = document.createElement("textarea");1111+ scratch.value = command;1112+ document.body.append(scratch);1113+ scratch.select();1114+ const didCopy = document.execCommand("copy");1115+ scratch.remove();1116+ if (didCopy) setFallbackCopied(true);
- apps/web/src/components/onboarding/WelcomeWizard.tsx lines 334 to 339OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +319,21 @@319+ description={320+ hasRemoteMachines321+ ? "These machines connected automatically from your account."322+ : "SSH in if you need to. The machine signs into your account and connects on its own."323+ }324+ onBack={onBack}325+ >326+ {hasRemoteMachines ? (327+ <>328+ <div className="mt-5 overflow-hidden rounded-lg border">329+ <CloudEnvironmentConnectRows330+ primaryEnvironmentId={primaryEnvironment?.environmentId ?? null}331+ savedEnvironments={savedEnvironments}332+ showSavedEnvironments333+ empty={null}334+ />335+ </div>336+ <details className="mt-4">337+ <summary className="cursor-pointer text-xs text-muted-foreground">338+ Add another machine339+ </summary>
Sign in to join this conversation.









Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
92f201e6-0378-4f3c-be90-a488d2038d3cYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Warning
Your free Security trial is over. An organization admin can activate Security or dismiss this notice.
Comment `@coderabbitai help` to get the list of available commands.