Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion apps/web/src/components/settings/SavedEnvironmentRows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import {
RouteIcon,
} from "lucide-react";
import { useAtomValue } from "@effect/atom-react";
import { useNavigate } from "@tanstack/react-router";
import { useEffect, useEffectEvent, useState } from "react";
import {
AuthOrchestrationOperateScope,
AuthRelayWriteScope,
type EnvironmentId,
connectReachabilityHelpUrl,
Expand Down Expand Up @@ -57,7 +59,7 @@ import { useManagedTunnelUsage } from "~/cloud/managedRelayState";
import { useT3ConnectAccountPage } from "../clerk/T3ConnectAccountPages";
import { TunnelLimitAlert, TunnelUsageMeter } from "../cloud/TunnelUsage";
import { environmentCatalog } from "~/connection/catalog";
import { readEnvironmentScope } from "~/state/session";
import { readEnvironmentScope, useEnvironmentScope } from "~/state/session";
import { type EnvironmentPresentation, useRelayEnvironmentDiscovery } from "~/state/environments";
import { APP_VERSION } from "~/branding";
import { useManagedPolicy } from "~/state/managedPolicy";
Expand Down Expand Up @@ -140,6 +142,10 @@ export function SavedBackendListRow({
const enabled = environment.entry.enabled && !unsupported;
const isConnected = environment.connection.phase === "connected";
const isRemoving = removingEnvironmentId === environmentId;
const navigate = useNavigate();
// Opens the Welcome page for this row's computer, which then scans that computer's history.
const canImportSessions =
useEnvironmentScope(environmentId, AuthOrchestrationOperateScope) && enabled && isConnected;
const errorTraceId = environment.connection.traceId;
const { copyToClipboard: copyTraceIdToClipboard } = useCopyToClipboard<{ traceId: string }>({
target: {
Expand Down Expand Up @@ -451,6 +457,11 @@ export function SavedBackendListRow({
<RouteIcon />
{routesOpen ? gt("Hide routes") : gt("Routes")}
</MenuItem>
{canImportSessions ? (
<MenuItem onClick={() => void navigate({ to: "/welcome", search: { environmentId } })}>
<T>Import sessions…</T>
</MenuItem>
) : null}
{mcpUrl ? (
<MenuItem onClick={() => copyMcpUrl(mcpUrl, { url: mcpUrl })}>
<T>Copy MCP URL</T>
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -9387,6 +9387,7 @@
"2c2a12fbdc300d03": "Um diese Einstellungen zu bearbeiten, kopple diese Verbindung mit den Berechtigungen „Relay anzeigen“ und „Relay verwalten“.",
"3b3d299149f45c3d": "Klicke auf „Umgebung hinzufügen“, um eine weitere Umgebung zu koppeln, oder verbinde eine über T3 Connect.",
"0e4f42dd41b74e9a": "Klicke auf „Umgebung hinzufügen“, um eine weitere Umgebung zu koppeln.",
"777fab9a267277ef": "Sitzungen importieren…",
"579a261154e2db62": "MCP-URL kopieren",
"4a1e6124e121d54f": "Trace-ID kopieren",
"8693499e957364d1": "Mehr Tunnel erhalten",
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9395,6 +9395,7 @@
"2c2a12fbdc300d03": "To edit these settings, pair this connection with both View relay and Manage relay permissions.",
"3b3d299149f45c3d": "Click “Add environment” to pair another environment, or connect one from T3 Connect.",
"0e4f42dd41b74e9a": "Click “Add environment” to pair another environment.",
"777fab9a267277ef": "Import sessions…",
"579a261154e2db62": "Copy MCP URL",
"4a1e6124e121d54f": "Copy trace ID",
"8693499e957364d1": "Get more tunnels",
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -9383,6 +9383,7 @@
"2c2a12fbdc300d03": "Para editar estos ajustes, empareja esta conexión con los permisos Ver relay y Gestionar relay.",
"3b3d299149f45c3d": "Haz clic en «Añadir entorno» para emparejar otro entorno, o conecta uno desde T3 Connect.",
"0e4f42dd41b74e9a": "Haz clic en «Añadir entorno» para emparejar otro entorno.",
"777fab9a267277ef": "Importar sesiones…",
"579a261154e2db62": "Copiar URL de MCP",
"4a1e6124e121d54f": "Copiar ID de traza",
"8693499e957364d1": "Obtener más túneles",
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/i18n/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -9385,6 +9385,7 @@
"2c2a12fbdc300d03": "Pour modifier ces paramètres, appairez cette connexion avec les autorisations Voir le relais et Gérer le relais.",
"3b3d299149f45c3d": "Cliquez sur « Ajouter un environnement » pour appairer un autre environnement, ou connectez-en un depuis T3 Connect.",
"0e4f42dd41b74e9a": "Cliquez sur « Ajouter un environnement » pour appairer un autre environnement.",
"777fab9a267277ef": "Importer des sessions…",
"579a261154e2db62": "Copier l’URL MCP",
"4a1e6124e121d54f": "Copier l’ID de trace",
"8693499e957364d1": "Obtenir plus de tunnels",
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/i18n/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -9340,6 +9340,7 @@
"2c2a12fbdc300d03": "これらの設定を編集するには、「リレーの表示」と「リレーの管理」の両方の権限でこの接続をペアリングしてください。",
"3b3d299149f45c3d": "「環境を追加」をクリックして別の環境をペアリングするか、T3 Connect から接続してください。",
"0e4f42dd41b74e9a": "「環境を追加」をクリックして別の環境をペアリングしてください。",
"777fab9a267277ef": "セッションをインポート…",
"579a261154e2db62": "MCP URL をコピー",
"4a1e6124e121d54f": "トレース ID をコピー",
"8693499e957364d1": "トンネルを追加で入手",
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/i18n/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -9343,6 +9343,7 @@
"2c2a12fbdc300d03": "이 설정을 편집하려면 릴레이 보기 및 릴레이 관리 권한을 모두 사용해 이 연결을 페어링하세요.",
"3b3d299149f45c3d": "다른 환경을 페어링하려면 “환경 추가”를 클릭하거나 T3 Connect에서 연결하세요.",
"0e4f42dd41b74e9a": "다른 환경을 페어링하려면 “환경 추가”를 클릭하세요.",
"777fab9a267277ef": "세션 가져오기…",
"579a261154e2db62": "MCP URL 복사",
"4a1e6124e121d54f": "추적 ID 복사",
"8693499e957364d1": "터널 더 받기",
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/i18n/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -9384,6 +9384,7 @@
"2c2a12fbdc300d03": "Para editar estas configurações, pareie esta conexão com as permissões View relay e Manage relay.",
"3b3d299149f45c3d": "Clique em “Adicionar ambiente” para parear outro ambiente ou conecte um pelo T3 Connect.",
"0e4f42dd41b74e9a": "Clique em “Adicionar ambiente” para parear outro ambiente.",
"777fab9a267277ef": "Importar sessões…",
"579a261154e2db62": "Copiar URL do MCP",
"4a1e6124e121d54f": "Copiar ID de rastreamento",
"8693499e957364d1": "Obter mais túneis",
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/i18n/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -9387,6 +9387,7 @@
"2c2a12fbdc300d03": "Чтобы менять эти настройки, выполните сопряжение этого подключения с разрешениями View relay и Manage relay.",
"3b3d299149f45c3d": "Нажмите «Добавить окружение», чтобы выполнить сопряжение с другим окружением, или подключите его из T3 Connect.",
"0e4f42dd41b74e9a": "Нажмите «Добавить окружение», чтобы выполнить сопряжение с другим окружением.",
"777fab9a267277ef": "Импортировать сеансы…",
"579a261154e2db62": "Копировать URL MCP",
"4a1e6124e121d54f": "Копировать ID трассировки",
"8693499e957364d1": "Получить больше туннелей",
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/i18n/translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -9393,6 +9393,7 @@
"2c2a12fbdc300d03": "Parkoppla den här anslutningen med både behörigheterna Visa relä och Hantera relä för att redigera de här inställningarna.",
"3b3d299149f45c3d": "Klicka på ”Lägg till miljö” för att parkoppla en annan miljö, eller anslut en från T3 Connect.",
"0e4f42dd41b74e9a": "Klicka på ”Lägg till miljö” för att parkoppla en annan miljö.",
"777fab9a267277ef": "Importera sessioner…",
"579a261154e2db62": "Kopiera MCP-URL",
"4a1e6124e121d54f": "Kopiera spårnings-ID",
"8693499e957364d1": "Skaffa fler tunnlar",
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/i18n/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -9401,6 +9401,7 @@
"2c2a12fbdc300d03": "要编辑这些设置,请在配对此连接时同时授予“查看中继”和“管理中继”权限。",
"3b3d299149f45c3d": "点击“添加环境”配对其他环境,或从 T3 Connect 连接一个环境。",
"0e4f42dd41b74e9a": "点击“添加环境”配对其他环境。",
"777fab9a267277ef": "导入会话…",
"579a261154e2db62": "复制 MCP URL",
"4a1e6124e121d54f": "复制追踪 ID",
"8693499e957364d1": "获取更多隧道",
Expand Down
42 changes: 42 additions & 0 deletions apps/web/src/onboarding/welcomePage.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
codexCardProvider,
codexNeedsSetup,
groupWelcomeAgents,
resolveWelcomeEnvironmentId,
turnedOnInstance,
welcomeOffersPhone,
} from "./welcomePage.logic";
Expand Down Expand Up @@ -263,3 +264,44 @@ describe("welcomeOffersPhone", () => {
expect(offers({ isPrimary: false })).toBe(false);
});
});

describe("resolveWelcomeEnvironmentId", () => {
const base = {
resumeEnvironmentId: undefined,
requestedEnvironmentId: undefined,
primaryEnvironmentId: "primary",
knownEnvironmentIds: ["primary", "remote", "other"],
};

it("opens a connected computer that Settings asked for", () => {
expect(resolveWelcomeEnvironmentId({ ...base, requestedEnvironmentId: "remote" })).toBe(
"remote",
);
});

it("lets a ChatGPT sign-in return to the computer it set up", () => {
expect(
resolveWelcomeEnvironmentId({
...base,
resumeEnvironmentId: "other",
requestedEnvironmentId: "remote",
}),
).toBe("other");
});

it("ignores a computer the catalog does not know", () => {
expect(resolveWelcomeEnvironmentId({ ...base, requestedEnvironmentId: "gone" })).toBe(
"primary",
);
});

it("opens a connected computer without a primary one, as in the hosted app", () => {
expect(
resolveWelcomeEnvironmentId({
...base,
primaryEnvironmentId: null,
requestedEnvironmentId: "remote",
}),
).toBe("remote");
});
});
20 changes: 20 additions & 0 deletions apps/web/src/onboarding/welcomePage.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,23 @@ export function codexCardProvider(input: {
welcomeAgentState(provider, input.settings) === "checking";
return open ? provider : null;
}

/**
* The computer the Welcome page sets up. A ChatGPT sign-in returns to the computer it set up, and
* Settings opens the page for a connected computer; either id counts only once the catalog knows
* it, so an unknown one falls back to this computer.
*/
export function resolveWelcomeEnvironmentId<Id extends string>(input: {
readonly resumeEnvironmentId: Id | undefined;
readonly requestedEnvironmentId: Id | undefined;
readonly primaryEnvironmentId: Id | null;
readonly knownEnvironmentIds: ReadonlyArray<Id>;
}): Id | null {
const known = (id: Id | undefined) =>
id !== undefined && input.knownEnvironmentIds.includes(id) ? id : undefined;
return (
known(input.resumeEnvironmentId) ??
known(input.requestedEnvironmentId) ??
input.primaryEnvironmentId
);
}
26 changes: 20 additions & 6 deletions apps/web/src/routes/welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as Option from "effect/Option";
import { NoProjectsHero } from "../components/NoProjectsHero";
import { WelcomePage } from "../components/onboarding/WelcomePage";
import { useNewThreadHandler } from "../hooks/useHandleNewThread";
import { resolveWelcomeEnvironmentId } from "../onboarding/welcomePage.logic";
import { useEnvironments, usePrimaryEnvironmentId } from "../state/environments";

const decodeEnvironmentId = Schema.decodeOption(EnvironmentId);
Expand All @@ -18,6 +19,14 @@ export const Route = createFileRoute("/welcome")({
throw redirect({ to: "/pair", replace: true });
}
},
// Settings → Environments opens the page for a connected computer to import its history.
validateSearch: (raw: Record<string, unknown>): { environmentId?: EnvironmentId } => {
const environmentId =
typeof raw.environmentId === "string"
? Option.getOrUndefined(decodeEnvironmentId(raw.environmentId))
: undefined;
return environmentId === undefined ? {} : { environmentId };
},
component: WelcomeRouteView,
});

Expand All @@ -28,15 +37,20 @@ function WelcomeRouteView() {
const resumeEnvironmentId = hash.startsWith("agents:")
? Option.getOrUndefined(decodeEnvironmentId(hash.slice("agents:".length)))
: undefined;
const requestedEnvironmentId = Route.useSearch({ select: (search) => search.environmentId });
const primaryEnvironmentId = usePrimaryEnvironmentId();
const { environments, isReady } = useEnvironments();
// Trust the id only once the catalog has it; an unknown computer falls back to this one.
const waitingForCatalog =
!isReady && (resumeEnvironmentId !== undefined || primaryEnvironmentId === null);
const resumeKnown =
resumeEnvironmentId !== undefined &&
environments.some((environment) => environment.environmentId === resumeEnvironmentId);
const environmentId = (resumeKnown ? resumeEnvironmentId : undefined) ?? primaryEnvironmentId;
!isReady &&
(resumeEnvironmentId !== undefined ||
requestedEnvironmentId !== undefined ||
primaryEnvironmentId === null);
const environmentId = resolveWelcomeEnvironmentId({
resumeEnvironmentId,
requestedEnvironmentId,
primaryEnvironmentId,
knownEnvironmentIds: environments.map((environment) => environment.environmentId),
});
// The root can remount this pending outlet after navigation; do not reopen setup.
const isWelcomeRoute = useLocation({ select: (location) => location.pathname === "/welcome" });
const [dismissed, setDismissed] = useState(false);
Expand Down
6 changes: 6 additions & 0 deletions docs/user/welcome-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ and the phone app. Only an agent is needed to start chatting.
To see the page again, go to **Settings → About → Welcome page** and select
**Open**. Direct links, such as Settings, open normally before setup is done.

The page sets up the computer you are using. To import projects and sessions from
another connected computer, go to **Settings → Environments**, open that
computer's **⋯** menu and select **Import sessions…**. The Welcome page then
lists that computer's agents and its Claude Code, Codex, and Pi history. The
option needs a connected computer and a connection that can import projects.

The hosted app at app.t3.codes does not open the page. With no computer connected,
it asks you to sign in to T3 Connect, then to install T3 Code and run
`t3 connect` on your computer. From home, it adds compatible computers linked to your account and
Expand Down
Loading