The best way to control Claude Code, Codex and more from any computer or phone
test: remove stale tests for unused thread and onboarding helpers (#30817)
Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com>
t3-code-bot[bot] committed
Nov 5, 2026 at 14:22 UTC
c72de5249a273b700dc05ed259f8b647827f09ca
4 files changed
+2
-286
apps/mobile/src/state/use-selected-thread-worktree.test.ts
deleted
-55
@@ -1,55 +0,0 @@
1
-import { EnvironmentId, ProjectId, ThreadId } from "@t3tools/contracts";
2
-import { describe, expect, it, vi } from "vite-plus/test";
3
-
4
-const state = vi.hoisted(() => ({
5
- shell: null as { projectId: string; worktreePath: string | null } | null,
6
- detail: null as { thread: { projectId: string } } | null,
7
- detailWorktreePath: null as string | null,
8
- projects: new Map<string, { workspaceRoot: string }>(),
9
-}));
10
-
11
-vi.mock("./entities", () => ({
12
- useQuietThreadShell: (ref: unknown) => (ref === null ? null : state.shell),
13
- useProject: (ref: { projectId: string } | null) =>
14
- ref === null ? null : (state.projects.get(ref.projectId) ?? null),
15
-}));
16
-vi.mock("./threads", async () => {
17
- const { some, none } = await import("effect/Option");
18
- return {
19
- useEnvironmentThread: (environmentId: unknown, threadId: unknown) => ({
20
- data:
21
- environmentId !== null && threadId !== null && state.detail ? some(state.detail) : none(),
22
- }),
23
- };
24
-});
25
-vi.mock("./use-thread-detail", () => ({
26
- useThreadWorktreePath: (ref: unknown) => (ref === null ? null : state.detailWorktreePath),
27
- useSelectedThreadWorktreePath: () => null,
28
-}));
29
-vi.mock("./use-thread-selection", () => ({ useThreadSelection: () => ({}) }));
30
-
31
-const { useThreadCwd } = await import("./use-selected-thread-worktree");
32
-
33
-const ref = { environmentId: EnvironmentId.make("env"), threadId: ThreadId.make("thread") };
34
-
35
-function setup(input: Partial<Omit<typeof state, "projects">>) {
36
- Object.assign(state, { shell: null, detail: null, detailWorktreePath: null }, input);
37
- state.projects = new Map([[ProjectId.make("project"), { workspaceRoot: "/repo" }]]);
38
-}
39
-
40
-describe("useThreadCwd", () => {
41
- it("falls back to the project root from the loaded detail when the shell is missing", () => {
42
- setup({ detail: { thread: { projectId: "project" } } });
43
- expect(useThreadCwd(ref)).toBe("/repo");
44
- });
45
-
46
- it("prefers the thread worktree over the project root", () => {
47
- setup({ shell: { projectId: "project", worktreePath: "/repo/.worktrees/a" } });
48
- expect(useThreadCwd(ref)).toBe("/repo/.worktrees/a");
49
- });
50
-
51
- it("is null without a thread", () => {
52
- setup({ detail: { thread: { projectId: "project" } } });
53
- expect(useThreadCwd(null)).toBeNull();
54
- });
55
-});
apps/mobile/src/state/use-selected-thread-worktree.ts
+1
-32
@@ -1,9 +1,4 @@
1
-import type { ScopedThreadRef } from "@t3tools/contracts";
2
-import * as Option from "effect/Option";
3
-
4
-import { useProject, useQuietThreadShell } from "./entities";
5
-import { useEnvironmentThread } from "./threads";
6
-import { useSelectedThreadWorktreePath, useThreadWorktreePath } from "./use-thread-detail";
1
+import { useSelectedThreadWorktreePath } from "./use-thread-detail";
2
import { useThreadSelection } from "./use-thread-selection";
3
import { resolvePreferredThreadWorktreePath } from "../features/terminal/terminalLaunchContext";
4
@@ -21,29 +16,3 @@ export function useSelectedThreadWorktree() {
16
selectedThreadCwd: selectedThreadWorktreePath ?? selectedThreadProject?.workspaceRoot ?? null,
17
};
18
}
24
-
25
-/**
26
- * Resolves a thread's cwd the way the selected thread's does, for a thread that is not the
27
- * current route's: the shell, or the loaded detail when the shell is missing, picks the project.
28
- */
29
-export function useThreadCwd(ref: ScopedThreadRef | null): string | null {
30
- const shell = useQuietThreadShell(ref);
31
- const detailState = useEnvironmentThread(
32
- shell === null ? (ref?.environmentId ?? null) : null,
33
- shell === null ? (ref?.threadId ?? null) : null,
34
- );
35
- const detailThread = Option.getOrNull(detailState.data)?.thread ?? null;
36
- const detailWorktreePath = useThreadWorktreePath(ref);
37
- const projectId = shell?.projectId ?? detailThread?.projectId ?? null;
38
- const project = useProject(
39
- ref === null || projectId === null ? null : { environmentId: ref.environmentId, projectId },
40
- );
41
- return (
42
- resolvePreferredThreadWorktreePath({
43
- threadShellWorktreePath: shell?.worktreePath ?? null,
44
- threadDetailWorktreePath: detailWorktreePath,
45
- }) ??
46
- project?.workspaceRoot ??
47
- null
48
- );
49
-}
apps/web/src/onboarding/targetEnvironment.logic.test.ts
+1
-165
@@ -1,171 +1,7 @@
1
-import {
2
- BearerConnectionTarget,
3
- PrimaryConnectionTarget,
4
- RelayConnectionTarget,
5
- SshConnectionTarget,
6
-} from "@t3tools/client-runtime/connection";
1
import { EnvironmentId } from "@t3tools/contracts";
2
import { describe, expect, it } from "vite-plus/test";
3
10
-import {
11
- resolveOnboardingSetup,
12
- resolveOnboardingTargetEnvironment,
13
-} from "./targetEnvironment.logic";
14
-
15
-const primaryEnvironment = {
16
- environmentId: EnvironmentId.make("primary"),
17
- connection: { phase: "connected" },
18
- entry: {
19
- target: new PrimaryConnectionTarget({
20
- environmentId: EnvironmentId.make("primary"),
21
- label: "This computer",
22
- httpBaseUrl: "http://127.0.0.1:3773",
23
- wsBaseUrl: "ws://127.0.0.1:3773",
24
- }),
25
- },
26
- label: "This computer",
27
-} as const;
28
-
29
-const olderRelay = {
30
- environmentId: EnvironmentId.make("older-remote"),
31
- connection: { phase: "connected" },
32
- entry: {
33
- target: new RelayConnectionTarget({
34
- environmentId: EnvironmentId.make("older-remote"),
35
- label: "Older computer",
36
- }),
37
- },
38
- label: "Older computer",
39
-} as const;
40
-
41
-const newerRelay = {
42
- environmentId: EnvironmentId.make("newer-relay"),
43
- connection: { phase: "connected" },
44
- entry: {
45
- target: new RelayConnectionTarget({
46
- environmentId: EnvironmentId.make("newer-relay"),
47
- label: "New computer",
48
- }),
49
- },
50
- label: "New computer",
51
-} as const;
52
-
53
-const pairedRemote = {
54
- environmentId: EnvironmentId.make("paired-remote"),
55
- connection: { phase: "connected" },
56
- entry: {
57
- target: new BearerConnectionTarget({
58
- environmentId: EnvironmentId.make("paired-remote"),
59
- label: "Direct computer",
60
- connectionId: "paired-remote",
61
- }),
62
- },
63
- label: "Direct computer",
64
-} as const;
65
-
66
-const sshEnvironment = {
67
- environmentId: EnvironmentId.make("ssh-remote"),
68
- connection: { phase: "connected" },
69
- entry: {
70
- target: new SshConnectionTarget({
71
- environmentId: EnvironmentId.make("ssh-remote"),
72
- label: "SSH computer",
73
- connectionId: "ssh-remote",
74
- }),
75
- },
76
- label: "SSH computer",
77
-} as const;
78
-
79
-const desktopLocalEnvironment = {
80
- environmentId: EnvironmentId.make("desktop-local-wsl"),
81
- connection: { phase: "connected" },
82
- entry: {
83
- target: new BearerConnectionTarget({
84
- environmentId: EnvironmentId.make("desktop-local-wsl"),
85
- label: "WSL",
86
- connectionId: "local:wsl:Ubuntu",
87
- }),
88
- },
89
- label: "WSL",
90
-} as const;
91
-
92
-describe("resolveOnboardingTargetEnvironment", () => {
93
- it("waits for the exact paired machine instead of using an older connected machine", () => {
94
- const pendingPairedRemote = { ...pairedRemote, connection: { phase: "connecting" } };
95
-
96
- expect(
97
- resolveOnboardingTargetEnvironment({
98
- mode: "direct",
99
- environments: [primaryEnvironment, olderRelay, pendingPairedRemote],
100
- primaryEnvironment,
101
- pairedEnvironmentId: pairedRemote.environmentId,
102
- }),
103
- ).toBeNull();
104
- });
105
-
106
- it("uses the exact paired machine once it connects", () => {
107
- expect(
108
- resolveOnboardingTargetEnvironment({
109
- mode: "direct",
110
- environments: [primaryEnvironment, olderRelay, pairedRemote],
111
- primaryEnvironment,
112
- pairedEnvironmentId: pairedRemote.environmentId,
113
- }),
114
- ).toBe(pairedRemote);
115
- });
116
-
117
- it("does not substitute a remote machine when the local primary is offline", () => {
118
- const offlinePrimary = { ...primaryEnvironment, connection: { phase: "disconnected" } };
119
-
120
- expect(
121
- resolveOnboardingTargetEnvironment({
122
- mode: "local",
123
- environments: [offlinePrimary, olderRelay],
124
- primaryEnvironment: offlinePrimary,
125
- pairedEnvironmentId: null,
126
- }),
127
- ).toBeNull();
128
- });
129
-
130
- it("uses the newest connected remote when no exact machine was selected", () => {
131
- expect(
132
- resolveOnboardingTargetEnvironment({
133
- mode: "connect",
134
- environments: [primaryEnvironment, olderRelay, newerRelay],
135
- primaryEnvironment,
136
- pairedEnvironmentId: null,
137
- }),
138
- ).toBe(newerRelay);
139
- });
140
-
141
- it("ignores direct, SSH, and desktop-managed connections in Connect mode", () => {
142
- expect(
143
- resolveOnboardingTargetEnvironment({
144
- mode: "connect",
145
- environments: [
146
- primaryEnvironment,
147
- olderRelay,
148
- pairedRemote,
149
- sshEnvironment,
150
- desktopLocalEnvironment,
151
- ],
152
- primaryEnvironment,
153
- pairedEnvironmentId: null,
154
- }),
155
- ).toBe(olderRelay);
156
- });
157
-
158
- it("uses the primary computer when no relay connection exists", () => {
159
- expect(
160
- resolveOnboardingTargetEnvironment({
161
- mode: "connect",
162
- environments: [primaryEnvironment, pairedRemote, sshEnvironment, desktopLocalEnvironment],
163
- primaryEnvironment,
164
- pairedEnvironmentId: null,
165
- }),
166
- ).toBe(primaryEnvironment);
167
- });
168
-});
4
+import { resolveOnboardingSetup } from "./targetEnvironment.logic";
5
6
describe("resolveOnboardingSetup", () => {
7
const computer = (id: string, phase: string) => ({
apps/web/src/onboarding/targetEnvironment.logic.ts
-34
@@ -13,40 +13,6 @@ export function isOnboardingRelayEnvironment(
13
return hasRelayRoute(environment.entry);
14
}
15
16
-export function resolveOnboardingTargetEnvironment<TEnvironment extends OnboardingEnvironment>({
17
- mode,
18
- environments,
19
- primaryEnvironment,
20
- pairedEnvironmentId,
21
-}: {
22
- readonly mode: "local" | "connect" | "direct";
23
- readonly environments: ReadonlyArray<TEnvironment>;
24
- readonly primaryEnvironment: TEnvironment | null;
25
- readonly pairedEnvironmentId: EnvironmentId | null;
26
-}): TEnvironment | null {
27
- if (mode === "direct" && pairedEnvironmentId !== null) {
28
- const pairedEnvironment = environments.find(
29
- (environment) => environment.environmentId === pairedEnvironmentId,
30
- );
31
- return pairedEnvironment?.connection.phase === "connected" ? pairedEnvironment : null;
32
- }
33
-
34
- const connectedRelayEnvironments = environments.filter(
35
- (environment) =>
36
- environment.connection.phase === "connected" && isOnboardingRelayEnvironment(environment),
37
- );
38
-
39
- if (mode === "connect" && connectedRelayEnvironments.length > 0) {
40
- return connectedRelayEnvironments[connectedRelayEnvironments.length - 1] ?? null;
41
- }
42
-
43
- if (primaryEnvironment?.connection.phase === "connected") {
44
- return primaryEnvironment;
45
- }
46
-
47
- return mode === "local" ? null : (connectedRelayEnvironments[0] ?? null);
48
-}
49
-
16
/** Waits only for first connection attempts; offline, failing, or unsupported computers cannot block setup. */
17
export function resolveOnboardingSetup(
18
environments: ReadonlyArray<Pick<OnboardingEnvironment, "environmentId" | "connection">>,