test: remove redundant and stale tests (#6267)
This commit is contained in:
1 parent
d484735c64
commit
2773229337
11 files changed
-875
No files matched your search
@@ -5,7 +5,6 @@ import { HttpClient } from "effect/unstable/http";
|
||||
import { ChildProcessSpawner } from "effect/unstable/process";
|
||||
|
||||
import {
|
||||
isTailscaleIpv4Address,
|
||||
parseTailscaleMagicDnsName,
|
||||
resolveTailscaleAdvertisedEndpoints,
|
||||
} from "./tailscaleEndpointProvider.ts";
|
||||
@@ -22,13 +21,6 @@ const unusedTailscaleExternalServicesLayer = Layer.mergeAll(
|
||||
);
|
||||
|
||||
describe("tailscale endpoint provider", () => {
|
||||
it("detects Tailnet IPv4 addresses", () => {
|
||||
assert.equal(isTailscaleIpv4Address("100.64.0.1"), true);
|
||||
assert.equal(isTailscaleIpv4Address("100.127.255.254"), true);
|
||||
assert.equal(isTailscaleIpv4Address("100.128.0.1"), false);
|
||||
assert.equal(isTailscaleIpv4Address("192.168.1.44"), false);
|
||||
});
|
||||
|
||||
it.effect("parses MagicDNS names from tailscale status", () =>
|
||||
Effect.gen(function* () {
|
||||
const dnsName = yield* parseTailscaleMagicDnsName(
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { computeLabelPosition } from "./PickLabelPosition.ts";
|
||||
|
||||
const VIEWPORT = { viewportWidth: 1280, viewportHeight: 800 };
|
||||
|
||||
describe("computeLabelPosition", () => {
|
||||
it("anchors to the element's top-left when there's room above and to the right", () => {
|
||||
const { x, y } = computeLabelPosition({
|
||||
...VIEWPORT,
|
||||
targetLeft: 200,
|
||||
targetTop: 200,
|
||||
targetBottom: 240,
|
||||
labelWidth: 120,
|
||||
labelHeight: 18,
|
||||
});
|
||||
expect(x).toBe(200);
|
||||
// 200 (top) - 18 (height) - 4 (gap)
|
||||
expect(y).toBe(200 - 18 - 4);
|
||||
});
|
||||
|
||||
it("clamps left edge so the label stays inside the viewport", () => {
|
||||
const { x } = computeLabelPosition({
|
||||
...VIEWPORT,
|
||||
targetLeft: -50,
|
||||
targetTop: 200,
|
||||
targetBottom: 240,
|
||||
labelWidth: 120,
|
||||
labelHeight: 18,
|
||||
});
|
||||
expect(x).toBe(4);
|
||||
});
|
||||
|
||||
it("clamps right edge when the label would overflow the viewport (the bug we shipped)", () => {
|
||||
const { x } = computeLabelPosition({
|
||||
...VIEWPORT,
|
||||
targetLeft: 1240,
|
||||
targetTop: 200,
|
||||
targetBottom: 240,
|
||||
labelWidth: 200,
|
||||
labelHeight: 18,
|
||||
});
|
||||
// viewportWidth (1280) - labelWidth (200) - margin (4) = 1076
|
||||
expect(x).toBe(1076);
|
||||
});
|
||||
|
||||
it("flips the label below the element when there's no room above", () => {
|
||||
const { y } = computeLabelPosition({
|
||||
...VIEWPORT,
|
||||
targetLeft: 200,
|
||||
targetTop: 4,
|
||||
targetBottom: 44,
|
||||
labelWidth: 120,
|
||||
labelHeight: 18,
|
||||
});
|
||||
// labelY = 4 - 18 - 4 = -18 → flip → 44 + 4 = 48
|
||||
expect(y).toBe(48);
|
||||
});
|
||||
|
||||
it("pins to the bottom margin when the element fills the viewport (no room above OR below)", () => {
|
||||
const { y } = computeLabelPosition({
|
||||
...VIEWPORT,
|
||||
targetLeft: 200,
|
||||
targetTop: 0,
|
||||
targetBottom: 800,
|
||||
labelWidth: 120,
|
||||
labelHeight: 18,
|
||||
});
|
||||
// Above overflows top → flip below = 800 + 4 = 804 → also overflows
|
||||
// bottom → pin to viewportHeight - labelHeight - margin = 778.
|
||||
expect(y).toBe(800 - 18 - 4);
|
||||
});
|
||||
|
||||
it("never returns a negative coordinate", () => {
|
||||
const { x, y } = computeLabelPosition({
|
||||
...VIEWPORT,
|
||||
targetLeft: -1000,
|
||||
targetTop: -1000,
|
||||
targetBottom: -900,
|
||||
labelWidth: 5000,
|
||||
labelHeight: 5000,
|
||||
});
|
||||
expect(x).toBeGreaterThanOrEqual(0);
|
||||
expect(y).toBeGreaterThanOrEqual(0);
|
||||
});
|
||||
});
|
||||
@@ -8,7 +8,6 @@ import { getTerminalLabel } from "@t3tools/shared/terminalLabels";
|
||||
import {
|
||||
buildTerminalMenuSessions,
|
||||
nextOpenTerminalId,
|
||||
nextTerminalId,
|
||||
previousLiveTerminalId,
|
||||
resolveProjectScriptTerminalId,
|
||||
type TerminalMenuSession,
|
||||
@@ -125,16 +124,6 @@ describe("buildTerminalMenuSessions", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("nextTerminalId", () => {
|
||||
it("uses the primary id when no terminals are listed yet", () => {
|
||||
expect(nextTerminalId([])).toBe(DEFAULT_TERMINAL_ID);
|
||||
});
|
||||
|
||||
it("allocates term-2 when only the primary shell exists", () => {
|
||||
expect(nextTerminalId([DEFAULT_TERMINAL_ID])).toBe("term-2");
|
||||
});
|
||||
});
|
||||
|
||||
describe("nextOpenTerminalId", () => {
|
||||
it("matches nextTerminalId when not on a terminal route", () => {
|
||||
expect(nextOpenTerminalId({ listedTerminalIds: [] })).toBe(DEFAULT_TERMINAL_ID);
|
||||
|
||||
@@ -14,7 +14,6 @@ import * as Effect from "effect/Effect";
|
||||
import {
|
||||
findThreadById,
|
||||
listThreadsByProjectId,
|
||||
requireNonNegativeInteger,
|
||||
requireThread,
|
||||
requireThreadAbsent,
|
||||
} from "./commandInvariants.ts";
|
||||
@@ -200,24 +199,4 @@ describe("commandInvariants", () => {
|
||||
),
|
||||
).rejects.toThrow("already exists");
|
||||
});
|
||||
|
||||
it("requires non-negative integers", async () => {
|
||||
await Effect.runPromise(
|
||||
requireNonNegativeInteger({
|
||||
commandType: "thread.checkpoint.revert",
|
||||
field: "turnCount",
|
||||
value: 0,
|
||||
}),
|
||||
);
|
||||
|
||||
await expect(
|
||||
Effect.runPromise(
|
||||
requireNonNegativeInteger({
|
||||
commandType: "thread.checkpoint.revert",
|
||||
field: "turnCount",
|
||||
value: -1,
|
||||
}),
|
||||
),
|
||||
).rejects.toThrow("greater than or equal to 0");
|
||||
});
|
||||
});
|
||||
@@ -40,9 +40,7 @@ import { ProviderInstanceRegistryHydrationLive } from "./ProviderInstanceRegistr
|
||||
import {
|
||||
haveProvidersChanged,
|
||||
mergeProviderSnapshot,
|
||||
mergeProviderSnapshots,
|
||||
ProviderRegistryLive,
|
||||
selectProvidersByKind,
|
||||
} from "./ProviderRegistry.ts";
|
||||
import * as ServerConfig from "../../config.ts";
|
||||
import * as ServerSettingsModule from "../../serverSettings.ts";
|
||||
@@ -893,70 +891,6 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te
|
||||
}),
|
||||
);
|
||||
|
||||
it("persists merged provider snapshots for the providers that were refreshed", () => {
|
||||
const previousProviders = [
|
||||
{
|
||||
instanceId: ProviderInstanceId.make("cursor"),
|
||||
driver: ProviderDriverKind.make("cursor"),
|
||||
status: "ready",
|
||||
enabled: true,
|
||||
installed: true,
|
||||
auth: { status: "authenticated" },
|
||||
checkedAt: "2026-04-14T00:00:00.000Z",
|
||||
version: "2026.04.09-f2b0fcd",
|
||||
models: [
|
||||
{
|
||||
slug: "claude-opus-4-6",
|
||||
name: "Opus 4.6",
|
||||
isCustom: false,
|
||||
capabilities: createModelCapabilities({
|
||||
optionDescriptors: [
|
||||
selectDescriptor("reasoning", "Reasoning", [
|
||||
{ id: "high", label: "High", isDefault: true },
|
||||
]),
|
||||
booleanDescriptor("fastMode", "Fast Mode"),
|
||||
booleanDescriptor("thinking", "Thinking"),
|
||||
],
|
||||
}),
|
||||
},
|
||||
],
|
||||
slashCommands: [],
|
||||
skills: [],
|
||||
},
|
||||
{
|
||||
instanceId: ProviderInstanceId.make("codex"),
|
||||
driver: ProviderDriverKind.make("codex"),
|
||||
status: "ready",
|
||||
enabled: true,
|
||||
installed: true,
|
||||
auth: { status: "authenticated" },
|
||||
checkedAt: "2026-04-14T00:00:00.000Z",
|
||||
version: "1.0.0",
|
||||
models: [],
|
||||
slashCommands: [],
|
||||
skills: [],
|
||||
},
|
||||
] as const satisfies ReadonlyArray<ServerProvider>;
|
||||
const refreshedCursor = {
|
||||
...previousProviders[0],
|
||||
checkedAt: "2026-04-14T00:01:00.000Z",
|
||||
models: [],
|
||||
} satisfies ServerProvider;
|
||||
|
||||
const mergedProviders = mergeProviderSnapshots(previousProviders, [refreshedCursor]);
|
||||
const persistedProviders = selectProvidersByKind(
|
||||
mergedProviders,
|
||||
new Set([ProviderDriverKind.make("cursor")]),
|
||||
);
|
||||
|
||||
assert.deepStrictEqual(persistedProviders, [
|
||||
{
|
||||
...refreshedCursor,
|
||||
models: [...previousProviders[0].models],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it.effect("persists the merged snapshot when a live update has empty models", () =>
|
||||
Effect.gen(function* () {
|
||||
const cursorDriver = ProviderDriverKind.make("cursor");
|
||||
|
||||
@@ -1,139 +0,0 @@
|
||||
import { MessageId } from "@t3tools/contracts";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { buildBootstrapInput } from "./historyBootstrap";
|
||||
|
||||
const messageId = (value: string) => MessageId.make(value);
|
||||
|
||||
describe("buildBootstrapInput", () => {
|
||||
it("includes full transcript when under budget", () => {
|
||||
const result = buildBootstrapInput(
|
||||
[
|
||||
{
|
||||
id: messageId("u-1"),
|
||||
role: "user",
|
||||
text: "hello",
|
||||
createdAt: "2026-02-09T00:00:00.000Z",
|
||||
turnId: null,
|
||||
updatedAt: "2026-02-09T00:00:00.000Z",
|
||||
streaming: false,
|
||||
},
|
||||
{
|
||||
id: messageId("a-1"),
|
||||
role: "assistant",
|
||||
text: "world",
|
||||
createdAt: "2026-02-09T00:00:01.000Z",
|
||||
turnId: null,
|
||||
updatedAt: "2026-02-09T00:00:01.000Z",
|
||||
streaming: false,
|
||||
},
|
||||
],
|
||||
"what's next?",
|
||||
1_500,
|
||||
);
|
||||
|
||||
expect(result.includedCount).toBe(2);
|
||||
expect(result.omittedCount).toBe(0);
|
||||
expect(result.truncated).toBe(false);
|
||||
expect(result.text).toContain("USER:\nhello");
|
||||
expect(result.text).toContain("ASSISTANT:\nworld");
|
||||
expect(result.text).toContain("Latest user request (answer this now):");
|
||||
expect(result.text).toContain("what's next?");
|
||||
});
|
||||
|
||||
it("truncates older transcript messages when over budget", () => {
|
||||
const result = buildBootstrapInput(
|
||||
[
|
||||
{
|
||||
id: messageId("u-1"),
|
||||
role: "user",
|
||||
text: "first question with details",
|
||||
createdAt: "2026-02-09T00:00:00.000Z",
|
||||
turnId: null,
|
||||
updatedAt: "2026-02-09T00:00:00.000Z",
|
||||
streaming: false,
|
||||
},
|
||||
{
|
||||
id: messageId("a-1"),
|
||||
role: "assistant",
|
||||
text: "first answer with details",
|
||||
createdAt: "2026-02-09T00:00:01.000Z",
|
||||
turnId: null,
|
||||
updatedAt: "2026-02-09T00:00:01.000Z",
|
||||
streaming: false,
|
||||
},
|
||||
{
|
||||
id: messageId("u-2"),
|
||||
role: "user",
|
||||
text: "second question with details",
|
||||
createdAt: "2026-02-09T00:00:02.000Z",
|
||||
turnId: null,
|
||||
updatedAt: "2026-02-09T00:00:02.000Z",
|
||||
streaming: false,
|
||||
},
|
||||
],
|
||||
"final request",
|
||||
320,
|
||||
);
|
||||
|
||||
expect(result.truncated).toBe(true);
|
||||
expect(result.omittedCount).toBeGreaterThan(0);
|
||||
expect(result.includedCount).toBeLessThan(3);
|
||||
expect(result.text).toContain("omitted to stay within input limits");
|
||||
expect(result.text.length).toBeLessThanOrEqual(320);
|
||||
});
|
||||
|
||||
it("preserves the latest prompt when prompt-only fallback is required", () => {
|
||||
const latestPrompt = "Please keep this exact latest prompt.";
|
||||
const result = buildBootstrapInput(
|
||||
[
|
||||
{
|
||||
id: messageId("u-1"),
|
||||
role: "user",
|
||||
text: "old context",
|
||||
createdAt: "2026-02-09T00:00:00.000Z",
|
||||
turnId: null,
|
||||
updatedAt: "2026-02-09T00:00:00.000Z",
|
||||
streaming: false,
|
||||
},
|
||||
],
|
||||
latestPrompt,
|
||||
latestPrompt.length + 3,
|
||||
);
|
||||
|
||||
expect(result.text).toBe(latestPrompt);
|
||||
expect(result.includedCount).toBe(0);
|
||||
expect(result.omittedCount).toBe(1);
|
||||
expect(result.truncated).toBe(true);
|
||||
});
|
||||
|
||||
it("captures user image attachment context in transcript blocks", () => {
|
||||
const result = buildBootstrapInput(
|
||||
[
|
||||
{
|
||||
id: messageId("u-image"),
|
||||
role: "user",
|
||||
text: "",
|
||||
attachments: [
|
||||
{
|
||||
type: "image",
|
||||
id: "img-1",
|
||||
name: "screenshot.png",
|
||||
mimeType: "image/png",
|
||||
sizeBytes: 2_048,
|
||||
},
|
||||
],
|
||||
createdAt: "2026-02-09T00:00:00.000Z",
|
||||
turnId: null,
|
||||
updatedAt: "2026-02-09T00:00:00.000Z",
|
||||
streaming: false,
|
||||
},
|
||||
],
|
||||
"What does this error mean?",
|
||||
1_500,
|
||||
);
|
||||
|
||||
expect(result.text).toContain("Attached image");
|
||||
expect(result.text).toContain("screenshot.png");
|
||||
});
|
||||
});
|
||||
@@ -1,65 +0,0 @@
|
||||
import { scopedThreadKey, scopeThreadRef } from "@t3tools/client-runtime/environment";
|
||||
import { ThreadId } from "@t3tools/contracts";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { collectActiveTerminalUiThreadKeys } from "./terminalUiStateCleanup";
|
||||
|
||||
const threadId = (id: string): ThreadId => ThreadId.make(id);
|
||||
const threadKey = (environmentId: string, id: string): string =>
|
||||
scopedThreadKey(scopeThreadRef(environmentId as never, threadId(id)));
|
||||
|
||||
describe("collectActiveTerminalUiThreadKeys", () => {
|
||||
it("retains non-deleted server threads", () => {
|
||||
const activeThreadKeys = collectActiveTerminalUiThreadKeys({
|
||||
snapshotThreads: [
|
||||
{ key: threadKey("env-a", "server-1"), deletedAt: null, archivedAt: null },
|
||||
{ key: threadKey("env-b", "server-2"), deletedAt: null, archivedAt: null },
|
||||
],
|
||||
draftThreadKeys: [],
|
||||
});
|
||||
|
||||
expect(activeThreadKeys).toEqual(
|
||||
new Set([threadKey("env-a", "server-1"), threadKey("env-b", "server-2")]),
|
||||
);
|
||||
});
|
||||
|
||||
it("ignores deleted and archived server threads and keeps local draft threads", () => {
|
||||
const activeThreadKeys = collectActiveTerminalUiThreadKeys({
|
||||
snapshotThreads: [
|
||||
{ key: threadKey("env-a", "server-active"), deletedAt: null, archivedAt: null },
|
||||
{
|
||||
key: threadKey("env-a", "server-deleted"),
|
||||
deletedAt: "2026-03-05T08:00:00.000Z",
|
||||
archivedAt: null,
|
||||
},
|
||||
{
|
||||
key: threadKey("env-a", "server-archived"),
|
||||
deletedAt: null,
|
||||
archivedAt: "2026-03-05T09:00:00.000Z",
|
||||
},
|
||||
],
|
||||
draftThreadKeys: [threadKey("env-a", "local-draft")],
|
||||
});
|
||||
|
||||
expect(activeThreadKeys).toEqual(
|
||||
new Set([threadKey("env-a", "server-active"), threadKey("env-a", "local-draft")]),
|
||||
);
|
||||
});
|
||||
|
||||
it("does not keep draft-linked terminal UI state for archived server threads", () => {
|
||||
const archivedThreadId = threadKey("env-a", "server-archived");
|
||||
|
||||
const activeThreadKeys = collectActiveTerminalUiThreadKeys({
|
||||
snapshotThreads: [
|
||||
{
|
||||
key: archivedThreadId,
|
||||
deletedAt: null,
|
||||
archivedAt: "2026-03-05T09:00:00.000Z",
|
||||
},
|
||||
],
|
||||
draftThreadKeys: [archivedThreadId, threadKey("env-a", "local-draft")],
|
||||
});
|
||||
|
||||
expect(activeThreadKeys).toEqual(new Set([threadKey("env-a", "local-draft")]));
|
||||
});
|
||||
});
|
||||
@@ -1,135 +0,0 @@
|
||||
import {
|
||||
CheckpointRef,
|
||||
EventId,
|
||||
MessageId,
|
||||
ProjectId,
|
||||
ProviderInstanceId,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
type OrchestrationEvent,
|
||||
} from "@t3tools/contracts";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { deriveOrchestrationBatchEffects } from "./orchestrationEventEffects";
|
||||
|
||||
function makeEvent<T extends OrchestrationEvent["type"]>(
|
||||
type: T,
|
||||
payload: Extract<OrchestrationEvent, { type: T }>["payload"],
|
||||
overrides: Partial<Extract<OrchestrationEvent, { type: T }>> = {},
|
||||
): Extract<OrchestrationEvent, { type: T }> {
|
||||
const sequence = overrides.sequence ?? 1;
|
||||
return {
|
||||
sequence,
|
||||
eventId: EventId.make(`event-${sequence}`),
|
||||
aggregateKind: "thread",
|
||||
aggregateId:
|
||||
"threadId" in payload
|
||||
? payload.threadId
|
||||
: "projectId" in payload
|
||||
? payload.projectId
|
||||
: ProjectId.make("project-1"),
|
||||
occurredAt: "2026-02-27T00:00:00.000Z",
|
||||
commandId: null,
|
||||
causationEventId: null,
|
||||
correlationId: null,
|
||||
metadata: {},
|
||||
type,
|
||||
payload,
|
||||
...overrides,
|
||||
} as Extract<OrchestrationEvent, { type: T }>;
|
||||
}
|
||||
|
||||
describe("deriveOrchestrationBatchEffects", () => {
|
||||
it("targets draft promotion and terminal cleanup from thread lifecycle events", () => {
|
||||
const createdThreadId = ThreadId.make("thread-created");
|
||||
const deletedThreadId = ThreadId.make("thread-deleted");
|
||||
const archivedThreadId = ThreadId.make("thread-archived");
|
||||
|
||||
const effects = deriveOrchestrationBatchEffects([
|
||||
makeEvent("thread.created", {
|
||||
threadId: createdThreadId,
|
||||
projectId: ProjectId.make("project-1"),
|
||||
title: "Created thread",
|
||||
modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5-codex" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: "2026-02-27T00:00:00.000Z",
|
||||
updatedAt: "2026-02-27T00:00:00.000Z",
|
||||
}),
|
||||
makeEvent("thread.deleted", {
|
||||
threadId: deletedThreadId,
|
||||
deletedAt: "2026-02-27T00:00:01.000Z",
|
||||
}),
|
||||
makeEvent("thread.archived", {
|
||||
threadId: archivedThreadId,
|
||||
archivedAt: "2026-02-27T00:00:02.000Z",
|
||||
updatedAt: "2026-02-27T00:00:02.000Z",
|
||||
}),
|
||||
]);
|
||||
|
||||
expect(effects.promoteDraftThreadIds).toEqual([createdThreadId]);
|
||||
expect(effects.clearDeletedThreadIds).toEqual([deletedThreadId]);
|
||||
expect(effects.removeTerminalUiStateThreadIds).toEqual([deletedThreadId, archivedThreadId]);
|
||||
expect(effects.needsProviderInvalidation).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps only the final lifecycle outcome for a thread within one batch", () => {
|
||||
const threadId = ThreadId.make("thread-1");
|
||||
|
||||
const effects = deriveOrchestrationBatchEffects([
|
||||
makeEvent("thread.deleted", {
|
||||
threadId,
|
||||
deletedAt: "2026-02-27T00:00:01.000Z",
|
||||
}),
|
||||
makeEvent("thread.created", {
|
||||
threadId,
|
||||
projectId: ProjectId.make("project-1"),
|
||||
title: "Recreated thread",
|
||||
modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5-codex" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: "2026-02-27T00:00:02.000Z",
|
||||
updatedAt: "2026-02-27T00:00:02.000Z",
|
||||
}),
|
||||
makeEvent("thread.turn-diff-completed", {
|
||||
threadId,
|
||||
turnId: TurnId.make("turn-1"),
|
||||
checkpointTurnCount: 1,
|
||||
checkpointRef: CheckpointRef.make("checkpoint-1"),
|
||||
status: "ready",
|
||||
files: [],
|
||||
assistantMessageId: MessageId.make("assistant-1"),
|
||||
completedAt: "2026-02-27T00:00:03.000Z",
|
||||
}),
|
||||
]);
|
||||
|
||||
expect(effects.promoteDraftThreadIds).toEqual([threadId]);
|
||||
expect(effects.clearDeletedThreadIds).toEqual([]);
|
||||
expect(effects.removeTerminalUiStateThreadIds).toEqual([]);
|
||||
expect(effects.needsProviderInvalidation).toBe(true);
|
||||
});
|
||||
|
||||
it("does not retain archive cleanup when a thread is unarchived later in the same batch", () => {
|
||||
const threadId = ThreadId.make("thread-1");
|
||||
|
||||
const effects = deriveOrchestrationBatchEffects([
|
||||
makeEvent("thread.archived", {
|
||||
threadId,
|
||||
archivedAt: "2026-02-27T00:00:01.000Z",
|
||||
updatedAt: "2026-02-27T00:00:01.000Z",
|
||||
}),
|
||||
makeEvent("thread.unarchived", {
|
||||
threadId,
|
||||
updatedAt: "2026-02-27T00:00:02.000Z",
|
||||
}),
|
||||
]);
|
||||
|
||||
expect(effects.promoteDraftThreadIds).toEqual([]);
|
||||
expect(effects.clearDeletedThreadIds).toEqual([]);
|
||||
expect(effects.removeTerminalUiStateThreadIds).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -1,306 +0,0 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
createOrchestrationRecoveryCoordinator,
|
||||
deriveReplayRetryDecision,
|
||||
} from "./orchestrationRecovery";
|
||||
|
||||
describe("createOrchestrationRecoveryCoordinator", () => {
|
||||
it("defers live events until bootstrap completes and then requests replay", () => {
|
||||
const coordinator = createOrchestrationRecoveryCoordinator();
|
||||
|
||||
expect(coordinator.beginSnapshotRecovery("bootstrap")).toBe(true);
|
||||
expect(coordinator.classifyDomainEvent(4)).toBe("defer");
|
||||
|
||||
expect(coordinator.completeSnapshotRecovery(2)).toBe(true);
|
||||
expect(coordinator.getState()).toMatchObject({
|
||||
latestSequence: 2,
|
||||
highestObservedSequence: 4,
|
||||
bootstrapped: true,
|
||||
pendingReplay: false,
|
||||
inFlight: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("classifies sequence gaps as recovery-only replay work", () => {
|
||||
const coordinator = createOrchestrationRecoveryCoordinator();
|
||||
|
||||
coordinator.beginSnapshotRecovery("bootstrap");
|
||||
coordinator.completeSnapshotRecovery(3);
|
||||
|
||||
expect(coordinator.classifyDomainEvent(5)).toBe("recover");
|
||||
expect(coordinator.beginReplayRecovery("sequence-gap")).toBe(true);
|
||||
expect(coordinator.getState().inFlight).toEqual({
|
||||
kind: "replay",
|
||||
reason: "sequence-gap",
|
||||
});
|
||||
});
|
||||
|
||||
it("tracks live event batches without entering recovery", () => {
|
||||
const coordinator = createOrchestrationRecoveryCoordinator();
|
||||
|
||||
coordinator.beginSnapshotRecovery("bootstrap");
|
||||
coordinator.completeSnapshotRecovery(3);
|
||||
|
||||
expect(coordinator.classifyDomainEvent(4)).toBe("apply");
|
||||
expect(coordinator.markEventBatchApplied([{ sequence: 4 }])).toEqual([{ sequence: 4 }]);
|
||||
expect(coordinator.getState()).toMatchObject({
|
||||
latestSequence: 4,
|
||||
highestObservedSequence: 4,
|
||||
bootstrapped: true,
|
||||
inFlight: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("requests another replay when deferred events arrive during replay recovery", () => {
|
||||
const coordinator = createOrchestrationRecoveryCoordinator();
|
||||
|
||||
coordinator.beginSnapshotRecovery("bootstrap");
|
||||
coordinator.completeSnapshotRecovery(3);
|
||||
coordinator.classifyDomainEvent(5);
|
||||
coordinator.beginReplayRecovery("sequence-gap");
|
||||
coordinator.classifyDomainEvent(7);
|
||||
coordinator.markEventBatchApplied([{ sequence: 4 }, { sequence: 5 }, { sequence: 6 }]);
|
||||
|
||||
expect(coordinator.completeReplayRecovery()).toEqual({
|
||||
replayMadeProgress: true,
|
||||
shouldReplay: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("retries replay when no progress was made but higher live sequences were observed", () => {
|
||||
const coordinator = createOrchestrationRecoveryCoordinator();
|
||||
|
||||
coordinator.beginSnapshotRecovery("bootstrap");
|
||||
coordinator.completeSnapshotRecovery(3);
|
||||
coordinator.classifyDomainEvent(5);
|
||||
coordinator.beginReplayRecovery("sequence-gap");
|
||||
|
||||
expect(coordinator.completeReplayRecovery()).toEqual({
|
||||
replayMadeProgress: false,
|
||||
shouldReplay: true,
|
||||
});
|
||||
expect(coordinator.getState()).toMatchObject({
|
||||
latestSequence: 3,
|
||||
highestObservedSequence: 5,
|
||||
pendingReplay: false,
|
||||
inFlight: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("does not request another replay when a replay made no progress and nothing newer was observed", () => {
|
||||
const coordinator = createOrchestrationRecoveryCoordinator();
|
||||
|
||||
coordinator.beginSnapshotRecovery("bootstrap");
|
||||
coordinator.completeSnapshotRecovery(3);
|
||||
coordinator.beginReplayRecovery("sequence-gap");
|
||||
|
||||
expect(coordinator.completeReplayRecovery()).toEqual({
|
||||
replayMadeProgress: false,
|
||||
shouldReplay: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("marks replay failure as unbootstrapped so snapshot fallback is recovery-only", () => {
|
||||
const coordinator = createOrchestrationRecoveryCoordinator();
|
||||
|
||||
coordinator.beginSnapshotRecovery("bootstrap");
|
||||
coordinator.completeSnapshotRecovery(3);
|
||||
coordinator.beginReplayRecovery("sequence-gap");
|
||||
coordinator.failReplayRecovery();
|
||||
|
||||
expect(coordinator.getState()).toMatchObject({
|
||||
bootstrapped: false,
|
||||
inFlight: null,
|
||||
});
|
||||
expect(coordinator.beginSnapshotRecovery("replay-failed")).toBe(true);
|
||||
expect(coordinator.getState().inFlight).toEqual({
|
||||
kind: "snapshot",
|
||||
reason: "replay-failed",
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps enough state to explain why bootstrap snapshot recovery requests replay", () => {
|
||||
const coordinator = createOrchestrationRecoveryCoordinator();
|
||||
|
||||
expect(coordinator.beginSnapshotRecovery("bootstrap")).toBe(true);
|
||||
expect(coordinator.classifyDomainEvent(4)).toBe("defer");
|
||||
expect(coordinator.completeSnapshotRecovery(2)).toBe(true);
|
||||
|
||||
expect(coordinator.getState()).toMatchObject({
|
||||
latestSequence: 2,
|
||||
highestObservedSequence: 4,
|
||||
bootstrapped: true,
|
||||
pendingReplay: false,
|
||||
inFlight: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("reports skip state when snapshot recovery is requested while replay is in flight", () => {
|
||||
const coordinator = createOrchestrationRecoveryCoordinator();
|
||||
|
||||
coordinator.beginSnapshotRecovery("bootstrap");
|
||||
coordinator.completeSnapshotRecovery(3);
|
||||
expect(coordinator.beginReplayRecovery("sequence-gap")).toBe(true);
|
||||
|
||||
expect(coordinator.beginSnapshotRecovery("bootstrap")).toBe(false);
|
||||
expect(coordinator.getState()).toMatchObject({
|
||||
pendingReplay: true,
|
||||
inFlight: {
|
||||
kind: "replay",
|
||||
reason: "sequence-gap",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("deriveReplayRetryDecision", () => {
|
||||
it("retries immediately when replay made progress", () => {
|
||||
expect(
|
||||
deriveReplayRetryDecision({
|
||||
previousTracker: {
|
||||
attempts: 2,
|
||||
latestSequence: 3,
|
||||
highestObservedSequence: 5,
|
||||
},
|
||||
completion: {
|
||||
replayMadeProgress: true,
|
||||
shouldReplay: true,
|
||||
},
|
||||
recoveryState: {
|
||||
latestSequence: 5,
|
||||
highestObservedSequence: 5,
|
||||
},
|
||||
baseDelayMs: 100,
|
||||
maxNoProgressRetries: 3,
|
||||
}),
|
||||
).toEqual({
|
||||
shouldRetry: true,
|
||||
delayMs: 0,
|
||||
tracker: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("caps no-progress retries for the same frontier", () => {
|
||||
const first = deriveReplayRetryDecision({
|
||||
previousTracker: null,
|
||||
completion: {
|
||||
replayMadeProgress: false,
|
||||
shouldReplay: true,
|
||||
},
|
||||
recoveryState: {
|
||||
latestSequence: 3,
|
||||
highestObservedSequence: 5,
|
||||
},
|
||||
baseDelayMs: 100,
|
||||
maxNoProgressRetries: 3,
|
||||
});
|
||||
|
||||
const second = deriveReplayRetryDecision({
|
||||
previousTracker: first.tracker,
|
||||
completion: {
|
||||
replayMadeProgress: false,
|
||||
shouldReplay: true,
|
||||
},
|
||||
recoveryState: {
|
||||
latestSequence: 3,
|
||||
highestObservedSequence: 5,
|
||||
},
|
||||
baseDelayMs: 100,
|
||||
maxNoProgressRetries: 3,
|
||||
});
|
||||
|
||||
const third = deriveReplayRetryDecision({
|
||||
previousTracker: second.tracker,
|
||||
completion: {
|
||||
replayMadeProgress: false,
|
||||
shouldReplay: true,
|
||||
},
|
||||
recoveryState: {
|
||||
latestSequence: 3,
|
||||
highestObservedSequence: 5,
|
||||
},
|
||||
baseDelayMs: 100,
|
||||
maxNoProgressRetries: 3,
|
||||
});
|
||||
|
||||
const fourth = deriveReplayRetryDecision({
|
||||
previousTracker: third.tracker,
|
||||
completion: {
|
||||
replayMadeProgress: false,
|
||||
shouldReplay: true,
|
||||
},
|
||||
recoveryState: {
|
||||
latestSequence: 3,
|
||||
highestObservedSequence: 5,
|
||||
},
|
||||
baseDelayMs: 100,
|
||||
maxNoProgressRetries: 3,
|
||||
});
|
||||
|
||||
expect(first).toEqual({
|
||||
shouldRetry: true,
|
||||
delayMs: 100,
|
||||
tracker: {
|
||||
attempts: 1,
|
||||
latestSequence: 3,
|
||||
highestObservedSequence: 5,
|
||||
},
|
||||
});
|
||||
expect(second).toEqual({
|
||||
shouldRetry: true,
|
||||
delayMs: 200,
|
||||
tracker: {
|
||||
attempts: 2,
|
||||
latestSequence: 3,
|
||||
highestObservedSequence: 5,
|
||||
},
|
||||
});
|
||||
expect(third).toEqual({
|
||||
shouldRetry: true,
|
||||
delayMs: 400,
|
||||
tracker: {
|
||||
attempts: 3,
|
||||
latestSequence: 3,
|
||||
highestObservedSequence: 5,
|
||||
},
|
||||
});
|
||||
expect(fourth).toEqual({
|
||||
shouldRetry: false,
|
||||
delayMs: 0,
|
||||
tracker: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("resets the retry budget when the replay frontier changes", () => {
|
||||
const exhausted = {
|
||||
attempts: 3,
|
||||
latestSequence: 3,
|
||||
highestObservedSequence: 5,
|
||||
};
|
||||
|
||||
expect(
|
||||
deriveReplayRetryDecision({
|
||||
previousTracker: exhausted,
|
||||
completion: {
|
||||
replayMadeProgress: false,
|
||||
shouldReplay: true,
|
||||
},
|
||||
recoveryState: {
|
||||
latestSequence: 3,
|
||||
highestObservedSequence: 6,
|
||||
},
|
||||
baseDelayMs: 100,
|
||||
maxNoProgressRetries: 3,
|
||||
}),
|
||||
).toEqual({
|
||||
shouldRetry: true,
|
||||
delayMs: 100,
|
||||
tracker: {
|
||||
attempts: 1,
|
||||
latestSequence: 3,
|
||||
highestObservedSequence: 6,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
missingRelayPublicConfigFields,
|
||||
publicConfigFromOutput,
|
||||
reconcileRootEnvPublicConfig,
|
||||
reconcileRootEnvRelayUrl,
|
||||
RelayDeployError,
|
||||
RelayDeployPublicConfigUnavailableError,
|
||||
serializeGithubOutput,
|
||||
@@ -87,25 +86,6 @@ describe("hasDeployChanges", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("reconcileRootEnvRelayUrl", () => {
|
||||
it("adds the relay URL to an empty root env file", () => {
|
||||
expect(reconcileRootEnvRelayUrl("", "https://relay.example.test")).toBe(
|
||||
"T3CODE_RELAY_URL=https://relay.example.test\n",
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves unrelated root env entries while replacing a previous relay URL", () => {
|
||||
expect(
|
||||
reconcileRootEnvRelayUrl(
|
||||
"T3CODE_CLERK_PUBLISHABLE_KEY=pk_test_example\nT3CODE_RELAY_URL=https://old.example.test\n",
|
||||
"https://relay.example.test",
|
||||
),
|
||||
).toBe(
|
||||
"T3CODE_CLERK_PUBLISHABLE_KEY=pk_test_example\nT3CODE_RELAY_URL=https://relay.example.test\n",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("reconcileRootEnvPublicConfig", () => {
|
||||
const config = {
|
||||
relayUrl: "https://relay.example.test",
|
||||
|
||||
@@ -22,7 +22,6 @@ import {
|
||||
resolveAndroidSdkRoot,
|
||||
selectLanIpv4Address,
|
||||
showcaseCaptureDirectory,
|
||||
showcaseSceneUrl,
|
||||
validateStoreAsset,
|
||||
validateStoreAssetCount,
|
||||
} from "./mobile-showcase.ts";
|
||||
@@ -244,23 +243,6 @@ it("selects a reachable LAN IPv4 address", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("maps capture scenes to the real application routes", () => {
|
||||
assert.equal(showcaseSceneUrl("threads", "environment-1"), "t3code://");
|
||||
assert.equal(showcaseSceneUrl("environments", "environment-1"), "t3code://settings/environments");
|
||||
assert.equal(
|
||||
showcaseSceneUrl("thread", "environment-1"),
|
||||
"t3code://threads/environment-1/remote-command-center",
|
||||
);
|
||||
assert.equal(
|
||||
showcaseSceneUrl("terminal", "environment-1"),
|
||||
"t3code://threads/environment-1/remote-command-center/terminal?terminalId=term-1",
|
||||
);
|
||||
assert.equal(
|
||||
showcaseSceneUrl("review", "environment-1"),
|
||||
"t3code://threads/environment-1/remote-command-center/review",
|
||||
);
|
||||
});
|
||||
|
||||
it("seeds a playful multi-environment project spectrum", () => {
|
||||
assert.deepStrictEqual(
|
||||
SHOWCASE_PROJECTS.map((project) => project.title),
|
||||
|
||||
Reference in new issue
Block a user