@devries-cameron20 / t3code Mirror · read-only / commits / 8feddd6687
Fork 0

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, 20:45 UTC

test(packages): prune low-value tests in packages (second pass) (#22593)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 20, 2026 at 18:31 UTC 8feddd66875857481ec33a435d01238f36b56e64
105 files changed +190 -2840
packages/client-runtime/src/connection/presentation.test.ts
+1
@@ -86,6 +86,7 @@ describe("connection presentation", () => {
86 expect(environmentMcpUrl({ entry })).toBe("http://192.168.4.53:3773/mcp");
87 });
88
89 + // regression: #16909 Copy MCP URL falls back to an alternate route when the relay route has no address
90 it("passes over routes without an address of their own", () => {
91 const relay = new RelayConnectionTarget({
92 environmentId: TARGET.environmentId,
packages/client-runtime/src/device/duoControl.test.ts
+1
@@ -85,6 +85,7 @@ it("pinches only a hit device, accumulates independently of native readback, cla
85 expect(pinch.active).toBe(false);
86 });
87
88 +// regression: #16630 fold controls follow the phone's orientation on each screen
89 it.each([
90 [
91 "vertical phone, closed",
packages/client-runtime/src/errors/transport.test.ts
-4
@@ -4,10 +4,6 @@ import { NETWORK_BLOCKING_HINT } from "./network.ts";
4 import { isTransportConnectionErrorMessage, sanitizeThreadErrorMessage } from "./transport.ts";
5
6 describe("isTransportConnectionErrorMessage", () => {
7 - it("returns true for SocketCloseError", () => {
8 - expect(isTransportConnectionErrorMessage("SocketCloseError: connection reset")).toBe(true);
9 - });
10 -
7 it("returns true for React Native disconnected socket errors", () => {
8 expect(
9 isTransportConnectionErrorMessage(
packages/client-runtime/src/markdownImages.test.ts
+6 -27
@@ -5,24 +5,12 @@ import { classifyMarkdownImageSource } from "./markdownImages.js";
5 describe("classifyMarkdownImageSource", () => {
6 it.each([
7 ["images/result.png", "/workspace/project", "/workspace/project/images/result.png"],
8 - ["./images/result.png", "/workspace/project", "/workspace/project/./images/result.png"],
9 - [
10 - "images/result.png",
11 - "C:\\Users\\dara\\project",
12 - "C:\\Users\\dara\\project\\images\\result.png",
13 - ],
8 [
9 "images\\result.png",
10 "C:\\Users\\dara\\project",
11 "C:\\Users\\dara\\project\\images\\result.png",
12 ],
19 - ["/workspace/project/image.png", null, "/workspace/project/image.png"],
20 - ["/C:/Users/dara/project/image.png", null, "C:/Users/dara/project/image.png"],
21 - ["C:/Users/dara/project/image.png", null, "C:/Users/dara/project/image.png"],
22 - ["\\\\server\\share\\image.png", null, "\\\\server\\share\\image.png"],
13 ["file:///workspace/project/image%20one.png", null, "/workspace/project/image one.png"],
24 - ["file:///C:/Users/dara/project/image.png", null, "C:/Users/dara/project/image.png"],
25 - ["file://localhost/C:/Users/dara/project/image.png", null, "C:/Users/dara/project/image.png"],
14 ["file://server/share/image.png", null, "\\\\server\\share\\image.png"],
15 ])("maps %s to a workspace file", (source, workspaceRoot, path) => {
16 expect(classifyMarkdownImageSource(source, workspaceRoot)).toEqual({
@@ -31,19 +19,10 @@ describe("classifyMarkdownImageSource", () => {
19 });
20 });
21
34 - it.each([
35 - null,
36 - "",
37 - "#image",
38 - "?image=1",
39 - "image.png",
40 - "~/image.png",
41 - "javascript:alert(1)",
42 - "ftp://example.com/image.png",
43 - "content://media/image/1",
44 - "custom:image.png",
45 - "file://%",
46 - ])("blocks unsupported or unresolved source %s", (source) => {
47 - expect(classifyMarkdownImageSource(source)).toEqual({ _tag: "Blocked" });
48 - });
22 + it.each(["image.png", "javascript:alert(1)", "file://%"])(
23 + "blocks unsupported or unresolved source %s",
24 + (source) => {
25 + expect(classifyMarkdownImageSource(source)).toEqual({ _tag: "Blocked" });
26 + },
27 + );
28 });
packages/client-runtime/src/mediaReference.test.ts
-11
@@ -5,17 +5,9 @@ import { mediaFileReference, mediaReferenceFileName } from "./mediaReference.ts"
5 describe("mediaFileReference", () => {
6 it.each([
7 ["/work/project/./media/../clip.mp4", "/work/project/", "clip.mp4"],
8 - ["/work/project/../outside.mp4", "/work/project", undefined],
8 ["/work/project-other/clip.mp4", "/work/project", undefined],
10 - ["/work/Project/clip.mp4", "/work/project", undefined],
11 - ["/work/project/a\\b.mp4", "/work/project", "a\\b.mp4"],
12 - ["/work/clip.mp4", "/work/other/..", "clip.mp4"],
13 - ["/clip.mp4", "/", "clip.mp4"],
9 ["C:\\WORK\\project\\media\\..\\Clip.mp4", "c:/work/project/", "Clip.mp4"],
15 - ["D:\\work\\clip.mp4", "C:\\work", undefined],
10 ["\\\\Server\\Share\\Project\\Clip.mp4", "//server/share/project", "Clip.mp4"],
17 - ["\\\\server\\other\\clip.mp4", "\\\\server\\share", undefined],
18 - ["../clip.mp4", "/work/project", undefined],
11 ])("preserves %s and only labels paths inside %s as relative", (path, root, relativePath) => {
12 expect(mediaFileReference(path, root)).toEqual({
13 kind: "file",
@@ -28,10 +20,7 @@ describe("mediaFileReference", () => {
20 describe("mediaReferenceFileName", () => {
21 it.each([
22 [{ kind: "file", path: "/tmp/take\\one%20.mp4" }, "take\\one%20.mp4"],
31 - [{ kind: "file", path: "C:\\clips/take\\one.mp4" }, "one.mp4"],
32 - [{ kind: "file", path: "\\\\server\\share\\one.mp4" }, "one.mp4"],
23 [{ kind: "url", url: "//cdn.example/clip%20one%2Emp4?sig=a+b#t=2" }, "clip one.mp4"],
34 - [{ kind: "url", url: "https://cdn.example/clip%2520.mp4" }, "clip%20.mp4"],
24 [{ kind: "url", url: "https://cdn.example/clip%20%oops.mp4" }, "clip%20%oops.mp4"],
25 ] as const)("preserves filename semantics for %j", (reference, name) => {
26 expect(mediaReferenceFileName(reference)).toBe(name);
packages/client-runtime/src/mediaSource.test.ts
-5
@@ -34,13 +34,8 @@ describe("resolveMediaSource", () => {
34 describe("host paths", () => {
35 it.each([
36 ["/tmp/frame%23one.png:12", "/tmp/frame#one.png"],
37 - ["/tmp/frame%3Fone.png:12:3", "/tmp/frame?one.png"],
37 ["/tmp/frame%2523one.png:12", "/tmp/frame%23one.png"],
39 - ["C:\\Users\\demo\\frame.png", "C:\\Users\\demo\\frame.png"],
40 - ["/C:/Users/demo/frame.png", "C:/Users/demo/frame.png"],
41 - ["file:///C:/Users/demo/frame.png", "C:/Users/demo/frame.png"],
38 ["file://server/share/frame.png", "\\\\server\\share\\frame.png"],
43 - ["\\\\server\\share\\frame.png", "\\\\server\\share\\frame.png"],
39 ])("resolves %s through the environment", (href, path) => {
40 expect(resolveMediaSource(href, { threadId, workspaceRoot: "/repo" })).toEqual({
41 kind: "image",
packages/client-runtime/src/operations/commands.test.ts
+69 -74
@@ -395,80 +395,75 @@ describe("V2 environment commands", () => {
395 }).pipe(Effect.provide(layerTestCrypto)),
396 );
397
398 - it.effect.each([
399 - "waiting",
400 - "completed",
401 - "failed",
402 - "interrupted",
403 - "cancelled",
404 - "rolled_back",
405 - ] as const)("dispatches Stop for %s runs with background commands except rollback", (status) =>
406 - Effect.gen(function* () {
407 - const waitingRunId = RunId.make("run-waiting");
408 - const projection: OrchestrationV2ThreadProjection = {
409 - ...v2Projection,
410 - runs: [
411 - {
412 - id: waitingRunId,
413 - threadId: v2ThreadId,
414 - ordinal: 1,
415 - providerInstanceId: v2Projection.thread.providerInstanceId,
416 - modelSelection: v2Projection.thread.modelSelection,
417 - providerThreadId: null,
418 - userMessageId: MessageId.make("message-waiting"),
419 - rootNodeId: null,
420 - activeAttemptId: null,
421 - status,
422 - requestedAt: v2Now,
423 - startedAt: v2Now,
424 - completedAt: null,
425 - checkpointId: null,
426 - contextHandoffId: null,
427 - },
428 - ],
429 - turnItems: [
430 - {
431 - id: TurnItemId.make("background-command"),
432 - threadId: v2ThreadId,
433 - runId: waitingRunId,
434 - nodeId: null,
435 - providerThreadId: null,
436 - providerTurnId: null,
437 - nativeItemRef: null,
438 - parentItemId: null,
439 - ordinal: 1,
440 - status: "running",
441 - title: null,
442 - startedAt: v2Now,
443 - completedAt: null,
444 - updatedAt: v2Now,
445 - type: "command_execution",
446 - input: "vp run dev",
447 - },
448 - ],
449 - };
450 - const commands: OrchestrationV2Command[] = [];
451 - const supervisor = yield* makeSupervisor({ commands, projects: [], projection });
452 -
453 - const result = yield* interruptThreadTurn({ threadId: v2ThreadId }).pipe(
454 - Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
455 - );
456 -
457 - expect(result).toEqual({ sequence: status === "rolled_back" ? 0 : 1 });
458 - expect(commands).toEqual(
459 - status === "rolled_back"
460 - ? []
461 - : [
462 - {
463 - type: "run.interrupt",
464 - commandId: expect.any(String),
465 - threadId: v2ThreadId,
466 - runId: waitingRunId,
467 - holdQueue: true,
468 - },
469 - ],
470 - );
471 - }).pipe(Effect.provide(layerTestCrypto)),
398 + it.effect.each(["waiting", "completed", "rolled_back"] as const)(
399 + "dispatches Stop for %s runs with background commands except rollback",
400 + (status) =>
401 + Effect.gen(function* () {
402 + const waitingRunId = RunId.make("run-waiting");
403 + const projection: OrchestrationV2ThreadProjection = {
404 + ...v2Projection,
405 + runs: [
406 + {
407 + id: waitingRunId,
408 + threadId: v2ThreadId,
409 + ordinal: 1,
410 + providerInstanceId: v2Projection.thread.providerInstanceId,
411 + modelSelection: v2Projection.thread.modelSelection,
412 + providerThreadId: null,
413 + userMessageId: MessageId.make("message-waiting"),
414 + rootNodeId: null,
415 + activeAttemptId: null,
416 + status,
417 + requestedAt: v2Now,
418 + startedAt: v2Now,
419 + completedAt: null,
420 + checkpointId: null,
421 + contextHandoffId: null,
422 + },
423 + ],
424 + turnItems: [
425 + {
426 + id: TurnItemId.make("background-command"),
427 + threadId: v2ThreadId,
428 + runId: waitingRunId,
429 + nodeId: null,
430 + providerThreadId: null,
431 + providerTurnId: null,
432 + nativeItemRef: null,
433 + parentItemId: null,
434 + ordinal: 1,
435 + status: "running",
436 + title: null,
437 + startedAt: v2Now,
438 + completedAt: null,
439 + updatedAt: v2Now,
440 + type: "command_execution",
441 + input: "vp run dev",
442 + },
443 + ],
444 + };
445 + const commands: OrchestrationV2Command[] = [];
446 + const supervisor = yield* makeSupervisor({ commands, projects: [], projection });
447 +
448 + const result = yield* interruptThreadTurn({ threadId: v2ThreadId }).pipe(
449 + Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
450 + );
451 +
452 + expect(result).toEqual({ sequence: status === "rolled_back" ? 0 : 1 });
453 + expect(commands).toEqual(
454 + status === "rolled_back"
455 + ? []
456 + : [
457 + {
458 + type: "run.interrupt",
459 + commandId: expect.any(String),
460 + threadId: v2ThreadId,
461 + runId: waitingRunId,
462 + holdQueue: true,
463 + },
464 + ],
465 + );
466 + }).pipe(Effect.provide(layerTestCrypto)),
467 );
468
469 it.effect("validates identified checkpoints locally for older servers", () =>
packages/client-runtime/src/pullRequestLinkInput.test.ts
-10
@@ -120,20 +120,10 @@ describe("parsePullRequestReference", () => {
120 expect(parsePullRequestReference("gh pr checkout 42")).toBe("42");
121 });
122
123 - it("accepts gh pr checkout commands with GitHub pull request URLs", () => {
124 - expect(
125 - parsePullRequestReference("gh pr checkout https://github.com/pingdotgg/t3code/pull/42"),
126 - ).toBe("https://github.com/pingdotgg/t3code/pull/42");
127 - });
128 -
123 it("accepts glab mr checkout commands with raw numbers", () => {
124 expect(parsePullRequestReference("glab mr checkout 42")).toBe("42");
125 });
126
133 - it("accepts az repos pr checkout commands with raw numbers", () => {
134 - expect(parsePullRequestReference("az repos pr checkout --id 42")).toBe("42");
135 - });
136 -
127 it("accepts az repos pr checkout commands with equals-style ids", () => {
128 expect(parsePullRequestReference("az repos pr checkout --id=42")).toBe("42");
129 });
packages/client-runtime/src/pullRequestQuery.test.ts
+1
@@ -78,6 +78,7 @@ describe("colon-namespaced labels typed as a search", () => {
78 expect(parsePullRequestQuery("size:S,size:XS").filters.labels).toEqual([["size:S", "size:XS"]]);
79 });
80
81 + // regression: #19934 negated key:value qualifiers become namespaced label exclusions
82 it("excludes one the same way", () => {
83 expect(parsePullRequestQuery("-size:XXL").filters.excludedLabels).toEqual(["size:XXL"]);
84 expect(parsePullRequestQuery("-size:S,XS").filters.excludedLabels).toEqual([
packages/client-runtime/src/relay/managedRelay.test.ts
-70
@@ -455,74 +455,4 @@ describe("ManagedRelayClient", () => {
455 }
456 }).pipe(Effect.provide(layerManagedRelayTest(fetchFn)));
457 });
458 -
459 - it.effect("lists account devices through the v2 Clerk bearer client endpoint", () => {
460 - const fetchFn = ((input, init) => {
461 - expect(String(input)).toBe("https://relay.example.test/v2/client/devices");
462 - expect(init?.headers).toMatchObject({
463 - authorization: "Bearer clerk-token",
464 - });
465 - return Promise.resolve(
466 - Response.json({
467 - devices: [
468 - {
469 - deviceId: "device-1",
470 - label: "Julius's iPhone",
471 - platform: "ios",
472 - iosMajorVersion: 18,
473 - appVersion: "1.0.0",
474 - notifications: {
475 - enabled: false,
476 - notifyOnApproval: true,
477 - notifyOnInput: true,
478 - notifyOnCompletion: true,
479 - notifyOnFailure: true,
480 - },
481 - liveActivities: {
482 - enabled: true,
483 - },
484 - updatedAt: "2026-06-01T00:00:00.000Z",
485 - },
486 - {
487 - deviceId: "device-2",
488 - label: "Android phone",
489 - platform: "android",
490 - iosMajorVersion: null,
491 - androidApiLevel: 36,
492 - appVersion: "1.0.0",
493 - notifications: {
494 - enabled: true,
495 - notifyOnApproval: true,
496 - notifyOnInput: true,
497 - notifyOnCompletion: true,
498 - notifyOnFailure: true,
499 - },
500 - liveActivities: { enabled: true },
501 - updatedAt: "2026-06-01T00:00:00.000Z",
502 - },
503 - ],
504 - }),
505 - );
506 - }) satisfies typeof globalThis.fetch;
507 -
508 - return Effect.gen(function* () {
509 - const relayClient = yield* ManagedRelay.ManagedRelayClient;
510 - const devices = yield* relayClient.listDevices({ clerkToken: "clerk-token" });
511 - expect(devices).toMatchObject([
512 - {
513 - deviceId: "device-1",
514 - label: "Julius's iPhone",
515 - notifications: {
516 - enabled: false,
517 - },
518 - },
519 - {
520 - deviceId: "device-2",
521 - platform: "android",
522 - iosMajorVersion: null,
523 - androidApiLevel: 36,
524 - },
525 - ]);
526 - }).pipe(Effect.provide(layerManagedRelayTest(fetchFn)));
527 - });
458 });
packages/client-runtime/src/state/commandPermissions.test.ts
-21
@@ -115,27 +115,6 @@ describe("command permissions", () => {
115 ),
116 );
117
118 - it.effect("requires the destination settings grant to check OTLP endpoints", () =>
119 - Effect.scoped(
120 - Effect.gen(function* () {
121 - const registry = yield* setup;
122 - const check = createCommandPermissions(runtime, WS_METHODS.serverCheckOtlpEndpoint);
123 - registry.set(sessions(env), AsyncResult.success(grant(true)));
124 - expect(registry.get(check.permissionAtom(env))).toBe(false);
125 - registry.set(
126 - sessions(env),
127 - AsyncResult.success({
128 - ...grant(false),
129 - scopes: [AuthSettingsWriteScope],
130 - permissions: [AuthSettingsWriteScope],
131 - }),
132 - );
133 - expect(registry.get(check.permissionAtom(env))).toBe(true);
134 - yield* check.authorize(registry, env);
135 - }),
136 - ),
137 - );
138 -
118 it.effect("uses the target grant for both availability and execution", () =>
119 Effect.scoped(
120 Effect.gen(function* () {
packages/client-runtime/src/state/customSnooze.test.ts
+1 -6
@@ -9,13 +9,8 @@ afterEach(() => vi.unstubAllEnvs());
9 describe("custom snooze", () => {
10 it.each([
11 ["2026-09-14", "14:30"],
12 - ["2026-09-13", "09:00"],
12 ["2027-02-29", "09:00"],
14 - ["2026-13-01", "09:00"],
13 ["2026-09-15", "24:00"],
16 - ["2026-09-15", "09:60"],
17 - ["", "09:00"],
18 - ["2026-09-15", ""],
14 ])("rejects invalid or non-future calendar input %s %s", (date, time) => {
15 expect(resolveCustomSnooze({ mode: "date", date, time }, now)).toBeNull();
16 });
@@ -31,7 +26,7 @@ describe("custom snooze", () => {
26 );
27 });
28
34 - it.each(["", "0", "-1", "NaN", "Infinity", "1e300"])("rejects invalid duration %s", (amount) => {
29 + it.each(["0", "NaN", "1e300"])("rejects invalid duration %s", (amount) => {
30 expect(resolveCustomSnooze({ mode: "duration", amount, unit: "hours" }, now)).toBeNull();
31 });
32
packages/client-runtime/src/state/entities.test.ts
-34
@@ -12,10 +12,6 @@ import {
12 import * as DateTime from "effect/DateTime";
13 import { describe, expect, it } from "vite-plus/test";
14
15 -import {
16 - InvalidScopedProjectRefCollectionKeyError,
17 - parseProjectRefCollectionKey,
18 -} from "./entities.ts";
15 import { presentThreadShell, resolveThreadWorkingStartedAt } from "./models.ts";
16 import { v2Projection, v2ThreadShell } from "./orchestrationV2TestFixtures.ts";
17 import { deriveLatestThreadRun, deriveThreadRuntime } from "./threadExecution.ts";
@@ -25,16 +21,6 @@ import { canSnooze, effectiveSnoozed } from "./threadSettled.ts";
21
22 const environmentId = EnvironmentId.make("environment-v2");
23
28 -describe("scoped entity keys", () => {
29 - it("rejects invalid project reference collection shapes", () => {
30 - const key = JSON.stringify([["environment-1"]]);
31 -
32 - expect(() => parseProjectRefCollectionKey(key)).toThrowError(
33 - InvalidScopedProjectRefCollectionKeyError,
34 - );
35 - });
36 -});
37 -
24 describe("V2 client presentation", () => {
25 it("keeps async questions in Working until the run completes", () => {
26 const runId = RunId.make("run-async-question");
@@ -86,26 +72,6 @@ describe("V2 client presentation", () => {
72 }
73 });
74
89 - it("parks presented runtime at idle when a settled shell has pending background tasks", () => {
90 - const runId = RunId.make("run-completed");
91 - const shell = presentThreadShell(environmentId, {
92 - ...v2ThreadShell,
93 - latestRunId: runId,
94 - activeRunId: null,
95 - status: "completed",
96 - pendingBackgroundTasks: [{ taskId: "bg-1", description: "Watch build", kind: "monitor" }],
97 - });
98 -
99 - expect(shell.latestRun).toMatchObject({ runId, status: "completed" });
100 - expect(shell.runtime).toMatchObject({
101 - status: "idle",
102 - activeRunId: null,
103 - });
104 - expect(shell.pendingBackgroundTasks).toEqual([
105 - { taskId: "bg-1", description: "Watch build", kind: "monitor" },
106 - ]);
107 - });
108 -
75 it("parks a thread that never ran at idle while a pull request watch holds it", () => {
76 const watch = { taskId: "pull-request-watch:github.com/acme/app#1", kind: "monitor" as const };
77 const watched = presentThreadShell(environmentId, {
packages/client-runtime/src/state/orchestrationV2Projection.test.ts
-12
@@ -188,18 +188,6 @@ describe("applyOrchestrationV2ProjectionEvent", () => {
188 expect(next?.updatedAt).toEqual(archivedAt);
189 });
190
191 - it("ignores events for another thread", () => {
192 - const event = {
193 - id: "event-other",
194 - type: "thread.deleted",
195 - threadId: ThreadId.make("thread-other"),
196 - occurredAt: now,
197 - payload: { ...emptyProjection.thread, id: ThreadId.make("thread-other"), deletedAt: now },
198 - } as OrchestrationV2DomainEvent;
199 -
200 - expect(applyOrchestrationV2ProjectionEvent(emptyProjection, event)).toBe(emptyProjection);
201 - });
202 -
191 it("preserves visible row identity when run updates do not change membership", () => {
192 const item = commandItem("item-stable");
193 const visibleTurnItems = [
packages/client-runtime/src/state/providerInstanceDisplay.test.ts
+1
@@ -19,6 +19,7 @@ describe("providerInstanceInitials", () => {
19 });
20
21 describe("normalizeProviderAccentColor", () => {
22 + // regression: #9899 a non-hex accent must not render as the account badge color
23 it("rejects a non-hex value", () => {
24 expect(normalizeProviderAccentColor("blue")).toBeUndefined();
25 });
packages/client-runtime/src/state/pullRequestDiffHttp.test.ts deleted
-77
@@ -1,77 +0,0 @@
1 -import { EnvironmentId, ProjectId } from "@t3tools/contracts";
2 -import { describe, expect, it } from "@effect/vitest";
3 -import * as Effect from "effect/Effect";
4 -import * as Option from "effect/Option";
5 -
6 -import { PrimaryConnectionTarget, type PreparedConnection } from "../connection/model.ts";
7 -import * as RpcHttp from "../rpc/http.ts";
8 -import { fetchEnvironmentPullRequestDiff } from "./pullRequestDiffHttp.ts";
9 -
10 -const TARGET = new PrimaryConnectionTarget({
11 - environmentId: EnvironmentId.make("environment-1"),
12 - label: "Test environment",
13 - httpBaseUrl: "https://environment.example.test/base",
14 - wsBaseUrl: "wss://environment.example.test",
15 -});
16 -
17 -const PREPARED: PreparedConnection = {
18 - environmentId: TARGET.environmentId,
19 - label: TARGET.label,
20 - httpBaseUrl: TARGET.httpBaseUrl,
21 - socketUrl: "wss://environment.example.test/ws",
22 - httpAuthorization: null,
23 - target: TARGET,
24 -};
25 -
26 -describe("fetchEnvironmentPullRequestDiff", () => {
27 - it.effect("posts the diff input to the prepared environment over authenticated HTTP", () =>
28 - Effect.gen(function* () {
29 - const calls: Array<readonly [RequestInfo | URL, RequestInit]> = [];
30 - const fetchFn = ((request, init) => {
31 - calls.push([request, init ?? {}]);
32 - return Promise.resolve(
33 - Response.json({
34 - patch: "diff --git a/file.ts b/file.ts",
35 - truncated: false,
36 - nextCursor: null,
37 - }),
38 - );
39 - }) satisfies typeof fetch;
40 -
41 - const result = yield* fetchEnvironmentPullRequestDiff({
42 - prepared: PREPARED,
43 - signer: Option.none(),
44 - diff: {
45 - projectId: ProjectId.make("project-1"),
46 - repository: "owner/repository",
47 - number: 42,
48 - cursor: "next-page",
49 - },
50 - }).pipe(Effect.provide(RpcHttp.layerRemoteHttpClient(fetchFn)));
51 -
52 - expect(result).toEqual({
53 - patch: "diff --git a/file.ts b/file.ts",
54 - truncated: false,
55 - nextCursor: null,
56 - });
57 - expect(calls).toHaveLength(1);
58 - const [request, init] = calls[0]!;
59 - expect(String(request)).toBe("https://environment.example.test/api/pull-requests/diff");
60 - expect(init.method).toBe("POST");
61 - expect(init.credentials).toBe("include");
62 -
63 - const body =
64 - typeof init.body === "string"
65 - ? init.body
66 - : init.body instanceof Uint8Array
67 - ? new TextDecoder().decode(init.body)
68 - : "";
69 - expect(JSON.parse(body)).toEqual({
70 - projectId: "project-1",
71 - repository: "owner/repository",
72 - number: 42,
73 - cursor: "next-page",
74 - });
75 - }),
76 - );
77 -});
packages/client-runtime/src/state/runtime.test.ts
-23
@@ -44,7 +44,6 @@ import {
44 createRuntimeCommand,
45 scheduleAtomCommandEffect,
46 executeAtomQuery,
47 - settleAsyncResult,
47 } from "./runtime.ts";
48
49 const QUERY_ENVIRONMENT = new PrimaryConnectionTarget({
@@ -180,28 +179,6 @@ const mountEnvironmentQuery = Effect.fn("TestEnvironmentQuery.mount")(function*
179 return registry;
180 });
181
183 -describe("settleAsyncResult", () => {
184 - it("encodes thrown and rejected promises as defects", async () => {
185 - const thrownDefect = new Error("thrown defect");
186 - const thrown = await settleAsyncResult<void, never>(() => {
187 - throw thrownDefect;
188 - });
189 - expect(AsyncResult.isFailure(thrown)).toBe(true);
190 - if (AsyncResult.isFailure(thrown)) {
191 - expect(Cause.hasDies(thrown.cause)).toBe(true);
192 - expect(Cause.squash(thrown.cause)).toBe(thrownDefect);
193 - }
194 -
195 - const rejectedDefect = new Error("rejected defect");
196 - const rejected = await settleAsyncResult<void, never>(() => Promise.reject(rejectedDefect));
197 - expect(AsyncResult.isFailure(rejected)).toBe(true);
198 - if (AsyncResult.isFailure(rejected)) {
199 - expect(Cause.hasDies(rejected.cause)).toBe(true);
200 - expect(Cause.squash(rejected.cause)).toBe(rejectedDefect);
201 - }
202 - });
203 -});
204 -
182 describe("preview event subscriptions", () => {
183 it.effect("delivers every open and close when RPC events arrive in batches", () =>
184 Effect.scoped(
packages/client-runtime/src/state/threadExecution.test.ts
+1 -8
@@ -98,6 +98,7 @@ describe("thread execution presentation", () => {
98 ).toMatchObject({ status: "running", lastError: null, lastErrorClass: null });
99 });
100
101 + // regression: #15029 working timers no longer reset on every background wake
102 it("counts a wake run's activity from the start of the work it continues", () => {
103 const workStartedAt = DateTime.makeUnsafe("2026-07-28T09:20:00.000Z");
104 const wake = { ...run("wake", 2, "running"), workStartedAt };
@@ -341,14 +342,6 @@ describe("deriveProviderSubagentStatus", () => {
342 nodes: [root],
343 });
344
344 - it("reports the provider's own subagent from its runless root turn", () => {
345 - expect(deriveProviderSubagentStatus(child("provider"))).toEqual({
346 - status: "completed",
347 - startedAt: "2026-07-28T10:00:00.000Z",
348 - completedAt: "2026-07-28T10:00:00.000Z",
349 - });
350 - });
351 -
345 it("leaves T3 delegated tasks and ordinary threads alone", () => {
346 expect(deriveProviderSubagentStatus(child("mcp"))).toBeNull();
347 expect(deriveProviderSubagentStatus({ ...v2Projection, nodes: [root] })).toBeNull();
packages/client-runtime/src/state/threadFeedback.test.ts
-8
@@ -6,7 +6,6 @@ import { AsyncResult } from "effect/reactivity";
6 import {
7 beginCodexFeedbackSubmission,
8 codexFeedbackNotice,
9 - parseCodexFeedbackCommand,
9 submitCodexFeedback,
10 type CodexFeedbackSubmission,
11 } from "./threadFeedback.ts";
@@ -25,13 +24,6 @@ describe("beginCodexFeedbackSubmission", () => {
24 });
25 });
26
28 -describe("parseCodexFeedbackCommand", () => {
29 - it("ignores other slash commands and ordinary messages", () => {
30 - expect(parseCodexFeedbackCommand("/feedback-status")).toBeNull();
31 - expect(parseCodexFeedbackCommand("Please send /feedback")).toBeNull();
32 - });
33 -});
34 -
27 describe("submitCodexFeedback", () => {
28 const submission = {
29 id: MessageId.make("feedback-message-1"),
packages/client-runtime/src/state/threadRelationships.test.ts
-4
@@ -16,10 +16,6 @@ describe("thread relationships", () => {
16 it.each([
17 ["running", "completed"],
18 ["completed", "running"],
19 - ["running", "running"],
20 - ["completed", "completed"],
21 - ["waiting", "failed"],
22 - ["interrupted", "pending"],
19 ])("keeps parent %s independent of child %s", (parentStatus, childStatus) => {
20 const parent = ThreadId.make("parent");
21 const child = ThreadId.make("child");
packages/client-runtime/src/state/threadSnoozed.test.ts
-10
@@ -168,16 +168,6 @@ describe("threadRaisedHandWhileSnoozed", () => {
168 });
169
170 describe("canSnooze", () => {
171 - it("allows snoozing quiet and working threads alike", () => {
172 - expect(canSnooze({ ...makeShell({}), latestUserMessageAt: null }, { now: NOW })).toBe(true);
173 - expect(
174 - canSnooze(
175 - { ...makeShell({ sessionStatus: "running" }), latestUserMessageAt: null },
176 - { now: NOW },
177 - ),
178 - ).toBe(true);
179 - });
180 -
171 it("refuses blocked-on-you work", () => {
172 expect(
173 canSnooze({ ...makeShell({ pending: "approval" }), latestUserMessageAt: null }, { now: NOW }),
packages/client-runtime/src/state/threadSort.test.ts
-10
@@ -74,16 +74,6 @@ describe("sortSettledThreads", () => {
74 updatedAt: input.updatedAt ?? "2026-03-09T09:00:00.000Z",
75 });
76
77 - it("falls back to last activity for auto-settled threads without a settledAt stamp", () => {
78 - const sorted = sortSettledThreads([
79 - settled({ id: "auto-old", latestUserMessageAt: "2026-03-09T08:00:00.000Z" }),
80 - settled({ id: "explicit", settledAt: "2026-03-09T10:00:00.000Z" }),
81 - settled({ id: "auto-recent", latestUserMessageAt: "2026-03-09T11:00:00.000Z" }),
82 - ]);
83 -
84 - expect(sorted.map((thread) => thread.id)).toEqual(["auto-recent", "explicit", "auto-old"]);
85 - });
86 -
77 it("counts a turn completion as activity for auto-settled threads", () => {
78 const sorted = sortSettledThreads([
79 settled({ id: "message-only", latestUserMessageAt: "2026-03-09T10:04:00.000Z" }),
packages/client-runtime/src/state/threadSubagents.test.ts
-21
@@ -183,24 +183,3 @@ describe("deriveThreadTurnSubagents", () => {
183 expect(turn?.subagents).toHaveLength(3);
184 });
185 });
186 -
187 -describe("resolveSubagentPillSegment", () => {
188 - it("hides itself once the turn is over and nothing is working", () => {
189 - const turn = deriveThreadTurnSubagents({
190 - runs: [finishedRun],
191 - subagents: [subagent({ id: "a", status: "completed" })],
192 - });
193 -
194 - expect(resolveSubagentPillSegment(turn)).toBeNull();
195 - expect(resolveSubagentPillSegment(null)).toBeNull();
196 - });
197 -
198 - it("stays visible after the turn ends while an agent is still working", () => {
199 - const turn = deriveThreadTurnSubagents({
200 - runs: [finishedRun],
201 - subagents: [subagent({ id: "a", status: "running" })],
202 - });
203 -
204 - expect(resolveSubagentPillSegment(turn)?.label).toBe("1/1");
205 - });
206 -});
packages/client-runtime/src/state/threads-sync.test.ts
-19
@@ -1180,25 +1180,6 @@ describe("EnvironmentThreads", () => {
1180 }),
1181 );
1182
1183 - it.effect("ignores replayed thread events at or below the snapshot sequence", () =>
1184 - Effect.gen(function* () {
1185 - const harness = yield* makeHarness({ cached: BASE_PROJECTION });
1186 - yield* Queue.offer(harness.inputs, snapshot(BASE_PROJECTION));
1187 - yield* Queue.offer(harness.inputs, titleUpdated("Replayed title", 1));
1188 - yield* Queue.offer(harness.inputs, titleUpdated("Live title", 2));
1189 -
1190 - const state = yield* awaitThreadState(
1191 - harness.observed,
1192 - (value) =>
1193 - value.status === "live" &&
1194 - Option.isSome(value.data) &&
1195 - value.data.value.thread.title === "Live title",
1196 - );
1197 -
1198 - expect(Option.getOrThrow(state.data).thread.title).toBe("Live title");
1199 - }),
1200 - );
1201 -
1183 it.effect("does not recreate a deleted cache from a queued save or finalizer", () =>
1184 Effect.gen(function* () {
1185 const scope = yield* Scope.make();
packages/client-runtime/src/state/usageProgress.test.ts
-14
@@ -109,20 +109,6 @@ describe("usageProgress", () => {
109 });
110
111 describe("usageLoadingState", () => {
112 - it("marks only refreshing providers while the rest have answered", () => {
113 - const state = usageLoadingState([
114 - environment("a", { isPending: true, summary: summary(["cursor"]) }),
115 - environment("b"),
116 - ]);
117 - expect(state).toEqual({ partial: true, everyProvider: false, providers: new Set(["cursor"]) });
118 - });
119 -
120 - it("marks every provider while an environment has not answered", () => {
121 - const state = usageLoadingState([environment("a"), environment("b", { summary: null })]);
122 - expect(state.everyProvider).toBe(true);
123 - expect(state.partial).toBe(true);
124 - });
125 -
112 it("ignores environments that cannot answer and settles once all have", () => {
113 const state = usageLoadingState([
114 environment("a"),
packages/client-runtime/src/state/vcsAction.test.ts
-27
@@ -200,33 +200,6 @@ describe("vcsActionState", () => {
200 });
201 });
202
203 - it("keeps running presentation state and retains a terminal action error until settle", () => {
204 - const initial = beginVcsActionState({
205 - operation: "run_change_request",
206 - label: "Running source control action",
207 - actionId,
208 - });
209 - const failed = applyVcsActionProgressEvent(
210 - initial,
211 - progress({
212 - actionId,
213 - action,
214 - cwd,
215 - kind: "action_failed",
216 - phase: null,
217 - message: "Push failed.",
218 - }),
219 - );
220 -
221 - expect(failed).toMatchObject({
222 - isRunning: true,
223 - operation: "run_change_request",
224 - actionId,
225 - action,
226 - error: "Push failed.",
227 - });
228 - });
229 -
203 it("ignores progress after a newer action owns the target", () => {
204 const current = beginVcsActionState({
205 operation: "pull",
packages/client-runtime/src/work-log/commandLabel.test.ts
+7 -118
@@ -4,52 +4,30 @@ import { commandDisplayText, commandProgramName } from "./commandLabel.ts";
4
5 describe("commandProgramName", () => {
6 it.each([
7 - ["/bin/zsh -lc 'vp test run apps/web/src/session-logic.test.ts'", "vp"],
8 - ["/bin/zsh -lc 'git diff --check'", "git"],
9 - ['/bin/zsh -lc "npx -y react-doctor@latest apps/web"', "npx"],
10 - ["/bin/zsh -lc 'rg -n \"registerHooks|worker\" apps/web/src'", "rg"],
11 - ["/bin/bash --noprofile --norc -l -c 'sed -n 1,270p file.ts'", "sed"],
12 - ["/bin/bash -o pipefail -lc 'vp test run'", "vp"],
7 ["/bin/bash --rcfile /tmp/config -c 'git status'", "git"],
14 - ["sh -ec 'node scripts/check.js'", "node"],
15 - ["fish --command 'rg --files'", "rg"],
8 ["zsh -lc 'CI=1 env -u DEBUG sudo -u root vp test run'", "vp"],
17 - ["env CI=1 /bin/zsh -lc '\"/Applications/My Tools/bin/check\" --verbose'", "check"],
18 - ["bash -lc \"zsh -c 'git status'\"", "git"],
9 ['"C:\\Program Files\\Git\\bin\\bash.exe" -lc "git status"', "git"],
10 + // regression: #9371 a multiline script whose later line re-quotes must still label its first program
11 ["/bin/zsh -lc 'git status\nsed -n '\"'1,20p' apps/web/src/components/DiffPanel.tsx\"", "git"],
12 ])("unwraps shell scripts without executing them: %s", (command, program) => {
13 expect(commandProgramName(command)).toBe(program);
14 });
15
16 it.each([
26 - ["vp test run", "vp"],
17 ["sudo -u root pnpm test", "pnpm"],
28 - ["env --split-string='CI=1 node scripts/check.js'", "node"],
29 - ['"C:\\Program Files\\nodejs\\node.exe" script.js', "node.exe"],
30 - ["/bin/zsh", "zsh"],
31 - ["/bin/bash -l", "bash"],
18 ["zsh script.sh -c 'git status'", "zsh"],
33 - ["bash -- -c 'git status'", "bash"],
34 - ["bash --rcfile config.sh", "bash"],
19 ["my-shell -c 'git status'", "my-shell"],
20 ["$HOME/.bun/bin/bun test", "bun"],
37 - ['"$ANDROID_HOME/emulator/emulator" -list-avds', "emulator"],
38 - ["${ROOT}/bin/tool --version", "tool"],
21 ])("preserves ordinary programs and actual shell launches: %s", (command, program) => {
22 expect(commandProgramName(command)).toBe(program);
23 });
24
43 - it.each([
44 - "",
45 - "zsh -lc",
46 - "zsh -lc ''",
47 - "zsh -lc 'git status",
48 - "zsh -lc 'env'",
49 - 'zsh -lc "git \\\"',
50 - ])("falls back for missing or malformed scripts: %s", (command) => {
51 - expect(commandProgramName(command)).toBeNull();
52 - });
25 + it.each(["zsh -lc", "zsh -lc 'git status", "zsh -lc 'env'"])(
26 + "falls back for missing or malformed scripts: %s",
27 + (command) => {
28 + expect(commandProgramName(command)).toBeNull();
29 + },
30 + );
31
32 it.each([
33 "if test -f package.json; then vp test; fi",
@@ -90,16 +68,7 @@ describe("commandProgramName", () => {
68
69 it.each([
70 ['rg -n "if|for|while" src', "rg"],
93 - ["printf '%s\\n' 'a;b|c'", "printf"],
94 - ["node -e \"if (true) console.log('ok')\"", "node"],
95 - ["echo '$(git status)'", "echo"],
71 ["vp test && git status", "vp"],
97 - ["vp test || git status", "vp"],
98 - ["rg needle src | head", "rg"],
99 - ["vp test; git status", "vp"],
100 - ["vp test &", "vp"],
101 - ["vp test\ngit status", "vp"],
102 - ['echo "$(git status)"', "echo"],
72 ["echo `git status`", "echo"],
73 ["cat <(rg needle src)", "cat"],
74 ])("uses the first executable-looking program: %s", (command, program) => {
@@ -108,53 +77,25 @@ describe("commandProgramName", () => {
77
78 it.each([
79 ["cd packages/client-runtime && vp test run", "vp"],
111 - ['cd "a path with spaces"; git status', "git"],
112 - ["cd apps/web\npnpm test", "pnpm"],
113 - ["cd first && cd second && bun test", "bun"],
114 - ["CI=1 cd apps/web && npm test", "npm"],
80 ["PATH+=:/tools npm test", "npm"],
116 - ["PATH+=:/tools && npm test", "npm"],
117 - ['TMP=$(mktemp -d); cd "$TMP"; npm pack ./package', "npm"],
81 ["cd $(find . -type d | head -1) && git status", "git"],
119 - ["cd `find . -type d | head -1` && node script.js", "node"],
120 - ["cd /tmp 2>&1 && npm test", "npm"],
121 - ["cd /tmp 2<&0 && pnpm test", "pnpm"],
122 - ["cd /tmp &>/dev/null && bun test", "bun"],
123 - ["cd work |& npm test", "npm"],
82 ["cd /tmp && # use the selected workspace\nnpm test", "npm"],
125 - ["export CI=1; # first note\n# second note\npnpm test", "pnpm"],
126 - ["cd&&npm test", "npm"],
127 - ["export CI=1;pnpm test", "pnpm"],
83 ["cd ${ROOT:-path;with;semicolons} && bun test", "bun"],
129 - ["cd ${ROOT:-path&&fallback} && node app.js", "node"],
130 - ["cd @(first|second) && npm test", "npm"],
131 - ["cd /tmp \\\n&& npm test", "npm"],
132 - ["/bin/zsh -lc 'cd apps/web && vp test run'", "vp"],
84 ])("skips leading cd commands and uses the next useful program: %s", (command, program) => {
85 expect(commandProgramName(command)).toBe(program);
86 });
87
88 it.each([
89 ["source ~/.nvm/nvm.sh && nvm use", "nvm"],
139 - [". ./.env && pnpm test", "pnpm"],
140 - ["export CI=1 && vp test run", "vp"],
90 ["unset DEBUG; node app.js", "node"],
142 - ["export CI=1 && cd apps/web && pnpm test", "pnpm"],
91 ["/bin/zsh -lc 'source ~/.nvm/nvm.sh && nvm use'", "nvm"],
92 ])("skips shell setup commands and uses the next useful program: %s", (command, program) => {
93 expect(commandProgramName(command)).toBe(program);
94 });
95
96 it.each([
149 - ["timeout 10 pnpm test", "pnpm"],
97 ["timeout 10s python3 script.py", "python3"],
151 - ["gtimeout 1.5 node app.js", "node"],
152 - ["nohup npx expo start >/tmp/metro.log 2>&1 &", "npx"],
153 - ["nohup -- env CI=1 bun test", "bun"],
154 - ["arch -x86_64 ./build/app-under-test", "app-under-test"],
98 ["arch -arch arm64 /opt/tools/check", "check"],
156 - ["bundle exec pod install", "pod"],
157 - ["timeout 30 nohup env CI=1 node app.js", "node"],
99 ["timeout 60 script -q /dev/null env CI=1 node app.js", "node"],
100 ])("unwraps process-launch wrappers: %s", (command, program) => {
101 expect(commandProgramName(command)).toBe(program);
@@ -162,56 +103,17 @@ describe("commandProgramName", () => {
103
104 it.each([
105 "command -v git",
165 - "command -V git",
166 - "command -a git",
167 - "command -pv git",
168 - "builtin -p",
169 - "exec",
106 "exec > output.log",
171 - "exec --",
172 - "exec cd /tmp && npm test",
173 - "exec env CI=1 cd /tmp && npm test",
174 - "exec CI=1 npm test",
107 "env CI=1 cd /tmp && npm test",
176 - "env CI=1; npm test",
177 - "sudo cd /tmp && npm test",
178 - "command CI=1 npm test",
179 - "command false && npm test",
180 - "cmd /c false && npm test",
181 - "cd /tmp <<EOF\nunterminated heredoc",
182 - "cd /tmp && >/tmp/log",
183 - "(xcrun simctl io booted recordVideo /tmp/video.mp4 &) ; wait",
184 - "export CI=1 && (bundle exec pod install || pod install)",
108 "$PY scripts/check.py",
186 - "${TOOL} --version",
187 - "%TOOL% --version",
188 - "!TOOL! --version",
189 - "& $tool --version",
109 "& { Get-Process }",
191 - "$value = 'configured'",
192 - "$headers = @{ 'Accept' = 'application/json'; 'Content-Type' = 'application/json' }; Invoke-WebRequest https://example.com",
193 - '"sha256(value)=$hash"',
194 - "broken{",
195 - "@echo off",
196 - ":: comment",
197 - "time -- npm test",
198 - "time -v npm test",
110 "coproc npm test",
200 - "coproc worker { npm test; }",
201 - "cd [first|second] && pnpm test",
202 - "npm) --version",
203 - "try { Invoke-WebRequest https://example.com } catch { Write-Error $_ }",
204 - "for($i=0; $i -lt 2; $i++){ Start-Sleep 1 }",
205 - "# comment only",
111 ])("does not treat shell lookup and commandless wrapper forms as executions: %s", (command) => {
112 expect(commandProgramName(command)).toBeNull();
113 });
114
115 it.each([
211 - ["parallel -j4", "parallel"],
116 ["hash --help", "hash"],
213 - ["process --help", "process"],
214 - ["rem comment", "rem"],
117 ["Exec node app.js", "Exec"],
118 ["CD /tmp && npm test", "CD"],
119 ])("does not hide legitimate or case-distinct program names: %s", (command, program) => {
@@ -224,26 +126,15 @@ describe("commandProgramName", () => {
126
127 it.each([
128 [">/tmp/log && npm test", "npm"],
227 - ["2>/tmp/error.log; pnpm test", "pnpm"],
228 - ["cd /tmp && >/tmp/log npm test", "npm"],
229 - ["cd /tmp && > /tmp/log pnpm test", "pnpm"],
230 - ["cd /tmp && 2>&1 bun test", "bun"],
129 ["cd /tmp && 2>& 1 node app.js", "node"],
232 - ["cd /tmp && &>/tmp/log git status", "git"],
233 - ["cd /tmp && *>>/tmp/log vp test", "vp"],
130 ["cd /tmp && {output}>/tmp/log deno test", "deno"],
235 - ["cd /tmp && <<<input ruby script.rb", "ruby"],
131 ])("skips redirections before the next command: %s", (command, program) => {
132 expect(commandProgramName(command)).toBe(program);
133 });
134
135 it.each([
241 - ["cd /tmp <<EOF\nnot-a-command\nEOF\nnpm test", "npm"],
242 - ["cd /tmp <<'EOF'\nnot-a-command\nEOF\npnpm test", "pnpm"],
243 - ["cd /tmp <<'EOF'\nnot-a-command\\\nEOF\npnpm test", "pnpm"],
136 ["cd /tmp <<-EOF\n\tnot-a-command\n\tEOF\nbun test", "bun"],
137 ["cd /tmp <<A <<B\none\nA\ntwo\nB\ngit status", "git"],
246 - ["cd /tmp <<EOF; # setup\nnot-a-command\nEOF\nnpm test", "npm"],
138 ["cd /tmp <<EOF && pnpm test\nnot-a-command\nEOF\nbun test", "pnpm"],
139 ])("skips heredoc bodies before finding the next command: %s", (command, program) => {
140 expect(commandProgramName(command)).toBe(program);
@@ -291,9 +182,7 @@ describe("commandDisplayText control characters", () => {
182 it.each([
183 ["printf '\u001b[31mred\u001b[0m'", "printf '␛[31mred␛[0m'"],
184 ["zsh -lc 'printf \"\u001b[1m\"'", 'printf "␛[1m"'],
294 - ["echo bell\u0007 delete\u007f", "echo bell␇ delete␡"],
185 ["printf 'a\\tb'\r\necho done", "printf 'a\\tb'\r\necho done"],
296 - ["cat <<'EOF'\n\tindented\nEOF", "cat <<'EOF'\n\tindented\nEOF"],
186 ])("shows %j as %j", (input, expected) => {
187 expect(commandDisplayText(input)).toBe(expected);
188 });
packages/client-runtime/src/work-log/presentation.test.ts
-3
@@ -47,12 +47,9 @@ describe("workEntryIndicatesToolFailure", () => {
47 };
48
49 it.each([
50 - [{ outputIndicatesFailure: true }, true],
50 [{ exitCode: 2 }, true],
51 [{ output: "sh: missing-command: command not found" }, true],
53 - [{ output: "Found 3 matches" }, false],
52 [{ output: `${"x".repeat(32_768)} command not found` }, false],
55 - [{}, false],
53 ] as const)(
54 "preserves command failure state after removing displayed output: %j",
55 (fields, failed) => {
packages/contracts/src/settings.test.ts
-20
@@ -155,13 +155,6 @@ describe("ClientSettings quit confirmation", () => {
155 });
156 });
157
158 -describe("ServerSettings.providerInstances (slice-2 invariant)", () => {
159 - it("decodes a fully empty config (legacy on-disk shape) without complaint", () => {
160 - const decoded = decodeServerSettings({});
161 - expect(decoded.providerInstances).toEqual({});
162 - });
163 -});
164 -
158 describe("provider enabled defaults", () => {
159 it("resolves instance enabled state with explicit false winning", () => {
160 const grok = ProviderDriverKind.make("grok");
@@ -291,19 +284,6 @@ describe("resolveProjectProviderInstanceEnabled", () => {
284 };
285 expect(resolveProjectProviderInstanceEnabled(settings, projectId, instanceId)).toBe(false);
286 });
294 -
295 - it("always resolves to the machine value when no project is in scope", () => {
296 - const settings: ServerSettings = {
297 - ...DEFAULT_SERVER_SETTINGS,
298 - providerInstances: {
299 - [instanceId]: { driver: ProviderDriverKind.make("codex"), enabled: true },
300 - },
301 - projectSettingsOverrides: {
302 - [projectId]: { providerInstances: { [instanceId]: { enabled: false } } },
303 - },
304 - };
305 - expect(resolveProjectProviderInstanceEnabled(settings, null, instanceId)).toBe(true);
306 - });
287 });
288
289 describe("requiredScopesForProjectMutation", () => {
packages/effect-acp/src/_internal/stdio.test.ts
-14
@@ -7,20 +7,6 @@ import * as AcpError from "../errors.ts";
7 import { makeTerminationError } from "./stdio.ts";
8
9 describe("ACP child process termination", () => {
10 - it.effect("retains the process identifier with the exit code", () =>
11 - Effect.gen(function* () {
12 - const error = yield* makeTerminationError({
13 - pid: ChildProcessSpawner.ProcessId(41),
14 - exitCode: Effect.succeed(ChildProcessSpawner.ExitCode(7)),
15 - });
16 -
17 - assert.instanceOf(error, AcpError.AcpProcessExitedError);
18 - assert.equal(error.pid, 41);
19 - assert.equal(error.code, 7);
20 - assert.equal(error.message, "ACP process exited with code 7");
21 - }),
22 - );
23 -
10 it.effect("retains the process identifier and exact exit-status cause", () =>
11 Effect.gen(function* () {
12 const rootCause = new Error("private process diagnostics");
packages/effect-acp/src/errors.test.ts
-22
@@ -3,7 +3,6 @@ import * as Effect from "effect/Effect";
3 import * as Schema from "effect/Schema";
4 import * as RpcClientError from "effect/rpc/RpcClientError";
5
6 -import * as AcpSchema from "./_generated/schema.gen.ts";
6 import { callRpc } from "./_internal/shared.ts";
7 import * as AcpError from "./errors.ts";
8
@@ -54,27 +53,6 @@ describe("effect-acp errors", () => {
53 });
54 });
55
57 - it.effect("preserves protocol request errors as request errors", () => {
58 - const failure = AcpSchema.Error.make({
59 - code: -32602,
60 - message: "Invalid params",
61 - data: { field: "sessionId" },
62 - });
63 -
64 - return Effect.gen(function* () {
65 - const error = yield* callRpc("session/load", Effect.fail(failure)).pipe(Effect.flip);
66 -
67 - expect(error).toMatchObject({
68 - _tag: "AcpRequestError",
69 - code: -32602,
70 - errorMessage: "Invalid params",
71 - data: { field: "sessionId" },
72 - method: "session/load",
73 - operation: "receive-response",
74 - });
75 - });
76 - });
77 -
56 it("preserves structured extension handler failures behind stable request errors", () => {
57 const cause = new AcpError.AcpTransportError({
58 operation: "read-input-stream",
packages/effect-acp/src/protocol.test.ts
+1 -72
@@ -52,7 +52,6 @@ const decodeSessionCancelNotification = Schema.decodeEffect(
52 Schema.fromJsonString(SessionCancelNotification),
53 );
54 const decodeExtRequest = Schema.decodeEffect(Schema.fromJsonString(ExtRequest));
55 -const decodeExtResponse = Schema.decodeEffect(Schema.fromJsonString(ExtResponse));
55 const decodeRequestPermissionResponse = Schema.decodeEffect(
56 Schema.fromJsonString(RequestPermissionResponse),
57 );
@@ -271,6 +270,7 @@ it.layer(NodeServices.layer)("effect-acp protocol", (it) => {
270 }),
271 );
272
273 + // regression: #9154 notifications went out with `id` and `headers`, which Grok CLI drops
274 it.effect("logs outgoing notifications when logOutgoing is enabled", () =>
275 Effect.gen(function* () {
276 const { stdio } = yield* makeInMemoryStdio();
@@ -383,44 +383,6 @@ it.layer(NodeServices.layer)("effect-acp protocol", (it) => {
383 }),
384 );
385
386 - it.effect("supports generic extension requests over the patched transport", () =>
387 - Effect.gen(function* () {
388 - const { stdio, input, output } = yield* makeInMemoryStdio();
389 - const transport = yield* AcpProtocol.makeAcpPatchedProtocol({
390 - stdio,
391 - serverRequestMethods: new Set(),
392 - });
393 -
394 - const response = yield* transport
395 - .request("x/test", { hello: "world" })
396 - .pipe(Effect.forkScoped);
397 - const outbound = yield* Queue.take(output);
398 - assert.deepEqual(yield* decodeExtRequest(outbound), {
399 - jsonrpc: "2.0",
400 - id: 1,
401 - method: "x/test",
402 - params: {
403 - hello: "world",
404 - },
405 - headers: [],
406 - });
407 -
408 - yield* Queue.offer(
409 - input,
410 - yield* encodeJsonl(ExtResponse, {
411 - jsonrpc: "2.0",
412 - id: 1,
413 - result: {
414 - ok: true,
415 - },
416 - }),
417 - );
418 -
419 - const resolved = yield* Fiber.join(response);
420 - assert.deepEqual(resolved, { ok: true });
421 - }),
422 - );
423 -
386 it.effect("does not correlate a string response id with a numeric extension request id", () =>
387 Effect.gen(function* () {
388 const { stdio, input, output } = yield* makeInMemoryStdio();
@@ -543,39 +505,6 @@ it.layer(NodeServices.layer)("effect-acp protocol", (it) => {
505 }),
506 );
507
546 - it.effect("preserves numeric ids for inbound extension requests", () =>
547 - Effect.gen(function* () {
548 - const { stdio, input, output } = yield* makeInMemoryStdio();
549 - yield* AcpProtocol.makeAcpPatchedProtocol({
550 - stdio,
551 - serverRequestMethods: new Set(),
552 - onExtRequest: () => Effect.succeed({ ok: true }),
553 - });
554 -
555 - yield* Queue.offer(
556 - input,
557 - yield* encodeJsonl(ExtRequest, {
558 - jsonrpc: "2.0",
559 - id: 7,
560 - method: "x/test",
561 - params: {
562 - hello: "world",
563 - },
564 - headers: [],
565 - }),
566 - );
567 -
568 - const outbound = yield* Queue.take(output);
569 - assert.deepEqual(yield* decodeExtResponse(outbound), {
570 - jsonrpc: "2.0",
571 - id: 7,
572 - result: {
573 - ok: true,
574 - },
575 - });
576 - }),
577 - );
578 -
508 it.effect("preserves zero-valued ids for inbound core client requests", () =>
509 Effect.gen(function* () {
510 const { stdio, input, output } = yield* makeInMemoryStdio();
packages/effect-codex-app-server/src/_internal/shared.test.ts
-13
@@ -103,16 +103,3 @@ it.effect("retains the request-handler error as the internal error cause", () =>
103 assert.notInclude(error.message, source.message);
104 }),
105 );
106 -
107 -it.effect("passes request errors through without adding a wrapper", () =>
108 - Effect.gen(function* () {
109 - const source = CodexError.CodexAppServerRequestError.invalidParams("Invalid thread id");
110 - const error = yield* Shared.runHandler(
111 - (_payload: void) => Effect.fail(source),
112 - undefined,
113 - "thread/start",
114 - ).pipe(Effect.flip);
115 -
116 - assert.strictEqual(error, source);
117 - }),
118 -);
packages/effect-codex-app-server/src/protocol.test.ts
-38
@@ -546,44 +546,6 @@ it.layer(NodeServices.layer)("effect-codex-app-server protocol", (it) => {
546 }),
547 );
548
549 - it.effect("surfaces JSON encoding failures as protocol parse errors", () =>
550 - Effect.gen(function* () {
551 - const { stdio } = yield* makeInMemoryStdio();
552 - const transport = yield* CodexProtocol.makeCodexAppServerPatchedProtocol({ stdio });
553 -
554 - const bigintError = yield* transport.notify("x/test", 1n).pipe(Effect.flip);
555 - assert.instanceOf(bigintError, CodexError.CodexAppServerProtocolParseError);
556 - assert.equal(bigintError.operation, "encode-wire-message");
557 - assert.equal(bigintError.method, "x/test");
558 - assert.exists(bigintError.cause);
559 - assert.equal(
560 - bigintError.message,
561 - "Codex App Server protocol operation 'encode-wire-message' failed for method 'x/test'.",
562 - );
563 -
564 - const circular: Record<string, unknown> = {};
565 - circular.self = circular;
566 - const circularError = yield* transport.notify("x/test", circular).pipe(Effect.flip);
567 - assert.instanceOf(circularError, CodexError.CodexAppServerProtocolParseError);
568 - assert.equal(circularError.operation, "encode-wire-message");
569 - assert.equal(circularError.method, "x/test");
570 - assert.exists(circularError.cause);
571 -
572 - const requestError = yield* transport.request("x/request", 1n).pipe(
573 - Effect.match({
574 - onFailure: (error) => error,
575 - onSuccess: () => assert.fail("Expected request encoding to fail"),
576 - }),
577 - );
578 - assert.instanceOf(requestError, CodexError.CodexAppServerProtocolParseError);
579 - assert.deepInclude(requestError, {
580 - operation: "encode-wire-message",
581 - method: "x/request",
582 - requestId: "1",
583 - });
584 - }),
585 - );
586 -
549 it.effect("correlates response errors with the originating request", () =>
550 Effect.gen(function* () {
551 const { stdio, input, output } = yield* makeInMemoryStdio();
packages/provider-acp/src/server/nativeLogging.test.ts
-111
@@ -4,7 +4,6 @@ import { assert, it } from "@effect/vitest";
4 import * as Cause from "effect/Cause";
5 import * as Effect from "effect/Effect";
6 import * as Exit from "effect/Exit";
7 -import * as Logger from "effect/Logger";
7 import * as Schema from "effect/Schema";
8 import * as AcpErrors from "effect-acp/errors";
9
@@ -68,33 +67,6 @@ nodeServicesIt("ACP native logging", (it) => {
67 }),
68 );
69
71 - it.effect("keeps request diagnostics without enabling full protocol logging", () =>
72 - Effect.gen(function* () {
73 - const records: Array<unknown> = [];
74 - const makeLogger = yield* makeAcpNativeLoggerFactory();
75 - const logger = makeLogger({
76 - nativeEventLogger: {
77 - filePath: "/tmp/provider-native.ndjson",
78 - write: (event) => Effect.sync(() => void records.push(event)),
79 - close: () => Effect.void,
80 - },
81 - provider: ProviderDriverKind.make("grok"),
82 - threadId: ThreadId.make("thread-1"),
83 - });
84 -
85 - assert.isUndefined(logger.protocolLogging);
86 - const requestLogger = logger.requestLogger;
87 - assert.exists(requestLogger);
88 - if (!requestLogger) return;
89 - yield* requestLogger({
90 - method: "session/prompt",
91 - payload: {},
92 - status: "started",
93 - });
94 - assert.lengthOf(records, 1);
95 - }),
96 - );
97 -
70 it.effect("drops transient ACP chunks before formatting verbose protocol logs", () =>
71 Effect.gen(function* () {
72 const records: Array<unknown> = [];
@@ -152,89 +124,6 @@ nodeServicesIt("ACP native logging", (it) => {
124 }),
125 );
126
155 - it.effect("keeps mixed and incomplete raw diagnostics", () =>
156 - Effect.gen(function* () {
157 - const records: Array<unknown> = [];
158 - const makeLogger = yield* makeAcpNativeLoggerFactory();
159 - const logger = makeLogger({
160 - nativeEventLogger: {
161 - filePath: "/tmp/provider-native.ndjson",
162 - write: (event) => Effect.sync(() => void records.push(event)),
163 - close: () => Effect.void,
164 - },
165 - provider: ProviderDriverKind.make("cursor"),
166 - threadId: ThreadId.make("thread-1"),
167 - verboseProtocolLogging: true,
168 - });
169 - const protocolLogger = logger.protocolLogging?.logger;
170 - assert.exists(protocolLogger);
171 - if (!protocolLogger) return;
172 -
173 - const transient = encodeUnknownJson({
174 - method: "session/update",
175 - params: { update: { sessionUpdate: "agent_message_chunk" } },
176 - });
177 - const lifecycle = encodeUnknownJson({ method: "session/new", params: {} });
178 -
179 - yield* protocolLogger({
180 - direction: "incoming",
181 - stage: "raw",
182 - payload: `${transient}\n${lifecycle}\n`,
183 - });
184 - yield* protocolLogger({
185 - direction: "incoming",
186 - stage: "raw",
187 - payload: transient,
188 - });
189 - yield* protocolLogger({
190 - direction: "incoming",
191 - stage: "raw",
192 - payload: `${transient}\n{malformed}\n`,
193 - });
194 -
195 - assert.lengthOf(records, 3);
196 - }),
197 - );
198 -
199 - it.effect("logs a structural tag when the native writer defects", () => {
200 - const messages: Array<unknown> = [];
201 - const logCapture = Logger.make<unknown, void>(({ message }) => {
202 - if (Array.isArray(message)) {
203 - messages.push(...message);
204 - } else {
205 - messages.push(message);
206 - }
207 - });
208 - const secret = "secret-writer-failure";
209 -
210 - return Effect.gen(function* () {
211 - const makeLogger = yield* makeAcpNativeLoggerFactory();
212 - const logger = makeLogger({
213 - nativeEventLogger: {
214 - filePath: "/tmp/provider-native.ndjson",
215 - write: () => Effect.die(new Error(secret)),
216 - close: () => Effect.void,
217 - },
218 - provider: ProviderDriverKind.make("cursor"),
219 - threadId: ThreadId.make("thread-1"),
220 - });
221 - const requestLogger = logger.requestLogger;
222 - assert.exists(requestLogger);
223 - if (!requestLogger) return;
224 -
225 - yield* requestLogger({
226 - method: "session/prompt",
227 - payload: {},
228 - status: "started",
229 - });
230 -
231 - const serialized = encodeUnknownJson(messages);
232 - assert.notInclude(serialized, secret);
233 - assert.include(serialized, '"errorTag":"Die"');
234 - assert.include(serialized, '"reasonCount":1');
235 - }).pipe(Effect.provide(Logger.layer([logCapture], { mergeWithExisting: false })));
236 - });
237 -
127 it.effect("preserves native writer interruption", () =>
128 Effect.gen(function* () {
129 const makeLogger = yield* makeAcpNativeLoggerFactory();
packages/provider-acp/src/server/runtimeModel.test.ts
-21
@@ -636,17 +636,6 @@ describe("AcpRuntimeModel", () => {
636 data: {},
637 }) satisfies AcpToolCallState;
638
639 - it("emits the first in-progress tool_call even when it has no detail", () => {
640 - expect(
641 - decideToolCallUpdateEmission({
642 - previous: undefined,
643 - next: { toolCallId: "tool-1", title: "Grok Tool", status: "pending", data: {} },
644 - lastEmittedDetailLength: undefined,
645 - skippedSinceEmit: 0,
646 - }),
647 - ).toEqual({ emit: true, skippedSinceEmit: 0 });
648 - });
649 -
639 it("always emits terminal (completed/failed) status updates regardless of growth", () => {
640 expect(
641 decideToolCallUpdateEmission({
@@ -705,16 +694,6 @@ describe("AcpRuntimeModel", () => {
694 expect(emittedIndices).toEqual([1, 11]);
695 });
696
708 - it("emits immediately when the title changes, even with no growth", () => {
709 - const decision = decideToolCallUpdateEmission({
710 - previous: { toolCallId: "tool-1", title: "Reading file", detail: "x", data: {} },
711 - next: { toolCallId: "tool-1", title: "Ran command", detail: "x", data: {} },
712 - lastEmittedDetailLength: 1,
713 - skippedSinceEmit: 0,
714 - });
715 - expect(decision).toEqual({ emit: true, skippedSinceEmit: 0 });
716 - });
717 -
697 it("coalesces small deltas but forces an emission after the coalesce limit", () => {
698 let lastEmittedDetailLength: number | undefined = 0;
699 let skippedSinceEmit = 0;
packages/provider-core/src/server/notification.test.ts
-15
@@ -15,10 +15,6 @@ import { backgroundWorkNotification, notificationTurnItem } from "./notification
15 const childThreadId = ThreadId.make("thread:child");
16
17 describe("backgroundWorkNotification", () => {
18 - it("keeps the generic notification when nothing is known", () => {
19 - assert.isNull(backgroundWorkNotification([]));
20 - });
21 -
18 it("names one piece of work and the thread of a subagent", () => {
19 assert.deepEqual(
20 backgroundWorkNotification([
@@ -124,17 +120,6 @@ describe("notificationTurnItem", () => {
120 task("c", "Update docs", "running"),
121 ];
122
127 - it("says how many of a run's delegated tasks a delivery reports", () => {
128 - const item = notificationTurnItem(userMessage, delivery(["a", "b"]), tasks);
129 - assert.equal(item.type, "notification");
130 - if (item.type !== "notification") return;
131 - assert.equal(item.summary, "2 of 3 delegated tasks finished: Review src/math.ts, Write tests");
132 - assert.deepEqual(item.source, {
133 - kind: "delegated_task",
134 - taskIds: [NodeId.make("a"), NodeId.make("b")],
135 - });
136 - });
137 -
123 it("opens the child thread of a single delegated task", () => {
124 const item = notificationTurnItem(userMessage, delivery(["a"]), tasks);
125 assert.deepInclude(item, {
packages/provider-core/src/server/textGenerationUtils.test.ts
+1 -2
@@ -3,11 +3,10 @@ import { describe, expect, it } from "vite-plus/test";
3 import { sanitizeCommitSubject } from "./textGenerationUtils.ts";
4
5 describe("sanitizeCommitSubject", () => {
6 + // regression: #19181 truncation split grapheme clusters at the subject limit
7 it.each([
8 { name: "an emoji", prefixLength: 71, character: "🚀" },
9 { name: "an accented character", prefixLength: 71, character: "e\u0301" },
9 - { name: "an emoji with a skin tone", prefixLength: 70, character: "👍🏽" },
10 - { name: "a flag", prefixLength: 69, character: "🇮🇹" },
10 { name: "a joined emoji", prefixLength: 65, character: "👨‍👩‍👧‍👦" },
11 ])("keeps $name intact at the subject limit", ({ prefixLength, character }) => {
12 const prefix = "a".repeat(prefixLength);
packages/provider-cursor/src/server/transportFailure.test.ts
-11
@@ -14,8 +14,6 @@ describe("CursorTransportFailure", () => {
14 it.each([
15 diagnostic,
16 "Error: ConnectError: [unavailable] transport closed",
17 - "Error: ConnectError: [aborted] aborted",
18 - "Error: ConnectError: [deadline_exceeded] timed out",
17 "Something went wrong communicating with the server. Please try again.",
18 ])("recognizes a terminal diagnostic: %s", (message) => {
19 expect(failureFor([message])).toBe(message);
@@ -28,18 +26,9 @@ describe("CursorTransportFailure", () => {
26
27 it.each([
28 "The error was " + diagnostic,
31 - "This is an example of a transport error:\n" + diagnostic,
32 - "I inspected the files.\n" + diagnostic,
33 - "> " + diagnostic,
34 - " " + diagnostic,
29 "```text\n" + diagnostic + "\n```",
36 - "~~~\n" + diagnostic + "\n~~~",
37 - diagnostic + "\nThis is an example of a transport error.",
30 "Error: ConnectError: [unauthenticated] sign in",
39 - "Error: ConnectError: [permission_denied] subscription required",
40 - "Error: HTTP 500 from the application being debugged",
31 "Error: RetriableError: [internal] Failed to run step, exceeded max retries",
42 - "Error: RetriableError: [internal] Failed to run step, exceeded max retries\n at step (cli.js:1:2)",
32 ])("preserves prose, code and non-transport errors: %s", (message) => {
33 expect(failureFor([...message])).toBeUndefined();
34 });
packages/provider-grok/src/server/acpSupport.test.ts
-30
@@ -18,20 +18,6 @@ describe("grokAcpSpawnArgs", () => {
18 "stdio",
19 ]);
20 });
21 -
22 - it("maps Full access to Grok always-approve", () => {
23 - expect(grokAcpSpawnArgs("full-access")).toEqual(["agent", "--always-approve", "stdio"]);
24 - });
25 -
26 - it("launches Auto on Grok's classifier and a mode Grok does not offer asking", () => {
27 - expect(grokAcpSpawnArgs("auto")).toEqual(["--permission-mode", "auto", "agent", "stdio"]);
28 - expect(grokAcpSpawnArgs("auto-accept-edits")).toEqual([
29 - "--permission-mode",
30 - "default",
31 - "agent",
32 - "stdio",
33 - ]);
34 - });
21 });
22
23 describe("applyGrokAcpModelSelection", () => {
@@ -139,20 +125,4 @@ describe("applyGrokAcpModelSelection", () => {
125 expect(result).toBe("grok-4.6");
126 }),
127 );
142 -
143 - it.effect("propagates session/set_model failures via mapError", () =>
144 - Effect.gen(function* () {
145 - const failure = EffectAcpErrors.AcpRequestError.invalidParams("session id not known");
146 - const { runtime } = makeRecordingRuntime(failure);
147 - const error = yield* Effect.flip(
148 - applyGrokAcpModelSelection({
149 - runtime,
150 - currentModelId: "grok-build",
151 - requestedModelId: "grok-mock-alt",
152 - mapError: (cause) => cause.message,
153 - }),
154 - );
155 - expect(error).toBe(failure.message);
156 - }),
157 - );
128 });
packages/provider-grok/src/server/xaiAcpExtension.test.ts
-17
@@ -37,23 +37,6 @@ import {
37 const decodeXAiAskUserQuestionRequest = Schema.decodeUnknownSync(XAiAskUserQuestionRequest);
38
39 describe("xAiPromptCompleteFromSessionUpdate", () => {
40 - it("maps live turn_completed snake_case payloads", () => {
41 - expect(
42 - xAiPromptCompleteFromSessionUpdate({
43 - sessionId: "019f4428-4bf1-7e52-b7c6-c29b506543b1",
44 - update: {
45 - sessionUpdate: "turn_completed",
46 - prompt_id: "t3-xai-prompt-1",
47 - stop_reason: "end_turn",
48 - },
49 - }),
50 - ).toEqual({
51 - sessionId: "019f4428-4bf1-7e52-b7c6-c29b506543b1",
52 - promptId: "t3-xai-prompt-1",
53 - stopReason: "end_turn",
54 - });
55 - });
56 -
40 it("ignores non-turn updates and task-completed prompt ids", () => {
41 expect(
42 xAiPromptCompleteFromSessionUpdate({
packages/provider-grok/src/server/xaiBackgroundTasks.test.ts
-12
@@ -54,16 +54,8 @@ describe("Grok background tasks", () => {
54
55 it.each([
56 ["running", null, "task.progress", undefined],
57 - ["pending", null, "task.progress", undefined],
58 - ["completed", 0, "task.completed", "completed"],
59 - ["success", 0, "task.completed", "completed"],
60 - ["succeeded", 0, "task.completed", "completed"],
57 ["failed", 1, "task.completed", "failed"],
62 - ["error", 1, "task.completed", "failed"],
58 ["stopped", 137, "task.completed", "stopped"],
64 - ["killed", 137, "task.completed", "stopped"],
65 - ["cancelled", 137, "task.completed", "stopped"],
66 - [undefined, 0, "task.completed", "completed"],
59 [undefined, 1, "task.completed", "failed"],
60 ])("maps poll status %s / exit %s", (status, exit_code, type, expectedStatus) => {
61 const { tasks, update } = mapper();
@@ -182,11 +174,7 @@ describe("Grok background tasks", () => {
174 });
175
176 it.each([
185 - null,
186 - [],
187 - {},
177 { type: "Text", text: "subagent_id: fake\ntype: executor\ndescription: fake" },
189 - { type: "Monitor", taskId: " " },
178 { type: "BackgroundTaskStarted", task_id: "shell-1" },
179 {
180 type: "TaskOutput",
packages/provider-opencode/src/server/OpenCodeRuntime.cliParsers.test.ts
-26
@@ -23,12 +23,6 @@ describe("parseModelsCliOutput", () => {
23 NodeAssert.equal(Object.keys(result.providers.get("openai")!.models).length, 1);
24 });
25
26 - it("handles empty input", () => {
27 - const result = OpenCodeRuntime.parseModelsCliOutput("");
28 - NodeAssert.equal(result.providers.size, 0);
29 - NodeAssert.equal(result.connected.length, 0);
30 - });
31 -
26 it("skips unparseable JSON blocks", () => {
27 const stdout = [
28 "anthropic/claude-sonnet-4-5",
@@ -79,26 +73,6 @@ describe("parseModelsCliOutput", () => {
73 });
74
75 describe("parseAgentListCliOutput", () => {
82 - it("parses multiple agents", () => {
83 - const stdout = [
84 - "build (primary)",
85 - " " + JSON.stringify([{ permission: "*", action: "allow", pattern: "*" }]),
86 - "explore (subagent)",
87 - " " + JSON.stringify([{ permission: "read", action: "allow", pattern: "*" }]),
88 - "plan (primary)",
89 - " " + JSON.stringify([{ permission: "edit", action: "ask", pattern: "*.md" }]),
90 - ].join("\n");
91 -
92 - const result = OpenCodeRuntime.parseAgentListCliOutput(stdout);
93 - NodeAssert.equal(result.length, 3);
94 - NodeAssert.equal(result[0]!.name, "build");
95 - NodeAssert.equal(result[0]!.mode, "primary");
96 - NodeAssert.equal(result[1]!.name, "explore");
97 - NodeAssert.equal(result[1]!.mode, "subagent");
98 - NodeAssert.equal(result[2]!.name, "plan");
99 - NodeAssert.equal(result[2]!.mode, "primary");
100 - });
101 -
76 it("skips agents with unparseable permission JSON", () => {
77 const stdout = [
78 "build (primary)",
packages/provider-opencode/src/server/OpenCodeRuntime.permissions.test.ts
-2
@@ -63,9 +63,7 @@ describe("toOpenCodePermissionReply", () => {
63 it.each([
64 ["accept", "once"],
65 ["acceptForSession", "always"],
66 - ["acceptAlways", "always"],
66 ["decline", "reject"],
68 - ["cancel", "reject"],
67 ] as const)("maps %s to %s", (decision, reply) => {
68 NodeAssert.equal(OpenCodeRuntime.toOpenCodePermissionReply(decision), reply);
69 });
packages/provider-opencode/src/server/adapter.test.ts
+1 -11
@@ -237,7 +237,7 @@ const makeOpenCodeRuntimeHarness = Effect.fn("makeOpenCodeRuntimeHarness")(funct
237 });
238
239 describe("OpenCodeAdapterV2", () => {
240 - it.effect.each(["completed", "failed", "unresolved", "unavailable", "reconnect"] as const)(
240 + it.effect.each(["completed", "failed", "unavailable"] as const)(
241 "normalizes OpenCode step usage for %s turns",
242 (ending) =>
243 Effect.gen(function* () {
@@ -324,16 +324,6 @@ describe("OpenCodeAdapterV2", () => {
324 );
325 yield* Effect.promise(() => nativeEvents.push(step("old", "old-assistant")));
326 }
327 - if (ending === "unresolved")
328 - yield* Effect.promise(() => nativeEvents.push(step("unknown", "unknown-assistant")));
329 - if (ending === "reconnect") {
330 - yield* Effect.promise(() =>
331 - nativeEvents.push({ type: "server.connected", properties: {} }),
332 - );
333 - yield* Effect.promise(() =>
334 - nativeEvents.push({ type: "server.connected", properties: {} }),
335 - );
336 - }
327 if (ending === "failed") {
328 yield* Effect.promise(() =>
329 nativeEvents.push({
packages/provider-opencode/src/server/openCode2Catalog.test.ts
+1
@@ -84,6 +84,7 @@ describe("loadOpenCode2Catalog", () => {
84 }),
85 );
86
87 + // regression: #17424 only the provider list is optional; a model-list failure fails the read
88 it.effect("fails the read when the model list fails", () =>
89 Effect.gen(function* () {
90 const error = yield* readCatalog({
packages/provider-opencode/src/server/status.test.ts
-56
@@ -462,31 +462,6 @@ const checkProvider = Effect.fn("checkProvider")(function* (
462 });
463
464 it.layer(layerTest)("checkOpenCodeProviderStatus", (it) => {
465 - it.effect("shows a codex-style missing binary message", () =>
466 - Effect.gen(function* () {
467 - runtimeMock.state.runVersionError = new Error("spawn opencode ENOENT");
468 - const snapshot = yield* checkProvider(makeOpenCodeSettings());
469 -
470 - NodeAssert.equal(snapshot.status, "error");
471 - NodeAssert.equal(snapshot.installed, false);
472 - NodeAssert.equal(
473 - snapshot.message,
474 - "OpenCode CLI (`opencode`) is not installed or not on PATH.",
475 - );
476 - }),
477 - );
478 -
479 - it.effect("hides generic Effect.tryPromise text for local CLI probe failures", () =>
480 - Effect.gen(function* () {
481 - runtimeMock.state.runVersionError = new Error("An error occurred in Effect.tryPromise");
482 - const snapshot = yield* checkProvider(makeOpenCodeSettings());
483 -
484 - NodeAssert.equal(snapshot.status, "error");
485 - NodeAssert.equal(snapshot.installed, true);
486 - NodeAssert.equal(snapshot.message, "Failed to execute OpenCode CLI health check.");
487 - }),
488 - );
489 -
465 it.effect("emits OpenCode variant defaults so trait picker can resolve a visible selection", () =>
466 Effect.gen(function* () {
467 runtimeMock.state.inventory = {
@@ -715,18 +690,6 @@ it.layer(layerTest)("checkOpenCodeProviderStatus", (it) => {
690 }),
691 );
692
718 - it.effect("uses the settings password when local environment auth differs", () =>
719 - Effect.gen(function* () {
720 - yield* checkProvider(
721 - makeOpenCodeSettings({ serverPassword: "settings-password" }),
722 - process.cwd(),
723 - { OPENCODE_SERVER_PASSWORD: "environment-password" },
724 - );
725 -
726 - NodeAssert.equal(runtimeMock.state.sdkClientInputs[0]?.serverPassword, "settings-password");
727 - }),
728 - );
729 -
693 it.effect("reports local model inventory failures without treating them as empty", () =>
694 Effect.gen(function* () {
695 runtimeMock.state.versionStdout = "opencode 1.14.20\n";
@@ -805,25 +768,6 @@ it.layer(layerTest)("checkOpenCodeProviderStatus with configured server URL", (i
768 NodeAssert.equal(runtimeMock.state.sdkClientInputs.length, 0);
769 }),
770 );
808 -
809 - it.effect("surfaces a friendly auth error for configured servers", () =>
810 - Effect.gen(function* () {
811 - runtimeMock.state.connectionError = new Error("401 Unauthorized");
812 - const snapshot = yield* checkProvider(
813 - makeOpenCodeSettings({
814 - serverUrl: "http://127.0.0.1:9999",
815 - serverPassword: "secret-password",
816 - }),
817 - );
818 -
819 - NodeAssert.equal(snapshot.status, "error");
820 - NodeAssert.equal(snapshot.installed, true);
821 - NodeAssert.equal(
822 - snapshot.message,
823 - "OpenCode server rejected authentication. Check the server URL and password.",
824 - );
825 - }),
826 - );
771 });
772
773 const builtinCommands = [
packages/provider-opencode/src/server/textGeneration.test.ts
-69
@@ -213,10 +213,6 @@ const layerOpenCodeTextGenerationExistingServerTest = Layer.succeed(
213 const DEFAULT_OPENCODE_SETTINGS = Schema.decodeSync(OpenCodeSettings)({
214 binaryPath: "fake-opencode",
215 });
216 -const LOCAL_AUTH_OPENCODE_SETTINGS = Schema.decodeSync(OpenCodeSettings)({
217 - binaryPath: "fake-opencode",
218 - serverPassword: "secret-password",
219 -});
216 const EXISTING_SERVER_OPENCODE_SETTINGS = Schema.decodeSync(OpenCodeSettings)({
217 binaryPath: "fake-opencode",
218 serverUrl: "http://127.0.0.1:9999",
@@ -370,19 +366,6 @@ it.layer(layerOpenCodeTextGenerationTest)("OpenCodeTextGeneration", (it) => {
366 ),
367 );
368
373 - it.effect("passes configured authentication to a locally spawned server", () =>
374 - withOpenCodeTextGeneration(LOCAL_AUTH_OPENCODE_SETTINGS, (textGeneration) =>
375 - Effect.gen(function* () {
376 - yield* textGeneration.generateCommitMessage(DEFAULT_COMMIT_MESSAGE_INPUT);
377 -
378 - expect(runtimeMock.state.startCalls).toEqual(["fake-opencode"]);
379 - expect(runtimeMock.state.authHeaders).toEqual([
380 - `Basic ${btoa("opencode:secret-password")}`,
381 - ]);
382 - }),
383 - ),
384 - );
385 -
369 it.effect("uses an environment-only password for a locally spawned server", () =>
370 withOpenCodeTextGeneration(
371 DEFAULT_OPENCODE_SETTINGS,
@@ -398,21 +381,6 @@ it.layer(layerOpenCodeTextGenerationTest)("OpenCodeTextGeneration", (it) => {
381 ),
382 );
383
401 - it.effect("uses settings auth when the local environment password differs", () =>
402 - withOpenCodeTextGeneration(
403 - LOCAL_AUTH_OPENCODE_SETTINGS,
404 - (textGeneration) =>
405 - Effect.gen(function* () {
406 - yield* textGeneration.generateCommitMessage(DEFAULT_COMMIT_MESSAGE_INPUT);
407 -
408 - expect(runtimeMock.state.authHeaders).toEqual([
409 - `Basic ${btoa("opencode:secret-password")}`,
410 - ]);
411 - }),
412 - { OPENCODE_SERVER_PASSWORD: "environment-password" },
413 - ),
414 - );
415 -
384 it.effect("returns a typed empty-output error for malformed and blank response parts", () =>
385 withOpenCodeTextGeneration(DEFAULT_OPENCODE_SETTINGS, (textGeneration) =>
386 Effect.gen(function* () {
@@ -471,43 +439,6 @@ it.layer(layerOpenCodeTextGenerationTest)("OpenCodeTextGeneration", (it) => {
439 }),
440 ),
441 );
474 -
475 - it.effect("surfaces the upstream OpenCode structured-output error message", () =>
476 - withOpenCodeTextGeneration(DEFAULT_OPENCODE_SETTINGS, (textGeneration) =>
477 - Effect.gen(function* () {
478 - runtimeMock.state.promptResult = {
479 - data: {
480 - info: {
481 - error: {
482 - name: "StructuredOutputError",
483 - data: {
484 - message: "Model did not produce structured output",
485 - retries: 2,
486 - },
487 - },
488 - },
489 - },
490 - };
491 -
492 - const error = yield* textGeneration
493 - .generateCommitMessage(DEFAULT_COMMIT_MESSAGE_INPUT)
494 - .pipe(Effect.flip);
495 -
496 - expect(error.message).toContain("Model did not produce structured output");
497 - expect(error.cause).toMatchObject({
498 - _tag: "OpenCodeTextGenerationPromptResponseError",
499 - operation: "generateCommitMessage",
500 - cwd: process.cwd(),
501 - sessionId: "http://127.0.0.1:4301/session",
502 - providerId: "openai",
503 - modelId: "gpt-5",
504 - providerErrorName: "StructuredOutputError",
505 - providerMessage: "Model did not produce structured output",
506 - });
507 - expect(error.cause).not.toHaveProperty("cause");
508 - }),
509 - ),
510 - );
442 });
443
444 it.layer(layerOpenCodeTextGenerationExistingServerTest)(
packages/provider-pi/src/server/adapter.test.ts
-43
@@ -517,45 +517,6 @@ const startTurn = Effect.fnUntraced(function* (
517 });
518 });
519
520 -const expectModelFailure = (errorMessage: string) =>
521 - Effect.gen(function* () {
522 - const fake = yield* makeFakePi;
523 - const { runtime, takeEvent } = yield* openRuntime(fake);
524 - const providerThread = yield* runtime.ensureThread({
525 - threadId: THREAD_ID,
526 - modelSelection: modelSelection("default"),
527 - runtimePolicy,
528 - });
529 - yield* startTurn(runtime, providerThread);
530 - yield* fake.takeRequest("prompt");
531 - yield* fake.emit({ type: "agent_start" });
532 - yield* fake.emit({
533 - type: "message_end",
534 - message: {
535 - role: "assistant",
536 - content: [],
537 - stopReason: "error",
538 - errorMessage,
539 - },
540 - });
541 - yield* fake.emit({ type: "agent_settled" });
542 -
543 - const sessionError = yield* takeEvent(
544 - (event) =>
545 - event.type === "provider_session.updated" && event.providerSession.status === "error",
546 - );
547 - assert.isTrue(
548 - sessionError.type === "provider_session.updated" &&
549 - sessionError.providerSession.lastError === errorMessage,
550 - );
551 - const terminal = yield* takeEvent((event) => event.type === "turn.terminal");
552 - assert.isTrue(
553 - terminal.type === "turn.terminal" &&
554 - terminal.status === "failed" &&
555 - terminal.failure.message === errorMessage,
556 - );
557 - }).pipe(Effect.scoped, Effect.provide(layerTest));
558 -
520 describe("PiAdapterV2", () => {
521 it.effect.each([false, true])(
522 "completes a resumed user turn before native wake events arrive, Pi streaming=%s",
@@ -2902,10 +2863,6 @@ describe("PiAdapterV2", () => {
2863 }).pipe(Effect.scoped, Effect.provide(layerTest)),
2864 );
2865
2905 - it.effect("persists current xAI capacity text for the thread error banner", () =>
2906 - expectModelFailure("The model is currently at capacity due to high demand."),
2907 - );
2908 -
2866 it.effect.each([
2867 { toolName: "bash", exitCode: 0, legacy: false },
2868 { toolName: "powershell", exitCode: 2, legacy: false },
packages/provider-pi/src/server/commands.test.ts
-32
@@ -47,35 +47,3 @@ it("maps current Pi skill metadata to T3's user and project skill scopes", () =>
47 slashCommands: [{ name: "hello", description: "Say hello." }],
48 });
49 });
50 -
51 -it("maps Pi global location and interface labels onto T3 skill fields", () => {
52 - expect(
53 - parsePiDiscoveredCommands({
54 - commands: [
55 - {
56 - name: "skill:global-review",
57 - description: "Review changes.",
58 - source: "skill",
59 - location: "global",
60 - interface: {
61 - displayName: "Global Review",
62 - shortDescription: "Review diffs.",
63 - },
64 - },
65 - ],
66 - }),
67 - ).toEqual({
68 - skills: [
69 - {
70 - name: "global-review",
71 - description: "Review changes.",
72 - path: "pi:skill:global-review",
73 - scope: "user",
74 - enabled: true,
75 - displayName: "Global Review",
76 - shortDescription: "Review diffs.",
77 - },
78 - ],
79 - slashCommands: [],
80 - });
81 -});
packages/provider-pi/src/server/status.test.ts
+1 -4
@@ -146,13 +146,10 @@ describe("PiProvider", () => {
146 }).pipe(Effect.provide(NodeServices.layer)),
147 );
148
149 + // regression: #18498 a malformed model inventory must not restore stale Pi models
150 it.effect.each([
151 ["missing models", {}],
151 - ["non-array models", { models: {} }],
152 - ["missing model provider", { models: [{ id: "claude-sonnet-4" }] }],
152 ["missing model id", { models: [{ provider: "anthropic" }] }],
154 - ["empty model provider", { models: [{ provider: "", id: "claude-sonnet-4" }] }],
155 - ["empty model id", { models: [{ provider: "anthropic", id: "" }] }],
153 [
154 "mixed valid and invalid models",
155 { models: [{ provider: "anthropic", id: "claude-sonnet-4" }, { provider: "openrouter" }] },
packages/shared/src/agentAwareness.test.ts
-16
@@ -158,22 +158,6 @@ describe("projectThreadAwarenessV2", () => {
158 ).toMatchObject({ phase });
159 });
160
161 - it("prioritizes V2 user-input requests", () => {
162 - expect(
163 - projectThreadAwarenessV2({
164 - environmentId: "env-1" as EnvironmentId,
165 - project,
166 - thread: v2Thread({
167 - pendingRuntimeRequest: {
168 - id: RuntimeRequestId.make("request-1"),
169 - kind: "user_input",
170 - createdAt: updatedAt,
171 - },
172 - }),
173 - }),
174 - ).toMatchObject({ phase: "waiting_for_input", headline: "Waiting for input" });
175 - });
176 -
161 it("reports an async question as input only after the working run completes", () => {
162 const input = {
163 environmentId: "env-1" as EnvironmentId,
packages/shared/src/assistantCitations.test.ts
-11
@@ -89,22 +89,11 @@ describe("assistant citation references", () => {
89 });
90
91 it.each([
92 - "https://example.com/quote",
92 "t3-citation://v2/a/b/c?text=quote&start=0&end=5&prefix=&suffix=",
94 - "t3-citation://v1/%ZZ/b/c?text=quote&start=0&end=5&prefix=&suffix=",
95 - "t3-citation://v1/a/b/c?text=quote&start=NaN&end=5&prefix=&suffix=",
93 "t3-citation://v1/a/b/c?text=quote&start=5&end=0&prefix=&suffix=",
97 - "t3-citation://v1/a/b/c?text=quote&start=0&end=9007199254740992&prefix=&suffix=",
94 "t3-citation://v1/a/b/c?text=quote&start=0&end=5&prefix=&suffix=&text=other",
95 "t3-citation://v1/a/b/c?text=quote&start=0&end=5&prefix=&suffix=&unknown=value",
100 - "t3-citation://v1/a/b/c?text=quote&start=0&end=5&prefix=&suffix=&comment=note&unknown=value",
96 "t3-citation://v1/a/b/c?text=quote&start=0&end=5&prefix=&suffix=&comment=one&comment=two",
102 - "t3-citation://v1/a/b/c?text=quote&start=0&end=5&prefix=&suffix=&comment=&comment=",
103 - "t3-citation://v1/a/b/c?text=quote&start=0&end=5&prefix=&suffix=&comment=one&%63omment=two",
104 - "t3-citation://v1/a/b/c?text=quote&start=0&end=5&prefix=&comment=note",
105 - "t3-citation://v1/a/b/c?text=quote&start=0&end=5&prefix=&suffix=&text=other&comment=note",
106 - "t3-citation://v1/a/b/c?text=&start=0&end=5&prefix=&suffix=",
107 - "t3-citation://v1/a/b/c?text=quote&start=0&end=5&prefix=&suffix=#unexpected",
97 ])("leaves invalid or unsupported references unchanged: %s", (href) => {
98 expect(parseAssistantCitationHref(href)).toBeNull();
99 const prompt = `[Assistant quote](${href})`;
packages/shared/src/changeRequestUrl.test.ts
-33
@@ -126,43 +126,12 @@ describe("parseChangeRequestUrl", () => {
126 });
127
128 describe("siblingPullRequestUrl", () => {
129 - it("recognizes Forgejo on custom HTTP hosts", () => {
130 - expect(parseChangeRequestUrl("http://git.example.test:3000/team/repo/pulls/42/files")).toEqual({
131 - host: "git.example.test",
132 - authority: "git.example.test:3000",
133 - repository: "team/repo",
134 - number: 42,
135 - });
136 - });
129 it.each([
130 [
131 "http://git.example.test:3000/team/repo/pulls/42/files",
132 "http://git.example.test:3000/team/repo/pulls/43",
133 ],
142 - [
143 - "https://git.example.test/forgejo/team/repo/pulls/42/files",
144 - "https://git.example.test/forgejo/team/repo/pulls/43",
145 - ],
134 ["https://github.com/pull/1/pull/42/files", "https://github.com/pull/1/pull/43"],
147 - [
148 - "https://git.acme.test/team/merge_requests/1/repo/-/merge_requests/42/diffs",
149 - "https://git.acme.test/team/merge_requests/1/repo/-/merge_requests/43",
150 - ],
151 -
152 - ["https://github.com/acme/web/pull/42#discussion_r123", "https://github.com/acme/web/pull/43"],
153 - ["https://github.com/acme/web/pull/42/files?w=1", "https://github.com/acme/web/pull/43"],
154 - [
155 - "https://github.acme.test:8443/acme/web/pull/42/",
156 - "https://github.acme.test:8443/acme/web/pull/43",
157 - ],
158 - [
159 - "https://git.acme.test/acme/web/-/merge_requests/42/diffs",
160 - "https://git.acme.test/acme/web/-/merge_requests/43",
161 - ],
162 - [
163 - "https://bitbucket.org/acme/web/pull-requests/42",
164 - "https://bitbucket.org/acme/web/pull-requests/43",
165 - ],
135 [
136 "https://dev.azure.com/acme/project/_git/web/pullrequest/42?view=files",
137 "https://dev.azure.com/acme/project/_git/web/pullrequest/43",
@@ -187,7 +156,6 @@ describe("changeRequestUrlFor", () => {
156
157 it.each([
158 ["http://forge.example:3000/git/owner/repo.git", "http://forge.example:3000"],
190 - ["https://forge.example:8443/git/owner/repo.git", "https://forge.example:8443"],
159 ["git@forge.example:git/owner/repo.git", "https://forge.example"],
160 ["http://other.example:3000/git/owner/repo.git", "https://forge.example"],
161 ])("preserves the matching Forgejo web origin from %s", (remoteUrl, origin) => {
@@ -198,7 +166,6 @@ describe("changeRequestUrlFor", () => {
166
167 it.each([
168 ["ssh.dev.azure.com", "v3/org/project/web"],
201 - ["vs-ssh.visualstudio.com", "v3/org/project/web"],
169 ["org.visualstudio.com", "defaultcollection/project/_git/web"],
170 ["dev.azure.com", "org/project/_git/web"],
171 ])("builds a browser URL from the Azure remote %s/%s", (host, repository) => {
packages/shared/src/changedFileKind.test.ts
-33
@@ -4,43 +4,10 @@ import { classifyChangedFile } from "./changedFileKind.ts";
4
5 describe("classifyChangedFile", () => {
6 it.each([
7 - ["apps/server/src/ws.ts", "code"],
8 - ["src/latest.ts", "code"],
9 - ["src/Latest.java", "code"],
7 ["src/contest.py", "code"],
11 - ["src/mockingbird.ts", "code"],
12 - ["src/testimonials/List.tsx", "code"],
13 - ["apps/web/src/foo.test.ts", "tests"],
14 - ["apps/web/src/Foo.browser.test.tsx", "tests"],
15 - ["src/foo.spec.js", "tests"],
16 - ["pkg/server_test.go", "tests"],
17 - ["tests/test_api.py", "tests"],
18 - ["conftest.py", "tests"],
19 - ["src/main/java/RequestTest.java", "tests"],
20 - ["Sources/AppTests.swift", "tests"],
21 - ["src/HTTPTest.java", "tests"],
22 - ["Sources/URLTests.swift", "tests"],
23 - ["spec/models/user_spec.rb", "tests"],
24 - ["src/__tests__/helpers.ts", "tests"],
25 - ["src/testUtils.ts", "code"],
26 - ["src\\__tests__\\app.ts", "tests"],
27 - ["src/__mocks__/fs.ts", "mocks"],
8 ["test/fixtures/pr.json", "mocks"],
29 - ["src/__snapshots__/view.test.ts.snap", "mocks"],
30 - ["src/api.mock.ts", "mocks"],
31 - ["src/mockServer.ts", "mocks"],
32 - ["pkg/testdata/input.txt", "mocks"],
9 ["pnpm-lock.yaml", "generated"],
34 - ["apps/web/package-lock.json", "generated"],
35 - ["go.sum", "generated"],
36 - ["src/routeTree.gen.ts", "generated"],
37 - ["src/__generated__/types.ts", "generated"],
38 - ["dist/app.min.js", "generated"],
10 ["README.md", "docs"],
40 - ["docs/internals/overview.mdx", "docs"],
41 - ["NOTES.txt", "docs"],
42 - ["requirements-dev.txt", "code"],
43 - ["CMakeLists.txt", "code"],
11 ["tests/README.md", "tests"],
12 ] as const)("%s is %s", (path, kind) => {
13 expect(classifyChangedFile(path)).toBe(kind);
packages/shared/src/cliArgs.test.ts
-23
@@ -40,20 +40,6 @@ describe("tokenizeCliArgs", () => {
40 });
41
42 describe("parseCliArgs", () => {
43 - it("parses --chrome --effort high --debug", () => {
44 - expect(parseCliArgs("--chrome --effort high --debug")).toEqual({
45 - flags: { chrome: null, effort: "high", debug: null },
46 - positionals: [],
47 - });
48 - });
49 -
50 - it("parses quoted --append-system-prompt with value and --chrome", () => {
51 - expect(parseCliArgs(`--append-system-prompt "always think step by step" --chrome`)).toEqual({
52 - flags: { "append-system-prompt": "always think step by step", chrome: null },
53 - positionals: [],
54 - });
55 - });
56 -
43 it("parses --key=value mixed with boolean flags", () => {
44 expect(parseCliArgs("--chrome --model=claude-sonnet-4-6 --debug")).toEqual({
45 flags: { chrome: null, model: "claude-sonnet-4-6", debug: null },
@@ -80,13 +66,4 @@ describe("parseCliArgs", () => {
66 },
67 );
68 });
83 -
84 - it("non-boolean flag still consumes next token", () => {
85 - expect(parseCliArgs(["--root", "/path", "1.2.3"], { booleanFlags: ["github-output"] })).toEqual(
86 - {
87 - flags: { root: "/path" },
88 - positionals: ["1.2.3"],
89 - },
90 - );
91 - });
69 });
packages/shared/src/codexMarkdownDirectives.test.ts
+1 -8
@@ -74,12 +74,8 @@ describe("remarkCodexDirectives", () => {
74
75 it.each([
76 "Meeting at 10:30",
77 - "Open src/main.ts:42",
78 - "Use :hover and :tada:",
79 - "::note",
77 ":::note\ncontent\n:::",
78 ':codex-file-citation-extra{path="outputs/report.xlsx"}',
82 - "::artifact-template-extra",
79 ':codex-followup-extra[Label]{prompt="Prompt"}',
80 ])("does not change unrelated colon syntax: %s", (markdown) => {
81 expect(parse(markdown)).toEqual(parseOrdinaryMarkdown(markdown));
@@ -87,10 +83,8 @@ describe("remarkCodexDirectives", () => {
83
84 it.each([
85 ':codex-file-citation{purpose="output"}',
90 - '::artifact-template{skill_name="artifact-template-hello-world"}',
86 ":codex-followup[Prepare print version]",
87 ':codex-followup[ ]{prompt="Prepare the document for printing."}',
93 - ':codex-followup[Prepare print version]{prompt=" "}',
88 ])("keeps malformed supported directives literal: %s", (markdown) => {
89 expect(parse(markdown)).toEqual(parseOrdinaryMarkdown(markdown));
90 });
@@ -100,10 +94,10 @@ describe.each([
94 { name: "renderCodexDirectivesForCopy", render: renderCodexDirectivesForCopy },
95 { name: "renderCodexInlineDirectivesAsMarkdown", render: renderCodexInlineDirectivesAsMarkdown },
96 ])("$name file citation round trips", ({ render }) => {
97 + // regression: #12243 copied Codex citations keep their backslashes
98 it.each([
99 "C:\\Users\\test\\[draft]\\report.md",
100 "\\\\server\\share\\report.md",
106 - "outputs/report.md",
101 "/tmp/report%5C.md",
102 ])("preserves the literal path and line: %s", (path) => {
103 const markdown = render(`:codex-file-citation{path="${path}" line_range_start="7"}`);
@@ -126,7 +120,6 @@ describe("native Markdown adapters", () => {
120 it.each([
121 `\\${FILE_CITATION}`,
122 `\`${FILE_CITATION}\``,
129 - `\`\`\`text\n${FILE_CITATION}\n\`\`\``,
123 `[See ${FILE_CITATION}](https://example.com)`,
124 ])("does not render excluded citation syntax: %s", (markdown) => {
125 expect(renderCodexInlineDirectivesAsMarkdown(markdown)).toBe(markdown);
packages/shared/src/composerContextLegacy.test.ts
+11 -19
@@ -80,25 +80,17 @@ describe("upgradeLegacyContextMessage", () => {
80 expect(upgradeLegacyContextMessage(text)).toEqual({ text, records: [] });
81 });
82
83 - it.each([
84 - "email@build:7",
85 - "café@build:7",
86 - "𐐀@build:7",
87 - "@build:7foo",
88 - "@build:7st",
89 - "@build:7é",
90 - "@build:7.foo",
91 - "@build:7@mention",
92 - "@build:7..foo",
93 - "@build:7.é",
94 - ])("does not replace terminal labels embedded in %s", (prompt) => {
95 - const upgraded = upgradeLegacyContextMessage(
96 - `${prompt}\n<terminal_context>\n- Build line 7:\n output\n</terminal_context>`,
97 - );
98 - expect(upgraded.text).toBe(
99 - `${prompt}\n\n[Build line 7](t3-context://v1/terminal/legacy_terminal_1)`,
100 - );
101 - });
83 + it.each(["email@build:7", "@build:7foo", "@build:7.foo"])(
84 + "does not replace terminal labels embedded in %s",
85 + (prompt) => {
86 + const upgraded = upgradeLegacyContextMessage(
87 + `${prompt}\n<terminal_context>\n- Build line 7:\n output\n</terminal_context>`,
88 + );
89 + expect(upgraded.text).toBe(
90 + `${prompt}\n\n[Build line 7](t3-context://v1/terminal/legacy_terminal_1)`,
91 + );
92 + },
93 + );
94
95 it.each(["terminal_context", "element_context"])(
96 "preserves malformed trailing %s blocks as text",
packages/shared/src/connectAuth.test.ts
-24
@@ -2,7 +2,6 @@ import { describe, expect, it } from "vite-plus/test";
2
3 import {
4 buildConnectAuthorizeRequestUrl,
5 - buildConnectClerkAuthorizeUrl,
5 connectLoopbackRedirectUri,
6 readConnectAuthorizeRequest,
7 } from "./connectAuth.ts";
@@ -49,27 +48,4 @@ describe("connectAuth", () => {
48 expect(readConnectAuthorizeRequest(url), port).toBeNull();
49 }
50 });
52 -
53 - it("builds a PKCE authorize URL against the Clerk endpoint", () => {
54 - const url = new URL(
55 - buildConnectClerkAuthorizeUrl({
56 - authorizationEndpoint: "https://clerk.t3.codes/oauth/authorize",
57 - clientId: "oauthapp_123",
58 - redirectUri: connectLoopbackRedirectUri(34338),
59 - scopes: ["openid", "profile", "email", "offline_access"],
60 - state: "state-1",
61 - challenge: "challenge-1",
62 - }),
63 - );
64 -
65 - expect(url.origin).toBe("https://clerk.t3.codes");
66 - expect(url.pathname).toBe("/oauth/authorize");
67 - expect(url.searchParams.get("client_id")).toBe("oauthapp_123");
68 - expect(url.searchParams.get("redirect_uri")).toBe("http://127.0.0.1:34338/callback");
69 - expect(url.searchParams.get("response_type")).toBe("code");
70 - expect(url.searchParams.get("scope")).toBe("openid profile email offline_access");
71 - expect(url.searchParams.get("state")).toBe("state-1");
72 - expect(url.searchParams.get("code_challenge")).toBe("challenge-1");
73 - expect(url.searchParams.get("code_challenge_method")).toBe("S256");
74 - });
51 });
packages/shared/src/dateTime.test.ts
+11 -35
@@ -14,47 +14,23 @@ describe("compareDateTimeStrings", () => {
14
15 it.each([
16 ["2024-02-29T12:00:00Z", "2024-02-29T17:30:00+05:30"],
17 - ["2000-02-29T00:00:00.100Z", "2000-02-28T20:30:00.1-03:30"],
17 ["0000-01-01T00:00:00.000Z", "+000000-01-01T00:00:00.000+00:00"],
19 - ["+010000-01-01T00:00:00.000Z", "9999-12-31T23:00:00.000-01:00"],
18 ["2026-09-01T24:00:00Z", "2026-09-02T00:00:00Z"],
21 - ["2026-09-01T24:00:00.0000Z", "2026-09-02T00:00:00.000Z"],
22 - ["2024-02-29T24:00:00+05:30", "2024-03-01T00:00:00+05:30"],
23 - ["2026-12-31T24:00:00-07:00", "2027-01-01T07:00:00Z"],
24 - ["2026-09-01T12:00Z", "2026-09-01T12:00:00.000Z"],
25 - ["2026-09-01T05:00-07:00", "2026-09-01T12:00:00Z"],
26 - ["2026-09-01T24:00Z", "2026-09-02T00:00:00Z"],
27 - ["2026-09-01T24:00+05:30", "2026-09-02T00:00:00+05:30"],
19 ])("preserves equal ISO instants %s and %s", (left, right) => {
20 expect(compareDateTimeStrings(left, right)).toBe(0);
21 });
22
32 - it.each([
33 - "2014-02-30",
34 - "2014-03-02",
35 - "2014-03-02T00:00:00",
36 - "2014-03-02T00:00:00.000",
37 - "03/02/2014",
38 - "March 2, 2014",
39 - "Sun, 02 Mar 2014 00:00:00 GMT",
40 - "2014-03-02T00:00:00.000Z\n",
41 - "2014-02-30T00:00:00.000Z",
42 - "1900-02-29T00:00:00.000-07:00",
43 - "2024-04-31T00:00:00.000+05:30",
44 - "2024-03-02T12:00:00.000+24:00",
45 - "2026-09-01T24:01:00Z",
46 - "2026-09-01T24:00:01Z",
47 - "2026-09-01T24:00:00.0001Z",
48 - "2026-09-01T24:01Z",
49 - "2026-09-01T25:00Z",
50 - ])("treats %s as malformed without native date guessing", (malformed) => {
51 - const valid = "1970-01-01T00:00:00.000Z";
52 - expect(compareDateTimeStrings(malformed, valid)).toBeLessThan(0);
53 - expect(compareDateTimeStrings(valid, malformed)).toBeGreaterThan(0);
54 - expect(compareDateTimeStrings(malformed, "invalid")).toBeLessThan(0);
55 - expect(compareDateTimeStrings("invalid", malformed)).toBeGreaterThan(0);
56 - expect(compareDateTimeStrings(malformed, malformed)).toBe(0);
57 - });
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";
packages/shared/src/favicon.test.ts
+2 -1
@@ -9,7 +9,8 @@ describe("faviconUrlForOrigin", () => {
9 );
10 });
11
12 - it.each([null, undefined, "", "invalid URL", "file:///tmp/private", "data:text/plain,private"])(
12 + // regression: #5838 no favicon request for missing or non-http origins
13 + it.each([null, "invalid URL", "file:///tmp/private"])(
14 "rejects an invalid or unsupported origin %s",
15 (origin) => {
16 expect(faviconUrlForOrigin(origin)).toBeNull();
packages/shared/src/fileLinks.test.ts
+2 -16
@@ -3,7 +3,6 @@ import { parseFileUrlHref, splitFilePathPosition, resolvePathLinkTarget } from "
3
4 describe("parseFileUrlHref", () => {
5 it.each([
6 - ["file:///Users/julius/project/src/main.ts#L42", "/Users/julius/project/src/main.ts", "#L42"],
6 [
7 "file:///D:/Programme/t3code/OpenInPicker.tsx#L69",
8 "D:/Programme/t3code/OpenInPicker.tsx",
@@ -29,40 +28,28 @@ describe("parseFileUrlHref", () => {
28
29 describe("splitFilePathPosition", () => {
30 it.each([
32 - ["src/main.ts", "", { path: "src/main.ts" }],
33 - ["src/main.ts:12", "", { path: "src/main.ts", line: 12 }],
31 ["src/main.ts:12:5", "", { path: "src/main.ts", line: 12, column: 5 }],
32 ["src/main.ts", "#L18C2", { path: "src/main.ts", line: 18, column: 2 }],
33 ["src/main.ts:3", "#L18C2", { path: "src/main.ts", line: 3 }],
34 ["src/main.ts:0", "", { path: "src/main.ts" }],
38 - ["src/main.ts", "#section", { path: "src/main.ts" }],
35 ])("splits %s%s", (path, hash, expected) => {
36 expect(splitFilePathPosition(path, hash)).toEqual(expected);
37 });
38 });
39
40 describe("resolvePathLinkTarget", () => {
41 + // regression: #21199 Windows terminal file links resolve against a Windows cwd
42 it.each([
43 [
44 String.raw`src\index.ts:12:7`,
45 String.raw`C:\Users\Jane Doe\project`,
46 String.raw`C:\Users\Jane Doe\project\src\index.ts:12:7`,
47 ],
51 - [
52 - "src/index.ts:12:7",
53 - "C:/Users/Jane Doe/project",
54 - String.raw`C:/Users/Jane Doe/project\src\index.ts:12:7`,
55 - ],
48 [
49 String.raw`.\src\index.ts:12`,
50 String.raw`\\server\share\project`,
51 String.raw`\\server\share\project\.\src\index.ts:12`,
52 ],
61 - [
62 - String.raw`~\index.ts:12`,
63 - String.raw`C:\Users\Jane Doe\project`,
64 - String.raw`C:\Users\Jane Doe\index.ts:12`,
65 - ],
53 ["src/index.ts:12", "/home/jane/project", "/home/jane/project/src/index.ts:12"],
54 ])("resolves %s using the connected environment cwd %s", (path, cwd, expected) => {
55 expect(resolvePathLinkTarget(path, cwd)).toBe(expected);
@@ -74,9 +61,8 @@ describe("resolvePathLinkTarget", () => {
61 ).toBe("C:/Users/julius/project/src/main.ts:12");
62 });
63
64 + // regression: #19627 Windows home paths match case-insensitively
65 it.each([
78 - ["C:\\Users\\julius\\project", "C:\\Users\\julius\\notes.md:3"],
79 - ["C:/Users/julius/project", "C:/Users/julius\\notes.md:3"],
66 ["C:\\users\\alice\\project", "C:\\users\\alice\\notes.md:3"],
67 ["C:/uSeRs/alice/project", "C:/uSeRs/alice\\notes.md:3"],
68 ])("resolves home paths against the Windows cwd %s", (cwd, expected) => {
packages/shared/src/filePreview.test.ts
+8 -23
@@ -9,31 +9,22 @@ import {
9 } from "./filePreview.ts";
10
11 describe("workspace file previews", () => {
12 - it.each([
13 - "README.md",
14 - "src/index.ts",
15 - "image.png.ts",
16 - "png",
17 - "image.png#notes.txt",
18 - "image.svg?notes.txt",
19 - "document.pdf?download=1",
20 - "report.html#notes.txt",
21 - "image%2Epng",
22 - ])("rejects non-preview path %s", (path) => {
23 - expect(isWorkspacePreviewEntryPath(path)).toBe(false);
24 - });
12 + // regression: #10311 previews classify by the literal filename, not URL-like suffixes
13 + it.each(["image.png.ts", "image.png#notes.txt", "image%2Epng"])(
14 + "rejects non-preview path %s",
15 + (path) => {
16 + expect(isWorkspacePreviewEntryPath(path)).toBe(false);
17 + },
18 + );
19 });
20
21 describe("media path parsing", () => {
22 + // regression: #9023 media kind comes from the decoded pathname, ignoring query and hash
23 it.each([
24 ["https://cdn.example/clip.webm?download=1#t=2", "video"],
25 ["https://example.com/download?name=recording.mp4", null],
31 - ["https://example.png", null],
26 ["images%2Fresult%2Epng", "image"],
33 - ["images/result%23v2.png", "image"],
27 ["images/result.png%23secret.txt", null],
35 - ["images/result.png%3Fsecret.txt", null],
36 - ["/tmp/100%.png", "image"],
28 ])("classifies the decoded pathname of %s", (source, kind) => {
29 expect(mediaKindFromPath(source)).toBe(kind);
30 });
@@ -42,13 +33,7 @@ describe("media path parsing", () => {
33 describe("attachment preview classification", () => {
34 it.each([
35 ["example.json", "application/octet-stream", "text"],
45 - ["README.md", "text/plain", "markdown"],
46 - ["component.tsx", "", "text"],
47 - ["report.pdf", "application/pdf", "pdf"],
48 - ["page.HTML", "", "html"],
49 - ["recording.mp3", "", "audio"],
36 ["payload", "application/problem+json", "text"],
51 - ["archive.zip", "application/zip", "unsupported"],
37 ["misleading.json", "application/pdf", "pdf"],
38 ["misleading.pdf", "application/zip", "unsupported"],
39 ])("classifies %s (%s) as %s", (name, mimeType, expected) => {
packages/shared/src/git.test.ts
+2 -5
@@ -266,9 +266,9 @@ describe("sanitizeFeatureBranchName", () => {
266 );
267 });
268
269 + // regression: #15615 generated branch namespaces are preserved
270 it.each([
271 ["refine toolbar", "feature/refine-toolbar"],
271 - ["", "feature/update"],
272 [" /?. / ", "feature/update"],
273 ["fix///", "feature/fix"],
274 ])("keeps the fallback for unprefixed input %s", (input, expected) => {
@@ -286,13 +286,11 @@ describe("resolveAutoFeatureBranchName", () => {
286 ).toBe("fix/refine-toolbar-3");
287 });
288
289 + // regression: #15615 generated branch namespaces are preserved
290 it.each([
291 ["fix/name", ["fix"], "fix-2/name"],
291 - ["team/jules/fix/name", ["team/jules"], "team/jules-2/fix/name"],
292 ["fix/name", ["fix/name/child"], "fix/name-2"],
293 - ["FIX/name", ["FIX", "FIX-2"], "fix-3/name"],
293 ["fix/name", ["fixes", "fix/name-extra/child"], "fix/name"],
295 - [undefined, ["feature", "feature-2"], "feature-3/update"],
294 ])("resolves %s against namespace blockers %j", (preferredBranch, existingNames, expected) => {
295 expect(resolveAutoFeatureBranchName(existingNames, preferredBranch)).toBe(expected);
296 });
@@ -300,7 +298,6 @@ describe("resolveAutoFeatureBranchName", () => {
298
299 describe("formatGeneratedBranchName", () => {
300 it.each([
303 - ["release..candidate", "release-candidate/add-search"],
301 [" Team / Jules.lock/", "Team/Jules-lock/add-search"],
302 ["-team//feature@{new}", "team/feature-new/add-search"],
303 [" /?. / ", "add-search"],
packages/shared/src/htmlRender.test.ts
+8 -11
@@ -31,17 +31,14 @@ describe("injectHtmlRenderBootstrap", () => {
31 expect(injected.endsWith("<p>hi</p>")).toBe(true);
32 });
33
34 - it.each(["textarea", "title", "xmp", "iframe", "noembed", "noframes", "noscript", "plaintext"])(
35 - "keeps the bootstrap outside %s content",
36 - (tag) => {
37 - const fragment = `<${tag}><head><meta name="viewport"></head></${tag}>`;
38 - const injected = injectHtmlRenderBootstrap(fragment);
39 - expect(injected.startsWith("<!doctype html><head>")).toBe(true);
40 - expect(injected.indexOf('<style id="t3-theme">')).toBeLessThan(injected.indexOf(`<${tag}>`));
41 - expect(injected).toContain('<meta name="viewport" content="width=device-width');
42 - expect(injected.endsWith(fragment)).toBe(true);
43 - },
44 - );
34 + it.each(["textarea", "iframe", "plaintext"])("keeps the bootstrap outside %s content", (tag) => {
35 + const fragment = `<${tag}><head><meta name="viewport"></head></${tag}>`;
36 + const injected = injectHtmlRenderBootstrap(fragment);
37 + expect(injected.startsWith("<!doctype html><head>")).toBe(true);
38 + expect(injected.indexOf('<style id="t3-theme">')).toBeLessThan(injected.indexOf(`<${tag}>`));
39 + expect(injected).toContain('<meta name="viewport" content="width=device-width');
40 + expect(injected.endsWith(fragment)).toBe(true);
41 + });
42
43 it.each([
44 '<template><head><meta name="viewport"></head></template>',
packages/shared/src/markdownLinks.test.ts
+9 -99
@@ -9,50 +9,23 @@ import {
9 } from "./markdownLinks.ts";
10
11 describe("isMarkdownFileLinkLabel", () => {
12 + // regression: #15509 descriptive labels are not mistaken for the linked file name
13 it.each([
14 ["validates the input", "/repo/src/example.ts:12", false],
14 - ["read src/example.ts", "/repo/src/example.ts:12", false],
15 - ["example.ts?why this matters", "/repo/src/example.ts", false],
16 - ["example.ts", "/repo/src/example.ts:12", true],
15 ["example.ts:12", "/repo/src/example.ts:12", true],
16 ["example.ts:99", "/repo/src/example.ts:12", false],
19 - ["example.ts:12:2", "/repo/src/example.ts:12:2", true],
20 - ["example.ts:12:3", "/repo/src/example.ts:12:2", false],
21 - ["example.ts:12", "/repo/src/example.ts", false],
22 - ["src/example.ts:12", "/repo/src/example.ts:12", true],
23 - ["./src/example.ts", "/repo/src/example.ts", true],
24 - ["/repo/src/example.ts", "/repo/src/example.ts", true],
25 - ["src/", "/home/me/project/src/", true],
26 - ["EXAMPLE.TS", "C:/repo/src/example.ts:12", true],
27 - ["file name.ts", "file:///repo/file%20name.ts", true],
28 - ["", "/repo/src/example.ts", true],
17 ])("classifies %s for %s", (label, href, expected) => {
18 expect(isMarkdownFileLinkLabel(label, href)).toBe(expected);
19 });
20 });
21
22 describe("inlineCodeFilePathCandidate", () => {
23 + // regression: #13909 model ids in inline code do not become file chips
24 it.each([
25 ["src\\main.ts", "src/main.ts"],
37 - ["C:\\Users\\demo\\image.png", "C:\\Users\\demo\\image.png"],
38 - ["\\\\server\\share\\image.png", "\\\\server\\share\\image.png"],
39 - ["conf.d/nginx.conf", "conf.d/nginx.conf"],
40 - ["script.pl:10", "script.pl:10"],
41 - ["node.meta", null],
42 - ["Recorded evidence here: /tmp/image.png", null],
26 ["origin/main", null],
44 - ["127.0.0.1:3000", null],
45 - ["example.com/index.html", null],
46 - ["example.pl/index.html", null],
27 ["z-ai/glm-5.3", null],
48 - ["z-ai/glm-5.3:12", null],
49 - ["python/3.12", null],
50 - ["Qwen/Qwen2.5-Coder", null],
51 - ["meta-llama/Llama-3.1-8B", null],
28 ["share/man/ls.1", "share/man/ls.1"],
53 - ["usr/lib/libfoo.so.1", "usr/lib/libfoo.so.1"],
54 - ["vendor/jquery-3.6.0.min.js", "vendor/jquery-3.6.0.min.js"],
55 - ["./models/glm-5.3", "./models/glm-5.3"],
29 ])("distinguishes file paths from code and hostnames in %s", (source, candidate) => {
30 expect(inlineCodeFilePathCandidate(source)).toBe(candidate);
31 });
@@ -60,46 +33,19 @@ describe("inlineCodeFilePathCandidate", () => {
33
34 describe("parseMarkdownFileLink", () => {
35 it.each([
63 - ["/Users/julius/project/AGENTS.md", "/Users/julius/project/AGENTS.md"],
64 - ["/home/me/notes.md", "/home/me/notes.md"],
65 - ["/usr/local/bin/tool", "/usr/local/bin/tool"],
66 - ["/workspace/Makefile", "/workspace/Makefile"],
67 - ["/tmp/favicons/", "/tmp/favicons/"],
68 - ["C:\\Users\\mike\\project\\src\\main.ts", "C:\\Users\\mike\\project\\src\\main.ts"],
36 ["C:%5Crepo%5Cimage.png", "C:\\repo\\image.png"],
70 - ["\\\\server\\share\\image.png", "\\\\server\\share\\image.png"],
71 - ["/D:/Programme/t3code/OpenInPicker.tsx", "D:/Programme/t3code/OpenInPicker.tsx"],
37 ["</D:/Programme/t3code/ChatMarkdown.tsx:1>", "D:/Programme/t3code/ChatMarkdown.tsx"],
73 - ["file:///Users/julius/project/file%2520name.md", "/Users/julius/project/file%20name.md"],
74 - ["file://server/share/workspace-image.svg", "\\\\server\\share\\workspace-image.svg"],
38 ["file://localhost/home/me/notes.md", "/home/me/notes.md"],
76 - ["apps/mobile/src/index.ts:10", "apps/mobile/src/index.ts"],
77 - ["docs/My%20Folder/checklist.xml", "docs/My Folder/checklist.xml"],
78 - ["Updated%20cutover%20checklist.md", "Updated cutover checklist.md"],
79 - ["./scripts/deploy", "./scripts/deploy"],
80 - ["~/notes/today.md", "~/notes/today.md"],
81 - ["AGENTS.md", "AGENTS.md"],
82 - ["script.ts:10", "script.ts"],
83 - ["/tmp/clip%23one.mp4#t=2", "/tmp/clip#one.mp4"],
39 ])("recognizes %s as a file", (href, path) => {
40 expect(parseMarkdownFileLink(href)?.path).toBe(path);
41 });
42
88 - it.each([
89 - "",
90 - "#anchor",
91 - "//cdn.example.com/clip.mp4",
92 - "https://example.com/docs",
93 - "mailto:someone@example.com",
94 - "javascript:alert(1)",
95 - "/chat/settings",
96 - "/chat/settings#L3",
97 - "/app#L1",
98 - "readme",
99 - "TODO:12",
100 - ])("does not treat %s as a file", (href) => {
101 - expect(parseMarkdownFileLink(href)).toBeNull();
102 - });
43 + it.each(["https://example.com/docs", "/chat/settings#L3", "TODO:12"])(
44 + "does not treat %s as a file",
45 + (href) => {
46 + expect(parseMarkdownFileLink(href)).toBeNull();
47 + },
48 + );
49
50 it("accepts conventional extensionless names with or without a position", () => {
51 expect(parseMarkdownFileLink("Makefile")).toEqual({ path: "Makefile" });
@@ -122,29 +68,10 @@ describe("parseMarkdownFileLink", () => {
68 });
69
70 describe("workspaceRelativeFilePath", () => {
71 + // regression: #12449 workspace root links resolve to "."
72 it.each([
73 ["/repo/project", "/repo/project", "."],
127 - ["/repo/project/", "/repo/project/", "."],
128 - ["/", "/", "."],
129 - ["C:/USERS/mike/project", "c:/users/MIKE/project", "."],
74 ["C:/", "c:/", "."],
131 - ["/repo/project/src/main.ts", "/repo/project", "src/main.ts"],
132 - ["/repo/project/src/main.ts", "/repo/project/", "src/main.ts"],
133 - ["C:\\Users\\mike\\t3code\\apps\\web\\a.ts", "C:/Users/mike/t3code", "apps/web/a.ts"],
134 - ["/C:/Users/mike/t3code/apps/web/a.ts", "C:/Users/mike/t3code", "apps/web/a.ts"],
135 - ["/Repo/Project/src/main.ts", "/repo/project", null],
136 - ["/tmp/case/project/probe.txt", "/tmp/case/Project", null],
137 - ["//tmp/case/project/probe.txt", "//tmp/case/Project", null],
138 - ["/tmp/case/Project/probe.txt", "/tmp/case/Project", "probe.txt"],
139 - ["C:/USERS/mike/t3code/main.ts", "c:/users/MIKE/t3code", "main.ts"],
140 - ["/C:/USERS/mike/t3code/main.ts", "/c:/users/MIKE/t3code", "main.ts"],
141 - ["\\\\server\\share\\PROJECT\\main.ts", "\\\\Server\\Share\\Project", "main.ts"],
142 - ["/tmp/repo/file.ts", "/", "tmp/repo/file.ts"],
143 - ["C:/Users/MIKE/main.ts", "c:/", "Users/MIKE/main.ts"],
144 - ["\\\\server\\SHARE\\file.ts", "\\\\Server\\Share\\", "file.ts"],
145 - ["/tmp/repo/file.ts ", "/tmp/repo", "file.ts "],
146 - ["/tmp/report.ts", "/repo/project", null],
147 - ["/repo/project-two/a.ts", "/repo/project", null],
75 ["/repo/project/a.ts", undefined, null],
76 ])("relates %s to %s", (path, workspaceRoot, relativePath) => {
77 expect(workspaceRelativeFilePath(path, workspaceRoot)).toBe(relativePath);
@@ -154,31 +81,14 @@ describe("workspaceRelativeFilePath", () => {
81 describe("extractMarkdownLinkHrefs", () => {
82 it.each([
83 ["[".repeat(32_000), []],
157 - ["[](a".repeat(16_000), []],
158 - ["[](<a".repeat(16_000), []],
159 - ["[x](https://e.com/".repeat(8_000), []],
84 ["[a](<foo)bar> invalid [b](ok)", ["<foo", "ok"]],
161 - ["[a](foo \"mixed title') [b](< >)", ["foo"]],
162 - ["[a](<one [b](two)> invalid [c](ok)", ["two", "ok"]],
163 - ["```text\n" + "[unfinished item\n".repeat(8_000) + "```", []],
85 ["[[[nested](src/main.ts) [unfinished", ["src/main.ts"]],
165 - ["[outer [inner] invalid [valid](src/main.ts)", ["src/main.ts"]],
166 - ["[bad](missing title [valid](src/main.ts)", ["src/main.ts"]],
167 - ["```text\n[link](src/main.ts)\n```", ["src/main.ts"]],
168 - ["[empty]() [valid](src/main.ts 'title')", ["src/main.ts"]],
169 - ['[angle](<src/My File.ts> "title")', ["src/My File.ts"]],
86 ])("extracts links from incomplete and nested text", (markdown, hrefs) => {
87 expect(extractMarkdownLinkHrefs(markdown)).toEqual(hrefs);
88 });
89 });
90
91 describe("resolveMarkdownFileLinkTarget", () => {
176 - it("resolves relative file paths against cwd", () => {
177 - expect(resolveMarkdownFileLinkTarget("src/processRunner.ts:71", "/Users/julius/project")).toBe(
178 - "/Users/julius/project/src/processRunner.ts:71",
179 - );
180 - });
181 -
92 it("does not treat filename line references as external schemes", () => {
93 expect(resolveMarkdownFileLinkTarget("script.ts:10", "/Users/julius/project")).toBe(
94 "/Users/julius/project/script.ts:10",
packages/shared/src/markdownMath.test.ts
+27 -33
@@ -54,16 +54,13 @@ describe("chat math parsing", () => {
54 },
55 );
56
57 - it.each(["\\(x\\)", "\\[x\\]", "$x$", "$$x$$"])(
58 - "preserves indented code containing %s",
59 - (formula) => {
60 - const source = ` ${formula}`;
61 - expect(collect(parse(source)).find((node) => node.type === "code")).toMatchObject({
62 - value: formula,
63 - });
64 - expect(markdownMathRanges(source)).toEqual([]);
65 - },
66 - );
57 + it.each(["\\(x\\)", "$x$", "$$x$$"])("preserves indented code containing %s", (formula) => {
58 + const source = ` ${formula}`;
59 + expect(collect(parse(source)).find((node) => node.type === "code")).toMatchObject({
60 + value: formula,
61 + });
62 + expect(markdownMathRanges(source)).toEqual([]);
63 + });
64
65 it("parses formulas without reserving private-use characters", () => {
66 const characters = Array.from({ length: 6400 }, (_, index) =>
@@ -187,7 +184,7 @@ describe("chat math parsing", () => {
184 });
185 });
186
190 - it.each([1, 2, 3, 4])("respects %i backslashes before a display fence", (count) => {
187 + it.each([1, 2])("respects %i backslashes before a display fence", (count) => {
188 const prefix = "a+" + "\\".repeat(count);
189 for (const opening of ["$$", "$$\n"]) {
190 const source = `${opening}${prefix}$$\nb\n$$`;
@@ -270,28 +267,25 @@ describe("math in GFM tables", () => {
267 }
268 });
269
273 - it.each([
274 - "[a](https://example.com/$x)",
275 - '[a](https://example.com "title $x")',
276 - "<https://example.com/$x>",
277 - "`$x`",
278 - '<span title="$x">a</span>',
279 - ])("preserves table separators after literal dollars in %s", (literal) => {
280 - const row = `| ${literal} | y$ |`;
281 - for (const source of [`${row}\n| --- | --- |`, `| First | Second |\n| --- | --- |\n${row}`]) {
282 - const tree = parse(source);
283 - const table = tree.children[0];
284 - expect(table?.type).toBe("table");
285 - if (table?.type !== "table") throw new Error("Missing table");
286 - expect(table.children.every((entry) => entry.children.length === 2)).toBe(true);
287 - expect(markdownMathRanges(source, tree)).toEqual([]);
288 - if (literal.startsWith("[a](https://example.com/$x)")) {
289 - expect(collect(tree).find((node) => node.type === "link")).toMatchObject({
290 - url: "https://example.com/$x",
291 - });
270 + it.each(["[a](https://example.com/$x)", "`$x`", '<span title="$x">a</span>'])(
271 + "preserves table separators after literal dollars in %s",
272 + (literal) => {
273 + const row = `| ${literal} | y$ |`;
274 + for (const source of [`${row}\n| --- | --- |`, `| First | Second |\n| --- | --- |\n${row}`]) {
275 + const tree = parse(source);
276 + const table = tree.children[0];
277 + expect(table?.type).toBe("table");
278 + if (table?.type !== "table") throw new Error("Missing table");
279 + expect(table.children.every((entry) => entry.children.length === 2)).toBe(true);
280 + expect(markdownMathRanges(source, tree)).toEqual([]);
281 + if (literal.startsWith("[a](https://example.com/$x)")) {
282 + expect(collect(tree).find((node) => node.type === "link")).toMatchObject({
283 + url: "https://example.com/$x",
284 + });
285 + }
286 }
293 - }
294 - });
287 + },
288 + );
289
290 it("retains multiline math after a prose pipe outside tables", () => {
291 const source = "a | b: \\(x\n+y\\)";
@@ -326,7 +320,7 @@ describe("math in GFM tables", () => {
320 ]);
321 expect(JSON.stringify(tree)).not.toMatch(/[\uE000-\uF8FF]/);
322 });
329 - it.each(["\\(\\frac{1}{|x|}\\)", "$$|x|$$", "$|x|$", "\\[|x|\\]"])(
323 + it.each(["\\(\\frac{1}{|x|}\\)", "$$|x|$$", "$|x|$"])(
324 "keeps pipes inside %s in one cell and preserves source offsets",
325 (formula) => {
326 const source = `| Name | Value |\n| --- | --- |\n| x | ${formula} |\n\n- [ ] next`;
packages/shared/src/nodeSqliteClient.test.ts
+1
@@ -202,6 +202,7 @@ it.effect("lets the writer commit while a read-only transaction is open", () =>
202 ),
203 );
204
205 +// regression: #19226 read-only transactions run on the separate reader connection
206 it.effect("rejects a write in a read-only transaction", () =>
207 withReaderClient((sql) =>
208 Effect.gen(function* () {
packages/shared/src/orchestrationTiming.test.ts
+1 -1
@@ -100,7 +100,7 @@ describe("deriveSubagentElapsedMs", () => {
100 const startedAt = "2026-09-21T12:00:00.000Z";
101 const completedAt = "2026-09-21T12:00:10.000Z";
102 const now = Date.parse("2026-09-21T13:00:00.000Z");
103 - it.each(["idle", "completed", "failed", "cancelled", "interrupted"] as const)(
103 + it.each(["idle", "completed", "failed"] as const)(
104 "does not count the age of %s work with unknown completion timing",
105 (status) => {
106 expect(deriveSubagentElapsedMs({ status, startedAt, completedAt: null }, now)).toBeNull();
packages/shared/src/orchestrationV2PendingBackgroundWork.test.ts
-17
@@ -139,23 +139,6 @@ describe("derivePendingBackgroundWork", () => {
139 ]);
140 });
141
142 - it("returns the provider-thread roster after settlement", () => {
143 - const tasks = derivePendingBackgroundWork({
144 - latestRun: { id: "run-1" as never, ordinal: 1, status: "completed" },
145 - providerThreads: [
146 - {
147 - id: "pt-1" as never,
148 - pendingBackgroundTasks: [
149 - { taskId: "bg-1", description: "Run Codex review", kind: "command" },
150 - ],
151 - },
152 - ],
153 - turnItems: [],
154 - activeProviderThreadId: "pt-1",
155 - });
156 - expect(tasks).toEqual([{ taskId: "bg-1", description: "Run Codex review", kind: "command" }]);
157 - });
158 -
142 it("includes nonterminal turn items and excludes completed ones", () => {
143 const tasks = derivePendingBackgroundWork({
144 latestRun: { id: "run-1" as never, ordinal: 1, status: "completed" },
packages/shared/src/orchestrationV2Timeline.test.ts
-11
@@ -64,17 +64,6 @@ describe.each([
64 ).toBe(false);
65 });
66
67 - it("keeps queued user messages while their run is queued", () => {
68 - expect(
69 - isVisible({
70 - item: { type: "user_message", inputIntent: "queued_turn", runId, nodeId },
71 - runs: [{ id: runId, status: "queued" }],
72 - attempts: [],
73 - items: [{ type: "user_message", inputIntent: "queued_turn", runId, nodeId }],
74 - }),
75 - ).toBe(true);
76 - });
77 -
67 it("keeps non-queued user messages on cancelled runs", () => {
68 expect(
69 isVisible({
packages/shared/src/otelEnvironment.test.ts
-13
@@ -179,13 +179,6 @@ describe("OtelEnvironment", () => {
179 Unset: () => "Unset",
180 });
181 it.effect.each([
182 - {
183 - name: "headers are comma-separated pairs with percent-encoded values",
184 - env: { ...ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS: "api-key=a%20b,tenant=t3" },
185 - traces: { protocol: "http/protobuf", headers: { "api-key": "a b", tenant: "t3" } },
186 - logs: { protocol: "http/protobuf", headers: { "api-key": "a b", tenant: "t3" } },
187 - warnings: [],
188 - },
182 {
183 name: "a per-signal protocol and headers beat the generic ones",
184 env: {
@@ -244,12 +237,6 @@ describe("OtelEnvironment", () => {
237 headers: { "x-key": "otel" },
238 });
239 it.each([
247 - {
248 - name: "T3CODE_OTLP_*_URL wins over an OTEL endpoint",
249 - otel: withLogs(otelExport),
250 - t3Url: "http://t3:4318/v1/logs",
251 - expected: { url: "http://t3:4318/v1/logs", export: t3Export },
252 - },
240 {
241 name: "T3CODE_OTLP_*_URL wins over a signal the OTEL variables turned off",
242 otel: withLogs(OtelEnvironment.OtelSignal.Off()),
packages/shared/src/path.test.ts
+2 -19
@@ -8,13 +8,10 @@ import {
8 } from "./path.ts";
9
10 describe("path helpers", () => {
11 + // regression: #17923 literal colons in names are kept, not parsed as positions
12 it.each([
13 ["report:123", "/workspace", "/workspace/report:123"],
13 - ["/workspace/report:12:3", "/other", "/workspace/report:12:3"],
14 ["src/file", "C:\\Workspace\\", "C:\\Workspace\\src\\file"],
15 - ["C:/Workspace/file", "/other", "C:/Workspace/file"],
16 - ["file", "\\\\host\\share\\", "\\\\host\\share\\file"],
17 - ["file", "/", "/file"],
15 ["~/report:123", "/workspace", "~/report:123"],
16 ])("resolves literal path %s within %s", (path, root, expected) => {
17 expect(resolveWorkspaceFilePath(path, root)).toBe(expected);
@@ -41,25 +38,11 @@ describe("path helpers", () => {
38 });
39
40 describe("workspaceRelativeFilePath", () => {
41 + // regression: #9309 POSIX paths compare case-sensitively, Windows paths do not
42 it.each([
45 - ["/repo/project/src/main.ts", "/repo/project", "src/main.ts"],
46 - ["/repo/project/src/main.ts", "/repo/project/", "src/main.ts"],
47 - ["C:\\Users\\mike\\t3code\\apps\\web\\a.ts", "C:/Users/mike/t3code", "apps/web/a.ts"],
48 - ["/C:/Users/mike/t3code/apps/web/a.ts", "C:/Users/mike/t3code", "apps/web/a.ts"],
43 ["/Repo/Project/src/main.ts", "/repo/project", null],
50 - ["/tmp/case/project/probe.txt", "/tmp/case/Project", null],
51 - ["//tmp/case/project/probe.txt", "//tmp/case/Project", null],
52 - ["/tmp/case/Project/probe.txt", "/tmp/case/Project", "probe.txt"],
44 ["C:/USERS/mike/t3code/main.ts", "c:/users/MIKE/t3code", "main.ts"],
54 - ["/C:/USERS/mike/t3code/main.ts", "/c:/users/MIKE/t3code", "main.ts"],
55 - ["\\\\server\\share\\PROJECT\\main.ts", "\\\\Server\\Share\\Project", "main.ts"],
56 - ["/tmp/repo/file.ts", "/", "tmp/repo/file.ts"],
57 - ["C:/Users/MIKE/main.ts", "c:/", "Users/MIKE/main.ts"],
58 - ["\\\\server\\SHARE\\file.ts", "\\\\Server\\Share\\", "file.ts"],
59 - ["/tmp/repo/file.ts ", "/tmp/repo", "file.ts "],
60 - ["/tmp/report.ts", "/repo/project", null],
45 ["/repo/project-two/a.ts", "/repo/project", null],
62 - ["/repo/project/a.ts", undefined, null],
46 ])("relates %s to %s", (path, workspaceRoot, relativePath) => {
47 expect(workspaceRelativeFilePath(path, workspaceRoot)).toBe(relativePath);
48 });
packages/shared/src/preview.test.ts
+1 -2
@@ -26,7 +26,6 @@ describe("previewPdfAssetUrl", () => {
26 "http://localhost:6497/api/assets/token/index.html",
27 "https://example.com/paper.pdf",
28 "file:///api/assets/token/paper.pdf",
29 - "javascript:alert(1)",
29 "invalid",
30 ])("leaves non-asset documents on their browser session: %s", (url) => {
31 expect(previewPdfAssetUrl(url, "https://environment.test")).toBeNull();
@@ -45,7 +44,7 @@ describe("previewPdfAssetUrl", () => {
44 expect(previewPdfAssetUrl(source, "https://environment.test")).toBe(source);
45 });
46
48 - it.each(["127.0.0.2", "127.255.255.254", "localhost.", "[::1]", "0.0.0.0"])(
47 + it.each(["127.0.0.2", "localhost.", "[::1]"])(
48 "remaps local assets on %s through the client connection",
49 (host) => {
50 expect(
packages/shared/src/projectSettings.test.ts
+1
@@ -20,6 +20,7 @@ const projectId = ProjectId.make("project-a");
20 const otherProjectId = ProjectId.make("project-b");
21
22 describe("resolveSendEnvMode", () => {
23 + // regression: #21404 non-git projects send from the current checkout, git repos keep their mode
24 it.each(["local", "worktree"] as const)(
25 "uses local for non-git projects requesting %s",
26 (mode) => {
packages/shared/src/providerAuthReturnUrl.test.ts
-5
@@ -15,12 +15,7 @@ describe("provider auth return destinations", () => {
15 );
16 it.each([
17 "t3code://attacker/welcome",
18 - "t3code://app:123/welcome",
19 - "t3code://app/auth/callback",
20 - "t3code://user@ app/welcome",
18 "t3code://app/welcome/../evil",
19 "https://attacker.example/welcome",
23 - "file:///welcome",
24 - "javascript:alert(1)",
20 ])("rejects %s", (url) => expect(providerAuthReturnUrl(url)).toBeUndefined());
21 });
packages/shared/src/relayAuth.test.ts
-15
@@ -49,19 +49,4 @@ describe("Clerk relay auth", () => {
49 });
50 expect((pathError as Error & { cause?: unknown }).cause).toBeUndefined();
51 });
52 -
53 - it("preserves URL parser failures for decoded frontend APIs", () => {
54 - const frontendApi = "[invalid-host";
55 - const error = captureError(() =>
56 - clerkFrontendApiHostnameFromPublishableKey(clerkPublishableKey(frontendApi)),
57 - );
58 -
59 - expect(error).toBeInstanceOf(ClerkPublishableKeyFrontendApiError);
60 - expect(error).toMatchObject({
61 - keyPrefix: "pk_test",
62 - frontendApi,
63 - reason: "invalid-url",
64 - });
65 - expect((error as ClerkPublishableKeyFrontendApiError).cause).toBeInstanceOf(Error);
66 - });
52 });
packages/shared/src/relayJwt.test.ts
+1 -29
@@ -1,36 +1,8 @@
1 -// @effect-diagnostics-next-line nodeBuiltinImport:off -- Effect's Crypto has no generateKeyPairSync.
2 -import * as NodeCrypto from "node:crypto";
3 -
1 import { describe, expect, it } from "@effect/vitest";
5 -import * as Effect from "effect/Effect";
2
7 -import { RelayJwtError, verifyRelayJwt } from "./relayJwt.ts";
3 +import { RelayJwtError } from "./relayJwt.ts";
4
5 describe("relayJwt", () => {
10 - it.effect("preserves verification request context and the JOSE cause", () =>
11 - Effect.gen(function* () {
12 - const keyPair = NodeCrypto.generateKeyPairSync("ed25519", {
13 - publicKeyEncoding: { format: "pem", type: "spki" },
14 - privateKeyEncoding: { format: "pem", type: "pkcs8" },
15 - });
16 - const error = yield* verifyRelayJwt({
17 - publicKey: keyPair.publicKey,
18 - token: "not-a-jwt",
19 - typ: "test-verify+jwt",
20 - issuer: "https://issuer.example.test",
21 - audience: "test-audience",
22 - nowEpochSeconds: 100,
23 - }).pipe(Effect.flip);
24 -
25 - expect(error.operation).toBe("verify");
26 - expect(error.typ).toBe("test-verify+jwt");
27 - expect(error.issuer).toBe("https://issuer.example.test");
28 - expect(error.audience).toBe("test-audience");
29 - expect(error.cause).toBeInstanceOf(Error);
30 - expect(error.message).toBe('Failed to verify relay JWT of type "test-verify+jwt".');
31 - }),
32 - );
33 -
6 it("extracts stable diagnostic codes without copying cause text into the error message", () => {
7 const error = new RelayJwtError({
8 operation: "verify",
packages/shared/src/relayUrl.test.ts
-3
@@ -16,9 +16,6 @@ describe("normalizeSecureRelayUrl", () => {
16 "http://relay.example.test",
17 "https://user:password@relay.example.test",
18 "https://relay.example.test/path",
19 - "https://relay.example.test?query=value",
20 - "https://relay.example.test#fragment",
21 - "not a url",
19 ])("rejects unsafe relay URL %s", (value) => {
20 expect(normalizeSecureRelayUrl(value)).toBeNull();
21 expect(isSecureRelayUrl(value)).toBe(false);
packages/shared/src/remote.test.ts
-45
@@ -1,7 +1,6 @@
1 import { describe, expect, it } from "vite-plus/test";
2
3 import {
4 - RemoteBackendUrlInvalidError,
4 RemoteBackendUrlMissingError,
5 RemotePairingTokenMissingError,
6 RemotePairingUrlInvalidError,
@@ -72,18 +71,6 @@ describe("remote", () => {
71 });
72 });
73
75 - it("normalizes a protocol-relative host from a hosted pairing link", () => {
76 - expect(
77 - resolveRemotePairingTarget({
78 - pairingUrl: "https://app.t3.codes/pair?host=%2F%2Fremote.example.com#token=pairing-token",
79 - }),
80 - ).toEqual({
81 - credential: "pairing-token",
82 - httpBaseUrl: "https://remote.example.com/",
83 - wsBaseUrl: "wss://remote.example.com/",
84 - });
85 - });
86 -
74 it("collapses extra leading slashes instead of producing an empty host", () => {
75 expect(
76 resolveRemotePairingTarget({
@@ -138,38 +125,6 @@ describe("remote", () => {
125 expect((pairingUrlError as RemotePairingUrlInvalidError).cause).toBeUndefined();
126 });
127
141 - it("rejects unsupported hosted pairing backend protocols", () => {
142 - let hostError: unknown;
143 - try {
144 - resolveRemotePairingTarget({
145 - pairingUrl:
146 - "https://app.t3.codes/pair?host=ftp%3A%2F%2Fremote.example.com#token=pairing-token",
147 - });
148 - } catch (cause) {
149 - hostError = cause;
150 - }
151 -
152 - expect(hostError).toBeInstanceOf(RemoteBackendUrlInvalidError);
153 - expect(hostError).toMatchObject({ source: "hosted-pairing-host", protocol: "ftp:" });
154 - expect((hostError as RemoteBackendUrlInvalidError).cause).toBeUndefined();
155 - });
156 -
157 - it("rejects unsupported direct host protocols", () => {
158 - let hostError: unknown;
159 - try {
160 - resolveRemotePairingTarget({
161 - host: "ftp://remote.example.com",
162 - pairingCode: "pairing-token",
163 - });
164 - } catch (cause) {
165 - hostError = cause;
166 - }
167 -
168 - expect(hostError).toBeInstanceOf(RemoteBackendUrlInvalidError);
169 - expect(hostError).toMatchObject({ source: "direct-host", protocol: "ftp:" });
170 - expect((hostError as RemoteBackendUrlInvalidError).cause).toBeUndefined();
171 - });
172 -
128 it("uses distinct structural errors for missing pairing inputs", () => {
129 expect(() => resolveRemotePairingTarget({})).toThrowError(RemoteBackendUrlMissingError);
130 expect(() =>
packages/shared/src/schemaJson.test.ts
-40
@@ -66,25 +66,6 @@ Done.`),
66 }
67 });
68
69 - it("preserves nested paths reported by schema filters", () => {
70 - const decode = decodeJsonResult(
71 - Schema.String.check(
72 - Schema.makeFilter(() => ({
73 - path: ["session", "token"],
74 - issue: "credential is invalid",
75 - })),
76 - ),
77 - );
78 - const decoded = decode('"credential=secret-value"');
79 -
80 - expect(Result.isFailure(decoded)).toBe(true);
81 - if (Result.isFailure(decoded)) {
82 - const diagnostic = formatSchemaError(decoded.failure);
83 - expect(diagnostic).toBe('Invalid value\n at ["session"]["token"]');
84 - expect(diagnostic).not.toContain("credential=secret-value");
85 - }
86 - });
87 -
69 it("does not expose malformed lenient JSON input in diagnostics", () => {
70 const decode = Schema.decodeUnknownExit(fromLenientJson(Schema.Unknown));
71 const exit = decode('{"token":"credential=secret-value",,}');
@@ -120,25 +101,4 @@ Done.`),
101 expect(diagnostic.match(/Invalid type/g)).toHaveLength(8);
102 expect(diagnostic).toContain("... and 2 more issue(s)");
103 });
123 -
124 - it("retains the omitted issue count when bounding long diagnostics", () => {
125 - const longPath = Array.from({ length: 16 }, (_, index) => `${index}-${"segment".repeat(16)}`);
126 - const decode = decodeJsonResult(
127 - Schema.String.check(
128 - Schema.makeFilter(() => ({ path: longPath, issue: "credential is invalid" })),
129 - ),
130 - );
131 - const failures: Array<Cause.Cause<Schema.SchemaError>> = [];
132 - for (let index = 0; index < 10; index += 1) {
133 - const decoded = decode(`"credential=secret-value-${index}"`);
134 - if (Result.isFailure(decoded)) {
135 - failures.push(decoded.failure);
136 - }
137 - }
138 -
139 - const cause = Cause.fromReasons(failures.flatMap((cause) => cause.reasons));
140 - const diagnostic = formatSchemaError(cause);
141 - expect(diagnostic.length).toBeLessThanOrEqual(2_048);
142 - expect(diagnostic.endsWith("\n... and 2 more issue(s)")).toBe(true);
143 - });
104 });
packages/shared/src/serverSettings.test.ts
-24
@@ -85,15 +85,6 @@ describe("serverSettings helpers", () => {
85 tokens: {},
86 });
87 });
88 - it("replaces SSH host lists when saving, editing, and removing hosts", () => {
89 - const host = { kind: "ssh" as const, id: "mini", label: "Mac mini", target: "mini" };
90 - const saved = applyServerSettingsPatch(DEFAULT_SERVER_SETTINGS, { deviceHosts: [host] });
91 - expect(saved.deviceHosts).toEqual([host]);
92 - const replacement = { ...host, target: "other-mini" };
93 - const edited = applyServerSettingsPatch(saved, { deviceHosts: [replacement] });
94 - expect(edited.deviceHosts).toEqual([replacement]);
95 - expect(applyServerSettingsPatch(edited, { deviceHosts: [] }).deviceHosts).toEqual([]);
96 - });
88
89 it("inherits actions, preserves existing actions, and supports empty overrides and reset", () => {
90 const project = { id: ProjectId.make("project-actions"), scripts: [] };
@@ -752,21 +743,6 @@ describe("serverSettings helpers", () => {
743 },
744 });
745 });
755 -
756 - it("ignores overrides attached to a concrete background profile", () => {
757 - const resolved = resolveServerBackgroundActivitySettings({
758 - ...DEFAULT_SERVER_SETTINGS,
759 - backgroundActivity: {
760 - schemaVersion: 1,
761 - profile: "balanced",
762 - overrides: {
763 - pauseWhenOnBattery: true,
764 - },
765 - },
766 - });
767 -
768 - expect(resolved.pauseWhenOnBattery).toBe(false);
769 - });
746 });
747
748 describe("worktreesDirectory", () => {
packages/shared/src/telemetryId.test.ts
-8
@@ -3,14 +3,6 @@ import { describe, expect, it } from "vite-plus/test";
3 import { hashTelemetryId, isTelemetryIdHash } from "./telemetryId.ts";
4
5 describe("telemetry ids", () => {
6 - // The server hashes the linked Connect account and clients hash the signed-in
7 - // one. Both must give plain SHA-256 hex, or the two never match.
8 - it("is the SHA-256 hex digest of the id", () => {
9 - expect(hashTelemetryId("user_connect")).toBe(
10 - "7938265611170ce1ba814a67f5a51bcff2b9b46c5597da465e6f098f2217717a",
11 - );
12 - });
13 -
6 it("accepts only hashes, never a raw id", () => {
7 expect(isTelemetryIdHash(hashTelemetryId("user_connect"))).toBe(true);
8 expect(isTelemetryIdHash("user_connect")).toBe(false);
packages/shared/src/usageLimits.test.ts
+1
@@ -720,6 +720,7 @@ describe("pooled account columns", () => {
720 row.columns.map((member) => (member.window ? member.account.key : null)),
721 );
722
723 + // regression: #20349 sessions stay visible while the weekly quota is exhausted
724 it.each([
725 ["claudeAgent", "13:00", 40, "14:00", 100],
726 ["codex", "14:00", 100, "14:00", 100],
packages/shared/src/usageMerge.test.ts
-20
@@ -113,26 +113,6 @@ describe("mergeUsage", () => {
113 expect(merged.duplicateSources).toHaveLength(1);
114 });
115
116 - it("sums environments that read different transcript directories", () => {
117 - const merged = mergeUsage(
118 - [
119 - environment(
120 - "env-a",
121 - summary([bucket()], [{ provider: "claude", hostId: "mac", homePath: "/a/.claude" }]),
122 - ),
123 - environment(
124 - "env-b",
125 - summary([bucket()], [{ provider: "claude", hostId: "linux", homePath: "/b/.claude" }]),
126 - ),
127 - ],
128 - USAGE_CONTRACT_VERSION,
129 - );
130 -
131 - expect(merged.costUsd).toBe(20);
132 - expect(merged.records).toBe(10);
133 - expect(merged.duplicateSources).toHaveLength(0);
134 - });
135 -
116 it("counts a shared transcript directory once", () => {
117 const shared = { provider: "claude" as const, hostId: "mac", homePath: "/home/theo/.claude" };
118 const merged = mergeUsage(
packages/source-control-azure-devops/src/server/AzureDevOpsCli.test.ts
+1 -82
@@ -1,5 +1,5 @@
1 import * as NodeServices from "@effect/platform-node/NodeServices";
2 -import { assert, it, afterEach, describe, expect, vi } from "@effect/vitest";
2 +import { assert, it, afterEach, describe, vi } from "@effect/vitest";
3 import * as Effect from "effect/Effect";
4 import * as Layer from "effect/Layer";
5 import * as Option from "effect/Option";
@@ -152,66 +152,6 @@ describe("AzureDevOpsCli.layer", () => {
152 }).pipe(Effect.provide(layer)),
153 );
154
155 - it.effect("lists pull requests with Azure status and source branch arguments", () =>
156 - Effect.gen(function* () {
157 - mockRun.mockReturnValueOnce(
158 - Effect.succeed(
159 - processOutput(
160 - JSON.stringify([
161 - {
162 - pullRequestId: 7,
163 - title: "Merged work",
164 - sourceRefName: "refs/heads/feature/merged",
165 - targetRefName: "refs/heads/main",
166 - status: "completed",
167 - closedDate: "2026-01-03T00:00:00.000Z",
168 - _links: {
169 - web: {
170 - href: "https://dev.azure.com/acme/project/_git/repo/pullrequest/7",
171 - },
172 - },
173 - },
174 - ]),
175 - ),
176 - ),
177 - );
178 -
179 - const az = yield* AzureDevOpsCli.AzureDevOpsCli;
180 - const result = yield* az.listPullRequests({
181 - cwd: "/repo",
182 - headSelector: "origin:feature/merged",
183 - state: "merged",
184 - limit: 10,
185 - });
186 -
187 - assert.strictEqual(result[0]?.state, "merged");
188 - assert.strictEqual(result[0]?.mergedAt, "2026-01-03T00:00:00.000Z");
189 - assert.strictEqual(result[0]?.closedAt, null);
190 - expect(mockRun).toHaveBeenCalledWith({
191 - operation: "AzureDevOpsCli.execute",
192 - command: "az",
193 - args: [
194 - "repos",
195 - "pr",
196 - "list",
197 - "--detect",
198 - "true",
199 - "--source-branch",
200 - "feature/merged",
201 - "--status",
202 - "completed",
203 - "--top",
204 - "10",
205 - "--only-show-errors",
206 - "--output",
207 - "json",
208 - ],
209 - cwd: "/repo",
210 - timeoutMs: 30_000,
211 - });
212 - }).pipe(Effect.provide(layer)),
213 - );
214 -
155 it.effect("reads repository clone URLs", () =>
156 Effect.gen(function* () {
157 mockRun.mockReturnValueOnce(
@@ -297,27 +237,6 @@ describe("AzureDevOpsCli.layer", () => {
237 }).pipe(Effect.provide(layer)),
238 );
239
300 - it.effect("keeps invalid pull request output diagnostics structured", () =>
301 - Effect.gen(function* () {
302 - mockRun.mockReturnValueOnce(Effect.succeed(processOutput("not-json")));
303 -
304 - const az = yield* AzureDevOpsCli.AzureDevOpsCli;
305 - const error = yield* az.getPullRequest({ cwd: "/repo", reference: "42" }).pipe(Effect.flip);
306 -
307 - assert.instanceOf(error, AzureDevOpsCli.AzureDevOpsPullRequestDecodeError);
308 - assert.strictEqual(error.operation, "getPullRequest");
309 - assert.strictEqual(error.command, "az");
310 - assert.strictEqual(error.cwd, "/repo");
311 - assert.strictEqual(error.outputLength, 8);
312 - assert.strictEqual(error.detail, "Azure DevOps CLI returned invalid pull request JSON.");
313 - assert.exists(error.cause);
314 - assert.strictEqual(
315 - error.message,
316 - "Azure DevOps CLI failed in getPullRequest: Azure DevOps CLI returned invalid pull request JSON.",
317 - );
318 - }).pipe(Effect.provide(layer)),
319 - );
320 -
240 it.effect("preserves rate-limit failures as a distinct error", () =>
241 Effect.gen(function* () {
242 const cause = new VcsProcessExitError({
packages/source-control-azure-devops/src/server/AzureDevOpsPullRequestCli.test.ts
-36
@@ -201,26 +201,6 @@ layer("AzureDevOpsPullRequestCli.layer", (it) => {
201 }),
202 );
203
204 - it.effect("reports truncation from the extra row", () =>
205 - Effect.gen(function* () {
206 - mockedExecute.mockReturnValueOnce(Effect.succeed(output(pullRequests(11, 1))));
207 - const cli = yield* AzureDevOpsPullRequestCli.AzureDevOpsPullRequestCli;
208 -
209 - const batch = yield* cli.listPullRequests({
210 - cwd: "/w",
211 - repository: "web",
212 - state: "open",
213 - involvement: "all",
214 - viewer: "bilal@acme.dev",
215 - limit: 10,
216 - });
217 -
218 - assert.strictEqual(batch.items.length, 10);
219 - assert.isTrue(batch.truncated);
220 - assert.strictEqual(batch.cursorAdvance, 10);
221 - }),
222 - );
223 -
204 it.effect("advances by malformed raw rows and keeps reading until the page is full", () =>
205 Effect.gen(function* () {
206 mockedExecute
@@ -849,22 +829,6 @@ layer("AzureDevOpsPullRequestCli.layer", (it) => {
829 }),
830 );
831
852 - it.effect("asks for a file by Azure's own spelling of its path", () =>
853 - Effect.gen(function* () {
854 - mockedExecute.mockReturnValueOnce(Effect.succeed(output(json({ content: "const a = 1;" }))));
855 - const cli = yield* AzureDevOpsPullRequestCli.AzureDevOpsPullRequestCli;
856 -
857 - yield* cli.readItemContent({
858 - cwd: "/w",
859 - location: { project: "platform", repository: "web" },
860 - path: "src/app.ts",
861 - commit: "a".repeat(40),
862 - });
863 -
864 - expect(argsOfCall(0)).toContain("path=/src/app.ts");
865 - }),
866 - );
867 -
832 it.effect("reports a pull request it cannot place as its own outcome", () =>
833 Effect.gen(function* () {
834 mockedExecute.mockReturnValueOnce(
packages/source-control-azure-devops/src/server/azureDevOpsDiff.test.ts
-19
@@ -196,25 +196,6 @@ describe("azureDevOpsFilePatch", () => {
196 });
197
198 describe("a file Azure names something a patch header cannot carry plainly", () => {
199 - it("writes each side as git's quoted form, the side letter inside the quotes", () => {
200 - const patch = azureDevOpsFilePatch({
201 - change: change({ path: "notes\treadme.md", oldPath: "notes\treadme.md" }),
202 - texts: texts("one\n", "two\n"),
203 - });
204 -
205 - expect(patch.section).toBe(
206 - [
207 - 'diff --git "a/notes\\treadme.md" "b/notes\\treadme.md"',
208 - '--- "a/notes\\treadme.md"',
209 - '+++ "b/notes\\treadme.md"',
210 - "@@ -1 +1 @@",
211 - "-one",
212 - "+two",
213 - "",
214 - ].join("\n"),
215 - );
216 - });
217 -
199 it("quotes the names a rename states, which carry no side letter", () => {
200 const patch = azureDevOpsFilePatch({
201 change: change({
packages/source-control-azure-devops/src/server/azureDevOpsPullRequestJson.test.ts
-27
@@ -63,9 +63,7 @@ describe("decodePullRequestListJson", () => {
63 });
64
65 it.each([
66 - ["active", "open"],
66 ["completed", "merged"],
68 - ["abandoned", "closed"],
67 ["something new", "open"],
68 ])("reads the %s status as %s", (status, expected) => {
69 const batch = expectSuccess(decodePullRequestListJson(asJson([pullRequest({ status })])));
@@ -76,9 +74,7 @@ describe("decodePullRequestListJson", () => {
74 it.each([
75 ["succeeded", "mergeable"],
76 ["conflicts", "conflicting"],
79 - ["rejectedByPolicy", "conflicting"],
77 ["queued", "unknown"],
81 - ["notSet", "unknown"],
78 ])("reads the %s merge status as %s", (mergeStatus, expected) => {
79 const batch = expectSuccess(decodePullRequestListJson(asJson([pullRequest({ mergeStatus })])));
80
@@ -407,19 +403,6 @@ describe("decodeIterationChangesJson", () => {
403 expect(page.changes.map((change) => change.path)).toEqual(["docs/page.md"]);
404 });
405
410 - it("carries where the next page of a long change starts", () => {
411 - const page = expectSuccess(
412 - decodeIterationChangesJson(
413 - asJson({
414 - changeEntries: [{ changeType: "add", item: { path: "/DEMO.md", objectId: "ec00" } }],
415 - nextSkip: 2000,
416 - }),
417 - ),
418 - );
419 -
420 - expect(page.nextSkip).toBe(2000);
421 - });
422 -
406 it("reads where a rename came from out of either of the two places Azure names it", () => {
407 const page = expectSuccess(
408 decodeIterationChangesJson(
@@ -446,16 +429,6 @@ describe("decodeItemContentJson", () => {
429 isBinary: false,
430 });
431 });
449 -
450 - it("keeps Azure's own word that a file is binary", () => {
451 - expect(
452 - expectSuccess(
453 - decodeItemContentJson(
454 - asJson({ path: "/logo.png", content: "b2xk", contentMetadata: { isBinary: true } }),
455 - ),
456 - ),
457 - ).toEqual({ contents: "b2xk", isBinary: true });
458 - });
432 });
433
434 /**
packages/source-control-bitbucket/src/server/BitbucketPullRequestApi.test.ts
-44
@@ -305,21 +305,6 @@ layer("BitbucketPullRequestApi.layer", (it) => {
305 }),
306 );
307
308 - it.effect("rewrites a title alone, without touching anything else", () =>
309 - Effect.gen(function* () {
310 - mockedRequest.mockReturnValue(Effect.succeed(response("{}")));
311 - const api = yield* BitbucketPullRequestApi.BitbucketPullRequestApi;
312 -
313 - yield* api.updateChangeRequest({ repository: "acme/web", number: 7, title: "A new title" });
314 -
315 - const call = callAt(0);
316 - expect(call.method).toBe("PUT");
317 - expect(call.url).toBe("/repositories/acme/web/pullrequests/7");
318 - // Bitbucket's PUT is a partial update, so a field left out of the body is left as it was.
319 - expect(JSON.parse(call.body ?? "")).toEqual({ title: "A new title" });
320 - }),
321 - );
322 -
308 it.effect("asks for the time a pull request closed, which Bitbucket leaves out by default", () =>
309 Effect.gen(function* () {
310 mockedRequest.mockReturnValueOnce(
@@ -421,35 +406,6 @@ layer("BitbucketPullRequestApi.layer", (it) => {
406 }),
407 );
408
424 - it.effect("writes a review's line comments, its summary, then its verdict", () =>
425 - Effect.gen(function* () {
426 - mockedRequest.mockReturnValue(Effect.succeed(response("{}")));
427 - const api = yield* BitbucketPullRequestApi.BitbucketPullRequestApi;
428 -
429 - yield* api.submitReview({
430 - repository: "acme/web",
431 - number: 7,
432 - verdict: "request-changes",
433 - body: "Two things.",
434 - comments: [
435 - {
436 - path: "src/a.ts",
437 - position: { kind: "deleted", oldLine: 12 },
438 - body: "why remove?",
439 - },
440 - ],
441 - });
442 -
443 - expect(callAt(0).url).toContain("/pullrequests/7/comments");
444 - expect(JSON.parse(callAt(0).body ?? "")).toEqual({
445 - content: { raw: "why remove?" },
446 - inline: { path: "src/a.ts", from: 12 },
447 - });
448 - expect(callAt(1).url).toContain("/pullrequests/7/comments");
449 - expect(callAt(2).url).toContain("/pullrequests/7/request-changes");
450 - }),
451 - );
452 -
409 it.effect("asks for the credentials' permission on this repository, and nobody else's", () =>
410 Effect.gen(function* () {
411 mockedRequest.mockReturnValue(
packages/source-control-bitbucket/src/server/BitbucketSourceControlProvider.test.ts deleted
-64
@@ -1,64 +0,0 @@
1 -import { SourceControlProviderKind } from "@t3tools/contracts";
2 -import { assert, it } from "@effect/vitest";
3 -import * as Effect from "effect/Effect";
4 -import * as Layer from "effect/Layer";
5 -import * as Option from "effect/Option";
6 -import * as Schema from "effect/Schema";
7 -
8 -import * as BitbucketApi from "./BitbucketApi.ts";
9 -import * as BitbucketSourceControlProvider from "./BitbucketSourceControlProvider.ts";
10 -import {
11 - BitbucketPullRequestSchema,
12 - normalizeBitbucketPullRequestRecord,
13 -} from "./bitbucketPullRequests.ts";
14 -
15 -const decodePullRequest = Schema.decodeEffect(BitbucketPullRequestSchema);
16 -
17 -function makeProvider(bitbucket: Partial<BitbucketApi.BitbucketApi["Service"]>) {
18 - return BitbucketSourceControlProvider.make.pipe(
19 - Effect.provide(Layer.mock(BitbucketApi.BitbucketApi)(bitbucket)),
20 - );
21 -}
22 -
23 -it.effect("maps Bitbucket PR summaries into provider-neutral change requests", () =>
24 - Effect.gen(function* () {
25 - const provider = yield* makeProvider({
26 - getPullRequest: () =>
27 - decodePullRequest({
28 - id: 42,
29 - title: "Add Bitbucket provider",
30 - links: { html: { href: "https://bitbucket.org/pingdotgg/t3code/pull-requests/42" } },
31 - source: {
32 - branch: { name: "feature/source-control" },
33 - commit: { hash: "a".repeat(40) },
34 - repository: { full_name: "fork/t3code" },
35 - },
36 - destination: {
37 - branch: { name: "main" },
38 - repository: { full_name: "pingdotgg/t3code" },
39 - },
40 - state: "OPEN",
41 - }).pipe(Effect.orDie, Effect.map(normalizeBitbucketPullRequestRecord)),
42 - });
43 -
44 - const changeRequest = yield* provider.getChangeRequest({
45 - cwd: "/repo",
46 - reference: "42",
47 - });
48 -
49 - assert.deepStrictEqual(changeRequest, {
50 - provider: SourceControlProviderKind.make("bitbucket"),
51 - number: 42,
52 - title: "Add Bitbucket provider",
53 - url: "https://bitbucket.org/pingdotgg/t3code/pull-requests/42",
54 - baseRefName: "main",
55 - headRefName: "feature/source-control",
56 - headSha: "a".repeat(40),
57 - state: "open",
58 - updatedAt: Option.none(),
59 - isCrossRepository: true,
60 - headRepositoryNameWithOwner: "fork/t3code",
61 - headRepositoryOwnerLogin: "fork",
62 - });
63 - }),
64 -);
packages/source-control-bitbucket/src/server/bitbucketPullRequestJson.test.ts
+1 -4
@@ -75,8 +75,6 @@ describe("decodePullRequestPageJson", () => {
75 it.each([
76 ["MERGED", "merged"],
77 ["DECLINED", "closed"],
78 - ["SUPERSEDED", "closed"],
79 - ["OPEN", "open"],
78 ["something new", "open"],
79 ])("reads the %s state as %s", (state, expected) => {
80 const decoded = expectSuccess(decodePullRequestPageJson(page([pullRequest({ state })])));
@@ -94,6 +92,7 @@ describe("decodePullRequestPageJson", () => {
92 });
93
94 describe("decodePullRequestJson", () => {
95 + // regression: #18402 a pull request with no head commit hash still decodes, headSha null
96 it.each([
97 { metadata: "absent commit", commit: undefined },
98 { metadata: "null commit", commit: null },
@@ -271,8 +270,6 @@ describe("decodeStatusesJson", () => {
270 it.each([
271 ["SUCCESSFUL", "success"],
272 ["FAILED", "failure"],
274 - ["INPROGRESS", "pending"],
275 - ["STOPPED", "cancelled"],
273 ["something new", "neutral"],
274 ])("reads the %s build state as %s", (state, expected) => {
275 const decoded = expectSuccess(decodeStatusesJson(page([{ name: "Pipeline", state }])));
packages/source-control-core/src/server/pullRequestChecks.test.ts
+1 -26
@@ -20,17 +20,11 @@ function entry(
20 }
21
22 describe("dedupeChecks", () => {
23 + // regression: #20094 runs were compared as timestamp text, picking the older run
24 it.each([
24 - ["2026-10-16T12:00:00Z", "2026-10-16T12:00:00.500Z"],
25 ["2026-10-16T12:00:00+02:00", "2026-10-16T10:30:00Z"],
26 - ["2026-10-16T12:00:00.0001Z", "2026-10-16T12:00:00.0002Z"],
27 - ["2026-10-16T12:00:00.0001z", "2026-10-16T12:00:00.0002z"],
26 ["2026-10-16T12:00:00.00009Z", "2026-10-16T12:00:00.0001Z"],
29 - ["2024-02-28T23:59:59Z", "2024-02-29T00:00:00.0001Z"],
30 - ["2000-02-28T23:59:59Z", "2000-02-29T00:00:00Z"],
27 ["2024-03-01T01:00:00Z", "2024-02-29T23:30:00-02:00"],
32 - ["2026-10-16t12:00:00z", "2026-10-16t12:00:00.0001z"],
33 - ["+010000-01-01T00:00:00Z", "+010000-01-01T00:00:00.0001Z"],
28 ])("keeps the newer instant between %s and %s in either listing order", (older, newer) => {
29 const oldRun = entry("build", "success", { at: older });
30 const newRun = entry("build", "failure", { at: newer });
@@ -44,7 +38,6 @@ describe("dedupeChecks", () => {
38 });
39
40 it.each([
47 - ["2026-10-16T12:00:00Z", "2026-10-16T12:00:00.000Z"],
41 ["2026-10-16T12:00:00Z", "2026-10-16T14:00:00+02:00"],
42 ["2026-10-16T24:00:00.000Z", "2026-10-17T00:00:00Z"],
43 ["2026-10-16T12:00Z", "2026-10-16T12:00:00Z"],
@@ -61,23 +54,6 @@ describe("dedupeChecks", () => {
54 expect([forward[0]?.status, reversed[0]?.status]).toEqual(["failure", "failure"]);
55 });
56
64 - it("keeps the newest run of a check the host listed twice", () => {
65 - const checks = dedupeChecks([
66 - entry("Prepare PR size config", "success", {
67 - workflowName: "PR Size",
68 - at: "2026-08-11T16:06:25Z",
69 - }),
70 - entry("Prepare PR size config", "pending", {
71 - workflowName: "PR Size",
72 - at: "2026-08-11T17:01:04Z",
73 - }),
74 - ]);
75 -
76 - expect(checks.map((check) => [check.name, check.status])).toEqual([
77 - ["Prepare PR size config", "pending"],
78 - ]);
79 - });
80 -
57 it.each([
58 ["2026-10-16", "2026-10-15T23:00:00-02:00", "success"],
59 ["2026-10-16T00:00:00", "2026-10-15T23:00:00-02:00", "success"],
@@ -96,7 +72,6 @@ describe("dedupeChecks", () => {
72
73 it.each([
74 ["2026-02-30T00:00:00Z", "2026-03-01T00:00:00Z"],
99 - ["2026-02-29T00: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) => {
packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.test.ts
+1 -4
@@ -139,10 +139,10 @@ it.effect.each([
139 ),
140 );
141
142 +// regression: #18775 a failed branch-protection read surfaces; only 403/404 are treated as no policy
143 it.effect.each([
144 ["rate limit", { reason: "rate-limit", httpStatus: 429 }, "rate-limited"],
145 ["authentication failure", { reason: "authentication", httpStatus: 401 }, "unauthenticated"],
145 - ["server failure", { httpStatus: 503 }, "failed"],
146 ["network failure", {}, "failed"],
147 ] as const)("propagates branch metadata %s", ([detail, fields, reason]) => {
148 const cause = new ForgejoCli.ForgejoCliError({ command: "fj", cwd: "/repo", detail, ...fields });
@@ -225,10 +225,7 @@ it.effect("opens Forgejo Actions check links on the pull request's server", () =
225 it.effect.each([
226 ["Ready", false, true, false, "mergeable"],
227 ["Draft", true, false, true, "unknown"],
228 - ["Blocked", false, false, false, "unknown"],
229 - ["Unchecked", false, undefined, false, "unknown"],
228 ["WIP: Legacy draft", undefined, false, true, "unknown"],
231 - ["[WIP] Legacy draft", undefined, false, true, "unknown"],
229 ["WIP: Explicitly ready", false, false, false, "unknown"],
230 ] as const)(
231 "reads Forgejo mergeability for %s (draft=%s, mergeable=%s) across list, summary and detail",
packages/source-control-gitcafe/src/server/GitCafePullRequestProvider.test.ts
-43
@@ -246,49 +246,6 @@ describe("GitCafePullRequestProvider", () => {
246 }).pipe(Effect.provide(server.layer));
247 });
248
249 - it.effect("reads the diff from the pull request's changed files", () => {
250 - const file = {
251 - path: "file.ts",
252 - oldPath: null,
253 - status: "modified",
254 - additions: 1,
255 - deletions: 1,
256 - binary: false,
257 - };
258 - const snapshot = { version: 4, headOid, comparisonBaseOid: baseOid };
259 - const server = fakeGitCafe({
260 - "GET /repos/owner/repo/pulls/7": pull,
261 - "GET /repos/owner/repo/pulls/7/changes": { ...snapshot, items: [file], next: null },
262 - "POST /repos/owner/repo/pulls/7/diff-files": {
263 - ...snapshot,
264 - items: [
265 - {
266 - ...file,
267 - hunks: [
268 - {
269 - oldStart: 1,
270 - oldLines: 1,
271 - newStart: 1,
272 - newLines: 1,
273 - lines: [
274 - { origin: "-", content: "old\n" },
275 - { origin: "+", content: "new\n" },
276 - ],
277 - },
278 - ],
279 - },
280 - ],
281 - },
282 - });
283 - return Effect.gen(function* () {
284 - const provider = yield* GitCafePullRequestProvider.make;
285 - const diff = yield* provider.getDiff(target);
286 - assert.include(diff.patch, "-old\n+new\n");
287 - assert.isNull(diff.nextCursor);
288 - assert.deepStrictEqual(server.writes(), ["POST /repos/owner/repo/pulls/7/diff-files"]);
289 - }).pipe(Effect.provide(server.layer));
290 - });
291 -
249 it.effect("resolves a thread through its root at the root's version", () => {
250 const server = fakeGitCafe({
251 "GET /repos/owner/repo/pulls/7/comments": { items: [root], next: null },
packages/source-control-gitcafe/src/server/GitCafeSourceControlProvider.test.ts
-2
@@ -198,8 +198,6 @@ describe("GitCafeSourceControlProvider", () => {
198
199 it.effect.each([
200 ["no context", undefined, "https://git.cafe/fork/project.git"],
201 - ["an HTTPS remote", "https://git.cafe/team/project.git", "https://git.cafe/fork/project.git"],
202 - ["an SSH remote", "ssh@git.cafe:team/project.git", "ssh@git.cafe:fork/project.git"],
201 ["an ssh:// remote", "ssh://ssh@git.cafe/team/project.git", "ssh@git.cafe:fork/project.git"],
202 [
203 "an HTTPS remote with a user",
packages/source-control-gitcafe/src/server/gitCafeHosts.test.ts
-5
@@ -13,11 +13,8 @@ describe("gitCafeHosts", () => {
13 });
14
15 it.each([
16 - ["https://git.cafe/team/project.git", "git.cafe"],
17 - ["https://git.cafe/team/project", "git.cafe"],
16 ["https://staging.git.cafe/team/project.git/", "staging.git.cafe"],
17 ["ssh@git.cafe:team/project.git", "git.cafe"],
20 - ["git@staging.git.cafe:team/project.git", "staging.git.cafe"],
18 ["ssh://git@git.cafe/team/project.git", "git.cafe"],
19 ])("reads the host and repository of %s", (url, host) => {
20 assert.deepStrictEqual(GitCafeHosts.parseGitCafeRemote(url), {
@@ -27,10 +24,8 @@ describe("gitCafeHosts", () => {
24 });
25
26 it.each([
30 - "https://github.com/team/project.git",
27 "https://evil.git.cafe/team/project.git",
28 "https://git.cafe/team/nested/project.git",
33 - "https://git.cafe/team",
29 "team/project",
30 ])("is not a GitCafe repository: %s", (url) => {
31 assert.isNull(GitCafeHosts.parseGitCafeRemote(url));
packages/source-control-github/src/server/GitHubPullRequestApi.test.ts
+2 -314
@@ -1200,31 +1200,6 @@ layer("GitHubPullRequestApi.layer", (it) => {
1200 }),
1201 );
1202
1203 - it.effect("excludes merged pull requests from the Closed tab", () =>
1204 - Effect.gen(function* () {
1205 - mockedExecute.mockImplementation((call) =>
1206 - Effect.succeed(
1207 - call.kind === "graphql" && call.operationName === "PullRequestList"
1208 - ? emptyList()
1209 - : emptySearch(),
1210 - ),
1211 - );
1212 - const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1213 -
1214 - yield* cli.listPullRequests({
1215 - cwd: "/w",
1216 - repository: "acme/web",
1217 - host: "github.com",
1218 - state: "closed",
1219 - involvement: "all",
1220 - viewer: "bilal",
1221 - limit: 10,
1222 - });
1223 -
1224 - expect(searchOfCall(0)).toBe("is:pr is:closed is:unmerged sort:updated-desc repo:acme/web");
1225 - }),
1226 - );
1227 -
1203 it.effect("carries every repository and every qualifier into one search", () =>
1204 Effect.gen(function* () {
1205 mockedExecute.mockReturnValue(Effect.succeed(searchPage([])));
@@ -1523,34 +1498,6 @@ layer("GitHubPullRequestApi.layer", (it) => {
1498 }),
1499 );
1500
1526 - it.effect("joins a search onto the tab's own qualifiers instead of replacing them", () =>
1527 - Effect.gen(function* () {
1528 - mockedExecute.mockImplementation((call) =>
1529 - Effect.succeed(
1530 - call.kind === "graphql" && call.operationName === "PullRequestList"
1531 - ? emptyList()
1532 - : emptySearch(),
1533 - ),
1534 - );
1535 - const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1536 -
1537 - yield* cli.listPullRequests({
1538 - cwd: "/w",
1539 - repository: "acme/web",
1540 - host: "github.com",
1541 - state: "closed",
1542 - involvement: "reviewing",
1543 - viewer: "bilal",
1544 - limit: 10,
1545 - query: "page",
1546 - });
1547 -
1548 - expect(searchOfCall(0)).toBe(
1549 - 'is:pr is:closed is:unmerged review-requested:bilal "page" sort:updated-desc repo:acme/web',
1550 - );
1551 - }),
1552 - );
1553 -
1501 it.effect("carries the further narrowings into the search as qualifiers", () =>
1502 Effect.gen(function* () {
1503 mockedExecute.mockImplementation((call) =>
@@ -1861,55 +1808,6 @@ layer("GitHubPullRequestApi.layer", (it) => {
1808 },
1809 });
1810
1864 - it.effect("updates a stale branch with a merge commit unless asked to rebase", () =>
1865 - Effect.gen(function* () {
1866 - route(["query PullRequestActionState", actionState()]);
1867 - const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1868 -
1869 - yield* cli.runPullRequestAction({
1870 - cwd: "/w",
1871 - repository: "acme/web",
1872 - host: "github.com",
1873 - number: 7,
1874 - action: "update-branch",
1875 - });
1876 - yield* cli.runPullRequestAction({
1877 - cwd: "/w",
1878 - repository: "acme/web",
1879 - host: "github.com",
1880 - number: 7,
1881 - action: "update-branch",
1882 - updateMethod: "rebase",
1883 - });
1884 -
1885 - expect(variablesOf("updatePullRequestBranch(")).toEqual([
1886 - { pullRequestId: "PR_7", expectedHeadOid: "abc123", updateMethod: "MERGE" },
1887 - { pullRequestId: "PR_7", expectedHeadOid: "abc123", updateMethod: "REBASE" },
1888 - ]);
1889 - }),
1890 - );
1891 -
1892 - it.effect("merges with the strategy it was asked for", () =>
1893 - Effect.gen(function* () {
1894 - route(["query PullRequestActionState", actionState()]);
1895 - const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1896 -
1897 - yield* cli.runPullRequestAction({
1898 - cwd: "/w",
1899 - repository: "acme/web",
1900 - host: "github.com",
1901 - number: 7,
1902 - action: "merge",
1903 - mergeMethod: "squash",
1904 - });
1905 -
1906 - expect(variablesOf("mergePullRequest(")).toEqual([
1907 - { input: { pullRequestId: "PR_7", mergeMethod: "SQUASH" } },
1908 - ]);
1909 - expect(variablesOf("enablePullRequestAutoMerge(")).toEqual([]);
1910 - }),
1911 - );
1912 -
1811 it.effect.each([
1812 {
1813 description: "base-only write",
@@ -2056,20 +1954,17 @@ layer("GitHubPullRequestApi.layer", (it) => {
1954
1955 it.effect.each([
1956 { description: "an open PR", head: { state: "OPEN" }, source: {} },
2059 - { description: "a missing source repository", head: { headRepository: null }, source: {} },
1957 { description: "the base branch", head: { headRefName: "main" }, source: {} },
1958 {
1959 description: "the default branch",
1960 head: {},
1961 source: { defaultBranchRef: { name: "feat/delete" } },
1962 },
2066 - { description: "a missing default branch", head: {}, source: { defaultBranchRef: null } },
1963 {
1964 description: "a changed branch",
1965 head: {},
1966 source: { ref: { target: { __typename: "Commit", oid: "new-commit" } } },
1967 },
2072 - { description: "an unavailable source repository", head: {}, source: null },
1968 ])("refuses to delete $description", ({ head, source }) =>
1969 Effect.gen(function* () {
1970 route(
@@ -2271,35 +2166,6 @@ layer("GitHubPullRequestApi.layer", (it) => {
2166 }),
2167 );
2168
2274 - it.effect("arms auto-merge with the same strategy a merge would have used", () =>
2275 - Effect.gen(function* () {
2276 - route(["query PullRequestActionState", actionState()]);
2277 - const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2278 -
2279 - yield* cli.runPullRequestAction({
2280 - cwd: "/w",
2281 - repository: "acme/web",
2282 - host: "github.com",
2283 - number: 7,
2284 - action: "enable-auto-merge",
2285 - mergeMethod: "squash",
2286 - });
2287 - yield* cli.runPullRequestAction({
2288 - cwd: "/w",
2289 - repository: "acme/web",
2290 - host: "github.com",
2291 - number: 7,
2292 - action: "enable-auto-merge",
2293 - });
2294 -
2295 - expect(variablesOf("enablePullRequestAutoMerge(")).toEqual([
2296 - { input: { pullRequestId: "PR_7", mergeMethod: "SQUASH" } },
2297 - { input: { pullRequestId: "PR_7", mergeMethod: "MERGE" } },
2298 - ]);
2299 - expect(variablesOf("mergePullRequest(")).toEqual([]);
2300 - }),
2301 - );
2302 -
2169 it.effect("merges at once when auto-merge is asked of a pull request that is ready now", () =>
2170 Effect.gen(function* () {
2171 route(["query PullRequestActionState", actionState({ mergeStateStatus: "CLEAN" })]);
@@ -2715,25 +2581,6 @@ layer("GitHubPullRequestApi.layer", (it) => {
2581 }),
2582 );
2583
2718 - it.effect("carries on from a cursor without asking for the whole diff again", () =>
2719 - Effect.gen(function* () {
2720 - mockedExecute.mockReturnValueOnce(Effect.fail(diffRefused));
2721 - mockedExecute.mockReturnValueOnce(Effect.succeed(output(pullRequestFiles(100, 0))));
2722 - const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2723 - const target = { cwd: "/w", repository: "acme/web", host: "github.com", number: 7 };
2724 -
2725 - const first = yield* cli.getPullRequestDiff(target);
2726 - assert.isNotNull(first.nextCursor);
2727 - mockedExecute.mockReturnValueOnce(Effect.succeed(output(pullRequestFiles(4, 100))));
2728 - const second = yield* cli.getPullRequestDiff({ ...target, cursor: first.nextCursor });
2729 -
2730 - assert.isNull(second.nextCursor);
2731 - expect(second.patch).toContain("diff --git a/src/file100.ts b/src/file100.ts");
2732 - assert.strictEqual(mockedExecute.mock.calls.length, 3);
2733 - assert.strictEqual(pathAt(2), "repos/acme/web/pulls/7/files?per_page=100&page=2");
2734 - }),
2735 - );
2736 -
2584 it.effect("refuses a cursor it never handed out rather than reading it into a request", () =>
2585 Effect.gen(function* () {
2586 const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
@@ -2849,33 +2696,6 @@ layer("GitHubPullRequestApi.layer", (it) => {
2696 }),
2697 );
2698
2852 - it.effect("reports an oversized diff file with its path and reason", () =>
2853 - Effect.gen(function* () {
2854 - mockedExecute.mockReturnValueOnce(Effect.succeed(output(pullRequestRefs)));
2855 - mockedExecute.mockReturnValueOnce(Effect.succeed(output("partial", true)));
2856 - const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2857 -
2858 - const error = yield* Effect.flip(
2859 - cli.getPullRequestDiffFileContents({
2860 - cwd: "/w",
2861 - repository: "acme/web",
2862 - host: "github.com",
2863 - number: 7,
2864 - changeType: "deleted",
2865 - oldPath: "src/large.ts",
2866 - newPath: "src/large.ts",
2867 - }),
2868 - );
2869 -
2870 - assert.strictEqual(error._tag, "GitHubDiffFileContentsUnavailableError");
2871 - if (error._tag === "GitHubDiffFileContentsUnavailableError") {
2872 - assert.strictEqual(error.path, "src/large.ts");
2873 - assert.strictEqual(error.reason, "oversized");
2874 - }
2875 - assert.strictEqual(pathAt(1), "repos/acme/web/contents/src/large.ts?ref=a1b2c3d");
2876 - }),
2877 - );
2878 -
2699 it.effect("reports undecodable diff file contents as binary", () =>
2700 Effect.gen(function* () {
2701 mockedExecute.mockReturnValueOnce(Effect.succeed(output(pullRequestRefs)));
@@ -3060,21 +2880,12 @@ layer("GitHubPullRequestApi.layer", (it) => {
2880 }),
2881 );
2882
2883 + // regression: #18780 credentials that cannot read /user still load pull requests
2884 it.effect.each([
2885 new GitHubRequestPolicy.GitHubApiAuthenticationError({
2886 host: "github.identity-auth-error.test",
2887 operation: "getRoutingIdentity",
2888 }),
3068 - new GitHubRequestPolicy.GitHubApiRateLimitError({
3069 - host: "github.identity-rate-error.test",
3070 - operation: "getRoutingIdentity",
3071 - retryAt: 123_456,
3072 - }),
3073 - new GitHubRequestPolicy.GitHubApiRequestError({
3074 - host: "github.identity-network-error.test",
3075 - operation: "getRoutingIdentity",
3076 - cause: new Error("connection refused"),
3077 - }),
2889 new GitHubRequestPolicy.GitHubApiResponseError({
2890 host: "github.identity-server-error.test",
2891 operation: "getRoutingIdentity",
@@ -3136,36 +2947,6 @@ layer("GitHubPullRequestApi.layer", (it) => {
2947 }),
2948 );
2949
3139 - it.effect("sends a whole review as one request", () =>
3140 - Effect.gen(function* () {
3141 - mockedExecute.mockReturnValue(Effect.succeed(output("{}")));
3142 - const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3143 -
3144 - yield* cli.submitReview({
3145 - cwd: "/w",
3146 - repository: "acme/web",
3147 - host: "github.com",
3148 - number: 7,
3149 - verdict: "approve",
3150 - body: "Looks right.",
3151 - comments: [{ path: "src/a.ts", position: { kind: "added", newLine: 4 }, body: "nit" }],
3152 - });
3153 -
3154 - assert.strictEqual(mockedExecute.mock.calls.length, 1);
3155 - expect(restCallsTo("/reviews")).toMatchObject([
3156 - {
3157 - method: "POST",
3158 - path: "repos/acme/web/pulls/7/reviews",
3159 - body: {
3160 - event: "APPROVE",
3161 - body: "Looks right.",
3162 - comments: [{ path: "src/a.ts", line: 4, side: "RIGHT", body: "nit" }],
3163 - },
3164 - },
3165 - ]);
3166 - }),
3167 - );
3168 -
2950 it.effect("confirms a given subject belongs to the named pull request, then reacts to it", () =>
2951 Effect.gen(function* () {
2952 route([SUBJECT_SCOPE_QUERY, subjectScope("IC_1", "PR_kwDOA")]);
@@ -3228,50 +3009,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
3009 }),
3010 );
3011
3231 - it.effect("rewrites only the words a request named", () =>
3232 - Effect.gen(function* () {
3233 - route([NODE_ID_QUERY, nodeIdAnswer("PR_kwDOA")]);
3234 - const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3235 - const rewrite = (fields: { readonly title?: string; readonly body?: string }) =>
3236 - cli.updatePullRequest({
3237 - cwd: "/w",
3238 - repository: "acme/web",
3239 - host: "github.com",
3240 - number: 22,
3241 - ...fields,
3242 - });
3243 -
3244 - yield* rewrite({ title: "A better title" });
3245 - yield* rewrite({ body: "A better description." });
3246 - yield* rewrite({ title: "Both", body: "at once." });
3247 -
3248 - assert.strictEqual(variablesOf(NODE_ID_QUERY).length, 1);
3249 - expect(variablesOf("updatePullRequest(")).toEqual([
3250 - { pullRequestId: "PR_kwDOA", title: "A better title" },
3251 - { pullRequestId: "PR_kwDOA", body: "A better description." },
3252 - { pullRequestId: "PR_kwDOA", title: "Both", body: "at once." },
3253 - ]);
3254 - }),
3255 - );
3256 -
3257 - it.effect("fails the read when gh returns something unreadable", () =>
3258 - Effect.gen(function* () {
3259 - mockedExecute.mockReturnValueOnce(Effect.succeed(output('{"message":"not found"}')));
3260 - const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3261 -
3262 - const error = yield* Effect.flip(
3263 - cli.getPullRequestDetail({
3264 - cwd: "/w",
3265 - repository: "acme/web",
3266 - host: "github.com",
3267 - number: 7,
3268 - }),
3269 - );
3270 -
3271 - assert.strictEqual(error._tag, "GitHubPullRequestReadError");
3272 - }),
3273 - );
3274 -
3012 + // regression: #19564 only a refused reviewer path is retried; other failures surface as-is
3013 it.effect.each([
3014 {
3015 name: "check path",
@@ -3282,31 +3020,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
3020 },
3021 ],
3022 },
3285 - {
3286 - name: "mixed errors",
3287 - errors: [refusedReviewer, { ...refusedReviewer, path: [...refusedReviewer.path, "login"] }],
3288 - },
3289 - {
3290 - name: "untyped error",
3291 - errors: [{ message: refusedReviewer.message, path: refusedReviewer.path }],
3292 - },
3293 - {
3294 - name: "negative index",
3295 - errors: [
3296 - {
3297 - ...refusedReviewer,
3298 - path: ["repository", "pullRequest", "reviewRequests", "nodes", -1, "requestedReviewer"],
3299 - },
3300 - ],
3301 - },
3023 { name: "HTTP 403", errors: [refusedReviewer], status: 403 },
3303 - {
3304 - name: "authentication",
3305 - errors: [refusedReviewer],
3306 - status: 401,
3307 - tag: "GitHubApiAuthenticationError",
3308 - },
3309 - { name: "rate limit", errors: [refusedReviewer], status: 429, tag: "GitHubApiRateLimitError" },
3024 {
3025 name: "GraphQL rate limit",
3026 errors: [refusedReviewer, { message: "API rate limit exceeded", type: "RATE_LIMITED" }],
@@ -3842,32 +3556,6 @@ layer("GitHubPullRequestApi.layer", (it) => {
3556 }),
3557 );
3558
3845 - it.effect("asks GitHub to review, naming the collection a request is added to", () =>
3846 - Effect.gen(function* () {
3847 - mockedExecute.mockReturnValue(Effect.succeed(output("{}")));
3848 - const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3849 -
3850 - yield* cli.setReviewerRequest({
3851 - cwd: "/w",
3852 - repository: "acme/web",
3853 - host: "github.com",
3854 - number: 7,
3855 - reviewers: [
3856 - { id: "octocat", kind: "user" },
3857 - { id: "reviewers", kind: "team" },
3858 - ],
3859 - requested: true,
3860 - });
3861 -
3862 - expect(callAt(0)).toMatchObject({
3863 - kind: "rest",
3864 - method: "POST",
3865 - path: "repos/acme/web/pulls/7/requested_reviewers",
3866 - body: { reviewers: ["octocat"], team_reviewers: ["reviewers"] },
3867 - });
3868 - }),
3869 - );
3870 -
3559 it.effect("reads who may review and who already has in one request", () =>
3560 Effect.gen(function* () {
3561 mockedExecute.mockReturnValue(
packages/source-control-github/src/server/GitHubPullRequestProvider.test.ts
-9
@@ -761,15 +761,6 @@ describe("getChangeRequestActivity dismissed reviews", () => {
761 Effect.provide(layerFor("<!-- Macroscope (Approvability) review body marker -->")),
762 ),
763 );
764 -
765 - it.effect("keeps the words of a dismissed review that has its own", () =>
766 - readActivity.pipe(
767 - Effect.map((activity) => {
768 - expect(activity.comments[0]?.body).toBe("These findings still stand.");
769 - }),
770 - Effect.provide(layerFor("These findings still stand.")),
771 - ),
772 - );
764 });
765
766 describe("loginAvatarUrl", () => {
packages/source-control-github/src/server/GitHubSourceControlProvider.test.ts
-47
@@ -292,31 +292,6 @@ describe("GitHubSourceControlProvider repository resolution", () => {
292 assert.deepStrictEqual(paths, ["github.com repos/acme/web"]);
293 }).pipe(Effect.provide(layer));
294 });
295 -
296 - it.effect("reads an SSH alias remote through github.com", () => {
297 - const hosts: string[] = [];
298 - const { layer } = harness({
299 - remotes: remotesOutput(["origin", "git@github:acme/web.git"]),
300 - api: {
301 - rest: (input) =>
302 - Effect.sync(() => {
303 - hosts.push(`${input.host} ${input.path}`);
304 - return restResponse({
305 - full_name: "acme/web",
306 - html_url: "https://github.com/acme/web",
307 - ssh_url: "git@github.com:acme/web.git",
308 - default_branch: "main",
309 - });
310 - }),
311 - },
312 - });
313 - return Effect.gen(function* () {
314 - const gh = yield* GitHubSourceControlProvider.make;
315 - yield* gh.getDefaultBranch({ cwd: "/repo" });
316 - yield* gh.getDefaultBranch({ cwd: "/repo", context: githubContext("github") });
317 - assert.deepStrictEqual(hosts, ["github.com repos/acme/web", "github.com repos/acme/web"]);
318 - }).pipe(Effect.provide(layer));
319 - });
295 });
296
297 describe("GitHubSourceControlProvider change request lookups by head", () => {
@@ -865,14 +840,6 @@ it("reports every gh login and leads with the account Settings pin", () => {
840 ]);
841 });
842
868 -it("falls back to gh's active login when the pinned account is gone", () => {
869 - const auth = GitHubSourceControlProvider.parseGitHubAuth(multiAccountStatus(), {
870 - hosts: { "github.com": { account: "former-job", enabled: true } },
871 - tokens: {},
872 - });
873 - assert.deepStrictEqual(auth.account, Option.some("personal"));
874 -});
875 -
843 it("reports unauthenticated when Settings turn off every signed-in host", () => {
844 const auth = GitHubSourceControlProvider.parseGitHubAuth(multiAccountStatus(), {
845 hosts: { "github.com": { enabled: false } },
@@ -1007,13 +974,6 @@ it.live.each([
974
975 it.effect.each([
976 { host: "github.com", resolved: "", envRepository: "", expected: "acme/web" },
1010 - { host: "code.example.test", resolved: "", envRepository: "", expected: "acme/web" },
1011 - {
1012 - host: "github.com",
1013 - resolved: "remote.origin.gh-resolved base",
1014 - envRepository: "",
1015 - expected: "me/web",
1016 - },
977 {
978 host: "code.example.test",
979 resolved: "remote.origin.gh-resolved base",
@@ -1026,13 +986,6 @@ it.effect.each([
986 envRepository: "",
987 expected: "acme/other",
988 },
1029 - {
1030 - host: "code.example.test",
1031 - resolved: "remote.upstream.gh-resolved acme/other",
1032 - envRepository: "",
1033 - expected: "acme/other",
1034 - },
1035 - { host: "github.com", resolved: "", envRepository: "chosen/repo", expected: "chosen/repo" },
989 {
990 host: "code.example.test",
991 resolved: "",
packages/source-control-github/src/server/gitHubPullRequestJson.test.ts
-24
@@ -1453,30 +1453,6 @@ describe("decodePullRequestFilesJson", () => {
1453 );
1454 });
1455
1456 - it("assembles a unified patch the files API does not return", () => {
1457 - const result = expectSuccess(
1458 - decodePullRequestFilesJson(
1459 - JSON.stringify([
1460 - { filename: "src/app.ts", status: "modified", patch: "@@ -1 +1 @@\n-old\n+new" },
1461 - ]),
1462 - ),
1463 - );
1464 -
1465 - expect(result.patch).toBe(
1466 - [
1467 - "diff --git a/src/app.ts b/src/app.ts",
1468 - "--- a/src/app.ts",
1469 - "+++ b/src/app.ts",
1470 - "@@ -1 +1 @@",
1471 - "-old",
1472 - "+new",
1473 - "",
1474 - ].join("\n"),
1475 - );
1476 - expect(result.truncated).toBe(false);
1477 - expect(result.rawCount).toBe(1);
1478 - });
1479 -
1456 it("points an added file at /dev/null on the left and a removed one on the right", () => {
1457 const result = expectSuccess(
1458 decodePullRequestFilesJson(
packages/source-control-gitlab/src/server/GitLabPullRequestCli.legacy.test.ts
+1
@@ -123,6 +123,7 @@ layer("legacy GitLab diff requests through GitLabCli", (it) => {
123 expect(run).toHaveBeenCalledTimes(2);
124 }),
125 );
126 + // regression: #15886 the older-GitLab fallback still surfaces its own failure
127 it.effect("propagates failure of the legacy endpoint", () =>
128 Effect.gen(function* () {
129 run.mockReturnValueOnce(failure("not-found"));
packages/source-control-gitlab/src/server/GitLabPullRequestCli.test.ts
-95
@@ -282,29 +282,10 @@ layer("GitLabPullRequestCli.layer", (it) => {
282 }),
283 );
284
285 - it.effect("addresses a nested group project by its encoded full path", () =>
286 - Effect.gen(function* () {
287 - mockedExecute.mockReturnValueOnce(Effect.succeed(output("[]")));
288 - const cli = yield* GitLabPullRequestCli.GitLabPullRequestCli;
289 -
290 - yield* cli.listMergeRequests({
291 - cwd: "/w",
292 - repository: "acme/platform/web",
293 - state: "open",
294 - involvement: "all",
295 - viewer: "bilal",
296 - limit: 10,
297 - });
298 -
299 - expect(argsOfCall(0)[1]).toContain("projects/acme%2Fplatform%2Fweb/merge_requests");
300 - }),
301 - );
302 -
285 it.effect.each([
286 { action: "merge", autoMerge: "false", mergeMethod: "squash" },
287 { action: "enable-auto-merge", autoMerge: "true", mergeMethod: "squash" },
288 { action: "merge", autoMerge: "false", mergeMethod: "rebase" },
307 - { action: "enable-auto-merge", autoMerge: "true", mergeMethod: "rebase" },
289 ] as const)(
290 "$action with $mergeMethod succeeds on a project requiring the current source SHA",
291 ({ action, autoMerge, mergeMethod }) =>
@@ -453,24 +434,6 @@ layer("GitLabPullRequestCli.layer", (it) => {
434 }),
435 );
436
456 - it.effect("carries on from a cursor at the page it names", () =>
457 - Effect.gen(function* () {
458 - mockedExecute
459 - .mockReturnValueOnce(Effect.succeed(output(diffPage(0))))
460 - .mockReturnValueOnce(Effect.succeed(output(diffPage(100, 3))));
461 - const cli = yield* GitLabPullRequestCli.GitLabPullRequestCli;
462 - const target = { cwd: "/w", repository: "acme/web", number: 7 };
463 -
464 - const first = yield* cli.getMergeRequestDiff(target);
465 - assert.isNotNull(first.nextCursor);
466 - const second = yield* cli.getMergeRequestDiff({ ...target, cursor: first.nextCursor });
467 -
468 - expect(argsOfCall(1)[1]).toContain("page=2");
469 - assert.isNull(second.nextCursor);
470 - expect(second.patch).toContain("diff --git a/src/100.ts b/src/100.ts");
471 - }),
472 - );
473 -
437 it.effect("refuses a cursor it never handed out rather than reading it into a query", () =>
438 Effect.gen(function* () {
439 const cli = yield* GitLabPullRequestCli.GitLabPullRequestCli;
@@ -581,43 +544,6 @@ layer("GitLabPullRequestCli.layer", (it) => {
544 }),
545 );
546
584 - it.effect("reports an oversized diff file with its path and reason", () =>
585 - Effect.gen(function* () {
586 - mockedExecute.mockReturnValueOnce(
587 - Effect.succeed(
588 - output(
589 - JSON.stringify({
590 - diff_refs: {
591 - base_sha: "a1b2c3d",
592 - head_sha: "b1c2d3e",
593 - start_sha: "a1b2c3d",
594 - },
595 - }),
596 - ),
597 - ),
598 - );
599 - mockedExecute.mockReturnValueOnce(Effect.succeed(output("partial", true)));
600 - const cli = yield* GitLabPullRequestCli.GitLabPullRequestCli;
601 -
602 - const error = yield* Effect.flip(
603 - cli.getMergeRequestDiffFileContents({
604 - cwd: "/w",
605 - repository: "acme/web",
606 - number: 7,
607 - changeType: "deleted",
608 - oldPath: "src/large.ts",
609 - newPath: "src/large.ts",
610 - }),
611 - );
612 -
613 - assert.strictEqual(error._tag, "GitLabDiffFileContentsUnavailableError");
614 - if (error._tag === "GitLabDiffFileContentsUnavailableError") {
615 - assert.strictEqual(error.path, "src/large.ts");
616 - assert.strictEqual(error.reason, "oversized");
617 - }
618 - }),
619 - );
620 -
547 it.effect("reports undecodable diff file contents as binary", () =>
548 Effect.gen(function* () {
549 mockedExecute.mockReturnValueOnce(
@@ -1071,27 +997,6 @@ layer("GitLabPullRequestCli.layer", (it) => {
997 expect(JSON.parse(callAt(1).stdin ?? "")).toEqual({ reviewer_ids: [5] });
998 }),
999 );
1074 -
1075 - it.effect("rewrites title and description together in one request", () =>
1076 - Effect.gen(function* () {
1077 - mockedExecute.mockReturnValue(Effect.succeed(output("{}")));
1078 - const cli = yield* GitLabPullRequestCli.GitLabPullRequestCli;
1079 -
1080 - yield* cli.updateMergeRequest({
1081 - cwd: "/w",
1082 - repository: "acme/web",
1083 - number: 7,
1084 - title: "A better title",
1085 - description: "What this changes.",
1086 - });
1087 -
1088 - assert.strictEqual(mockedExecute.mock.calls.length, 1);
1089 - expect(JSON.parse(callAt(0).stdin ?? "")).toEqual({
1090 - title: "A better title",
1091 - description: "What this changes.",
1092 - });
1093 - }),
1094 - );
1000 it.effect("reads blob ids for the marked paths at the merge request's head", () =>
1001 Effect.gen(function* () {
1002 mockedExecute.mockReturnValueOnce(
packages/source-control-gitlab/src/server/GitLabSourceControlProvider.test.ts
+1 -45
@@ -25,49 +25,6 @@ function makeProvider(gitlab: Partial<GitLabCli.GitLabCli["Service"]>) {
25 );
26 }
27
28 -it.effect("maps GitLab MR summaries into provider-neutral change requests", () =>
29 - Effect.gen(function* () {
30 - const provider = yield* makeProvider({
31 - getMergeRequest: () =>
32 - Effect.succeed({
33 - number: 42,
34 - title: "Add GitLab provider",
35 - url: "https://gitlab.com/pingdotgg/t3code/-/merge_requests/42",
36 - baseRefName: "main",
37 - headRefName: "feature/source-control",
38 - headSha: "a".repeat(40),
39 - state: "closed",
40 - closedAt: "2026-08-23T10:00:00Z",
41 - isCrossRepository: true,
42 - headRepositoryNameWithOwner: "fork/t3code",
43 - headRepositoryOwnerLogin: "fork",
44 - }),
45 - });
46 -
47 - const changeRequest = yield* provider.getChangeRequest({
48 - cwd: "/repo",
49 - reference: "42",
50 - });
51 -
52 - assert.deepStrictEqual(changeRequest, {
53 - provider: SourceControlProviderKind.make("gitlab"),
54 - number: 42,
55 - title: "Add GitLab provider",
56 - url: "https://gitlab.com/pingdotgg/t3code/-/merge_requests/42",
57 - baseRefName: "main",
58 - headRefName: "feature/source-control",
59 - headSha: "a".repeat(40),
60 - state: "closed",
61 - closedAt: "2026-08-23T10:00:00Z",
62 - mergedAt: null,
63 - updatedAt: Option.none(),
64 - isCrossRepository: true,
65 - headRepositoryNameWithOwner: "fork/t3code",
66 - headRepositoryOwnerLogin: "fork",
67 - });
68 - }),
69 -);
70 -
28 it("accepts authenticated GitLab hosts when another configured host fails", () => {
29 const auth = GitLabSourceControlProvider.discovery.parseAuth({
30 exitCode: ChildProcessSpawner.ExitCode(1),
@@ -151,6 +108,7 @@ it("tells a host glab has no login for apart from output that cannot say", () =>
108 assert.strictEqual(refine("git.example.test\n x API call failed: 503"), undefined);
109 });
110
111 +// regression: #15395 self-hosted GitLab remotes resolve bare MR numbers once glab is signed in
112 it.effect.each([
113 [
114 "https://code.example.test:8443@Code.Example.Test:8443/Team/Repo.git",
@@ -159,8 +117,6 @@ it.effect.each([
117 "Code.Example.Test:8443",
118 ],
119 ["git@code.example.test:team/repo.git", true, "gitlab"],
162 - ["code.example.test:team/repo.git", true, "gitlab"],
163 - ["git@code.example.test:/team/repo.git", true, "gitlab"],
120 ["https://code.example.test/team/repo.git", false, "unknown"],
121 ["https://github.com/team/repo.git", true, "github"],
122 ] as const)(
packages/source-control-gitlab/src/server/gitLabMergeRequestJson.test.ts
-51
@@ -88,12 +88,6 @@ describe("decodeMergeRequestListJson", () => {
88 expect(batch.items[0]?.state).toBe("merged");
89 });
90
91 - it("keeps a locked merge request open", () => {
92 - const batch = expectSuccess(decodeMergeRequestListJson(listJson([{ state: "locked" }])));
93 -
94 - expect(batch.items[0]?.state).toBe("open");
95 - });
96 -
91 it("reads the legacy draft flag", () => {
92 const batch = expectSuccess(decodeMergeRequestListJson(listJson([{ work_in_progress: true }])));
93
@@ -108,14 +102,6 @@ describe("decodeMergeRequestListJson", () => {
102 expect(batch.items[0]?.mergeability).toBe("conflicting");
103 });
104
111 - it("leaves an unfinished merge check unknown", () => {
112 - const batch = expectSuccess(
113 - decodeMergeRequestListJson(listJson([{ merge_status: "checking" }])),
114 - );
115 -
116 - expect(batch.items[0]?.mergeability).toBe("unknown");
117 - });
118 -
105 it("skips a malformed row but still counts it, so paging does not stop early", () => {
106 const batch = expectSuccess(
107 decodeMergeRequestListJson(
@@ -460,17 +446,6 @@ describe("decodeMergeRequestDiffsJson", () => {
446 });
447
448 describe("merge request viewer fields", () => {
463 - it("carries GitLab's own answer for whether this viewer can merge", () => {
464 - expect(
465 - expectSuccess(decodeMergeRequestDetailJson(detailJson({ user: { can_merge: false } })))
466 - .viewerCanMerge,
467 - ).toBe(false);
468 - expect(
469 - expectSuccess(decodeMergeRequestDetailJson(detailJson({ user: { can_merge: true } })))
470 - .viewerCanMerge,
471 - ).toBe(true);
472 - });
473 -
449 it("leaves merging permitted where GitLab answered without the field", () => {
450 expect(expectSuccess(decodeMergeRequestDetailJson(detailJson({}))).viewerCanMerge).toBe(true);
451 expect(
@@ -525,26 +500,6 @@ describe("decodeAwardEmojiJson", () => {
500 expect(result.nextCursor).toBeNull();
501 });
502
528 - it("hands back a cursor when GitLab has more notes to page", () => {
529 - const result = expectSuccess(
530 - decodeAwardEmojiJson(
531 - JSON.stringify({
532 - data: {
533 - currentUser: null,
534 - project: {
535 - mergeRequest: {
536 - awardEmoji: { nodes: [] },
537 - notes: { pageInfo: { hasNextPage: true, endCursor: "Y3Vyc29yOjE" }, nodes: [] },
538 - },
539 - },
540 - },
541 - }),
542 - ),
543 - );
544 -
545 - expect(result.nextCursor).toBe("Y3Vyc29yOjE");
546 - });
547 -
503 it("matches the viewer's username case-insensitively, since GitLab is not consistent about case", () => {
504 const result = expectSuccess(
505 decodeAwardEmojiJson(
@@ -584,12 +539,6 @@ describe("decodeOwnAwardIdJson", () => {
539 expectSuccess(decodeOwnAwardIdJson(awards, { content: "thumbs-up", viewer: "bilal" })),
540 ).toBe(102);
541 });
587 -
588 - it("returns nothing where the reader has no award of that name", () => {
589 - expect(
590 - expectSuccess(decodeOwnAwardIdJson(awards, { content: "heart", viewer: "bilal" })),
591 - ).toBeNull();
592 - });
542 });
543
544 describe("decodeRepositoryBlobsJson", () => {