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
15 changes: 5 additions & 10 deletions apps/server/integration/OrchestrationEngineHarness.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,19 +406,14 @@ export const makeOrchestrationIntegrationHarness = (
disposed = true;

const shutdown = Effect.gen(function* () {
const stopAllExit = yield* Effect.exit(
Effect.promise(() => runtime.runPromise(providerService.stopAll())),
);
const closeScopeExit = yield* Effect.exit(Scope.close(scope, Exit.void));
const disposeRuntimeExit = yield* Effect.exit(Effect.promise(() => runtime.dispose()));

const failureCause = Exit.isFailure(stopAllExit)
? stopAllExit.cause
: Exit.isFailure(closeScopeExit)
? closeScopeExit.cause
: Exit.isFailure(disposeRuntimeExit)
? disposeRuntimeExit.cause
: null;
const failureCause = Exit.isFailure(closeScopeExit)
? closeScopeExit.cause
: Exit.isFailure(disposeRuntimeExit)
? disposeRuntimeExit.cause
: null;

if (failureCause) {
return yield* Effect.failCause(failureCause);
Expand Down
101 changes: 95 additions & 6 deletions apps/server/scripts/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Data, Effect, FileSystem, Logger, Option, Path } from "effect";
import { Command, Flag } from "effect/unstable/cli";
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";

import { DEVELOPMENT_ICON_OVERRIDES, PUBLISH_ICON_OVERRIDES } from "../../../scripts/lib/brand-assets.ts";
import { resolveCatalogDependencies } from "../../../scripts/lib/resolve-catalog.ts";
import rootPackageJson from "../../../package.json" with { type: "json" };
import serverPackageJson from "../package.json" with { type: "json" };
Expand All @@ -31,6 +32,84 @@ const runCommand = Effect.fn("runCommand")(function* (command: ChildProcess.Comm
}
});

interface PublishIconBackup {
readonly targetPath: string;
readonly backupPath: string;
}

const applyPublishIconOverrides = Effect.fn("applyPublishIconOverrides")(function* (
repoRoot: string,
serverDir: string,
) {
const path = yield* Path.Path;
const fs = yield* FileSystem.FileSystem;
const backups: PublishIconBackup[] = [];

for (const override of PUBLISH_ICON_OVERRIDES) {
const sourcePath = path.join(repoRoot, override.sourceRelativePath);
const targetPath = path.join(serverDir, override.targetRelativePath);
const backupPath = `${targetPath}.publish-bak`;

if (!(yield* fs.exists(sourcePath))) {
return yield* new CliError({
message: `Missing publish icon source: ${sourcePath}`,
});
}
if (!(yield* fs.exists(targetPath))) {
return yield* new CliError({
message: `Missing publish icon target: ${targetPath}. Run the build subcommand first.`,
});
}

yield* fs.copyFile(targetPath, backupPath);
yield* fs.copyFile(sourcePath, targetPath);
backups.push({ targetPath, backupPath });
}

yield* Effect.log("[cli] Applied publish icon overrides to dist/client");
return backups as ReadonlyArray<PublishIconBackup>;
});

const restorePublishIconOverrides = Effect.fn("restorePublishIconOverrides")(function* (
backups: ReadonlyArray<PublishIconBackup>,
) {
const fs = yield* FileSystem.FileSystem;
for (const backup of backups) {
if (!(yield* fs.exists(backup.backupPath))) {
continue;
}
yield* fs.rename(backup.backupPath, backup.targetPath);
}
});

const applyDevelopmentIconOverrides = Effect.fn("applyDevelopmentIconOverrides")(function* (
repoRoot: string,
serverDir: string,
) {
const path = yield* Path.Path;
const fs = yield* FileSystem.FileSystem;

for (const override of DEVELOPMENT_ICON_OVERRIDES) {
const sourcePath = path.join(repoRoot, override.sourceRelativePath);
const targetPath = path.join(serverDir, override.targetRelativePath);

if (!(yield* fs.exists(sourcePath))) {
return yield* new CliError({
message: `Missing development icon source: ${sourcePath}`,
});
}
if (!(yield* fs.exists(targetPath))) {
return yield* new CliError({
message: `Missing development icon target: ${targetPath}. Build web first.`,
});
}

yield* fs.copyFile(sourcePath, targetPath);
}

yield* Effect.log("[cli] Applied development icon overrides to dist/client");
});

// ---------------------------------------------------------------------------
// build subcommand
// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -61,6 +140,7 @@ const buildCmd = Command.make(

if (yield* fs.exists(webDist)) {
yield* fs.copy(webDist, clientTarget);
yield* applyDevelopmentIconOverrides(repoRoot, serverDir);
yield* Effect.log("[cli] Bundled web app into dist/client");
} else {
yield* Effect.logWarning("[cli] Web dist not found — skipping client bundle.");
Expand Down Expand Up @@ -104,10 +184,8 @@ const publishCmd = Command.make(
yield* Effect.acquireUseRelease(
// Acquire: backup package.json, resolve catalog: deps, strip devDependencies/scripts
Effect.gen(function* () {
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Resolved
const original = yield* fs.readFileString(packageJsonPath);
yield* fs.writeFileString(backupPath, original);

// Build package.json for publish
// Resolve catalog dependencies before any file mutations. If this throws,
// acquire fails and no release hook runs, so filesystem must still be untouched.
const version = Option.getOrElse(config.appVersion, () => serverPackageJson.version);
const pkg = {
name: serverPackageJson.name,
Expand All @@ -120,15 +198,19 @@ const publishCmd = Command.make(
dependencies: serverPackageJson.dependencies as Record<string, unknown>,
};

// Resolve catalog: entries in production dependencies
pkg.dependencies = resolveCatalogDependencies(
pkg.dependencies,
rootPackageJson.workspaces.catalog,
"apps/server dependencies",
);

const original = yield* fs.readFileString(packageJsonPath);
yield* fs.writeFileString(backupPath, original);
yield* fs.writeFileString(packageJsonPath, `${JSON.stringify(pkg, null, 2)}\n`);
yield* Effect.log("[cli] Resolved package.json for publish");

const iconBackups = yield* applyPublishIconOverrides(repoRoot, serverDir);
return { iconBackups };
}),
// Use: npm publish
() =>
Expand All @@ -147,8 +229,15 @@ const publishCmd = Command.make(
);
}),
// Release: restore
() =>
(resource: { readonly iconBackups: ReadonlyArray<PublishIconBackup> }) =>
Effect.gen(function* () {
yield* restorePublishIconOverrides(resource.iconBackups).pipe(
Effect.catch((error) =>
Effect.logError(
`[cli] Failed to restore publish icon overrides: ${String(error)}`,
),
),
);
yield* fs.rename(backupPath, packageJsonPath);
if (config.verbose) yield* Effect.log("[cli] Restored original package.json");
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ function createProviderServiceHarness(
listSessions,
getCapabilities: () => Effect.succeed({ sessionModelSwitch: "in-session" }),
rollbackConversation,
stopAll: () => Effect.void,
streamEvents: Stream.fromPubSub(runtimeEventPubSub),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ describe("ProviderCommandReactor", () => {
sessionModelSwitch: provider === "codex" ? "in-session" : "in-session",
}),
rollbackConversation: () => unsupported(),
stopAll: () => Effect.void,
streamEvents: Stream.fromPubSub(runtimeEventPubSub),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ function createProviderServiceHarness() {
listSessions: () => Effect.succeed([]),
getCapabilities: () => Effect.succeed({ sessionModelSwitch: "in-session" }),
rollbackConversation: () => unsupported(),
stopAll: () => Effect.void,
streamEvents: Stream.fromPubSub(runtimeEventPubSub),
};

Expand Down
19 changes: 3 additions & 16 deletions apps/server/src/provider/Layers/ProviderService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,6 @@ it.effect(
});
}).pipe(Effect.provide(firstProviderLayer));

yield* Effect.gen(function* () {
const provider = yield* ProviderService;
yield* provider.stopAll();
}).pipe(Effect.provide(firstProviderLayer));

const persistedAfterStopAll = yield* Effect.gen(function* () {
const repository = yield* ProviderSessionRuntimeRepository;
return yield* repository.getByThreadId({ threadId: startedSession.threadId });
Expand Down Expand Up @@ -549,7 +544,7 @@ routing.layer("ProviderServiceLive routing", (it) => {
runtimeMode: "full-access",
});

yield* provider.stopAll();
yield* routing.codex.stopAll();
routing.codex.startSession.mockClear();
routing.codex.sendTurn.mockClear();

Expand Down Expand Up @@ -578,7 +573,7 @@ routing.layer("ProviderServiceLive routing", (it) => {
}),
);

it.effect("stops all sessions and clears adapter runtime", () =>
it.effect("lists no sessions after adapter runtime clears", () =>
Effect.gen(function* () {
const provider = yield* ProviderService;

Expand All @@ -593,7 +588,7 @@ routing.layer("ProviderServiceLive routing", (it) => {
runtimeMode: "full-access",
});

yield* provider.stopAll();
yield* routing.codex.stopAll();

const remaining = yield* provider.listSessions();
assert.equal(remaining.length, 0);
Expand Down Expand Up @@ -641,14 +636,6 @@ routing.layer("ProviderServiceLive routing", (it) => {
}
}

yield* provider.stopAll();
const stoppedRuntime = yield* runtimeRepository.getByThreadId({
threadId: session.threadId,
});
assert.equal(Option.isSome(stoppedRuntime), true);
if (Option.isSome(stoppedRuntime)) {
assert.equal(stoppedRuntime.value.status, "stopped");
}
}),
);
});
Expand Down
9 changes: 7 additions & 2 deletions apps/server/src/provider/Layers/ProviderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ const makeProviderService = (options?: ProviderServiceLiveOptions) =>
});
});

