fix(web): make onboarding a shared multi-computer wizard (#10465)
This commit is contained in:
1 parent
490eb17d31
commit
f729e8fd83
20 files changed
+1207
-1285
No files matched your search
@@ -4,7 +4,14 @@ import { type ReactNode, useEffect, useLayoutEffect, useRef, useState } from "re
|
||||
|
||||
const HEIGHT_TRANSITION_FALLBACK_MS = 250;
|
||||
|
||||
export function AnimatedHeight({ children }: { readonly children: ReactNode }) {
|
||||
export function AnimatedHeight({
|
||||
children,
|
||||
holdHeight = false,
|
||||
}: {
|
||||
readonly children: ReactNode;
|
||||
/** Retain the previous content height while a replacement is loading. */
|
||||
readonly holdHeight?: boolean;
|
||||
}) {
|
||||
const contentRef = useRef<HTMLDivElement>(null);
|
||||
const [heightState, setHeightState] = useState<{
|
||||
readonly height: number | null;
|
||||
@@ -22,6 +29,7 @@ export function AnimatedHeight({ children }: { readonly children: ReactNode }) {
|
||||
}, [heightState.height, heightState.isClipping]);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (holdHeight) return;
|
||||
const element = contentRef.current;
|
||||
if (!element) return;
|
||||
let firstFrameId: number | null = null;
|
||||
@@ -67,7 +75,7 @@ export function AnimatedHeight({ children }: { readonly children: ReactNode }) {
|
||||
resizeObserver.disconnect();
|
||||
cancelPendingFrames();
|
||||
};
|
||||
}, []);
|
||||
}, [holdHeight]);
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -85,7 +93,9 @@ export function AnimatedHeight({ children }: { readonly children: ReactNode }) {
|
||||
);
|
||||
}}
|
||||
>
|
||||
<div ref={contentRef}>{children}</div>
|
||||
<div ref={contentRef} style={holdHeight ? { height: "100%" } : undefined}>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import { PlusIcon } from "lucide-react";
|
||||
import { useCallback } from "react";
|
||||
|
||||
import { openCommandPalette } from "../commandPaletteBus";
|
||||
import { Button } from "./ui/button";
|
||||
import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "./ui/empty";
|
||||
import { SidebarInset } from "./ui/sidebar";
|
||||
|
||||
export function NoProjectsHero() {
|
||||
const openAddProject = useCallback(() => openCommandPalette({ open: "add-project" }), []);
|
||||
|
||||
return (
|
||||
<SidebarInset className="h-dvh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground">
|
||||
<div className="flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-background">
|
||||
<Empty className="flex-1">
|
||||
<div className="w-full max-w-lg px-8 py-12">
|
||||
<EmptyHeader className="max-w-none">
|
||||
<EmptyTitle className="text-foreground text-2xl sm:text-3xl">
|
||||
What should we work on?
|
||||
</EmptyTitle>
|
||||
<EmptyDescription className="mt-2 text-sm text-muted-foreground/78">
|
||||
Add a project to start your first thread.
|
||||
</EmptyDescription>
|
||||
<div className="mt-6 flex justify-center">
|
||||
<Button size="sm" onClick={openAddProject}>
|
||||
<PlusIcon className="size-4" />
|
||||
Add project
|
||||
</Button>
|
||||
</div>
|
||||
</EmptyHeader>
|
||||
</div>
|
||||
</Empty>
|
||||
</div>
|
||||
</SidebarInset>
|
||||
);
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import type { AtomCommandResult } from "@t3tools/client-runtime/state/runtime";
|
||||
import { EnvironmentId } from "@t3tools/contracts";
|
||||
import * as Option from "effect/Option";
|
||||
import { AsyncResult } from "effect/unstable/reactivity";
|
||||
import { act, type ButtonHTMLAttributes } from "react";
|
||||
import { act, useState, type ButtonHTMLAttributes, type ReactNode } from "react";
|
||||
import { create, type ReactTestRenderer } from "react-test-renderer";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
|
||||
|
||||
@@ -42,6 +42,25 @@ vi.mock("~/state/environments", async () => {
|
||||
return { useRelayEnvironmentDiscovery: () => useSyncExternalStore(subscribe, read, read) };
|
||||
});
|
||||
vi.mock("../ConnectionStatusDot", () => ({ ConnectionStatusDot: () => null }));
|
||||
vi.mock("../ui/tooltip", () => ({
|
||||
Tooltip: ({ children }: { children: ReactNode }) => children,
|
||||
TooltipTrigger: ({ children }: { children: ReactNode }) => <span>{children}</span>,
|
||||
TooltipPopup: () => null,
|
||||
}));
|
||||
vi.mock("../ui/checkbox", () => ({
|
||||
Checkbox: (props: {
|
||||
checked: boolean;
|
||||
disabled: boolean;
|
||||
onCheckedChange: (checked: boolean) => void;
|
||||
}) => (
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={props.checked}
|
||||
disabled={props.disabled}
|
||||
onChange={(event) => props.onCheckedChange(event.target.checked)}
|
||||
/>
|
||||
),
|
||||
}));
|
||||
vi.mock("../ui/button", () => ({
|
||||
Button: ({ children, ...props }: ButtonHTMLAttributes<HTMLButtonElement>) => (
|
||||
<button {...props}>{children}</button>
|
||||
@@ -118,6 +137,7 @@ beforeEach(() => {
|
||||
error: Option.none(),
|
||||
};
|
||||
discovery.listEnvironments.mockReset().mockResolvedValue(new Map());
|
||||
discovery.register.mockReset().mockResolvedValue(AsyncResult.success(undefined));
|
||||
discovery.refresh.mockReset().mockImplementation(async () => {
|
||||
publish({ environments: new Map(), refreshing: true, offline: false, error: Option.none() });
|
||||
const environments = await discovery.listEnvironments();
|
||||
@@ -133,6 +153,71 @@ afterEach(async () => {
|
||||
});
|
||||
|
||||
describe("cloud onboarding discovery", () => {
|
||||
it("signals that the section can expand after initial discovery settles", async () => {
|
||||
let finishDiscovery!: (environments: DiscoveredEnvironments) => void;
|
||||
discovery.listEnvironments.mockReturnValue(
|
||||
new Promise((resolve) => {
|
||||
finishDiscovery = resolve;
|
||||
}),
|
||||
);
|
||||
const onDiscoveryReady = vi.fn();
|
||||
await act(async () => {
|
||||
renderer = create(
|
||||
<CloudEnvironmentConnectRows
|
||||
primaryEnvironmentId={null}
|
||||
savedEnvironments={[]}
|
||||
onDiscoveryReady={onDiscoveryReady}
|
||||
/>,
|
||||
);
|
||||
});
|
||||
expect(onDiscoveryReady).not.toHaveBeenCalled();
|
||||
await act(async () => {
|
||||
finishDiscovery(linkedMachines);
|
||||
});
|
||||
expect(onDiscoveryReady).toHaveBeenCalledTimes(1);
|
||||
expect(renderer!.root.findByType("button").children).toEqual(["Connect"]);
|
||||
});
|
||||
|
||||
it("connects and selects discovered computers by default without overwriting deselection", async () => {
|
||||
discovery.listEnvironments.mockResolvedValue(linkedMachines);
|
||||
const autoSelectedComputers = new Set<EnvironmentId>();
|
||||
function Setup() {
|
||||
const [selectedIds, setSelectedIds] = useState<ReadonlySet<EnvironmentId>>(new Set());
|
||||
return (
|
||||
<CloudEnvironmentConnectRows
|
||||
primaryEnvironmentId={null}
|
||||
savedEnvironments={[]}
|
||||
showSavedEnvironments
|
||||
selection={{
|
||||
autoSelectedComputers,
|
||||
selectedIds,
|
||||
onChange: (id, checked) =>
|
||||
setSelectedIds((current) => {
|
||||
const next = new Set(current);
|
||||
if (checked) next.add(id);
|
||||
else next.delete(id);
|
||||
return next;
|
||||
}),
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
await act(async () => {
|
||||
renderer = create(<Setup />);
|
||||
});
|
||||
|
||||
expect(discovery.register).toHaveBeenCalledTimes(1);
|
||||
expect(renderer!.root.findByType("input").props.checked).toBe(true);
|
||||
await act(async () => {
|
||||
await renderer!.root.findByType("input").props.onChange({ target: { checked: false } });
|
||||
});
|
||||
await act(async () => {
|
||||
publish({ ...discovery.state!, environments: new Map(linkedMachines) });
|
||||
});
|
||||
expect(renderer!.root.findByType("input").props.checked).toBe(false);
|
||||
expect(discovery.register).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("shows a newly linked computer without remounting and stops polling once found", async () => {
|
||||
discovery.listEnvironments
|
||||
.mockResolvedValueOnce(new Map())
|
||||
@@ -152,6 +237,31 @@ describe("cloud onboarding discovery", () => {
|
||||
expect(discovery.listEnvironments).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("keeps a discovered computer visible when it is added to the browser", async () => {
|
||||
discovery.listEnvironments.mockResolvedValue(linkedMachines);
|
||||
await mount();
|
||||
expect(renderer!.root.findByType("button").children).toEqual(["Connect"]);
|
||||
await act(async () => {
|
||||
renderer!.update(
|
||||
<CloudEnvironmentConnectRows
|
||||
primaryEnvironmentId={null}
|
||||
savedEnvironments={[
|
||||
{
|
||||
environmentId: newMachineId,
|
||||
connection: { phase: "connected", error: null, traceId: null },
|
||||
},
|
||||
]}
|
||||
showSavedEnvironments
|
||||
refreshWhileEmpty
|
||||
/>,
|
||||
);
|
||||
});
|
||||
expect(renderer!.root.findAllByType("p").map((node) => node.children)).toContainEqual([
|
||||
"Work laptop",
|
||||
]);
|
||||
expect(renderer!.root.findByType("button").children).toEqual(["Connected"]);
|
||||
});
|
||||
|
||||
it("waits while hidden and refreshes immediately when visible again", async () => {
|
||||
page.visibilityState = "hidden";
|
||||
await mount();
|
||||
|
||||
@@ -20,9 +20,11 @@ import { useRelayEnvironmentDiscovery } from "~/state/environments";
|
||||
import { useAtomCommand } from "~/state/use-atom-command";
|
||||
import { ConnectionStatusDot } from "../ConnectionStatusDot";
|
||||
import { ITEM_ROW_CLASSNAME, ITEM_ROW_INNER_CLASSNAME } from "../settings/itemRows";
|
||||
import { Checkbox } from "../ui/checkbox";
|
||||
import { Button } from "../ui/button";
|
||||
import { Skeleton } from "../ui/skeleton";
|
||||
import { toastManager } from "../ui/toast";
|
||||
import { Tooltip, TooltipTrigger, TooltipPopup } from "../ui/tooltip";
|
||||
import { presentSavedCloudEnvironmentConnection } from "./cloudEnvironmentConnectionPresentation";
|
||||
|
||||
const EMPTY_DISCOVERY_REFRESH_INTERVAL_MS = 5_000;
|
||||
@@ -59,12 +61,20 @@ export function CloudEnvironmentConnectRows({
|
||||
showSavedEnvironments = false,
|
||||
refreshWhileEmpty = false,
|
||||
empty = null,
|
||||
selection,
|
||||
onDiscoveryReady,
|
||||
}: {
|
||||
readonly primaryEnvironmentId: EnvironmentId | null;
|
||||
readonly savedEnvironments: ReadonlyArray<SavedCloudEnvironmentConnection>;
|
||||
readonly showSavedEnvironments?: boolean;
|
||||
readonly refreshWhileEmpty?: boolean;
|
||||
readonly empty?: ReactNode;
|
||||
readonly onDiscoveryReady?: () => void;
|
||||
readonly selection?: {
|
||||
readonly autoSelectedComputers?: Set<EnvironmentId>;
|
||||
readonly selectedIds: ReadonlySet<EnvironmentId>;
|
||||
readonly onChange: (environmentId: EnvironmentId, selected: boolean) => void;
|
||||
};
|
||||
}) {
|
||||
const environmentsState = useRelayEnvironmentDiscovery();
|
||||
const registerEnvironment = useAtomCommand(environmentCatalog.register, {
|
||||
@@ -89,33 +99,43 @@ export function CloudEnvironmentConnectRows({
|
||||
),
|
||||
[registerEnvironment],
|
||||
);
|
||||
const [connectingEnvironmentId, setConnectingEnvironmentId] = useState<EnvironmentId | null>(
|
||||
null,
|
||||
);
|
||||
const [connectingEnvironmentIds, setConnectingEnvironmentIds] = useState<
|
||||
ReadonlySet<EnvironmentId>
|
||||
>(new Set());
|
||||
const savedById = new Map(
|
||||
savedEnvironments.map((environment) => [environment.environmentId, environment]),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!refreshWhileEmpty || document.visibilityState === "visible") {
|
||||
void refreshRelayEnvironments();
|
||||
let active = true;
|
||||
if (onDiscoveryReady || !refreshWhileEmpty || document.visibilityState === "visible") {
|
||||
void refreshRelayEnvironments().then(() => {
|
||||
if (active) onDiscoveryReady?.();
|
||||
});
|
||||
}
|
||||
}, [refreshRelayEnvironments, refreshWhileEmpty]);
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, [refreshRelayEnvironments, refreshWhileEmpty, onDiscoveryReady]);
|
||||
|
||||
const connectEnvironment = async (environment: RelayClientEnvironmentRecord) => {
|
||||
setConnectingEnvironmentId(environment.environmentId);
|
||||
setConnectingEnvironmentIds((current) => new Set([...current, environment.environmentId]));
|
||||
const result = await connectRelayEnvironment(environment);
|
||||
setConnectingEnvironmentId(null);
|
||||
setConnectingEnvironmentIds((current) => {
|
||||
const next = new Set(current);
|
||||
next.delete(environment.environmentId);
|
||||
return next;
|
||||
});
|
||||
if (result._tag === "Success") {
|
||||
toastManager.add({
|
||||
type: "success",
|
||||
title: "Environment added",
|
||||
description: `Connecting to ${environment.label} through T3 Connect.`,
|
||||
});
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
if (isAtomCommandInterrupted(result)) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
const cause = squashAtomCommandFailure(result);
|
||||
const message =
|
||||
@@ -135,6 +155,7 @@ export function CloudEnvironmentConnectRows({
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
return false;
|
||||
};
|
||||
|
||||
const visibleEnvironments = [...environmentsState.environments.values()].filter(
|
||||
@@ -142,6 +163,25 @@ export function CloudEnvironmentConnectRows({
|
||||
environment.environmentId !== primaryEnvironmentId &&
|
||||
(showSavedEnvironments || !savedById.has(environment.environmentId)),
|
||||
);
|
||||
const selectNewComputers = useEffectEvent(() => {
|
||||
const seen = selection?.autoSelectedComputers;
|
||||
if (!selection || !seen) return;
|
||||
for (const { environment } of visibleEnvironments) {
|
||||
const id = environment.environmentId;
|
||||
if (seen.has(id)) continue;
|
||||
seen.add(id);
|
||||
selection.onChange(id, true);
|
||||
if (!savedById.has(id)) {
|
||||
void connectEnvironment(environment).then((connected) => {
|
||||
if (!connected) selection.onChange(id, false);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
useEffect(() => {
|
||||
selectNewComputers();
|
||||
}, [environmentsState.environments]);
|
||||
|
||||
// Discovery clears its list on refresh, so poll only until a machine appears.
|
||||
const shouldRefreshWhileEmpty =
|
||||
refreshWhileEmpty && visibleEnvironments.length === 0 && !environmentsState.offline;
|
||||
@@ -254,6 +294,48 @@ export function CloudEnvironmentConnectRows({
|
||||
: availability === "checking"
|
||||
? "Available · Checking relay status…"
|
||||
: (Option.getOrNull(error)?.message ?? "Available · Relay status unavailable");
|
||||
if (selection) {
|
||||
return (
|
||||
<label
|
||||
key={environment.environmentId}
|
||||
className="flex cursor-pointer items-center gap-3 rounded-lg border border-border bg-background px-3 py-2.5 has-disabled:cursor-default"
|
||||
>
|
||||
<Checkbox
|
||||
checked={selection.selectedIds.has(environment.environmentId)}
|
||||
disabled={connectingEnvironmentIds.has(environment.environmentId)}
|
||||
onCheckedChange={async (checked) => {
|
||||
selection.onChange(environment.environmentId, checked);
|
||||
if (checked && !savedEnvironment) {
|
||||
const connected = await connectEnvironment(environment);
|
||||
if (!connected) selection.onChange(environment.environmentId, false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<span className="min-w-0 flex-1 truncate text-sm font-medium">{environment.label}</span>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={<span tabIndex={0} />}
|
||||
className={cn(
|
||||
"max-w-[45%] shrink-0 truncate text-xs",
|
||||
savedConnection?.tone === "error" ? "text-destructive" : "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{connectingEnvironmentIds.has(environment.environmentId)
|
||||
? "Connecting…"
|
||||
: (savedConnection?.buttonLabel ??
|
||||
(availability === "online"
|
||||
? "Available"
|
||||
: availability === "offline"
|
||||
? "Offline"
|
||||
: availability === "error"
|
||||
? "Unavailable"
|
||||
: "Checking…"))}
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup className="max-w-80 break-words">{statusText}</TooltipPopup>
|
||||
</Tooltip>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div key={environment.environmentId} className={ITEM_ROW_CLASSNAME}>
|
||||
<div className={ITEM_ROW_INNER_CLASSNAME}>
|
||||
@@ -301,10 +383,10 @@ export function CloudEnvironmentConnectRows({
|
||||
) : (
|
||||
<Button
|
||||
size="sm"
|
||||
disabled={connectingEnvironmentId !== null}
|
||||
disabled={connectingEnvironmentIds.size > 0}
|
||||
onClick={() => void connectEnvironment(environment)}
|
||||
>
|
||||
{connectingEnvironmentId === environment.environmentId ? "Connecting…" : "Connect"}
|
||||
{connectingEnvironmentIds.has(environment.environmentId) ? "Connecting…" : "Connect"}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -2,14 +2,13 @@ import { RefreshIcon } from "~/components/ui/refresh-icon";
|
||||
import { useAtomValue } from "@effect/atom-react";
|
||||
import { useLocation, useNavigate } from "@tanstack/react-router";
|
||||
import { Atom } from "effect/unstable/reactivity";
|
||||
import { useEffect, useLayoutEffect, useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import {
|
||||
ensureClientSettingsHydrated,
|
||||
useClientSettings,
|
||||
useClientSettingsHydrationStatus,
|
||||
} from "../../hooks/useSettings";
|
||||
import { mountOnboardingTheme } from "../../hooks/useTheme";
|
||||
import { useCompleteOnboarding } from "../../onboarding/firstRun";
|
||||
import {
|
||||
isFirstRunWorkspaceProvenanceAuthoritative,
|
||||
@@ -104,13 +103,6 @@ export function FirstRunGate({
|
||||
}));
|
||||
const { decision, stalled } = gateState;
|
||||
const settingsReadFailed = hydrationStatus === "failed" || hydrationStatus === "retrying";
|
||||
const ownsOnboardingTheme = settingsReadFailed || stalled || decision === "wizard";
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (!ownsOnboardingTheme) return;
|
||||
return mountOnboardingTheme();
|
||||
}, [ownsOnboardingTheme]);
|
||||
|
||||
// A workspace still counts as fresh when its only content is the server's
|
||||
// own cwd auto-bootstrap: web mode creates a project + thread from cwd at
|
||||
// startup (`autoBootstrapProjectFromCwd` defaults on there), so "no
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -29,7 +29,7 @@ import { RadioGroup } from "../ui/radio-group";
|
||||
import { toastManager } from "../ui/toast";
|
||||
import { DRIVER_OPTION_BY_VALUE, DRIVER_OPTIONS } from "./providerDriverMeta";
|
||||
import { ProviderSettingsForm, deriveProviderSettingsFields } from "./ProviderSettingsForm";
|
||||
import { AnimatedHeight } from "../AnimatedHeight";
|
||||
import { WizardPanel } from "../ui/wizard";
|
||||
import {
|
||||
ADD_PROVIDER_WIZARD_STEPS,
|
||||
resolveWizardNavigation,
|
||||
@@ -246,173 +246,168 @@ export function AddProviderInstanceDialog({
|
||||
/>
|
||||
</DialogHeader>
|
||||
|
||||
<div
|
||||
data-slot="dialog-panel"
|
||||
className="space-y-4 bg-zinc-25/80 px-6 py-5 ring-1 ring-black/5 dark:bg-white/2 dark:ring-white/5"
|
||||
>
|
||||
<AnimatedHeight>
|
||||
<div className={cn("grid gap-2", wizardStep !== 0 && "hidden")}>
|
||||
<div id="add-instance-driver-label" className="text-sm font-medium text-foreground">
|
||||
Driver
|
||||
</div>
|
||||
<RadioGroup
|
||||
value={driver}
|
||||
onValueChange={(value) => setDriver(ProviderDriverKind.make(value))}
|
||||
aria-labelledby="add-instance-driver-label"
|
||||
className="grid grid-cols-1 gap-2 sm:grid-cols-2"
|
||||
>
|
||||
{DRIVER_OPTIONS.map((option) => {
|
||||
const IconComponent = option.icon;
|
||||
return (
|
||||
<RadioPrimitive.Root
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
className="relative flex cursor-pointer items-center gap-3 rounded-lg bg-card px-3 py-3 text-left text-muted-foreground outline-none ring-1 ring-black/5 hover:bg-zinc-50 focus-visible:ring-2 focus-visible:ring-ring data-checked:bg-primary/8 data-checked:text-foreground data-checked:ring-2 data-checked:ring-primary data-checked:hover:bg-primary/8 dark:bg-white/3 dark:ring-white/5 dark:hover:bg-white/5 dark:data-checked:bg-primary/15 dark:data-checked:ring-primary dark:data-checked:hover:bg-primary/15"
|
||||
>
|
||||
<IconComponent className="size-4 shrink-0" aria-hidden />
|
||||
<span className="min-w-0 flex-1 truncate text-sm font-medium text-foreground">
|
||||
{option.label}
|
||||
</span>
|
||||
<RadioPrimitive.Indicator
|
||||
className="grid size-5 shrink-0 place-items-center rounded-full bg-primary text-primary-foreground"
|
||||
aria-hidden
|
||||
>
|
||||
<CheckIcon className="size-3.5 shrink-0" />
|
||||
</RadioPrimitive.Indicator>
|
||||
{option.badgeLabel ? (
|
||||
<Badge variant="warning" size="sm">
|
||||
{option.badgeLabel}
|
||||
</Badge>
|
||||
) : null}
|
||||
</RadioPrimitive.Root>
|
||||
);
|
||||
})}
|
||||
{COMING_SOON_DRIVER_OPTIONS.map((option) => {
|
||||
const IconComponent = option.icon;
|
||||
return (
|
||||
<RadioPrimitive.Root
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
disabled
|
||||
className={cn(
|
||||
"relative flex cursor-not-allowed items-center gap-3 rounded-lg bg-card/60 px-3 py-3 text-left opacity-55 outline-none ring-1 ring-black/5 dark:bg-white/2 dark:ring-white/5",
|
||||
)}
|
||||
>
|
||||
<IconComponent
|
||||
className="size-4 shrink-0 text-muted-foreground"
|
||||
aria-hidden
|
||||
/>
|
||||
<span className="min-w-0 flex-1 truncate text-sm font-medium text-foreground">
|
||||
{option.label}
|
||||
</span>
|
||||
<Badge variant="warning" size="sm">
|
||||
Coming Soon
|
||||
</Badge>
|
||||
</RadioPrimitive.Root>
|
||||
);
|
||||
})}
|
||||
</RadioGroup>
|
||||
<WizardPanel>
|
||||
<div className={cn("grid gap-2", wizardStep !== 0 && "hidden")}>
|
||||
<div id="add-instance-driver-label" className="text-sm font-medium text-foreground">
|
||||
Driver
|
||||
</div>
|
||||
|
||||
<label className={cn("grid gap-2", wizardStep !== 1 && "hidden")}>
|
||||
<span className="text-xs font-medium text-foreground">Label</span>
|
||||
<Input
|
||||
className="bg-background"
|
||||
placeholder="e.g. Work"
|
||||
value={label}
|
||||
onChange={(event) => setLabel(event.target.value)}
|
||||
/>
|
||||
<span className="text-[11px] text-muted-foreground">
|
||||
Shown in the provider list. Optional.
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<label className={cn("grid gap-2", wizardStep !== 1 && "hidden")}>
|
||||
<span className="text-xs font-medium text-foreground">Instance ID</span>
|
||||
<Input
|
||||
className="bg-background"
|
||||
placeholder={`${driver}_work`}
|
||||
value={instanceId}
|
||||
onChange={(event) => {
|
||||
setInstanceIdOverride(event.target.value);
|
||||
}}
|
||||
aria-invalid={showInstanceIdError}
|
||||
/>
|
||||
{showInstanceIdError ? (
|
||||
<span className="text-[11px] text-destructive">{instanceIdError}</span>
|
||||
) : (
|
||||
<span className="text-[11px] text-muted-foreground">
|
||||
Routing key used by threads and sessions. Letters, digits, '-', or '_'.
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
|
||||
<div className={cn("grid gap-2", wizardStep !== 1 && "hidden")}>
|
||||
<span className="text-xs font-medium text-foreground">Accent color</span>
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-2">
|
||||
<input
|
||||
type="color"
|
||||
value={normalizeProviderAccentColor(accentColor) ?? PROVIDER_ACCENT_SWATCHES[0]}
|
||||
onChange={(event) => setAccentColor(event.target.value)}
|
||||
aria-label="Provider instance accent color"
|
||||
className="h-8 w-10 cursor-pointer rounded-xl border border-input bg-background p-0.5"
|
||||
/>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{PROVIDER_ACCENT_SWATCHES.map((swatch) => {
|
||||
const selected = accentColor.toLowerCase() === swatch;
|
||||
return (
|
||||
<button
|
||||
key={swatch}
|
||||
type="button"
|
||||
className={cn(
|
||||
"size-6 cursor-pointer rounded-full border transition",
|
||||
selected
|
||||
? "scale-110 border-foreground ring-2 ring-ring ring-offset-1 ring-offset-background"
|
||||
: "border-black/10 hover:scale-105 dark:border-white/20",
|
||||
)}
|
||||
style={{ backgroundColor: swatch }}
|
||||
onClick={() => setAccentColor(swatch)}
|
||||
aria-label={`Use ${swatch} accent`}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{accentColor ? (
|
||||
<Button
|
||||
type="button"
|
||||
size="xs"
|
||||
variant="ghost"
|
||||
className="text-muted-foreground"
|
||||
onClick={() => setAccentColor("")}
|
||||
<RadioGroup
|
||||
value={driver}
|
||||
onValueChange={(value) => setDriver(ProviderDriverKind.make(value))}
|
||||
aria-labelledby="add-instance-driver-label"
|
||||
className="grid grid-cols-1 gap-2 sm:grid-cols-2"
|
||||
>
|
||||
{DRIVER_OPTIONS.map((option) => {
|
||||
const IconComponent = option.icon;
|
||||
return (
|
||||
<RadioPrimitive.Root
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
className="relative flex cursor-pointer items-center gap-3 rounded-lg bg-card px-3 py-3 text-left text-muted-foreground outline-none ring-1 ring-black/5 hover:bg-zinc-50 focus-visible:ring-2 focus-visible:ring-ring data-checked:bg-primary/8 data-checked:text-foreground data-checked:ring-2 data-checked:ring-primary data-checked:hover:bg-primary/8 dark:bg-white/3 dark:ring-white/5 dark:hover:bg-white/5 dark:data-checked:bg-primary/15 dark:data-checked:ring-primary dark:data-checked:hover:bg-primary/15"
|
||||
>
|
||||
Clear
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
<span className="text-[11px] text-muted-foreground">
|
||||
Optional marker shown in the picker.
|
||||
</span>
|
||||
</div>
|
||||
<IconComponent className="size-4 shrink-0" aria-hidden />
|
||||
<span className="min-w-0 flex-1 truncate text-sm font-medium text-foreground">
|
||||
{option.label}
|
||||
</span>
|
||||
<RadioPrimitive.Indicator
|
||||
className="grid size-5 shrink-0 place-items-center rounded-full bg-primary text-primary-foreground"
|
||||
aria-hidden
|
||||
>
|
||||
<CheckIcon className="size-3.5 shrink-0" />
|
||||
</RadioPrimitive.Indicator>
|
||||
{option.badgeLabel ? (
|
||||
<Badge variant="warning" size="sm">
|
||||
{option.badgeLabel}
|
||||
</Badge>
|
||||
) : null}
|
||||
</RadioPrimitive.Root>
|
||||
);
|
||||
})}
|
||||
{COMING_SOON_DRIVER_OPTIONS.map((option) => {
|
||||
const IconComponent = option.icon;
|
||||
return (
|
||||
<RadioPrimitive.Root
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
disabled
|
||||
className={cn(
|
||||
"relative flex cursor-not-allowed items-center gap-3 rounded-lg bg-card/60 px-3 py-3 text-left opacity-55 outline-none ring-1 ring-black/5 dark:bg-white/2 dark:ring-white/5",
|
||||
)}
|
||||
>
|
||||
<IconComponent
|
||||
className="size-4 shrink-0 text-muted-foreground"
|
||||
aria-hidden
|
||||
/>
|
||||
<span className="min-w-0 flex-1 truncate text-sm font-medium text-foreground">
|
||||
{option.label}
|
||||
</span>
|
||||
<Badge variant="warning" size="sm">
|
||||
Coming Soon
|
||||
</Badge>
|
||||
</RadioPrimitive.Root>
|
||||
);
|
||||
})}
|
||||
</RadioGroup>
|
||||
</div>
|
||||
|
||||
{driverSettingsFields.length > 0 ? (
|
||||
<div className={cn("grid gap-4", wizardStep !== 2 && "hidden")}>
|
||||
<ProviderSettingsForm
|
||||
definition={driverOption}
|
||||
value={configDraft}
|
||||
idPrefix={`add-provider-${driver}`}
|
||||
variant="dialog"
|
||||
onChange={setConfigDraft}
|
||||
/>
|
||||
<label className={cn("grid gap-2", wizardStep !== 1 && "hidden")}>
|
||||
<span className="text-xs font-medium text-foreground">Label</span>
|
||||
<Input
|
||||
className="bg-background"
|
||||
placeholder="e.g. Work"
|
||||
value={label}
|
||||
onChange={(event) => setLabel(event.target.value)}
|
||||
/>
|
||||
<span className="text-[11px] text-muted-foreground">
|
||||
Shown in the provider list. Optional.
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<label className={cn("grid gap-2", wizardStep !== 1 && "hidden")}>
|
||||
<span className="text-xs font-medium text-foreground">Instance ID</span>
|
||||
<Input
|
||||
className="bg-background"
|
||||
placeholder={`${driver}_work`}
|
||||
value={instanceId}
|
||||
onChange={(event) => {
|
||||
setInstanceIdOverride(event.target.value);
|
||||
}}
|
||||
aria-invalid={showInstanceIdError}
|
||||
/>
|
||||
{showInstanceIdError ? (
|
||||
<span className="text-[11px] text-destructive">{instanceIdError}</span>
|
||||
) : (
|
||||
<span className="text-[11px] text-muted-foreground">
|
||||
Routing key used by threads and sessions. Letters, digits, '-', or '_'.
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
|
||||
<div className={cn("grid gap-2", wizardStep !== 1 && "hidden")}>
|
||||
<span className="text-xs font-medium text-foreground">Accent color</span>
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-2">
|
||||
<input
|
||||
type="color"
|
||||
value={normalizeProviderAccentColor(accentColor) ?? PROVIDER_ACCENT_SWATCHES[0]}
|
||||
onChange={(event) => setAccentColor(event.target.value)}
|
||||
aria-label="Provider instance accent color"
|
||||
className="h-8 w-10 cursor-pointer rounded-xl border border-input bg-background p-0.5"
|
||||
/>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{PROVIDER_ACCENT_SWATCHES.map((swatch) => {
|
||||
const selected = accentColor.toLowerCase() === swatch;
|
||||
return (
|
||||
<button
|
||||
key={swatch}
|
||||
type="button"
|
||||
className={cn(
|
||||
"size-6 cursor-pointer rounded-full border transition",
|
||||
selected
|
||||
? "scale-110 border-foreground ring-2 ring-ring ring-offset-1 ring-offset-background"
|
||||
: "border-black/10 hover:scale-105 dark:border-white/20",
|
||||
)}
|
||||
style={{ backgroundColor: swatch }}
|
||||
onClick={() => setAccentColor(swatch)}
|
||||
aria-label={`Use ${swatch} accent`}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : wizardStep === 2 ? (
|
||||
<div className="grid gap-2">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
This driver has no required configuration. You can add the instance now.
|
||||
</p>
|
||||
</div>
|
||||
) : null}
|
||||
</AnimatedHeight>
|
||||
</div>
|
||||
{accentColor ? (
|
||||
<Button
|
||||
type="button"
|
||||
size="xs"
|
||||
variant="ghost"
|
||||
className="text-muted-foreground"
|
||||
onClick={() => setAccentColor("")}
|
||||
>
|
||||
Clear
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
<span className="text-[11px] text-muted-foreground">
|
||||
Optional marker shown in the picker.
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{driverSettingsFields.length > 0 ? (
|
||||
<div className={cn("grid gap-4", wizardStep !== 2 && "hidden")}>
|
||||
<ProviderSettingsForm
|
||||
definition={driverOption}
|
||||
value={configDraft}
|
||||
idPrefix={`add-provider-${driver}`}
|
||||
variant="dialog"
|
||||
onChange={setConfigDraft}
|
||||
/>
|
||||
</div>
|
||||
) : wizardStep === 2 ? (
|
||||
<div className="grid gap-2">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
This driver has no required configuration. You can add the instance now.
|
||||
</p>
|
||||
</div>
|
||||
) : null}
|
||||
</WizardPanel>
|
||||
|
||||
<DialogFooter variant="bare">
|
||||
<Button
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Children, isValidElement, type ReactElement } from "react";
|
||||
import { describe, expect, it, vi } from "vite-plus/test";
|
||||
|
||||
import { WizardSteps } from "../ui/wizard";
|
||||
import { ADD_PROVIDER_WIZARD_STEPS } from "./AddProviderInstanceDialog.logic";
|
||||
import { AddProviderInstanceWizardSteps } from "./AddProviderInstanceWizardSteps";
|
||||
|
||||
@@ -25,7 +26,7 @@ function renderStepButtons(
|
||||
onNavigation,
|
||||
});
|
||||
|
||||
return Children.toArray(header.props.children)
|
||||
return Children.toArray(WizardSteps(header.props).props.children)
|
||||
.filter((child): child is ReactElement<StepListItemProps> => isValidElement(child))
|
||||
.map((item) => item.props.children);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { CheckIcon } from "lucide-react";
|
||||
|
||||
import { cn } from "../../lib/utils";
|
||||
import { WizardSteps } from "../ui/wizard";
|
||||
import {
|
||||
ADD_PROVIDER_WIZARD_STEPS,
|
||||
resolveWizardNavigation,
|
||||
@@ -21,53 +19,17 @@ export function AddProviderInstanceWizardSteps({
|
||||
onNavigation,
|
||||
}: AddProviderInstanceWizardStepsProps) {
|
||||
return (
|
||||
<ol
|
||||
className="grid grid-cols-3 gap-1 rounded-xl bg-zinc-25 p-1 ring-1 ring-black/5 dark:bg-white/4 dark:ring-white/5"
|
||||
role="list"
|
||||
>
|
||||
{ADD_PROVIDER_WIZARD_STEPS.map((step, index) => (
|
||||
<li key={step} className="min-w-0">
|
||||
<button
|
||||
type="button"
|
||||
className={cn(
|
||||
"flex w-full min-w-0 cursor-pointer items-center gap-2 rounded-lg px-2.5 py-2 text-left outline-none hover:bg-card focus-visible:ring-2 focus-visible:ring-ring max-sm:justify-center max-sm:px-2",
|
||||
index === currentStep &&
|
||||
"bg-card text-foreground shadow-xs ring-1 ring-black/5 hover:bg-card dark:shadow-none dark:ring-white/5",
|
||||
)}
|
||||
aria-current={index === currentStep ? "step" : undefined}
|
||||
aria-label={`${step}, step ${index + 1}${index < currentStep && summaries[index] ? `, ${summaries[index]}` : ""}`}
|
||||
onClick={() =>
|
||||
onNavigation(
|
||||
resolveWizardNavigation(currentStep, index, ADD_PROVIDER_WIZARD_STEPS.length, {
|
||||
instanceIdError,
|
||||
}),
|
||||
)
|
||||
}
|
||||
>
|
||||
<span
|
||||
className={cn(
|
||||
"grid size-5 shrink-0 place-items-center rounded-full text-sm font-medium ring-1",
|
||||
index < currentStep
|
||||
? "bg-primary text-primary-foreground ring-primary"
|
||||
: index === currentStep
|
||||
? "bg-primary/10 text-primary ring-primary/30"
|
||||
: "bg-card text-muted-foreground ring-black/10 dark:bg-white/5 dark:ring-white/10",
|
||||
)}
|
||||
aria-hidden
|
||||
>
|
||||
{index < currentStep ? <CheckIcon className="size-4 shrink-0" /> : index + 1}
|
||||
</span>
|
||||
<span
|
||||
className={cn(
|
||||
"min-w-0 truncate text-sm font-medium max-sm:hidden",
|
||||
index === currentStep ? "text-foreground" : "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{step}
|
||||
</span>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
<WizardSteps
|
||||
steps={ADD_PROVIDER_WIZARD_STEPS}
|
||||
currentStep={currentStep}
|
||||
summaries={summaries}
|
||||
onStepChange={(requestedStep) =>
|
||||
onNavigation(
|
||||
resolveWizardNavigation(currentStep, requestedStep, ADD_PROVIDER_WIZARD_STEPS.length, {
|
||||
instanceIdError,
|
||||
}),
|
||||
)
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { CheckIcon } from "lucide-react";
|
||||
import type { ComponentProps } from "react";
|
||||
|
||||
import { cn } from "../../lib/utils";
|
||||
import { AnimatedHeight } from "../AnimatedHeight";
|
||||
|
||||
export function WizardSteps({
|
||||
steps,
|
||||
currentStep,
|
||||
summaries,
|
||||
onStepChange,
|
||||
isStepDisabled,
|
||||
}: {
|
||||
readonly steps: readonly string[];
|
||||
readonly currentStep: number;
|
||||
readonly summaries?: readonly (string | null)[];
|
||||
readonly isStepDisabled?: (step: number) => boolean;
|
||||
readonly onStepChange?: (step: number) => void;
|
||||
}) {
|
||||
const Step = onStepChange ? "button" : "div";
|
||||
return (
|
||||
<ol
|
||||
className="grid auto-cols-fr grid-flow-col gap-1 rounded-xl bg-zinc-25 p-1 ring-1 ring-black/5 dark:bg-white/4 dark:ring-white/5"
|
||||
role="list"
|
||||
aria-label="Setup progress"
|
||||
>
|
||||
{steps.map((step, index) => (
|
||||
<li key={step} className="min-w-0">
|
||||
<Step
|
||||
{...(onStepChange
|
||||
? { type: "button" as const, disabled: isStepDisabled?.(index) }
|
||||
: {})}
|
||||
className={cn(
|
||||
"flex w-full min-w-0 items-center gap-2 rounded-lg px-2.5 py-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring max-sm:justify-center max-sm:px-2",
|
||||
onStepChange &&
|
||||
"cursor-pointer hover:bg-card disabled:cursor-default disabled:hover:bg-transparent",
|
||||
index === currentStep &&
|
||||
"bg-card text-foreground shadow-xs ring-1 ring-black/5 hover:bg-card dark:shadow-none dark:ring-white/5",
|
||||
)}
|
||||
aria-current={index === currentStep ? "step" : undefined}
|
||||
aria-label={`${step}, step ${index + 1}${index < currentStep && summaries?.[index] ? `, ${summaries?.[index]}` : ""}`}
|
||||
onClick={onStepChange ? () => onStepChange(index) : undefined}
|
||||
>
|
||||
<span
|
||||
className={cn(
|
||||
"grid size-5 shrink-0 place-items-center rounded-full text-sm font-medium ring-1",
|
||||
index < currentStep
|
||||
? "bg-primary text-primary-foreground ring-primary"
|
||||
: index === currentStep
|
||||
? "bg-primary/10 text-primary ring-primary/30"
|
||||
: "bg-card text-muted-foreground ring-black/10 dark:bg-white/5 dark:ring-white/10",
|
||||
)}
|
||||
aria-hidden
|
||||
>
|
||||
{index < currentStep ? <CheckIcon className="size-4 shrink-0" /> : index + 1}
|
||||
</span>
|
||||
<span
|
||||
className={cn(
|
||||
"min-w-0 truncate text-sm font-medium max-sm:hidden",
|
||||
index === currentStep ? "text-foreground" : "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{step}
|
||||
</span>
|
||||
</Step>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
);
|
||||
}
|
||||
|
||||
export function WizardPanel({
|
||||
className,
|
||||
children,
|
||||
holdHeight = false,
|
||||
...props
|
||||
}: ComponentProps<"div"> & { readonly holdHeight?: boolean }) {
|
||||
return (
|
||||
<div
|
||||
data-slot="dialog-panel"
|
||||
className={cn(
|
||||
"space-y-4 bg-zinc-25/80 px-6 py-5 ring-1 ring-black/5 dark:bg-white/2 dark:ring-white/5",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<AnimatedHeight holdHeight={holdHeight}>{children}</AnimatedHeight>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -204,204 +204,3 @@ describe("theme failure handling", () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("onboarding theme", () => {
|
||||
it("clears custom palettes and restores the latest selected theme", async () => {
|
||||
const storage = createStorage();
|
||||
const classes = new Set<string>();
|
||||
const styleValues = new Map<string, string>();
|
||||
const root = {
|
||||
classList: {
|
||||
add: (name: string) => classes.add(name),
|
||||
contains: (name: string) => classes.has(name),
|
||||
remove: (name: string) => classes.delete(name),
|
||||
toggle: (name: string, force?: boolean) => {
|
||||
const next = force ?? !classes.has(name);
|
||||
if (next) classes.add(name);
|
||||
else classes.delete(name);
|
||||
return next;
|
||||
},
|
||||
},
|
||||
dataset: {} as Record<string, string>,
|
||||
offsetHeight: 0,
|
||||
style: {
|
||||
backgroundColor: "",
|
||||
removeProperty: (name: string) => styleValues.delete(name),
|
||||
setProperty: (name: string, value: string) => styleValues.set(name, value),
|
||||
},
|
||||
};
|
||||
vi.doMock("react", () => ({
|
||||
useCallback: <A>(callback: A) => callback,
|
||||
useEffect: () => undefined,
|
||||
useSyncExternalStore: (
|
||||
subscribe: (listener: () => void) => () => void,
|
||||
getSnapshot: () => unknown,
|
||||
) => {
|
||||
subscribe(() => undefined);
|
||||
return getSnapshot();
|
||||
},
|
||||
}));
|
||||
vi.stubGlobal("window", {
|
||||
addEventListener: () => undefined,
|
||||
localStorage: storage,
|
||||
matchMedia: () => ({
|
||||
matches: false,
|
||||
addEventListener: () => undefined,
|
||||
removeEventListener: () => undefined,
|
||||
}),
|
||||
removeEventListener: () => undefined,
|
||||
});
|
||||
vi.stubGlobal("document", {
|
||||
body: { style: { backgroundColor: "" } },
|
||||
createElement: () => ({ name: "", setAttribute: () => undefined }),
|
||||
documentElement: root,
|
||||
head: { append: () => undefined },
|
||||
querySelector: () => null,
|
||||
querySelectorAll: () => [],
|
||||
});
|
||||
vi.stubGlobal("getComputedStyle", () => ({
|
||||
backgroundColor: "rgb(0, 0, 0)",
|
||||
getPropertyValue: () => "",
|
||||
}));
|
||||
vi.stubGlobal("requestAnimationFrame", (callback: FrameRequestCallback) => {
|
||||
callback(0);
|
||||
return 0;
|
||||
});
|
||||
|
||||
const { EMBER_THEME, installCustomTheme } = await import("../themePalette");
|
||||
const firstTheme = installCustomTheme({
|
||||
...EMBER_THEME,
|
||||
id: "first-custom",
|
||||
label: "First Custom",
|
||||
});
|
||||
const secondTheme = installCustomTheme({
|
||||
...EMBER_THEME,
|
||||
id: "second-custom",
|
||||
label: "Second Custom",
|
||||
colors: { ...EMBER_THEME.colors, error: "#123456" },
|
||||
});
|
||||
storage.setItem("t3code:theme", firstTheme.id);
|
||||
|
||||
const { mountOnboardingTheme, useTheme } = await import("./useTheme");
|
||||
expect(root.dataset.themeId).toBe(firstTheme.id);
|
||||
expect(styleValues.get("--app-theme-error")).toBe(firstTheme.colors.error);
|
||||
|
||||
const cleanup = mountOnboardingTheme();
|
||||
expect(root.dataset.themeId).toBeUndefined();
|
||||
expect(styleValues.size).toBe(0);
|
||||
|
||||
expect(useTheme().setTheme(secondTheme.id)).toBe(true);
|
||||
expect(root.dataset.themeId).toBeUndefined();
|
||||
expect(styleValues.size).toBe(0);
|
||||
|
||||
cleanup();
|
||||
expect(root.dataset.themeId).toBe(secondTheme.id);
|
||||
expect(styleValues.get("--app-theme-error")).toBe(secondTheme.colors.error);
|
||||
});
|
||||
|
||||
it("follows the saved appearance and restores the latest saved theme", async () => {
|
||||
const storage = createStorage();
|
||||
storage.setItem("t3code:theme", "dark");
|
||||
const classes = new Set<string>();
|
||||
const styleValues = new Map<string, string>();
|
||||
const style = {
|
||||
backgroundColor: "",
|
||||
removeProperty: (name: string) => styleValues.delete(name),
|
||||
setProperty: (name: string, value: string) => styleValues.set(name, value),
|
||||
};
|
||||
const root = {
|
||||
classList: {
|
||||
add: (name: string) => classes.add(name),
|
||||
contains: (name: string) => classes.has(name),
|
||||
remove: (name: string) => classes.delete(name),
|
||||
toggle: (name: string, force?: boolean) => {
|
||||
const next = force ?? !classes.has(name);
|
||||
if (next) classes.add(name);
|
||||
else classes.delete(name);
|
||||
return next;
|
||||
},
|
||||
},
|
||||
dataset: {} as Record<string, string>,
|
||||
offsetHeight: 0,
|
||||
style,
|
||||
};
|
||||
const body = { style: { backgroundColor: "" } };
|
||||
let storageHandler: ((event: StorageEvent) => void) | undefined;
|
||||
const setDesktopTheme = vi.fn().mockResolvedValue(undefined);
|
||||
vi.doMock("react", () => ({
|
||||
useCallback: <A>(callback: A) => callback,
|
||||
useEffect: () => undefined,
|
||||
useSyncExternalStore: (
|
||||
subscribe: (listener: () => void) => () => void,
|
||||
getSnapshot: () => unknown,
|
||||
) => {
|
||||
subscribe(() => undefined);
|
||||
return getSnapshot();
|
||||
},
|
||||
}));
|
||||
vi.stubGlobal("window", {
|
||||
addEventListener: (type: string, listener: (event: StorageEvent) => void) => {
|
||||
if (type === "storage") storageHandler = listener;
|
||||
},
|
||||
localStorage: storage,
|
||||
matchMedia: () => ({
|
||||
matches: false,
|
||||
addEventListener: () => undefined,
|
||||
removeEventListener: () => undefined,
|
||||
}),
|
||||
removeEventListener: () => undefined,
|
||||
desktopBridge: { setTheme: setDesktopTheme },
|
||||
});
|
||||
vi.stubGlobal("document", {
|
||||
body,
|
||||
createElement: () => ({ name: "", setAttribute: () => undefined }),
|
||||
documentElement: root,
|
||||
head: { append: () => undefined },
|
||||
querySelector: () => null,
|
||||
querySelectorAll: () => [],
|
||||
});
|
||||
vi.stubGlobal("getComputedStyle", () => ({
|
||||
backgroundColor:
|
||||
root.dataset.onboardingSurface !== undefined && classes.has("dark")
|
||||
? "rgb(0, 0, 0)"
|
||||
: classes.has("dark")
|
||||
? "rgb(10, 10, 10)"
|
||||
: "rgb(255, 255, 255)",
|
||||
getPropertyValue: () => "",
|
||||
}));
|
||||
vi.stubGlobal("requestAnimationFrame", (callback: FrameRequestCallback) => {
|
||||
callback(0);
|
||||
return 0;
|
||||
});
|
||||
|
||||
const { mountOnboardingTheme, useTheme } = await import("./useTheme");
|
||||
expect(useTheme().resolvedTheme).toBe("dark");
|
||||
const cleanup = mountOnboardingTheme();
|
||||
|
||||
// A dark preference pins the wizard to true black.
|
||||
expect(root.dataset.onboardingSurface).toBe("");
|
||||
expect(classes.has("dark")).toBe(true);
|
||||
expect(root.style.backgroundColor).toBe("#000");
|
||||
expect(body.style.backgroundColor).toBe("#000");
|
||||
expect(useTheme().resolvedTheme).toBe("dark");
|
||||
expect(setDesktopTheme).toHaveBeenLastCalledWith("dark");
|
||||
|
||||
// A light preference switches the wizard to the default light palette.
|
||||
storage.setItem("t3code:theme", "light");
|
||||
storageHandler?.({ key: "t3code:theme" } as StorageEvent);
|
||||
expect(classes.has("dark")).toBe(false);
|
||||
expect(root.style.backgroundColor).toBe("rgb(255, 255, 255)");
|
||||
expect(body.style.backgroundColor).toBe("rgb(255, 255, 255)");
|
||||
expect(useTheme().resolvedTheme).toBe("light");
|
||||
expect(setDesktopTheme).toHaveBeenLastCalledWith("light");
|
||||
|
||||
cleanup();
|
||||
expect(root.dataset.onboardingSurface).toBeUndefined();
|
||||
expect(classes.has("dark")).toBe(false);
|
||||
expect(root.style.backgroundColor).toBe("rgb(255, 255, 255)");
|
||||
expect(body.style.backgroundColor).toBe("rgb(255, 255, 255)");
|
||||
expect(storage.getItem("t3code:theme")).toBe("light");
|
||||
expect(useTheme().resolvedTheme).toBe("light");
|
||||
expect(setDesktopTheme).toHaveBeenLastCalledWith("light");
|
||||
});
|
||||
});
|
||||
@@ -99,13 +99,6 @@ function themeHalvesSignature(halves: ThemeHalves | null): string {
|
||||
return `${halves?.light ?? ""}|${halves?.dark ?? ""}`;
|
||||
}
|
||||
|
||||
function isOnboardingThemeActive(): boolean {
|
||||
return (
|
||||
typeof document !== "undefined" &&
|
||||
document.documentElement.dataset?.onboardingSurface !== undefined
|
||||
);
|
||||
}
|
||||
|
||||
const THEME_COLOR_META_NAME = "theme-color";
|
||||
const DYNAMIC_THEME_COLOR_SELECTOR = `meta[name="${THEME_COLOR_META_NAME}"][data-dynamic-theme-color="true"]`;
|
||||
|
||||
@@ -300,22 +293,15 @@ function resolveBrowserChromeSurface(): HTMLElement {
|
||||
|
||||
export function syncBrowserChromeTheme() {
|
||||
if (typeof document === "undefined" || typeof getComputedStyle === "undefined") return;
|
||||
const onboardingActive = isOnboardingThemeActive();
|
||||
const rootStyles = getComputedStyle(document.documentElement);
|
||||
const themeChromeColor =
|
||||
!onboardingActive && document.documentElement.dataset.themeId
|
||||
? normalizeThemeColor(rootStyles.getPropertyValue("--app-chrome-background"))
|
||||
: null;
|
||||
const themeChromeColor = document.documentElement.dataset.themeId
|
||||
? normalizeThemeColor(rootStyles.getPropertyValue("--app-chrome-background"))
|
||||
: null;
|
||||
const surfaceColor = normalizeThemeColor(
|
||||
getComputedStyle(resolveBrowserChromeSurface()).backgroundColor,
|
||||
);
|
||||
const fallbackColor = normalizeThemeColor(getComputedStyle(document.body).backgroundColor);
|
||||
// Dark onboarding pins a true-black canvas; light onboarding uses the
|
||||
// default light palette and reads it back from the document like the app.
|
||||
const backgroundColor =
|
||||
onboardingActive && document.documentElement.classList.contains("dark")
|
||||
? "#000"
|
||||
: (themeChromeColor ?? surfaceColor ?? fallbackColor);
|
||||
const backgroundColor = themeChromeColor ?? surfaceColor ?? fallbackColor;
|
||||
if (!backgroundColor) return;
|
||||
|
||||
document.documentElement.style.backgroundColor = backgroundColor;
|
||||
@@ -336,13 +322,8 @@ export function syncBrowserChromeTheme() {
|
||||
|
||||
function applyTheme(theme: Theme, { suppressTransitions = false, preservePreview = true } = {}) {
|
||||
if (typeof document === "undefined" || typeof window === "undefined") return;
|
||||
const onboardingActive = isOnboardingThemeActive();
|
||||
// Keep the editor's draft visible until an explicit refresh restores the selection.
|
||||
if (
|
||||
preservePreview &&
|
||||
!onboardingActive &&
|
||||
document.documentElement.dataset?.themeId === THEME_PREVIEW_ID
|
||||
) {
|
||||
if (preservePreview && document.documentElement.dataset?.themeId === THEME_PREVIEW_ID) {
|
||||
return;
|
||||
}
|
||||
const appearanceMode = readAppearanceModePreference(theme);
|
||||
@@ -370,11 +351,7 @@ function applyTheme(theme: Theme, { suppressTransitions = false, preservePreview
|
||||
appearanceMode,
|
||||
themeHalves,
|
||||
);
|
||||
// Onboarding follows the saved light/dark appearance but never applies a
|
||||
// custom palette, so the wizard keeps its fixed neutral tokens.
|
||||
if (!onboardingActive) {
|
||||
applyThemePalette(resolveThemeHalf(theme, themeHalves, resolvedAppearance), resolvedAppearance);
|
||||
}
|
||||
applyThemePalette(resolveThemeHalf(theme, themeHalves, resolvedAppearance), resolvedAppearance);
|
||||
document.documentElement.classList.toggle("dark", resolvedAppearance === "dark");
|
||||
lastAppliedTheme = { theme, systemDark, followSystem, appearanceMode, themeHalves };
|
||||
syncBrowserChromeTheme();
|
||||
@@ -388,32 +365,6 @@ function applyTheme(theme: Theme, { suppressTransitions = false, preservePreview
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Own the document-wide palette used by the first-run wizard and its portals.
|
||||
* The wizard follows the saved light or dark appearance (and system changes)
|
||||
* but drops any custom theme palette until the returned cleanup runs.
|
||||
*/
|
||||
export function mountOnboardingTheme(): () => void {
|
||||
if (typeof document === "undefined" || typeof window === "undefined") return () => {};
|
||||
|
||||
const root = document.documentElement;
|
||||
// "system" is a reserved id with no palette, so this clears theme variables.
|
||||
applyThemePalette("system");
|
||||
root.dataset.onboardingSurface = "";
|
||||
lastAppliedTheme = null;
|
||||
applyTheme(getStored(), { preservePreview: false });
|
||||
emitChange();
|
||||
|
||||
return () => {
|
||||
delete root.dataset.onboardingSurface;
|
||||
root.style.backgroundColor = "";
|
||||
document.body.style.backgroundColor = "";
|
||||
lastAppliedTheme = null;
|
||||
applyTheme(getStored(), { suppressTransitions: true, preservePreview: false });
|
||||
emitChange();
|
||||
};
|
||||
}
|
||||
|
||||
export async function syncDesktopThemePreference(
|
||||
bridge: DesktopThemeBridge,
|
||||
theme: Theme,
|
||||
|
||||
+13
-39
@@ -609,6 +609,18 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
|
||||
}
|
||||
|
||||
@layer components {
|
||||
/* AnimatedHeight owns resizing for its contents. Nested collapsibles must
|
||||
expose their final layout immediately, otherwise each animation frame
|
||||
restarts the parent's transition and the dialog trails behind its content. */
|
||||
[data-slot="animated-height"] [data-slot="collapsible-panel"] {
|
||||
height: auto !important;
|
||||
transition: none !important;
|
||||
}
|
||||
|
||||
[data-slot="animated-height"] [data-slot="collapsible-panel"][data-closed] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Each maintainer palette gives the same line art its own material: rose
|
||||
vellum, forest drafting paper, marine cyanotype, copper, and violet ink.
|
||||
These colors stay deliberately deep at the top edge so the white stage
|
||||
@@ -1184,43 +1196,6 @@ html[data-theme-id]:not([data-theme-id=""]) {
|
||||
--terminal-selection-background: var(--app-theme-terminal-selection-background);
|
||||
}
|
||||
|
||||
/* The first-run flow owns the whole document so portaled menus and tooltips
|
||||
use the same fixed palette as the wizard. Light onboarding uses the default
|
||||
light palette from :root above. Dark onboarding pins a true-black palette.
|
||||
This follows the theme mapping so saved custom themes cannot override it
|
||||
while onboarding is mounted. */
|
||||
html[data-onboarding-surface]:root {
|
||||
@variant dark {
|
||||
color-scheme: dark;
|
||||
--accent: #262626;
|
||||
--accent-foreground: #fff;
|
||||
--appearance-contrast-target: #fff;
|
||||
--app-chrome-background: #000;
|
||||
--background: #000;
|
||||
--border: #262626;
|
||||
--card: #000;
|
||||
--card-foreground: #fff;
|
||||
--destructive: var(--color-red-400);
|
||||
--foreground: #fff;
|
||||
--icon-muted: #a1a1aa;
|
||||
--input: #262626;
|
||||
--muted: #171717;
|
||||
--muted-foreground: #a1a1aa;
|
||||
--placeholder: #71717a;
|
||||
--popover: #171717;
|
||||
--popover-foreground: #fff;
|
||||
--ring: #737373;
|
||||
--secondary: #171717;
|
||||
--secondary-foreground: #fff;
|
||||
--secondary-label: #a1a1aa;
|
||||
--success-foreground: var(--color-emerald-400);
|
||||
--terminal-background: #000;
|
||||
--terminal-cursor: #fff;
|
||||
--terminal-foreground: #fff;
|
||||
--terminal-selection-background: rgb(255 255 255 / 20%);
|
||||
}
|
||||
}
|
||||
|
||||
/* Theme-token dependency probes are restored synchronously, before paint. Keep
|
||||
transitions from observing the temporary sentinel color in between. */
|
||||
html[data-theme-token-probe],
|
||||
@@ -1424,8 +1399,7 @@ html[data-theme-id="t3-chat"] [data-app-sidebar] {
|
||||
|
||||
/* Recompute contrast wherever a subtree owns its own semantic color palette. */
|
||||
:root,
|
||||
[data-app-sidebar],
|
||||
[data-onboarding-surface] {
|
||||
[data-app-sidebar] {
|
||||
--contrast-toolbar-foreground: color-mix(
|
||||
in oklab,
|
||||
color-mix(
|
||||
|
||||
@@ -3,6 +3,7 @@ import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
partitionOnboardingProjects,
|
||||
onboardingProjectKey,
|
||||
resolveOnboardingLandingProject,
|
||||
resolveOnboardingProjectId,
|
||||
} from "./projectImport.logic";
|
||||
@@ -243,3 +244,23 @@ describe("resolveOnboardingLandingProject", () => {
|
||||
).toBe("current");
|
||||
});
|
||||
});
|
||||
|
||||
describe("projects on multiple computers", () => {
|
||||
it("keeps identical paths independent when selecting a landing project after partial imports", () => {
|
||||
const first = onboardingProjectKey(EnvironmentId.make("first"), "/code/app");
|
||||
const second = onboardingProjectKey(EnvironmentId.make("second"), "/code/app");
|
||||
const completed = new Map([[first, "first-project"]]);
|
||||
expect(completed.has(second)).toBe(false);
|
||||
expect(resolveOnboardingLandingProject([second], completed, completed)).toBeUndefined();
|
||||
completed.set(second, "second-project");
|
||||
expect(resolveOnboardingLandingProject([second, first], completed, completed)).toBe(
|
||||
"second-project",
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves computer identity when choosing recent projects", () => {
|
||||
const first = { ...candidate("/code/app"), environmentId: "first" };
|
||||
const second = { ...candidate("/code/app"), environmentId: "second" };
|
||||
expect(partitionOnboardingProjects([first, second], now).recent).toEqual([first, second]);
|
||||
});
|
||||
});
|
||||
@@ -4,8 +4,8 @@ import type { AgentSessionProjectCandidate, EnvironmentId, ProjectId } from "@t3
|
||||
const RECENT_PROJECT_WINDOW_MS = 30 * 24 * 60 * 60 * 1000;
|
||||
|
||||
/** Existing projects still need their agent history imported, so every scan candidate is offered. */
|
||||
export function partitionOnboardingProjects(
|
||||
candidates: ReadonlyArray<AgentSessionProjectCandidate>,
|
||||
export function partitionOnboardingProjects<T extends AgentSessionProjectCandidate>(
|
||||
candidates: ReadonlyArray<T>,
|
||||
now = Date.now(),
|
||||
) {
|
||||
const cutoff = now - RECENT_PROJECT_WINDOW_MS;
|
||||
@@ -53,3 +53,8 @@ export function resolveOnboardingLandingProject<T>(
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/** Paths identify projects only within the computer that owns them. */
|
||||
export function onboardingProjectKey(environmentId: EnvironmentId, path: string): string {
|
||||
return JSON.stringify([environmentId, path]);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { RegistryContext, useAtomValue } from "@effect/atom-react";
|
||||
import type { EnvironmentId } from "@t3tools/contracts";
|
||||
import * as Option from "effect/Option";
|
||||
import { AsyncResult, Atom } from "effect/unstable/reactivity";
|
||||
import { useContext, useMemo } from "react";
|
||||
|
||||
import { agentSessionScan } from "../state/agentSessions";
|
||||
import { formatEnvironmentQueryError } from "../state/query";
|
||||
|
||||
/** Subscribe to each selected computer without coupling their failures or refreshes. */
|
||||
export function useProjectScans(environmentIds: readonly EnvironmentId[]) {
|
||||
const registry = useContext(RegistryContext);
|
||||
const scansAtom = useMemo(
|
||||
() =>
|
||||
Atom.make((get) =>
|
||||
environmentIds.map((environmentId) => {
|
||||
const atom = agentSessionScan({ environmentId, input: {} });
|
||||
const result = get(atom);
|
||||
return {
|
||||
environmentId,
|
||||
data: Option.getOrNull(AsyncResult.value(result)),
|
||||
error: result._tag === "Failure" ? formatEnvironmentQueryError(result.cause) : null,
|
||||
isPending: result.waiting || result._tag === "Initial",
|
||||
refresh: () => registry.refresh(atom),
|
||||
};
|
||||
}),
|
||||
),
|
||||
[environmentIds, registry],
|
||||
);
|
||||
return useAtomValue(scansAtom);
|
||||
}
|
||||
@@ -124,15 +124,23 @@ function RootRouteView() {
|
||||
);
|
||||
}
|
||||
|
||||
// The welcome wizard is full-screen like /pair, but keeps toasts so its
|
||||
// connect/import actions can report failures.
|
||||
// Show onboarding over the workspace, keeping automatic thread navigation
|
||||
// and other startup dialogs suspended until setup finishes.
|
||||
if (pathname === "/welcome") {
|
||||
return (
|
||||
<ToastProvider>
|
||||
<DocumentTitleSync />
|
||||
<ContrastAppearanceSync />
|
||||
<FontAppearanceSync />
|
||||
<Outlet />
|
||||
<AnchoredToastProvider>
|
||||
<DocumentTitleSync />
|
||||
<ContrastAppearanceSync />
|
||||
<EnvironmentThemeSync />
|
||||
<GlassAppearanceSync />
|
||||
<FontAppearanceSync />
|
||||
<CommandPalette>
|
||||
<AppSidebarLayout>
|
||||
<Outlet />
|
||||
</AppSidebarLayout>
|
||||
</CommandPalette>
|
||||
</AnchoredToastProvider>
|
||||
</ToastProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ import { RefreshIcon } from "~/components/ui/refresh-icon";
|
||||
import { scopeProjectRef } from "@t3tools/client-runtime/environment";
|
||||
import { createFileRoute, Link } from "@tanstack/react-router";
|
||||
import { LinkIcon, PlusIcon } from "lucide-react";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
|
||||
import { openCommandPalette } from "../commandPaletteBus";
|
||||
import { NoProjectsHero } from "../components/NoProjectsHero";
|
||||
import { sortScopedProjectsForSidebar } from "../components/Sidebar.logic";
|
||||
import { Button } from "../components/ui/button";
|
||||
import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "../components/ui/empty";
|
||||
@@ -107,35 +107,6 @@ function DraftStartError({ onRetry }: { readonly onRetry: () => void }) {
|
||||
);
|
||||
}
|
||||
|
||||
function NoProjectsHero() {
|
||||
const openAddProject = useCallback(() => openCommandPalette({ open: "add-project" }), []);
|
||||
|
||||
return (
|
||||
<SidebarInset className="h-dvh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground">
|
||||
<div className="flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-background">
|
||||
<Empty className="flex-1">
|
||||
<div className="w-full max-w-lg px-8 py-12">
|
||||
<EmptyHeader className="max-w-none">
|
||||
<EmptyTitle className="text-foreground text-2xl sm:text-3xl">
|
||||
What should we work on?
|
||||
</EmptyTitle>
|
||||
<EmptyDescription className="mt-2 text-sm text-muted-foreground/78">
|
||||
Add a project to start your first thread.
|
||||
</EmptyDescription>
|
||||
<div className="mt-6 flex justify-center">
|
||||
<Button size="sm" onClick={openAddProject}>
|
||||
<PlusIcon className="size-4" />
|
||||
Add project
|
||||
</Button>
|
||||
</div>
|
||||
</EmptyHeader>
|
||||
</div>
|
||||
</Empty>
|
||||
</div>
|
||||
</SidebarInset>
|
||||
);
|
||||
}
|
||||
|
||||
export const Route = createFileRoute("/_chat/")({
|
||||
component: ChatIndexRouteView,
|
||||
});
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import { createFileRoute, redirect, useNavigate } from "@tanstack/react-router";
|
||||
import { createFileRoute, redirect, useLocation, useNavigate } from "@tanstack/react-router";
|
||||
import { useState } from "react";
|
||||
|
||||
import { NoProjectsHero } from "../components/NoProjectsHero";
|
||||
import { WelcomeWizard } from "../components/onboarding/WelcomeWizard";
|
||||
import { useNewThreadHandler } from "../hooks/useHandleNewThread";
|
||||
|
||||
/**
|
||||
* First-run welcome wizard. Full-screen, outside the sidebar shell (the root
|
||||
* route mounts this path bare, like /pair). Reached only via the first-run
|
||||
* gate on the index route; visiting it directly after onboarding is harmless —
|
||||
* finishing again just refreshes the completion flag.
|
||||
*/
|
||||
/** Onboarding overlays the workspace. Visiting /welcome reopens setup. */
|
||||
export const Route = createFileRoute("/welcome")({
|
||||
beforeLoad: ({ context }) => {
|
||||
const { authGateState } = context;
|
||||
@@ -22,6 +19,10 @@ export const Route = createFileRoute("/welcome")({
|
||||
function WelcomeRouteView() {
|
||||
const { authGateState } = Route.useRouteContext();
|
||||
const navigate = useNavigate();
|
||||
// The root shell can remount this pending outlet after the location changes.
|
||||
// Never reopen setup while the destination route is still loading.
|
||||
const isWelcomeRoute = useLocation({ select: (location) => location.pathname === "/welcome" });
|
||||
const [dismissed, setDismissed] = useState(false);
|
||||
const openNewThread = useNewThreadHandler();
|
||||
// An authenticated gate means a primary server is serving this app —
|
||||
// desktop, `npx t3`, or a dev server — and that server is "this machine"
|
||||
@@ -29,17 +30,23 @@ function WelcomeRouteView() {
|
||||
// local server to offer.
|
||||
const localAvailable = authGateState.status === "authenticated";
|
||||
return (
|
||||
<WelcomeWizard
|
||||
localAvailable={localAvailable}
|
||||
onDone={(projectRef) => {
|
||||
if (projectRef !== undefined) {
|
||||
void openNewThread(projectRef, { replace: true }).catch(() => {
|
||||
<>
|
||||
<NoProjectsHero />
|
||||
{isWelcomeRoute && !dismissed ? (
|
||||
<WelcomeWizard
|
||||
localAvailable={localAvailable}
|
||||
onDone={(projectRef) => {
|
||||
setDismissed(true);
|
||||
if (projectRef !== undefined) {
|
||||
void openNewThread(projectRef, { replace: true }).catch(() => {
|
||||
void navigate({ to: "/", replace: true });
|
||||
});
|
||||
return;
|
||||
}
|
||||
void navigate({ to: "/", replace: true });
|
||||
});
|
||||
return;
|
||||
}
|
||||
void navigate({ to: "/", replace: true });
|
||||
}}
|
||||
/>
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -3,18 +3,28 @@
|
||||
T3 Code shows a setup flow when you open a new installation or connect to the
|
||||
hosted app for the first time. Existing workspaces skip this flow.
|
||||
|
||||
## Choose a connection
|
||||
## Connect your computers
|
||||
|
||||
Select one or more computers to set up. If you opened T3 Code directly from a
|
||||
server or the desktop app, that computer is already connected and selected.
|
||||
It is identified by its name, which may differ from the device running your
|
||||
browser.
|
||||
|
||||
You can add more computers before continuing:
|
||||
|
||||
- **This computer** runs agents on the computer that hosts T3 Code. It does not
|
||||
require an account.
|
||||
- **T3 Connect** connects computers that are signed in to your account. Run
|
||||
`npx t3 connect` on each computer you want to add, then start T3 Code or run
|
||||
`npx t3 serve` so the computer stays available.
|
||||
- **Pair a server** connects directly to a server on your network or tailnet.
|
||||
- **Add a computer** connects directly to a server on your network or tailnet.
|
||||
Start the server with `npx t3 serve`, then run `npx t3 pair --tailscale` and
|
||||
paste the pairing link. You can also run `npx t3 serve --host <address>` and
|
||||
use `npx t3 pair` when the server is already reachable on your network.
|
||||
|
||||
Saved computers and computers discovered through T3 Connect are selected by
|
||||
default. Uncheck any you do not want to set up; this does not disconnect them.
|
||||
Continue when your selected computers are connected. Setup checks
|
||||
agents across the selected computers, then offers project import grouped by computer.
|
||||
|
||||
If T3 Code cannot confirm the workspace during startup, the setup flow shows
|
||||
**Still connecting** instead of opening the app. Select **Reload** to try again.
|
||||
|
||||
@@ -24,7 +34,7 @@ unreadable settings with defaults.
|
||||
|
||||
## Check your agents
|
||||
|
||||
T3 Code checks the selected computer for Claude Code and Codex. If an agent is
|
||||
T3 Code checks each selected computer for Claude Code and Codex. If an agent is
|
||||
not installed or signed in, select its action to open a terminal with the
|
||||
correct command ready to run. Install uses the vendor's standalone installer,
|
||||
which does not need Node or npm and keeps **Update now** working in Settings.
|
||||
@@ -37,7 +47,7 @@ terminal metadata while the terminal process can use them.
|
||||
## Import your projects
|
||||
|
||||
T3 Code finds directories that Claude Code or Codex has used. The default
|
||||
selection includes projects active within the last 30 days. Select **Choose**
|
||||
selection includes projects active within the last 30 days. Use the checkboxes
|
||||
to include older projects or change the selection.
|
||||
|
||||
A large or malformed history can reach the scan limit. T3 Code keeps the
|
||||
@@ -60,5 +70,5 @@ with up to 100,000 input records. Run import again to continue a large batch.
|
||||
Completed conversations are not imported again. You can continue without the
|
||||
remaining history.
|
||||
|
||||
You can skip agent setup and project import. Select **Back** to return to a
|
||||
previous step.
|
||||
You can continue without configuring agents or importing projects, or return to an earlier step
|
||||
using the setup progress bar. Navigation pauses while an import is running.
|
||||
Reference in new issue
Block a user