Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ec01e28bd | ||
|
|
2ade03788b | ||
|
|
48fc85e7fe |
No files matched your search
@@ -116,7 +116,6 @@ const seedProjectAndThread = (harness: OrchestrationIntegrationHarness) =>
|
||||
projectId: PROJECT_ID,
|
||||
title: "Integration Project",
|
||||
workspaceRoot: harness.workspaceDir,
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider,
|
||||
model: defaultModel,
|
||||
@@ -130,7 +129,6 @@ const seedProjectAndThread = (harness: OrchestrationIntegrationHarness) =>
|
||||
threadId: THREAD_ID,
|
||||
projectId: PROJECT_ID,
|
||||
title: "Integration Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider,
|
||||
model: defaultModel,
|
||||
@@ -267,7 +265,6 @@ it.live.skipIf(!process.env.CODEX_BINARY_PATH)(
|
||||
projectId: PROJECT_ID,
|
||||
title: "Integration Project",
|
||||
workspaceRoot: harness.workspaceDir,
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
@@ -281,7 +278,6 @@ it.live.skipIf(!process.env.CODEX_BINARY_PATH)(
|
||||
threadId: THREAD_ID,
|
||||
projectId: PROJECT_ID,
|
||||
title: "Integration Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
"@pierre/diffs": "^1.1.0-beta.16",
|
||||
"effect": "catalog:",
|
||||
"node-pty": "^1.1.0",
|
||||
"open": "^10.1.0",
|
||||
"ws": "^8.18.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -31,7 +31,6 @@ function makeSnapshot(input: {
|
||||
id: input.projectId,
|
||||
title: "Project",
|
||||
workspaceRoot: input.workspaceRoot,
|
||||
pinned: false,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: "2026-01-01T00:00:00.000Z",
|
||||
@@ -44,7 +43,6 @@ function makeSnapshot(input: {
|
||||
id: input.threadId,
|
||||
projectId: input.projectId,
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -51,6 +51,8 @@ const testLayer = Layer.mergeAll(
|
||||
stopSignal: Effect.void,
|
||||
} satisfies ServerShape),
|
||||
Layer.succeed(Open, {
|
||||
getAvailableEditors: Effect.succeed([]),
|
||||
openExternal: () => Effect.void,
|
||||
openBrowser: (_target: string) => Effect.void,
|
||||
openInEditor: () => Effect.void,
|
||||
} satisfies OpenShape),
|
||||
|
||||
+536
-247
@@ -1,269 +1,558 @@
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
|
||||
import * as NodePath from "@effect/platform-node/NodePath";
|
||||
import { assert, it } from "@effect/vitest";
|
||||
import { assertSuccess } from "@effect/vitest/utils";
|
||||
import { FileSystem, Path, Effect } from "effect";
|
||||
|
||||
import {
|
||||
isCommandAvailable,
|
||||
launchDetached,
|
||||
resolveAvailableEditors,
|
||||
resolveEditorLaunch,
|
||||
} from "./open";
|
||||
Deferred,
|
||||
Effect,
|
||||
Exit,
|
||||
FileSystem,
|
||||
Layer,
|
||||
PlatformError,
|
||||
Scope,
|
||||
Sink,
|
||||
Stream,
|
||||
} from "effect";
|
||||
import { ChildProcessSpawner } from "effect/unstable/process";
|
||||
|
||||
it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => {
|
||||
it.effect("returns commands for command-based editors", () =>
|
||||
Effect.gen(function* () {
|
||||
const antigravityLaunch = yield* resolveEditorLaunch(
|
||||
{ cwd: "/tmp/workspace", editor: "antigravity" },
|
||||
"darwin",
|
||||
);
|
||||
assert.deepEqual(antigravityLaunch, {
|
||||
command: "agy",
|
||||
args: ["/tmp/workspace"],
|
||||
});
|
||||
import { makeOpenLayer, Open } from "./open";
|
||||
|
||||
const cursorLaunch = yield* resolveEditorLaunch(
|
||||
{ cwd: "/tmp/workspace", editor: "cursor" },
|
||||
"darwin",
|
||||
);
|
||||
assert.deepEqual(cursorLaunch, {
|
||||
command: "cursor",
|
||||
args: ["/tmp/workspace"],
|
||||
});
|
||||
const encoder = new TextEncoder();
|
||||
|
||||
const vscodeLaunch = yield* resolveEditorLaunch(
|
||||
{ cwd: "/tmp/workspace", editor: "vscode" },
|
||||
"darwin",
|
||||
);
|
||||
assert.deepEqual(vscodeLaunch, {
|
||||
command: "code",
|
||||
args: ["/tmp/workspace"],
|
||||
});
|
||||
interface SpawnCall {
|
||||
readonly command: string;
|
||||
readonly args: ReadonlyArray<string>;
|
||||
readonly detached?: boolean | undefined;
|
||||
readonly shell?: boolean | string | undefined;
|
||||
readonly stdin?: unknown;
|
||||
readonly stdout?: unknown;
|
||||
readonly stderr?: unknown;
|
||||
}
|
||||
|
||||
const vscodeInsidersLaunch = yield* resolveEditorLaunch(
|
||||
{ cwd: "/tmp/workspace", editor: "vscode-insiders" },
|
||||
"darwin",
|
||||
);
|
||||
assert.deepEqual(vscodeInsidersLaunch, {
|
||||
command: "code-insiders",
|
||||
args: ["/tmp/workspace"],
|
||||
});
|
||||
function decodePowerShellCommand(encoded: string): string {
|
||||
return Buffer.from(encoded, "base64").toString("utf16le");
|
||||
}
|
||||
|
||||
const vscodiumLaunch = yield* resolveEditorLaunch(
|
||||
{ cwd: "/tmp/workspace", editor: "vscodium" },
|
||||
"darwin",
|
||||
);
|
||||
assert.deepEqual(vscodiumLaunch, {
|
||||
command: "codium",
|
||||
args: ["/tmp/workspace"],
|
||||
});
|
||||
function platformSpawnError(message: string) {
|
||||
return PlatformError.systemError({
|
||||
_tag: "Unknown",
|
||||
module: "ChildProcess",
|
||||
method: "spawn",
|
||||
description: message,
|
||||
});
|
||||
}
|
||||
|
||||
const zedLaunch = yield* resolveEditorLaunch(
|
||||
{ cwd: "/tmp/workspace", editor: "zed" },
|
||||
"darwin",
|
||||
function spawnerLayer(
|
||||
calls: Array<SpawnCall>,
|
||||
handler: (call: SpawnCall) => {
|
||||
readonly code?: number;
|
||||
readonly fail?: string;
|
||||
readonly awaitExit?: Deferred.Deferred<void>;
|
||||
readonly onKill?: () => void;
|
||||
} = () => ({
|
||||
code: 0,
|
||||
}),
|
||||
) {
|
||||
return Layer.succeed(
|
||||
ChildProcessSpawner.ChildProcessSpawner,
|
||||
ChildProcessSpawner.make((command) => {
|
||||
const standardCommand = command as unknown as {
|
||||
readonly command: string;
|
||||
readonly args: ReadonlyArray<string>;
|
||||
readonly options: {
|
||||
readonly detached?: boolean;
|
||||
readonly shell?: boolean | string;
|
||||
readonly stdin?: unknown;
|
||||
readonly stdout?: unknown;
|
||||
readonly stderr?: unknown;
|
||||
};
|
||||
};
|
||||
|
||||
const call: SpawnCall = {
|
||||
command: standardCommand.command,
|
||||
args: [...standardCommand.args],
|
||||
detached: standardCommand.options.detached,
|
||||
shell: standardCommand.options.shell,
|
||||
stdin: standardCommand.options.stdin,
|
||||
stdout: standardCommand.options.stdout,
|
||||
stderr: standardCommand.options.stderr,
|
||||
};
|
||||
calls.push(call);
|
||||
|
||||
const result = handler(call);
|
||||
if (result.fail) {
|
||||
return Effect.fail(platformSpawnError(result.fail));
|
||||
}
|
||||
|
||||
let exited = false;
|
||||
const exitCode = result.awaitExit
|
||||
? Deferred.await(result.awaitExit).pipe(
|
||||
Effect.tap(() =>
|
||||
Effect.sync(() => {
|
||||
exited = true;
|
||||
}),
|
||||
),
|
||||
Effect.andThen(Effect.succeed(ChildProcessSpawner.ExitCode(result.code ?? 0))),
|
||||
)
|
||||
: Effect.sync(() => {
|
||||
exited = true;
|
||||
return ChildProcessSpawner.ExitCode(result.code ?? 0);
|
||||
});
|
||||
|
||||
return Effect.succeed(
|
||||
ChildProcessSpawner.makeHandle({
|
||||
pid: ChildProcessSpawner.ProcessId(calls.length),
|
||||
exitCode,
|
||||
isRunning: Effect.succeed(false),
|
||||
kill: () =>
|
||||
Effect.sync(() => {
|
||||
if (!exited) {
|
||||
result.onKill?.();
|
||||
}
|
||||
}),
|
||||
stdin: Sink.drain,
|
||||
stdout: Stream.make(encoder.encode("")),
|
||||
stderr: Stream.make(encoder.encode("")),
|
||||
all: Stream.empty,
|
||||
getInputFd: () => Sink.drain,
|
||||
getOutputFd: () => Stream.empty,
|
||||
}),
|
||||
);
|
||||
assert.deepEqual(zedLaunch, {
|
||||
command: "zed",
|
||||
args: ["/tmp/workspace"],
|
||||
});
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
it.effect("uses --goto when editor supports line/column suffixes", () =>
|
||||
Effect.gen(function* () {
|
||||
const lineOnly = yield* resolveEditorLaunch(
|
||||
{ cwd: "/tmp/workspace/AGENTS.md:48", editor: "cursor" },
|
||||
"darwin",
|
||||
);
|
||||
assert.deepEqual(lineOnly, {
|
||||
command: "cursor",
|
||||
args: ["--goto", "/tmp/workspace/AGENTS.md:48"],
|
||||
});
|
||||
|
||||
const lineAndColumn = yield* resolveEditorLaunch(
|
||||
{ cwd: "/tmp/workspace/src/open.ts:71:5", editor: "cursor" },
|
||||
"darwin",
|
||||
);
|
||||
assert.deepEqual(lineAndColumn, {
|
||||
command: "cursor",
|
||||
args: ["--goto", "/tmp/workspace/src/open.ts:71:5"],
|
||||
});
|
||||
|
||||
const vscodeLineAndColumn = yield* resolveEditorLaunch(
|
||||
{ cwd: "/tmp/workspace/src/open.ts:71:5", editor: "vscode" },
|
||||
"darwin",
|
||||
);
|
||||
assert.deepEqual(vscodeLineAndColumn, {
|
||||
command: "code",
|
||||
args: ["--goto", "/tmp/workspace/src/open.ts:71:5"],
|
||||
});
|
||||
|
||||
const vscodeInsidersLineAndColumn = yield* resolveEditorLaunch(
|
||||
{ cwd: "/tmp/workspace/src/open.ts:71:5", editor: "vscode-insiders" },
|
||||
"darwin",
|
||||
);
|
||||
assert.deepEqual(vscodeInsidersLineAndColumn, {
|
||||
command: "code-insiders",
|
||||
args: ["--goto", "/tmp/workspace/src/open.ts:71:5"],
|
||||
});
|
||||
|
||||
const vscodiumLineAndColumn = yield* resolveEditorLaunch(
|
||||
{ cwd: "/tmp/workspace/src/open.ts:71:5", editor: "vscodium" },
|
||||
"darwin",
|
||||
);
|
||||
assert.deepEqual(vscodiumLineAndColumn, {
|
||||
command: "codium",
|
||||
args: ["--goto", "/tmp/workspace/src/open.ts:71:5"],
|
||||
});
|
||||
|
||||
const zedLineAndColumn = yield* resolveEditorLaunch(
|
||||
{ cwd: "/tmp/workspace/src/open.ts:71:5", editor: "zed" },
|
||||
"darwin",
|
||||
);
|
||||
assert.deepEqual(zedLineAndColumn, {
|
||||
command: "zed",
|
||||
args: ["/tmp/workspace/src/open.ts:71:5"],
|
||||
});
|
||||
}),
|
||||
const provideOpen = (
|
||||
options: Parameters<typeof makeOpenLayer>[0],
|
||||
spawnLayer: Layer.Layer<ChildProcessSpawner.ChildProcessSpawner>,
|
||||
) =>
|
||||
makeOpenLayer(options).pipe(
|
||||
Layer.provide(Layer.mergeAll(NodeFileSystem.layer, NodePath.layer, spawnLayer)),
|
||||
);
|
||||
|
||||
it.effect("maps file-manager editor to OS open commands", () =>
|
||||
Effect.gen(function* () {
|
||||
const launch1 = yield* resolveEditorLaunch(
|
||||
{ cwd: "/tmp/workspace", editor: "file-manager" },
|
||||
"darwin",
|
||||
);
|
||||
assert.deepEqual(launch1, {
|
||||
command: "open",
|
||||
args: ["/tmp/workspace"],
|
||||
});
|
||||
const runOpen = <A>(
|
||||
options: Parameters<typeof makeOpenLayer>[0],
|
||||
spawnLayer: Layer.Layer<ChildProcessSpawner.ChildProcessSpawner>,
|
||||
effect: Effect.Effect<A, Error, Open>,
|
||||
) => effect.pipe(Effect.provide(provideOpen(options, spawnLayer)));
|
||||
|
||||
const launch2 = yield* resolveEditorLaunch(
|
||||
{ cwd: "C:\\workspace", editor: "file-manager" },
|
||||
"win32",
|
||||
);
|
||||
assert.deepEqual(launch2, {
|
||||
command: "explorer",
|
||||
args: ["C:\\workspace"],
|
||||
});
|
||||
const readOpen = Effect.service(Open);
|
||||
|
||||
const launch3 = yield* resolveEditorLaunch(
|
||||
{ cwd: "/tmp/workspace", editor: "file-manager" },
|
||||
"linux",
|
||||
);
|
||||
assert.deepEqual(launch3, {
|
||||
command: "xdg-open",
|
||||
args: ["/tmp/workspace"],
|
||||
});
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it.layer(NodeServices.layer)("launchDetached", (it) => {
|
||||
it.effect("resolves when command can be spawned", () =>
|
||||
Effect.gen(function* () {
|
||||
const result = yield* launchDetached({
|
||||
command: process.execPath,
|
||||
args: ["-e", "process.exit(0)"],
|
||||
}).pipe(Effect.result);
|
||||
assertSuccess(result, undefined);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("rejects when command does not exist", () =>
|
||||
Effect.gen(function* () {
|
||||
const result = yield* launchDetached({
|
||||
command: `t3code-no-such-command-${Date.now()}`,
|
||||
args: [],
|
||||
}).pipe(Effect.result);
|
||||
assert.equal(result._tag, "Failure");
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it.layer(NodeServices.layer)("isCommandAvailable", (it) => {
|
||||
it.effect("resolves win32 commands with PATHEXT", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-open-test-" });
|
||||
yield* fs.writeFileString(path.join(dir, "code.CMD"), "@echo off\r\n");
|
||||
const env = {
|
||||
PATH: dir,
|
||||
PATHEXT: ".COM;.EXE;.BAT;.CMD",
|
||||
} satisfies NodeJS.ProcessEnv;
|
||||
assert.equal(isCommandAvailable("code", { platform: "win32", env }), true);
|
||||
}),
|
||||
);
|
||||
|
||||
it("returns false when a command is not on PATH", () => {
|
||||
const env = {
|
||||
PATH: "",
|
||||
PATHEXT: ".COM;.EXE;.BAT;.CMD",
|
||||
} satisfies NodeJS.ProcessEnv;
|
||||
assert.equal(isCommandAvailable("definitely-not-installed", { platform: "win32", env }), false);
|
||||
const writeExecutable = (filePath: string) =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
yield* fs.writeFileString(filePath, "#!/bin/sh\nexit 0\n");
|
||||
yield* fs.chmod(filePath, 0o755);
|
||||
});
|
||||
|
||||
it.effect("does not treat bare files without executable extension as available on win32", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-open-test-" });
|
||||
yield* fs.writeFileString(path.join(dir, "npm"), "echo nope\r\n");
|
||||
const env = {
|
||||
PATH: dir,
|
||||
PATHEXT: ".COM;.EXE;.BAT;.CMD",
|
||||
} satisfies NodeJS.ProcessEnv;
|
||||
assert.equal(isCommandAvailable("npm", { platform: "win32", env }), false);
|
||||
}),
|
||||
);
|
||||
it.effect("getAvailableEditors detects installed editors through the service", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-open-editors-" });
|
||||
yield* fs.writeFileString(`${dir}/code-insiders.CMD`, "@echo off\r\n");
|
||||
yield* fs.writeFileString(`${dir}/codium.CMD`, "@echo off\r\n");
|
||||
yield* fs.writeFileString(`${dir}/explorer.CMD`, "@echo off\r\n");
|
||||
|
||||
it.effect("appends PATHEXT for commands with non-executable extensions on win32", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-open-test-" });
|
||||
yield* fs.writeFileString(path.join(dir, "my.tool.CMD"), "@echo off\r\n");
|
||||
const env = {
|
||||
PATH: dir,
|
||||
PATHEXT: ".COM;.EXE;.BAT;.CMD",
|
||||
} satisfies NodeJS.ProcessEnv;
|
||||
assert.equal(isCommandAvailable("my.tool", { platform: "win32", env }), true);
|
||||
}),
|
||||
);
|
||||
const calls: Array<SpawnCall> = [];
|
||||
const open = yield* runOpen(
|
||||
{
|
||||
platform: "win32",
|
||||
env: {
|
||||
PATH: dir,
|
||||
PATHEXT: ".COM;.EXE;.BAT;.CMD",
|
||||
},
|
||||
},
|
||||
spawnerLayer(calls),
|
||||
readOpen,
|
||||
);
|
||||
|
||||
it.effect("uses platform-specific PATH delimiter for platform overrides", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const firstDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-open-test-" });
|
||||
const secondDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-open-test-" });
|
||||
yield* fs.writeFileString(path.join(firstDir, "code.CMD"), "@echo off\r\n");
|
||||
yield* fs.writeFileString(path.join(secondDir, "code.CMD"), "MZ");
|
||||
const env = {
|
||||
PATH: `${firstDir};${secondDir}`,
|
||||
PATHEXT: ".COM;.EXE;.BAT;.CMD",
|
||||
} satisfies NodeJS.ProcessEnv;
|
||||
assert.equal(isCommandAvailable("code", { platform: "win32", env }), true);
|
||||
}),
|
||||
);
|
||||
});
|
||||
const editors = yield* open.getAvailableEditors;
|
||||
assert.deepEqual(editors, ["vscode-insiders", "vscodium", "file-manager"]);
|
||||
assert.deepEqual(calls, []);
|
||||
}).pipe(Effect.provide(NodeFileSystem.layer)),
|
||||
);
|
||||
|
||||
it.layer(NodeServices.layer)("resolveAvailableEditors", (it) => {
|
||||
it.effect("returns installed editors for command launches", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-editors-" });
|
||||
it.effect("getAvailableEditors does not advertise WSL file-manager from PowerShell alone", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-open-wsl-editors-" });
|
||||
yield* fs.makeDirectory(`${dir}/mnt/c/Windows/System32/WindowsPowerShell/v1.0`, {
|
||||
recursive: true,
|
||||
});
|
||||
yield* writeExecutable(`${dir}/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`);
|
||||
|
||||
yield* fs.writeFileString(path.join(dir, "code-insiders.CMD"), "@echo off\r\n");
|
||||
yield* fs.writeFileString(path.join(dir, "codium.CMD"), "@echo off\r\n");
|
||||
yield* fs.writeFileString(path.join(dir, "explorer.CMD"), "MZ");
|
||||
const editors = resolveAvailableEditors("win32", {
|
||||
PATH: dir,
|
||||
PATHEXT: ".COM;.EXE;.BAT;.CMD",
|
||||
});
|
||||
assert.deepEqual(editors, ["vscode-insiders", "vscodium", "file-manager"]);
|
||||
}),
|
||||
);
|
||||
});
|
||||
const calls: Array<SpawnCall> = [];
|
||||
const open = yield* runOpen(
|
||||
{
|
||||
platform: "linux",
|
||||
env: {
|
||||
PATH: `${dir}:${dir}/mnt/c/Windows/System32/WindowsPowerShell/v1.0`,
|
||||
WSL_DISTRO_NAME: "Ubuntu",
|
||||
},
|
||||
isWsl: true,
|
||||
isInsideContainer: false,
|
||||
powerShellCommand: `${dir}/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,
|
||||
},
|
||||
spawnerLayer(calls),
|
||||
readOpen,
|
||||
);
|
||||
|
||||
const editors = yield* open.getAvailableEditors;
|
||||
assert.equal(editors.includes("file-manager"), false);
|
||||
assert.deepEqual(calls, []);
|
||||
}).pipe(Effect.provide(NodeFileSystem.layer)),
|
||||
);
|
||||
|
||||
it.effect("openInEditor uses --goto for editors that support it", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-open-cursor-" });
|
||||
yield* writeExecutable(`${dir}/cursor`);
|
||||
|
||||
const calls: Array<SpawnCall> = [];
|
||||
const open = yield* runOpen(
|
||||
{
|
||||
platform: "darwin",
|
||||
env: { PATH: dir },
|
||||
},
|
||||
spawnerLayer(calls),
|
||||
readOpen,
|
||||
);
|
||||
|
||||
yield* open.openInEditor({
|
||||
cwd: "/tmp/workspace/src/open.ts:71:5",
|
||||
editor: "cursor",
|
||||
});
|
||||
|
||||
assert.deepEqual(calls, [
|
||||
{
|
||||
command: `${dir}/cursor`,
|
||||
args: ["--goto", "/tmp/workspace/src/open.ts:71:5"],
|
||||
detached: true,
|
||||
shell: false,
|
||||
stdin: "ignore",
|
||||
stdout: "ignore",
|
||||
stderr: "ignore",
|
||||
},
|
||||
]);
|
||||
}).pipe(Effect.provide(NodeFileSystem.layer)),
|
||||
);
|
||||
|
||||
it.effect("openInEditor launches Windows batch shims through cmd.exe without shell mode", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-open-vscode-win32-" });
|
||||
yield* fs.writeFileString(`${dir}/code.cmd`, "@echo off\r\n");
|
||||
|
||||
const calls: Array<SpawnCall> = [];
|
||||
const open = yield* runOpen(
|
||||
{
|
||||
platform: "win32",
|
||||
env: {
|
||||
PATH: dir,
|
||||
PATHEXT: ".COM;.EXE;.BAT;.CMD",
|
||||
},
|
||||
},
|
||||
spawnerLayer(calls),
|
||||
readOpen,
|
||||
);
|
||||
|
||||
yield* open.openInEditor({
|
||||
cwd: "C:\\work\\100% real\\file.ts:12:4",
|
||||
editor: "vscode",
|
||||
});
|
||||
|
||||
assert.equal(calls.length, 1);
|
||||
assert.equal(calls[0]?.command, "cmd.exe");
|
||||
assert.deepEqual(calls[0]?.args.slice(0, 4), ["/d", "/v:off", "/s", "/c"]);
|
||||
assert.equal(calls[0]?.args[4]?.toLowerCase().includes(`${dir}/code.cmd`.toLowerCase()), true);
|
||||
assert.equal(calls[0]?.args[4]?.includes('"--goto"'), true);
|
||||
assert.equal(calls[0]?.args[4]?.includes("100%% real"), true);
|
||||
assert.equal(calls[0]?.detached, true);
|
||||
assert.equal(calls[0]?.shell, false);
|
||||
assert.equal(calls[0]?.stdin, "ignore");
|
||||
assert.equal(calls[0]?.stdout, "ignore");
|
||||
assert.equal(calls[0]?.stderr, "ignore");
|
||||
}).pipe(Effect.provide(NodeFileSystem.layer)),
|
||||
);
|
||||
|
||||
it.effect("openInEditor detached launches survive service scope shutdown", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-open-zed-detached-" });
|
||||
yield* writeExecutable(`${dir}/zed`);
|
||||
|
||||
const calls: Array<SpawnCall> = [];
|
||||
const exitDeferred = yield* Deferred.make<void>();
|
||||
let killCount = 0;
|
||||
|
||||
yield* Effect.acquireUseRelease(
|
||||
Scope.make("sequential"),
|
||||
(scope) =>
|
||||
Effect.gen(function* () {
|
||||
const runtimeServices = yield* Layer.build(
|
||||
provideOpen(
|
||||
{
|
||||
platform: "darwin",
|
||||
env: { PATH: dir },
|
||||
},
|
||||
spawnerLayer(calls, () => ({
|
||||
awaitExit: exitDeferred,
|
||||
onKill: () => {
|
||||
killCount += 1;
|
||||
},
|
||||
})),
|
||||
),
|
||||
).pipe(Scope.provide(scope));
|
||||
|
||||
const open = yield* readOpen.pipe(Effect.provide(runtimeServices), Scope.provide(scope));
|
||||
yield* open.openInEditor({
|
||||
cwd: "/tmp/workspace",
|
||||
editor: "zed",
|
||||
});
|
||||
}),
|
||||
(scope) => Scope.close(scope, Exit.void),
|
||||
);
|
||||
|
||||
assert.equal(killCount, 0);
|
||||
assert.deepEqual(calls, [
|
||||
{
|
||||
command: `${dir}/zed`,
|
||||
args: ["/tmp/workspace"],
|
||||
detached: true,
|
||||
shell: false,
|
||||
stdin: "ignore",
|
||||
stdout: "ignore",
|
||||
stderr: "ignore",
|
||||
},
|
||||
]);
|
||||
|
||||
yield* Deferred.succeed(exitDeferred, void 0);
|
||||
yield* Effect.yieldNow;
|
||||
assert.equal(killCount, 0);
|
||||
}).pipe(Effect.provide(NodeFileSystem.layer)),
|
||||
);
|
||||
|
||||
it.effect("openInEditor uses the default opener for file-manager on macOS", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-open-macos-" });
|
||||
yield* writeExecutable(`${dir}/open`);
|
||||
|
||||
const calls: Array<SpawnCall> = [];
|
||||
const open = yield* runOpen(
|
||||
{
|
||||
platform: "darwin",
|
||||
env: { PATH: dir },
|
||||
},
|
||||
spawnerLayer(calls),
|
||||
readOpen,
|
||||
);
|
||||
|
||||
yield* open.openInEditor({
|
||||
cwd: "/tmp/workspace",
|
||||
editor: "file-manager",
|
||||
});
|
||||
|
||||
assert.deepEqual(calls, [
|
||||
{
|
||||
command: `${dir}/open`,
|
||||
args: ["/tmp/workspace"],
|
||||
detached: undefined,
|
||||
shell: false,
|
||||
stdin: undefined,
|
||||
stdout: undefined,
|
||||
stderr: undefined,
|
||||
},
|
||||
]);
|
||||
}).pipe(Effect.provide(NodeFileSystem.layer)),
|
||||
);
|
||||
|
||||
it.effect("openBrowser uses macOS open flags and app arguments", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-open-browser-macos-" });
|
||||
yield* writeExecutable(`${dir}/open`);
|
||||
|
||||
const calls: Array<SpawnCall> = [];
|
||||
const open = yield* runOpen(
|
||||
{
|
||||
platform: "darwin",
|
||||
env: { PATH: dir },
|
||||
},
|
||||
spawnerLayer(calls),
|
||||
readOpen,
|
||||
);
|
||||
|
||||
yield* open.openBrowser("https://example.com", {
|
||||
wait: true,
|
||||
background: true,
|
||||
newInstance: true,
|
||||
app: {
|
||||
name: "google chrome",
|
||||
arguments: ["--profile-directory=Work"],
|
||||
},
|
||||
});
|
||||
|
||||
assert.deepEqual(calls, [
|
||||
{
|
||||
command: `${dir}/open`,
|
||||
args: [
|
||||
"--wait-apps",
|
||||
"--background",
|
||||
"--new",
|
||||
"-a",
|
||||
"google chrome",
|
||||
"https://example.com",
|
||||
"--args",
|
||||
"--profile-directory=Work",
|
||||
],
|
||||
detached: undefined,
|
||||
shell: false,
|
||||
stdin: undefined,
|
||||
stdout: undefined,
|
||||
stderr: undefined,
|
||||
},
|
||||
]);
|
||||
}).pipe(Effect.provide(NodeFileSystem.layer)),
|
||||
);
|
||||
|
||||
it.effect("openBrowser uses PowerShell on win32", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-open-browser-win32-" });
|
||||
yield* fs.writeFileString(`${dir}/powershell.exe`, "MZ");
|
||||
|
||||
const calls: Array<SpawnCall> = [];
|
||||
const open = yield* runOpen(
|
||||
{
|
||||
platform: "win32",
|
||||
env: {
|
||||
PATH: dir,
|
||||
PATHEXT: ".COM;.EXE;.BAT;.CMD",
|
||||
},
|
||||
},
|
||||
spawnerLayer(calls),
|
||||
readOpen,
|
||||
);
|
||||
|
||||
yield* open.openBrowser("https://example.com");
|
||||
|
||||
assert.equal(calls.length, 1);
|
||||
assert.equal(calls[0]?.command, `${dir}/powershell.exe`);
|
||||
assert.equal(calls[0]?.args.at(-2), "-EncodedCommand");
|
||||
assert.equal(
|
||||
decodePowerShellCommand(calls[0]?.args.at(-1) ?? ""),
|
||||
"Start 'https://example.com'",
|
||||
);
|
||||
}).pipe(Effect.provide(NodeFileSystem.layer)),
|
||||
);
|
||||
|
||||
it.effect("openBrowser falls back from WSL PowerShell to xdg-open", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-open-browser-wsl-" });
|
||||
yield* fs.makeDirectory(`${dir}/mnt/c/Windows/System32/WindowsPowerShell/v1.0`, {
|
||||
recursive: true,
|
||||
});
|
||||
yield* writeExecutable(`${dir}/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`);
|
||||
yield* writeExecutable(`${dir}/xdg-open`);
|
||||
|
||||
const calls: Array<SpawnCall> = [];
|
||||
const open = yield* runOpen(
|
||||
{
|
||||
platform: "linux",
|
||||
env: {
|
||||
PATH: `${dir}:${dir}/mnt/c/Windows/System32/WindowsPowerShell/v1.0`,
|
||||
WSL_DISTRO_NAME: "Ubuntu",
|
||||
},
|
||||
isWsl: true,
|
||||
isInsideContainer: false,
|
||||
powerShellCommand: `${dir}/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,
|
||||
},
|
||||
spawnerLayer(calls, (call) =>
|
||||
call.command.includes("powershell")
|
||||
? { fail: "powershell unavailable" }
|
||||
: {
|
||||
code: 0,
|
||||
},
|
||||
),
|
||||
readOpen,
|
||||
);
|
||||
|
||||
yield* open.openBrowser("https://example.com");
|
||||
|
||||
assert.equal(calls[0]?.command.includes("powershell"), true);
|
||||
assert.equal(calls[1]?.command, `${dir}/xdg-open`);
|
||||
assert.deepEqual(calls[1]?.args, ["https://example.com"]);
|
||||
}).pipe(Effect.provide(NodeFileSystem.layer)),
|
||||
);
|
||||
|
||||
it.effect("openInEditor uses xdg-open first for WSL file-manager paths", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-open-wsl-file-manager-" });
|
||||
yield* fs.makeDirectory(`${dir}/mnt/c/Windows/System32/WindowsPowerShell/v1.0`, {
|
||||
recursive: true,
|
||||
});
|
||||
yield* writeExecutable(`${dir}/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`);
|
||||
yield* writeExecutable(`${dir}/xdg-open`);
|
||||
|
||||
const calls: Array<SpawnCall> = [];
|
||||
const open = yield* runOpen(
|
||||
{
|
||||
platform: "linux",
|
||||
env: {
|
||||
PATH: `${dir}:${dir}/mnt/c/Windows/System32/WindowsPowerShell/v1.0`,
|
||||
WSL_DISTRO_NAME: "Ubuntu",
|
||||
},
|
||||
isWsl: true,
|
||||
isInsideContainer: false,
|
||||
powerShellCommand: `${dir}/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,
|
||||
},
|
||||
spawnerLayer(calls),
|
||||
readOpen,
|
||||
);
|
||||
|
||||
yield* open.openInEditor({
|
||||
cwd: "/home/julius/workspace",
|
||||
editor: "file-manager",
|
||||
});
|
||||
|
||||
assert.deepEqual(calls, [
|
||||
{
|
||||
command: `${dir}/xdg-open`,
|
||||
args: ["/home/julius/workspace"],
|
||||
detached: true,
|
||||
shell: false,
|
||||
stdin: "ignore",
|
||||
stdout: "ignore",
|
||||
stderr: "ignore",
|
||||
},
|
||||
]);
|
||||
}).pipe(Effect.provide(NodeFileSystem.layer)),
|
||||
);
|
||||
|
||||
it.effect("openInEditor fails when the editor command is unavailable", () =>
|
||||
Effect.gen(function* () {
|
||||
const calls: Array<SpawnCall> = [];
|
||||
const open = yield* runOpen(
|
||||
{
|
||||
platform: "darwin",
|
||||
env: { PATH: "" },
|
||||
},
|
||||
spawnerLayer(calls),
|
||||
readOpen,
|
||||
);
|
||||
|
||||
const error = yield* open
|
||||
.openInEditor({
|
||||
cwd: "/tmp/workspace",
|
||||
editor: "cursor",
|
||||
})
|
||||
.pipe(Effect.flip);
|
||||
|
||||
assert.equal(error._tag, "OpenError");
|
||||
assert.equal(error.message, "Command not found: cursor");
|
||||
assert.deepEqual(calls, []);
|
||||
}),
|
||||
);
|
||||
+575
-171
@@ -1,21 +1,17 @@
|
||||
/**
|
||||
* Open - Browser/editor launch service interface.
|
||||
*
|
||||
* Owns process launch helpers for opening URLs in a browser and workspace
|
||||
* paths in a configured editor.
|
||||
* Owns process launch helpers for opening URLs in a browser, workspace paths in
|
||||
* a configured editor, and generic external targets through the platform's
|
||||
* default opener.
|
||||
*
|
||||
* @module Open
|
||||
*/
|
||||
import { spawn } from "node:child_process";
|
||||
import { accessSync, constants, statSync } from "node:fs";
|
||||
import { extname, join } from "node:path";
|
||||
import os from "node:os";
|
||||
|
||||
import { EDITORS, type EditorId } from "@t3tools/contracts";
|
||||
import { ServiceMap, Schema, Effect, Layer } from "effect";
|
||||
|
||||
// ==============================
|
||||
// Definitions
|
||||
// ==============================
|
||||
import { Effect, Exit, FileSystem, Layer, Option, Path, Schema, Scope, ServiceMap } from "effect";
|
||||
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
|
||||
|
||||
export class OpenError extends Schema.TaggedErrorClass<OpenError>()("OpenError", {
|
||||
message: Schema.String,
|
||||
@@ -27,33 +23,66 @@ export interface OpenInEditorInput {
|
||||
readonly editor: EditorId;
|
||||
}
|
||||
|
||||
interface EditorLaunch {
|
||||
readonly command: string;
|
||||
readonly args: ReadonlyArray<string>;
|
||||
export interface OpenApplicationInput {
|
||||
readonly name: string | ReadonlyArray<string>;
|
||||
readonly arguments?: ReadonlyArray<string>;
|
||||
}
|
||||
|
||||
interface CommandAvailabilityOptions {
|
||||
export interface OpenExternalInput {
|
||||
readonly target: string;
|
||||
readonly wait?: boolean;
|
||||
readonly background?: boolean;
|
||||
readonly newInstance?: boolean;
|
||||
readonly allowNonzeroExitCode?: boolean;
|
||||
readonly app?: OpenApplicationInput | ReadonlyArray<OpenApplicationInput>;
|
||||
}
|
||||
|
||||
export interface OpenRuntimeOptions {
|
||||
readonly platform?: NodeJS.Platform;
|
||||
readonly env?: NodeJS.ProcessEnv;
|
||||
readonly isWsl?: boolean;
|
||||
readonly isInsideContainer?: boolean;
|
||||
readonly powerShellCommand?: string;
|
||||
}
|
||||
|
||||
interface OpenRuntime {
|
||||
readonly platform: NodeJS.Platform;
|
||||
readonly env: NodeJS.ProcessEnv;
|
||||
readonly isWsl: boolean;
|
||||
readonly isInsideContainer: boolean;
|
||||
readonly powerShellCandidates: ReadonlyArray<string>;
|
||||
readonly windowsPathExtensions: ReadonlyArray<string>;
|
||||
}
|
||||
|
||||
interface LaunchPlan {
|
||||
readonly command: string;
|
||||
readonly args: ReadonlyArray<string>;
|
||||
readonly wait: boolean;
|
||||
readonly allowNonzeroExitCode: boolean;
|
||||
readonly detached?: boolean;
|
||||
readonly shell?: boolean;
|
||||
readonly stdio?: "ignore";
|
||||
}
|
||||
|
||||
interface ResolvedCommand {
|
||||
readonly path: string;
|
||||
readonly usesCmdWrapper: boolean;
|
||||
}
|
||||
|
||||
const LINE_COLUMN_SUFFIX_PATTERN = /:\d+(?::\d+)?$/;
|
||||
const WINDOWS_POWERSHELL_CANDIDATES = ["powershell.exe", "powershell", "pwsh.exe", "pwsh"] as const;
|
||||
const WSL_POWERSHELL_CANDIDATES = [
|
||||
"/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe",
|
||||
"/mnt/c/Program Files/PowerShell/7/pwsh.exe",
|
||||
"powershell.exe",
|
||||
"pwsh.exe",
|
||||
] as const;
|
||||
const WINDOWS_BATCH_EXTENSIONS = [".CMD", ".BAT"] as const;
|
||||
|
||||
function shouldUseGotoFlag(editor: (typeof EDITORS)[number], target: string): boolean {
|
||||
return editor.supportsGoto && LINE_COLUMN_SUFFIX_PATTERN.test(target);
|
||||
}
|
||||
|
||||
function fileManagerCommandForPlatform(platform: NodeJS.Platform): string {
|
||||
switch (platform) {
|
||||
case "darwin":
|
||||
return "open";
|
||||
case "win32":
|
||||
return "explorer";
|
||||
default:
|
||||
return "xdg-open";
|
||||
}
|
||||
}
|
||||
|
||||
function stripWrappingQuotes(value: string): string {
|
||||
return value.replace(/^"+|"+$/g, "");
|
||||
}
|
||||
@@ -72,19 +101,24 @@ function resolveWindowsPathExtensions(env: NodeJS.ProcessEnv): ReadonlyArray<str
|
||||
.map((entry) => entry.trim())
|
||||
.filter((entry) => entry.length > 0)
|
||||
.map((entry) => (entry.startsWith(".") ? entry.toUpperCase() : `.${entry.toUpperCase()}`));
|
||||
|
||||
return parsed.length > 0 ? Array.from(new Set(parsed)) : fallback;
|
||||
}
|
||||
|
||||
function resolveWindowsCommandShell(env: NodeJS.ProcessEnv): string {
|
||||
return env.ComSpec ?? env.COMSPEC ?? "cmd.exe";
|
||||
}
|
||||
|
||||
function resolveCommandCandidates(
|
||||
command: string,
|
||||
platform: NodeJS.Platform,
|
||||
windowsPathExtensions: ReadonlyArray<string>,
|
||||
runtime: OpenRuntime,
|
||||
pathService: Path.Path,
|
||||
): ReadonlyArray<string> {
|
||||
if (platform !== "win32") return [command];
|
||||
const extension = extname(command);
|
||||
if (runtime.platform !== "win32") return [command];
|
||||
const extension = pathService.extname(command);
|
||||
const normalizedExtension = extension.toUpperCase();
|
||||
|
||||
if (extension.length > 0 && windowsPathExtensions.includes(normalizedExtension)) {
|
||||
if (extension.length > 0 && runtime.windowsPathExtensions.includes(normalizedExtension)) {
|
||||
const commandWithoutExtension = command.slice(0, -extension.length);
|
||||
return Array.from(
|
||||
new Set([
|
||||
@@ -96,179 +130,549 @@ function resolveCommandCandidates(
|
||||
}
|
||||
|
||||
const candidates: string[] = [];
|
||||
for (const extension of windowsPathExtensions) {
|
||||
candidates.push(`${command}${extension}`);
|
||||
candidates.push(`${command}${extension.toLowerCase()}`);
|
||||
for (const extensionName of runtime.windowsPathExtensions) {
|
||||
candidates.push(`${command}${extensionName}`);
|
||||
candidates.push(`${command}${extensionName.toLowerCase()}`);
|
||||
}
|
||||
return Array.from(new Set(candidates));
|
||||
}
|
||||
|
||||
function isExecutableFile(
|
||||
filePath: string,
|
||||
platform: NodeJS.Platform,
|
||||
windowsPathExtensions: ReadonlyArray<string>,
|
||||
): boolean {
|
||||
try {
|
||||
const stat = statSync(filePath);
|
||||
if (!stat.isFile()) return false;
|
||||
if (platform === "win32") {
|
||||
const extension = extname(filePath);
|
||||
if (extension.length === 0) return false;
|
||||
return windowsPathExtensions.includes(extension.toUpperCase());
|
||||
}
|
||||
accessSync(filePath, constants.X_OK);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function resolvePathDelimiter(platform: NodeJS.Platform): string {
|
||||
return platform === "win32" ? ";" : ":";
|
||||
}
|
||||
|
||||
export function isCommandAvailable(
|
||||
command: string,
|
||||
options: CommandAvailabilityOptions = {},
|
||||
): boolean {
|
||||
const platform = options.platform ?? process.platform;
|
||||
const env = options.env ?? process.env;
|
||||
const windowsPathExtensions = platform === "win32" ? resolveWindowsPathExtensions(env) : [];
|
||||
const commandCandidates = resolveCommandCandidates(command, platform, windowsPathExtensions);
|
||||
function detectWsl(platform: NodeJS.Platform, env: NodeJS.ProcessEnv): boolean {
|
||||
if (platform !== "linux") return false;
|
||||
if (typeof env.WSL_DISTRO_NAME === "string" || typeof env.WSL_INTEROP === "string") {
|
||||
return true;
|
||||
}
|
||||
return os.release().toLowerCase().includes("microsoft");
|
||||
}
|
||||
|
||||
if (command.includes("/") || command.includes("\\")) {
|
||||
return commandCandidates.some((candidate) =>
|
||||
isExecutableFile(candidate, platform, windowsPathExtensions),
|
||||
);
|
||||
function quotePowerShellValue(value: string): string {
|
||||
return `'${value.replaceAll("'", "''")}'`;
|
||||
}
|
||||
|
||||
function encodePowerShellCommand(command: string): string {
|
||||
return Buffer.from(command, "utf16le").toString("base64");
|
||||
}
|
||||
|
||||
function normalizeAppCandidates(
|
||||
app: OpenExternalInput["app"],
|
||||
): ReadonlyArray<{ readonly name: string; readonly arguments: ReadonlyArray<string> } | undefined> {
|
||||
if (!app) return [undefined];
|
||||
|
||||
const apps = Array.isArray(app) ? app : [app];
|
||||
const candidates: Array<{ readonly name: string; readonly arguments: ReadonlyArray<string> }> =
|
||||
[];
|
||||
|
||||
for (const appDef of apps) {
|
||||
const names = Array.isArray(appDef.name) ? appDef.name : [appDef.name];
|
||||
for (const name of names) {
|
||||
candidates.push({ name, arguments: appDef.arguments ?? [] });
|
||||
}
|
||||
}
|
||||
|
||||
const pathValue = resolvePathEnvironmentVariable(env);
|
||||
if (pathValue.length === 0) return false;
|
||||
const pathEntries = pathValue
|
||||
.split(resolvePathDelimiter(platform))
|
||||
.map((entry) => stripWrappingQuotes(entry.trim()))
|
||||
.filter((entry) => entry.length > 0);
|
||||
return candidates;
|
||||
}
|
||||
|
||||
for (const pathEntry of pathEntries) {
|
||||
for (const candidate of commandCandidates) {
|
||||
if (isExecutableFile(join(pathEntry, candidate), platform, windowsPathExtensions)) {
|
||||
return true;
|
||||
function isUriLikeTarget(target: string): boolean {
|
||||
return /^[A-Za-z][A-Za-z\d+.-]*:/.test(target);
|
||||
}
|
||||
|
||||
function shouldPreferWindowsOpenerOnWsl(input: OpenExternalInput, runtime: OpenRuntime): boolean {
|
||||
return runtime.isWsl && !runtime.isInsideContainer && isUriLikeTarget(input.target);
|
||||
}
|
||||
|
||||
function makeLaunchPlan(
|
||||
command: string,
|
||||
args: ReadonlyArray<string>,
|
||||
options: {
|
||||
readonly wait: boolean;
|
||||
readonly allowNonzeroExitCode: boolean;
|
||||
readonly detached?: boolean;
|
||||
readonly shell?: boolean;
|
||||
readonly stdio?: "ignore";
|
||||
},
|
||||
): LaunchPlan {
|
||||
return {
|
||||
command,
|
||||
args,
|
||||
wait: options.wait,
|
||||
allowNonzeroExitCode: options.allowNonzeroExitCode,
|
||||
shell: options.shell ?? false,
|
||||
...(options.detached !== undefined ? { detached: options.detached } : {}),
|
||||
...(options.stdio !== undefined ? { stdio: options.stdio } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
function makeDarwinDefaultPlan(input: OpenExternalInput): LaunchPlan {
|
||||
const args: string[] = [];
|
||||
const wait = input.wait ?? false;
|
||||
|
||||
if (wait) args.push("--wait-apps");
|
||||
if (input.background) args.push("--background");
|
||||
if (input.newInstance) args.push("--new");
|
||||
args.push(input.target);
|
||||
|
||||
return makeLaunchPlan("open", args, {
|
||||
wait,
|
||||
allowNonzeroExitCode: input.allowNonzeroExitCode ?? false,
|
||||
shell: false,
|
||||
});
|
||||
}
|
||||
|
||||
function makeDarwinApplicationPlan(
|
||||
input: OpenExternalInput,
|
||||
app: { readonly name: string; readonly arguments: ReadonlyArray<string> },
|
||||
): LaunchPlan {
|
||||
const args: string[] = [];
|
||||
const wait = input.wait ?? false;
|
||||
|
||||
if (wait) args.push("--wait-apps");
|
||||
if (input.background) args.push("--background");
|
||||
if (input.newInstance) args.push("--new");
|
||||
args.push("-a", app.name);
|
||||
args.push(input.target);
|
||||
if (app.arguments.length > 0) {
|
||||
args.push("--args", ...app.arguments);
|
||||
}
|
||||
|
||||
return makeLaunchPlan("open", args, {
|
||||
wait,
|
||||
allowNonzeroExitCode: input.allowNonzeroExitCode ?? false,
|
||||
shell: false,
|
||||
});
|
||||
}
|
||||
|
||||
function makePowerShellPlan(input: OpenExternalInput, powerShellCommand: string): LaunchPlan {
|
||||
const encodedParts = ["Start"];
|
||||
const wait = input.wait ?? false;
|
||||
|
||||
if (wait) encodedParts.push("-Wait");
|
||||
encodedParts.push(quotePowerShellValue(input.target));
|
||||
|
||||
return makeLaunchPlan(
|
||||
powerShellCommand,
|
||||
[
|
||||
"-NoProfile",
|
||||
"-NonInteractive",
|
||||
"-ExecutionPolicy",
|
||||
"Bypass",
|
||||
"-EncodedCommand",
|
||||
encodePowerShellCommand(encodedParts.join(" ")),
|
||||
],
|
||||
{
|
||||
wait,
|
||||
allowNonzeroExitCode: input.allowNonzeroExitCode ?? false,
|
||||
shell: false,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function makeLinuxDefaultPlan(input: OpenExternalInput): LaunchPlan {
|
||||
const wait = input.wait ?? false;
|
||||
return makeLaunchPlan("xdg-open", [input.target], {
|
||||
wait,
|
||||
allowNonzeroExitCode: input.allowNonzeroExitCode ?? false,
|
||||
detached: !wait,
|
||||
...(wait ? {} : { stdio: "ignore" as const }),
|
||||
shell: false,
|
||||
});
|
||||
}
|
||||
|
||||
function makeWindowsExplorerPlan(input: OpenExternalInput): LaunchPlan {
|
||||
return makeLaunchPlan("explorer", [input.target], {
|
||||
wait: false,
|
||||
allowNonzeroExitCode: false,
|
||||
shell: false,
|
||||
});
|
||||
}
|
||||
|
||||
function makeDirectApplicationPlan(
|
||||
input: OpenExternalInput,
|
||||
app: { readonly name: string; readonly arguments: ReadonlyArray<string> },
|
||||
): LaunchPlan {
|
||||
return makeLaunchPlan(app.name, [...app.arguments, input.target], {
|
||||
wait: input.wait ?? false,
|
||||
allowNonzeroExitCode: input.allowNonzeroExitCode ?? false,
|
||||
shell: false,
|
||||
});
|
||||
}
|
||||
|
||||
function resolveExternalPlans(
|
||||
input: OpenExternalInput,
|
||||
runtime: OpenRuntime,
|
||||
): ReadonlyArray<LaunchPlan> {
|
||||
const appCandidates = normalizeAppCandidates(input.app);
|
||||
const plans: LaunchPlan[] = [];
|
||||
const preferWindowsOpenerOnWsl = shouldPreferWindowsOpenerOnWsl(input, runtime);
|
||||
|
||||
for (const app of appCandidates) {
|
||||
if (app) {
|
||||
if (runtime.platform === "darwin") {
|
||||
plans.push(makeDarwinApplicationPlan(input, app));
|
||||
} else {
|
||||
plans.push(makeDirectApplicationPlan(input, app));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (runtime.platform === "darwin") {
|
||||
plans.push(makeDarwinDefaultPlan(input));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (runtime.platform === "win32" || preferWindowsOpenerOnWsl) {
|
||||
for (const powerShellCommand of runtime.powerShellCandidates) {
|
||||
plans.push(makePowerShellPlan(input, powerShellCommand));
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function resolveAvailableEditors(
|
||||
platform: NodeJS.Platform = process.platform,
|
||||
env: NodeJS.ProcessEnv = process.env,
|
||||
): ReadonlyArray<EditorId> {
|
||||
const available: EditorId[] = [];
|
||||
|
||||
for (const editor of EDITORS) {
|
||||
const command = editor.command ?? fileManagerCommandForPlatform(platform);
|
||||
if (isCommandAvailable(command, { platform, env })) {
|
||||
available.push(editor.id);
|
||||
if (runtime.platform === "win32") {
|
||||
if (!(input.wait ?? false)) {
|
||||
plans.push(makeWindowsExplorerPlan(input));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
plans.push(makeLinuxDefaultPlan(input));
|
||||
}
|
||||
|
||||
return available;
|
||||
return plans;
|
||||
}
|
||||
|
||||
/**
|
||||
* OpenShape - Service API for browser and editor launch actions.
|
||||
*/
|
||||
export interface OpenShape {
|
||||
/**
|
||||
* Open a URL target in the default browser.
|
||||
*/
|
||||
readonly openBrowser: (target: string) => Effect.Effect<void, OpenError>;
|
||||
function toOpenError(message: string, cause: unknown): OpenError {
|
||||
return new OpenError({ message, cause });
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a workspace path in a selected editor integration.
|
||||
*
|
||||
* Launches the editor as a detached process so server startup is not blocked.
|
||||
*/
|
||||
function isWindowsBatchShim(pathService: Path.Path, filePath: string): boolean {
|
||||
return WINDOWS_BATCH_EXTENSIONS.includes(pathService.extname(filePath).toUpperCase() as never);
|
||||
}
|
||||
|
||||
function quoteForWindowsCmd(value: string): string {
|
||||
return `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
|
||||
}
|
||||
|
||||
function makeWindowsCmdCommandLine(commandPath: string, args: ReadonlyArray<string>): string {
|
||||
return `"${[commandPath, ...args].map(quoteForWindowsCmd).join(" ")}"`;
|
||||
}
|
||||
|
||||
export interface OpenShape {
|
||||
readonly getAvailableEditors: Effect.Effect<ReadonlyArray<EditorId>, OpenError>;
|
||||
readonly openExternal: (input: OpenExternalInput) => Effect.Effect<void, OpenError>;
|
||||
readonly openBrowser: (
|
||||
target: string,
|
||||
options?: Omit<OpenExternalInput, "target">,
|
||||
) => Effect.Effect<void, OpenError>;
|
||||
readonly openInEditor: (input: OpenInEditorInput) => Effect.Effect<void, OpenError>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open - Service tag for browser/editor launch operations.
|
||||
*/
|
||||
export class Open extends ServiceMap.Service<Open, OpenShape>()("t3/open") {}
|
||||
|
||||
// ==============================
|
||||
// Implementations
|
||||
// ==============================
|
||||
|
||||
export const resolveEditorLaunch = Effect.fnUntraced(function* (
|
||||
input: OpenInEditorInput,
|
||||
platform: NodeJS.Platform = process.platform,
|
||||
): Effect.fn.Return<EditorLaunch, OpenError> {
|
||||
const editorDef = EDITORS.find((editor) => editor.id === input.editor);
|
||||
if (!editorDef) {
|
||||
return yield* new OpenError({ message: `Unknown editor: ${input.editor}` });
|
||||
}
|
||||
|
||||
if (editorDef.command) {
|
||||
return shouldUseGotoFlag(editorDef, input.cwd)
|
||||
? { command: editorDef.command, args: ["--goto", input.cwd] }
|
||||
: { command: editorDef.command, args: [input.cwd] };
|
||||
}
|
||||
|
||||
if (editorDef.id !== "file-manager") {
|
||||
return yield* new OpenError({ message: `Unsupported editor: ${input.editor}` });
|
||||
}
|
||||
|
||||
return { command: fileManagerCommandForPlatform(platform), args: [input.cwd] };
|
||||
});
|
||||
|
||||
export const launchDetached = (launch: EditorLaunch) =>
|
||||
const makeOpen = (options: OpenRuntimeOptions = {}) =>
|
||||
Effect.gen(function* () {
|
||||
if (!isCommandAvailable(launch.command)) {
|
||||
return yield* new OpenError({ message: `Editor command not found: ${launch.command}` });
|
||||
}
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const pathService = yield* Path.Path;
|
||||
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
|
||||
yield* Effect.callback<void, OpenError>((resume) => {
|
||||
let child;
|
||||
try {
|
||||
child = spawn(launch.command, [...launch.args], {
|
||||
detached: true,
|
||||
stdio: "ignore",
|
||||
shell: process.platform === "win32",
|
||||
});
|
||||
} catch (error) {
|
||||
return resume(
|
||||
Effect.fail(new OpenError({ message: "failed to spawn detached process", cause: error })),
|
||||
const isInsideContainer =
|
||||
options.isInsideContainer ??
|
||||
(typeof options.env?.CONTAINER === "string" ||
|
||||
typeof options.env?.container === "string" ||
|
||||
typeof options.env?.KUBERNETES_SERVICE_HOST === "string"
|
||||
? true
|
||||
: yield* fileSystem.exists("/.dockerenv").pipe(Effect.catch(() => Effect.succeed(false))));
|
||||
|
||||
const runtime: OpenRuntime = {
|
||||
platform: options.platform ?? process.platform,
|
||||
env: options.env ?? process.env,
|
||||
isWsl:
|
||||
options.isWsl ??
|
||||
detectWsl(options.platform ?? process.platform, options.env ?? process.env),
|
||||
isInsideContainer,
|
||||
powerShellCandidates:
|
||||
options.powerShellCommand !== undefined
|
||||
? [options.powerShellCommand]
|
||||
: (options.isWsl ??
|
||||
detectWsl(options.platform ?? process.platform, options.env ?? process.env))
|
||||
? WSL_POWERSHELL_CANDIDATES
|
||||
: WINDOWS_POWERSHELL_CANDIDATES,
|
||||
windowsPathExtensions: resolveWindowsPathExtensions(options.env ?? process.env),
|
||||
};
|
||||
|
||||
const resolveCommand = Effect.fn(function* (
|
||||
command: string,
|
||||
): Effect.fn.Return<Option.Option<ResolvedCommand>, never> {
|
||||
const candidates = resolveCommandCandidates(command, runtime, pathService);
|
||||
|
||||
const resolveExecutableFile = Effect.fn(function* (
|
||||
filePath: string,
|
||||
): Effect.fn.Return<Option.Option<ResolvedCommand>, never> {
|
||||
const info = yield* fileSystem.stat(filePath).pipe(Effect.option);
|
||||
if (Option.isNone(info) || info.value.type !== "File") return Option.none();
|
||||
|
||||
if (runtime.platform === "win32") {
|
||||
const extension = pathService.extname(filePath);
|
||||
if (
|
||||
extension.length === 0 ||
|
||||
!runtime.windowsPathExtensions.includes(extension.toUpperCase())
|
||||
) {
|
||||
return Option.none();
|
||||
}
|
||||
|
||||
return Option.some({
|
||||
path: filePath,
|
||||
usesCmdWrapper: isWindowsBatchShim(pathService, filePath),
|
||||
} satisfies ResolvedCommand);
|
||||
}
|
||||
|
||||
return (info.value.mode & 0o111) !== 0
|
||||
? Option.some({
|
||||
path: filePath,
|
||||
usesCmdWrapper: false,
|
||||
} satisfies ResolvedCommand)
|
||||
: Option.none();
|
||||
});
|
||||
|
||||
if (command.includes("/") || command.includes("\\")) {
|
||||
for (const candidate of candidates) {
|
||||
const resolved = yield* resolveExecutableFile(candidate);
|
||||
if (Option.isSome(resolved)) return resolved;
|
||||
}
|
||||
return Option.none();
|
||||
}
|
||||
|
||||
const pathValue = resolvePathEnvironmentVariable(runtime.env);
|
||||
if (pathValue.length === 0) return Option.none();
|
||||
|
||||
const pathEntries = pathValue
|
||||
.split(resolvePathDelimiter(runtime.platform))
|
||||
.map((entry) => stripWrappingQuotes(entry.trim()))
|
||||
.filter((entry) => entry.length > 0);
|
||||
|
||||
for (const pathEntry of pathEntries) {
|
||||
for (const candidate of candidates) {
|
||||
const resolved = yield* resolveExecutableFile(pathService.join(pathEntry, candidate));
|
||||
if (Option.isSome(resolved)) {
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Option.none();
|
||||
});
|
||||
|
||||
const commandAvailable = (command: string) =>
|
||||
resolveCommand(command).pipe(Effect.map(Option.isSome));
|
||||
|
||||
const fileManagerAvailable = Effect.gen(function* () {
|
||||
const candidates =
|
||||
runtime.platform === "darwin"
|
||||
? ["open"]
|
||||
: runtime.platform === "win32"
|
||||
? [...runtime.powerShellCandidates, "explorer"]
|
||||
: ["xdg-open"];
|
||||
|
||||
for (const candidate of candidates) {
|
||||
if (yield* commandAvailable(candidate)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
const getAvailableEditors = Effect.gen(function* () {
|
||||
const available: EditorId[] = [];
|
||||
|
||||
for (const editor of EDITORS) {
|
||||
if (editor.id === "file-manager") {
|
||||
if (yield* fileManagerAvailable) {
|
||||
available.push(editor.id);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (editor.command && (yield* commandAvailable(editor.command))) {
|
||||
available.push(editor.id);
|
||||
}
|
||||
}
|
||||
|
||||
return available as ReadonlyArray<EditorId>;
|
||||
}).pipe(Effect.mapError((cause) => toOpenError("Failed to resolve available editors", cause)));
|
||||
|
||||
const spawnPlan = (
|
||||
plan: LaunchPlan,
|
||||
resolvedCommand: ResolvedCommand,
|
||||
failureMessage: string,
|
||||
) =>
|
||||
spawner
|
||||
.spawn(
|
||||
ChildProcess.make(
|
||||
resolvedCommand.usesCmdWrapper
|
||||
? resolveWindowsCommandShell(runtime.env)
|
||||
: resolvedCommand.path,
|
||||
resolvedCommand.usesCmdWrapper
|
||||
? [
|
||||
"/d",
|
||||
"/v:off",
|
||||
"/s",
|
||||
"/c",
|
||||
makeWindowsCmdCommandLine(resolvedCommand.path, plan.args),
|
||||
]
|
||||
: [...plan.args],
|
||||
{
|
||||
detached: plan.detached,
|
||||
shell: plan.shell,
|
||||
...(plan.stdio === "ignore"
|
||||
? {
|
||||
stdin: "ignore",
|
||||
stdout: "ignore",
|
||||
stderr: "ignore",
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
),
|
||||
)
|
||||
.pipe(Effect.mapError((cause) => toOpenError(failureMessage, cause)));
|
||||
|
||||
const waitForExit = (
|
||||
plan: LaunchPlan,
|
||||
failureMessage: string,
|
||||
handle: ChildProcessSpawner.ChildProcessHandle,
|
||||
) =>
|
||||
handle.exitCode.pipe(
|
||||
Effect.flatMap((exitCode) =>
|
||||
!plan.allowNonzeroExitCode && (exitCode as number) !== 0
|
||||
? Effect.fail(
|
||||
new OpenError({
|
||||
message: `${failureMessage} (code=${exitCode as number})`,
|
||||
}),
|
||||
)
|
||||
: Effect.void,
|
||||
),
|
||||
Effect.mapError((cause) => toOpenError(failureMessage, cause)),
|
||||
);
|
||||
|
||||
const runWaitedPlan = (
|
||||
plan: LaunchPlan,
|
||||
resolvedCommand: ResolvedCommand,
|
||||
failureMessage: string,
|
||||
) =>
|
||||
Effect.acquireUseRelease(
|
||||
Scope.make("sequential"),
|
||||
(scope) =>
|
||||
Effect.gen(function* () {
|
||||
const handle = yield* spawnPlan(plan, resolvedCommand, failureMessage).pipe(
|
||||
Scope.provide(scope),
|
||||
);
|
||||
yield* waitForExit(plan, failureMessage, handle);
|
||||
}),
|
||||
(scope) => Scope.close(scope, Exit.void),
|
||||
);
|
||||
|
||||
const runDetachedPlan = (
|
||||
plan: LaunchPlan,
|
||||
resolvedCommand: ResolvedCommand,
|
||||
failureMessage: string,
|
||||
) =>
|
||||
Effect.gen(function* () {
|
||||
const childScope = yield* Scope.make("sequential");
|
||||
const handle = yield* spawnPlan(plan, resolvedCommand, failureMessage).pipe(
|
||||
Scope.provide(childScope),
|
||||
Effect.catch((error) =>
|
||||
Scope.close(childScope, Exit.void).pipe(Effect.andThen(Effect.fail(error))),
|
||||
),
|
||||
);
|
||||
|
||||
const releaseOnExit: Effect.Effect<void, never> = handle.exitCode.pipe(
|
||||
Effect.ignoreCause,
|
||||
Effect.ensuring(Scope.close(childScope, Exit.void)),
|
||||
);
|
||||
|
||||
yield* Effect.forkDetach(releaseOnExit);
|
||||
});
|
||||
|
||||
const runPlan = (plan: LaunchPlan, resolvedCommand: ResolvedCommand, failureMessage: string) =>
|
||||
plan.wait
|
||||
? runWaitedPlan(plan, resolvedCommand, failureMessage)
|
||||
: runDetachedPlan(plan, resolvedCommand, failureMessage);
|
||||
|
||||
const runFirstAvailablePlan = (
|
||||
plans: ReadonlyArray<LaunchPlan>,
|
||||
failureMessage: string,
|
||||
): Effect.Effect<void, OpenError> => {
|
||||
const [first, ...rest] = plans;
|
||||
if (!first) {
|
||||
return Effect.fail(new OpenError({ message: failureMessage }));
|
||||
}
|
||||
|
||||
return resolveCommand(first.command).pipe(
|
||||
Effect.flatMap((resolvedCommand) => {
|
||||
if (Option.isNone(resolvedCommand)) {
|
||||
return rest.length === 0
|
||||
? Effect.fail(new OpenError({ message: `Command not found: ${first.command}` }))
|
||||
: runFirstAvailablePlan(rest, failureMessage);
|
||||
}
|
||||
|
||||
return runPlan(first, resolvedCommand.value, failureMessage).pipe(
|
||||
Effect.catch((error) =>
|
||||
rest.length === 0 ? Effect.fail(error) : runFirstAvailablePlan(rest, failureMessage),
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
const openExternal = (input: OpenExternalInput) => {
|
||||
if (input.target.trim().length === 0) {
|
||||
return Effect.fail(new OpenError({ message: "Open target must not be empty" }));
|
||||
}
|
||||
|
||||
return runFirstAvailablePlan(
|
||||
resolveExternalPlans(input, runtime),
|
||||
`Failed to open ${input.target}`,
|
||||
);
|
||||
};
|
||||
|
||||
const openInEditor = (input: OpenInEditorInput) => {
|
||||
const editor = EDITORS.find((candidate) => candidate.id === input.editor);
|
||||
if (!editor) {
|
||||
return Effect.fail(new OpenError({ message: `Unknown editor: ${input.editor}` }));
|
||||
}
|
||||
|
||||
if (editor.command) {
|
||||
return runFirstAvailablePlan(
|
||||
[
|
||||
makeLaunchPlan(
|
||||
editor.command,
|
||||
shouldUseGotoFlag(editor, input.cwd) ? ["--goto", input.cwd] : [input.cwd],
|
||||
{
|
||||
wait: false,
|
||||
allowNonzeroExitCode: false,
|
||||
detached: true,
|
||||
stdio: "ignore",
|
||||
shell: false,
|
||||
},
|
||||
),
|
||||
],
|
||||
`Failed to open ${input.cwd} in ${input.editor}`,
|
||||
);
|
||||
}
|
||||
|
||||
const handleSpawn = () => {
|
||||
child.unref();
|
||||
resume(Effect.void);
|
||||
};
|
||||
return openExternal({ target: input.cwd });
|
||||
};
|
||||
|
||||
child.once("spawn", handleSpawn);
|
||||
child.once("error", (cause) =>
|
||||
resume(Effect.fail(new OpenError({ message: "failed to spawn detached process", cause }))),
|
||||
);
|
||||
});
|
||||
return {
|
||||
getAvailableEditors,
|
||||
openExternal,
|
||||
openBrowser: (target, openOptions = {}) => openExternal({ ...openOptions, target }),
|
||||
openInEditor,
|
||||
} satisfies OpenShape;
|
||||
});
|
||||
|
||||
const make = Effect.gen(function* () {
|
||||
const open = yield* Effect.tryPromise({
|
||||
try: () => import("open"),
|
||||
catch: (cause) => new OpenError({ message: "failed to load browser opener", cause }),
|
||||
});
|
||||
export const makeOpenLayer = (options: OpenRuntimeOptions = {}) =>
|
||||
Layer.effect(Open, makeOpen(options));
|
||||
|
||||
return {
|
||||
openBrowser: (target) =>
|
||||
Effect.tryPromise({
|
||||
try: () => open.default(target),
|
||||
catch: (cause) => new OpenError({ message: "Browser auto-open failed", cause }),
|
||||
}),
|
||||
openInEditor: (input) => Effect.flatMap(resolveEditorLaunch(input), launchDetached),
|
||||
} satisfies OpenShape;
|
||||
});
|
||||
|
||||
export const OpenLive = Layer.effect(Open, make);
|
||||
export const OpenLive = makeOpenLayer();
|
||||
@@ -282,7 +282,6 @@ describe("CheckpointReactor", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Test Project",
|
||||
workspaceRoot: options?.projectWorkspaceRoot ?? cwd,
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -297,7 +296,6 @@ describe("CheckpointReactor", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -72,7 +72,6 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Project 1",
|
||||
workspaceRoot: "/tmp/project-1",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -87,7 +86,6 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -134,7 +132,6 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-archive"),
|
||||
title: "Project Archive",
|
||||
workspaceRoot: "/tmp/project-archive",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -149,7 +146,6 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-archive"),
|
||||
projectId: asProjectId("project-archive"),
|
||||
title: "Archive me",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -203,7 +199,6 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-replay"),
|
||||
title: "Replay Project",
|
||||
workspaceRoot: "/tmp/project-replay",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -218,7 +213,6 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-replay"),
|
||||
projectId: asProjectId("project-replay"),
|
||||
title: "replay",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -263,7 +257,6 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-stream"),
|
||||
title: "Stream Project",
|
||||
workspaceRoot: "/tmp/project-stream",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -288,7 +281,6 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-stream"),
|
||||
projectId: asProjectId("project-stream"),
|
||||
title: "domain-stream",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -326,7 +318,6 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-turn-diff"),
|
||||
title: "Turn Diff Project",
|
||||
workspaceRoot: "/tmp/project-turn-diff",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -341,7 +332,6 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-turn-diff"),
|
||||
projectId: asProjectId("project-turn-diff"),
|
||||
title: "Turn diff thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -445,7 +435,6 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-flaky"),
|
||||
title: "Flaky Project",
|
||||
workspaceRoot: "/tmp/project-flaky",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -462,7 +451,6 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-flaky-fail"),
|
||||
projectId: asProjectId("project-flaky"),
|
||||
title: "flaky-fail",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -483,7 +471,6 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-flaky-ok"),
|
||||
projectId: asProjectId("project-flaky"),
|
||||
title: "flaky-ok",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -541,7 +528,6 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-atomic"),
|
||||
title: "Atomic Project",
|
||||
workspaceRoot: "/tmp/project-atomic",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -556,7 +542,6 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-atomic"),
|
||||
projectId: asProjectId("project-atomic"),
|
||||
title: "atomic",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -684,7 +669,6 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-sync"),
|
||||
title: "Sync Project",
|
||||
workspaceRoot: "/tmp/project-sync",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -699,7 +683,6 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-sync"),
|
||||
projectId: asProjectId("project-sync"),
|
||||
title: "sync-before",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -771,7 +754,6 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-duplicate"),
|
||||
title: "Duplicate Project",
|
||||
workspaceRoot: "/tmp/project-duplicate",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -787,7 +769,6 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-duplicate"),
|
||||
projectId: asProjectId("project-duplicate"),
|
||||
title: "duplicate",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -808,7 +789,6 @@ describe("OrchestrationEngine", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-duplicate"),
|
||||
projectId: asProjectId("project-duplicate"),
|
||||
title: "duplicate",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -1867,7 +1867,6 @@ engineLayer("OrchestrationProjectionPipeline via engine dispatch", (it) => {
|
||||
projectId: ProjectId.makeUnsafe("project-live"),
|
||||
title: "Live Project",
|
||||
workspaceRoot: "/tmp/project-live",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -1906,7 +1905,6 @@ engineLayer("OrchestrationProjectionPipeline via engine dispatch", (it) => {
|
||||
projectId: ProjectId.makeUnsafe("project-scripts"),
|
||||
title: "Scripts Project",
|
||||
workspaceRoot: "/tmp/project-scripts",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -383,7 +383,6 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
|
||||
projectId: event.payload.projectId,
|
||||
title: event.payload.title,
|
||||
workspaceRoot: event.payload.workspaceRoot,
|
||||
pinned: event.payload.pinned,
|
||||
defaultModelSelection: event.payload.defaultModelSelection,
|
||||
scripts: event.payload.scripts,
|
||||
createdAt: event.payload.createdAt,
|
||||
@@ -405,7 +404,6 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
|
||||
...(event.payload.workspaceRoot !== undefined
|
||||
? { workspaceRoot: event.payload.workspaceRoot }
|
||||
: {}),
|
||||
...(event.payload.pinned !== undefined ? { pinned: event.payload.pinned } : {}),
|
||||
...(event.payload.defaultModelSelection !== undefined
|
||||
? { defaultModelSelection: event.payload.defaultModelSelection }
|
||||
: {}),
|
||||
@@ -444,7 +442,6 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
|
||||
threadId: event.payload.threadId,
|
||||
projectId: event.payload.projectId,
|
||||
title: event.payload.title,
|
||||
pinned: event.payload.pinned,
|
||||
modelSelection: event.payload.modelSelection,
|
||||
runtimeMode: event.payload.runtimeMode,
|
||||
interactionMode: event.payload.interactionMode,
|
||||
@@ -498,7 +495,6 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
|
||||
yield* projectionThreadRepository.upsert({
|
||||
...existingRow.value,
|
||||
...(event.payload.title !== undefined ? { title: event.payload.title } : {}),
|
||||
...(event.payload.pinned !== undefined ? { pinned: event.payload.pinned } : {}),
|
||||
...(event.payload.modelSelection !== undefined
|
||||
? { modelSelection: event.payload.modelSelection }
|
||||
: {}),
|
||||
|
||||
@@ -234,7 +234,6 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
|
||||
id: asProjectId("project-1"),
|
||||
title: "Project 1",
|
||||
workspaceRoot: "/tmp/project-1",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -258,7 +257,6 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
|
||||
id: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread 1",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -46,7 +46,6 @@ import {
|
||||
const decodeReadModel = Schema.decodeUnknownEffect(OrchestrationReadModel);
|
||||
const ProjectionProjectDbRowSchema = ProjectionProject.mapFields(
|
||||
Struct.assign({
|
||||
pinned: Schema.BooleanFromBit,
|
||||
defaultModelSelection: Schema.NullOr(Schema.fromJsonString(ModelSelection)),
|
||||
scripts: Schema.fromJsonString(Schema.Array(ProjectScript)),
|
||||
}),
|
||||
@@ -60,7 +59,6 @@ const ProjectionThreadMessageDbRowSchema = ProjectionThreadMessage.mapFields(
|
||||
const ProjectionThreadProposedPlanDbRowSchema = ProjectionThreadProposedPlan;
|
||||
const ProjectionThreadDbRowSchema = ProjectionThread.mapFields(
|
||||
Struct.assign({
|
||||
pinned: Schema.BooleanFromBit,
|
||||
modelSelection: Schema.fromJsonString(ModelSelection),
|
||||
}),
|
||||
);
|
||||
@@ -149,7 +147,6 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
workspace_root AS "workspaceRoot",
|
||||
pinned,
|
||||
default_model_selection_json AS "defaultModelSelection",
|
||||
scripts_json AS "scripts",
|
||||
created_at AS "createdAt",
|
||||
@@ -169,7 +166,6 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
thread_id AS "threadId",
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
pinned,
|
||||
model_selection_json AS "modelSelection",
|
||||
runtime_mode AS "runtimeMode",
|
||||
interaction_mode AS "interactionMode",
|
||||
@@ -546,7 +542,6 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
id: row.projectId,
|
||||
title: row.title,
|
||||
workspaceRoot: row.workspaceRoot,
|
||||
pinned: row.pinned,
|
||||
defaultModelSelection: row.defaultModelSelection,
|
||||
scripts: row.scripts,
|
||||
createdAt: row.createdAt,
|
||||
@@ -558,7 +553,6 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
id: row.threadId,
|
||||
projectId: row.projectId,
|
||||
title: row.title,
|
||||
pinned: row.pinned,
|
||||
modelSelection: row.modelSelection,
|
||||
runtimeMode: row.runtimeMode,
|
||||
interactionMode: row.interactionMode,
|
||||
|
||||
@@ -245,7 +245,6 @@ describe("ProviderCommandReactor", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Provider Project",
|
||||
workspaceRoot: "/tmp/provider-project",
|
||||
pinned: false,
|
||||
defaultModelSelection: modelSelection,
|
||||
createdAt: now,
|
||||
}),
|
||||
@@ -257,7 +256,6 @@ describe("ProviderCommandReactor", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: modelSelection,
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
|
||||
@@ -225,7 +225,6 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Provider Project",
|
||||
workspaceRoot,
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -240,7 +239,6 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -770,7 +768,6 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
threadId: sourceThreadId,
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Plan Source",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -806,7 +803,6 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
threadId: targetThreadId,
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Plan Target",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -959,7 +955,6 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
threadId: sourceThreadId,
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Plan Source",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -1113,7 +1108,6 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
threadId: sourceThreadId,
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Plan Source",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -1149,7 +1143,6 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
threadId: targetThreadId,
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Plan Target",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -28,7 +28,6 @@ const readModel: OrchestrationReadModel = {
|
||||
id: ProjectId.makeUnsafe("project-a"),
|
||||
title: "Project A",
|
||||
workspaceRoot: "/tmp/project-a",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -42,7 +41,6 @@ const readModel: OrchestrationReadModel = {
|
||||
id: ProjectId.makeUnsafe("project-b"),
|
||||
title: "Project B",
|
||||
workspaceRoot: "/tmp/project-b",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -58,7 +56,6 @@ const readModel: OrchestrationReadModel = {
|
||||
id: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: ProjectId.makeUnsafe("project-a"),
|
||||
title: "Thread A",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -82,7 +79,6 @@ const readModel: OrchestrationReadModel = {
|
||||
id: ThreadId.makeUnsafe("thread-2"),
|
||||
projectId: ProjectId.makeUnsafe("project-b"),
|
||||
title: "Thread B",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -162,7 +158,6 @@ describe("commandInvariants", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-3"),
|
||||
projectId: ProjectId.makeUnsafe("project-a"),
|
||||
title: "new",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -187,7 +182,6 @@ describe("commandInvariants", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: ProjectId.makeUnsafe("project-a"),
|
||||
title: "dup",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -29,7 +29,6 @@ describe("decider project scripts", () => {
|
||||
projectId: asProjectId("project-scripts"),
|
||||
title: "Scripts",
|
||||
workspaceRoot: "/tmp/scripts",
|
||||
pinned: false,
|
||||
createdAt: now,
|
||||
},
|
||||
readModel,
|
||||
@@ -38,10 +37,7 @@ describe("decider project scripts", () => {
|
||||
|
||||
const event = Array.isArray(result) ? result[0] : result;
|
||||
expect(event.type).toBe("project.created");
|
||||
expect(event.payload).toMatchObject({
|
||||
pinned: false,
|
||||
scripts: [],
|
||||
});
|
||||
expect((event.payload as { scripts: unknown[] }).scripts).toEqual([]);
|
||||
});
|
||||
|
||||
it("propagates scripts in project.meta.update payload", async () => {
|
||||
@@ -63,7 +59,6 @@ describe("decider project scripts", () => {
|
||||
projectId: asProjectId("project-scripts"),
|
||||
title: "Scripts",
|
||||
workspaceRoot: "/tmp/scripts",
|
||||
pinned: false,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
@@ -99,82 +94,6 @@ describe("decider project scripts", () => {
|
||||
expect((event.payload as { scripts?: unknown[] }).scripts).toEqual(scripts);
|
||||
});
|
||||
|
||||
it("propagates pin state through thread create and meta update", async () => {
|
||||
const now = new Date().toISOString();
|
||||
const initial = createEmptyReadModel(now);
|
||||
const withProject = await Effect.runPromise(
|
||||
projectEvent(initial, {
|
||||
sequence: 1,
|
||||
eventId: asEventId("evt-project-create-pin"),
|
||||
aggregateKind: "project",
|
||||
aggregateId: asProjectId("project-pin"),
|
||||
type: "project.created",
|
||||
occurredAt: now,
|
||||
commandId: CommandId.makeUnsafe("cmd-project-create-pin"),
|
||||
causationEventId: null,
|
||||
correlationId: CommandId.makeUnsafe("cmd-project-create-pin"),
|
||||
metadata: {},
|
||||
payload: {
|
||||
projectId: asProjectId("project-pin"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project-pin",
|
||||
pinned: false,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const created = await Effect.runPromise(
|
||||
decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.create",
|
||||
commandId: CommandId.makeUnsafe("cmd-thread-create-pin"),
|
||||
threadId: ThreadId.makeUnsafe("thread-pin"),
|
||||
projectId: asProjectId("project-pin"),
|
||||
title: "Pinned thread",
|
||||
pinned: true,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
},
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
},
|
||||
readModel: withProject,
|
||||
}),
|
||||
);
|
||||
const createdEvent = Array.isArray(created) ? created[0] : created;
|
||||
expect(createdEvent.type).toBe("thread.created");
|
||||
expect(createdEvent.payload).toMatchObject({ pinned: true });
|
||||
|
||||
const withThread = await Effect.runPromise(
|
||||
projectEvent(withProject, {
|
||||
...createdEvent,
|
||||
sequence: 2,
|
||||
}),
|
||||
);
|
||||
const updated = await Effect.runPromise(
|
||||
decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.meta.update",
|
||||
commandId: CommandId.makeUnsafe("cmd-thread-update-pin"),
|
||||
threadId: ThreadId.makeUnsafe("thread-pin"),
|
||||
pinned: false,
|
||||
},
|
||||
readModel: withThread,
|
||||
}),
|
||||
);
|
||||
const updatedEvent = Array.isArray(updated) ? updated[0] : updated;
|
||||
expect(updatedEvent.type).toBe("thread.meta-updated");
|
||||
expect(updatedEvent.payload).toMatchObject({ pinned: false });
|
||||
});
|
||||
|
||||
it("emits user message and turn-start-requested events for thread.turn.start", async () => {
|
||||
const now = new Date().toISOString();
|
||||
const initial = createEmptyReadModel(now);
|
||||
@@ -194,7 +113,6 @@ describe("decider project scripts", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
@@ -218,7 +136,6 @@ describe("decider project scripts", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -305,7 +222,6 @@ describe("decider project scripts", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
@@ -329,7 +245,6 @@ describe("decider project scripts", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -389,7 +304,6 @@ describe("decider project scripts", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
@@ -413,7 +327,6 @@ describe("decider project scripts", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -77,7 +77,6 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
projectId: command.projectId,
|
||||
title: command.title,
|
||||
workspaceRoot: command.workspaceRoot,
|
||||
pinned: command.pinned ?? false,
|
||||
defaultModelSelection: command.defaultModelSelection ?? null,
|
||||
scripts: [],
|
||||
createdAt: command.createdAt,
|
||||
@@ -105,7 +104,6 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
projectId: command.projectId,
|
||||
...(command.title !== undefined ? { title: command.title } : {}),
|
||||
...(command.workspaceRoot !== undefined ? { workspaceRoot: command.workspaceRoot } : {}),
|
||||
...(command.pinned !== undefined ? { pinned: command.pinned } : {}),
|
||||
...(command.defaultModelSelection !== undefined
|
||||
? { defaultModelSelection: command.defaultModelSelection }
|
||||
: {}),
|
||||
@@ -160,7 +158,6 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
threadId: command.threadId,
|
||||
projectId: command.projectId,
|
||||
title: command.title,
|
||||
pinned: command.pinned ?? false,
|
||||
modelSelection: command.modelSelection,
|
||||
runtimeMode: command.runtimeMode,
|
||||
interactionMode: command.interactionMode,
|
||||
@@ -257,7 +254,6 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
...(command.title !== undefined ? { title: command.title } : {}),
|
||||
...(command.pinned !== undefined ? { pinned: command.pinned } : {}),
|
||||
...(command.modelSelection !== undefined
|
||||
? { modelSelection: command.modelSelection }
|
||||
: {}),
|
||||
|
||||
@@ -76,7 +76,6 @@ describe("orchestration projector", () => {
|
||||
id: "thread-1",
|
||||
projectId: "project-1",
|
||||
title: "demo",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -99,99 +98,6 @@ describe("orchestration projector", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("applies pin updates for projects and threads", async () => {
|
||||
const now = new Date().toISOString();
|
||||
const later = new Date(Date.parse(now) + 1_000).toISOString();
|
||||
const withProject = await Effect.runPromise(
|
||||
projectEvent(
|
||||
createEmptyReadModel(now),
|
||||
makeEvent({
|
||||
sequence: 1,
|
||||
type: "project.created",
|
||||
aggregateKind: "project",
|
||||
aggregateId: "project-1",
|
||||
occurredAt: now,
|
||||
commandId: "cmd-project-create",
|
||||
payload: {
|
||||
projectId: "project-1",
|
||||
title: "demo",
|
||||
workspaceRoot: "/tmp/project-1",
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
const withPinnedProject = await Effect.runPromise(
|
||||
projectEvent(
|
||||
withProject,
|
||||
makeEvent({
|
||||
sequence: 2,
|
||||
type: "project.meta-updated",
|
||||
aggregateKind: "project",
|
||||
aggregateId: "project-1",
|
||||
occurredAt: later,
|
||||
commandId: "cmd-project-pin",
|
||||
payload: {
|
||||
projectId: "project-1",
|
||||
pinned: true,
|
||||
updatedAt: later,
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(withPinnedProject.projects[0]?.pinned).toBe(true);
|
||||
|
||||
const withThread = await Effect.runPromise(
|
||||
projectEvent(
|
||||
withPinnedProject,
|
||||
makeEvent({
|
||||
sequence: 3,
|
||||
type: "thread.created",
|
||||
aggregateKind: "thread",
|
||||
aggregateId: "thread-1",
|
||||
occurredAt: now,
|
||||
commandId: "cmd-thread-create",
|
||||
payload: {
|
||||
threadId: "thread-1",
|
||||
projectId: "project-1",
|
||||
title: "demo",
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
},
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
const withPinnedThread = await Effect.runPromise(
|
||||
projectEvent(
|
||||
withThread,
|
||||
makeEvent({
|
||||
sequence: 4,
|
||||
type: "thread.meta-updated",
|
||||
aggregateKind: "thread",
|
||||
aggregateId: "thread-1",
|
||||
occurredAt: later,
|
||||
commandId: "cmd-thread-pin",
|
||||
payload: {
|
||||
threadId: "thread-1",
|
||||
pinned: true,
|
||||
updatedAt: later,
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(withPinnedThread.threads[0]?.pinned).toBe(true);
|
||||
});
|
||||
|
||||
it("fails when event payload cannot be decoded by runtime schema", async () => {
|
||||
const now = new Date().toISOString();
|
||||
const model = createEmptyReadModel(now);
|
||||
|
||||
@@ -183,7 +183,6 @@ export function projectEvent(
|
||||
id: payload.projectId,
|
||||
title: payload.title,
|
||||
workspaceRoot: payload.workspaceRoot,
|
||||
pinned: payload.pinned,
|
||||
defaultModelSelection: payload.defaultModelSelection,
|
||||
scripts: payload.scripts,
|
||||
createdAt: payload.createdAt,
|
||||
@@ -214,7 +213,6 @@ export function projectEvent(
|
||||
...(payload.workspaceRoot !== undefined
|
||||
? { workspaceRoot: payload.workspaceRoot }
|
||||
: {}),
|
||||
...(payload.pinned !== undefined ? { pinned: payload.pinned } : {}),
|
||||
...(payload.defaultModelSelection !== undefined
|
||||
? { defaultModelSelection: payload.defaultModelSelection }
|
||||
: {}),
|
||||
@@ -256,7 +254,6 @@ export function projectEvent(
|
||||
id: payload.threadId,
|
||||
projectId: payload.projectId,
|
||||
title: payload.title,
|
||||
pinned: payload.pinned,
|
||||
modelSelection: payload.modelSelection,
|
||||
runtimeMode: payload.runtimeMode,
|
||||
interactionMode: payload.interactionMode,
|
||||
@@ -323,7 +320,6 @@ export function projectEvent(
|
||||
...nextBase,
|
||||
threads: updateThread(nextBase.threads, payload.threadId, {
|
||||
...(payload.title !== undefined ? { title: payload.title } : {}),
|
||||
...(payload.pinned !== undefined ? { pinned: payload.pinned } : {}),
|
||||
...(payload.modelSelection !== undefined
|
||||
? { modelSelection: payload.modelSelection }
|
||||
: {}),
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
|
||||
const ProjectionProjectDbRow = ProjectionProject.mapFields(
|
||||
Struct.assign({
|
||||
pinned: Schema.BooleanFromBit,
|
||||
defaultModelSelection: Schema.NullOr(Schema.fromJsonString(ModelSelection)),
|
||||
scripts: Schema.fromJsonString(Schema.Array(ProjectScript)),
|
||||
}),
|
||||
@@ -32,7 +31,6 @@ const makeProjectionProjectRepository = Effect.gen(function* () {
|
||||
project_id,
|
||||
title,
|
||||
workspace_root,
|
||||
pinned,
|
||||
default_model_selection_json,
|
||||
scripts_json,
|
||||
created_at,
|
||||
@@ -43,7 +41,6 @@ const makeProjectionProjectRepository = Effect.gen(function* () {
|
||||
${row.projectId},
|
||||
${row.title},
|
||||
${row.workspaceRoot},
|
||||
${row.pinned ? 1 : 0},
|
||||
${row.defaultModelSelection !== null ? JSON.stringify(row.defaultModelSelection) : null},
|
||||
${JSON.stringify(row.scripts)},
|
||||
${row.createdAt},
|
||||
@@ -54,7 +51,6 @@ const makeProjectionProjectRepository = Effect.gen(function* () {
|
||||
DO UPDATE SET
|
||||
title = excluded.title,
|
||||
workspace_root = excluded.workspace_root,
|
||||
pinned = excluded.pinned,
|
||||
default_model_selection_json = excluded.default_model_selection_json,
|
||||
scripts_json = excluded.scripts_json,
|
||||
created_at = excluded.created_at,
|
||||
@@ -72,7 +68,6 @@ const makeProjectionProjectRepository = Effect.gen(function* () {
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
workspace_root AS "workspaceRoot",
|
||||
pinned,
|
||||
default_model_selection_json AS "defaultModelSelection",
|
||||
scripts_json AS "scripts",
|
||||
created_at AS "createdAt",
|
||||
@@ -92,7 +87,6 @@ const makeProjectionProjectRepository = Effect.gen(function* () {
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
workspace_root AS "workspaceRoot",
|
||||
pinned,
|
||||
default_model_selection_json AS "defaultModelSelection",
|
||||
scripts_json AS "scripts",
|
||||
created_at AS "createdAt",
|
||||
|
||||
@@ -27,7 +27,6 @@ projectionRepositoriesLayer("Projection repositories", (it) => {
|
||||
projectId: ProjectId.makeUnsafe("project-null-options"),
|
||||
title: "Null options project",
|
||||
workspaceRoot: "/tmp/project-null-options",
|
||||
pinned: true,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.4",
|
||||
@@ -61,7 +60,6 @@ projectionRepositoriesLayer("Projection repositories", (it) => {
|
||||
const persisted = yield* projects.getById({
|
||||
projectId: ProjectId.makeUnsafe("project-null-options"),
|
||||
});
|
||||
assert.strictEqual(Option.getOrNull(persisted)?.pinned, true);
|
||||
assert.deepStrictEqual(Option.getOrNull(persisted)?.defaultModelSelection, {
|
||||
provider: "codex",
|
||||
model: "gpt-5.4",
|
||||
@@ -78,7 +76,6 @@ projectionRepositoriesLayer("Projection repositories", (it) => {
|
||||
threadId: ThreadId.makeUnsafe("thread-null-options"),
|
||||
projectId: ProjectId.makeUnsafe("project-null-options"),
|
||||
title: "Null options thread",
|
||||
pinned: true,
|
||||
modelSelection: {
|
||||
provider: "claudeAgent",
|
||||
model: "claude-opus-4-6",
|
||||
@@ -117,7 +114,6 @@ projectionRepositoriesLayer("Projection repositories", (it) => {
|
||||
const persisted = yield* threads.getById({
|
||||
threadId: ThreadId.makeUnsafe("thread-null-options"),
|
||||
});
|
||||
assert.strictEqual(Option.getOrNull(persisted)?.pinned, true);
|
||||
assert.deepStrictEqual(Option.getOrNull(persisted)?.modelSelection, {
|
||||
provider: "claudeAgent",
|
||||
model: "claude-opus-4-6",
|
||||
|
||||
@@ -15,7 +15,6 @@ import { ModelSelection } from "@t3tools/contracts";
|
||||
|
||||
const ProjectionThreadDbRow = ProjectionThread.mapFields(
|
||||
Struct.assign({
|
||||
pinned: Schema.BooleanFromBit,
|
||||
modelSelection: Schema.fromJsonString(ModelSelection),
|
||||
}),
|
||||
);
|
||||
@@ -32,7 +31,6 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
thread_id,
|
||||
project_id,
|
||||
title,
|
||||
pinned,
|
||||
model_selection_json,
|
||||
runtime_mode,
|
||||
interaction_mode,
|
||||
@@ -48,7 +46,6 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
${row.threadId},
|
||||
${row.projectId},
|
||||
${row.title},
|
||||
${row.pinned ? 1 : 0},
|
||||
${JSON.stringify(row.modelSelection)},
|
||||
${row.runtimeMode},
|
||||
${row.interactionMode},
|
||||
@@ -64,7 +61,6 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
DO UPDATE SET
|
||||
project_id = excluded.project_id,
|
||||
title = excluded.title,
|
||||
pinned = excluded.pinned,
|
||||
model_selection_json = excluded.model_selection_json,
|
||||
runtime_mode = excluded.runtime_mode,
|
||||
interaction_mode = excluded.interaction_mode,
|
||||
@@ -87,7 +83,6 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
thread_id AS "threadId",
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
pinned,
|
||||
model_selection_json AS "modelSelection",
|
||||
runtime_mode AS "runtimeMode",
|
||||
interaction_mode AS "interactionMode",
|
||||
@@ -112,7 +107,6 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
thread_id AS "threadId",
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
pinned,
|
||||
model_selection_json AS "modelSelection",
|
||||
runtime_mode AS "runtimeMode",
|
||||
interaction_mode AS "interactionMode",
|
||||
|
||||
@@ -31,7 +31,6 @@ import Migration0015 from "./Migrations/015_ProjectionTurnsSourceProposedPlan.ts
|
||||
import Migration0016 from "./Migrations/016_CanonicalizeModelSelections.ts";
|
||||
import Migration0017 from "./Migrations/017_ProjectionThreadsArchivedAt.ts";
|
||||
import Migration0018 from "./Migrations/018_ProjectionThreadsArchivedAtIndex.ts";
|
||||
import Migration0019 from "./Migrations/019_ProjectionPins.ts";
|
||||
|
||||
/**
|
||||
* Migration loader with all migrations defined inline.
|
||||
@@ -62,7 +61,6 @@ export const migrationEntries = [
|
||||
[16, "CanonicalizeModelSelections", Migration0016],
|
||||
[17, "ProjectionThreadsArchivedAt", Migration0017],
|
||||
[18, "ProjectionThreadsArchivedAtIndex", Migration0018],
|
||||
[19, "ProjectionPins", Migration0019],
|
||||
] as const;
|
||||
|
||||
export const makeMigrationLoader = (throughId?: number) =>
|
||||
|
||||
@@ -9,7 +9,6 @@ export default Effect.gen(function* () {
|
||||
project_id TEXT PRIMARY KEY,
|
||||
title TEXT NOT NULL,
|
||||
workspace_root TEXT NOT NULL,
|
||||
pinned INTEGER NOT NULL DEFAULT 0,
|
||||
default_model TEXT,
|
||||
scripts_json TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL,
|
||||
@@ -23,7 +22,6 @@ export default Effect.gen(function* () {
|
||||
thread_id TEXT PRIMARY KEY,
|
||||
project_id TEXT NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
pinned INTEGER NOT NULL DEFAULT 0,
|
||||
model TEXT NOT NULL,
|
||||
branch TEXT,
|
||||
worktree_path TEXT,
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
|
||||
export default Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
|
||||
const projectColumns = yield* sql<{ readonly name: string }>`
|
||||
PRAGMA table_info(projection_projects)
|
||||
`;
|
||||
if (!projectColumns.some((column) => column.name === "pinned")) {
|
||||
yield* sql`
|
||||
ALTER TABLE projection_projects
|
||||
ADD COLUMN pinned INTEGER NOT NULL DEFAULT 0
|
||||
`;
|
||||
}
|
||||
|
||||
const threadColumns = yield* sql<{ readonly name: string }>`
|
||||
PRAGMA table_info(projection_threads)
|
||||
`;
|
||||
if (!threadColumns.some((column) => column.name === "pinned")) {
|
||||
yield* sql`
|
||||
ALTER TABLE projection_threads
|
||||
ADD COLUMN pinned INTEGER NOT NULL DEFAULT 0
|
||||
`;
|
||||
}
|
||||
});
|
||||
@@ -16,7 +16,6 @@ export const ProjectionProject = Schema.Struct({
|
||||
projectId: ProjectId,
|
||||
title: Schema.String,
|
||||
workspaceRoot: Schema.String,
|
||||
pinned: Schema.Boolean,
|
||||
defaultModelSelection: Schema.NullOr(ModelSelection),
|
||||
scripts: Schema.Array(ProjectScript),
|
||||
createdAt: IsoDateTime,
|
||||
|
||||
@@ -24,7 +24,6 @@ export const ProjectionThread = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
projectId: ProjectId,
|
||||
title: Schema.String,
|
||||
pinned: Schema.Boolean,
|
||||
modelSelection: ModelSelection,
|
||||
runtimeMode: RuntimeMode,
|
||||
interactionMode: ProviderInteractionMode,
|
||||
|
||||
@@ -63,6 +63,8 @@ const asThreadId = (value: string): ThreadId => ThreadId.makeUnsafe(value);
|
||||
const asTurnId = (value: string): TurnId => TurnId.makeUnsafe(value);
|
||||
|
||||
const defaultOpenService: OpenShape = {
|
||||
getAvailableEditors: Effect.succeed([]),
|
||||
openExternal: () => Effect.void,
|
||||
openBrowser: () => Effect.void,
|
||||
openInEditor: () => Effect.void,
|
||||
};
|
||||
@@ -1030,6 +1032,8 @@ describe("WebSocket Server", () => {
|
||||
it("routes shell.openInEditor through the injected open service", async () => {
|
||||
const openCalls: Array<{ cwd: string; editor: string }> = [];
|
||||
const openService: OpenShape = {
|
||||
getAvailableEditors: Effect.succeed([]),
|
||||
openExternal: () => Effect.void,
|
||||
openBrowser: () => Effect.void,
|
||||
openInEditor: (input) => {
|
||||
openCalls.push({ cwd: input.cwd, editor: input.editor });
|
||||
@@ -1221,7 +1225,6 @@ describe("WebSocket Server", () => {
|
||||
projectId: "project-diff",
|
||||
title: "Diff Project",
|
||||
workspaceRoot,
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -1235,7 +1238,6 @@ describe("WebSocket Server", () => {
|
||||
threadId: "thread-diff",
|
||||
projectId: "project-diff",
|
||||
title: "Diff Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -1308,7 +1310,6 @@ describe("WebSocket Server", () => {
|
||||
projectId: "project-1",
|
||||
title: "WS Project",
|
||||
workspaceRoot,
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -1322,7 +1323,6 @@ describe("WebSocket Server", () => {
|
||||
threadId: "thread-1",
|
||||
projectId: "project-1",
|
||||
title: "Thread 1",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -1535,6 +1535,8 @@ describe("WebSocket Server", () => {
|
||||
process.on("unhandledRejection", onUnhandledRejection);
|
||||
|
||||
const brokenOpenService: OpenShape = {
|
||||
getAvailableEditors: Effect.succeed([]),
|
||||
openExternal: () => Effect.void,
|
||||
openBrowser: () => Effect.void,
|
||||
openInEditor: () =>
|
||||
Effect.sync(() => BigInt(1)).pipe(Effect.map((result) => result as unknown as void)),
|
||||
|
||||
@@ -58,7 +58,7 @@ import { ProviderService } from "./provider/Services/ProviderService";
|
||||
import { ProviderRegistry } from "./provider/Services/ProviderRegistry";
|
||||
import { CheckpointDiffQuery } from "./checkpointing/Services/CheckpointDiffQuery";
|
||||
import { clamp } from "effect/Number";
|
||||
import { Open, resolveAvailableEditors } from "./open";
|
||||
import { Open } from "./open";
|
||||
import { ServerConfig } from "./config";
|
||||
import { GitCore } from "./git/Services/GitCore.ts";
|
||||
import { tryHandleProjectFaviconRequest } from "./projectFaviconRoute";
|
||||
@@ -250,7 +250,10 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
logWebSocketEvents,
|
||||
autoBootstrapProjectFromCwd,
|
||||
} = serverConfig;
|
||||
const availableEditors = resolveAvailableEditors();
|
||||
const open = yield* Open;
|
||||
const availableEditors = yield* open.getAvailableEditors.pipe(
|
||||
Effect.mapError((cause) => new ServerLifecycleError({ operation: "availableEditors", cause })),
|
||||
);
|
||||
|
||||
const runtimeServices = yield* Effect.services<
|
||||
ServerRuntimeServices | ServerConfig | FileSystem.FileSystem | Path.Path
|
||||
@@ -615,7 +618,7 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
const projectionReadModelQuery = yield* ProjectionSnapshotQuery;
|
||||
const checkpointDiffQuery = yield* CheckpointDiffQuery;
|
||||
const orchestrationReactor = yield* OrchestrationReactor;
|
||||
const { openInEditor } = yield* Open;
|
||||
const { openInEditor } = open;
|
||||
|
||||
const subscriptionsScope = yield* Scope.make("sequential");
|
||||
yield* Effect.addFinalizer(() => Scope.close(subscriptionsScope, Exit.void));
|
||||
@@ -675,7 +678,6 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
projectId: bootstrapProjectId,
|
||||
title: bootstrapProjectTitle,
|
||||
workspaceRoot: cwd,
|
||||
pinned: false,
|
||||
defaultModelSelection: bootstrapProjectDefaultModelSelection,
|
||||
createdAt,
|
||||
});
|
||||
@@ -699,7 +701,6 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
threadId,
|
||||
projectId: bootstrapProjectId,
|
||||
title: "New thread",
|
||||
pinned: false,
|
||||
modelSelection: bootstrapProjectDefaultModelSelection,
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "full-access",
|
||||
|
||||
@@ -237,7 +237,6 @@ function createSnapshotForTargetUser(options: {
|
||||
id: PROJECT_ID,
|
||||
title: "Project",
|
||||
workspaceRoot: "/repo/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5",
|
||||
@@ -253,7 +252,6 @@ function createSnapshotForTargetUser(options: {
|
||||
id: THREAD_ID,
|
||||
projectId: PROJECT_ID,
|
||||
title: "Browser test thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5",
|
||||
@@ -312,7 +310,6 @@ function addThreadToSnapshot(
|
||||
id: threadId,
|
||||
projectId: PROJECT_ID,
|
||||
title: "New thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5",
|
||||
@@ -360,7 +357,6 @@ function createThreadCreatedEvent(threadId: ThreadId, sequence: number): Orchest
|
||||
threadId,
|
||||
projectId: PROJECT_ID,
|
||||
title: "New thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5",
|
||||
|
||||
@@ -89,7 +89,6 @@ const makeThread = (input?: {
|
||||
codexThreadId: null,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: { provider: "codex" as const, model: "gpt-5.4" },
|
||||
runtimeMode: "full-access" as const,
|
||||
interactionMode: "default" as const,
|
||||
@@ -248,7 +247,6 @@ describe("hasServerAcknowledgedLocalDispatch", () => {
|
||||
codexThreadId: null,
|
||||
projectId,
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: { provider: "codex", model: "gpt-5.4" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
@@ -285,7 +283,6 @@ describe("hasServerAcknowledgedLocalDispatch", () => {
|
||||
codexThreadId: null,
|
||||
projectId,
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: { provider: "codex", model: "gpt-5.4" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
@@ -331,7 +328,6 @@ describe("hasServerAcknowledgedLocalDispatch", () => {
|
||||
codexThreadId: null,
|
||||
projectId,
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: { provider: "codex", model: "gpt-5.4" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
|
||||
@@ -26,7 +26,6 @@ export function buildLocalDraftThread(
|
||||
codexThreadId: null,
|
||||
projectId: draftThread.projectId,
|
||||
title: "New thread",
|
||||
pinned: false,
|
||||
modelSelection: fallbackModelSelection,
|
||||
runtimeMode: draftThread.runtimeMode,
|
||||
interactionMode: draftThread.interactionMode,
|
||||
|
||||
@@ -2774,7 +2774,6 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
threadId: threadIdForSend,
|
||||
projectId: activeProject.id,
|
||||
title,
|
||||
pinned: false,
|
||||
modelSelection: threadCreateModelSelection,
|
||||
runtimeMode,
|
||||
interactionMode,
|
||||
@@ -3222,7 +3221,6 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
threadId: nextThreadId,
|
||||
projectId: activeProject.id,
|
||||
title: nextThreadTitle,
|
||||
pinned: false,
|
||||
modelSelection: nextThreadModelSelection,
|
||||
runtimeMode,
|
||||
interactionMode: "default",
|
||||
|
||||
@@ -76,7 +76,6 @@ function createMinimalSnapshot(): OrchestrationReadModel {
|
||||
id: PROJECT_ID,
|
||||
title: "Project",
|
||||
workspaceRoot: "/repo/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5",
|
||||
@@ -92,7 +91,6 @@ function createMinimalSnapshot(): OrchestrationReadModel {
|
||||
id: THREAD_ID,
|
||||
projectId: PROJECT_ID,
|
||||
title: "Test thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5",
|
||||
|
||||
@@ -592,7 +592,6 @@ function makeProject(overrides: Partial<Project> = {}): Project {
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
name: "Project",
|
||||
cwd: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.4",
|
||||
@@ -611,7 +610,6 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
codexThreadId: null,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.4",
|
||||
@@ -760,73 +758,6 @@ describe("sortThreadsForSidebar", () => {
|
||||
ThreadId.makeUnsafe("thread-2"),
|
||||
]);
|
||||
});
|
||||
|
||||
it("puts pinned threads ahead of unpinned threads in auto-sort modes", () => {
|
||||
const sorted = sortThreadsForSidebar(
|
||||
[
|
||||
{
|
||||
...makeThread({
|
||||
id: ThreadId.makeUnsafe("thread-1"),
|
||||
createdAt: "2026-03-09T10:00:00.000Z",
|
||||
updatedAt: "2026-03-09T10:01:00.000Z",
|
||||
}),
|
||||
pinned: true,
|
||||
},
|
||||
{
|
||||
...makeThread({
|
||||
id: ThreadId.makeUnsafe("thread-2"),
|
||||
createdAt: "2026-03-09T10:05:00.000Z",
|
||||
updatedAt: "2026-03-09T10:05:00.000Z",
|
||||
}),
|
||||
pinned: false,
|
||||
},
|
||||
],
|
||||
"updated_at",
|
||||
);
|
||||
|
||||
expect(sorted.map((thread) => thread.id)).toEqual([
|
||||
ThreadId.makeUnsafe("thread-1"),
|
||||
ThreadId.makeUnsafe("thread-2"),
|
||||
]);
|
||||
});
|
||||
|
||||
it("still auto-sorts within the pinned thread bucket", () => {
|
||||
const sorted = sortThreadsForSidebar(
|
||||
[
|
||||
{
|
||||
...makeThread({
|
||||
id: ThreadId.makeUnsafe("thread-1"),
|
||||
createdAt: "2026-03-09T10:01:00.000Z",
|
||||
updatedAt: "2026-03-09T10:01:00.000Z",
|
||||
}),
|
||||
pinned: true,
|
||||
},
|
||||
{
|
||||
...makeThread({
|
||||
id: ThreadId.makeUnsafe("thread-2"),
|
||||
createdAt: "2026-03-09T10:05:00.000Z",
|
||||
updatedAt: "2026-03-09T10:05:00.000Z",
|
||||
}),
|
||||
pinned: true,
|
||||
},
|
||||
{
|
||||
...makeThread({
|
||||
id: ThreadId.makeUnsafe("thread-3"),
|
||||
createdAt: "2026-03-09T10:10:00.000Z",
|
||||
updatedAt: "2026-03-09T10:10:00.000Z",
|
||||
}),
|
||||
pinned: false,
|
||||
},
|
||||
],
|
||||
"updated_at",
|
||||
);
|
||||
|
||||
expect(sorted.map((thread) => thread.id)).toEqual([
|
||||
ThreadId.makeUnsafe("thread-2"),
|
||||
ThreadId.makeUnsafe("thread-1"),
|
||||
ThreadId.makeUnsafe("thread-3"),
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getFallbackThreadIdAfterDelete", () => {
|
||||
@@ -865,41 +796,6 @@ describe("getFallbackThreadIdAfterDelete", () => {
|
||||
expect(fallbackThreadId).toBe(ThreadId.makeUnsafe("thread-newest"));
|
||||
});
|
||||
|
||||
it("respects pinning when choosing the fallback thread after delete", () => {
|
||||
const fallbackThreadId = getFallbackThreadIdAfterDelete({
|
||||
threads: [
|
||||
{
|
||||
...makeThread({
|
||||
id: ThreadId.makeUnsafe("thread-active"),
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
updatedAt: "2026-03-09T10:05:00.000Z",
|
||||
}),
|
||||
pinned: false,
|
||||
},
|
||||
{
|
||||
...makeThread({
|
||||
id: ThreadId.makeUnsafe("thread-pinned"),
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
updatedAt: "2026-03-09T10:03:00.000Z",
|
||||
}),
|
||||
pinned: true,
|
||||
},
|
||||
{
|
||||
...makeThread({
|
||||
id: ThreadId.makeUnsafe("thread-newer"),
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
updatedAt: "2026-03-09T10:10:00.000Z",
|
||||
}),
|
||||
pinned: false,
|
||||
},
|
||||
],
|
||||
deletedThreadId: ThreadId.makeUnsafe("thread-active"),
|
||||
sortOrder: "updated_at",
|
||||
});
|
||||
|
||||
expect(fallbackThreadId).toBe(ThreadId.makeUnsafe("thread-pinned"));
|
||||
});
|
||||
|
||||
it("skips other threads being deleted in the same action", () => {
|
||||
const fallbackThreadId = getFallbackThreadIdAfterDelete({
|
||||
threads: [
|
||||
@@ -1004,65 +900,6 @@ describe("sortProjectsForSidebar", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("puts pinned projects ahead of unpinned projects in auto-sort modes", () => {
|
||||
const sorted = sortProjectsForSidebar(
|
||||
[
|
||||
makeProject({
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
name: "Pinned older project",
|
||||
pinned: true,
|
||||
updatedAt: "2026-03-09T10:01:00.000Z",
|
||||
}),
|
||||
makeProject({
|
||||
id: ProjectId.makeUnsafe("project-2"),
|
||||
name: "Unpinned newer project",
|
||||
pinned: false,
|
||||
updatedAt: "2026-03-09T10:05:00.000Z",
|
||||
}),
|
||||
],
|
||||
[],
|
||||
"updated_at",
|
||||
);
|
||||
|
||||
expect(sorted.map((project) => project.id)).toEqual([
|
||||
ProjectId.makeUnsafe("project-1"),
|
||||
ProjectId.makeUnsafe("project-2"),
|
||||
]);
|
||||
});
|
||||
|
||||
it("still auto-sorts within the pinned bucket", () => {
|
||||
const sorted = sortProjectsForSidebar(
|
||||
[
|
||||
makeProject({
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
name: "Pinned older project",
|
||||
pinned: true,
|
||||
updatedAt: "2026-03-09T10:01:00.000Z",
|
||||
}),
|
||||
makeProject({
|
||||
id: ProjectId.makeUnsafe("project-2"),
|
||||
name: "Pinned newer project",
|
||||
pinned: true,
|
||||
updatedAt: "2026-03-09T10:05:00.000Z",
|
||||
}),
|
||||
makeProject({
|
||||
id: ProjectId.makeUnsafe("project-3"),
|
||||
name: "Unpinned project",
|
||||
pinned: false,
|
||||
updatedAt: "2026-03-09T10:10:00.000Z",
|
||||
}),
|
||||
],
|
||||
[],
|
||||
"updated_at",
|
||||
);
|
||||
|
||||
expect(sorted.map((project) => project.id)).toEqual([
|
||||
ProjectId.makeUnsafe("project-2"),
|
||||
ProjectId.makeUnsafe("project-1"),
|
||||
ProjectId.makeUnsafe("project-3"),
|
||||
]);
|
||||
});
|
||||
|
||||
it("falls back to name and id ordering when projects have no sortable timestamps", () => {
|
||||
const sorted = sortProjectsForSidebar(
|
||||
[
|
||||
|
||||
@@ -16,12 +16,10 @@ type SidebarProject = {
|
||||
name: string;
|
||||
createdAt?: string | undefined;
|
||||
updatedAt?: string | undefined;
|
||||
pinned?: boolean | undefined;
|
||||
};
|
||||
type SidebarThreadSortInput = Pick<Thread, "createdAt" | "updatedAt"> & {
|
||||
latestUserMessageAt?: string | null;
|
||||
messages?: Pick<Thread["messages"][number], "createdAt" | "role">[];
|
||||
pinned?: boolean | undefined;
|
||||
};
|
||||
|
||||
export type ThreadTraversalDirection = "previous" | "next";
|
||||
@@ -454,11 +452,6 @@ export function sortThreadsForSidebar<
|
||||
T extends Pick<Thread, "id" | "createdAt" | "updatedAt"> & SidebarThreadSortInput,
|
||||
>(threads: readonly T[], sortOrder: SidebarThreadSortOrder): T[] {
|
||||
return threads.toSorted((left, right) => {
|
||||
const leftPinned = left.pinned === true;
|
||||
const rightPinned = right.pinned === true;
|
||||
if (leftPinned !== rightPinned) {
|
||||
return rightPinned ? 1 : -1;
|
||||
}
|
||||
const rightTimestamp = getThreadSortTimestamp(right, sortOrder);
|
||||
const leftTimestamp = getThreadSortTimestamp(left, sortOrder);
|
||||
const byTimestamp =
|
||||
@@ -533,11 +526,6 @@ export function sortProjectsForSidebar<
|
||||
}
|
||||
|
||||
return [...projects].toSorted((left, right) => {
|
||||
const leftPinned = left.pinned === true;
|
||||
const rightPinned = right.pinned === true;
|
||||
if (leftPinned !== rightPinned) {
|
||||
return rightPinned ? 1 : -1;
|
||||
}
|
||||
const rightTimestamp = getProjectSortTimestamp(
|
||||
right,
|
||||
threadsByProjectId.get(right.id) ?? [],
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
ChevronRightIcon,
|
||||
FolderIcon,
|
||||
GitPullRequestIcon,
|
||||
PinIcon,
|
||||
PlusIcon,
|
||||
SettingsIcon,
|
||||
SquarePenIcon,
|
||||
@@ -153,7 +152,6 @@ type SidebarThreadSnapshot = Pick<
|
||||
| "id"
|
||||
| "interactionMode"
|
||||
| "latestTurn"
|
||||
| "pinned"
|
||||
| "projectId"
|
||||
| "proposedPlans"
|
||||
| "session"
|
||||
@@ -165,7 +163,9 @@ type SidebarThreadSnapshot = Pick<
|
||||
latestUserMessageAt: string | null;
|
||||
};
|
||||
|
||||
type SidebarProjectSnapshot = Project & { expanded: boolean };
|
||||
type SidebarProjectSnapshot = Project & {
|
||||
expanded: boolean;
|
||||
};
|
||||
|
||||
const sidebarThreadSnapshotCache = new WeakMap<
|
||||
Thread,
|
||||
@@ -206,7 +206,6 @@ function toSidebarThreadSnapshot(
|
||||
updatedAt: thread.updatedAt,
|
||||
archivedAt: thread.archivedAt,
|
||||
latestTurn: thread.latestTurn,
|
||||
pinned: thread.pinned,
|
||||
lastVisitedAt,
|
||||
branch: thread.branch,
|
||||
worktreePath: thread.worktreePath,
|
||||
@@ -676,7 +675,6 @@ export default function Sidebar() {
|
||||
projectId,
|
||||
title,
|
||||
workspaceRoot: cwd,
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: DEFAULT_MODEL_BY_PROVIDER.codex,
|
||||
@@ -834,42 +832,6 @@ export default function Sidebar() {
|
||||
});
|
||||
},
|
||||
});
|
||||
const setThreadPinned = useCallback(async (thread: SidebarThreadSnapshot, pinned: boolean) => {
|
||||
const api = readNativeApi();
|
||||
if (!api) return;
|
||||
try {
|
||||
await api.orchestration.dispatchCommand({
|
||||
type: "thread.meta.update",
|
||||
commandId: newCommandId(),
|
||||
threadId: thread.id,
|
||||
pinned,
|
||||
});
|
||||
} catch (error) {
|
||||
toastManager.add({
|
||||
type: "error",
|
||||
title: `${pinned ? "Pin" : "Unpin"} thread failed`,
|
||||
description: error instanceof Error ? error.message : "An error occurred.",
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
const setProjectPinned = useCallback(async (project: Project, pinned: boolean) => {
|
||||
const api = readNativeApi();
|
||||
if (!api) return;
|
||||
try {
|
||||
await api.orchestration.dispatchCommand({
|
||||
type: "project.meta.update",
|
||||
commandId: newCommandId(),
|
||||
projectId: project.id,
|
||||
pinned,
|
||||
});
|
||||
} catch (error) {
|
||||
toastManager.add({
|
||||
type: "error",
|
||||
title: `${pinned ? "Pin" : "Unpin"} project failed`,
|
||||
description: error instanceof Error ? error.message : "An error occurred.",
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
const handleThreadContextMenu = useCallback(
|
||||
async (threadId: ThreadId, position: { x: number; y: number }) => {
|
||||
const api = readNativeApi();
|
||||
@@ -880,7 +842,6 @@ export default function Sidebar() {
|
||||
thread.worktreePath ?? projectCwdById.get(thread.projectId) ?? null;
|
||||
const clicked = await api.contextMenu.show(
|
||||
[
|
||||
{ id: "toggle-pin", label: thread.pinned ? "Unpin thread" : "Pin thread" },
|
||||
{ id: "rename", label: "Rename thread" },
|
||||
{ id: "mark-unread", label: "Mark unread" },
|
||||
{ id: "copy-path", label: "Copy Path" },
|
||||
@@ -890,11 +851,6 @@ export default function Sidebar() {
|
||||
position,
|
||||
);
|
||||
|
||||
if (clicked === "toggle-pin") {
|
||||
await setThreadPinned(thread, !thread.pinned);
|
||||
return;
|
||||
}
|
||||
|
||||
if (clicked === "rename") {
|
||||
setRenamingThreadId(threadId);
|
||||
setRenamingTitle(thread.title);
|
||||
@@ -944,7 +900,6 @@ export default function Sidebar() {
|
||||
markThreadUnread,
|
||||
projectCwdById,
|
||||
threads,
|
||||
setThreadPinned,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -1063,19 +1018,11 @@ export default function Sidebar() {
|
||||
|
||||
const clicked = await api.contextMenu.show(
|
||||
[
|
||||
{
|
||||
id: "toggle-pin",
|
||||
label: project.pinned ? "Unpin project" : "Pin project",
|
||||
},
|
||||
{ id: "copy-path", label: "Copy Project Path" },
|
||||
{ id: "delete", label: "Remove project", destructive: true },
|
||||
],
|
||||
position,
|
||||
);
|
||||
if (clicked === "toggle-pin") {
|
||||
await setProjectPinned(project, !project.pinned);
|
||||
return;
|
||||
}
|
||||
if (clicked === "copy-path") {
|
||||
copyPathToClipboard(project.cwd, { path: project.cwd });
|
||||
return;
|
||||
@@ -1122,7 +1069,6 @@ export default function Sidebar() {
|
||||
copyPathToClipboard,
|
||||
getDraftThreadByProjectId,
|
||||
projects,
|
||||
setProjectPinned,
|
||||
threads,
|
||||
],
|
||||
);
|
||||
@@ -1439,12 +1385,9 @@ export default function Sidebar() {
|
||||
const isConfirmingArchive = confirmingArchiveThreadId === thread.id && !isThreadRunning;
|
||||
const threadMetaClassName = isConfirmingArchive
|
||||
? "pointer-events-none opacity-0"
|
||||
: "pointer-events-none transition-opacity duration-150 group-hover/menu-sub-item:opacity-0 group-focus-within/menu-sub-item:opacity-0";
|
||||
const hoverActionClassName =
|
||||
"inline-flex size-5 cursor-pointer items-center justify-center text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring";
|
||||
const hoverActionGroupClassName =
|
||||
"pointer-events-none absolute top-1/2 right-1 flex -translate-y-1/2 items-center gap-0.5 opacity-0 transition-opacity duration-150 group-hover/menu-sub-item:pointer-events-auto group-hover/menu-sub-item:opacity-100 group-focus-within/menu-sub-item:pointer-events-auto group-focus-within/menu-sub-item:opacity-100";
|
||||
const pinActionLabel = thread.pinned ? "Unpin" : "Pin";
|
||||
: !isThreadRunning
|
||||
? "pointer-events-none transition-opacity duration-150 group-hover/menu-sub-item:opacity-0 group-focus-within/menu-sub-item:opacity-0"
|
||||
: "pointer-events-none";
|
||||
|
||||
return (
|
||||
<SidebarMenuSubItem
|
||||
@@ -1500,11 +1443,6 @@ export default function Sidebar() {
|
||||
}}
|
||||
>
|
||||
<div className="flex min-w-0 flex-1 items-center gap-1.5 text-left">
|
||||
{thread.pinned ? (
|
||||
<span className="inline-flex shrink-0" title="Pinned thread">
|
||||
<PinIcon className="size-3 text-muted-foreground/55" />
|
||||
</span>
|
||||
) : null}
|
||||
{prStatus && (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
@@ -1602,69 +1540,58 @@ export default function Sidebar() {
|
||||
>
|
||||
Confirm
|
||||
</button>
|
||||
) : null}
|
||||
{!isConfirmingArchive ? (
|
||||
<div className={hoverActionGroupClassName}>
|
||||
) : !isThreadRunning ? (
|
||||
appSettings.confirmThreadArchive ? (
|
||||
<div className="pointer-events-none absolute top-1/2 right-1 -translate-y-1/2 opacity-0 transition-opacity duration-150 group-hover/menu-sub-item:pointer-events-auto group-hover/menu-sub-item:opacity-100 group-focus-within/menu-sub-item:pointer-events-auto group-focus-within/menu-sub-item:opacity-100">
|
||||
<button
|
||||
type="button"
|
||||
data-thread-selection-safe
|
||||
data-testid={`thread-archive-${thread.id}`}
|
||||
aria-label={`Archive ${thread.title}`}
|
||||
className="inline-flex size-5 cursor-pointer items-center justify-center text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring"
|
||||
onPointerDown={(event) => {
|
||||
event.stopPropagation();
|
||||
}}
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
setConfirmingArchiveThreadId(thread.id);
|
||||
requestAnimationFrame(() => {
|
||||
confirmArchiveButtonRefs.current.get(thread.id)?.focus();
|
||||
});
|
||||
}}
|
||||
>
|
||||
<ArchiveIcon className="size-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<button
|
||||
type="button"
|
||||
data-thread-selection-safe
|
||||
data-testid={`thread-pin-${thread.id}`}
|
||||
aria-label={`${pinActionLabel} ${thread.title}`}
|
||||
className={hoverActionClassName}
|
||||
onPointerDown={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}}
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
void setThreadPinned(thread, !thread.pinned);
|
||||
}}
|
||||
>
|
||||
<PinIcon className="size-3.5" />
|
||||
</button>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">{pinActionLabel}</TooltipPopup>
|
||||
</Tooltip>
|
||||
{!isThreadRunning ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<div className="pointer-events-none absolute top-1/2 right-1 -translate-y-1/2 opacity-0 transition-opacity duration-150 group-hover/menu-sub-item:pointer-events-auto group-hover/menu-sub-item:opacity-100 group-focus-within/menu-sub-item:pointer-events-auto group-focus-within/menu-sub-item:opacity-100">
|
||||
<button
|
||||
type="button"
|
||||
data-thread-selection-safe
|
||||
data-testid={`thread-archive-${thread.id}`}
|
||||
aria-label={`Archive ${thread.title}`}
|
||||
className={hoverActionClassName}
|
||||
className="inline-flex size-5 cursor-pointer items-center justify-center text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring"
|
||||
onPointerDown={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}}
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (appSettings.confirmThreadArchive) {
|
||||
setConfirmingArchiveThreadId(thread.id);
|
||||
requestAnimationFrame(() => {
|
||||
confirmArchiveButtonRefs.current.get(thread.id)?.focus();
|
||||
});
|
||||
return;
|
||||
}
|
||||
void attemptArchiveThread(thread.id);
|
||||
}}
|
||||
>
|
||||
<ArchiveIcon className="size-3.5" />
|
||||
</button>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">Archive</TooltipPopup>
|
||||
</Tooltip>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">Archive</TooltipPopup>
|
||||
</Tooltip>
|
||||
)
|
||||
) : null}
|
||||
<span className={threadMetaClassName}>
|
||||
{showThreadJumpHints && jumpLabel ? (
|
||||
@@ -1739,18 +1666,6 @@ export default function Sidebar() {
|
||||
/>
|
||||
)}
|
||||
<ProjectFavicon cwd={project.cwd} />
|
||||
{project.pinned ? (
|
||||
<span
|
||||
className="inline-flex shrink-0"
|
||||
title={
|
||||
isManualProjectSorting
|
||||
? "Pinned project (inactive in manual sorting)"
|
||||
: "Pinned project"
|
||||
}
|
||||
>
|
||||
<PinIcon className="size-3 text-muted-foreground/55" />
|
||||
</span>
|
||||
) : null}
|
||||
<span className="flex-1 truncate text-xs font-medium text-foreground/90">
|
||||
{project.name}
|
||||
</span>
|
||||
@@ -1768,10 +1683,6 @@ export default function Sidebar() {
|
||||
}
|
||||
showOnHover
|
||||
className="top-1 right-1.5 size-5 rounded-md p-0 text-muted-foreground/70 hover:bg-secondary hover:text-foreground"
|
||||
onPointerDown={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}}
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
@@ -48,7 +48,6 @@ describe("deriveOrchestrationBatchEffects", () => {
|
||||
threadId: createdThreadId,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Created thread",
|
||||
pinned: false,
|
||||
modelSelection: { provider: "codex", model: "gpt-5-codex" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
@@ -81,7 +80,6 @@ describe("deriveOrchestrationBatchEffects", () => {
|
||||
threadId,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Recreated thread",
|
||||
pinned: false,
|
||||
modelSelection: { provider: "codex", model: "gpt-5-codex" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
|
||||
@@ -25,7 +25,6 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
codexThreadId: null,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -54,7 +53,6 @@ function makeState(thread: Thread): AppState {
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
name: "Project",
|
||||
cwd: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
@@ -99,7 +97,6 @@ function makeReadModelThread(overrides: Partial<OrchestrationReadModel["threads"
|
||||
id: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
@@ -131,7 +128,6 @@ function makeReadModel(thread: OrchestrationReadModel["threads"][number]): Orche
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
@@ -153,7 +149,6 @@ function makeReadModelProject(
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
@@ -258,7 +253,6 @@ describe("store read model sync", () => {
|
||||
id: project2,
|
||||
name: "Project 2",
|
||||
cwd: "/tmp/project-2",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: DEFAULT_MODEL_BY_PROVIDER.codex,
|
||||
@@ -269,7 +263,6 @@ describe("store read model sync", () => {
|
||||
id: project1,
|
||||
name: "Project 1",
|
||||
cwd: "/tmp/project-1",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: DEFAULT_MODEL_BY_PROVIDER.codex,
|
||||
@@ -360,7 +353,6 @@ describe("incremental orchestration updates", () => {
|
||||
id: originalProjectId,
|
||||
name: "Project",
|
||||
cwd: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: DEFAULT_MODEL_BY_PROVIDER.codex,
|
||||
@@ -378,7 +370,6 @@ describe("incremental orchestration updates", () => {
|
||||
projectId: recreatedProjectId,
|
||||
title: "Project Recreated",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: DEFAULT_MODEL_BY_PROVIDER.codex,
|
||||
|
||||
@@ -147,7 +147,6 @@ function mapThread(thread: OrchestrationThread): Thread {
|
||||
codexThreadId: null,
|
||||
projectId: thread.projectId,
|
||||
title: thread.title,
|
||||
pinned: thread.pinned,
|
||||
modelSelection: normalizeModelSelection(thread.modelSelection),
|
||||
runtimeMode: thread.runtimeMode,
|
||||
interactionMode: thread.interactionMode,
|
||||
@@ -172,7 +171,6 @@ function mapProject(project: OrchestrationReadModel["projects"][number]): Projec
|
||||
id: project.id,
|
||||
name: project.title,
|
||||
cwd: project.workspaceRoot,
|
||||
pinned: project.pinned,
|
||||
defaultModelSelection: project.defaultModelSelection
|
||||
? normalizeModelSelection(project.defaultModelSelection)
|
||||
: null,
|
||||
@@ -426,7 +424,6 @@ export function applyOrchestrationEvent(state: AppState, event: OrchestrationEve
|
||||
id: event.payload.projectId,
|
||||
title: event.payload.title,
|
||||
workspaceRoot: event.payload.workspaceRoot,
|
||||
pinned: event.payload.pinned,
|
||||
defaultModelSelection: event.payload.defaultModelSelection,
|
||||
scripts: event.payload.scripts,
|
||||
createdAt: event.payload.createdAt,
|
||||
@@ -447,7 +444,6 @@ export function applyOrchestrationEvent(state: AppState, event: OrchestrationEve
|
||||
...project,
|
||||
...(event.payload.title !== undefined ? { name: event.payload.title } : {}),
|
||||
...(event.payload.workspaceRoot !== undefined ? { cwd: event.payload.workspaceRoot } : {}),
|
||||
...(event.payload.pinned !== undefined ? { pinned: event.payload.pinned } : {}),
|
||||
...(event.payload.defaultModelSelection !== undefined
|
||||
? {
|
||||
defaultModelSelection: event.payload.defaultModelSelection
|
||||
@@ -474,7 +470,6 @@ export function applyOrchestrationEvent(state: AppState, event: OrchestrationEve
|
||||
id: event.payload.threadId,
|
||||
projectId: event.payload.projectId,
|
||||
title: event.payload.title,
|
||||
pinned: event.payload.pinned,
|
||||
modelSelection: event.payload.modelSelection,
|
||||
runtimeMode: event.payload.runtimeMode,
|
||||
interactionMode: event.payload.interactionMode,
|
||||
@@ -524,7 +519,6 @@ export function applyOrchestrationEvent(state: AppState, event: OrchestrationEve
|
||||
const threads = updateThread(state.threads, event.payload.threadId, (thread) => ({
|
||||
...thread,
|
||||
...(event.payload.title !== undefined ? { title: event.payload.title } : {}),
|
||||
...(event.payload.pinned !== undefined ? { pinned: event.payload.pinned } : {}),
|
||||
...(event.payload.modelSelection !== undefined
|
||||
? { modelSelection: normalizeModelSelection(event.payload.modelSelection) }
|
||||
: {}),
|
||||
|
||||
@@ -82,7 +82,6 @@ export interface Project {
|
||||
id: ProjectId;
|
||||
name: string;
|
||||
cwd: string;
|
||||
pinned: boolean;
|
||||
defaultModelSelection: ModelSelection | null;
|
||||
createdAt?: string | undefined;
|
||||
updatedAt?: string | undefined;
|
||||
@@ -94,7 +93,6 @@ export interface Thread {
|
||||
codexThreadId: string | null;
|
||||
projectId: ProjectId;
|
||||
title: string;
|
||||
pinned: boolean;
|
||||
modelSelection: ModelSelection;
|
||||
runtimeMode: RuntimeMode;
|
||||
interactionMode: ProviderInteractionMode;
|
||||
|
||||
@@ -10,7 +10,6 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
codexThreadId: null,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
pinned: false,
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
|
||||
@@ -289,7 +289,6 @@ describe("wsNativeApi", () => {
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/workspace",
|
||||
pinned: false,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: "2026-02-24T00:00:00.000Z",
|
||||
@@ -332,7 +331,6 @@ describe("wsNativeApi", () => {
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
pinned: false,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
|
||||
@@ -54,7 +54,6 @@
|
||||
"@pierre/diffs": "^1.1.0-beta.16",
|
||||
"effect": "catalog:",
|
||||
"node-pty": "^1.1.0",
|
||||
"open": "^10.1.0",
|
||||
"ws": "^8.18.0",
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -176,13 +175,13 @@
|
||||
"vite": "^8.0.0",
|
||||
},
|
||||
"catalog": {
|
||||
"@effect/language-service": "0.84.1",
|
||||
"@effect/platform-node": "4.0.0-beta.42",
|
||||
"@effect/sql-sqlite-bun": "4.0.0-beta.42",
|
||||
"@effect/vitest": "4.0.0-beta.42",
|
||||
"@effect/language-service": "0.84.2",
|
||||
"@effect/platform-node": "4.0.0-beta.43",
|
||||
"@effect/sql-sqlite-bun": "4.0.0-beta.43",
|
||||
"@effect/vitest": "4.0.0-beta.43",
|
||||
"@types/bun": "^1.3.9",
|
||||
"@types/node": "^24.10.13",
|
||||
"effect": "4.0.0-beta.42",
|
||||
"effect": "4.0.0-beta.43",
|
||||
"tsdown": "^0.20.3",
|
||||
"typescript": "^5.7.3",
|
||||
"vitest": "^4.0.0",
|
||||
@@ -268,15 +267,15 @@
|
||||
|
||||
"@dnd-kit/utilities": ["@dnd-kit/[email protected]", "", { "dependencies": { "tslib": "^2.0.0" }, "peerDependencies": { "react": ">=16.8.0" } }, "sha512-+MKAJEOfaBe5SmV6t34p80MMKhjvUz0vRrvVJbPT0WElzaOJ/1xs+D+KDv+tD/NE5ujfrChEcshd4fLn0wpiqg=="],
|
||||
|
||||
"@effect/language-service": ["@effect/[email protected].1", "", { "bin": { "effect-language-service": "cli.js" } }, "sha512-YUqjJU24HeYgPV453cR2fDqkZ+zZKMuxGnmxWAPscWJ6gt6FB7JZohMCOczRTIOGPrQMcloJX7BjCaPu+RNhpw=="],
|
||||
"@effect/language-service": ["@effect/[email protected].2", "", { "bin": { "effect-language-service": "cli.js" } }, "sha512-l04qNxpiA8rY5yXWckRPJ7Mk5MNerXuNymSFf+IdflfI5i8jgL1bpBNLuP6ijg7wgjdHc/KmTnCj2kT0SCntuA=="],
|
||||
|
||||
"@effect/platform-node": ["@effect/[email protected]2", "", { "dependencies": { "@effect/platform-node-shared": "^4.0.0-beta.42", "mime": "^4.1.0", "undici": "^7.24.0" }, "peerDependencies": { "effect": "^4.0.0-beta.42", "ioredis": "^5.7.0" } }, "sha512-kbdRML2FBa4q8U8rZQcnmLKZ5zN/z1bAA7t5D1/UsBHZqJgnfRgu1CP6kaEfb1Nie6YyaWshxTktZQryjvW/Yg=="],
|
||||
"@effect/platform-node": ["@effect/[email protected]3", "", { "dependencies": { "@effect/platform-node-shared": "^4.0.0-beta.43", "mime": "^4.1.0", "undici": "^7.24.0" }, "peerDependencies": { "effect": "^4.0.0-beta.43", "ioredis": "^5.7.0" } }, "sha512-Uq6E1rjaIpjHauzjwoB2HzAg3battYt2Boy8XO50GoHiWCXKE6WapYZ0/AnaBx5v5qg2sOfqpuiLsUf9ZgxOkA=="],
|
||||
|
||||
"@effect/platform-node-shared": ["@effect/[email protected]2", "", { "dependencies": { "@types/ws": "^8.18.1", "ws": "^8.19.0" }, "peerDependencies": { "effect": "^4.0.0-beta.42" } }, "sha512-PC+lxLsrwob3+nBChAPrQq32olCeyApgXBvs1NrRsoArLViNT76T/68CttuCAksCZj5e1bZ1ZibLPel3vUmx2g=="],
|
||||
"@effect/platform-node-shared": ["@effect/[email protected]3", "", { "dependencies": { "@types/ws": "^8.18.1", "ws": "^8.19.0" }, "peerDependencies": { "effect": "^4.0.0-beta.43" } }, "sha512-A9q0GEb61pYcQ06Dr6gXj1nKlDI3KHsar1sk3qb1ZY+kVSR64tBAylI8zGon23KY+NPtTUj/sEIToB7jc3Qt5w=="],
|
||||
|
||||
"@effect/sql-sqlite-bun": ["@effect/[email protected]2", "", { "peerDependencies": { "effect": "^4.0.0-beta.42" } }, "sha512-Ah2QfkeV+I9r5OBVJijSDnFXCv51giBXngSwhju5gefc0uWiM3G1tsYAqrNX24HlvFFEnOAZqNf/Sq1h4NqOAA=="],
|
||||
"@effect/sql-sqlite-bun": ["@effect/[email protected]3", "", { "peerDependencies": { "effect": "^4.0.0-beta.43" } }, "sha512-Ryb7x0rBjW5NHegbzvz9y2Yv4KpwZ1UiPk7/Rv+Mkux74Qkjdmotmrvy9P+M5A9TZyL2Av+GpaLTPJKsL0PG+Q=="],
|
||||
|
||||
"@effect/vitest": ["@effect/[email protected]2", "", { "peerDependencies": { "effect": "^4.0.0-beta.42", "vitest": "^3.0.0 || ^4.0.0" } }, "sha512-/11arjUnCRhIrBRvOn/nrbg5p/FadjAPvStddZlpl1VrCxtB2s0n39cbG9uTyDdf1ZrRBG73Upo1ZDF1CTWy8w=="],
|
||||
"@effect/vitest": ["@effect/[email protected]3", "", { "peerDependencies": { "effect": "^4.0.0-beta.43", "vitest": "^3.0.0 || ^4.0.0" } }, "sha512-XN2LAwiUWPqbV2jrsYYRjrVydQ8MIgwr83MVImtUaOQco4vk43+8OHlXQMRN/u2HnGK29KT+O2yTMMBdk2Q6Sw=="],
|
||||
|
||||
"@electron/get": ["@electron/[email protected]", "", { "dependencies": { "debug": "^4.1.1", "env-paths": "^2.2.0", "fs-extra": "^8.1.0", "got": "^11.8.5", "progress": "^2.0.3", "semver": "^6.2.0", "sumchecker": "^3.0.1" }, "optionalDependencies": { "global-agent": "^3.0.0" } }, "sha512-Qkzpg2s9GnVV2I2BjRksUi43U5e6+zaQMcjoJy0C+C5oxaKl+fmckGDQFtRpZpZV0NQekuZZ+tGz7EA9TVnQtQ=="],
|
||||
|
||||
@@ -896,8 +895,6 @@
|
||||
|
||||
"bun-types": ["[email protected]", "", { "dependencies": { "@types/node": "*" } }, "sha512-tcpfCCl6XWo6nCVnpcVrxQ+9AYN1iqMIzgrSKYMB/fjLtV2eyAVEg7AxQJuCq/26R6HpKWykQXuSOq/21RYcbg=="],
|
||||
|
||||
"bundle-name": ["[email protected]", "", { "dependencies": { "run-applescript": "^7.0.0" } }, "sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q=="],
|
||||
|
||||
"cac": ["[email protected]", "", {}, "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ=="],
|
||||
|
||||
"cacheable-lookup": ["[email protected]", "", {}, "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA=="],
|
||||
@@ -972,16 +969,10 @@
|
||||
|
||||
"decompress-response": ["[email protected]", "", { "dependencies": { "mimic-response": "^3.1.0" } }, "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ=="],
|
||||
|
||||
"default-browser": ["[email protected]", "", { "dependencies": { "bundle-name": "^4.1.0", "default-browser-id": "^5.0.0" } }, "sha512-H9LMLr5zwIbSxrmvikGuI/5KGhZ8E2zH3stkMgM5LpOWDutGM2JZaj460Udnf1a+946zc7YBgrqEWwbk7zHvGw=="],
|
||||
|
||||
"default-browser-id": ["[email protected]", "", {}, "sha512-x1VCxdX4t+8wVfd1so/9w+vQ4vx7lKd2Qp5tDRutErwmR85OgmfX7RlLRMWafRMY7hbEiXIbudNrjOAPa/hL8Q=="],
|
||||
|
||||
"defer-to-connect": ["[email protected]", "", {}, "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg=="],
|
||||
|
||||
"define-data-property": ["[email protected]", "", { "dependencies": { "es-define-property": "^1.0.0", "es-errors": "^1.3.0", "gopd": "^1.0.1" } }, "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A=="],
|
||||
|
||||
"define-lazy-prop": ["[email protected]", "", {}, "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg=="],
|
||||
|
||||
"define-properties": ["[email protected]", "", { "dependencies": { "define-data-property": "^1.0.1", "has-property-descriptors": "^1.0.0", "object-keys": "^1.1.1" } }, "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg=="],
|
||||
|
||||
"defu": ["[email protected]", "", {}, "sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg=="],
|
||||
@@ -1020,7 +1011,7 @@
|
||||
|
||||
"dunder-proto": ["[email protected]", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.1", "es-errors": "^1.3.0", "gopd": "^1.2.0" } }, "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A=="],
|
||||
|
||||
"effect": ["[email protected]2", "", { "dependencies": { "@standard-schema/spec": "^1.1.0", "fast-check": "^4.5.3", "find-my-way-ts": "^0.1.6", "ini": "^6.0.0", "kubernetes-types": "^1.30.0", "msgpackr": "^1.11.8", "multipasta": "^0.2.7", "toml": "^3.0.0", "uuid": "^13.0.0", "yaml": "^2.8.2" } }, "sha512-c1UrRP+tLzyHb4Fepl8XBDJlLQLkrcMXrRBba441GQRxMbeQ/aIOSFcBwSda1iMJ5l9F0lYc3Bhe33/whrmavQ=="],
|
||||
"effect": ["[email protected]3", "", { "dependencies": { "@standard-schema/spec": "^1.1.0", "fast-check": "^4.5.3", "find-my-way-ts": "^0.1.6", "ini": "^6.0.0", "kubernetes-types": "^1.30.0", "msgpackr": "^1.11.8", "multipasta": "^0.2.7", "toml": "^3.0.0", "uuid": "^13.0.0", "yaml": "^2.8.2" } }, "sha512-AJYyDimIwJOn87uUz/JzmgDc5GfjxJbXvEbTvNzMa+M3Uer344bLo/O5mMRkqc1vBleA+Ygs4+dbE3QsqOkKTQ=="],
|
||||
|
||||
"electron": ["[email protected]", "", { "dependencies": { "@electron/get": "^2.0.0", "@types/node": "^24.9.0", "extract-zip": "^2.0.1" }, "bin": { "electron": "cli.js" } }, "sha512-ett8W+yOFGDuM0vhJMamYSkrbV3LoaffzJd9GfjI96zRAxyrNqUSKqBpf/WGbQCweDxX2pkUCUfrv4wwKpsFZA=="],
|
||||
|
||||
@@ -1462,8 +1453,6 @@
|
||||
|
||||
"oniguruma-to-es": ["[email protected]", "", { "dependencies": { "oniguruma-parser": "^0.12.1", "regex": "^6.1.0", "regex-recursion": "^6.0.2" } }, "sha512-Zjygswjpsewa0NLTsiizVuMQZbp0MDyM6lIt66OxsF21npUDlzpHi1Mgb/qhQdkb+dWFTzJmFbEWdvZgRho8eQ=="],
|
||||
|
||||
"open": ["[email protected]", "", { "dependencies": { "default-browser": "^5.2.1", "define-lazy-prop": "^3.0.0", "is-inside-container": "^1.0.0", "wsl-utils": "^0.1.0" } }, "sha512-YgBpdJHPyQ2UE5x+hlSXcnejzAvD0b22U2OuAP+8OnlJT+PjWPxtgmGqKKc+RgTM63U9gN0YzrYc71R2WT/hTA=="],
|
||||
|
||||
"outvariant": ["[email protected]", "", {}, "sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA=="],
|
||||
|
||||
"oxfmt": ["[email protected]", "", { "dependencies": { "tinypool": "2.1.0" }, "optionalDependencies": { "@oxfmt/binding-android-arm-eabi": "0.40.0", "@oxfmt/binding-android-arm64": "0.40.0", "@oxfmt/binding-darwin-arm64": "0.40.0", "@oxfmt/binding-darwin-x64": "0.40.0", "@oxfmt/binding-freebsd-x64": "0.40.0", "@oxfmt/binding-linux-arm-gnueabihf": "0.40.0", "@oxfmt/binding-linux-arm-musleabihf": "0.40.0", "@oxfmt/binding-linux-arm64-gnu": "0.40.0", "@oxfmt/binding-linux-arm64-musl": "0.40.0", "@oxfmt/binding-linux-ppc64-gnu": "0.40.0", "@oxfmt/binding-linux-riscv64-gnu": "0.40.0", "@oxfmt/binding-linux-riscv64-musl": "0.40.0", "@oxfmt/binding-linux-s390x-gnu": "0.40.0", "@oxfmt/binding-linux-x64-gnu": "0.40.0", "@oxfmt/binding-linux-x64-musl": "0.40.0", "@oxfmt/binding-openharmony-arm64": "0.40.0", "@oxfmt/binding-win32-arm64-msvc": "0.40.0", "@oxfmt/binding-win32-ia32-msvc": "0.40.0", "@oxfmt/binding-win32-x64-msvc": "0.40.0" }, "bin": { "oxfmt": "bin/oxfmt" } }, "sha512-g0C3I7xUj4b4DcagevM9kgH6+pUHytikxUcn3/VUkvzTNaaXBeyZqb7IBsHwojeXm4mTBEC/aBjBTMVUkZwWUQ=="],
|
||||
@@ -1598,8 +1587,6 @@
|
||||
|
||||
"rolldown-plugin-dts": ["[email protected]", "", { "dependencies": { "@babel/generator": "8.0.0-rc.2", "@babel/helper-validator-identifier": "8.0.0-rc.2", "@babel/parser": "8.0.0-rc.2", "@babel/types": "8.0.0-rc.2", "ast-kit": "^3.0.0-beta.1", "birpc": "^4.0.0", "dts-resolver": "^2.1.3", "get-tsconfig": "^4.13.6", "obug": "^2.1.1" }, "peerDependencies": { "@ts-macro/tsc": "^0.3.6", "@typescript/native-preview": ">=7.0.0-dev.20250601.1", "rolldown": "^1.0.0-rc.3", "typescript": "^5.0.0 || ^6.0.0-beta", "vue-tsc": "~3.2.0" }, "optionalPeers": ["@ts-macro/tsc", "@typescript/native-preview", "typescript", "vue-tsc"] }, "sha512-M/HXfM4cboo+jONx9Z0X+CUf3B5tCi7ni+kR5fUW50Fp9AlZk0oVLesibGWgCXDKFp5lpgQ9yhKoImUFjl3VZw=="],
|
||||
|
||||
"run-applescript": ["[email protected]", "", {}, "sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q=="],
|
||||
|
||||
"rxjs": ["[email protected]", "", { "dependencies": { "tslib": "^2.1.0" } }, "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA=="],
|
||||
|
||||
"sax": ["[email protected]", "", {}, "sha512-21IYA3Q5cQf089Z6tgaUTr7lDAyzoTPx5HRtbhsME8Udispad8dC/+sziTNugOEx54ilvatQ9YCzl4KQLPcRHA=="],
|
||||
@@ -1856,8 +1843,6 @@
|
||||
|
||||
"ws": ["[email protected]", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg=="],
|
||||
|
||||
"wsl-utils": ["[email protected]", "", { "dependencies": { "is-wsl": "^3.1.0" } }, "sha512-h3Fbisa2nKGPxCpm89Hk33lBLsnaGBvctQopaBSOW/uIs6FTe1ATyAnKFJrzVs9vpGdsTe73WF3V4lIsk4Gacw=="],
|
||||
|
||||
"xxhash-wasm": ["[email protected]", "", {}, "sha512-147y/6YNh+tlp6nd/2pWq38i9h6mz/EuQ6njIrmW8D1BS5nCqs0P6DG+m6zTGnNz5I+uhZ0SHxBs9BsPrwcKDA=="],
|
||||
|
||||
"y18n": ["[email protected]", "", {}, "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="],
|
||||
|
||||
+5
-5
@@ -8,11 +8,11 @@
|
||||
"scripts"
|
||||
],
|
||||
"catalog": {
|
||||
"effect": "4.0.0-beta.42",
|
||||
"@effect/platform-node": "4.0.0-beta.42",
|
||||
"@effect/sql-sqlite-bun": "4.0.0-beta.42",
|
||||
"@effect/vitest": "4.0.0-beta.42",
|
||||
"@effect/language-service": "0.84.1",
|
||||
"effect": "4.0.0-beta.43",
|
||||
"@effect/platform-node": "4.0.0-beta.43",
|
||||
"@effect/sql-sqlite-bun": "4.0.0-beta.43",
|
||||
"@effect/vitest": "4.0.0-beta.43",
|
||||
"@effect/language-service": "0.84.2",
|
||||
"@types/bun": "^1.3.9",
|
||||
"@types/node": "^24.10.13",
|
||||
"tsdown": "^0.20.3",
|
||||
|
||||
@@ -95,7 +95,6 @@ it.effect("trims branded ids and command string fields at decode boundaries", ()
|
||||
assert.strictEqual(parsed.projectId, "project-1");
|
||||
assert.strictEqual(parsed.title, "Project Title");
|
||||
assert.strictEqual(parsed.workspaceRoot, "/tmp/workspace");
|
||||
assert.strictEqual(parsed.pinned, false);
|
||||
assert.deepStrictEqual(parsed.defaultModelSelection, {
|
||||
provider: "codex",
|
||||
model: "gpt-5.2",
|
||||
@@ -118,7 +117,6 @@ it.effect("decodes historical project.created payloads with a default provider",
|
||||
updatedAt: "2026-01-01T00:00:00.000Z",
|
||||
});
|
||||
assert.strictEqual(parsed.defaultModelSelection?.provider, "codex");
|
||||
assert.strictEqual(parsed.pinned, false);
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -216,7 +214,6 @@ it.effect("decodes thread.created runtime mode for historical events", () =>
|
||||
|
||||
assert.strictEqual(parsed.runtimeMode, DEFAULT_RUNTIME_MODE);
|
||||
assert.strictEqual(parsed.modelSelection.provider, "codex");
|
||||
assert.strictEqual(parsed.pinned, false);
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -145,7 +145,6 @@ export const OrchestrationProject = Schema.Struct({
|
||||
id: ProjectId,
|
||||
title: TrimmedNonEmptyString,
|
||||
workspaceRoot: TrimmedNonEmptyString,
|
||||
pinned: Schema.Boolean.pipe(Schema.withDecodingDefault(() => false)),
|
||||
defaultModelSelection: Schema.NullOr(ModelSelection),
|
||||
scripts: Schema.Array(ProjectScript),
|
||||
createdAt: IsoDateTime,
|
||||
@@ -275,7 +274,6 @@ export const OrchestrationThread = Schema.Struct({
|
||||
id: ThreadId,
|
||||
projectId: ProjectId,
|
||||
title: TrimmedNonEmptyString,
|
||||
pinned: Schema.Boolean.pipe(Schema.withDecodingDefault(() => false)),
|
||||
modelSelection: ModelSelection,
|
||||
runtimeMode: RuntimeMode,
|
||||
interactionMode: ProviderInteractionMode.pipe(
|
||||
@@ -310,7 +308,6 @@ export const ProjectCreateCommand = Schema.Struct({
|
||||
projectId: ProjectId,
|
||||
title: TrimmedNonEmptyString,
|
||||
workspaceRoot: TrimmedNonEmptyString,
|
||||
pinned: Schema.Boolean.pipe(Schema.withDecodingDefault(() => false)),
|
||||
defaultModelSelection: Schema.optional(Schema.NullOr(ModelSelection)),
|
||||
createdAt: IsoDateTime,
|
||||
});
|
||||
@@ -321,7 +318,6 @@ const ProjectMetaUpdateCommand = Schema.Struct({
|
||||
projectId: ProjectId,
|
||||
title: Schema.optional(TrimmedNonEmptyString),
|
||||
workspaceRoot: Schema.optional(TrimmedNonEmptyString),
|
||||
pinned: Schema.optional(Schema.Boolean),
|
||||
defaultModelSelection: Schema.optional(Schema.NullOr(ModelSelection)),
|
||||
scripts: Schema.optional(Schema.Array(ProjectScript)),
|
||||
});
|
||||
@@ -338,7 +334,6 @@ const ThreadCreateCommand = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
projectId: ProjectId,
|
||||
title: TrimmedNonEmptyString,
|
||||
pinned: Schema.Boolean.pipe(Schema.withDecodingDefault(() => false)),
|
||||
modelSelection: ModelSelection,
|
||||
runtimeMode: RuntimeMode,
|
||||
interactionMode: ProviderInteractionMode.pipe(
|
||||
@@ -372,7 +367,6 @@ const ThreadMetaUpdateCommand = Schema.Struct({
|
||||
commandId: CommandId,
|
||||
threadId: ThreadId,
|
||||
title: Schema.optional(TrimmedNonEmptyString),
|
||||
pinned: Schema.optional(Schema.Boolean),
|
||||
modelSelection: Schema.optional(ModelSelection),
|
||||
branch: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||
worktreePath: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||
@@ -630,7 +624,6 @@ export const ProjectCreatedPayload = Schema.Struct({
|
||||
projectId: ProjectId,
|
||||
title: TrimmedNonEmptyString,
|
||||
workspaceRoot: TrimmedNonEmptyString,
|
||||
pinned: Schema.Boolean.pipe(Schema.withDecodingDefault(() => false)),
|
||||
defaultModelSelection: Schema.NullOr(ModelSelection),
|
||||
scripts: Schema.Array(ProjectScript),
|
||||
createdAt: IsoDateTime,
|
||||
@@ -641,7 +634,6 @@ export const ProjectMetaUpdatedPayload = Schema.Struct({
|
||||
projectId: ProjectId,
|
||||
title: Schema.optional(TrimmedNonEmptyString),
|
||||
workspaceRoot: Schema.optional(TrimmedNonEmptyString),
|
||||
pinned: Schema.optional(Schema.Boolean),
|
||||
defaultModelSelection: Schema.optional(Schema.NullOr(ModelSelection)),
|
||||
scripts: Schema.optional(Schema.Array(ProjectScript)),
|
||||
updatedAt: IsoDateTime,
|
||||
@@ -656,7 +648,6 @@ export const ThreadCreatedPayload = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
projectId: ProjectId,
|
||||
title: TrimmedNonEmptyString,
|
||||
pinned: Schema.Boolean.pipe(Schema.withDecodingDefault(() => false)),
|
||||
modelSelection: ModelSelection,
|
||||
runtimeMode: RuntimeMode.pipe(Schema.withDecodingDefault(() => DEFAULT_RUNTIME_MODE)),
|
||||
interactionMode: ProviderInteractionMode.pipe(
|
||||
@@ -687,7 +678,6 @@ export const ThreadUnarchivedPayload = Schema.Struct({
|
||||
export const ThreadMetaUpdatedPayload = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
title: Schema.optional(TrimmedNonEmptyString),
|
||||
pinned: Schema.optional(Schema.Boolean),
|
||||
modelSelection: Schema.optional(ModelSelection),
|
||||
branch: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||
worktreePath: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||
|
||||
Reference in new issue
Block a user