const stopAll: ProviderServiceShape["stopAll"] = () =>
const runStopAll = () =>
Effect.gen(function* () {
const threadIds = yield* directory.listThreadIds();
yield* Effect.forEach(adapters, (adapter) => adapter.stopAll()).pipe(Effect.asVoid);
Expand All @@ -497,6 +497,12 @@ const makeProviderService = (options?: ProviderServiceLiveOptions) =>
yield* analytics.flush;
});

yield* Effect.addFinalizer(() =>
Effect.catch(runStopAll(), (cause) =>
Effect.logWarning("failed to stop provider service", { cause }),
),
);

return {
startSession,
sendTurn,
Expand All @@ -507,7 +513,6 @@ const makeProviderService = (options?: ProviderServiceLiveOptions) =>
listSessions,
getCapabilities,
rollbackConversation,
stopAll,
streamEvents: Stream.fromPubSub(runtimeEventPubSub),
} satisfies ProviderServiceShape;
});
Expand Down
10 changes: 0 additions & 10 deletions apps/server/src/provider/Services/ProviderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,6 @@ export interface ProviderServiceShape {
readonly numTurns: number;
}) => Effect.Effect<void, ProviderServiceError>;

/**
* Stop all active provider sessions.
*
* Persisted session bindings remain so stale sessions can be resumed after
* process restart.
*
* Runtime alias mappings are cleared as part of shutdown.
*/
readonly stopAll: () => Effect.Effect<void, ProviderServiceError>;

