@devries-cameron20 / t3code-1 / commits / 2821004fd6
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

test(clients): prune redundant checks and retain compatibility guards (#21850)

Co-authored-by: Theo Browne <me@t3.gg>

Julius Marminge committed Oct 19, 2026 at 20:39 UTC 2821004fd60e120259442c6ffdf6415dcf429878
16 files changed +24 -481
apps/desktop/src/app/DesktopAppErrors.test.ts deleted
-30
@@ -1,30 +0,0 @@
1 -import { assert, describe, it } from "@effect/vitest";
2 -
3 -import {
4 - DesktopBackendPortUnavailableError,
5 - DesktopDevelopmentBackendPortRequiredError,
6 -} from "./DesktopApp.ts";
7 -
8 -describe("DesktopApp errors", () => {
9 - it("preserves unavailable backend port context", () => {
10 - const error = new DesktopBackendPortUnavailableError({
11 - startPort: 3_773,
12 - maxPort: 65_535,
13 - hosts: ["127.0.0.1", "0.0.0.0", "::"],
14 - });
15 -
16 - assert.equal(error.startPort, 3_773);
17 - assert.equal(error.maxPort, 65_535);
18 - assert.deepEqual(error.hosts, ["127.0.0.1", "0.0.0.0", "::"]);
19 - assert.equal(
20 - error.message,
21 - "No desktop backend port is available on hosts 127.0.0.1, 0.0.0.0, :: between 3773 and 65535.",
22 - );
23 - });
24 -
25 - it("reports the required development port", () => {
26 - const error = new DesktopDevelopmentBackendPortRequiredError();
27 -
28 - assert.equal(error.message, "T3CODE_PORT is required in desktop development.");
29 - });
30 -});
apps/desktop/src/app/DesktopDetachedActionErrors.test.ts deleted
-37
@@ -1,37 +0,0 @@
1 -import { assert, describe, it } from "@effect/vitest";
2 -import * as Cause from "effect/Cause";
3 -
4 -import { DesktopLifecycleRelaunchError } from "./DesktopLifecycle.ts";
5 -import { DesktopApplicationMenuActionError } from "../window/DesktopApplicationMenu.ts";
6 -
7 -describe("desktop detached action errors", () => {
8 - it("preserves the complete relaunch failure cause and reason", () => {
9 - const cause = Cause.combine(
10 - Cause.fail(new Error("shutdown failed")),
11 - Cause.die(new Error("relaunch defect")),
12 - );
13 - const error = new DesktopLifecycleRelaunchError({
14 - reason: "apply update",
15 - cause,
16 - });
17 -
18 - assert.strictEqual(error.cause, cause);
19 - assert.equal(error.reason, "apply update");
20 - assert.equal(error.message, 'Desktop relaunch failed for reason "apply update".');
21 - });
22 -
23 - it("preserves the complete menu action failure cause and action", () => {
24 - const cause = Cause.combine(
25 - Cause.fail(new Error("window unavailable")),
26 - Cause.die(new Error("dispatch defect")),
27 - );
28 - const error = new DesktopApplicationMenuActionError({
29 - action: "open-settings",
30 - cause,
31 - });
32 -
33 - assert.strictEqual(error.cause, cause);
34 - assert.equal(error.action, "open-settings");
35 - assert.equal(error.message, 'Desktop menu action "open-settings" failed.');
36 - });
37 -});
apps/desktop/src/backend/DesktopBackendPool.test.ts
+1 -54
@@ -1,5 +1,4 @@
1 import { assert, describe, it } from "@effect/vitest";
2 -import * as Duration from "effect/Duration";
2 import * as Effect from "effect/Effect";
3 import * as FileSystem from "effect/FileSystem";
4 import * as Layer from "effect/Layer";
@@ -19,29 +18,7 @@ import * as DesktopWindow from "../window/DesktopWindow.ts";
18 import * as DesktopWslEnvironment from "../wsl/DesktopWslEnvironment.ts";
19 import * as DesktopBackendConfiguration from "./DesktopBackendConfiguration.ts";
20 import * as DesktopBackendPool from "./DesktopBackendPool.ts";
22 -import type { DesktopBackendSnapshot, DesktopBackendStartConfig } from "./DesktopBackendManager.ts";
23 -
24 -function makeStubInstance(
25 - id: DesktopBackendPool.BackendInstanceId,
26 - label: string,
27 -): DesktopBackendPool.DesktopBackendInstance {
28 - const snapshot: DesktopBackendSnapshot = {
29 - desiredRunning: false,
30 - ready: false,
31 - activePid: Option.none(),
32 - restartAttempt: 0,
33 - restartScheduled: false,
34 - };
35 - return {
36 - id,
37 - label: Effect.succeed(label),
38 - start: Effect.void,
39 - stop: () => Effect.void,
40 - currentConfig: Effect.succeed(Option.none<DesktopBackendStartConfig>()),
41 - snapshot: Effect.succeed(snapshot),
42 - waitForReady: (_timeout: Duration.Duration) => Effect.succeed(false),
43 - };
44 -}
21 +import type { DesktopBackendStartConfig } from "./DesktopBackendManager.ts";
22
23 function layerPool(labelRef: Ref.Ref<string>): Layer.Layer<DesktopBackendPool.DesktopBackendPool> {
24 return DesktopBackendPool.layer.pipe(
@@ -111,36 +88,6 @@ function layerPool(labelRef: Ref.Ref<string>): Layer.Layer<DesktopBackendPool.De
88 }
89
90 describe("DesktopBackendPool", () => {
114 - it.effect("layerTest exposes registered instances by id", () =>
115 - Effect.gen(function* () {
116 - const pool = yield* DesktopBackendPool.DesktopBackendPool;
117 - const fetchedPrimary = yield* pool.get(DesktopBackendPool.PRIMARY_INSTANCE_ID);
118 - const fetchedWsl = yield* pool.get(DesktopBackendPool.BackendInstanceId("wsl:ubuntu"));
119 - const fetchedMissing = yield* pool.get(DesktopBackendPool.BackendInstanceId("missing"));
120 - const all = yield* pool.list;
121 - const resolvedPrimary = yield* pool.primary;
122 -
123 - assert.equal(yield* Option.getOrThrow(fetchedPrimary).label, "Windows");
124 - assert.equal(yield* Option.getOrThrow(fetchedWsl).label, "WSL (Ubuntu)");
125 - assert.isTrue(Option.isNone(fetchedMissing));
126 - assert.lengthOf(all, 2);
127 - assert.equal(resolvedPrimary.id, DesktopBackendPool.PRIMARY_INSTANCE_ID);
128 - }).pipe(
129 - Effect.provide(
130 - DesktopBackendPool.layerTest([
131 - makeStubInstance(DesktopBackendPool.PRIMARY_INSTANCE_ID, "Windows"),
132 - makeStubInstance(DesktopBackendPool.BackendInstanceId("wsl:ubuntu"), "WSL (Ubuntu)"),
133 - ]),
134 - ),
135 - ),
136 - );
137 -
138 - it.effect("layerTest dies when no instances are supplied", () =>
139 - Effect.exit(
140 - DesktopBackendPool.DesktopBackendPool.pipe(Effect.provide(DesktopBackendPool.layerTest([]))),
141 - ).pipe(Effect.map((exit) => assert.equal(exit._tag, "Failure"))),
142 - );
143 -
91 it.effect("resolves the primary label lazily after pool layer construction", () =>
92 Effect.scoped(
93 Effect.gen(function* () {
apps/mobile/src/features/connection/ConnectionFormField.test.tsx deleted
-42
@@ -1,42 +0,0 @@
1 -import type { ReactNode } from "react";
2 -import { renderToStaticMarkup } from "react-dom/server";
3 -import { describe, expect, it, vi } from "vite-plus/test";
4 -
5 -vi.mock("react-native", () => ({
6 - View: ({ children }: { children: ReactNode }) => <div>{children}</div>,
7 -}));
8 -vi.mock("../../components/ui/AppText", () => ({
9 - AppText: ({
10 - accessibilityElementsHidden,
11 - importantForAccessibility,
12 - children,
13 - }: {
14 - accessibilityElementsHidden?: boolean;
15 - importantForAccessibility?: string;
16 - children: ReactNode;
17 - }) => (
18 - <span
19 - aria-hidden={
20 - accessibilityElementsHidden || importantForAccessibility === "no-hide-descendants"
21 - }
22 - >
23 - {children}
24 - </span>
25 - ),
26 - AppTextInput: ({ accessibilityLabel }: { accessibilityLabel?: string }) => (
27 - <input aria-label={accessibilityLabel} />
28 - ),
29 -}));
30 -
31 -import { ConnectionFormField } from "./ConnectionFormField";
32 -
33 -describe("ConnectionFormField accessibility", () => {
34 - it.each(["Host", "Pairing code"])("exposes %s once as the input name", (label) => {
35 - const markup = renderToStaticMarkup(
36 - <ConnectionFormField label={label} placeholder="Not an accessible name" />,
37 - );
38 -
39 - expect(markup).toContain(`<span aria-hidden="true">${label}</span>`);
40 - expect(markup).toContain(`<input aria-label="${label}"/>`);
41 - });
42 -});
apps/mobile/src/native/scrollEdgeEffects.test.ts
+2 -22
@@ -1,29 +1,9 @@
1 import { describe, expect, it } from "vite-plus/test";
2
3 -import { nativeHeaderScrollEdgeEffects, nativeTopScrollEdgeEffect } from "./scrollEdgeEffects";
3 +import { nativeTopScrollEdgeEffect } from "./scrollEdgeEffects";
4
5 describe("nativeTopScrollEdgeEffect", () => {
6 - it("keeps the automatic native treatment on iOS 26", () => {
7 - expect(nativeTopScrollEdgeEffect("ios", "26.5")).toBe("automatic");
8 - });
9 -
10 - it("keeps UIKit automatic scroll-edge sampling on iOS 27 and later", () => {
6 + it("keeps UIKit content sampling instead of a local soft overlay on iOS 27", () => {
7 expect(nativeTopScrollEdgeEffect("ios", "27.0")).toBe("automatic");
12 - expect(nativeTopScrollEdgeEffect("ios", 28)).toBe("automatic");
13 - });
14 -
15 - it("does not apply the iOS workaround to other platforms", () => {
16 - expect(nativeTopScrollEdgeEffect("android", 27)).toBe("automatic");
17 - });
18 -});
19 -
20 -describe("nativeHeaderScrollEdgeEffects", () => {
21 - it("keeps non-top header edges hidden while applying the platform top effect", () => {
22 - expect(nativeHeaderScrollEdgeEffects("ios", "27.0")).toEqual({
23 - top: "automatic",
24 - bottom: "hidden",
25 - left: "hidden",
26 - right: "hidden",
27 - });
8 });
9 });
apps/mobile/src/state/thread-order.test.ts
+1 -1
@@ -90,7 +90,7 @@ describe("shared mobile pending move", () => {
90 expect(getPendingThreadOrder()).toBeNull();
91 });
92
93 - it.each(["failure", "interruption"])("releases a %s without restoring old canonical keys", () => {
93 + it("releases a cancelled move without restoring old canonical keys", () => {
94 const { start, upsert } = fixture();
95 const move = start();
96 upsert("b", "aa");
apps/web/src/components/Sidebar.logic.test.ts
-40
@@ -38,7 +38,6 @@ import {
38 resolveSidebarThreadStatus,
39 resolveSidebarV2TopStatus,
40 resolveThreadLastVisitedAt,
41 - resolveThreadRowClassName,
41 resolveThreadStatusPill,
42 resolveWorkingStartedAt,
43 pullRequestMatchesSearchQuery,
@@ -54,7 +53,6 @@ import {
53 sortProjectsForSidebar,
54 sortScopedProjectsForSidebar,
55 sortSidebarV2ProjectGroups,
57 - shouldCreateNewThreadInCurrentProject,
56 shouldNavigateAfterThreadPark,
57 THREAD_JUMP_HINT_SHOW_DELAY_MS,
58 type SidebarListItem,
@@ -63,7 +61,6 @@ import {
61 resolveSidebarDropVerb,
62 } from "./Sidebar.logic";
63 import { threadSearchMatchKey } from "@t3tools/client-runtime/state/thread-search";
66 -import { sortSettledThreads } from "@t3tools/client-runtime/state/thread-sort";
64 import { EnvironmentId, ProjectId, ProviderInstanceId, RunId, ThreadId } from "@t3tools/contracts";
65
66 import {
@@ -1790,43 +1787,6 @@ describe("sortProjectsForSidebar", () => {
1787 ]);
1788 });
1789
1793 - it("ignores archived threads when sorting projects", () => {
1794 - const sorted = sortProjectsForSidebar(
1795 - [
1796 - makeProject({
1797 - id: ProjectId.make("project-1"),
1798 - title: "Visible project",
1799 - updatedAt: "2026-03-09T10:01:00.000Z",
1800 - }),
1801 - makeProject({
1802 - id: ProjectId.make("project-2"),
1803 - title: "Archived-only project",
1804 - updatedAt: "2026-03-09T10:00:00.000Z",
1805 - }),
1806 - ],
1807 - [
1808 - makeThread({
1809 - id: ThreadId.make("thread-visible"),
1810 - projectId: ProjectId.make("project-1"),
1811 - updatedAt: "2026-03-09T10:02:00.000Z",
1812 - archivedAt: null,
1813 - }),
1814 - makeThread({
1815 - id: ThreadId.make("thread-archived"),
1816 - projectId: ProjectId.make("project-2"),
1817 - updatedAt: "2026-03-09T10:10:00.000Z",
1818 - archivedAt: "2026-03-09T10:11:00.000Z",
1819 - }),
1820 - ].filter((thread) => thread.archivedAt === null),
1821 - "updated_at",
1822 - );
1823 -
1824 - expect(sorted.map((project) => project.id)).toEqual([
1825 - ProjectId.make("project-1"),
1826 - ProjectId.make("project-2"),
1827 - ]);
1828 - });
1829 -
1790 it.each(["updated_at", "created_at"] as const)(
1791 "matches the per-comparison %s order on a shuffled list with ties",
1792 (sortOrder) => {
apps/web/src/components/Sidebar.logic.ts
+1 -35
@@ -23,7 +23,7 @@ import {
23 type ThreadSortInput,
24 } from "../lib/threadSort";
25 import type { SidebarThreadSummary, Thread } from "../types";
26 -import { cn, normalizeSearchText } from "../lib/utils";
26 +import { normalizeSearchText } from "../lib/utils";
27 import { isLatestRunSettled } from "../session-logic";
28 import { resolveServerBackedAppStageLabel } from "../branding.logic";
29
@@ -876,40 +876,6 @@ export function isContextMenuPointerDown(input: {
876 return input.isMac && input.button === 0 && input.ctrlKey;
877 }
878
879 -export function resolveThreadRowClassName(input: {
880 - isActive: boolean;
881 - isSelected: boolean;
882 -}): string {
883 - const baseClassName =
884 - "h-8 w-full translate-x-0 cursor-pointer justify-start rounded-md px-2 text-left text-sm select-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring";
885 -
886 - if (input.isSelected && input.isActive) {
887 - return cn(
888 - baseClassName,
889 - "bg-sidebar-row-active text-sidebar-foreground font-medium hover:bg-sidebar-row-active hover:text-sidebar-foreground",
890 - );
891 - }
892 -
893 - if (input.isSelected) {
894 - return cn(
895 - baseClassName,
896 - "bg-sidebar-row-selected text-sidebar-foreground hover:bg-sidebar-row-active hover:text-sidebar-foreground",
897 - );
898 - }
899 -
900 - if (input.isActive) {
901 - return cn(
902 - baseClassName,
903 - "bg-sidebar-row-active text-sidebar-foreground font-medium hover:bg-sidebar-row-active hover:text-sidebar-foreground",
904 - );
905 - }
906 -
907 - return cn(
908 - baseClassName,
909 - "text-sidebar-muted-foreground/80 hover:bg-sidebar-row-hover hover:text-sidebar-foreground",
910 - );
911 -}
912 -
879 export type SidebarThreadStatus =
880 | "approval"
881 | "input"
apps/web/src/components/chat/pendingDraftWork.test.ts
-9
@@ -42,15 +42,6 @@ describe("PendingDraftWork", () => {
42 expect(pending.has("isolated-a")).toBe(false);
43 });
44
45 - it("keeps a claim on the draft across a remount of the composer", async () => {
46 - const { pendingDraftWork: first } = await import("./pendingDraftWork");
47 - first.begin("remounted");
48 - const { pendingDraftWork: second } = await import("./pendingDraftWork");
49 - expect(second.has("remounted")).toBe(true);
50 - second.end("remounted");
51 - expect(first.has("remounted")).toBe(false);
52 - });
53 -
45 it("does not go negative when a transfer ends twice", () => {
46 const pending = pendingDraftWork;
47 pending.begin("double-end");
apps/web/src/components/chat/workspaceFileDrop.test.ts
+2 -12
@@ -70,13 +70,14 @@ describe("makeWorkspaceFileDropHandlers", () => {
70
71 it("forwards dropped files and clears the active state", () => {
72 const file = new File(["contents"], "example.txt", { type: "text/plain" });
73 - const { host, setDragActive, addFiles } = makeHost();
73 + const { host, setDragActive, addFiles, addFolders } = makeHost();
74 const { event } = makeDragEvent({ files: [file] });
75
76 makeWorkspaceFileDropHandlers(host).onDrop(event);
77
78 expect(setDragActive).toHaveBeenCalledWith(false);
79 expect(addFiles).toHaveBeenCalledWith([file]);
80 + expect(addFolders).not.toHaveBeenCalled();
81 });
82
83 it("routes mixed drops to files and folders", () => {
@@ -120,15 +121,4 @@ describe("makeWorkspaceFileDropHandlers", () => {
121 expect(addFiles).not.toHaveBeenCalled();
122 expect(addFolders).toHaveBeenCalledWith([folder]);
123 });
123 -
124 - it("uses files when the browser does not expose drag items", () => {
125 - const file = new File(["contents"], "example.txt", { type: "text/plain" });
126 - const { host, addFiles, addFolders } = makeHost();
127 - const { event } = makeDragEvent({ files: [file] });
128 -
129 - makeWorkspaceFileDropHandlers(host).onDrop(event);
130 -
131 - expect(addFiles).toHaveBeenCalledWith([file]);
132 - expect(addFolders).not.toHaveBeenCalled();
133 - });
124 });
apps/web/src/components/clerk/clerkAppearance.test.ts
+10 -27
@@ -51,34 +51,17 @@ const builtInThemeModes = [
51 );
52
53 describe("clerkAppearance", () => {
54 - it("maps theme colors without overriding Clerk's component structure", () => {
55 - expect(clerkAppearance).toEqual({
56 - variables: {
57 - colorPrimary: "var(--update-foreground)",
58 - colorPrimaryForeground: "var(--card)",
59 - colorDanger: "var(--error)",
60 - colorSuccess: "var(--success)",
61 - colorWarning: "var(--warning)",
62 - colorNeutral: "var(--contrast-foreground)",
63 - colorForeground: "var(--contrast-foreground)",
64 - colorMuted: "color-mix(in srgb, var(--card) 98%, var(--contrast-foreground))",
65 - colorMutedForeground: "var(--contrast-muted-foreground)",
66 - colorBackground: "var(--card)",
67 - colorInputForeground: "var(--contrast-foreground)",
68 - colorInput: "var(--secondary)",
69 - colorRing: "var(--ring)",
70 - },
71 - elements: {
72 - formFieldErrorText: { color: "var(--error-foreground)" },
73 - formFieldWarningText: { color: "var(--warning-foreground)" },
74 - formFieldSuccessText: { color: "var(--success-foreground)" },
75 - otpCodeFieldErrorText: { color: "var(--error-foreground)" },
76 - otpCodeFieldSuccessText: { color: "var(--success-foreground)" },
77 - },
78 - });
79 - });
80 -
54 it.each(builtInThemeModes)("keeps Clerk text readable across a built-in palette", (colors) => {
55 + expect(clerkAppearance.variables).toMatchObject({
56 + colorForeground: "var(--contrast-foreground)",
57 + colorBackground: "var(--card)",
58 + colorMutedForeground: "var(--contrast-muted-foreground)",
59 + colorMuted: "color-mix(in srgb, var(--card) 98%, var(--contrast-foreground))",
60 + colorInputForeground: "var(--contrast-foreground)",
61 + colorInput: "var(--secondary)",
62 + colorPrimary: "var(--update-foreground)",
63 + colorPrimaryForeground: "var(--card)",
64 + });
65 const mutedSurface = mixThemeColors(colors.surface, colors.text, 0.98);
66
67 expect(contrastRatio(colors.text, colors.surface)).toBeGreaterThanOrEqual(4.5);
apps/web/src/components/pullRequest/pullRequestReactions.logic.test.ts
-30
@@ -3,9 +3,6 @@ import { describe, expect, it } from "vite-plus/test";
3
4 import {
5 applyPendingPullRequestReactions,
6 - PULL_REQUEST_REACTION_ORDER,
7 - pullRequestReactionEmoji,
8 - pullRequestReactionName,
6 pullRequestReactionTooltip,
7 } from "./pullRequestReactions.logic";
8
@@ -19,33 +16,6 @@ function reaction(overrides: Partial<PullRequestReaction> = {}): PullRequestReac
16 };
17 }
18
22 -describe("reaction presentation", () => {
23 - it("names and draws all eight, in GitHub's picker order", () => {
24 - expect(PULL_REQUEST_REACTION_ORDER).toEqual([
25 - "thumbs-up",
26 - "thumbs-down",
27 - "laugh",
28 - "hooray",
29 - "confused",
30 - "heart",
31 - "rocket",
32 - "eyes",
33 - ]);
34 - expect(PULL_REQUEST_REACTION_ORDER.map(pullRequestReactionEmoji)).toEqual([
35 - "👍",
36 - "👎",
37 - "😄",
38 - "🎉",
39 - "😕",
40 - "❤️",
41 - "🚀",
42 - "👀",
43 - ]);
44 - expect(pullRequestReactionName("thumbs-up")).toBe("thumbs up");
45 - expect(pullRequestReactionName("eyes")).toBe("eyes");
46 - });
47 -});
48 -
19 describe("reaction tooltip", () => {
20 it("reads as GitHub's sentence for one, two and three names", () => {
21 expect(
apps/web/src/composer-logic.test.ts
-15
@@ -876,21 +876,6 @@ describe("assistant citation cursor offsets", () => {
876 });
877 });
878
879 -describe("replaceTextRange trailing space consumption", () => {
880 - it("double space after insertion when replacement ends with space", () => {
881 - const text = "and then @AG summarize";
882 - const rangeStart = "and then ".length;
883 - const rangeEnd = "and then @AG".length;
884 -
885 - const withoutConsume = replaceTextRange(text, rangeStart, rangeEnd, "@AGENTS.md ");
886 - expect(withoutConsume.text).toBe("and then @AGENTS.md summarize");
887 -
888 - const extendedEnd = text[rangeEnd] === " " ? rangeEnd + 1 : rangeEnd;
889 - const withConsume = replaceTextRange(text, rangeStart, extendedEnd, "@AGENTS.md ");
890 - expect(withConsume.text).toBe("and then @AGENTS.md summarize");
891 - });
892 -});
893 -
879 describe("isCollapsedCursorAdjacentToInlineToken", () => {
880 it("returns false when no mention exists", () => {
881 expect(isCollapsedCursorAdjacentToInlineToken("plain text", 6, "left")).toBe(false);
packages/client-runtime/src/environment/knownEnvironment.test.ts
-11
@@ -43,17 +43,6 @@ describe("scoped refs", () => {
43 expect(scopedThreadKey(threadRef)).toBe("environment-test:thread-1");
44 });
45
46 - it("returns typed scoped refs", () => {
47 - expect(projectRef).toEqual({
48 - environmentId,
49 - projectId: ProjectId.make("project-1"),
50 - });
51 - expect(threadRef).toEqual({
52 - environmentId,
53 - threadId: ThreadId.make("thread-1"),
54 - });
55 - });
56 -
46 it("parses scoped project and thread keys back into refs", () => {
47 expect(parseScopedProjectKey("environment-test:project-1")).toEqual(projectRef);
48 expect(parseScopedThreadKey("environment-test:thread-1")).toEqual(threadRef);
packages/client-runtime/src/state/runtime.test.ts
-110
@@ -11,7 +11,6 @@ import * as Cause from "effect/Cause";
11 import * as Deferred from "effect/Deferred";
12 import * as Effect from "effect/Effect";
13 import * as Exit from "effect/Exit";
14 -import * as Fiber from "effect/Fiber";
14 import * as Latch from "effect/Latch";
15 import * as Layer from "effect/Layer";
16 import * as Option from "effect/Option";
@@ -1065,115 +1064,6 @@ describe("environment query lifecycle", () => {
1064 );
1065 });
1066
1068 -describe("Atom.fn mutation semantics", () => {
1069 - it.effect("interrupts the previous invocation when the same mutation atom is written again", () =>
1070 - Effect.gen(function* () {
1071 - const firstLatch = Latch.makeUnsafe();
1072 - const secondLatch = Latch.makeUnsafe();
1073 - const interrupted: string[] = [];
1074 - const mutation = Atom.fn((id: "first" | "second") =>
1075 - (id === "first" ? firstLatch : secondLatch).await.pipe(
1076 - Effect.as(id),
1077 - Effect.onInterrupt(() =>
1078 - Effect.sync(() => {
1079 - interrupted.push(id);
1080 - }),
1081 - ),
1082 - ),
1083 - );
1084 - const registry = AtomRegistry.make();
1085 - const unmount = registry.mount(mutation);
1086 -
1087 - registry.set(mutation, "first");
1088 - registry.set(mutation, "second");
1089 - yield* Effect.yieldNow;
1090 -
1091 - expect(interrupted).toEqual(["first"]);
1092 -
1093 - secondLatch.openUnsafe();
1094 - expect(
1095 - yield* AtomRegistry.getResult(registry, mutation, {
1096 - suspendOnWaiting: true,
1097 - }),
1098 - ).toBe("second");
1099 -
1100 - unmount();
1101 - registry.dispose();
1102 - }),
1103 - );
1104 -
1105 - it.effect("keeps stream mutations waiting until the final emitted value", () =>
1106 - Effect.gen(function* () {
1107 - const completionLatch = Latch.makeUnsafe();
1108 - const mutation = Atom.fn(() =>
1109 - Stream.make("progress").pipe(
1110 - Stream.concat(Stream.fromEffect(completionLatch.await.pipe(Effect.as("done")))),
1111 - ),
1112 - );
1113 - const registry = AtomRegistry.make();
1114 - const unmount = registry.mount(mutation);
1115 -
1116 - registry.set(mutation, undefined);
1117 -
1118 - const progress = registry.get(mutation);
1119 - expect(AsyncResult.isSuccess(progress)).toBe(true);
1120 - if (AsyncResult.isSuccess(progress)) {
1121 - expect(progress.value).toBe("progress");
1122 - expect(progress.waiting).toBe(true);
1123 - }
1124 -
1125 - completionLatch.openUnsafe();
1126 - expect(
1127 - yield* AtomRegistry.getResult(registry, mutation, {
1128 - suspendOnWaiting: true,
1129 - }),
1130 - ).toBe("done");
1131 -
1132 - unmount();
1133 - registry.dispose();
1134 - }),
1135 - );
1136 -
1137 - it.effect(
1138 - "allows concurrent effects to finish but does not correlate results to individual writes",
1139 - () =>
1140 - Effect.gen(function* () {
1141 - const firstLatch = Latch.makeUnsafe();
1142 - const secondLatch = Latch.makeUnsafe();
1143 - const mutation = Atom.fn<never, "first" | "second", "first" | "second">(
1144 - (id: "first" | "second") =>
1145 - (id === "first" ? firstLatch : secondLatch).await.pipe(Effect.as(id)),
1146 - { concurrent: true },
1147 - );
1148 - const registry = AtomRegistry.make();
1149 - const unmount = registry.mount(mutation);
1150 -
1151 - registry.set(mutation, "first");
1152 - const firstResult = yield* AtomRegistry.getResult(registry, mutation, {
1153 - suspendOnWaiting: true,
1154 - }).pipe(Effect.forkChild({ startImmediately: true }));
1155 - registry.set(mutation, "second");
1156 - const secondResult = yield* AtomRegistry.getResult(registry, mutation, {
1157 - suspendOnWaiting: true,
1158 - }).pipe(Effect.forkChild({ startImmediately: true }));
1159 -
1160 - secondLatch.openUnsafe();
1161 - yield* Effect.yieldNow;
1162 -
1163 - const stillWaiting = registry.get(mutation);
1164 - expect(stillWaiting.waiting).toBe(true);
1165 -
1166 - firstLatch.openUnsafe();
1167 -
1168 - expect(yield* Fiber.join(firstResult)).toBe("first");
1169 - expect(yield* Fiber.join(secondResult)).toBe("first");
1170 -
1171 - unmount();
1172 - registry.dispose();
1173 - }),
1174 - );
1175 -});
1176 -
1067 describe("executeAtomQuery", () => {
1068 it("keeps concurrent query results correlated to their atoms", async () => {
1069 const firstLatch = Latch.makeUnsafe();
packages/client-runtime/src/work-log/commandLabel.test.ts
+7 -6
@@ -163,13 +163,14 @@ describe("commandProgramName", () => {
163 expect(commandProgramName(command)).toBe(program);
164 });
165
166 - it.each(
167 - ["cd /tmp", "export CI=1", "unset DEBUG", "source env.sh", ". env.sh"].flatMap((setup) =>
168 - ["&&", " || ", ";", "\n", "|", " |& ", " & "].map(
169 - (operator) => [`${setup}${operator}npm test`, "npm"] as const,
170 - ),
166 + it.each([
167 + ...["&&", " || ", ";", "\n", "|", " |& ", " & "].map(
168 + (operator) => [`cd /tmp${operator}npm test`, "npm"] as const,
169 + ),
170 + ...["export CI=1", "unset DEBUG", "source env.sh", ". env.sh"].map(
171 + (setup) => [`${setup}&&npm test`, "npm"] as const,
172 ),
172 - )("handles shell setup followed by every command separator: %s", (command, program) => {
173 + ])("handles shell setup followed by every command separator: %s", (command, program) => {
174 expect(commandProgramName(command)).toBe(program);
175 });
176