Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ function withReplayRequestId(
entry: CodexReplay.CodexAppServerReplayEntry,
id: number,
): CodexReplay.CodexAppServerReplayEntry {
return entry.type !== "runtime_exit" && Predicate.isObject(entry.frame)
return entry.type !== "runtime_exit" && Predicate.isObject(entry.frame) && "id" in entry.frame
? { ...entry, frame: { ...entry.frame, id } }
: entry;
}
Expand Down Expand Up @@ -1159,7 +1159,7 @@ describe("CodexAdapterV2 post-settle continuation", () => {
runtimePolicy: CODEX_TEST_RUNTIME_POLICY,
});
const events: Array<ProviderAdapter.ProviderAdapterV2Event> = [];
const firstTerminal = yield* Deferred.make<void>();
const firstTerminal = yield* Deferred.make<void, ProviderAdapter.ProviderAdapterV2Error>();
yield* runtime.events.pipe(
Stream.runForEach((event) =>
Effect.sync(() => {
Expand All @@ -1174,6 +1174,7 @@ describe("CodexAdapterV2 post-settle continuation", () => {
Effect.andThen(onEvent(event)),
),
),
Effect.catchCause((cause) => Deferred.failCause(firstTerminal, cause)),
Effect.forkScoped,
);
if (runtime.hasPendingBackgroundWork === undefined) {
Expand Down
4 changes: 3 additions & 1 deletion apps/server/src/provider/Drivers/ClaudeSkills.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ it.layer(NodeServices.layer)("discoverClaudeSkills", (it) => {
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });
const tempDir = yield* fs.realPath(
yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" }),
);
const configDir = path.join(tempDir, "claude-home");
const workspace = path.join(tempDir, "workspace");
const nestedWorkspace = path.join(workspace, "packages", "app");
Expand Down
24 changes: 1 addition & 23 deletions apps/server/src/provider/Drivers/CodexDriver.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,4 @@
/**
* CodexDriver — first concrete `ProviderDriver` in the new per-instance model.
*
* A driver is a plain value (not a Context.Service) whose `create()` returns
* one `ProviderInstance` bundling:
* - `snapshot` — the live `ManagedServerProvider` for this instance;
* - `adapter` — the Codex session/turn/approval runtime;
* - `textGeneration` — commit/PR/branch/title generation via `codex exec`.
*
* Each call to `create()` captures the `codexConfig` argument in closures
* owned by the returned instance. Two instances created with different
* `homePath`s (e.g. `codex_personal` + `codex_work`) therefore run with
* fully independent Codex app-server processes and `CODEX_HOME`
* environments — no shared mutable state.
*
* Resource lifecycle: `create()` runs in a scope handed in by the registry.
* Closing that scope releases the adapter's child processes, the managed
* snapshot's refresh fibre, and the text-generation binaries' transient
* scratch files. The registry uses this to tear down an instance when its
* `providerInstances` entry disappears or its config changes.
*
* @module provider/Drivers/CodexDriver
*/
// Each instance owns its Codex home and child processes; the registry owns its scope.
import { CodexSettings, ProviderDriverKind, type ServerProvider } from "@t3tools/contracts";
import * as Crypto from "effect/Crypto";
import * as Effect from "effect/Effect";
Expand Down
30 changes: 18 additions & 12 deletions apps/server/src/textGeneration/TextGeneration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ describe("TextGeneration.make", () => {
makeStubRegistry([instance]),
),
Effect.provide(
Layer.mock(SourceControlProviderRegistry.SourceControlProviderRegistry)({
resolveLink: () => Effect.die("Supplied context must not be fetched again"),
}),
Layer.mergeAll(
Layer.mock(SourceControlProviderRegistry.SourceControlProviderRegistry)({
resolveLink: () => Effect.die("Supplied context must not be fetched again"),
}),
ServerSettings.layerTest(),
),
),
Effect.provide(ServerSettings.layerTest()),
);
yield* generation.generateThreadTitle({
cwd: process.cwd(),
Expand Down Expand Up @@ -131,11 +133,13 @@ describe("TextGeneration.make", () => {
makeStubRegistry([personal, work]),
),
Effect.provide(
Layer.mock(SourceControlProviderRegistry.SourceControlProviderRegistry)({
resolveLink: () => Effect.die("No link lookup expected"),
}),
Layer.mergeAll(
Layer.mock(SourceControlProviderRegistry.SourceControlProviderRegistry)({
resolveLink: () => Effect.die("No link lookup expected"),
}),
ServerSettings.layerTest(),
),
),
Effect.provide(ServerSettings.layerTest()),
);

const result = yield* tg.generateBranchName({
Expand All @@ -157,11 +161,13 @@ describe("TextGeneration.make", () => {
makeStubRegistry([]),
),
Effect.provide(
Layer.mock(SourceControlProviderRegistry.SourceControlProviderRegistry)({
resolveLink: () => Effect.die("No link lookup expected"),
}),
Layer.mergeAll(
Layer.mock(SourceControlProviderRegistry.SourceControlProviderRegistry)({
resolveLink: () => Effect.die("No link lookup expected"),
}),
ServerSettings.layerTest(),
),
),
Effect.provide(ServerSettings.layerTest()),
);

const result = yield* tg
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/vcs/GitVcsDriverCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3743,7 +3743,7 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
assert.equal(yield* git(created.worktree.path, ["branch", "--show-current"]), branch);
assert.include(
yield* git(cwd, ["-c", "core.quotePath=false", "worktree", "list", "--porcelain"]),
`worktree ${created.worktree.path}`,
`worktree ${NodeFS.realpathSync.native(created.worktree.path)}`,
);
folders.add(folder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ export function ScheduledTasksSettings(target: {
? { environmentId: pendingDraft.environmentId, task: null, seed: pendingDraft.seed }
: null,
);
// The form owns the prefill once open; clearing it keeps a later visit from reopening it.
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- Consume the external pending-draft atom after the mounted editor takes ownership.
useEffect(() => {
if (pendingDraft) setPendingScheduledTaskDraft(null);
}, [pendingDraft]);
Expand Down
9 changes: 7 additions & 2 deletions scripts/build-npm-launcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,16 @@ it.layer(NodeServices.layer)("build-npm-launcher", (it) => {
T3CODE_RELEASE_BASE_URL: release.baseUrl,
};
const launcher = path.join(packageDir, "bin/t3.mjs");
const canonicalLauncher = yield* fs.realPath(launcher);
const first = yield* run(process.execPath, [launcher, "serve", "a b"], {
cwd: root,
env,
});
assert.equal(first.stdout.trim(), `stub serve a b launcher=${launcher}`, first.stderr);
assert.equal(
first.stdout.trim(),
`stub serve a b launcher=${canonicalLauncher}`,
first.stderr,
);
assert.equal(first.exitCode, 7);
const versionDir = path.join(home, "runtime/versions", VERSION);
assert.equal(
Expand Down Expand Up @@ -298,7 +303,7 @@ fs.readFileSync = (file, ...rest) => {
});
assert.equal(
replaced.stdout.trim(),
`stub --version launcher=${launcher}`,
`stub --version launcher=${canonicalLauncher}`,
replaced.stderr,
);
assert.equal(replaced.exitCode, 7);
Expand Down