Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d90d516bd | ||
|
|
881c64937a |
No files matched your search
+2
-2
@@ -1,13 +1,13 @@
|
||||
# Scripts
|
||||
|
||||
- `bun run dev` — Starts contracts, server, and web in `turbo watch` mode.
|
||||
- `bun run dev` — Starts contracts, server, and web in workspace dev mode.
|
||||
- `bun run dev:server` — Starts just the WebSocket server (uses Bun TypeScript execution).
|
||||
- `bun run dev:web` — Starts just the Vite dev server for the web app.
|
||||
- Dev commands default `T3CODE_STATE_DIR` to `~/.t3/dev` to keep dev state isolated from desktop/prod state.
|
||||
- Override server CLI-equivalent flags from root dev commands with `--`, for example:
|
||||
`bun run dev -- --base-dir ~/.t3-2`
|
||||
- `bun run start` — Runs the production server (serves built web app as static files).
|
||||
- `bun run build` — Builds contracts, web app, and server through Turbo.
|
||||
- `bun run build` — Builds workspace packages and apps through Vite+ task running.
|
||||
- `bun run typecheck` — Strict TypeScript checks for all packages.
|
||||
- `bun run test` — Runs workspace tests.
|
||||
- `bun run dist:desktop:artifact -- --platform <mac|linux|win> --target <target> --arch <arch>` — Builds a desktop artifact for a specific platform/target/arch.
|
||||
|
||||
@@ -24,13 +24,11 @@ jobs:
|
||||
with:
|
||||
node-version-file: package.json
|
||||
|
||||
- name: Cache Bun and Turbo
|
||||
- name: Cache Bun
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: |
|
||||
~/.bun/install/cache
|
||||
.turbo
|
||||
key: ${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}-${{ hashFiles('turbo.json') }}
|
||||
path: ~/.bun/install/cache
|
||||
key: ${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}-
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"$schema": "./node_modules/oxfmt/configuration_schema.json",
|
||||
"ignorePatterns": [
|
||||
".plans",
|
||||
"dist",
|
||||
"dist-electron",
|
||||
"node_modules",
|
||||
"bun.lock",
|
||||
"*.tsbuildinfo",
|
||||
"**/routeTree.gen.ts",
|
||||
"apps/web/public/mockServiceWorker.js"
|
||||
],
|
||||
"sortPackageJson": {}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
||||
"ignorePatterns": [
|
||||
"dist",
|
||||
"dist-electron",
|
||||
"node_modules",
|
||||
"bun.lock",
|
||||
"*.tsbuildinfo",
|
||||
"**/routeTree.gen.ts"
|
||||
],
|
||||
"plugins": ["eslint", "oxc", "react", "unicorn", "typescript"],
|
||||
"categories": {
|
||||
"correctness": "warn",
|
||||
"suspicious": "warn",
|
||||
"perf": "warn"
|
||||
},
|
||||
"rules": {
|
||||
"react-in-jsx-scope": "off",
|
||||
"eslint/no-shadow": "off",
|
||||
"eslint/no-await-in-loop": "off"
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,12 @@
|
||||
"main": "dist-electron/main.js",
|
||||
"scripts": {
|
||||
"dev": "bun run --parallel dev:bundle dev:electron",
|
||||
"dev:bundle": "tsdown --watch",
|
||||
"dev:bundle": "vp pack --watch",
|
||||
"dev:electron": "bun run scripts/dev-electron.mjs",
|
||||
"build": "tsdown",
|
||||
"build": "vp pack",
|
||||
"start": "bun run scripts/start-electron.mjs",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run --passWithNoTests",
|
||||
"test": "vp test run --passWithNoTests",
|
||||
"smoke-test": "node scripts/smoke-test.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -22,9 +22,8 @@
|
||||
"@t3tools/contracts": "workspace:*",
|
||||
"@t3tools/shared": "workspace:*",
|
||||
"@types/node": "catalog:",
|
||||
"tsdown": "catalog:",
|
||||
"typescript": "catalog:",
|
||||
"vitest": "catalog:"
|
||||
"vite-plus": "catalog:"
|
||||
},
|
||||
"productName": "T3 Code (Alpha)"
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { BrowserWindow } from "electron";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeEach, describe, expect, it, vi } from "vite-plus/test";
|
||||
|
||||
const { showMessageBoxMock } = vi.hoisted(() => ({
|
||||
showMessageBoxMock: vi.fn(),
|
||||
|
||||
@@ -99,7 +99,7 @@ let destructiveMenuIconCache: Electron.NativeImage | null | undefined;
|
||||
const desktopRuntimeInfo = resolveDesktopRuntimeInfo({
|
||||
platform: process.platform,
|
||||
processArch: process.arch,
|
||||
runningUnderArm64Translation: app.runningUnderARM64Translation === true,
|
||||
runningUnderArm64Translation: app.runningUnderARM64Translation,
|
||||
});
|
||||
const initialUpdateState = (): DesktopUpdateState =>
|
||||
createInitialDesktopUpdateState(app.getVersion(), desktopRuntimeInfo);
|
||||
|
||||
@@ -3,7 +3,7 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
import { RotatingFileSink } from "@t3tools/shared/logging";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { afterEach, describe, expect, it } from "vite-plus/test";
|
||||
|
||||
const tempRoots: string[] = [];
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { isArm64HostRunningIntelBuild, resolveDesktopRuntimeInfo } from "./runtimeArch";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { describe, expect, it, vi } from "vite-plus/test";
|
||||
|
||||
import { syncShellEnvironment } from "./syncShellEnvironment";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
createInitialDesktopUpdateState,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
import type { DesktopUpdateState } from "@t3tools/contracts";
|
||||
|
||||
import {
|
||||
|
||||
@@ -5,5 +5,6 @@
|
||||
"types": ["node", "electron"],
|
||||
"lib": ["ES2023", "DOM", "esnext.disposable"]
|
||||
},
|
||||
"include": ["src", "tsdown.config.ts"]
|
||||
"include": ["src", "vite.config.ts", "../../packages/contracts/src", "../../packages/shared/src"],
|
||||
"exclude": ["../../packages/contracts/src/**/*.test.ts", "../../packages/shared/src/**/*.test.ts"]
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import { defineConfig } from "tsdown";
|
||||
|
||||
const shared = {
|
||||
format: "cjs" as const,
|
||||
outDir: "dist-electron",
|
||||
sourcemap: true,
|
||||
outExtensions: () => ({ js: ".js" }),
|
||||
};
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
...shared,
|
||||
entry: ["src/main.ts"],
|
||||
clean: true,
|
||||
noExternal: (id) => id.startsWith("@t3tools/"),
|
||||
},
|
||||
{
|
||||
...shared,
|
||||
entry: ["src/preload.ts"],
|
||||
},
|
||||
]);
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"$schema": "https://turbo.build/schema.json",
|
||||
"extends": ["//"],
|
||||
"tasks": {
|
||||
"build": {
|
||||
"dependsOn": ["^build"],
|
||||
"outputs": ["dist-electron/**"],
|
||||
},
|
||||
"dev": {
|
||||
"dependsOn": ["t3#build"],
|
||||
"persistent": true,
|
||||
},
|
||||
"start": {
|
||||
"dependsOn": ["build", "@t3tools/web#build", "t3#build"],
|
||||
"cache": false,
|
||||
"persistent": true,
|
||||
},
|
||||
"smoke-test": {
|
||||
"dependsOn": ["build", "@t3tools/web#build", "t3#build"],
|
||||
"cache": false,
|
||||
"outputs": [],
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import * as path from "node:path";
|
||||
|
||||
import { defineConfig } from "vite-plus";
|
||||
|
||||
const shared = {
|
||||
format: "cjs" as const,
|
||||
outDir: "dist-electron",
|
||||
sourcemap: true,
|
||||
outExtensions: () => ({ js: ".js" }),
|
||||
};
|
||||
|
||||
export default defineConfig({
|
||||
resolve: {
|
||||
tsconfigPaths: true,
|
||||
alias: [
|
||||
{
|
||||
find: /^@t3tools\/contracts$/,
|
||||
replacement: path.resolve(import.meta.dirname, "../../packages/contracts/src/index.ts"),
|
||||
},
|
||||
{
|
||||
find: /^@t3tools\/contracts\/settings$/,
|
||||
replacement: path.resolve(import.meta.dirname, "../../packages/contracts/src/settings.ts"),
|
||||
},
|
||||
{
|
||||
find: /^@t3tools\/shared\/(.*)$/,
|
||||
replacement: path.resolve(import.meta.dirname, "../../packages/shared/src/$1.ts"),
|
||||
},
|
||||
],
|
||||
},
|
||||
pack: [
|
||||
{
|
||||
...shared,
|
||||
entry: ["src/main.ts"],
|
||||
clean: true,
|
||||
noExternal: (id) => id.startsWith("@t3tools/"),
|
||||
},
|
||||
{
|
||||
...shared,
|
||||
entry: ["src/preload.ts"],
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -114,19 +114,19 @@ function waitFor<A, E>(
|
||||
predicate: (value: A) => boolean,
|
||||
description: string,
|
||||
timeoutMs?: number,
|
||||
): Effect.Effect<A, never>;
|
||||
): Effect.Effect<A>;
|
||||
function waitFor<A, B extends A, E>(
|
||||
read: Effect.Effect<A, E>,
|
||||
predicate: (value: A) => value is B,
|
||||
description: string,
|
||||
timeoutMs?: number,
|
||||
): Effect.Effect<B, never>;
|
||||
): Effect.Effect<B>;
|
||||
function waitFor<A, E>(
|
||||
read: Effect.Effect<A, E>,
|
||||
predicate: (value: A) => boolean,
|
||||
description: string,
|
||||
timeoutMs = 10_000,
|
||||
): Effect.Effect<A, never> {
|
||||
): Effect.Effect<A> {
|
||||
const RETRY_SIGNAL = "wait_for_retry";
|
||||
const retryIntervalMs = 10;
|
||||
const maxRetries = Math.max(0, Math.floor(timeoutMs / retryIntervalMs));
|
||||
@@ -175,11 +175,11 @@ export interface OrchestrationIntegrationHarness {
|
||||
threadId: string,
|
||||
predicate: (thread: OrchestrationThread) => boolean,
|
||||
timeoutMs?: number,
|
||||
) => Effect.Effect<OrchestrationThread, never>;
|
||||
) => Effect.Effect<OrchestrationThread>;
|
||||
readonly waitForDomainEvent: (
|
||||
predicate: (event: OrchestrationEvent) => boolean,
|
||||
timeoutMs?: number,
|
||||
) => Effect.Effect<ReadonlyArray<OrchestrationEvent>, never>;
|
||||
) => Effect.Effect<ReadonlyArray<OrchestrationEvent>>;
|
||||
readonly waitForPendingApproval: (
|
||||
requestId: string,
|
||||
predicate: (row: {
|
||||
@@ -188,25 +188,22 @@ export interface OrchestrationIntegrationHarness {
|
||||
readonly resolvedAt: string | null;
|
||||
}) => boolean,
|
||||
timeoutMs?: number,
|
||||
) => Effect.Effect<
|
||||
{
|
||||
readonly status: "pending" | "resolved";
|
||||
readonly decision: "accept" | "acceptForSession" | "decline" | "cancel" | null;
|
||||
readonly resolvedAt: string | null;
|
||||
},
|
||||
never
|
||||
>;
|
||||
) => Effect.Effect<{
|
||||
readonly status: "pending" | "resolved";
|
||||
readonly decision: "accept" | "acceptForSession" | "decline" | "cancel" | null;
|
||||
readonly resolvedAt: string | null;
|
||||
}>;
|
||||
readonly waitForReceipt: {
|
||||
(
|
||||
predicate: (receipt: OrchestrationRuntimeReceipt) => boolean,
|
||||
timeoutMs?: number,
|
||||
): Effect.Effect<OrchestrationRuntimeReceipt, never>;
|
||||
): Effect.Effect<OrchestrationRuntimeReceipt>;
|
||||
<Receipt extends OrchestrationRuntimeReceipt>(
|
||||
predicate: (receipt: OrchestrationRuntimeReceipt) => receipt is Receipt,
|
||||
timeoutMs?: number,
|
||||
): Effect.Effect<Receipt, never>;
|
||||
): Effect.Effect<Receipt>;
|
||||
};
|
||||
readonly dispose: Effect.Effect<void, never>;
|
||||
readonly dispose: Effect.Effect<void>;
|
||||
}
|
||||
|
||||
interface MakeOrchestrationIntegrationHarnessOptions {
|
||||
@@ -391,7 +388,7 @@ export const makeOrchestrationIntegrationHarness = (
|
||||
(thread): thread is OrchestrationThread => thread !== null && predicate(thread),
|
||||
`projected thread '${threadId}'`,
|
||||
timeoutMs,
|
||||
) as Effect.Effect<OrchestrationThread, never>;
|
||||
) as Effect.Effect<OrchestrationThread>;
|
||||
|
||||
const waitForDomainEvent: OrchestrationIntegrationHarness["waitForDomainEvent"] = (
|
||||
predicate,
|
||||
@@ -435,23 +432,20 @@ export const makeOrchestrationIntegrationHarness = (
|
||||
} => row !== null && predicate(row),
|
||||
`pending approval '${requestId}'`,
|
||||
timeoutMs,
|
||||
) as Effect.Effect<
|
||||
{
|
||||
readonly status: "pending" | "resolved";
|
||||
readonly decision: "accept" | "acceptForSession" | "decline" | "cancel" | null;
|
||||
readonly resolvedAt: string | null;
|
||||
},
|
||||
never
|
||||
>;
|
||||
) as Effect.Effect<{
|
||||
readonly status: "pending" | "resolved";
|
||||
readonly decision: "accept" | "acceptForSession" | "decline" | "cancel" | null;
|
||||
readonly resolvedAt: string | null;
|
||||
}>;
|
||||
|
||||
function waitForReceipt(
|
||||
predicate: (receipt: OrchestrationRuntimeReceipt) => boolean,
|
||||
timeoutMs?: number,
|
||||
): Effect.Effect<OrchestrationRuntimeReceipt, never>;
|
||||
): Effect.Effect<OrchestrationRuntimeReceipt>;
|
||||
function waitForReceipt<Receipt extends OrchestrationRuntimeReceipt>(
|
||||
predicate: (receipt: OrchestrationRuntimeReceipt) => receipt is Receipt,
|
||||
timeoutMs?: number,
|
||||
): Effect.Effect<Receipt, never>;
|
||||
): Effect.Effect<Receipt>;
|
||||
function waitForReceipt(
|
||||
predicate: (receipt: OrchestrationRuntimeReceipt) => boolean,
|
||||
timeoutMs?: number,
|
||||
|
||||
@@ -30,7 +30,7 @@ export interface TestTurnResponse {
|
||||
readonly mutateWorkspace?: (input: {
|
||||
readonly cwd: string;
|
||||
readonly turnCount: number;
|
||||
}) => Effect.Effect<void, never>;
|
||||
}) => Effect.Effect<void>;
|
||||
}
|
||||
|
||||
export type FixtureProviderRuntimeEvent = {
|
||||
@@ -183,9 +183,7 @@ export interface TestProviderAdapterHarness {
|
||||
threadId: ThreadId,
|
||||
response: TestTurnResponse,
|
||||
) => Effect.Effect<void, ProviderAdapterSessionNotFoundError>;
|
||||
readonly queueTurnResponseForNextSession: (
|
||||
response: TestTurnResponse,
|
||||
) => Effect.Effect<void, never>;
|
||||
readonly queueTurnResponseForNextSession: (response: TestTurnResponse) => Effect.Effect<void>;
|
||||
readonly getStartCount: () => number;
|
||||
readonly getRollbackCalls: (threadId: ThreadId) => ReadonlyArray<number>;
|
||||
readonly getInterruptCalls: (threadId: ThreadId) => ReadonlyArray<TurnId | undefined>;
|
||||
@@ -337,7 +335,7 @@ export const makeTestProviderAdapterHarness = (options?: MakeTestProviderAdapter
|
||||
}
|
||||
|
||||
if (response.mutateWorkspace && state.session.cwd) {
|
||||
yield* response.mutateWorkspace({ cwd: state.session.cwd!, turnCount });
|
||||
yield* response.mutateWorkspace({ cwd: state.session.cwd, turnCount });
|
||||
}
|
||||
|
||||
const userItem = {
|
||||
@@ -505,9 +503,7 @@ export const makeTestProviderAdapterHarness = (options?: MakeTestProviderAdapter
|
||||
),
|
||||
);
|
||||
|
||||
const queueTurnResponseForNextSession = (
|
||||
response: TestTurnResponse,
|
||||
): Effect.Effect<void, never> =>
|
||||
const queueTurnResponseForNextSession = (response: TestTurnResponse): Effect.Effect<void> =>
|
||||
Effect.sync(() => {
|
||||
queuedResponsesForNextSession.push(response);
|
||||
});
|
||||
|
||||
@@ -58,7 +58,7 @@ function waitForSync<A>(
|
||||
predicate: (value: A) => boolean,
|
||||
description: string,
|
||||
timeoutMs = 3000,
|
||||
): Effect.Effect<A, never> {
|
||||
): Effect.Effect<A> {
|
||||
return Effect.gen(function* () {
|
||||
const deadline = Date.now() + timeoutMs;
|
||||
|
||||
@@ -226,9 +226,7 @@ it.live("runs a single turn end-to-end and persists checkpoint state in sqlite +
|
||||
THREAD_ID,
|
||||
(entry) =>
|
||||
entry.session?.status === "ready" &&
|
||||
entry.messages.some(
|
||||
(message) => message.role === "assistant" && message.streaming === false,
|
||||
) &&
|
||||
entry.messages.some((message) => message.role === "assistant" && !message.streaming) &&
|
||||
entry.checkpoints.length === 1,
|
||||
);
|
||||
assert.equal(thread.checkpoints[0]?.status, "ready");
|
||||
@@ -309,9 +307,7 @@ it.live.skipIf(!process.env.CODEX_BINARY_PATH)(
|
||||
(entry) =>
|
||||
entry.session?.status === "ready" &&
|
||||
entry.session.providerName === "codex" &&
|
||||
entry.messages.some(
|
||||
(message) => message.role === "assistant" && message.streaming === false,
|
||||
),
|
||||
entry.messages.some((message) => message.role === "assistant" && !message.streaming),
|
||||
180_000,
|
||||
);
|
||||
assert.equal(firstThread.session?.threadId, "thread-1");
|
||||
|
||||
@@ -40,7 +40,7 @@ const makeWorkspaceDirectory = Effect.gen(function* () {
|
||||
interface IntegrationFixture {
|
||||
readonly cwd: string;
|
||||
readonly harness: TestProviderAdapterHarness;
|
||||
readonly layer: Layer.Layer<ProviderService, unknown, never>;
|
||||
readonly layer: Layer.Layer<ProviderService, unknown>;
|
||||
}
|
||||
|
||||
const makeIntegrationFixture = Effect.gen(function* () {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"start": "node dist/index.mjs",
|
||||
"prepare": "effect-language-service patch",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run"
|
||||
"test": "vp test run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@anthropic-ai/claude-agent-sdk": "^0.2.77",
|
||||
@@ -41,9 +41,8 @@
|
||||
"@types/bun": "catalog:",
|
||||
"@types/node": "catalog:",
|
||||
"@types/ws": "^8.5.13",
|
||||
"tsdown": "catalog:",
|
||||
"typescript": "catalog:",
|
||||
"vitest": "catalog:"
|
||||
"vite-plus": "catalog:"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^22.16 || ^23.11 || >=24.10"
|
||||
|
||||
@@ -10,7 +10,10 @@ import {
|
||||
DEVELOPMENT_ICON_OVERRIDES,
|
||||
PUBLISH_ICON_OVERRIDES,
|
||||
} from "../../../scripts/lib/brand-assets.ts";
|
||||
import { resolveCatalogDependencies } from "../../../scripts/lib/resolve-catalog.ts";
|
||||
import {
|
||||
getWorkspaceCatalog,
|
||||
resolveCatalogDependencies,
|
||||
} from "../../../scripts/lib/resolve-catalog.ts";
|
||||
import rootPackageJson from "../../../package.json" with { type: "json" };
|
||||
import serverPackageJson from "../package.json" with { type: "json" };
|
||||
|
||||
@@ -22,6 +25,7 @@ class CliError extends Data.TaggedError("CliError")<{
|
||||
const RepoRoot = Effect.service(Path.Path).pipe(
|
||||
Effect.flatMap((path) => path.fromFileUrl(new URL("../../..", import.meta.url))),
|
||||
);
|
||||
const workspaceCatalog = getWorkspaceCatalog(rootPackageJson);
|
||||
|
||||
const runCommand = Effect.fn("runCommand")(function* (command: ChildProcess.Command) {
|
||||
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
@@ -129,7 +133,7 @@ const buildCmd = Command.make(
|
||||
const repoRoot = yield* RepoRoot;
|
||||
const serverDir = path.join(repoRoot, "apps/server");
|
||||
|
||||
yield* Effect.log("[cli] Running tsdown...");
|
||||
yield* Effect.log("[cli] Running vp pack...");
|
||||
yield* runCommand(
|
||||
ChildProcess.make({
|
||||
cwd: serverDir,
|
||||
@@ -137,7 +141,7 @@ const buildCmd = Command.make(
|
||||
stderr: "inherit",
|
||||
// Windows needs shell mode to resolve .cmd shims (e.g. bun.cmd).
|
||||
shell: process.platform === "win32",
|
||||
})`bun tsdown`,
|
||||
})`vp pack`,
|
||||
);
|
||||
|
||||
const webDist = path.join(repoRoot, "apps/web/dist");
|
||||
@@ -151,7 +155,7 @@ const buildCmd = Command.make(
|
||||
yield* Effect.logWarning("[cli] Web dist not found — skipping client bundle.");
|
||||
}
|
||||
}),
|
||||
).pipe(Command.withDescription("Build the server package (tsdown + bundle web client)."));
|
||||
).pipe(Command.withDescription("Build the server package (vp pack + bundle web client)."));
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// publish subcommand
|
||||
@@ -205,7 +209,7 @@ const publishCmd = Command.make(
|
||||
|
||||
pkg.dependencies = resolveCatalogDependencies(
|
||||
pkg.dependencies,
|
||||
rootPackageJson.workspaces.catalog,
|
||||
workspaceCatalog,
|
||||
"apps/server dependencies",
|
||||
);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
createAttachmentId,
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as Duration from "effect/Duration";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Fiber from "effect/Fiber";
|
||||
import { TestClock } from "effect/testing";
|
||||
import { vi } from "vitest";
|
||||
import { vi } from "vite-plus/test";
|
||||
|
||||
import { readBootstrapEnvelope, resolveFdPath } from "./bootstrap";
|
||||
import { assertNone, assertSome } from "@effect/vitest/utils";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { parseTurnDiffFilesFromUnifiedDiff } from "./Diffs.ts";
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
type OrchestrationReadModel,
|
||||
} from "@t3tools/contracts";
|
||||
import { Effect, Layer } from "effect";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { ProjectionSnapshotQuery } from "../../orchestration/Services/ProjectionSnapshotQuery.ts";
|
||||
import { checkpointRefForThreadTurn } from "../Utils.ts";
|
||||
|
||||
@@ -3,7 +3,7 @@ import path from "node:path";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { it } from "@effect/vitest";
|
||||
import { Effect, FileSystem, Layer, PlatformError, Scope } from "effect";
|
||||
import { describe, expect } from "vitest";
|
||||
import { describe, expect } from "vite-plus/test";
|
||||
|
||||
import { checkpointRefForThreadTurn } from "../Utils.ts";
|
||||
import { CheckpointStoreLive } from "./CheckpointStore.ts";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { describe, expect, it, vi } from "vite-plus/test";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
||||
import os from "node:os";
|
||||
|
||||
@@ -432,7 +432,7 @@ export interface CodexAppServerManagerEvents {
|
||||
export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEvents> {
|
||||
private readonly sessions = new Map<ThreadId, CodexSessionContext>();
|
||||
|
||||
private runPromise: (effect: Effect.Effect<unknown, never>) => Promise<unknown>;
|
||||
private runPromise: (effect: Effect.Effect<unknown>) => Promise<unknown>;
|
||||
constructor(services?: ServiceMap.ServiceMap<never>) {
|
||||
super();
|
||||
this.runPromise = services ? Effect.runPromiseWith(services) : Effect.runPromise;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { it } from "@effect/vitest";
|
||||
import { Effect, FileSystem, Layer, Path } from "effect";
|
||||
import { expect } from "vitest";
|
||||
import { expect } from "vite-plus/test";
|
||||
|
||||
import { ServerConfig } from "../../config.ts";
|
||||
import { TextGeneration } from "../Services/TextGeneration.ts";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { it } from "@effect/vitest";
|
||||
import { Effect, FileSystem, Layer, Path, Result } from "effect";
|
||||
import { expect } from "vitest";
|
||||
import { expect } from "vite-plus/test";
|
||||
|
||||
import { ServerConfig } from "../../config.ts";
|
||||
import { CodexTextGenerationLive } from "./CodexTextGeneration.ts";
|
||||
|
||||
@@ -82,7 +82,7 @@ const makeCodexTextGeneration = Effect.gen(function* () {
|
||||
);
|
||||
};
|
||||
|
||||
const safeUnlink = (filePath: string): Effect.Effect<void, never> =>
|
||||
const safeUnlink = (filePath: string): Effect.Effect<void> =>
|
||||
fileSystem.remove(filePath).pipe(Effect.catch(() => Effect.void));
|
||||
|
||||
const materializeImageAttachments = (
|
||||
|
||||
@@ -4,7 +4,7 @@ import path from "node:path";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { it } from "@effect/vitest";
|
||||
import { Effect, FileSystem, Layer, PlatformError, Scope } from "effect";
|
||||
import { describe, expect, vi } from "vitest";
|
||||
import { describe, expect, vi } from "vite-plus/test";
|
||||
|
||||
import { GitCoreLive, makeGitCore } from "./GitCore.ts";
|
||||
import { GitCore, type GitCoreShape } from "../Services/GitCore.ts";
|
||||
@@ -374,7 +374,7 @@ it.layer(TestLayer)("git integration", (it) => {
|
||||
const tmp = yield* makeTmpDir();
|
||||
yield* initRepoWithCommit(tmp);
|
||||
const result = yield* (yield* GitCore).listBranches({ cwd: tmp });
|
||||
expect(result.branches.every((b) => b.isDefault === false)).toBe(true);
|
||||
expect(result.branches.every((b) => !b.isDefault)).toBe(true);
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -324,7 +324,7 @@ function toGitCommandError(
|
||||
|
||||
interface Trace2Monitor {
|
||||
readonly env: NodeJS.ProcessEnv;
|
||||
readonly flush: Effect.Effect<void, never>;
|
||||
readonly flush: Effect.Effect<void>;
|
||||
}
|
||||
|
||||
function trace2ChildKey(record: Record<string, unknown>): string | null {
|
||||
@@ -488,7 +488,7 @@ const collectOutput = Effect.fn("collectOutput")(function* <E>(
|
||||
stream: Stream.Stream<Uint8Array, E>,
|
||||
maxOutputBytes: number,
|
||||
truncateOutputAtMaxBytes: boolean,
|
||||
onLine: ((line: string) => Effect.Effect<void, never>) | undefined,
|
||||
onLine: ((line: string) => Effect.Effect<void>) | undefined,
|
||||
): Effect.fn.Return<{ readonly text: string; readonly truncated: boolean }, GitCommandError> {
|
||||
const decoder = new TextDecoder();
|
||||
let bytes = 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { assert, it } from "@effect/vitest";
|
||||
import { Effect } from "effect";
|
||||
import { afterEach, expect, vi } from "vitest";
|
||||
import { afterEach, expect, vi } from "vite-plus/test";
|
||||
|
||||
vi.mock("../../processRunner", () => ({
|
||||
runProcess: vi.fn(),
|
||||
|
||||
@@ -5,7 +5,7 @@ import { spawnSync } from "node:child_process";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { it } from "@effect/vitest";
|
||||
import { Effect, FileSystem, Layer, PlatformError, Scope } from "effect";
|
||||
import { expect } from "vitest";
|
||||
import { expect } from "vite-plus/test";
|
||||
import type { GitActionProgressEvent, ModelSelection } from "@t3tools/contracts";
|
||||
|
||||
import { GitCommandError, GitHubCliError, TextGenerationError } from "../Errors.ts";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
buildBranchNamePrompt,
|
||||
|
||||
@@ -55,27 +55,27 @@ export interface GitPreparedCommitContext {
|
||||
}
|
||||
|
||||
export interface ExecuteGitProgress {
|
||||
readonly onStdoutLine?: (line: string) => Effect.Effect<void, never>;
|
||||
readonly onStderrLine?: (line: string) => Effect.Effect<void, never>;
|
||||
readonly onHookStarted?: (hookName: string) => Effect.Effect<void, never>;
|
||||
readonly onStdoutLine?: (line: string) => Effect.Effect<void>;
|
||||
readonly onStderrLine?: (line: string) => Effect.Effect<void>;
|
||||
readonly onHookStarted?: (hookName: string) => Effect.Effect<void>;
|
||||
readonly onHookFinished?: (input: {
|
||||
hookName: string;
|
||||
exitCode: number | null;
|
||||
durationMs: number | null;
|
||||
}) => Effect.Effect<void, never>;
|
||||
}) => Effect.Effect<void>;
|
||||
}
|
||||
|
||||
export interface GitCommitProgress {
|
||||
readonly onOutputLine?: (input: {
|
||||
stream: "stdout" | "stderr";
|
||||
text: string;
|
||||
}) => Effect.Effect<void, never>;
|
||||
readonly onHookStarted?: (hookName: string) => Effect.Effect<void, never>;
|
||||
}) => Effect.Effect<void>;
|
||||
readonly onHookStarted?: (hookName: string) => Effect.Effect<void>;
|
||||
readonly onHookFinished?: (input: {
|
||||
hookName: string;
|
||||
exitCode: number | null;
|
||||
durationMs: number | null;
|
||||
}) => Effect.Effect<void, never>;
|
||||
}) => Effect.Effect<void>;
|
||||
}
|
||||
|
||||
export interface GitCommitOptions {
|
||||
|
||||
@@ -22,7 +22,7 @@ import type { Effect } from "effect";
|
||||
import type { GitManagerServiceError } from "../Errors.ts";
|
||||
|
||||
export interface GitActionProgressReporter {
|
||||
readonly publish: (event: GitActionProgressEvent) => Effect.Effect<void, never>;
|
||||
readonly publish: (event: GitActionProgressEvent) => Effect.Effect<void>;
|
||||
}
|
||||
|
||||
export interface GitRunStackedActionOptions {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { inferImageExtension, parseBase64DataUrl } from "./imageMime.ts";
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as FileSystem from "effect/FileSystem";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Command from "effect/unstable/cli/Command";
|
||||
import { FetchHttpClient } from "effect/unstable/http";
|
||||
import { beforeEach } from "vitest";
|
||||
import { beforeEach } from "vite-plus/test";
|
||||
import { NetService } from "@t3tools/shared/Net";
|
||||
|
||||
import { CliConfig, recordStartupHeartbeat, t3Cli, type CliConfigShape } from "./main";
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
} from "@t3tools/contracts";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { Effect, Exit, Layer, ManagedRuntime, PubSub, Scope, Stream } from "effect";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, describe, expect, it, vi } from "vite-plus/test";
|
||||
|
||||
import { CheckpointStoreLive } from "../../checkpointing/Layers/CheckpointStore.ts";
|
||||
import { CheckpointStore } from "../../checkpointing/Services/CheckpointStore.ts";
|
||||
@@ -69,7 +69,7 @@ function createProviderServiceHarness(
|
||||
);
|
||||
|
||||
const unsupported = <A>() =>
|
||||
Effect.die(new Error("Unsupported provider call in test")) as Effect.Effect<A, never>;
|
||||
Effect.die(new Error("Unsupported provider call in test")) as Effect.Effect<A>;
|
||||
const listSessions = () =>
|
||||
hasSession
|
||||
? Effect.succeed([
|
||||
|
||||
@@ -748,7 +748,7 @@ const make = Effect.gen(function* () {
|
||||
|
||||
const processInput = (
|
||||
input: ReactorInput,
|
||||
): Effect.Effect<void, CheckpointStoreError | OrchestrationDispatchError, never> =>
|
||||
): Effect.Effect<void, CheckpointStoreError | OrchestrationDispatchError> =>
|
||||
input.source === "domain" ? processDomainEvent(input.event) : processRuntimeEvent(input.event);
|
||||
|
||||
const processInputSafely = (input: ReactorInput) =>
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
type OrchestrationEvent,
|
||||
} from "@t3tools/contracts";
|
||||
import { Effect, Layer, ManagedRuntime, Queue, Stream } from "effect";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { PersistenceSqlError } from "../../persistence/Errors.ts";
|
||||
import { OrchestrationCommandReceiptRepositoryLive } from "../../persistence/Layers/OrchestrationCommandReceipts.ts";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Effect, Exit, Layer, ManagedRuntime, Scope } from "effect";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { afterEach, describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { CheckpointReactor } from "../Services/CheckpointReactor.ts";
|
||||
import { ProviderCommandReactor } from "../Services/ProviderCommandReactor.ts";
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
TurnId,
|
||||
} from "@t3tools/contracts";
|
||||
import { Effect, Exit, Layer, ManagedRuntime, PubSub, Scope, Stream } from "effect";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, describe, expect, it, vi } from "vite-plus/test";
|
||||
|
||||
import { deriveServerPaths, ServerConfig } from "../../config.ts";
|
||||
import { TextGenerationError } from "../../git/Errors.ts";
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
TurnId,
|
||||
} from "@t3tools/contracts";
|
||||
import { Effect, Exit, Layer, ManagedRuntime, PubSub, Scope, Stream } from "effect";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { afterEach, describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { OrchestrationEventStoreLive } from "../../persistence/Layers/OrchestrationEventStore.ts";
|
||||
import { OrchestrationCommandReceiptRepositoryLive } from "../../persistence/Layers/OrchestrationCommandReceipts.ts";
|
||||
@@ -1626,8 +1626,7 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
event.payload.messageId === "assistant:item-complete-dedup" &&
|
||||
event.payload.streaming === false
|
||||
event.payload.messageId === "assistant:item-complete-dedup" && !event.payload.streaming
|
||||
);
|
||||
});
|
||||
expect(completionEvents).toHaveLength(1);
|
||||
|
||||
@@ -30,7 +30,7 @@ export interface OrchestrationEngineShape {
|
||||
*
|
||||
* @returns Effect containing the latest read model.
|
||||
*/
|
||||
readonly getReadModel: () => Effect.Effect<OrchestrationReadModel, never, never>;
|
||||
readonly getReadModel: () => Effect.Effect<OrchestrationReadModel, never>;
|
||||
|
||||
/**
|
||||
* Replay persisted orchestration events from an exclusive sequence cursor.
|
||||
@@ -40,7 +40,7 @@ export interface OrchestrationEngineShape {
|
||||
*/
|
||||
readonly readEvents: (
|
||||
fromSequenceExclusive: number,
|
||||
) => Stream.Stream<OrchestrationEvent, OrchestrationEventStoreError, never>;
|
||||
) => Stream.Stream<OrchestrationEvent, OrchestrationEventStoreError>;
|
||||
|
||||
/**
|
||||
* Dispatch a validated orchestration command.
|
||||
@@ -53,7 +53,7 @@ export interface OrchestrationEngineShape {
|
||||
*/
|
||||
readonly dispatch: (
|
||||
command: OrchestrationCommand,
|
||||
) => Effect.Effect<{ sequence: number }, OrchestrationDispatchError, never>;
|
||||
) => Effect.Effect<{ sequence: number }, OrchestrationDispatchError>;
|
||||
|
||||
/**
|
||||
* Stream persisted domain events in dispatch order.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
import {
|
||||
MessageId,
|
||||
CommandId,
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
ProjectId,
|
||||
ThreadId,
|
||||
} from "@t3tools/contracts";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
import { Effect } from "effect";
|
||||
|
||||
import { decideOrchestrationCommand } from "./decider.ts";
|
||||
|
||||
@@ -679,7 +679,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
|
||||
default: {
|
||||
command satisfies never;
|
||||
const fallback = command as never as { type: string };
|
||||
const fallback = command as { type: string };
|
||||
return yield* new OrchestrationCommandInvariantError({
|
||||
commandType: fallback.type,
|
||||
detail: `Unknown command type: ${fallback.type}`,
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
type OrchestrationEvent,
|
||||
} from "@t3tools/contracts";
|
||||
import { Effect } from "effect";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { createEmptyReadModel, projectEvent } from "./projector.ts";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { describe, expect, it, vi } from "vite-plus/test";
|
||||
|
||||
import { fixPath } from "./os-jank";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { runProcess } from "./processRunner";
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import path from "node:path";
|
||||
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { Effect } from "effect";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { afterEach, describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { ProjectFaviconResolverLive } from "./project/Layers/ProjectFaviconResolver.ts";
|
||||
import { tryHandleProjectFaviconRequest } from "./projectFaviconRoute";
|
||||
|
||||
@@ -2134,7 +2134,7 @@ describe("ClaudeAdapterLive", () => {
|
||||
});
|
||||
|
||||
const permissionResult = yield* Effect.promise(() => permissionPromise);
|
||||
assert.equal((permissionResult as PermissionResult).behavior, "allow");
|
||||
assert.equal(permissionResult.behavior, "allow");
|
||||
}).pipe(
|
||||
Effect.provideService(Random.Random, makeDeterministicRandomService()),
|
||||
Effect.provide(harness.layer),
|
||||
@@ -2623,7 +2623,7 @@ describe("ClaudeAdapterLive", () => {
|
||||
});
|
||||
|
||||
const permissionResult = yield* Effect.promise(() => permissionPromise);
|
||||
assert.equal((permissionResult as PermissionResult).behavior, "deny");
|
||||
assert.equal(permissionResult.behavior, "deny");
|
||||
const deniedResult = permissionResult as PermissionResult & {
|
||||
message?: string;
|
||||
};
|
||||
@@ -2817,7 +2817,7 @@ describe("ClaudeAdapterLive", () => {
|
||||
|
||||
// The canUseTool promise should resolve with the answers in SDK format.
|
||||
const permissionResult = yield* Effect.promise(() => permissionPromise);
|
||||
assert.equal((permissionResult as PermissionResult).behavior, "allow");
|
||||
assert.equal(permissionResult.behavior, "allow");
|
||||
const updatedInput = (permissionResult as { updatedInput: Record<string, unknown> })
|
||||
.updatedInput;
|
||||
assert.deepEqual(updatedInput.answers, { "Which framework?": "React" });
|
||||
@@ -2889,7 +2889,7 @@ describe("ClaudeAdapterLive", () => {
|
||||
yield* Stream.runHead(adapter.streamEvents);
|
||||
|
||||
const permissionResult = yield* Effect.promise(() => permissionPromise);
|
||||
assert.equal((permissionResult as PermissionResult).behavior, "allow");
|
||||
assert.equal(permissionResult.behavior, "allow");
|
||||
const updatedInput = (permissionResult as { updatedInput: Record<string, unknown> })
|
||||
.updatedInput;
|
||||
assert.deepEqual(updatedInput.answers, { "Deploy to which env?": "Staging" });
|
||||
|
||||
@@ -261,7 +261,7 @@ function isInterruptedResult(result: SDKResultMessage): boolean {
|
||||
|
||||
return (
|
||||
result.subtype === "error_during_execution" &&
|
||||
result.is_error === false &&
|
||||
!result.is_error &&
|
||||
(errors.includes("request was aborted") ||
|
||||
errors.includes("interrupted by user") ||
|
||||
errors.includes("aborted"))
|
||||
@@ -2817,7 +2817,7 @@ const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
|
||||
providerRefs: {},
|
||||
});
|
||||
|
||||
let streamFiber: Fiber.Fiber<void, never>;
|
||||
let streamFiber: Fiber.Fiber<void>;
|
||||
streamFiber = runFork(
|
||||
Effect.exit(runSdkStream(context)).pipe(
|
||||
Effect.flatMap((exit) => {
|
||||
|
||||
@@ -1345,7 +1345,7 @@ const makeCodexAdapter = Effect.fn("makeCodexAdapter")(function* (
|
||||
if (options?.manager) {
|
||||
return options.manager;
|
||||
}
|
||||
const services = yield* Effect.services<never>();
|
||||
const services = yield* Effect.services();
|
||||
return options?.makeManager?.(services) ?? new CodexAppServerManager(services);
|
||||
});
|
||||
|
||||
@@ -1564,7 +1564,7 @@ const makeCodexAdapter = Effect.fn("makeCodexAdapter")(function* (
|
||||
});
|
||||
|
||||
const registerListener = Effect.fn("registerListener")(function* () {
|
||||
const services = yield* Effect.services<never>();
|
||||
const services = yield* Effect.services();
|
||||
const listenerEffect = Effect.fn("listener")(function* (event: ProviderEvent) {
|
||||
yield* writeNativeEvent(event);
|
||||
const runtimeEvents = mapToRuntimeEvents(event, event.threadId);
|
||||
|
||||
@@ -15,12 +15,12 @@ export interface AnalyticsServiceShape {
|
||||
readonly record: (
|
||||
event: string,
|
||||
properties?: Readonly<Record<string, unknown>>,
|
||||
) => Effect.Effect<void, never>;
|
||||
) => Effect.Effect<void>;
|
||||
|
||||
/**
|
||||
* Flush queued telemetry.
|
||||
*/
|
||||
readonly flush: Effect.Effect<void, never>;
|
||||
readonly flush: Effect.Effect<void>;
|
||||
}
|
||||
|
||||
export class AnalyticsService extends ServiceMap.Service<AnalyticsService, AnalyticsServiceShape>()(
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
Scope,
|
||||
} from "effect";
|
||||
import { TestClock } from "effect/testing";
|
||||
import { expect } from "vitest";
|
||||
import { expect } from "vite-plus/test";
|
||||
|
||||
import type { TerminalManagerShape } from "../Services/Manager";
|
||||
import {
|
||||
@@ -483,7 +483,7 @@ it.layer(NodeServices.layer, { excludeTestServices: true })("TerminalManager", (
|
||||
hasRunningSubprocess = true;
|
||||
yield* waitFor(
|
||||
Effect.map(getEvents, (events) =>
|
||||
events.some((event) => event.type === "activity" && event.hasRunningSubprocess === true),
|
||||
events.some((event) => event.type === "activity" && event.hasRunningSubprocess),
|
||||
),
|
||||
"1200 millis",
|
||||
);
|
||||
@@ -491,7 +491,7 @@ it.layer(NodeServices.layer, { excludeTestServices: true })("TerminalManager", (
|
||||
hasRunningSubprocess = false;
|
||||
yield* waitFor(
|
||||
Effect.map(getEvents, (events) =>
|
||||
events.some((event) => event.type === "activity" && event.hasRunningSubprocess === false),
|
||||
events.some((event) => event.type === "activity" && !event.hasRunningSubprocess),
|
||||
),
|
||||
"1200 millis",
|
||||
);
|
||||
|
||||
@@ -130,7 +130,7 @@ type DrainProcessEventAction =
|
||||
|
||||
interface TerminalManagerState {
|
||||
sessions: Map<string, TerminalSessionState>;
|
||||
killFibers: Map<PtyProcess, Fiber.Fiber<void, never>>;
|
||||
killFibers: Map<PtyProcess, Fiber.Fiber<void>>;
|
||||
}
|
||||
|
||||
function snapshot(session: TerminalSessionState): TerminalSessionSnapshot {
|
||||
@@ -742,14 +742,14 @@ export const makeTerminalManagerWithOptions = Effect.fn("makeTerminalManagerWith
|
||||
process: PtyProcess | null,
|
||||
) {
|
||||
if (!process) return;
|
||||
const fiber: Option.Option<Fiber.Fiber<void, never>> = yield* modifyManagerState<
|
||||
Option.Option<Fiber.Fiber<void, never>>
|
||||
const fiber: Option.Option<Fiber.Fiber<void>> = yield* modifyManagerState<
|
||||
Option.Option<Fiber.Fiber<void>>
|
||||
>((state) => {
|
||||
const existing: Option.Option<Fiber.Fiber<void, never>> = Option.fromNullishOr(
|
||||
const existing: Option.Option<Fiber.Fiber<void>> = Option.fromNullishOr(
|
||||
state.killFibers.get(process),
|
||||
);
|
||||
if (Option.isNone(existing)) {
|
||||
return [Option.none<Fiber.Fiber<void, never>>(), state] as const;
|
||||
return [Option.none<Fiber.Fiber<void>>(), state] as const;
|
||||
}
|
||||
const killFibers = new Map(state.killFibers);
|
||||
killFibers.delete(process);
|
||||
@@ -762,7 +762,7 @@ export const makeTerminalManagerWithOptions = Effect.fn("makeTerminalManagerWith
|
||||
|
||||
const registerKillFiber = Effect.fn("terminal.registerKillFiber")(function* (
|
||||
process: PtyProcess,
|
||||
fiber: Fiber.Fiber<void, never>,
|
||||
fiber: Fiber.Fiber<void>,
|
||||
) {
|
||||
yield* modifyManagerState((state) => {
|
||||
const killFibers = new Map(state.killFibers);
|
||||
|
||||
@@ -22,6 +22,7 @@ const IGNORED_DIRECTORY_NAMES = new Set([
|
||||
"node_modules",
|
||||
".next",
|
||||
".turbo",
|
||||
".vite",
|
||||
"dist",
|
||||
"build",
|
||||
"out",
|
||||
@@ -226,10 +227,7 @@ export const makeWorkspaceEntries = Effect.gen(function* () {
|
||||
onNone: () => Effect.succeed(false),
|
||||
});
|
||||
|
||||
const filterGitIgnoredPaths = (
|
||||
cwd: string,
|
||||
relativePaths: string[],
|
||||
): Effect.Effect<string[], never> =>
|
||||
const filterGitIgnoredPaths = (cwd: string, relativePaths: string[]): Effect.Effect<string[]> =>
|
||||
Option.match(gitOption, {
|
||||
onSome: (git) =>
|
||||
git.filterIgnoredPaths(cwd, relativePaths).pipe(
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
Scope,
|
||||
Stream,
|
||||
} from "effect";
|
||||
import { describe, expect, it, afterEach, vi } from "vitest";
|
||||
import { describe, expect, it, afterEach, vi } from "vite-plus/test";
|
||||
import { createServer } from "./wsServer";
|
||||
import WebSocket from "ws";
|
||||
import { deriveServerPaths, ServerConfig, type ServerConfigShape } from "./config";
|
||||
@@ -281,7 +281,7 @@ function dequeue<T>(channel: MessageChannel<T>, timeoutMs: number): Promise<T> {
|
||||
const index = channel.waiters.indexOf(waiter);
|
||||
if (index >= 0) channel.waiters.splice(index, 1);
|
||||
reject(new Error(`Timed out waiting for WebSocket message after ${timeoutMs}ms`));
|
||||
}, timeoutMs) as ReturnType<typeof setTimeout>,
|
||||
}, timeoutMs),
|
||||
};
|
||||
channel.waiters.push(waiter);
|
||||
});
|
||||
@@ -508,7 +508,7 @@ describe("WebSocket Server", () => {
|
||||
authToken?: string;
|
||||
baseDir?: string;
|
||||
staticDir?: string;
|
||||
providerLayer?: Layer.Layer<ProviderService, never>;
|
||||
providerLayer?: Layer.Layer<ProviderService>;
|
||||
providerRegistry?: ProviderRegistryShape;
|
||||
open?: OpenShape;
|
||||
gitManager?: GitManagerShape;
|
||||
@@ -1505,7 +1505,7 @@ describe("WebSocket Server", () => {
|
||||
const push = await waitForPush(
|
||||
ws,
|
||||
WS_CHANNELS.terminalEvent,
|
||||
(candidate) => (candidate.data as TerminalEvent).type === "output",
|
||||
(candidate) => candidate.data.type === "output",
|
||||
);
|
||||
expect(push.type).toBe("push");
|
||||
expect(push.channel).toBe(WS_CHANNELS.terminalEvent);
|
||||
|
||||
@@ -98,7 +98,7 @@ export interface ServerShape {
|
||||
/**
|
||||
* Wait for process shutdown signals.
|
||||
*/
|
||||
readonly stopSignal: Effect.Effect<void, never>;
|
||||
readonly stopSignal: Effect.Effect<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { WebSocket } from "ws";
|
||||
import { it } from "@effect/vitest";
|
||||
import { describe, expect } from "vitest";
|
||||
import { describe, expect } from "vite-plus/test";
|
||||
import { Effect, Ref } from "effect";
|
||||
import { WS_CHANNELS } from "@t3tools/contracts";
|
||||
|
||||
|
||||
@@ -21,5 +21,14 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"include": ["src", "tsdown.config.ts", "scripts", "integration", "../../scripts/lib"]
|
||||
"include": [
|
||||
"src",
|
||||
"vite.config.ts",
|
||||
"scripts",
|
||||
"integration",
|
||||
"../../scripts/lib",
|
||||
"../../packages/contracts/src",
|
||||
"../../packages/shared/src"
|
||||
],
|
||||
"exclude": ["../../packages/contracts/src/**/*.test.ts", "../../packages/shared/src/**/*.test.ts"]
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { defineConfig } from "tsdown";
|
||||
|
||||
export default defineConfig({
|
||||
entry: ["src/index.ts"],
|
||||
format: ["esm", "cjs"],
|
||||
checks: {
|
||||
legacyCjs: false,
|
||||
},
|
||||
outDir: "dist",
|
||||
sourcemap: true,
|
||||
clean: true,
|
||||
noExternal: (id) => id.startsWith("@t3tools/"),
|
||||
inlineOnly: false,
|
||||
banner: {
|
||||
js: "#!/usr/bin/env node\n",
|
||||
},
|
||||
});
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"$schema": "https://turbo.build/schema.json",
|
||||
"extends": ["//"],
|
||||
"tasks": {
|
||||
"start": {
|
||||
"dependsOn": ["build"],
|
||||
"cache": false,
|
||||
"persistent": true,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import * as path from "node:path";
|
||||
|
||||
import { defineConfig } from "vite-plus";
|
||||
|
||||
export default defineConfig({
|
||||
resolve: {
|
||||
tsconfigPaths: true,
|
||||
alias: [
|
||||
{
|
||||
find: /^@t3tools\/contracts$/,
|
||||
replacement: path.resolve(import.meta.dirname, "../../packages/contracts/src/index.ts"),
|
||||
},
|
||||
{
|
||||
find: /^@t3tools\/contracts\/settings$/,
|
||||
replacement: path.resolve(import.meta.dirname, "../../packages/contracts/src/settings.ts"),
|
||||
},
|
||||
{
|
||||
find: /^@t3tools\/shared\/(.*)$/,
|
||||
replacement: path.resolve(import.meta.dirname, "../../packages/shared/src/$1.ts"),
|
||||
},
|
||||
],
|
||||
},
|
||||
pack: {
|
||||
entry: ["src/index.ts"],
|
||||
format: ["esm", "cjs"],
|
||||
checks: {
|
||||
legacyCjs: false,
|
||||
},
|
||||
outDir: "dist",
|
||||
sourcemap: true,
|
||||
clean: true,
|
||||
noExternal: (id) => id.startsWith("@t3tools/"),
|
||||
inlineOnly: false,
|
||||
banner: {
|
||||
js: "#!/usr/bin/env node\n",
|
||||
},
|
||||
},
|
||||
test: {
|
||||
testTimeout: 15_000,
|
||||
hookTimeout: 15_000,
|
||||
},
|
||||
});
|
||||
@@ -1,13 +0,0 @@
|
||||
import { defineConfig, mergeConfig } from "vitest/config";
|
||||
|
||||
import baseConfig from "../../vitest.config";
|
||||
|
||||
export default mergeConfig(
|
||||
baseConfig,
|
||||
defineConfig({
|
||||
test: {
|
||||
testTimeout: 15_000,
|
||||
hookTimeout: 15_000,
|
||||
},
|
||||
}),
|
||||
);
|
||||
@@ -4,13 +4,13 @@
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"dev": "vp dev",
|
||||
"build": "vp build",
|
||||
"prepare": "effect-language-service patch",
|
||||
"preview": "vite preview",
|
||||
"preview": "vp preview",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run --passWithNoTests",
|
||||
"test:browser": "vitest run --config vitest.browser.config.ts",
|
||||
"test": "vp test run --passWithNoTests",
|
||||
"test:browser": "vp test run --config vitest.browser.config.ts",
|
||||
"test:browser:install": "playwright install --with-deps chromium"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -50,14 +50,12 @@
|
||||
"@types/react": "^19.0.0",
|
||||
"@types/react-dom": "^19.0.0",
|
||||
"@vitejs/plugin-react": "^6.0.0",
|
||||
"@vitest/browser-playwright": "^4.0.18",
|
||||
"babel-plugin-react-compiler": "^19.0.0-beta-e552027-20250112",
|
||||
"msw": "2.12.11",
|
||||
"playwright": "^1.58.2",
|
||||
"tailwindcss": "^4.0.0",
|
||||
"typescript": "catalog:",
|
||||
"vite": "^8.0.0",
|
||||
"vitest": "catalog:",
|
||||
"vite-plus": "catalog:",
|
||||
"vitest-browser-react": "^2.0.5"
|
||||
}
|
||||
}
|
||||
@@ -7,114 +7,111 @@
|
||||
* - Please do NOT modify this file.
|
||||
*/
|
||||
|
||||
const PACKAGE_VERSION = '2.12.11'
|
||||
const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82'
|
||||
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
|
||||
const activeClientIds = new Set()
|
||||
const PACKAGE_VERSION = "2.12.11";
|
||||
const INTEGRITY_CHECKSUM = "4db4a41e972cec1b64cc569c66952d82";
|
||||
const IS_MOCKED_RESPONSE = Symbol("isMockedResponse");
|
||||
const activeClientIds = new Set();
|
||||
|
||||
addEventListener('install', function () {
|
||||
self.skipWaiting()
|
||||
})
|
||||
addEventListener("install", function () {
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
addEventListener('activate', function (event) {
|
||||
event.waitUntil(self.clients.claim())
|
||||
})
|
||||
addEventListener("activate", function (event) {
|
||||
event.waitUntil(self.clients.claim());
|
||||
});
|
||||
|
||||
addEventListener('message', async function (event) {
|
||||
const clientId = Reflect.get(event.source || {}, 'id')
|
||||
addEventListener("message", async function (event) {
|
||||
const clientId = Reflect.get(event.source || {}, "id");
|
||||
|
||||
if (!clientId || !self.clients) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
const client = await self.clients.get(clientId)
|
||||
const client = await self.clients.get(clientId);
|
||||
|
||||
if (!client) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
const allClients = await self.clients.matchAll({
|
||||
type: 'window',
|
||||
})
|
||||
type: "window",
|
||||
});
|
||||
|
||||
switch (event.data) {
|
||||
case 'KEEPALIVE_REQUEST': {
|
||||
case "KEEPALIVE_REQUEST": {
|
||||
sendToClient(client, {
|
||||
type: 'KEEPALIVE_RESPONSE',
|
||||
})
|
||||
break
|
||||
type: "KEEPALIVE_RESPONSE",
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case 'INTEGRITY_CHECK_REQUEST': {
|
||||
case "INTEGRITY_CHECK_REQUEST": {
|
||||
sendToClient(client, {
|
||||
type: 'INTEGRITY_CHECK_RESPONSE',
|
||||
type: "INTEGRITY_CHECK_RESPONSE",
|
||||
payload: {
|
||||
packageVersion: PACKAGE_VERSION,
|
||||
checksum: INTEGRITY_CHECKSUM,
|
||||
},
|
||||
})
|
||||
break
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case 'MOCK_ACTIVATE': {
|
||||
activeClientIds.add(clientId)
|
||||
case "MOCK_ACTIVATE": {
|
||||
activeClientIds.add(clientId);
|
||||
|
||||
sendToClient(client, {
|
||||
type: 'MOCKING_ENABLED',
|
||||
type: "MOCKING_ENABLED",
|
||||
payload: {
|
||||
client: {
|
||||
id: client.id,
|
||||
frameType: client.frameType,
|
||||
},
|
||||
},
|
||||
})
|
||||
break
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case 'CLIENT_CLOSED': {
|
||||
activeClientIds.delete(clientId)
|
||||
case "CLIENT_CLOSED": {
|
||||
activeClientIds.delete(clientId);
|
||||
|
||||
const remainingClients = allClients.filter((client) => {
|
||||
return client.id !== clientId
|
||||
})
|
||||
return client.id !== clientId;
|
||||
});
|
||||
|
||||
// Unregister itself when there are no more clients
|
||||
if (remainingClients.length === 0) {
|
||||
self.registration.unregister()
|
||||
self.registration.unregister();
|
||||
}
|
||||
|
||||
break
|
||||
break;
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
addEventListener('fetch', function (event) {
|
||||
const requestInterceptedAt = Date.now()
|
||||
addEventListener("fetch", function (event) {
|
||||
const requestInterceptedAt = Date.now();
|
||||
|
||||
// Bypass navigation requests.
|
||||
if (event.request.mode === 'navigate') {
|
||||
return
|
||||
if (event.request.mode === "navigate") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Opening the DevTools triggers the "only-if-cached" request
|
||||
// that cannot be handled by the worker. Bypass such requests.
|
||||
if (
|
||||
event.request.cache === 'only-if-cached' &&
|
||||
event.request.mode !== 'same-origin'
|
||||
) {
|
||||
return
|
||||
if (event.request.cache === "only-if-cached" && event.request.mode !== "same-origin") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Bypass all requests when there are no active clients.
|
||||
// Prevents the self-unregistered worked from handling requests
|
||||
// after it's been terminated (still remains active until the next reload).
|
||||
if (activeClientIds.size === 0) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
const requestId = crypto.randomUUID()
|
||||
event.respondWith(handleRequest(event, requestId, requestInterceptedAt))
|
||||
})
|
||||
const requestId = crypto.randomUUID();
|
||||
event.respondWith(handleRequest(event, requestId, requestInterceptedAt));
|
||||
});
|
||||
|
||||
/**
|
||||
* @param {FetchEvent} event
|
||||
@@ -122,28 +119,23 @@ addEventListener('fetch', function (event) {
|
||||
* @param {number} requestInterceptedAt
|
||||
*/
|
||||
async function handleRequest(event, requestId, requestInterceptedAt) {
|
||||
const client = await resolveMainClient(event)
|
||||
const requestCloneForEvents = event.request.clone()
|
||||
const response = await getResponse(
|
||||
event,
|
||||
client,
|
||||
requestId,
|
||||
requestInterceptedAt,
|
||||
)
|
||||
const client = await resolveMainClient(event);
|
||||
const requestCloneForEvents = event.request.clone();
|
||||
const response = await getResponse(event, client, requestId, requestInterceptedAt);
|
||||
|
||||
// Send back the response clone for the "response:*" life-cycle events.
|
||||
// Ensure MSW is active and ready to handle the message, otherwise
|
||||
// this message will pend indefinitely.
|
||||
if (client && activeClientIds.has(client.id)) {
|
||||
const serializedRequest = await serializeRequest(requestCloneForEvents)
|
||||
const serializedRequest = await serializeRequest(requestCloneForEvents);
|
||||
|
||||
// Clone the response so both the client and the library could consume it.
|
||||
const responseClone = response.clone()
|
||||
const responseClone = response.clone();
|
||||
|
||||
sendToClient(
|
||||
client,
|
||||
{
|
||||
type: 'RESPONSE',
|
||||
type: "RESPONSE",
|
||||
payload: {
|
||||
isMockedResponse: IS_MOCKED_RESPONSE in response,
|
||||
request: {
|
||||
@@ -160,10 +152,10 @@ async function handleRequest(event, requestId, requestInterceptedAt) {
|
||||
},
|
||||
},
|
||||
responseClone.body ? [serializedRequest.body, responseClone.body] : [],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return response
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,30 +167,30 @@ async function handleRequest(event, requestId, requestInterceptedAt) {
|
||||
* @returns {Promise<Client | undefined>}
|
||||
*/
|
||||
async function resolveMainClient(event) {
|
||||
const client = await self.clients.get(event.clientId)
|
||||
const client = await self.clients.get(event.clientId);
|
||||
|
||||
if (activeClientIds.has(event.clientId)) {
|
||||
return client
|
||||
return client;
|
||||
}
|
||||
|
||||
if (client?.frameType === 'top-level') {
|
||||
return client
|
||||
if (client?.frameType === "top-level") {
|
||||
return client;
|
||||
}
|
||||
|
||||
const allClients = await self.clients.matchAll({
|
||||
type: 'window',
|
||||
})
|
||||
type: "window",
|
||||
});
|
||||
|
||||
return allClients
|
||||
.filter((client) => {
|
||||
// Get only those clients that are currently visible.
|
||||
return client.visibilityState === 'visible'
|
||||
return client.visibilityState === "visible";
|
||||
})
|
||||
.find((client) => {
|
||||
// Find the client ID that's recorded in the
|
||||
// set of clients that have registered the worker.
|
||||
return activeClientIds.has(client.id)
|
||||
})
|
||||
return activeClientIds.has(client.id);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,36 +203,34 @@ async function resolveMainClient(event) {
|
||||
async function getResponse(event, client, requestId, requestInterceptedAt) {
|
||||
// Clone the request because it might've been already used
|
||||
// (i.e. its body has been read and sent to the client).
|
||||
const requestClone = event.request.clone()
|
||||
const requestClone = event.request.clone();
|
||||
|
||||
function passthrough() {
|
||||
// Cast the request headers to a new Headers instance
|
||||
// so the headers can be manipulated with.
|
||||
const headers = new Headers(requestClone.headers)
|
||||
const headers = new Headers(requestClone.headers);
|
||||
|
||||
// Remove the "accept" header value that marked this request as passthrough.
|
||||
// This prevents request alteration and also keeps it compliant with the
|
||||
// user-defined CORS policies.
|
||||
const acceptHeader = headers.get('accept')
|
||||
const acceptHeader = headers.get("accept");
|
||||
if (acceptHeader) {
|
||||
const values = acceptHeader.split(',').map((value) => value.trim())
|
||||
const filteredValues = values.filter(
|
||||
(value) => value !== 'msw/passthrough',
|
||||
)
|
||||
const values = acceptHeader.split(",").map((value) => value.trim());
|
||||
const filteredValues = values.filter((value) => value !== "msw/passthrough");
|
||||
|
||||
if (filteredValues.length > 0) {
|
||||
headers.set('accept', filteredValues.join(', '))
|
||||
headers.set("accept", filteredValues.join(", "));
|
||||
} else {
|
||||
headers.delete('accept')
|
||||
headers.delete("accept");
|
||||
}
|
||||
}
|
||||
|
||||
return fetch(requestClone, { headers })
|
||||
return fetch(requestClone, { headers });
|
||||
}
|
||||
|
||||
// Bypass mocking when the client is not active.
|
||||
if (!client) {
|
||||
return passthrough()
|
||||
return passthrough();
|
||||
}
|
||||
|
||||
// Bypass initial page load requests (i.e. static assets).
|
||||
@@ -248,15 +238,15 @@ async function getResponse(event, client, requestId, requestInterceptedAt) {
|
||||
// means that MSW hasn't dispatched the "MOCK_ACTIVATE" event yet
|
||||
// and is not ready to handle requests.
|
||||
if (!activeClientIds.has(client.id)) {
|
||||
return passthrough()
|
||||
return passthrough();
|
||||
}
|
||||
|
||||
// Notify the client that a request has been intercepted.
|
||||
const serializedRequest = await serializeRequest(event.request)
|
||||
const serializedRequest = await serializeRequest(event.request);
|
||||
const clientMessage = await sendToClient(
|
||||
client,
|
||||
{
|
||||
type: 'REQUEST',
|
||||
type: "REQUEST",
|
||||
payload: {
|
||||
id: requestId,
|
||||
interceptedAt: requestInterceptedAt,
|
||||
@@ -264,19 +254,19 @@ async function getResponse(event, client, requestId, requestInterceptedAt) {
|
||||
},
|
||||
},
|
||||
[serializedRequest.body],
|
||||
)
|
||||
);
|
||||
|
||||
switch (clientMessage.type) {
|
||||
case 'MOCK_RESPONSE': {
|
||||
return respondWithMock(clientMessage.data)
|
||||
case "MOCK_RESPONSE": {
|
||||
return respondWithMock(clientMessage.data);
|
||||
}
|
||||
|
||||
case 'PASSTHROUGH': {
|
||||
return passthrough()
|
||||
case "PASSTHROUGH": {
|
||||
return passthrough();
|
||||
}
|
||||
}
|
||||
|
||||
return passthrough()
|
||||
return passthrough();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -287,21 +277,18 @@ async function getResponse(event, client, requestId, requestInterceptedAt) {
|
||||
*/
|
||||
function sendToClient(client, message, transferrables = []) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const channel = new MessageChannel()
|
||||
const channel = new MessageChannel();
|
||||
|
||||
channel.port1.onmessage = (event) => {
|
||||
if (event.data && event.data.error) {
|
||||
return reject(event.data.error)
|
||||
return reject(event.data.error);
|
||||
}
|
||||
|
||||
resolve(event.data)
|
||||
}
|
||||
resolve(event.data);
|
||||
};
|
||||
|
||||
client.postMessage(message, [
|
||||
channel.port2,
|
||||
...transferrables.filter(Boolean),
|
||||
])
|
||||
})
|
||||
client.postMessage(message, [channel.port2, ...transferrables.filter(Boolean)]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -314,17 +301,17 @@ function respondWithMock(response) {
|
||||
// instance will have status code set to 0. Since it's not possible to create
|
||||
// a Response instance with status code 0, handle that use-case separately.
|
||||
if (response.status === 0) {
|
||||
return Response.error()
|
||||
return Response.error();
|
||||
}
|
||||
|
||||
const mockedResponse = new Response(response.body, response)
|
||||
const mockedResponse = new Response(response.body, response);
|
||||
|
||||
Reflect.defineProperty(mockedResponse, IS_MOCKED_RESPONSE, {
|
||||
value: true,
|
||||
enumerable: true,
|
||||
})
|
||||
});
|
||||
|
||||
return mockedResponse
|
||||
return mockedResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -345,5 +332,5 @@ async function serializeRequest(request) {
|
||||
referrerPolicy: request.referrerPolicy,
|
||||
body: await request.arrayBuffer(),
|
||||
keepalive: request.keepalive,
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { AUTO_SCROLL_BOTTOM_THRESHOLD_PX, isScrollContainerNearBottom } from "./chat-scroll";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { GitBranch } from "@t3tools/contracts";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
import {
|
||||
dedupeRemoteBranchesWithLocalMatches,
|
||||
deriveLocalBranchNameFromRemoteRef,
|
||||
|
||||
@@ -20,8 +20,17 @@ import {
|
||||
import { RouterProvider, createMemoryHistory } from "@tanstack/react-router";
|
||||
import { HttpResponse, http, ws } from "msw";
|
||||
import { setupWorker } from "msw/browser";
|
||||
import { page } from "vitest/browser";
|
||||
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { page } from "vite-plus/test/browser";
|
||||
import {
|
||||
afterAll,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
beforeEach,
|
||||
describe,
|
||||
expect,
|
||||
it,
|
||||
vi,
|
||||
} from "vite-plus/test";
|
||||
import { render } from "vitest-browser-react";
|
||||
|
||||
import { useComposerDraftStore } from "../composerDraftStore";
|
||||
@@ -757,12 +766,30 @@ async function triggerChatNewShortcutUntilPath(
|
||||
|
||||
async function waitForNewThreadShortcutLabel(): Promise<void> {
|
||||
const newThreadButton = page.getByTestId("new-thread-button");
|
||||
await expect.element(newThreadButton).toBeInTheDocument();
|
||||
await waitForLocatorVisible(newThreadButton);
|
||||
await newThreadButton.hover();
|
||||
const shortcutLabel = isMacPlatform(navigator.platform)
|
||||
? "New thread (⇧⌘O)"
|
||||
: "New thread (Ctrl+Shift+O)";
|
||||
await expect.element(page.getByText(shortcutLabel)).toBeInTheDocument();
|
||||
await waitForLocatorVisible(page.getByText(shortcutLabel));
|
||||
}
|
||||
|
||||
async function waitForLocatorVisible(locator: {
|
||||
query: () => HTMLElement | SVGElement | null;
|
||||
}): Promise<void> {
|
||||
await vi.waitFor(
|
||||
() => {
|
||||
const element = locator.query();
|
||||
expect(element).not.toBeNull();
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
const style = getComputedStyle(element);
|
||||
expect(style.display).not.toBe("none");
|
||||
expect(style.visibility).not.toBe("hidden");
|
||||
},
|
||||
{ timeout: 4_000, interval: 16 },
|
||||
);
|
||||
}
|
||||
|
||||
async function waitForImagesToLoad(scope: ParentNode): Promise<void> {
|
||||
@@ -1128,7 +1155,7 @@ describe("ChatView timeline estimator parity (full app)", () => {
|
||||
});
|
||||
|
||||
try {
|
||||
await expect.element(page.getByText("No threads yet")).toBeInTheDocument();
|
||||
await waitForLocatorVisible(page.getByText("No threads yet"));
|
||||
} finally {
|
||||
await mounted.cleanup();
|
||||
}
|
||||
@@ -1865,7 +1892,7 @@ describe("ChatView timeline estimator parity (full app)", () => {
|
||||
try {
|
||||
const threadRow = page.getByTestId(`thread-row-${THREAD_ID}`);
|
||||
|
||||
await expect.element(threadRow).toBeInTheDocument();
|
||||
await waitForLocatorVisible(threadRow);
|
||||
const archiveButton = await waitForElement(
|
||||
() =>
|
||||
document.querySelector<HTMLButtonElement>(`[data-testid="thread-archive-${THREAD_ID}"]`),
|
||||
@@ -1918,16 +1945,15 @@ describe("ChatView timeline estimator parity (full app)", () => {
|
||||
try {
|
||||
const threadRow = page.getByTestId(`thread-row-${THREAD_ID}`);
|
||||
|
||||
await expect.element(threadRow).toBeInTheDocument();
|
||||
await waitForLocatorVisible(threadRow);
|
||||
await threadRow.hover();
|
||||
|
||||
const archiveButton = page.getByTestId(`thread-archive-${THREAD_ID}`);
|
||||
await expect.element(archiveButton).toBeInTheDocument();
|
||||
await waitForLocatorVisible(archiveButton);
|
||||
await archiveButton.click();
|
||||
|
||||
const confirmButton = page.getByTestId(`thread-archive-confirm-${THREAD_ID}`);
|
||||
await expect.element(confirmButton).toBeInTheDocument();
|
||||
await expect.element(confirmButton).toBeVisible();
|
||||
await waitForLocatorVisible(confirmButton);
|
||||
} finally {
|
||||
localStorage.removeItem("t3code:client-settings:v1");
|
||||
await mounted.cleanup();
|
||||
@@ -1946,7 +1972,7 @@ describe("ChatView timeline estimator parity (full app)", () => {
|
||||
try {
|
||||
// Wait for the sidebar to render with the project.
|
||||
const newThreadButton = page.getByTestId("new-thread-button");
|
||||
await expect.element(newThreadButton).toBeInTheDocument();
|
||||
await waitForLocatorVisible(newThreadButton);
|
||||
|
||||
await newThreadButton.click();
|
||||
|
||||
@@ -1974,10 +2000,8 @@ describe("ChatView timeline estimator parity (full app)", () => {
|
||||
);
|
||||
|
||||
// The empty thread view and composer should still be visible.
|
||||
await expect
|
||||
.element(page.getByText("Send a message to start the conversation."))
|
||||
.toBeInTheDocument();
|
||||
await expect.element(page.getByTestId("composer-editor")).toBeInTheDocument();
|
||||
await waitForLocatorVisible(page.getByText("Send a message to start the conversation."));
|
||||
await waitForLocatorVisible(page.getByTestId("composer-editor"));
|
||||
} finally {
|
||||
await mounted.cleanup();
|
||||
}
|
||||
@@ -2008,7 +2032,7 @@ describe("ChatView timeline estimator parity (full app)", () => {
|
||||
|
||||
try {
|
||||
const newThreadButton = page.getByTestId("new-thread-button");
|
||||
await expect.element(newThreadButton).toBeInTheDocument();
|
||||
await waitForLocatorVisible(newThreadButton);
|
||||
|
||||
await newThreadButton.click();
|
||||
|
||||
@@ -2061,7 +2085,7 @@ describe("ChatView timeline estimator parity (full app)", () => {
|
||||
|
||||
try {
|
||||
const newThreadButton = page.getByTestId("new-thread-button");
|
||||
await expect.element(newThreadButton).toBeInTheDocument();
|
||||
await waitForLocatorVisible(newThreadButton);
|
||||
|
||||
await newThreadButton.click();
|
||||
|
||||
@@ -2101,7 +2125,7 @@ describe("ChatView timeline estimator parity (full app)", () => {
|
||||
|
||||
try {
|
||||
const newThreadButton = page.getByTestId("new-thread-button");
|
||||
await expect.element(newThreadButton).toBeInTheDocument();
|
||||
await waitForLocatorVisible(newThreadButton);
|
||||
|
||||
await newThreadButton.click();
|
||||
|
||||
@@ -2143,7 +2167,7 @@ describe("ChatView timeline estimator parity (full app)", () => {
|
||||
|
||||
try {
|
||||
const newThreadButton = page.getByTestId("new-thread-button");
|
||||
await expect.element(newThreadButton).toBeInTheDocument();
|
||||
await waitForLocatorVisible(newThreadButton);
|
||||
|
||||
await newThreadButton.click();
|
||||
|
||||
@@ -2280,7 +2304,7 @@ describe("ChatView timeline estimator parity (full app)", () => {
|
||||
|
||||
try {
|
||||
const newThreadButton = page.getByTestId("new-thread-button");
|
||||
await expect.element(newThreadButton).toBeInTheDocument();
|
||||
await waitForLocatorVisible(newThreadButton);
|
||||
await waitForNewThreadShortcutLabel();
|
||||
await waitForServerConfigToApply();
|
||||
await newThreadButton.click();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ProjectId, ThreadId, TurnId } from "@t3tools/contracts";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, describe, expect, it, vi } from "vite-plus/test";
|
||||
import { useStore } from "../store";
|
||||
|
||||
import {
|
||||
|
||||
@@ -1812,9 +1812,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
handleInteractionModeChange(interactionMode === "plan" ? "default" : "plan");
|
||||
}, [handleInteractionModeChange, interactionMode]);
|
||||
const toggleRuntimeMode = useCallback(() => {
|
||||
void handleRuntimeModeChange(
|
||||
runtimeMode === "full-access" ? "approval-required" : "full-access",
|
||||
);
|
||||
handleRuntimeModeChange(runtimeMode === "full-access" ? "approval-required" : "full-access");
|
||||
}, [handleRuntimeModeChange, runtimeMode]);
|
||||
const togglePlanSidebar = useCallback(() => {
|
||||
setPlanSidebarOpen((open) => {
|
||||
@@ -3488,7 +3486,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
void handleInteractionModeChange(item.command === "plan" ? "plan" : "default");
|
||||
handleInteractionModeChange(item.command === "plan" ? "plan" : "default");
|
||||
const applied = applyPromptReplacement(trigger.rangeStart, trigger.rangeEnd, "", {
|
||||
expectedText: snapshot.value.slice(trigger.rangeStart, trigger.rangeEnd),
|
||||
});
|
||||
@@ -4063,7 +4061,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
size="sm"
|
||||
type="button"
|
||||
onClick={() =>
|
||||
void handleRuntimeModeChange(
|
||||
handleRuntimeModeChange(
|
||||
runtimeMode === "full-access"
|
||||
? "approval-required"
|
||||
: "full-access",
|
||||
|
||||
@@ -597,7 +597,7 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
|
||||
data-diff-file-path={filePath}
|
||||
className="diff-render-file mb-2 rounded-md first:mt-2 last:mb-0"
|
||||
onClickCapture={(event) => {
|
||||
const nativeEvent = event.nativeEvent as MouseEvent;
|
||||
const nativeEvent = event.nativeEvent;
|
||||
const composedPath = nativeEvent.composedPath?.() ?? [];
|
||||
const clickedHeader = composedPath.some((node) => {
|
||||
if (!(node instanceof Element)) return false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { GitStatusResult } from "@t3tools/contracts";
|
||||
import { assert, describe, it } from "vitest";
|
||||
import { assert, describe, it } from "vite-plus/test";
|
||||
import {
|
||||
buildGitActionProgressStages,
|
||||
buildMenuItems,
|
||||
|
||||
@@ -14,7 +14,16 @@ import {
|
||||
import { RouterProvider, createMemoryHistory } from "@tanstack/react-router";
|
||||
import { ws, http, HttpResponse } from "msw";
|
||||
import { setupWorker } from "msw/browser";
|
||||
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
afterAll,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
beforeEach,
|
||||
describe,
|
||||
expect,
|
||||
it,
|
||||
vi,
|
||||
} from "vite-plus/test";
|
||||
import { render } from "vitest-browser-react";
|
||||
|
||||
import { useComposerDraftStore } from "../composerDraftStore";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
createThreadJumpHintVisibilityController,
|
||||
|
||||
@@ -440,7 +440,7 @@ function getLatestUserMessageTimestamp(thread: SidebarThreadSortInput): number {
|
||||
|
||||
function getThreadSortTimestamp(
|
||||
thread: SidebarThreadSortInput,
|
||||
sortOrder: SidebarThreadSortOrder | Exclude<SidebarProjectSortOrder, "manual">,
|
||||
sortOrder: SidebarThreadSortOrder,
|
||||
): number {
|
||||
if (sortOrder === "created_at") {
|
||||
return toSortableTimestamp(thread.createdAt) ?? Number.NEGATIVE_INFINITY;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
resolveTerminalSelectionActionPosition,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { DEFAULT_MODEL_BY_PROVIDER, ModelSelection, ThreadId } from "@t3tools/contracts";
|
||||
import "../../index.css";
|
||||
|
||||
import { page } from "vitest/browser";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { page } from "vite-plus/test/browser";
|
||||
import { afterEach, describe, expect, it, vi } from "vite-plus/test";
|
||||
import { render } from "vitest-browser-react";
|
||||
|
||||
import { CompactComposerControlsMenu } from "./CompactComposerControlsMenu";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ThreadId } from "@t3tools/contracts";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { ComposerPendingTerminalContextChip } from "./ComposerPendingTerminalContexts";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
import { computeMessageDurationStart, normalizeCompactToolLabel } from "./MessagesTimeline.logic";
|
||||
|
||||
describe("computeMessageDurationStart", () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { MessageId } from "@t3tools/contracts";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { beforeAll, describe, expect, it, vi } from "vitest";
|
||||
import { beforeAll, describe, expect, it, vi } from "vite-plus/test";
|
||||
|
||||
function matchMedia() {
|
||||
return {
|
||||
|
||||
@@ -198,7 +198,7 @@ export const ProposedPlanCard = memo(function ProposedPlanCard({
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={() => void handleSaveToWorkspace()}
|
||||
onClick={() => handleSaveToWorkspace()}
|
||||
disabled={isSavingToWorkspace}
|
||||
>
|
||||
{isSavingToWorkspace ? "Saving..." : "Save"}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { type ProviderKind, type ServerProvider } from "@t3tools/contracts";
|
||||
import { page } from "vitest/browser";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { page } from "vite-plus/test/browser";
|
||||
import { afterEach, describe, expect, it, vi } from "vite-plus/test";
|
||||
import { render } from "vitest-browser-react";
|
||||
|
||||
import { ProviderModelPicker } from "./ProviderModelPicker";
|
||||
|
||||
@@ -10,9 +10,9 @@ import {
|
||||
type ServerProvider,
|
||||
ThreadId,
|
||||
} from "@t3tools/contracts";
|
||||
import { page } from "vitest/browser";
|
||||
import { page } from "vite-plus/test/browser";
|
||||
import { useCallback } from "react";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, describe, expect, it, vi } from "vite-plus/test";
|
||||
import { render } from "vitest-browser-react";
|
||||
|
||||
import { TraitsPicker } from "./TraitsPicker";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
import type { ServerProviderModel } from "@t3tools/contracts";
|
||||
import { getComposerProviderState } from "./composerProviderRegistry";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
buildInlineTerminalContextText,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
COMPOSER_FOOTER_COMPACT_BREAKPOINT_PX,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
import type { DesktopUpdateActionResult, DesktopUpdateState } from "@t3tools/contracts";
|
||||
|
||||
import {
|
||||
|
||||
@@ -1043,7 +1043,7 @@ export function GeneralSettingsPanel() {
|
||||
variant="ghost"
|
||||
className="size-5 rounded-sm p-0 text-muted-foreground hover:text-foreground"
|
||||
disabled={isRefreshingProviders}
|
||||
onClick={() => void refreshProviders()}
|
||||
onClick={() => refreshProviders()}
|
||||
aria-label="Refresh provider status"
|
||||
>
|
||||
{isRefreshingProviders ? (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { appendTerminalContextsToPrompt } from "../lib/terminalContext";
|
||||
import { buildInlineTerminalContextText } from "./chat/userMessageTerminalContexts";
|
||||
|
||||
@@ -23,7 +23,7 @@ function AutocompleteInput({
|
||||
size?: "sm" | "default" | "lg" | number;
|
||||
ref?: React.Ref<HTMLInputElement>;
|
||||
}) {
|
||||
const sizeValue = (size ?? "default") as "sm" | "default" | "lg" | number;
|
||||
const sizeValue = size ?? "default";
|
||||
|
||||
return (
|
||||
<div className="relative not-has-[>*.w-full]:w-fit w-full text-foreground has-disabled:opacity-64">
|
||||
|
||||
@@ -36,7 +36,7 @@ function ComboboxChipsInput({
|
||||
size?: "sm" | "default" | "lg" | number;
|
||||
ref?: React.Ref<HTMLInputElement>;
|
||||
}) {
|
||||
const sizeValue = (size ?? "default") as "sm" | "default" | "lg" | number;
|
||||
const sizeValue = size ?? "default";
|
||||
|
||||
return (
|
||||
<ComboboxPrimitive.Input
|
||||
@@ -69,7 +69,7 @@ function ComboboxInput({
|
||||
size?: "sm" | "default" | "lg" | number;
|
||||
ref?: React.Ref<HTMLInputElement>;
|
||||
}) {
|
||||
const sizeValue = (size ?? "default") as "sm" | "default" | "lg" | number;
|
||||
const sizeValue = size ?? "default";
|
||||
|
||||
return (
|
||||
<div className="relative not-has-[>*.w-full]:w-fit w-full text-foreground has-disabled:opacity-64">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
SidebarMenuAction,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { assert, describe, it } from "vitest";
|
||||
import { assert, describe, it } from "vite-plus/test";
|
||||
import { buildVisibleToastLayout, shouldHideCollapsedToastContent } from "./toast.logic";
|
||||
|
||||
describe("shouldHideCollapsedToastContent", () => {
|
||||
|
||||
Loaded 100 of 174 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user