/**
* Canonical provider runtime event stream.
*
Expand Down
9 changes: 3 additions & 6 deletions apps/server/src/serverLogger.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import fs from "node:fs";
import path from "node:path";

import { Effect, Logger, Option } from "effect";
import { Effect, Logger } from "effect";
import * as Layer from "effect/Layer";

import { ServerConfig } from "./config";

export const ServerLoggerLive = Effect.gen(function* () {
const config = yield* Effect.serviceOption(ServerConfig);
if (Option.isNone(config)) {
return Logger.layer([Logger.defaultLogger]);
}
const config = yield* ServerConfig;

const logDir = path.join(config.value.stateDir, "logs");
const logDir = path.join(config.stateDir, "logs");
const logPath = path.join(logDir, "server.log");

yield* Effect.sync(() => {
Expand Down
1 change: 0 additions & 1 deletion apps/server/src/wsServer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,6 @@ describe("WebSocket Server", () => {
listSessions: () => Effect.succeed([]),
getCapabilities: () => Effect.succeed({ sessionModelSwitch: "in-session" }),
rollbackConversation: () => unsupported(),
stopAll: () => Effect.void,
streamEvents: Stream.fromPubSub(runtimeEventPubSub),
};
const providerLayer = Layer.succeed(ProviderService, providerService);
Expand Down
6 changes: 0 additions & 6 deletions apps/server/src/wsServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,6 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
const orchestrationEngine = yield* OrchestrationEngineService;
const projectionReadModelQuery = yield* ProjectionSnapshotQuery;
const checkpointDiffQuery = yield* CheckpointDiffQuery;
const liveProviderService = yield* ProviderService;
const orchestrationReactor = yield* OrchestrationReactor;
const { openInEditor } = yield* Open;

Expand Down Expand Up @@ -660,11 +659,6 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
}

const runPromise = yield* Effect.map(Effect.services<never>(), Effect.runPromiseWith);
yield* Effect.addFinalizer(() =>
Effect.catch(liveProviderService.stopAll(), (cause) =>
Effect.logWarning("failed to stop provider service", { cause }),
),
);

const unsubscribeTerminalEvents = yield* terminalManager.subscribe(
(event) => void Effect.runPromise(onTerminalEvent(event)),
Expand Down
Binary file modified apps/web/public/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified apps/web/public/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified apps/web/public/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified apps/web/public/favicon.ico
Binary file not shown.
4 changes: 0 additions & 4 deletions apps/web/public/favicon.svg

This file was deleted.

Binary file removed assets/T3 Code [email protected]
Binary file not shown.
4 changes: 0 additions & 4 deletions assets/T3 Code logo.svg

This file was deleted.

Binary file removed assets/T3 Code [email protected]
Binary file not shown.
Binary file removed assets/T3 Code [email protected]
Binary file not shown.
Binary file removed assets/T3 [email protected]
Binary file not shown.
Binary file added assets/dev/blueprint-ios-1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added assets/dev/blueprint-universal-1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dev/blueprint-web-apple-touch-180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dev/blueprint-web-favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dev/blueprint-web-favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dev/blueprint-web-favicon.ico
Binary file not shown.
Binary file added assets/dev/blueprint-windows.ico
Binary file not shown.
Binary file removed assets/logo-1024.png
Binary file not shown.
Binary file removed assets/macos-icon-1024.png
Binary file not shown.
Binary file added assets/prod/black-ios-1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added assets/prod/t3-black-web-apple-touch-180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/prod/t3-black-web-favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/prod/t3-black-web-favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/prod/t3-black-web-favicon.ico
Binary file not shown.
Binary file added assets/prod/t3-black-windows.ico
Binary file not shown.
Loading