The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 19:30 UTC
test: delete low-value tests and dead test-only exports (#24058)
Theo Browne committed
Oct 23, 2026 at 03:08 UTC
51a7118b700b19191fa0614785e0149a6d8a6e72
49 files changed
+69
-2630
apps/desktop/src/updates/updateMachine.test.ts
-54
@@ -8,7 +8,6 @@ import {
8
reduceDesktopUpdateStateOnDownloadFailure,
9
reduceDesktopUpdateStateOnInstallFailure,
10
reduceDesktopUpdateStateOnNoUpdate,
11
- reduceDesktopUpdateStateOnUpdateAvailable,
11
} from "./updateMachine.ts";
12
13
const runtimeInfo = {
@@ -50,30 +49,6 @@ describe("updateMachine", () => {
49
expect(failed.message).toBeNull();
50
});
51
53
- it("keeps the installer when the feed still offers its version", () => {
54
- const releaseNotes = [{ version: "1.1.0", items: ["fix: queued update"], totalItems: 1 }];
55
- const state = reduceDesktopUpdateStateOnUpdateAvailable(
56
- {
57
- ...createInitialDesktopUpdateState("1.0.0", runtimeInfo, "latest"),
58
- enabled: true,
59
- status: "downloaded",
60
- availableVersion: "1.1.0",
61
- downloadedVersion: "1.1.0",
62
- releaseNotes,
63
- omittedReleaseCount: 2,
64
- downloadPercent: 100,
65
- },
66
- "1.1.0",
67
- "2026-03-04T00:00:00.000Z",
68
- );
69
-
70
- expect(state.status).toBe("downloaded");
71
- expect(state.downloadedVersion).toBe("1.1.0");
72
- expect(state.releaseNotes).toEqual(releaseNotes);
73
- expect(state.omittedReleaseCount).toBe(2);
74
- expect(state.downloadPercent).toBe(100);
75
- });
76
-
52
it("preserves available version on download failure for retry", () => {
53
const state = reduceDesktopUpdateStateOnDownloadFailure(
54
{
@@ -114,35 +89,6 @@ describe("updateMachine", () => {
89
expect(failedInstall.canRetry).toBe(true);
90
});
91
117
- it("preserves a downloaded update when no update is available", () => {
118
- const releaseNotes = [{ version: "1.1.0", items: ["fix: queued update"], totalItems: 1 }];
119
- const state = reduceDesktopUpdateStateOnNoUpdate(
120
- {
121
- ...createInitialDesktopUpdateState("1.0.0", runtimeInfo, "latest"),
122
- enabled: true,
123
- status: "error",
124
- availableVersion: "1.1.0",
125
- downloadedVersion: "1.1.0",
126
- releaseNotes,
127
- omittedReleaseCount: 2,
128
- message: "old failure",
129
- errorContext: "download",
130
- canRetry: true,
131
- },
132
- "2026-03-04T00:00:00.000Z",
133
- );
134
-
135
- expect(state.status).toBe("downloaded");
136
- expect(state.availableVersion).toBe("1.1.0");
137
- expect(state.downloadedVersion).toBe("1.1.0");
138
- expect(state.releaseNotes).toBe(releaseNotes);
139
- expect(state.omittedReleaseCount).toBe(2);
140
- expect(state.downloadPercent).toBe(100);
141
- expect(state.message).toBeNull();
142
- expect(state.errorContext).toBeNull();
143
- expect(state.canRetry).toBe(true);
144
- });
145
-
92
it("clears stale available state when no update is available", () => {
93
const state = reduceDesktopUpdateStateOnNoUpdate(
94
{
apps/mobile/src/features/threads/threadActivityFileNavigation.test.ts
deleted
-26
@@ -1,26 +0,0 @@
1
-import { EnvironmentId, ThreadId } from "@t3tools/contracts";
2
-import { describe, expect, it } from "@effect/vitest";
3
-
4
-import { buildThreadActivityFileParams } from "./threadActivityFileNavigation";
5
-
6
-describe("thread activity file navigation", () => {
7
- it("keeps inherited activity file links on the currently selected thread", () => {
8
- const sourceThreadId = ThreadId.make("source-thread");
9
- const currentThreadId = ThreadId.make("current-thread");
10
-
11
- const params = buildThreadActivityFileParams({
12
- environmentId: EnvironmentId.make("environment"),
13
- currentThreadId,
14
- activitySourceThreadId: sourceThreadId,
15
- relativePath: "apps/mobile/src/index.ts",
16
- line: 12,
17
- });
18
-
19
- expect(params).toEqual({
20
- environmentId: "environment",
21
- threadId: "current-thread",
22
- path: ["apps", "mobile", "src", "index.ts"],
23
- line: "12",
24
- });
25
- });
26
-});
apps/mobile/src/features/threads/threadActivityFileNavigation.ts
deleted
-20
@@ -1,20 +0,0 @@
1
-import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
2
-
3
-interface ThreadActivityFileContext {
4
- readonly environmentId: EnvironmentId;
5
- readonly currentThreadId: ThreadId;
6
- readonly activitySourceThreadId: ThreadId;
7
- readonly relativePath: string;
8
- readonly line?: number | null;
9
-}
10
-
11
-export function buildThreadActivityFileParams(input: ThreadActivityFileContext) {
12
- return {
13
- environmentId: String(input.environmentId),
14
- threadId: String(input.currentThreadId),
15
- path: input.relativePath.split("/").filter((segment) => segment.length > 0),
16
- ...(Number.isFinite(input.line) && Number(input.line) > 0
17
- ? { line: String(Math.floor(Number(input.line))) }
18
- : {}),
19
- };
20
-}
apps/mobile/src/lib/threadActivityInspector.test.ts
deleted
-96
@@ -1,96 +0,0 @@
1
-import { EMPTY_V2_ITEM_SUPPORT } from "@t3tools/client-runtime/state/item-support";
2
-import {
3
- CheckpointId,
4
- CheckpointScopeId,
5
- NodeId,
6
- RunId,
7
- ThreadId,
8
- TurnItemId,
9
- type OrchestrationV2ProjectedTurnItem,
10
- type OrchestrationV2TurnItem,
11
-} from "@t3tools/contracts";
12
-import * as DateTime from "effect/DateTime";
13
-import { describe, expect, it } from "vite-plus/test";
14
-
15
-import type { ThreadFeedActivity } from "./threadActivity";
16
-import { buildThreadActivityInspector } from "./threadActivityInspector";
17
-
18
-const threadId = ThreadId.make("thread-1");
19
-const sourceThreadId = ThreadId.make("thread-source");
20
-const runId = RunId.make("run-1");
21
-const nodeId = NodeId.make("node-1");
22
-const startedAt = DateTime.makeUnsafe("2026-06-20T00:00:00.000Z");
23
-const completedAt = DateTime.makeUnsafe("2026-06-20T00:00:02.000Z");
24
-
25
-function itemBase(id: string) {
26
- return {
27
- id: TurnItemId.make(id),
28
- threadId,
29
- runId,
30
- nodeId,
31
- providerThreadId: null,
32
- providerTurnId: null,
33
- nativeItemRef: null,
34
- parentItemId: null,
35
- ordinal: 0,
36
- status: "completed" as const,
37
- title: null,
38
- startedAt,
39
- completedAt,
40
- updatedAt: completedAt,
41
- };
42
-}
43
-
44
-function activityFor(item: OrchestrationV2TurnItem): Pick<ThreadFeedActivity, "projectedItem"> {
45
- const row: OrchestrationV2ProjectedTurnItem = {
46
- position: 0,
47
- visibility: "inherited",
48
- sourceThreadId,
49
- sourceItemId: item.id,
50
- item,
51
- };
52
- return { projectedItem: row };
53
-}
54
-
55
-describe("buildThreadActivityInspector", () => {
56
- it("enables rollback only for the matching ready checkpoint", () => {
57
- const checkpointId = CheckpointId.make("checkpoint-1");
58
- const scopeId = CheckpointScopeId.make("scope-1");
59
- const item: OrchestrationV2TurnItem = {
60
- ...itemBase("checkpoint"),
61
- type: "checkpoint",
62
- checkpointId,
63
- scopeId,
64
- files: [{ path: "src/main.ts", kind: "modified", additions: 2, deletions: 1 }],
65
- };
66
- const checkpoint = { id: checkpointId, scopeId, status: "ready" } as never;
67
- const model = buildThreadActivityInspector(
68
- activityFor(item),
69
- {
70
- ...EMPTY_V2_ITEM_SUPPORT,
71
- item,
72
- checkpoint,
73
- },
74
- sourceThreadId,
75
- );
76
-
77
- expect(model.canRollback).toBe(true);
78
- expect(model.rollbackTarget).toEqual({
79
- threadId: sourceThreadId,
80
- checkpointId,
81
- scopeId,
82
- });
83
-
84
- const inheritedModel = buildThreadActivityInspector(
85
- activityFor(item),
86
- {
87
- ...EMPTY_V2_ITEM_SUPPORT,
88
- item,
89
- checkpoint,
90
- },
91
- ThreadId.make("child-thread"),
92
- );
93
- expect(inheritedModel.canRollback).toBe(false);
94
- expect(inheritedModel.rollbackTarget).toBeNull();
95
- });
96
-});
apps/mobile/src/lib/threadActivityInspector.ts
deleted
-313
@@ -1,313 +0,0 @@
1
-import type { V2ItemSupport } from "@t3tools/client-runtime/state/item-support";
2
-import { toolItemForDisplay } from "@t3tools/client-runtime/work-log/presentation";
3
-import { formatDiffCount } from "@t3tools/client-runtime/diff-count";
4
-import type { ThreadId } from "@t3tools/contracts";
5
-import { formatDuration } from "@t3tools/shared/orchestrationTiming";
6
-import * as DateTime from "effect/DateTime";
7
-
8
-import type { ThreadFeedActivity } from "./threadActivity";
9
-
10
-export interface ThreadActivityInspectorField {
11
- readonly label: string;
12
- readonly value: string;
13
-}
14
-
15
-export interface ThreadActivityInspectorBlock {
16
- readonly label: string;
17
- readonly value: string;
18
- readonly monospaced: boolean;
19
-}
20
-
21
-export interface ThreadActivityFileLink {
22
- readonly label: string;
23
- readonly path: string;
24
- readonly line?: number;
25
-}
26
-
27
-export interface ThreadActivityWebLink {
28
- readonly label: string;
29
- readonly url: string;
30
-}
31
-
32
-export interface ThreadActivityInspectorModel {
33
- readonly fields: ReadonlyArray<ThreadActivityInspectorField>;
34
- readonly blocks: ReadonlyArray<ThreadActivityInspectorBlock>;
35
- readonly fileLinks: ReadonlyArray<ThreadActivityFileLink>;
36
- readonly webLinks: ReadonlyArray<ThreadActivityWebLink>;
37
- readonly canRollback: boolean;
38
- readonly rollbackTarget: {
39
- readonly threadId: ThreadId;
40
- readonly checkpointId: string;
41
- readonly scopeId: string;
42
- } | null;
43
- readonly structuredDetails: string;
44
-}
45
-
46
-function formatStructured(value: unknown): string {
47
- if (typeof value === "string") return value;
48
- try {
49
- return JSON.stringify(value, null, 2) ?? String(value);
50
- } catch {
51
- return String(value);
52
- }
53
-}
54
-
55
-function durationLabel(
56
- startedAt: DateTime.Utc | null,
57
- completedAt: DateTime.Utc | null,
58
-): string | null {
59
- if (startedAt === null) return null;
60
- const start = DateTime.toEpochMillis(startedAt);
61
- const end = completedAt === null ? Date.now() : DateTime.toEpochMillis(completedAt);
62
- return formatDuration(Math.max(0, end - start));
63
-}
64
-
65
-function addBlock(
66
- blocks: ThreadActivityInspectorBlock[],
67
- label: string,
68
- value: unknown,
69
- monospaced = true,
70
-): void {
71
- if (value === undefined || value === null || value === "") return;
72
- blocks.push({ label, value: formatStructured(value), monospaced });
73
-}
74
-
75
-export function buildThreadActivityInspector(
76
- activity: Pick<ThreadFeedActivity, "projectedItem">,
77
- support: V2ItemSupport,
78
- currentThreadId: ThreadId,
79
-): ThreadActivityInspectorModel {
80
- const row = activity.projectedItem;
81
- const item = row.item;
82
- const fields: ThreadActivityInspectorField[] = [
83
- { label: "Item", value: item.type.replaceAll("_", " ") },
84
- { label: "Status", value: item.status.replaceAll("_", " ") },
85
- ];
86
- const duration = durationLabel(item.startedAt, item.completedAt);
87
- if (duration) fields.push({ label: "Duration", value: duration });
88
- if (row.visibility !== "local") fields.push({ label: "Visibility", value: row.visibility });
89
- if (support.run) fields.push({ label: "Run", value: support.run.status });
90
-
91
- const latestAttempt = support.attempts.at(-1);
92
- if (latestAttempt) {
93
- fields.push({
94
- label: "Attempt",
95
- value: `${latestAttempt.attemptOrdinal} · ${latestAttempt.status} · ${latestAttempt.reason.replaceAll("_", " ")}`,
96
- });
97
- }
98
- if (support.node) {
99
- fields.push({
100
- label: "Node",
101
- value: `${support.node.kind.replaceAll("_", " ")} · ${support.node.status}`,
102
- });
103
- }
104
- if (support.providerThread) {
105
- fields.push({
106
- label: "Provider thread",
107
- value: `${support.providerThread.providerInstanceId} · ${support.providerThread.status}`,
108
- });
109
- }
110
- if (support.providerTurn) {
111
- fields.push({ label: "Provider turn", value: support.providerTurn.status });
112
- }
113
- if (support.providerSession) {
114
- fields.push({
115
- label: "Session",
116
- value: `${support.providerSession.status} · ${support.providerSession.model ?? "default model"}`,
117
- });
118
- fields.push({ label: "Working directory", value: support.providerSession.cwd });
119
- }
120
- if (support.runtimeRequest) {
121
- fields.push({
122
- label: "Request",
123
- value: `${support.runtimeRequest.status} · ${support.runtimeRequest.responseCapability.type.replaceAll("_", " ")}`,
124
- });
125
- }
126
-
127
- const blocks: ThreadActivityInspectorBlock[] = [];
128
- const fileLinks: ThreadActivityFileLink[] = [];
129
- const webLinks: ThreadActivityWebLink[] = [];
130
-
131
- if (support.attempts.length > 1) {
132
- addBlock(
133
- blocks,
134
- "Attempt history",
135
- support.attempts
136
- .map(
137
- (attempt) =>
138
- `Attempt ${attempt.attemptOrdinal} · ${attempt.status} · ${attempt.reason.replaceAll("_", " ")}`,
139
- )
140
- .join("\n"),
141
- );
142
- }
143
-
144
- switch (item.type) {
145
- case "reasoning":
146
- addBlock(blocks, "Reasoning", item.text, false);
147
- break;
148
- case "command_execution":
149
- addBlock(blocks, "Command", item.input);
150
- if (item.exitCode !== undefined) {
151
- addBlock(blocks, "Exit", `Process exited with code ${item.exitCode}`);
152
- }
153
- break;
154
- case "file_change":
155
- for (const change of item.changes ?? [{ path: item.fileName, operation: "modify" }]) {
156
- fileLinks.push({
157
- label: `${change.operation} ${change.oldPath ? `${change.oldPath} → ` : ""}${change.path}`,
158
- path: change.path,
159
- });
160
- }
161
- if (item.additions !== undefined || item.deletions !== undefined) {
162
- fields.push({
163
- label: "Changes",
164
- value: `+${formatDiffCount(item.additions ?? 0)} −${formatDiffCount(item.deletions ?? 0)}`,
165
- });
166
- }
167
- break;
168
- case "file_search":
169
- addBlock(blocks, "Query", item.pattern);
170
- for (const result of item.results ?? []) {
171
- fileLinks.push({
172
- label: result.preview ? `${result.fileName}: ${result.preview}` : result.fileName,
173
- path: result.fileName,
174
- ...(result.line === undefined ? {} : { line: result.line }),
175
- });
176
- }
177
- break;
178
- case "web_search":
179
- addBlock(blocks, "Queries", item.patterns?.join("\n"));
180
- for (const result of item.results ?? []) {
181
- if (result.url) {
182
- webLinks.push({
183
- label: result.title ?? result.url,
184
- url: result.url,
185
- });
186
- }
187
- if (result.snippet)
188
- addBlock(blocks, result.title ?? "Search result", result.snippet, false);
189
- }
190
- break;
191
- case "dynamic_tool":
192
- addBlock(blocks, "Input", item.input);
193
- break;
194
- case "approval_request":
195
- addBlock(blocks, "Prompt", item.prompt, false);
196
- break;
197
- case "user_input_request":
198
- addBlock(
199
- blocks,
200
- "Questions",
201
- item.questions.map((question) => question.question).join("\n"),
202
- false,
203
- );
204
- break;
205
- case "checkpoint":
206
- addBlock(
207
- blocks,
208
- "Files",
209
- item.files
210
- .map(
211
- (file) =>
212
- `${file.path} +${formatDiffCount(file.additions)} −${formatDiffCount(file.deletions)} ${file.kind}`,
213
- )
214
- .join("\n"),
215
- );
216
- break;
217
- case "subagent":
218
- addBlock(blocks, "Prompt", item.prompt, false);
219
- addBlock(blocks, "Progress", support.subagent?.progress ?? item.progress, false);
220
- addBlock(blocks, "Result", support.subagent?.result ?? item.result, false);
221
- if (support.subagent) {
222
- fields.push({
223
- label: "Delegated task",
224
- value: `${support.subagent.origin.replaceAll("_", " ")} · ${support.subagent.status}`,
225
- });
226
- }
227
- break;
228
- case "handoff":
229
- addBlock(blocks, "Summary", item.summary, false);
230
- fields.push({
231
- label: "Handoff",
232
- value: `${item.strategy.replaceAll("_", " ")} · ${support.contextHandoff?.status ?? item.status}`,
233
- });
234
- if (support.contextTransfer) {
235
- fields.push({
236
- label: "Transfer",
237
- value: `${support.contextTransfer.type.replaceAll("_", " ")} · ${support.contextTransfer.status}`,
238
- });
239
- if (support.contextTransfer.resolution) {
240
- fields.push({
241
- label: "Context",
242
- value: support.contextTransfer.resolution.strategy.replaceAll("_", " "),
243
- });
244
- }
245
- }
246
- break;
247
- case "error":
248
- addBlock(blocks, "Error", item.failure.message, false);
249
- if (item.failure.code) fields.push({ label: "Code", value: item.failure.code });
250
- if (item.failure.retryable !== null) {
251
- fields.push({ label: "Retryable", value: item.failure.retryable ? "yes" : "no" });
252
- }
253
- break;
254
- case "proposed_plan":
255
- addBlock(blocks, "Plan", item.markdown, false);
256
- break;
257
- case "todo_list":
258
- addBlock(
259
- blocks,
260
- "Tasks",
261
- item.steps
262
- .map((step) => `${step.status === "completed" ? "✓" : "○"} ${step.text}`)
263
- .join("\n"),
264
- false,
265
- );
266
- addBlock(blocks, "Explanation", item.explanation, false);
267
- break;
268
- case "compaction":
269
- addBlock(blocks, "Summary", item.summary, false);
270
- if (item.beforeTokenCount !== undefined || item.afterTokenCount !== undefined) {
271
- fields.push({
272
- label: "Context tokens",
273
- value: `${item.beforeTokenCount ?? "?"} → ${item.afterTokenCount ?? "?"}`,
274
- });
275
- }
276
- break;
277
- case "run_interrupt_request":
278
- case "run_interrupt_result":
279
- addBlock(blocks, "Message", item.message, false);
280
- break;
281
- case "fork":
282
- case "thread_created":
283
- case "user_message":
284
- case "assistant_message":
285
- break;
286
- }
287
-
288
- const checkpoint =
289
- item.type === "checkpoint" && row.sourceThreadId === currentThreadId
290
- ? support.checkpoint
291
- : null;
292
- return {
293
- fields,
294
- blocks,
295
- fileLinks,
296
- webLinks,
297
- canRollback: checkpoint?.status === "ready",
298
- rollbackTarget:
299
- checkpoint?.status === "ready"
300
- ? {
301
- threadId: row.sourceThreadId,
302
- checkpointId: checkpoint.id,
303
- scopeId: checkpoint.scopeId,
304
- }
305
- : null,
306
- structuredDetails: formatStructured({
307
- visibility: row.visibility,
308
- sourceThreadId: row.sourceThreadId,
309
- sourceItemId: row.sourceItemId,
310
- item: toolItemForDisplay(item),
311
- }),
312
- };
313
-}
apps/server/src/cloud/servicePreflight.test.ts
+1
-1
@@ -2,7 +2,7 @@ import { expect, it } from "@effect/vitest";
2
3
import { runServicePreflight } from "./servicePreflight.ts";
4
5
-it.each([1, 2])("blocks legacy launcher protocol %i", (launcherProtocol) => {
5
+it.each([1])("blocks legacy launcher protocol %i", (launcherProtocol) => {
6
expect(
7
runServicePreflight({
8
databasePath: "/missing/state.sqlite",
apps/server/src/mcp/threadAccess.test.ts
-9
@@ -38,12 +38,3 @@ it.effect("points a bare uuid at the mcp: thread it belongs to", () =>
38
expect(error.message).toBe(`The thread was not found. Did you mean \`mcp:${bareId}\`?`);
39
}),
40
);
41
-
42
-it.effect("keeps the plain message for an id that matches nothing", () =>
43
- Effect.gen(function* () {
44
- const error = yield* readBare([]);
45
-
46
- expect(error.code).toBe("thread_not_found");
47
- expect(error.message).toBe("The thread was not found.");
48
- }),
49
-);
apps/server/src/mcp/toolkits/orchestrator/tools.test.ts
deleted
-16
@@ -1,16 +0,0 @@
1
-import { expect, it } from "@effect/vitest";
2
-import { Tool } from "effect/ai";
3
-
4
-import { OrchestratorToolkit } from "./tools.ts";
5
-
6
-// Oversized page sizes clamp on decode, so the schema has no `maximum`; Codex also drops
7
-// bounds from its TypeScript view. The description is the only place a model sees a limit.
8
-it("states t3_thread_read page size limits in the parameter descriptions", () => {
9
- const schema = Tool.getJsonSchema(OrchestratorToolkit.tools.t3_thread_read) as {
10
- readonly properties: Readonly<Record<string, { readonly description?: string }>>;
11
- };
12
- const limits = { limit: "100", runLimit: "50", maxCharsPerItem: "50000" };
13
- for (const [name, maximum] of Object.entries(limits)) {
14
- expect(schema.properties[name]?.description, name).toContain(maximum);
15
- }
16
-});
apps/server/src/mcp/toolkits/preview/tools.test.ts
+1
-20
@@ -3,15 +3,6 @@ import { Tool } from "effect/ai";
3
4
import { PreviewToolkit } from "./tools.ts";
5
6
-const schemaHasDescription = (schema: unknown): boolean => {
7
- if (!schema || typeof schema !== "object") return false;
8
- const record = schema as Record<string, unknown>;
9
- if (typeof record.description === "string" && record.description.length > 0) return true;
10
- return [record.anyOf, record.oneOf, record.allOf]
11
- .filter(Array.isArray)
12
- .some((members) => members.some(schemaHasDescription));
13
-};
14
-
6
const schemaHasMultipleAllOfDescriptions = (schema: unknown): boolean => {
7
if (!schema || typeof schema !== "object") return false;
8
const record = schema as Record<string, unknown>;
@@ -25,7 +16,7 @@ const schemaHasMultipleAllOfDescriptions = (schema: unknown): boolean => {
16
return descriptionCount > 1 || Object.values(record).some(schemaHasMultipleAllOfDescriptions);
17
};
18
28
-it("exports provider-compatible object schemas with described parameters", () => {
19
+it("exports provider-compatible object schemas", () => {
20
for (const tool of Object.values(PreviewToolkit.tools)) {
21
const schema = Tool.getJsonSchema(tool) as {
22
readonly type?: unknown;
@@ -33,10 +24,6 @@ it("exports provider-compatible object schemas with described parameters", () =>
24
readonly anyOf?: unknown;
25
readonly oneOf?: unknown;
26
};
36
- expect(
37
- tool.description?.length ?? 0,
38
- `${tool.name} should have a useful description`,
39
- ).toBeGreaterThan(40);
27
expect(schema.type, `${tool.name} must export a top-level object schema`).toBe("object");
28
expect(schema.anyOf, `${tool.name} must not export a root anyOf`).toBeUndefined();
29
expect(schema.oneOf, `${tool.name} must not export a root oneOf`).toBeUndefined();
@@ -47,11 +34,5 @@ it("exports provider-compatible object schemas with described parameters", () =>
34
schema.properties?.tabId,
35
`${tool.name} must allow an explicit collaborative browser tab target`,
36
).toBeDefined();
50
- for (const [field, fieldSchema] of Object.entries(schema.properties ?? {})) {
51
- expect(
52
- schemaHasDescription(fieldSchema),
53
- `${tool.name}.${field} should explain what data the agent must pass`,
54
- ).toBe(true);
55
- }
37
}
38
});
apps/server/src/provider/CodexDeveloperInstructions.test.ts
+15
-45
@@ -1,9 +1,5 @@
1
import * as NodeAssert from "node:assert/strict";
2
3
-import {
4
- T3_CODE_ORCHESTRATION_INSTRUCTIONS,
5
- T3_CODE_ORCHESTRATION_SECTIONS,
6
-} from "@t3tools/provider-core/server/orchestrationInstructions";
3
import { describe, it } from "vite-plus/test";
4
5
import {
@@ -13,49 +9,23 @@ import {
9
10
describe("buildCodexAdditionalContext", () => {
11
describe.each([
16
- { model: "gpt-5.3-codex", reasoningEffort: "high" },
12
{ model: "custom-model", modelName: "Custom 🦊 Model", reasoningEffort: "xhigh" },
13
])("with runtime $model", (runtime) => {
19
- it.each([
20
- undefined,
21
- false,
22
- true,
23
- { browser: false, device: false },
24
- { browser: true, device: false },
25
- { browser: false, device: true },
26
- { browser: true, device: true },
27
- ])("keeps every entry within Codex's per-entry cap with tools %j", (availability) => {
28
- const context = buildCodexAdditionalContext(runtime, availability);
29
-
30
- for (const [key, entry] of Object.entries(context)) {
31
- // Codex counts ceil(UTF-8 bytes / 4) tokens, excluding keys and wrappers.
32
- const bytes = Buffer.byteLength(entry.value, "utf8");
33
- const limit = CODEX_ADDITIONAL_CONTEXT_VALUE_MAX_BYTES;
34
- NodeAssert.ok(
35
- bytes <= limit,
36
- `${key}: ${bytes} UTF-8 bytes exceeds Codex's ${limit}-byte per-entry cap by ${bytes - limit} bytes; split the instructions into separate entries to avoid silent truncation`,
37
- );
38
- }
39
- });
40
- });
41
-
42
- it("delivers all orchestration sections in authored order when keys are sorted", () => {
43
- const context = buildCodexAdditionalContext({
44
- model: "gpt-5.3-codex",
45
- reasoningEffort: "high",
46
- });
47
- const sections = Object.keys(context)
48
- .filter((key) => key.startsWith("t3_code_orchestration_"))
49
- .sort()
50
- .map((key) => context[key]!);
51
-
52
- NodeAssert.deepEqual(
53
- sections,
54
- T3_CODE_ORCHESTRATION_SECTIONS.map((value) => ({ kind: "application", value })),
55
- );
56
- NodeAssert.equal(
57
- sections.map((entry) => entry.value).join("\n\n"),
58
- T3_CODE_ORCHESTRATION_INSTRUCTIONS.trim(),
14
+ it.each([undefined, { browser: true, device: true }])(
15
+ "keeps every entry within Codex's per-entry cap with tools %j",
16
+ (availability) => {
17
+ const context = buildCodexAdditionalContext(runtime, availability);
18
+
19
+ for (const [key, entry] of Object.entries(context)) {
20
+ // Codex counts ceil(UTF-8 bytes / 4) tokens, excluding keys and wrappers.
21
+ const bytes = Buffer.byteLength(entry.value, "utf8");
22
+ const limit = CODEX_ADDITIONAL_CONTEXT_VALUE_MAX_BYTES;
23
+ NodeAssert.ok(
24
+ bytes <= limit,
25
+ `${key}: ${bytes} UTF-8 bytes exceeds Codex's ${limit}-byte per-entry cap by ${bytes - limit} bytes; split the instructions into separate entries to avoid silent truncation`,
26
+ );
27
+ }
28
+ },
29
);
30
});
31
});
apps/server/src/provider/ProviderInstanceRegistryHydration.test.ts
-23
@@ -81,27 +81,4 @@ describe("deriveProviderInstanceConfigMap", () => {
81
82
expect(merged[instanceId]).toBe(settings.providerInstances[instanceId]);
83
});
84
-
85
- it("folds overrides from multiple projects", () => {
86
- const otherInstanceId = ProviderInstanceId.make("claudeAgent_personal");
87
- const otherProjectId = ProjectId.make("project-b");
88
- const settings = settingsWith({
89
- providerInstances: {
90
- [instanceId]: { driver: ProviderDriverKind.make("codex"), enabled: false },
91
- [otherInstanceId]: { driver: ProviderDriverKind.make("claudeAgent"), enabled: false },
92
- },
93
- projectSettingsOverrides: {
94
- [projectId]: { providerInstances: { [instanceId]: { enabled: true } } },
95
- [otherProjectId]: { providerInstances: { [otherInstanceId]: { enabled: true } } },
96
- },
97
- });
98
-
99
- const merged = deriveProviderInstanceConfigMap(settings);
100
-
101
- expect(merged[instanceId]).toEqual({ driver: ProviderDriverKind.make("codex"), enabled: true });
102
- expect(merged[otherInstanceId]).toEqual({
103
- driver: ProviderDriverKind.make("claudeAgent"),
104
- enabled: true,
105
- });
106
- });
84
});
apps/server/src/vcs/VcsProcess.test.ts
-22
@@ -341,28 +341,6 @@ describe("VcsProcess.run", () => {
341
}).pipe(Effect.scoped, provideLive, Effect.provide(NodeServices.layer)),
342
);
343
344
- it.effect("writes stdin before waiting for exit", () =>
345
- Effect.gen(function* () {
346
- const result = yield* run({
347
- operation: "test.stdin",
348
- command: "node",
349
- args: [
350
- "-e",
351
- [
352
- "process.stdin.setEncoding('utf8');",
353
- "let data='';",
354
- "process.stdin.on('data', chunk => { data += chunk; });",
355
- "process.stdin.on('end', () => { process.stdout.write(data); });",
356
- ].join(""),
357
- ],
358
- cwd: process.cwd(),
359
- stdin: "stdin payload",
360
- });
361
-
362
- expect(result.stdout).toBe("stdin payload");
363
- }).pipe(provideLive),
364
- );
365
-
344
it.effect("classifies authentication failures without retaining stderr", () =>
345
Effect.gen(function* () {
346
const secretStderr = "authentication failed for token super-secret-token";
apps/web/src/components/desktopUpdate.logic.test.ts
+11
-14
@@ -65,20 +65,17 @@ describe("desktop update button state", () => {
65
});
66
67
describe("desktop update UI helpers", () => {
68
- it.each([
69
- "owner/repo/extra",
70
- "owner#notes/repo",
71
- "owner/repo#notes",
72
- "owner?tab=notes/repo",
73
- "owner/repo?tab=notes",
74
- ])("falls back to upstream for an invalid configured repository: %s", (repository) => {
75
- expect(getDesktopUpdateReleaseHistoryUrl(repository)).toBe(
76
- "https://github.com/pingdotgg/t3code/releases",
77
- );
78
- expect(getDesktopUpdateReleaseUrl("1.2.3", repository)).toBe(
79
- "https://github.com/pingdotgg/t3code/releases/tag/v1.2.3",
80
- );
81
- });
68
+ it.each(["owner/repo/extra", "owner#notes/repo", "owner/repo?tab=notes"])(
69
+ "falls back to upstream for an invalid configured repository: %s",
70
+ (repository) => {
71
+ expect(getDesktopUpdateReleaseHistoryUrl(repository)).toBe(
72
+ "https://github.com/pingdotgg/t3code/releases",
73
+ );
74
+ expect(getDesktopUpdateReleaseUrl("1.2.3", repository)).toBe(
75
+ "https://github.com/pingdotgg/t3code/releases/tag/v1.2.3",
76
+ );
77
+ },
78
+ );
79
});
80
81
describe("canCheckForUpdate", () => {
apps/web/src/components/pullRequest/pullRequestFileOrder.logic.test.ts
-11
@@ -118,15 +118,4 @@ describe("orderDiffFiles", () => {
118
"src/orphan.spec.ts",
119
]);
120
});
121
-
122
- it("orders the same diff the same way whatever order it arrives in", () => {
123
- const files = [
124
- file("src/a.ts", ['import { b } from "./b";']),
125
- file("src/b.ts"),
126
- file("src/c.ts"),
127
- file("src/a.test.ts"),
128
- file("yarn.lock"),
129
- ];
130
- expect(order(files)).toEqual(order(files.toReversed()));
131
- });
121
});
apps/web/src/components/settings/SnapShotSetupDialog.logic.test.ts
-32
@@ -128,38 +128,6 @@ it("resumes KDE setup after the helper passes its real permission check", () =>
128
expect(captureSetupInitialStep({ ...state, shortcutRegistered: false })).toBe("shortcut");
129
});
130
131
-it("uses the current desktop's access requirements while preserving setup for the others", () => {
132
- const kde: DesktopSnapShotState = {
133
- ...gnome,
134
- linuxDesktop: "kde",
135
- linuxBackend: "kde",
136
- kdeHelper: { status: "not-installed", message: "Install the helper" },
137
- shortcutVerified: false,
138
- };
139
- expect(captureSetupDesktopName(kde)).toBe("KDE Plasma");
140
- expect(captureSetupInitialStep(kde)).toBe("access");
141
- expect(
142
- captureSetupInitialStep({
143
- ...kde,
144
- kdeHelper: { status: "ready", message: "Ready" },
145
- shortcutRegistered: false,
146
- }),
147
- ).toBe("shortcut");
148
-
149
- const niri: DesktopSnapShotState = {
150
- ...gnome,
151
- linuxDesktop: "niri",
152
- linuxBackend: "niri",
153
- shortcutRegistered: false,
154
- };
155
- expect(captureSetupDesktopName(niri)).toBe("Niri");
156
- expect(captureSetupInitialStep(niri)).toBe("shortcut");
157
-
158
- expect(captureSetupDesktopName(gnome)).toBe("GNOME");
159
- expect(captureSetupInitialStep(gnome)).toBe("shortcut");
160
- expect(captureSetupShortcutReady(gnome, false)).toBe(true);
161
-});
162
-
131
it("does not report a successful check when capture support could not be read", () => {
132
expect(captureSetupCheckMessage({ ...gnome, message: "Desktop disconnected" })).toContain(
133
"Still unable to check access",
apps/web/src/components/settings/settingsScopeNavigation.test.ts
+1
-6
@@ -106,12 +106,7 @@ describe("settings scope navigation", () => {
106
expect(router.state.location.search).toEqual(checkoutSearch);
107
});
108
109
- it.each([
110
- "/settings/projects",
111
- "/settings/integrations",
112
- "/settings/source-control",
113
- "/settings/scheduled-tasks",
114
- ] as const)(
109
+ it.each(["/settings/projects", "/settings/scheduled-tasks"] as const)(
110
"keeps %s when regrouping or selecting a target from the shared settings layout",
111
async (to) => {
112
const router = createSettingsRouter();
apps/web/src/lib/embeddedScripts.test.ts
-5
@@ -49,29 +49,24 @@ describe("embeddedScripts", () => {
49
50
it.each([
51
[`python3 -c 'print(1)'`, "python", "print(1)"],
52
- [`python3 -X dev -c 'print(1)'`, "python", "print(1)"],
52
[`py -3 -c 'print(1)'`, "python", "print(1)"],
54
- [`C:\\Python312\\python.exe -c 'print(1)'`, "python", "print(1)"],
53
[`"C:\\Program Files\\Python312\\python.exe" -c 'print(1)'`, "python", "print(1)"],
54
[`node --eval "process.exit(0)"`, "javascript", "process.exit(0)"],
55
[`bun -e 'console.log(Bun.version)'`, "typescript", "console.log(Bun.version)"],
56
[`deno eval 'console.log(1)'`, "typescript", "console.log(1)"],
57
[`deno eval --config deno.json 'console.log(1)'`, "typescript", "console.log(1)"],
60
- [`deno eval --env-file 'console.log(1)'`, "typescript", "console.log(1)"],
58
[`psql -f schema.sql -c 'select 1'`, "sql", "select 1"],
59
[`node -C development -e 'console.log(1)'`, "javascript", "console.log(1)"],
60
[`ruby -e 'puts 1'`, "ruby", "puts 1"],
61
[`ruby -I lib -e 'puts 1'`, "ruby", "puts 1"],
62
[`perl -E 'say 1'`, "perl", "say 1"],
63
[`sqlite3 app.db "select * from users"`, "sql", "select * from users"],
67
- [`psql -d app -c 'select 1'`, "sql", "select 1"],
64
[`pwsh -NoProfile -Command "Get-ChildItem"`, "powershell", "Get-ChildItem"],
65
[`env FOO=1 sudo -u bob python3 -c 'print(1)'`, "python", "print(1)"],
66
[`env -- FOO=1 python3 -c 'print(1)'`, "python", "print(1)"],
67
[`node --eval="process.exit(0)"`, "javascript", "process.exit(0)"],
68
[`psql --command='select 1'`, "sql", "select 1"],
69
[`mysql -c -e 'select 1'`, "sql", "select 1"],
74
- [`mysql -f app <<'EOF'\nselect 1;\nEOF`, "sql", "select 1;\n"],
70
[`psql app <<'EOF'\nselect 1;\nEOF`, "sql", "select 1;\n"],
71
[`echo "$(node -e 'console.log(1)')"`, "javascript", "console.log(1)"],
72
[`python3 <<< 'print(1)'`, "python", "print(1)"],
apps/web/src/lib/snapShotShortcut.test.ts
-10
@@ -5,18 +5,13 @@ import { parseDesktopSnapShotShortcut, snapShotShortcutKeyLabels } from "./snapS
5
describe("desktop-approved window capture shortcut labels", () => {
6
it.each([
7
["Press <Shift><Control>2", ["Ctrl", "⇧", "2"]],
8
- ["<Control><Shift>2", ["Ctrl", "⇧", "2"]],
8
["Ctrl+Shift+8", ["Ctrl", "⇧", "8"]],
10
- ["CTRL+SHIFT+8", ["Ctrl", "⇧", "8"]],
9
["Meta+F12", ["Super", "F12"]],
12
- ["Super+F8", ["Super", "F8"]],
10
["<Primary><Alt>Return", ["Ctrl", "Alt", "Enter"]],
11
["<Super>Left", ["Super", "Left"]],
12
["<Control>space", ["Ctrl", "Space"]],
13
["<Control>plus", ["Ctrl", "+"]],
17
- ["<Control>+", ["Ctrl", "+"]],
14
["Ctrl++", ["Ctrl", "+"]],
19
- [" Ctrl + Shift + 2 ", ["Ctrl", "⇧", "2"]],
15
])("formats %s using the shared keycap labels", (label, expected) => {
16
const shortcut = parseDesktopSnapShotShortcut(label);
17
expect(shortcut).not.toBeNull();
@@ -25,14 +20,9 @@ describe("desktop-approved window capture shortcut labels", () => {
20
21
it.each([
22
"",
28
- " ",
29
- "Press ",
23
"Ctrl+",
24
"Press the shortcut configured in your desktop",
32
- "Ctrl+Shift+2 or Ctrl+Shift+3",
33
- "Press <Control>2 or <Control>3",
25
"<Unknown>2",
35
- "<Control>",
26
"<Control>UnknownKey",
27
])("does not guess keys from an unrecognized description: %s", (label) => {
28
expect(parseDesktopSnapShotShortcut(label)).toBeNull();
apps/web/src/lib/threadSort.test.ts
deleted
-85
@@ -1,85 +0,0 @@
1
-import { describe, expect, it } from "vite-plus/test";
2
-import {
3
- DEFAULT_RUNTIME_MODE,
4
- EnvironmentId,
5
- ProjectId,
6
- ProviderInstanceId,
7
- ThreadId,
8
-} from "@t3tools/contracts";
9
-import type { Thread } from "../types";
10
-import { makeThreadFixture, type ThreadFixtureOverrides } from "../test-fixtures";
11
-import { sortThreads } from "./threadSort";
12
-
13
-const LOCAL_ENVIRONMENT_ID = EnvironmentId.make("environment-local");
14
-const PROJECT_ID = ProjectId.make("project-1");
15
-
16
-function makeThread(overrides: ThreadFixtureOverrides = {}): Thread {
17
- return makeThreadFixture({
18
- id: ThreadId.make("thread-1"),
19
- environmentId: LOCAL_ENVIRONMENT_ID,
20
- projectId: PROJECT_ID,
21
- title: "Thread",
22
- modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
23
- runtimeMode: DEFAULT_RUNTIME_MODE,
24
- interactionMode: "default",
25
- runtime: null,
26
- messages: [],
27
- proposedPlans: [],
28
- createdAt: "2026-03-09T10:00:00.000Z",
29
- archivedAt: null,
30
- settledOverride: null,
31
- settledAt: null,
32
- deletedAt: null,
33
- updatedAt: "2026-03-09T10:00:00.000Z",
34
- latestRun: null,
35
- branch: null,
36
- worktreePath: null,
37
- ...overrides,
38
- });
39
-}
40
-
41
-describe("sortThreads", () => {
42
- it("sorts threads by the latest user message in recency mode", () => {
43
- const sorted = sortThreads(
44
- [
45
- makeThread({
46
- id: ThreadId.make("thread-1"),
47
- updatedAt: "2026-03-09T10:10:00.000Z",
48
- messages: [
49
- {
50
- id: "message-1" as never,
51
- role: "user",
52
- text: "older",
53
- runId: null,
54
- createdAt: "2026-03-09T10:01:00.000Z",
55
- updatedAt: "2026-03-09T10:01:00.000Z",
56
- streaming: false,
57
- },
58
- ],
59
- }),
60
- makeThread({
61
- id: ThreadId.make("thread-2"),
62
- createdAt: "2026-03-09T10:05:00.000Z",
63
- updatedAt: "2026-03-09T10:05:00.000Z",
64
- messages: [
65
- {
66
- id: "message-2" as never,
67
- role: "user",
68
- text: "newer",
69
- runId: null,
70
- createdAt: "2026-03-09T10:06:00.000Z",
71
- updatedAt: "2026-03-09T10:06:00.000Z",
72
- streaming: false,
73
- },
74
- ],
75
- }),
76
- ],
77
- "updated_at",
78
- );
79
-
80
- expect(sorted.map((thread) => thread.id)).toEqual([
81
- ThreadId.make("thread-2"),
82
- ThreadId.make("thread-1"),
83
- ]);
84
- });
85
-});
apps/web/src/onboarding/projectImport.logic.test.ts
-22
@@ -192,28 +192,6 @@ describe("resolveOnboardingProjectId", () => {
192
),
193
).toBeNull();
194
});
195
-
196
- it("finds the current root owner when the scan has no project ID", () => {
197
- const recreatedProjectId = ProjectId.make("recreated-project");
198
- expect(
199
- resolveOnboardingProjectId(
200
- [
201
- {
202
- id: localProjectId,
203
- environmentId: localEnvironmentId,
204
- workspaceRoot: "/projects/other",
205
- },
206
- {
207
- id: recreatedProjectId,
208
- environmentId: localEnvironmentId,
209
- workspaceRoot: "/projects/repo",
210
- },
211
- ],
212
- localEnvironmentId,
213
- candidate("/projects/repo"),
214
- ),
215
- ).toBe(recreatedProjectId);
216
- });
195
});
196
197
describe("resolveOnboardingLandingProject", () => {
apps/web/src/threadRoutes.test.ts
-2
@@ -57,9 +57,7 @@ describe("threadRoutes", () => {
57
58
it.each([
59
{ status: "cached", source: "server thread" },
60
- { status: "synchronizing", source: "server thread" },
60
{ status: "cached", source: "draft" },
62
- { status: "synchronizing", source: "draft" },
61
] as const)(
62
"keeps available $source visible while the shell is $status",
63
({ status, source }) => {
packages/client-runtime/src/providerSkills.test.ts
-59
@@ -4,7 +4,6 @@ import { describe, expect, it } from "vite-plus/test";
4
import {
5
getProviderSkillsForSlashMenu,
6
hasCompleteProviderWorkspaceSnapshot,
7
- resolveProviderForCwd,
7
resolveProviderSkillsForCwd,
8
resolveProviderSlashCommandsForCwd,
9
} from "./providerSkills.ts";
@@ -124,61 +123,3 @@ describe("workspace provider snapshots", () => {
123
expect(hasCompleteProviderWorkspaceSnapshot(provider, null)).toBe(false);
124
});
125
});
127
-
128
-describe("resolveProviderForCwd", () => {
129
- it("switches workspace options for every model without changing the machine catalog", () => {
130
- const reasoning = {
131
- id: "reasoning",
132
- label: "Reasoning",
133
- type: "select" as const,
134
- options: [{ id: "high", label: "High" }],
135
- };
136
- const globalAgent = {
137
- id: "agent",
138
- label: "Agent",
139
- type: "select" as const,
140
- options: [{ id: "build", label: "Build" }],
141
- };
142
- const workspaceAgent = {
143
- ...globalAgent,
144
- options: [{ id: "readonly", label: "Readonly" }],
145
- };
146
- const emptyAgent = { ...globalAgent, options: [] };
147
- const catalog: ServerProvider = {
148
- ...provider,
149
- models: [
150
- {
151
- slug: "model",
152
- name: "Model",
153
- isCustom: false,
154
- capabilities: { optionDescriptors: [globalAgent, reasoning] },
155
- },
156
- { slug: "custom", name: "Custom", isCustom: true, capabilities: null },
157
- { slug: "legacy", name: "Legacy", isCustom: false, capabilities: {} },
158
- ],
159
- workspaceSnapshots: [
160
- ...provider.workspaceSnapshots,
161
- ...[workspaceAgent, emptyAgent].map((agent, index) => ({
162
- ...provider.workspaceSnapshots[0]!,
163
- cwd: `/workspace/options-${index}`,
164
- optionDescriptors: [agent],
165
- })),
166
- ],
167
- };
168
- const original = structuredClone(catalog);
169
-
170
- for (const [index, agent] of [workspaceAgent, emptyAgent, workspaceAgent].entries()) {
171
- const scoped = resolveProviderForCwd(catalog, `/workspace/options-${index % 2}`);
172
- expect(scoped.models.map((model) => model.capabilities?.optionDescriptors)).toEqual([
173
- expect.arrayContaining([reasoning, agent]),
174
- [agent],
175
- [agent],
176
- ]);
177
- expect(scoped.models[0]?.capabilities?.optionDescriptors).toHaveLength(2);
178
- }
179
- expect(catalog).toEqual(original);
180
- expect(resolveProviderForCwd(catalog, "/workspace/unknown")).toBe(catalog);
181
- expect(resolveProviderForCwd(catalog, "/workspace/project-a")).toBe(catalog);
182
- expect(resolveProviderForCwd(catalog, null)).toBe(catalog);
183
- });
184
-});
packages/client-runtime/src/providerSkills.ts
-24
@@ -114,30 +114,6 @@ export function hasCurrentProviderWorkspaceSnapshot(
114
);
115
}
116
117
-export function resolveProviderForCwd(
118
- provider: ServerProvider,
119
- cwd: string | null | undefined,
120
-): ServerProvider {
121
- const descriptors = resolveProviderWorkspaceSnapshot(provider, cwd)?.optionDescriptors;
122
- if (descriptors === undefined) return provider;
123
- const overriddenIds = new Set(descriptors.map((descriptor) => descriptor.id));
124
- return {
125
- ...provider,
126
- models: provider.models.map((model) => ({
127
- ...model,
128
- capabilities: {
129
- ...model.capabilities,
130
- optionDescriptors: [
131
- ...(model.capabilities?.optionDescriptors ?? []).filter(
132
- (descriptor) => !overriddenIds.has(descriptor.id),
133
- ),
134
- ...descriptors,
135
- ],
136
- },
137
- })),
138
- };
139
-}
140
-
117
export function resolveProviderSkillsForCwd(
118
provider: ServerProvider,
119
cwd: string | null | undefined,
packages/client-runtime/src/state/sharedSettings.test.ts
+1
-167
@@ -1,20 +1,12 @@
1
import {
2
DEFAULT_SERVER_SETTINGS,
3
- EnvironmentId,
3
ProviderDriverKind,
4
ProviderInstanceId,
5
} from "@t3tools/contracts";
6
import { describe, expect, it } from "@effect/vitest";
7
9
-import {
10
- filterSharedServerPatch,
11
- findSharedSettingsMismatches,
12
- pickSharedServerSettings,
13
-} from "./sharedSettings.ts";
8
+import { filterSharedServerPatch, pickSharedServerSettings } from "./sharedSettings.ts";
9
15
-const primaryId = EnvironmentId.make("env-primary");
16
-const laptopId = EnvironmentId.make("env-laptop");
17
-const boxId = EnvironmentId.make("env-box");
10
const restartCapabilities = { threadRestartContinuation: true };
11
12
describe("filterSharedServerPatch", () => {
@@ -82,19 +74,6 @@ describe("filterSharedServerPatch", () => {
74
expect(filterSharedServerPatch(patch, restartCapabilities, settings, sourceSettings)).toEqual(
75
availability === "enabled" ? patch : { sidebarAutoSettleAfterDays: 7 },
76
);
85
- const primarySettings = {
86
- ...sourceSettings,
87
- textGenerationModelSelection: selection,
88
- };
89
- expect(
90
- findSharedSettingsMismatches({
91
- primaryEnvironmentId: primaryId,
92
- primarySettings,
93
- environments: [
94
- { environmentId: boxId, label: "Remote Box", syncEligible: true, settings },
95
- ],
96
- }),
97
- ).toEqual(availability === "enabled" ? [{ environmentId: boxId, label: "Remote Box" }] : []);
77
},
78
);
79
@@ -113,148 +92,3 @@ describe("filterSharedServerPatch", () => {
92
},
93
);
94
});
116
-
117
-describe("findSharedSettingsMismatches", () => {
118
- const primarySettings = { ...DEFAULT_SERVER_SETTINGS, sidebarAutoSettleAfterDays: 7 };
119
-
120
- it.each([true, false])(
121
- "detects remote restart continuation drift when the preference is %s",
122
- (enabled) => {
123
- const settings = { ...primarySettings, continueThreadsAfterServerUpdate: enabled };
124
- const remoteSettings = { ...settings, continueThreadsAfterServerUpdate: !enabled };
125
- const environment = {
126
- environmentId: boxId,
127
- label: "Remote Box",
128
- syncEligible: true,
129
- settings: remoteSettings,
130
- capabilities: restartCapabilities,
131
- };
132
- expect(
133
- findSharedSettingsMismatches({
134
- primaryEnvironmentId: primaryId,
135
- primarySettings: settings,
136
- primaryCapabilities: restartCapabilities,
137
- environments: [environment],
138
- }),
139
- ).toEqual([{ environmentId: boxId, label: "Remote Box" }]);
140
- expect(
141
- findSharedSettingsMismatches({
142
- primaryEnvironmentId: primaryId,
143
- primarySettings: settings,
144
- primaryCapabilities: restartCapabilities,
145
- environments: [
146
- {
147
- ...environment,
148
- settings: Object.assign(
149
- {},
150
- remoteSettings,
151
- pickSharedServerSettings(settings, restartCapabilities),
152
- ),
153
- },
154
- ],
155
- }),
156
- ).toEqual([]);
157
- },
158
- );
159
-
160
- it.each([
161
- [undefined, restartCapabilities],
162
- [restartCapabilities, undefined],
163
- [undefined, undefined],
164
- ])(
165
- "ignores restart drift unless both servers support it (%j, %j)",
166
- (primaryCapabilities, capabilities) => {
167
- const environment = {
168
- environmentId: boxId,
169
- label: "Remote Box",
170
- syncEligible: true,
171
- capabilities,
172
- settings: { ...primarySettings, continueThreadsAfterServerUpdate: true },
173
- };
174
- const input = {
175
- primaryEnvironmentId: primaryId,
176
- primarySettings,
177
- primaryCapabilities,
178
- environments: [environment],
179
- };
180
- expect(findSharedSettingsMismatches(input)).toEqual([]);
181
- expect(
182
- findSharedSettingsMismatches({
183
- ...input,
184
- environments: [
185
- {
186
- ...environment,
187
- settings: { ...environment.settings, sidebarAutoSettleAfterDays: 14 },
188
- },
189
- ],
190
- }),
191
- ).toEqual([{ environmentId: boxId, label: "Remote Box" }]);
192
- },
193
- );
194
-
195
- it("lists sync-eligible environments whose shared settings differ", () => {
196
- const mismatches = findSharedSettingsMismatches({
197
- primaryEnvironmentId: primaryId,
198
- primarySettings,
199
- environments: [
200
- {
201
- environmentId: primaryId,
202
- label: "Desktop",
203
- syncEligible: true,
204
- settings: primarySettings,
205
- },
206
- {
207
- environmentId: laptopId,
208
- label: "Laptop",
209
- syncEligible: true,
210
- settings: primarySettings,
211
- },
212
- {
213
- environmentId: boxId,
214
- label: "Remote Box",
215
- syncEligible: true,
216
- settings: DEFAULT_SERVER_SETTINGS,
217
- },
218
- ],
219
- });
220
- expect(mismatches).toEqual([{ environmentId: boxId, label: "Remote Box" }]);
221
- });
222
-
223
- it("ignores machine-only differences", () => {
224
- const mismatches = findSharedSettingsMismatches({
225
- primaryEnvironmentId: primaryId,
226
- primarySettings,
227
- environments: [
228
- {
229
- environmentId: boxId,
230
- label: "Remote Box",
231
- syncEligible: true,
232
- settings: {
233
- ...primarySettings,
234
- enableAgentBrowserAccess: false,
235
- defaultThreadEnvMode:
236
- primarySettings.defaultThreadEnvMode === "local" ? "worktree" : "local",
237
- },
238
- },
239
- ],
240
- });
241
- expect(mismatches).toEqual([]);
242
- });
243
-
244
- it("skips ineligible environments and environments without a loaded config", () => {
245
- const mismatches = findSharedSettingsMismatches({
246
- primaryEnvironmentId: primaryId,
247
- primarySettings,
248
- environments: [
249
- {
250
- environmentId: laptopId,
251
- label: "Laptop",
252
- syncEligible: false,
253
- settings: DEFAULT_SERVER_SETTINGS,
254
- },
255
- { environmentId: boxId, label: "Remote Box", syncEligible: true, settings: null },
256
- ],
257
- });
258
- expect(mismatches).toEqual([]);
259
- });
260
-});
packages/client-runtime/src/state/sharedSettings.ts
-58
@@ -5,7 +5,6 @@ import type {
5
ServerSettingsPatch,
6
} from "@t3tools/contracts";
7
import { isModelSelectionProviderEnabled } from "@t3tools/shared/serverSettings";
8
-import * as Equal from "effect/Equal";
8
import * as Struct from "effect/Struct";
9
10
import type { EnvironmentConnectionPhase } from "../connection/presentation.ts";
@@ -97,60 +96,3 @@ export function supportsSharedSettingsSync(environment: {
96
environment.serverConfig?.environment.capabilities.threadAutoSettlement === true
97
);
98
}
100
-
101
-export interface SharedSettingsEnvironment {
102
- readonly environmentId: EnvironmentId;
103
- readonly label: string;
104
- readonly syncEligible: boolean;
105
- readonly settings: ServerSettings | null;
106
- readonly capabilities?:
107
- | Pick<ExecutionEnvironmentCapabilities, "threadRestartContinuation">
108
- | undefined;
109
-}
110
-
111
-/**
112
- * Callers must pass the real loaded settings, never a default fallback, or
113
- * "apply to all" would push defaults over real values.
114
- */
115
-export function findSharedSettingsMismatches(input: {
116
- readonly primaryEnvironmentId: EnvironmentId | null;
117
- readonly primarySettings: ServerSettings | null;
118
- readonly primaryCapabilities?:
119
- | Pick<ExecutionEnvironmentCapabilities, "threadRestartContinuation">
120
- | undefined;
121
- readonly environments: ReadonlyArray<SharedSettingsEnvironment>;
122
-}): ReadonlyArray<{ readonly environmentId: EnvironmentId; readonly label: string }> {
123
- if (input.primaryEnvironmentId === null || input.primarySettings === null) {
124
- return [];
125
- }
126
- const primarySettings = pickSharedServerSettings(
127
- input.primarySettings,
128
- input.primaryCapabilities,
129
- );
130
- return input.environments.flatMap((environment) => {
131
- if (
132
- environment.environmentId === input.primaryEnvironmentId ||
133
- !environment.syncEligible ||
134
- environment.settings === null
135
- ) {
136
- return [];
137
- }
138
- const expected = filterSharedServerPatch(
139
- primarySettings,
140
- environment.capabilities,
141
- environment.settings,
142
- input.primarySettings ?? undefined,
143
- );
144
- let actual = filterSharedServerPatch(
145
- pickSharedServerSettings(environment.settings, environment.capabilities),
146
- input.primaryCapabilities,
147
- environment.settings,
148
- );
149
- if (!expected.textGenerationModelSelection) {
150
- actual = Struct.omit(actual, ["textGenerationModelSelection"]);
151
- }
152
- return Equal.equals(actual, expected)
153
- ? []
154
- : [{ environmentId: environment.environmentId, label: environment.label }];
155
- });
156
-}
packages/client-runtime/src/state/threadFeedback.test.ts
-15
@@ -4,26 +4,11 @@ import * as Cause from "effect/Cause";
4
import { AsyncResult } from "effect/reactivity";
5
6
import {
7
- beginCodexFeedbackSubmission,
7
codexFeedbackNotice,
8
submitCodexFeedback,
9
type CodexFeedbackSubmission,
10
} from "./threadFeedback.ts";
11
13
-describe("beginCodexFeedbackSubmission", () => {
14
- it("allows only one upload per thread until the active upload releases its guard", () => {
15
- const inFlight = new Set<string>();
16
- const finish = beginCodexFeedbackSubmission(inFlight, "environment:thread");
17
-
18
- expect(finish).not.toBeNull();
19
- expect(beginCodexFeedbackSubmission(inFlight, "environment:thread")).toBeNull();
20
- expect(beginCodexFeedbackSubmission(inFlight, "environment:other-thread")).not.toBeNull();
21
-
22
- finish?.();
23
- expect(beginCodexFeedbackSubmission(inFlight, "environment:thread")).not.toBeNull();
24
- });
25
-});
26
-
12
describe("submitCodexFeedback", () => {
13
const submission = {
14
id: MessageId.make("feedback-message-1"),
packages/client-runtime/src/state/threadFeedback.ts
-9
@@ -44,15 +44,6 @@ export function codexFeedbackNotice(submission: CodexFeedbackSubmission) {
44
}
45
}
46
47
-export function beginCodexFeedbackSubmission(
48
- submissionsInFlight: Set<string>,
49
- threadKey: string,
50
-): (() => void) | null {
51
- if (submissionsInFlight.has(threadKey)) return null;
52
- submissionsInFlight.add(threadKey);
53
- return () => submissionsInFlight.delete(threadKey);
54
-}
55
-
47
export interface LocalChatMessage {
48
readonly id: MessageId;
49
readonly role: "user" | "assistant";
packages/client-runtime/src/work-log/commandLabel.test.ts
-20
@@ -31,37 +31,17 @@ describe("commandProgramName", () => {
31
32
it.each([
33
"if test -f package.json; then vp test; fi",
34
- "[ -f package.json ]",
34
"[[ -f package.json ]]",
35
"test -f package.json",
36
'for file in *; do echo "$file"; done',
38
- "while true; do sleep 1; done",
39
- "until false; do sleep 1; done",
40
- "case $name in test) vp test;; esac",
41
- 'select item in one two; do echo "$item"; done',
42
- "function check() { vp test; }",
37
"check() { vp test; }",
44
- "k(){ echo ok; }; k",
38
"{ vp test; }",
46
- "(vp test)",
39
"(( count += 1 ))",
48
- "! vp test",
49
- ":",
40
". ./script.sh",
51
- "source ./script.sh",
52
- "eval 'vp test'",
53
- "cd packages/client-runtime",
41
"export NODE_ENV=test",
55
- "local name=value",
56
- "set -e",
57
- "alias ll='ls -la'",
42
"repeat 3 echo ok",
59
- "and vp test",
43
"return 1",
61
- "break",
62
- "continue",
44
"true",
64
- "false",
45
])("falls back for shell syntax and internal control commands: %s", (command) => {
46
expect(commandProgramName(command)).toBeNull();
47
});
packages/client-runtime/src/work-log/presentation.test.ts
-64
@@ -4,8 +4,6 @@ import { ThreadId, TurnItemId, type OrchestrationV2TurnItem } from "@t3tools/con
4
import * as DateTime from "effect/DateTime";
5
6
import {
7
- commandDetailRepeatsCommand,
8
- extractCommandOutputText,
7
resolveWorkEntryToolPresentation,
8
toolItemForDisplay,
9
type WorkLogPresentationEntry,
@@ -182,65 +180,3 @@ describe("resolveWorkEntryToolPresentation", () => {
180
).toBeNull();
181
});
182
});
185
-
186
-describe("command work-log details", () => {
187
- it("extracts Claude result blocks and projected output", () => {
188
- expect(
189
- extractCommandOutputText({
190
- result: {
191
- content: [
192
- { type: "text", text: "first" },
193
- { type: "text", text: "second" },
194
- ],
195
- },
196
- }),
197
- ).toBe("first\nsecond");
198
- expect(extractCommandOutputText({ rawOutput: { content: "projected summary" } })).toBe(
199
- "projected summary",
200
- );
201
- });
202
-
203
- it("treats an ingestion-truncated echo of a long command as a repeat", () => {
204
- const command = `git add -A && git commit -m "${"x".repeat(200)}"`;
205
- const truncated = `Bash: ${command}`.slice(0, 177) + "...";
206
- expect(
207
- commandDetailRepeatsCommand({
208
- detail: truncated,
209
- command,
210
- rawCommand: null,
211
- toolName: "Bash",
212
- data: { toolName: "Bash", command },
213
- }),
214
- ).toBe(true);
215
- expect(
216
- commandDetailRepeatsCommand({
217
- detail: "Bash: printf hello...",
218
- command: "printf goodbye",
219
- rawCommand: null,
220
- toolName: "Bash",
221
- data: { toolName: "Bash", command: "printf goodbye" },
222
- }),
223
- ).toBe(false);
224
- });
225
-
226
- it("treats ACP command echoes as synthetic even without a tool kind", () => {
227
- expect(
228
- commandDetailRepeatsCommand({
229
- detail: "pnpm test",
230
- command: "pnpm test",
231
- rawCommand: null,
232
- toolName: undefined,
233
- data: { toolCallId: "tool-1", command: "pnpm test" },
234
- }),
235
- ).toBe(true);
236
- expect(
237
- commandDetailRepeatsCommand({
238
- detail: "pnpm test",
239
- command: "pnpm test",
240
- rawCommand: null,
241
- toolName: undefined,
242
- data: { command: "pnpm test" },
243
- }),
244
- ).toBe(false);
245
- });
246
-});
packages/client-runtime/src/work-log/presentation.ts
-129
@@ -235,135 +235,6 @@ function nonEmptyString(value: unknown): string | null {
235
return typeof value === "string" && value.trim().length > 0 ? value : null;
236
}
237
238
-function commandResultContent(value: unknown): string | null {
239
- const direct = nonEmptyString(value);
240
- if (direct) return direct;
241
-
242
- const directContent = Array.isArray(value) ? value : null;
243
- const record = asRecord(value);
244
- const content = record?.content;
245
- const contentText = nonEmptyString(content);
246
- if (contentText) return contentText;
247
- const blocks = directContent ?? (Array.isArray(content) ? content : null);
248
- if (!blocks) return null;
249
-
250
- const chunks = blocks.flatMap((entry) => {
251
- const text = nonEmptyString(entry) ?? nonEmptyString(asRecord(entry)?.text);
252
- return text ? [text] : [];
253
- });
254
- return chunks.length > 0 ? chunks.join("\n") : null;
255
-}
256
-
257
-export function extractCommandOutputText(dataValue: unknown): string | null {
258
- const data = asRecord(dataValue);
259
- const item = asRecord(data?.item);
260
- const itemResult = asRecord(item?.result);
261
- const rawOutput = asRecord(data?.rawOutput);
262
- const outputStreams = [
263
- nonEmptyString(rawOutput?.stdout),
264
- nonEmptyString(rawOutput?.stderr),
265
- ].filter((value): value is string => value !== null);
266
- const acpContent = Array.isArray(data?.content)
267
- ? data.content
268
- .flatMap((entryValue) => {
269
- const entry = asRecord(entryValue);
270
- const content = asRecord(entry?.content);
271
- const text = entry?.type === "content" ? nonEmptyString(content?.text) : null;
272
- return text ? [text] : [];
273
- })
274
- .join("\n")
275
- : null;
276
-
277
- const candidates = [
278
- item?.aggregatedOutput,
279
- itemResult?.content,
280
- data?.rawOutput,
281
- rawOutput?.content,
282
- outputStreams.length > 0 ? outputStreams.join("\n") : null,
283
- rawOutput?.output,
284
- acpContent,
285
- data?.result,
286
- ];
287
- for (const candidate of candidates) {
288
- const text = commandResultContent(candidate);
289
- if (text) return text;
290
- }
291
- return null;
292
-}
293
-
294
-/**
295
- * Ingestion caps tool details at 180 chars and appends "...", so a long command
296
- * echo no longer equals the command it repeats. Treat a truncated prefix of the
297
- * command as the same echo.
298
- */
299
-function textRepeatsCommand(text: string, commands: ReadonlyArray<string | null>): boolean {
300
- const truncated = text.endsWith("...")
301
- ? text.slice(0, -3)
302
- : text.endsWith("\u2026")
303
- ? text.slice(0, -1)
304
- : null;
305
- return commands.some((candidate) => {
306
- const command = candidate?.trim();
307
- if (!command) return false;
308
- if (command === text) return true;
309
- return (
310
- truncated !== null &&
311
- truncated.length > 0 &&
312
- command.length > truncated.length &&
313
- command.startsWith(truncated)
314
- );
315
- });
316
-}
317
-
318
-/**
319
- * OpenCode stores completed output in `detail` with no other output channel, so
320
- * plain equality is only treated as synthetic when the payload shape shows the
321
- * detail came from the command: Codex item metadata, an ACP tool call
322
- * (`data.toolCallId`, `kind: "execute"`), a Claude tool-name prefix, or no
323
- * structured command at all.
324
- */
325
-export function commandDetailRepeatsCommand(input: {
326
- readonly detail: string;
327
- readonly command: string | null;
328
- readonly rawCommand: string | null;
329
- readonly toolName: unknown;
330
- readonly data: unknown;
331
-}): boolean {
332
- const toolName = nonEmptyString(input.toolName)?.trim();
333
- const detail = input.detail.trim();
334
- const commands = [input.command, input.rawCommand];
335
- if (toolName) {
336
- const prefix = `${toolName}:`;
337
- if (detail.toLowerCase().startsWith(prefix.toLowerCase())) {
338
- const unprefixed = detail.slice(prefix.length).trim();
339
- if (textRepeatsCommand(unprefixed, commands)) return true;
340
- }
341
- }
342
-
343
- if (!textRepeatsCommand(detail, commands)) return false;
344
-
345
- const data = asRecord(input.data);
346
- const item = asRecord(data?.item);
347
- const itemInput = asRecord(item?.input);
348
- const itemResult = asRecord(item?.result);
349
- const hasStructuredCommand = [
350
- item?.command,
351
- itemInput?.command,
352
- itemResult?.command,
353
- data?.command,
354
- ].some((value) =>
355
- Array.isArray(value)
356
- ? value.some((part) => nonEmptyString(part) !== null)
357
- : nonEmptyString(value) !== null,
358
- );
359
- return (
360
- !hasStructuredCommand ||
361
- item !== null ||
362
- data?.toolCallId !== undefined ||
363
- nonEmptyString(data?.kind)?.toLowerCase() === "execute"
364
- );
365
-}
366
-
238
function workLogEntryIsToolLike(entry: WorkLogPresentationEntry): boolean {
239
if (entry.tone === "tool" || entry.tone === "thinking" || entry.tone === "error") return true;
240
if (entry.command !== undefined && entry.command.trim().length > 0) return true;
packages/contracts/src/browserProfile.test.ts
-7
@@ -4,7 +4,6 @@ import {
4
BUILT_IN_BROWSER_PROFILES,
5
DEFAULT_BROWSER_PROFILE_ID,
6
INCOGNITO_BROWSER_PROFILE_ID,
7
- findBrowserProfile,
7
resolveBrowserProfiles,
8
type BrowserProfile,
9
} from "./browserProfile.ts";
@@ -21,12 +20,6 @@ describe("resolveBrowserProfiles", () => {
20
21
expect(resolved).toEqual([...BUILT_IN_BROWSER_PROFILES, work]);
22
});
24
-
25
- it("keeps incognito ephemeral", () => {
26
- const incognito = findBrowserProfile(resolveBrowserProfiles([]), INCOGNITO_BROWSER_PROFILE_ID);
27
-
28
- expect(incognito?.kind).toBe("incognito");
29
- });
23
});
24
25
describe("resolveBrowserProfiles normalization", () => {
packages/contracts/src/preview.test.ts
+1
-12
@@ -1,22 +1,11 @@
1
import { Schema } from "effect";
2
import { describe, expect, it } from "vite-plus/test";
3
4
-import {
5
- PreviewAutomationHost,
6
- PreviewAutomationOpenInput,
7
- PreviewAutomationStatus,
8
-} from "./previewAutomation.ts";
4
+import { PreviewAutomationHost, PreviewAutomationStatus } from "./previewAutomation.ts";
5
10
-const decodeOpenInput = Schema.decodeUnknownSync(PreviewAutomationOpenInput);
6
const decodeAutomationHost = Schema.decodeUnknownSync(PreviewAutomationHost);
7
const decodeAutomationStatus = Schema.decodeUnknownSync(PreviewAutomationStatus);
8
14
-describe("PreviewAutomationOpenInput", () => {
15
- it("retains the legacy show visibility alias", () => {
16
- expect(decodeOpenInput({ show: false })).toEqual({ show: false });
17
- });
18
-});
19
-
9
describe("PreviewAutomationHost", () => {
10
it("accepts legacy hosts and current operation advertisements", () => {
11
expect(decodeAutomationHost({ clientId: "legacy", environmentId: "environment-1" })).toEqual({
packages/contracts/src/provider.test.ts
+1
-37
@@ -2,46 +2,10 @@ import { describe, expect, it } from "vite-plus/test";
2
import * as Schema from "effect/Schema";
3
4
import { ThreadId } from "./baseSchemas.ts";
5
-import {
6
- ProviderSendTurnInput,
7
- ProviderSessionStartInput,
8
- ProviderUploadFeedbackError,
9
-} from "./provider.ts";
5
+import { ProviderSendTurnInput, ProviderUploadFeedbackError } from "./provider.ts";
6
11
-const decodeProviderSessionStartInput = Schema.decodeUnknownSync(ProviderSessionStartInput);
7
const decodeProviderSendTurnInput = Schema.decodeUnknownSync(ProviderSendTurnInput);
8
14
-function getOptionValue(
15
- options: ReadonlyArray<{ id: string; value: unknown }> | undefined,
16
- id: string,
17
-): unknown {
18
- return options?.find((option) => option.id === id)?.value;
19
-}
20
-
21
-describe("ProviderSessionStartInput", () => {
22
- it("accepts codex-compatible payloads", () => {
23
- const parsed = decodeProviderSessionStartInput({
24
- threadId: "thread-1",
25
- provider: "codex",
26
- cwd: "/tmp/workspace",
27
- modelSelection: {
28
- provider: "codex",
29
- model: "gpt-5.3-codex",
30
- options: [
31
- { id: "reasoningEffort", value: "high" },
32
- { id: "fastMode", value: true },
33
- ],
34
- },
35
- runtimeMode: "full-access",
36
- });
37
- expect(parsed.runtimeMode).toBe("full-access");
38
- expect(parsed.modelSelection?.instanceId).toBe("codex");
39
- expect(parsed.modelSelection?.model).toBe("gpt-5.3-codex");
40
- expect(getOptionValue(parsed.modelSelection?.options, "reasoningEffort")).toBe("high");
41
- expect(getOptionValue(parsed.modelSelection?.options, "fastMode")).toBe(true);
42
- });
43
-});
44
-
9
describe("ProviderSendTurnInput", () => {
10
it.each(["image", "file"])(
11
"caps total image bytes for %s attachments without charging videos",
packages/contracts/src/server.test.ts
-20
@@ -75,26 +75,6 @@ describe("server config forward compatibility", () => {
75
describe("ServerObservability", () => {
76
const decodeServerObservability = Schema.decodeUnknownSync(ServerObservability);
77
78
- it("reads where each running endpoint came from", () => {
79
- const parsed = decodeServerObservability({
80
- logsDirectoryPath: "/tmp/t3/logs",
81
- localTracingEnabled: true,
82
- otlpTracesUrl: "https://collector.example.com/v1/traces",
83
- otlpTracesSource: "environment",
84
- otlpTracesVariable: "OTEL_EXPORTER_OTLP_ENDPOINT",
85
- otlpTracesEnabled: true,
86
- otlpMetricsUrl: "https://collector.example.com/v1/metrics",
87
- otlpMetricsSource: "settings",
88
- otlpMetricsEnabled: true,
89
- otlpLogsEnabled: false,
90
- });
91
-
92
- expect(parsed.otlpTracesSource).toBe("environment");
93
- expect(parsed.otlpTracesVariable).toBe("OTEL_EXPORTER_OTLP_ENDPOINT");
94
- expect(parsed.otlpMetricsSource).toBe("settings");
95
- expect(parsed.otlpLogsSource).toBeUndefined();
96
- });
97
-
78
it("rejects an unknown endpoint source", () => {
79
expect(() =>
80
decodeServerObservability({
packages/provider-acp/package.json
-4
@@ -19,10 +19,6 @@
19
"types": "./src/server/clientTerminals.ts",
20
"import": "./src/server/clientTerminals.ts"
21
},
22
- "./server/coreRuntimeEvents": {
23
- "types": "./src/server/coreRuntimeEvents.ts",
24
- "import": "./src/server/coreRuntimeEvents.ts"
25
- },
22
"./server/mcpOverAcpBridge": {
23
"types": "./src/server/mcpOverAcpBridge.ts",
24
"import": "./src/server/mcpOverAcpBridge.ts"
packages/provider-acp/src/server/coreRuntimeEvents.test.ts
deleted
-247
@@ -1,247 +0,0 @@
1
-import { ProviderDriverKind, RuntimeRequestId, TurnId } from "@t3tools/contracts";
2
-import { describe, expect, it } from "vite-plus/test";
3
-
4
-import {
5
- makeAcpAssistantItemEvent,
6
- makeAcpContentDeltaEvent,
7
- makeAcpPlanUpdatedEvent,
8
- makeAcpRequestOpenedEvent,
9
- makeAcpRequestResolvedEvent,
10
- makeAcpToolCallEvent,
11
-} from "./coreRuntimeEvents.ts";
12
-
13
-describe("AcpCoreRuntimeEvents", () => {
14
- it("maps ACP permission requests to canonical runtime events", () => {
15
- const stamp = { eventId: "event-1" as never, createdAt: "2026-03-27T00:00:00.000Z" };
16
- const turnId = TurnId.make("turn-1");
17
- const permissionRequest = {
18
- kind: "execute" as const,
19
- detail: "cat package.json",
20
- toolCall: {
21
- toolCallId: "tool-1",
22
- kind: "execute",
23
- status: "pending" as const,
24
- command: "cat package.json",
25
- detail: "cat package.json",
26
- data: { toolCallId: "tool-1", kind: "execute" },
27
- },
28
- };
29
-
30
- const openedEvent = makeAcpRequestOpenedEvent({
31
- stamp,
32
- provider: ProviderDriverKind.make("cursor"),
33
- threadId: "thread-1" as never,
34
- turnId,
35
- requestId: RuntimeRequestId.make("request-1"),
36
- permissionRequest,
37
- detail: "cat package.json",
38
- args: { command: ["cat", "package.json"] },
39
- source: "acp.jsonrpc",
40
- method: "session/request_permission",
41
- rawPayload: { sessionId: "session-1" },
42
- });
43
- expect(openedEvent).toMatchObject({
44
- type: "request.opened",
45
- payload: {
46
- requestType: "exec_command_approval",
47
- detail: "cat package.json",
48
- },
49
- });
50
- expect(openedEvent).not.toHaveProperty("payload.options");
51
-
52
- expect(
53
- makeAcpRequestResolvedEvent({
54
- stamp,
55
- provider: ProviderDriverKind.make("cursor"),
56
- threadId: "thread-1" as never,
57
- turnId,
58
- requestId: RuntimeRequestId.make("request-1"),
59
- permissionRequest,
60
- decision: "accept",
61
- }),
62
- ).toMatchObject({
63
- type: "request.resolved",
64
- payload: {
65
- requestType: "exec_command_approval",
66
- decision: "accept",
67
- },
68
- });
69
- });
70
-
71
- it("preserves a native file approval without a remembered-allow choice", () => {
72
- const event = makeAcpRequestOpenedEvent({
73
- stamp: { eventId: "approval-1" as never, createdAt: "2026-09-02T00:00:00.000Z" },
74
- provider: ProviderDriverKind.make("antigravity"),
75
- threadId: "thread-1" as never,
76
- turnId: TurnId.make("turn-1"),
77
- requestId: RuntimeRequestId.make("request-1"),
78
- permissionRequest: { kind: "edit" },
79
- approvalOptions: [
80
- { decision: "accept", label: "Allow once" },
81
- { decision: "decline", label: "Reject" },
82
- ],
83
- detail: "Edit package.json",
84
- args: {},
85
- source: "acp.jsonrpc",
86
- method: "session/request_permission",
87
- rawPayload: { sessionId: "session-1" },
88
- });
89
-
90
- expect(event.payload).toEqual({
91
- requestType: "file_change_approval",
92
- detail: "Edit package.json",
93
- args: {},
94
- options: [
95
- { decision: "accept", label: "Allow once" },
96
- { decision: "decline", label: "Reject" },
97
- ],
98
- });
99
- });
100
-
101
- it("maps generic ACP permission kinds to dynamic tool approvals", () => {
102
- const stamp = { eventId: "event-1" as never, createdAt: "2026-03-27T00:00:00.000Z" };
103
-
104
- for (const kind of ["search", "fetch", "other", "unknown", "future-tool-kind"]) {
105
- const permissionRequest = { kind };
106
- const request = {
107
- stamp,
108
- provider: ProviderDriverKind.make("cursor"),
109
- threadId: "thread-1" as never,
110
- turnId: TurnId.make("turn-1"),
111
- requestId: RuntimeRequestId.make(`request-${kind}`),
112
- permissionRequest,
113
- };
114
-
115
- expect(
116
- makeAcpRequestOpenedEvent({
117
- ...request,
118
- detail: kind,
119
- args: {},
120
- source: "acp.jsonrpc",
121
- method: "session/request_permission",
122
- rawPayload: { sessionId: "session-1" },
123
- }),
124
- ).toMatchObject({
125
- type: "request.opened",
126
- payload: { requestType: "dynamic_tool_call" },
127
- });
128
-
129
- expect(
130
- makeAcpRequestResolvedEvent({
131
- ...request,
132
- decision: "accept",
133
- }),
134
- ).toMatchObject({
135
- type: "request.resolved",
136
- payload: { requestType: "dynamic_tool_call" },
137
- });
138
- }
139
- });
140
-
141
- it("maps ACP core plan, tool-call, and content updates", () => {
142
- const stamp = { eventId: "event-1" as never, createdAt: "2026-03-27T00:00:00.000Z" };
143
- const turnId = TurnId.make("turn-1");
144
-
145
- expect(
146
- makeAcpPlanUpdatedEvent({
147
- stamp,
148
- provider: ProviderDriverKind.make("cursor"),
149
- threadId: "thread-1" as never,
150
- turnId,
151
- payload: {
152
- nativePlanId: "plan-1",
153
- kind: "items",
154
- plan: [{ step: "Inspect state", status: "inProgress" }],
155
- },
156
- source: "acp.cursor.extension",
157
- method: "cursor/update_todos",
158
- rawPayload: { todos: [] },
159
- }),
160
- ).toMatchObject({
161
- type: "turn.plan.updated",
162
- raw: {
163
- method: "cursor/update_todos",
164
- },
165
- });
166
-
167
- expect(
168
- makeAcpToolCallEvent({
169
- stamp,
170
- provider: ProviderDriverKind.make("cursor"),
171
- threadId: "thread-1" as never,
172
- turnId,
173
- toolCall: {
174
- toolCallId: "tool-1",
175
- kind: "execute",
176
- status: "completed",
177
- title: "Terminal",
178
- detail: "bun run test",
179
- data: { command: "bun run test" },
180
- },
181
- rawPayload: { sessionId: "session-1" },
182
- }),
183
- ).toMatchObject({
184
- type: "item.completed",
185
- payload: {
186
- itemType: "command_execution",
187
- status: "completed",
188
- },
189
- });
190
-
191
- expect(
192
- makeAcpContentDeltaEvent({
193
- stamp,
194
- provider: ProviderDriverKind.make("cursor"),
195
- threadId: "thread-1" as never,
196
- turnId,
197
- itemId: "assistant:session-1:segment:0",
198
- text: "hello",
199
- rawPayload: { sessionId: "session-1" },
200
- }),
201
- ).toMatchObject({
202
- type: "content.delta",
203
- itemId: "assistant:session-1:segment:0",
204
- payload: {
205
- delta: "hello",
206
- },
207
- });
208
-
209
- expect(
210
- makeAcpAssistantItemEvent({
211
- stamp,
212
- provider: ProviderDriverKind.make("cursor"),
213
- threadId: "thread-1" as never,
214
- turnId,
215
- itemId: "assistant:session-1:segment:0",
216
- lifecycle: "item.started",
217
- }),
218
- ).toMatchObject({
219
- type: "item.started",
220
- itemId: "assistant:session-1:segment:0",
221
- payload: {
222
- itemType: "assistant_message",
223
- status: "inProgress",
224
- },
225
- });
226
- });
227
-
228
- it("maps thoughts to the reasoning stream", () => {
229
- expect(
230
- makeAcpContentDeltaEvent({
231
- stamp: { eventId: "thought-1" as never, createdAt: "2026-09-02T00:00:00.000Z" },
232
- provider: ProviderDriverKind.make("cursor"),
233
- threadId: "thread-1" as never,
234
- turnId: TurnId.make("turn-1"),
235
- streamKind: "reasoning_text",
236
- text: "Inspect the current implementation first.",
237
- rawPayload: { sessionId: "session-1" },
238
- }),
239
- ).toMatchObject({
240
- type: "content.delta",
241
- payload: {
242
- streamKind: "reasoning_text",
243
- delta: "Inspect the current implementation first.",
244
- },
245
- });
246
- });
247
-});
packages/provider-acp/src/server/coreRuntimeEvents.ts
deleted
-255
@@ -1,255 +0,0 @@
1
-import {
2
- type RuntimeEventRawSource,
3
- RuntimeItemId,
4
- type CanonicalRequestType,
5
- type EventId,
6
- type ProviderApprovalDecision,
7
- type ProviderApprovalOption,
8
- type ProviderDriverKind,
9
- type ProviderRuntimeEvent,
10
- type RuntimeRequestId,
11
- type ThreadId,
12
- type TurnId,
13
-} from "@t3tools/contracts";
14
-
15
-import {
16
- type AcpPermissionRequest,
17
- type AcpPlanUpdate,
18
- type AcpToolCallState,
19
- canonicalItemTypeFromAcpToolKind,
20
-} from "./runtimeModel.ts";
21
-
22
-type AcpAdapterRawSource = Extract<
23
- RuntimeEventRawSource,
24
- "acp.jsonrpc" | `acp.${string}.extension`
25
->;
26
-
27
-interface AcpEventStamp {
28
- readonly eventId: EventId;
29
- readonly createdAt: string;
30
-}
31
-
32
-type AcpCanonicalRequestType = Extract<
33
- CanonicalRequestType,
34
- "exec_command_approval" | "file_read_approval" | "file_change_approval" | "dynamic_tool_call"
35
->;
36
-
37
-function canonicalRequestTypeFromAcpKind(kind: string | "unknown"): AcpCanonicalRequestType {
38
- switch (kind) {
39
- case "execute":
40
- return "exec_command_approval";
41
- case "read":
42
- return "file_read_approval";
43
- case "edit":
44
- case "delete":
45
- case "move":
46
- return "file_change_approval";
47
- default:
48
- return "dynamic_tool_call";
49
- }
50
-}
51
-
52
-function runtimeItemStatusFromAcpToolStatus(
53
- status: AcpToolCallState["status"],
54
-): "inProgress" | "completed" | "failed" | undefined {
55
- switch (status) {
56
- case "pending":
57
- case "inProgress":
58
- return "inProgress";
59
- case "completed":
60
- return "completed";
61
- case "failed":
62
- return "failed";
63
- default:
64
- return undefined;
65
- }
66
-}
67
-
68
-export function makeAcpRequestOpenedEvent(input: {
69
- readonly stamp: AcpEventStamp;
70
- readonly provider: ProviderDriverKind;
71
- readonly threadId: ThreadId;
72
- readonly turnId: TurnId | undefined;
73
- readonly requestId: RuntimeRequestId;
74
- readonly permissionRequest: AcpPermissionRequest;
75
- readonly approvalOptions?: ReadonlyArray<ProviderApprovalOption>;
76
- readonly detail: string;
77
- readonly args: unknown;
78
- readonly source: AcpAdapterRawSource;
79
- readonly method: string;
80
- readonly rawPayload: unknown;
81
-}): ProviderRuntimeEvent {
82
- return {
83
- type: "request.opened",
84
- ...input.stamp,
85
- provider: input.provider,
86
- threadId: input.threadId,
87
- turnId: input.turnId,
88
- requestId: input.requestId,
89
- payload: {
90
- requestType: canonicalRequestTypeFromAcpKind(input.permissionRequest.kind),
91
- detail: input.detail,
92
- args: input.args,
93
- ...(input.approvalOptions !== undefined ? { options: input.approvalOptions } : {}),
94
- },
95
- raw: {
96
- source: input.source,
97
- method: input.method,
98
- payload: input.rawPayload,
99
- },
100
- };
101
-}
102
-
103
-export function makeAcpRequestResolvedEvent(input: {
104
- readonly stamp: AcpEventStamp;
105
- readonly provider: ProviderDriverKind;
106
- readonly threadId: ThreadId;
107
- readonly turnId: TurnId | undefined;
108
- readonly requestId: RuntimeRequestId;
109
- readonly permissionRequest: AcpPermissionRequest;
110
- readonly decision: ProviderApprovalDecision;
111
-}): ProviderRuntimeEvent {
112
- return {
113
- type: "request.resolved",
114
- ...input.stamp,
115
- provider: input.provider,
116
- threadId: input.threadId,
117
- turnId: input.turnId,
118
- requestId: input.requestId,
119
- payload: {
120
- requestType: canonicalRequestTypeFromAcpKind(input.permissionRequest.kind),
121
- decision: input.decision,
122
- },
123
- };
124
-}
125
-
126
-export function makeAcpPlanUpdatedEvent(input: {
127
- readonly stamp: AcpEventStamp;
128
- readonly provider: ProviderDriverKind;
129
- readonly threadId: ThreadId;
130
- readonly turnId: TurnId | undefined;
131
- readonly payload: AcpPlanUpdate;
132
- readonly source: AcpAdapterRawSource;
133
- readonly method: string;
134
- readonly rawPayload: unknown;
135
-}): ProviderRuntimeEvent {
136
- const payload =
137
- input.payload.kind === "items"
138
- ? {
139
- plan: input.payload.plan,
140
- ...(input.payload.explanation == null ? {} : { explanation: input.payload.explanation }),
141
- }
142
- : input.payload.kind === "removed"
143
- ? { plan: [] }
144
- : {
145
- plan: [
146
- {
147
- step:
148
- input.payload.kind === "markdown"
149
- ? input.payload.markdown
150
- : input.payload.kind === "file"
151
- ? `Plan file: ${input.payload.uri}`
152
- : `[Unsupported ACP plan content: ${input.payload.contentType}]`,
153
- status: "pending" as const,
154
- },
155
- ],
156
- };
157
- return {
158
- type: "turn.plan.updated",
159
- ...input.stamp,
160
- provider: input.provider,
161
- threadId: input.threadId,
162
- turnId: input.turnId,
163
- payload,
164
- raw: {
165
- source: input.source,
166
- method: input.method,
167
- payload: input.rawPayload,
168
- },
169
- };
170
-}
171
-
172
-export function makeAcpToolCallEvent(input: {
173
- readonly stamp: AcpEventStamp;
174
- readonly provider: ProviderDriverKind;
175
- readonly threadId: ThreadId;
176
- readonly turnId: TurnId | undefined;
177
- readonly toolCall: AcpToolCallState;
178
- readonly rawPayload: unknown;
179
-}): ProviderRuntimeEvent {
180
- const runtimeStatus = runtimeItemStatusFromAcpToolStatus(input.toolCall.status);
181
- return {
182
- type:
183
- input.toolCall.status === "completed" || input.toolCall.status === "failed"
184
- ? "item.completed"
185
- : "item.updated",
186
- ...input.stamp,
187
- provider: input.provider,
188
- threadId: input.threadId,
189
- turnId: input.turnId,
190
- itemId: RuntimeItemId.make(input.toolCall.toolCallId),
191
- payload: {
192
- itemType: canonicalItemTypeFromAcpToolKind(input.toolCall.kind),
193
- ...(runtimeStatus ? { status: runtimeStatus } : {}),
194
- ...(input.toolCall.title ? { title: input.toolCall.title } : {}),
195
- ...(input.toolCall.detail ? { detail: input.toolCall.detail } : {}),
196
- ...(Object.keys(input.toolCall.data).length > 0 ? { data: input.toolCall.data } : {}),
197
- },
198
- raw: {
199
- source: "acp.jsonrpc",
200
- method: "session/update",
201
- payload: input.rawPayload,
202
- },
203
- };
204
-}
205
-
206
-export function makeAcpAssistantItemEvent(input: {
207
- readonly stamp: AcpEventStamp;
208
- readonly provider: ProviderDriverKind;
209
- readonly threadId: ThreadId;
210
- readonly turnId: TurnId | undefined;
211
- readonly itemId: string;
212
- readonly lifecycle: "item.started" | "item.completed";
213
-}): ProviderRuntimeEvent {
214
- return {
215
- type: input.lifecycle,
216
- ...input.stamp,
217
- provider: input.provider,
218
- threadId: input.threadId,
219
- turnId: input.turnId,
220
- itemId: RuntimeItemId.make(input.itemId),
221
- payload: {
222
- itemType: "assistant_message",
223
- status: input.lifecycle === "item.completed" ? "completed" : "inProgress",
224
- },
225
- };
226
-}
227
-
228
-export function makeAcpContentDeltaEvent(input: {
229
- readonly stamp: AcpEventStamp;
230
- readonly provider: ProviderDriverKind;
231
- readonly threadId: ThreadId;
232
- readonly turnId: TurnId | undefined;
233
- readonly itemId?: string;
234
- readonly streamKind?: "assistant_text" | "reasoning_text";
235
- readonly text: string;
236
- readonly rawPayload: unknown;
237
-}): ProviderRuntimeEvent {
238
- return {
239
- type: "content.delta",
240
- ...input.stamp,
241
- provider: input.provider,
242
- threadId: input.threadId,
243
- turnId: input.turnId,
244
- ...(input.itemId ? { itemId: RuntimeItemId.make(input.itemId) } : {}),
245
- payload: {
246
- streamKind: input.streamKind ?? "assistant_text",
247
- delta: input.text,
248
- },
249
- raw: {
250
- source: "acp.jsonrpc",
251
- method: "session/update",
252
- payload: input.rawPayload,
253
- },
254
- };
255
-}
packages/provider-acp/src/server/runtimeModel.ts
+1
-1
@@ -793,7 +793,7 @@ function normalizeToolKind(kind: unknown): string | undefined {
793
return typeof kind === "string" && kind.trim().length > 0 ? kind.trim() : undefined;
794
}
795
796
-export function canonicalItemTypeFromAcpToolKind(kind: string | undefined): ToolLifecycleItemType {
796
+function canonicalItemTypeFromAcpToolKind(kind: string | undefined): ToolLifecycleItemType {
797
switch (kind) {
798
case "read":
799
return "dynamic_tool_call";
packages/provider-grok/src/server/xaiBackgroundTasks.test.ts
deleted
-190
@@ -1,190 +0,0 @@
1
-import { describe, expect, it } from "vite-plus/test";
2
-import { TurnId } from "@t3tools/contracts";
3
-
4
-import {
5
- buildGrokBackgroundTaskEvents,
6
- type GrokBackgroundTaskRecord,
7
-} from "./xaiBackgroundTasks.ts";
8
-
9
-const turnId = TurnId.make("turn-1");
10
-const monitor = { type: "Monitor", taskId: "monitor-1", timeoutMs: 60_000 };
11
-const shell = { type: "BackgroundTaskStarted", task_id: "shell-1", command: "sleep 40" };
12
-
13
-function mapper() {
14
- const tasks = new Map<string, GrokBackgroundTaskRecord>();
15
- const update = (
16
- rawOutput: unknown,
17
- overrides: Partial<Parameters<typeof buildGrokBackgroundTaskEvents>[0]> = {},
18
- ) =>
19
- buildGrokBackgroundTaskEvents({
20
- tasks,
21
- toolCallId: "call-1",
22
- rawInput: { description: "Watch" },
23
- rawOutput,
24
- toolCallStatus: "completed",
25
- turnId,
26
- ...overrides,
27
- });
28
- return { tasks, update };
29
-}
30
-
31
-describe("Grok background tasks", () => {
32
- it.each([
33
- [monitor, "monitor-1", "monitor", "Watch"],
34
- [shell, "shell-1", "shell", "sleep 40"],
35
- ] as const)("starts and deduplicates %j", (output, id, taskType, description) => {
36
- const { tasks, update } = mapper();
37
- expect(update(output)).toEqual([
38
- {
39
- type: "task.started",
40
- turnId,
41
- payload: { taskId: id, taskType, description, title: description, toolUseId: "call-1" },
42
- },
43
- ]);
44
- expect(update(output)).toEqual([]);
45
- expect(tasks.size).toBe(1);
46
- });
47
-
48
- it("accepts automatic backgrounding before the tool becomes terminal", () => {
49
- const { update } = mapper();
50
- expect(update(shell, { toolCallStatus: "inProgress" })[0]?.type).toBe("task.started");
51
- expect(update(monitor, { toolCallStatus: "inProgress" })).toEqual([]);
52
- expect(update(monitor, { toolCallStatus: "failed" })).toEqual([]);
53
- });
54
-
55
- it.each([
56
- ["running", null, "task.progress", undefined],
57
- ["failed", 1, "task.completed", "failed"],
58
- ["stopped", 137, "task.completed", "stopped"],
59
- [undefined, 1, "task.completed", "failed"],
60
- ])("maps poll status %s / exit %s", (status, exit_code, type, expectedStatus) => {
61
- const { tasks, update } = mapper();
62
- update(monitor);
63
- const events = update({
64
- type: "TaskOutput",
65
- Result: {
66
- task_id: "monitor-1",
67
- command: "[monitor:Watch]",
68
- status,
69
- exit_code,
70
- output: "\n result\nmore",
71
- },
72
- });
73
- expect(events).toEqual([
74
- {
75
- type,
76
- turnId,
77
- payload: {
78
- taskId: "monitor-1",
79
- taskType: "monitor",
80
- description: "Watch",
81
- title: "Watch",
82
- toolUseId: "call-1",
83
- summary: "result",
84
- ...(expectedStatus ? { status: expectedStatus } : {}),
85
- },
86
- },
87
- ]);
88
- expect(tasks.size).toBe(type === "task.progress" ? 1 : 0);
89
- });
90
-
91
- it.each([undefined, TurnId.make("turn-2")])(
92
- "does not attribute old tasks to a later turn: %s",
93
- (laterTurnId) => {
94
- const { tasks, update } = mapper();
95
- update(shell);
96
- const events = update(
97
- {
98
- type: "TaskOutput",
99
- Result: { task_id: "shell-1", command: "sleep 40", status: "completed" },
100
- },
101
- { turnId: laterTurnId },
102
- );
103
- expect(events).toHaveLength(1);
104
- expect(events[0]?.turnId).toBeUndefined();
105
- expect(tasks.size).toBe(0);
106
- },
107
- );
108
-
109
- it("starts unknown poll tasks before progress or completion and ignores subagents", () => {
110
- const { tasks, update } = mapper();
111
- const events = update({
112
- type: "TaskOutput",
113
- MultiResult: {
114
- results: [
115
- { task_id: "shell-1", command: "sleep 40", status: "running" },
116
- { task_id: "monitor-1", command: "[monitor] Watch", status: "completed" },
117
- { task_id: "agent-1", command: "[subagent:executor] work", status: "running" },
118
- ],
119
- },
120
- });
121
- expect(events.map(({ type }) => type)).toEqual([
122
- "task.started",
123
- "task.progress",
124
- "task.started",
125
- "task.completed",
126
- ]);
127
- expect(events.map(({ payload }) => payload.taskType)).toEqual([
128
- "shell",
129
- "shell",
130
- "monitor",
131
- "monitor",
132
- ]);
133
- expect([...tasks.keys()]).toEqual(["shell-1"]);
134
- expect(events.map((event) => event.turnId)).toEqual([
135
- undefined,
136
- undefined,
137
- undefined,
138
- undefined,
139
- ]);
140
- });
141
-
142
- it("retires only successfully killed tasks, including mixed results", () => {
143
- const { tasks, update } = mapper();
144
- update(shell);
145
- update(monitor);
146
- const result = { type: "KillTask", Result: { task_id: "shell-1", outcome: "killed" } };
147
- expect(update(result, { toolCallStatus: "failed" })).toEqual([]);
148
- expect(tasks.size).toBe(2);
149
- const events = update({
150
- type: "KillTask",
151
- MultiResult: {
152
- results: [
153
- result.Result,
154
- { task_id: "monitor-1", outcome: "error" },
155
- { task_id: "unknown", outcome: "killed" },
156
- ],
157
- },
158
- });
159
- expect(events).toEqual([
160
- {
161
- type: "task.completed",
162
- turnId,
163
- payload: {
164
- taskId: "shell-1",
165
- taskType: "shell",
166
- description: "sleep 40",
167
- title: "sleep 40",
168
- toolUseId: "call-1",
169
- status: "stopped",
170
- },
171
- },
172
- ]);
173
- expect([...tasks.keys()]).toEqual(["monitor-1"]);
174
- });
175
-
176
- it.each([
177
- { type: "Text", text: "subagent_id: fake\ntype: executor\ndescription: fake" },
178
- { type: "BackgroundTaskStarted", task_id: "shell-1" },
179
- {
180
- type: "TaskOutput",
181
- MultiResult: {
182
- results: [null, {}, { task_id: "task", command: "sleep 40", exit_code: Infinity }],
183
- },
184
- },
185
- ])("ignores malformed or unrelated outputs: %j", (output) => {
186
- const { tasks, update } = mapper();
187
- expect(update(output)).toEqual([]);
188
- expect(tasks.size).toBe(0);
189
- });
190
-});
packages/provider-grok/src/server/xaiBackgroundTasks.ts
deleted
-155
@@ -1,155 +0,0 @@
1
-import {
2
- RuntimeTaskId,
3
- type ProviderRuntimeTaskStartedEvent,
4
- type ProviderRuntimeTaskProgressEvent,
5
- type ProviderRuntimeTaskCompletedEvent,
6
- type TurnId,
7
-} from "@t3tools/contracts";
8
-
9
-type TaskEvent =
10
- | Pick<ProviderRuntimeTaskStartedEvent, "type" | "payload" | "turnId">
11
- | Pick<ProviderRuntimeTaskProgressEvent, "type" | "payload" | "turnId">
12
- | Pick<ProviderRuntimeTaskCompletedEvent, "type" | "payload" | "turnId">;
13
-
14
-export interface GrokBackgroundTaskRecord {
15
- readonly payload: {
16
- readonly taskId: RuntimeTaskId;
17
- readonly taskType: "monitor" | "shell";
18
- readonly description: string;
19
- readonly title: string;
20
- readonly toolUseId?: string;
21
- };
22
- readonly turnId: TurnId | undefined;
23
-}
24
-
25
-function record(value: unknown): Record<string, unknown> {
26
- return typeof value === "object" && value !== null && !Array.isArray(value)
27
- ? (value as Record<string, unknown>)
28
- : {};
29
-}
30
-
31
-function text(value: unknown): string | undefined {
32
- return typeof value === "string" ? value.trim() || undefined : undefined;
33
-}
34
-
35
-function lifecycle(status: unknown, exitCode: unknown) {
36
- switch (text(status)?.toLowerCase()) {
37
- case "pending":
38
- case "running":
39
- return "running";
40
- case "completed":
41
- case "success":
42
- case "succeeded":
43
- return "completed";
44
- case "failed":
45
- case "error":
46
- return "failed";
47
- case "stopped":
48
- case "killed":
49
- case "cancelled":
50
- return "stopped";
51
- default:
52
- return typeof exitCode === "number" && Number.isFinite(exitCode)
53
- ? exitCode === 0
54
- ? "completed"
55
- : "failed"
56
- : undefined;
57
- }
58
-}
59
-
60
-export function buildGrokBackgroundTaskEvents(input: {
61
- readonly tasks: Map<string, GrokBackgroundTaskRecord>;
62
- readonly toolCallId: string;
63
- readonly rawInput: unknown;
64
- readonly rawOutput: unknown;
65
- readonly toolCallStatus: string | undefined;
66
- readonly turnId?: TurnId | undefined;
67
-}): TaskEvent[] {
68
- const { tasks, toolCallId, toolCallStatus, turnId } = input;
69
- const output = record(input.rawOutput);
70
- const events: TaskEvent[] = [];
71
- if (
72
- toolCallStatus !== "completed" &&
73
- toolCallStatus !== "failed" &&
74
- output.type !== "BackgroundTaskStarted"
75
- ) {
76
- return events;
77
- }
78
- const attribution = (task: GrokBackgroundTaskRecord) =>
79
- task.turnId !== undefined && task.turnId === turnId ? { turnId } : {};
80
- const start = (
81
- id: string,
82
- taskType: "monitor" | "shell",
83
- description: string,
84
- toolUseId?: string,
85
- ) => {
86
- const known = tasks.get(id);
87
- if (known) return known;
88
- const task: GrokBackgroundTaskRecord = {
89
- payload: {
90
- taskId: RuntimeTaskId.make(id),
91
- taskType,
92
- description,
93
- title: description,
94
- ...(toolUseId ? { toolUseId } : {}),
95
- },
96
- // Polls can rediscover older tasks without establishing their originating turn.
97
- turnId: toolUseId ? turnId : undefined,
98
- };
99
- tasks.set(id, task);
100
- events.push({ type: "task.started", payload: task.payload, ...attribution(task) });
101
- return task;
102
- };
103
- const complete = (
104
- task: GrokBackgroundTaskRecord,
105
- status: "completed" | "failed" | "stopped",
106
- summary?: string,
107
- ) => {
108
- tasks.delete(task.payload.taskId);
109
- events.push({
110
- type: "task.completed",
111
- payload: { ...task.payload, status, ...(summary ? { summary } : {}) },
112
- ...attribution(task),
113
- });
114
- };
115
-
116
- if (output.type === "Monitor" && toolCallStatus === "completed") {
117
- const id = text(output.taskId);
118
- if (id) start(id, "monitor", text(record(input.rawInput).description) ?? "Monitor", toolCallId);
119
- } else if (output.type === "BackgroundTaskStarted") {
120
- const id = text(output.task_id) ?? text(output.taskId);
121
- const command = text(output.command);
122
- if (id && command) start(id, "shell", command.split("\n")[0]!.slice(0, 200), toolCallId);
123
- } else if (output.type === "TaskOutput" || output.type === "KillTask") {
124
- const results = record(output.MultiResult).results;
125
- for (const value of Array.isArray(results) ? results : [output.Result]) {
126
- const result = record(value);
127
- const id = text(result.task_id);
128
- if (!id) continue;
129
- if (output.type === "KillTask") {
130
- const task = tasks.get(id);
131
- if (task && toolCallStatus === "completed" && result.outcome === "killed")
132
- complete(task, "stopped");
133
- continue;
134
- }
135
- const command = text(result.command);
136
- const status = lifecycle(result.status, result.exit_code);
137
- if (!command || !status || command.startsWith("[subagent:")) continue;
138
- const task = start(id, /^\[monitor[:\]]/.test(command) ? "monitor" : "shell", command);
139
- const summary = text(result.output)
140
- ?.split("\n")
141
- .find((line) => line.trim())
142
- ?.trim();
143
- if (status === "running") {
144
- events.push({
145
- type: "task.progress",
146
- payload: { ...task.payload, ...(summary ? { summary } : {}) },
147
- ...attribution(task),
148
- });
149
- } else {
150
- complete(task, status, summary);
151
- }
152
- }
153
- }
154
- return events;
155
-}
packages/shared/package.json
-4
@@ -411,10 +411,6 @@
411
"types": "./src/hostClassification.ts",
412
"import": "./src/hostClassification.ts"
413
},
414
- "./dateTime": {
415
- "types": "./src/dateTime.ts",
416
- "import": "./src/dateTime.ts"
417
- },
414
"./cliRelease": {
415
"types": "./src/cliRelease.ts",
416
"import": "./src/cliRelease.ts"
packages/shared/src/composerTrigger.test.ts
-3
@@ -43,7 +43,6 @@ describe("detectComposerTrigger", () => {
43
});
44
45
it.each([
46
- "It costs $5",
46
"budget $9.99",
47
"only $.99",
48
"about €20",
@@ -51,8 +50,6 @@ describe("detectComposerTrigger", () => {
50
"$1,000",
51
"£2e6",
52
"raise $10k.",
54
- "is it $5?",
55
- "(about $9.99)",
53
])("does not open the skill menu for the amount in %j", (text) =>
54
expect(detectComposerTrigger(text, text.length)).toBeNull(),
55
);
packages/shared/src/dateTime.test.ts
deleted
-54
@@ -1,54 +0,0 @@
1
-import { describe, expect, it } from "@effect/vitest";
2
-
3
-import { compareDateTimeStrings } from "./dateTime.ts";
4
-
5
-describe("compareDateTimeStrings", () => {
6
- it("compares valid date-time strings by absolute time", () => {
7
- expect(
8
- compareDateTimeStrings("2026-09-01T12:00:00.000Z", "2026-09-01T05:00:00.000-07:00"),
9
- ).toBe(0);
10
- expect(
11
- compareDateTimeStrings("2026-09-01T12:00:01.000Z", "2026-09-01T12:00:00.000Z"),
12
- ).toBeGreaterThan(0);
13
- });
14
-
15
- it.each([
16
- ["2024-02-29T12:00:00Z", "2024-02-29T17:30:00+05:30"],
17
- ["0000-01-01T00:00:00.000Z", "+000000-01-01T00:00:00.000+00:00"],
18
- ["2026-09-01T24:00:00Z", "2026-09-02T00:00:00Z"],
19
- ])("preserves equal ISO instants %s and %s", (left, right) => {
20
- expect(compareDateTimeStrings(left, right)).toBe(0);
21
- });
22
-
23
- it.each(["2014-03-02", "2014-02-30T00:00:00.000Z", "2026-09-01T24:01:00Z"])(
24
- "treats %s as malformed without native date guessing",
25
- (malformed) => {
26
- const valid = "1970-01-01T00:00:00.000Z";
27
- expect(compareDateTimeStrings(malformed, valid)).toBeLessThan(0);
28
- expect(compareDateTimeStrings(valid, malformed)).toBeGreaterThan(0);
29
- expect(compareDateTimeStrings(malformed, "invalid")).toBeLessThan(0);
30
- expect(compareDateTimeStrings("invalid", malformed)).toBeGreaterThan(0);
31
- expect(compareDateTimeStrings(malformed, malformed)).toBe(0);
32
- },
33
- );
34
-
35
- it("gives every permutation of mixed values the same order", () => {
36
- const early = "2026-09-01T12:00:00.000+14:00";
37
- const late = "2026-09-01T00:00:00.000-12:00";
38
- const malformed = "2026-09-01T06:invalid";
39
- const expected = [malformed, early, late];
40
-
41
- const permutations = [
42
- [early, late, malformed],
43
- [early, malformed, late],
44
- [late, early, malformed],
45
- [late, malformed, early],
46
- [malformed, early, late],
47
- [malformed, late, early],
48
- ];
49
-
50
- for (const values of permutations) {
51
- expect(values.toSorted(compareDateTimeStrings)).toEqual(expected);
52
- }
53
- });
54
-});
packages/shared/src/dateTime.ts
deleted
-37
@@ -1,37 +0,0 @@
1
-import * as DateTime from "effect/DateTime";
2
-import * as Option from "effect/Option";
3
-import * as Schema from "effect/Schema";
4
-
5
-const isZonedIsoDateTime = Schema.is(
6
- Schema.String.check(
7
- Schema.isPattern(
8
- /^(?:\d{4}|[+-]\d{6})-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?|24:00(?::00(?:\.0+)?)?)(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/,
9
- ),
10
- Schema.isTrimmed(),
11
- ),
12
-);
13
-
14
-function parseTimestamp(value: string): number {
15
- if (!isZonedIsoDateTime(value)) return Number.NaN;
16
-
17
- // Engines can normalize invalid calendar dates instead of rejecting them.
18
- const datePart = value.slice(0, value.indexOf("T"));
19
- const date = DateTime.make(`${datePart}T00:00:00.000Z`);
20
- if (Option.isNone(date)) return Number.NaN;
21
- const parts = DateTime.toPartsUtc(date.value);
22
- if (parts.month !== Number(datePart.slice(-5, -3)) || parts.day !== Number(datePart.slice(-2))) {
23
- return Number.NaN;
24
- }
25
- return Date.parse(value);
26
-}
27
-
28
-export function compareDateTimeStrings(left: string, right: string): number {
29
- const leftTimestamp = parseTimestamp(left);
30
- const rightTimestamp = parseTimestamp(right);
31
- const leftIsValid = !Number.isNaN(leftTimestamp);
32
- const rightIsValid = !Number.isNaN(rightTimestamp);
33
-
34
- if (leftIsValid !== rightIsValid) return leftIsValid ? 1 : -1;
35
- if (leftIsValid) return leftTimestamp - rightTimestamp;
36
- return left < right ? -1 : left > right ? 1 : 0;
37
-}
packages/shared/src/model.test.ts
+1
-47
@@ -1,5 +1,5 @@
1
import { describe, expect, it } from "vite-plus/test";
2
-import { ProviderDriverKind, ProviderInstanceId, type ModelCapabilities } from "@t3tools/contracts";
2
+import { ProviderInstanceId, type ModelCapabilities } from "@t3tools/contracts";
3
4
import {
5
applyClaudePromptEffortPrefix,
@@ -10,8 +10,6 @@ import {
10
getProviderOptionCurrentLabel,
11
getProviderOptionDescriptors,
12
readCustomModelEntries,
13
- normalizeCustomModelSlug,
14
- normalizeModelSlug,
13
modelSelectionsEqual,
14
} from "./model.ts";
15
@@ -35,15 +33,6 @@ const codexCaps: ModelCapabilities = createModelCapabilities({
33
],
34
});
35
38
-describe("model slug normalization", () => {
39
- it("preserves exact custom slugs instead of expanding provider aliases", () => {
40
- const claude = ProviderDriverKind.make("claudeAgent");
41
-
42
- expect(normalizeModelSlug("opus", claude)).toBe("opus");
43
- expect(normalizeCustomModelSlug(" opus ")).toBe("opus");
44
- });
45
-});
46
-
36
const claudeCaps: ModelCapabilities = createModelCapabilities({
37
optionDescriptors: [
38
{
@@ -72,41 +61,6 @@ const claudeCaps: ModelCapabilities = createModelCapabilities({
61
});
62
63
describe("descriptor helpers", () => {
75
- it("applies selection values to capability descriptors", () => {
76
- expect(
77
- getProviderOptionDescriptors({
78
- caps: claudeCaps,
79
- selections: [
80
- { id: "effort", value: "medium" },
81
- { id: "contextWindow", value: "200k" },
82
- ],
83
- }),
84
- ).toEqual([
85
- {
86
- id: "effort",
87
- label: "Reasoning",
88
- type: "select",
89
- options: [
90
- { id: "medium", label: "Medium" },
91
- { id: "high", label: "High", isDefault: true },
92
- { id: "ultrathink", label: "Ultrathink" },
93
- ],
94
- currentValue: "medium",
95
- promptInjectedValues: ["ultrathink"],
96
- },
97
- {
98
- id: "contextWindow",
99
- label: "Context Window",
100
- type: "select",
101
- options: [
102
- { id: "200k", label: "200k" },
103
- { id: "1m", label: "1M", isDefault: true },
104
- ],
105
- currentValue: "200k",
106
- },
107
- ]);
108
- });
109
-
64
it("builds dispatch options only from explicit selections", () => {
65
const descriptors = getProviderOptionDescriptors({
66
caps: codexCaps,
packages/shared/src/threadPullRequests.test.ts
+20
-87
@@ -6,7 +6,6 @@ import {
6
import { beforeEach, describe, expect, it } from "vite-plus/test";
7
8
import {
9
- legacyLinkedPullRequestOf,
9
legacyThreadPullRequestKey,
10
threadPullRequestSearchTerms,
11
resolveThreadCurrentPullRequest,
@@ -83,6 +82,26 @@ describe("threadPullRequestKeysEqual", () => {
82
}),
83
).toBe(false);
84
});
85
+
86
+ it("recovers Azure repository keys from stored URLs", () => {
87
+ const own = link(7, {
88
+ host: "dev.azure.com",
89
+ repository: "org-a/project/_git/web",
90
+ url: "https://dev.azure.com/org-a/project/_git/web/pullrequest/7",
91
+ });
92
+ expect(legacyThreadPullRequestKey({ ...own, repository: "web" })).toEqual({
93
+ host: "dev.azure.com",
94
+ repository: "org-a/project/_git/web",
95
+ number: 7,
96
+ });
97
+ expect(
98
+ threadPullRequestKeysEqual(own, {
99
+ host: "org-a.visualstudio.com",
100
+ repository: "DefaultCollection/project/_git/web",
101
+ number: 7,
102
+ }),
103
+ ).toBe(true);
104
+ });
105
});
106
107
describe("resolveThreadCurrentPullRequest", () => {
@@ -131,92 +150,6 @@ describe("resolveThreadCurrentPullRequest", () => {
150
});
151
});
152
134
-describe("legacyLinkedPullRequestOf", () => {
135
- const identity = {
136
- canonicalKey: "github.com/pingdotgg/t3code",
137
- provider: "github",
138
- displayName: "pingdotgg/t3code",
139
- locator: {
140
- source: "git-remote" as const,
141
- remoteName: "origin",
142
- remoteUrl: "https://github.com/pingdotgg/t3code.git",
143
- },
144
- };
145
- it("projects only links the owning project can route without a host", () => {
146
- expect(legacyLinkedPullRequestOf([link(7)], "project-1" as never, identity)).toEqual({
147
- projectId: "project-1",
148
- repository: "pingdotgg/t3code",
149
- number: 7,
150
- url: "https://github.com/pingdotgg/t3code/pull/7",
151
- });
152
- expect(legacyLinkedPullRequestOf([], "project-1" as never, identity)).toBeNull();
153
- });
154
- it.each([
155
- {
156
- host: "github.enterprise.test",
157
- url: "https://github.enterprise.test/pingdotgg/t3code/pull/7",
158
- },
159
- { repository: "acme/other", url: "https://github.com/acme/other/pull/7" },
160
- ])("omits an unsafe legacy route %j", (foreign) => {
161
- expect(
162
- legacyLinkedPullRequestOf([link(7, foreign)], "project-1" as never, identity),
163
- ).toBeNull();
164
- expect(
165
- legacyLinkedPullRequestOf([link(7, foreign), link(8)], "project-1" as never, identity)
166
- ?.number,
167
- ).toBe(8);
168
- });
169
- it.each([
170
- "dev.azure.com/org-a/project/_git/web",
171
- "ssh.dev.azure.com/v3/org-a/project/web",
172
- "org-a.visualstudio.com/DefaultCollection/project/_git/web",
173
- ])("projects Azure links through the legacy selector for %s", (canonicalKey) => {
174
- const azureIdentity = {
175
- ...identity,
176
- provider: "azure-devops",
177
- canonicalKey,
178
- displayName: canonicalKey.slice(canonicalKey.indexOf("/") + 1),
179
- name: "web",
180
- };
181
- const own = link(7, {
182
- host: "dev.azure.com",
183
- repository: "org-a/project/_git/web",
184
- url: "https://dev.azure.com/org-a/project/_git/web/pullrequest/7",
185
- });
186
- const foreign = link(7, {
187
- host: "dev.azure.com",
188
- repository: "web",
189
- url: "https://dev.azure.com/org-b/project/_git/web/pullrequest/7",
190
- linkedAt: "2026-01-02T00:00:00.000Z",
191
- });
192
- for (const repository of ["web", "org-a/project/_git/web"]) {
193
- expect(
194
- legacyLinkedPullRequestOf(
195
- [{ ...own, repository }, foreign],
196
- "project-1" as never,
197
- azureIdentity,
198
- ),
199
- ).toEqual({ projectId: "project-1", repository: "web", number: 7, url: own.url });
200
- }
201
- expect(legacyLinkedPullRequestOf([foreign], "project-1" as never, azureIdentity)).toBeNull();
202
- expect(legacyThreadPullRequestKey({ ...own, repository: "web" })).toEqual({
203
- host: "dev.azure.com",
204
- repository: "org-a/project/_git/web",
205
- number: 7,
206
- });
207
- expect(
208
- threadPullRequestKeysEqual(own, {
209
- host: "org-a.visualstudio.com",
210
- repository: "DefaultCollection/project/_git/web",
211
- number: 7,
212
- }),
213
- ).toBe(true);
214
- });
215
- it("does not guess when the project identity is unavailable", () => {
216
- expect(legacyLinkedPullRequestOf([link(7)], "project-1" as never, null)).toBeNull();
217
- });
218
-});
219
-
153
describe("resolveThreadPullRequestChains", () => {
154
it("chains links by base → head within a repository, bottom to top", () => {
155
const chains = resolveThreadPullRequestChains([
packages/shared/src/threadPullRequests.ts
+1
-51
@@ -1,15 +1,12 @@
1
import type {
2
OrchestrationV2AppThread,
3
- RepositoryIdentity,
4
- SourceControlProviderKind,
3
ThreadLinkedPullRequest,
4
ThreadPullRequestKey,
5
ThreadPullRequestLink,
6
} from "@t3tools/contracts";
7
10
-import { pullRequestHostOf } from "@t3tools/contracts";
8
import { parseChangeRequestUrl } from "./changeRequestUrl.ts";
12
-import { canonicalRepositoryKey, sourceControlRepositorySelector } from "./sourceControl.ts";
9
+import { canonicalRepositoryKey } from "./sourceControl.ts";
10
11
type ThreadPullRequestKeySource = ThreadPullRequestKey & {
12
readonly authority?: string;
@@ -159,53 +156,6 @@ export function resolveThreadCurrentPullRequestLink(
156
return current.kind === "single" ? current.link : current.top;
157
}
158
162
-export function legacyLinkedPullRequestOf(
163
- links: ReadonlyArray<ThreadPullRequestLink>,
164
- projectId: ThreadLinkedPullRequest["projectId"],
165
- identity: RepositoryIdentity | null | undefined,
166
-): ThreadLinkedPullRequest | null {
167
- if (!identity) return null;
168
- const host = pullRequestHostOf(identity, identity.provider as SourceControlProviderKind);
169
- if (typeof host !== "string") return null;
170
- const repository = sourceControlRepositorySelector(identity);
171
- if (repository === null) return null;
172
- const azureKey =
173
- identity.provider === "azure-devops"
174
- ? canonicalRepositoryKey(identity.canonicalKey.toLowerCase())
175
- : null;
176
- const link = resolveThreadCurrentPullRequestLink(
177
- links.filter((link) => {
178
- if (azureKey !== null) {
179
- const key = legacyThreadPullRequestKey(link, link.host);
180
- return canonicalRepositoryKey(`${key.host}/${key.repository}`) === azureKey;
181
- }
182
- const parsed = parseChangeRequestUrl(link.url);
183
- if (parsed?.authority !== undefined) {
184
- try {
185
- const remote = new URL(identity.locator.remoteUrl);
186
- if (remote.protocol === "http:" || remote.protocol === "https:") {
187
- return (
188
- parsed.authority === remote.host && parsed.repository === repository.toLowerCase()
189
- );
190
- }
191
- } catch {}
192
- return parsed.host === host && parsed.repository === repository.toLowerCase();
193
- }
194
- return (
195
- link.host.toLowerCase() === host.toLowerCase() &&
196
- link.repository.toLowerCase() === repository.toLowerCase()
197
- );
198
- }),
199
- );
200
- if (link === null) return null;
201
- return {
202
- projectId,
203
- repository: azureKey === null ? link.repository : repository,
204
- number: link.number,
205
- url: link.url,
206
- };
207
-}
208
-
159
export interface ThreadPullRequestChain {
160
readonly kind: "native" | "derived";
161
readonly layers: ReadonlyArray<ThreadPullRequestLink>;
packages/shared/src/threadReference.test.ts
-26
@@ -57,32 +57,6 @@ describe("resolveThreadReferenceCopyTarget", () => {
57
},
58
);
59
60
- it("copies the highest open stack layer instead of the first link", () => {
61
- const stack: NonNullable<ThreadPullRequestLink["stack"]> = {
62
- kind: "native",
63
- id: "stack-1",
64
- number: 1,
65
- url: "https://github.com/other/repo/stacks/1",
66
- base: "main",
67
- layers: [
68
- { number: 42, headBranch: "first", state: "open" },
69
- { number: 43, headBranch: "second", state: "open" },
70
- ],
71
- };
72
- const top = {
73
- ...crossRepositoryPullRequest,
74
- number: 43,
75
- url: "https://github.com/other/repo/pull/43",
76
- stack,
77
- };
78
- expect(
79
- resolveThreadReferenceCopyTarget({
80
- threadId: "thread-1",
81
- pullRequests: [{ ...crossRepositoryPullRequest, stack }, top],
82
- }),
83
- ).toMatchObject({ kind: "pull-request", value: top.url });
84
- });
85
-
60
it("uses the fallback URL when native links are dismissed", () => {
61
expect(
62
resolveThreadReferenceCopyTarget({
packages/source-control-core/src/server/pullRequestChecks.test.ts
+14
-16
@@ -24,7 +24,6 @@ describe("dedupeChecks", () => {
24
it.each([
25
["2026-10-16T12:00:00+02:00", "2026-10-16T10:30:00Z"],
26
["2026-10-16T12:00:00.00009Z", "2026-10-16T12:00:00.0001Z"],
27
- ["2024-03-01T01:00:00Z", "2024-02-29T23:30:00-02:00"],
27
])("keeps the newer instant between %s and %s in either listing order", (older, newer) => {
28
const oldRun = entry("build", "success", { at: older });
29
const newRun = entry("build", "failure", { at: newer });
@@ -70,21 +69,20 @@ describe("dedupeChecks", () => {
69
).toEqual([expected, expected]);
70
});
71
73
- it.each([
74
- ["2026-02-30T00:00:00Z", "2026-03-01T00:00:00Z"],
75
- ["1900-02-29T00:00:00Z", "1900-03-01T00:00:00Z"],
76
- ["2026-04-31T00:00:00.0001-02:00", "2026-05-01T00:00:00Z"],
77
- ])("uses text fallback for impossible date %s", (malformed, valid) => {
78
- const malformedRun = entry("build", "success", { at: malformed });
79
- const validRun = entry("build", "failure", { at: valid });
80
-
81
- expect(
82
- [
83
- [malformedRun, validRun],
84
- [validRun, malformedRun],
85
- ].map((runs) => dedupeChecks(runs)[0]?.status),
86
- ).toEqual(["failure", "failure"]);
87
- });
72
+ it.each([["2026-02-30T00:00:00Z", "2026-03-01T00:00:00Z"]])(
73
+ "uses text fallback for impossible date %s",
74
+ (malformed, valid) => {
75
+ const malformedRun = entry("build", "success", { at: malformed });
76
+ const validRun = entry("build", "failure", { at: valid });
77
+
78
+ expect(
79
+ [
80
+ [malformedRun, validRun],
81
+ [validRun, malformedRun],
82
+ ].map((runs) => dedupeChecks(runs)[0]?.status),
83
+ ).toEqual(["failure", "failure"]);
84
+ },
85
+ );
86
87
it("holds a check at the place it first appeared, so a re-run does not reshuffle the list", () => {
88
const checks = dedupeChecks([