Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
8e5c244
Refactor web store into atomic slices
justsomelegs Apr 3, 2026
0737ff4
Fix project recreation keys and update web tests
justsomelegs Apr 3, 2026
5e009d6
Merge upstream/main into web/atomic-store-refactor
justsomelegs Apr 5, 2026
a5bd205
Merge remote-tracking branch 'upstream/main' into HEAD
justsomelegs Apr 5, 2026
6ff8f71
fix(web): stabilize browser test store selectors
justsomelegs Apr 5, 2026
f108f22
Merge branch 'main' into web/atomic-store-refactor
justsomelegs Apr 6, 2026
d20a403
Merge branch 'main' into web/atomic-store-refactor
justsomelegs Apr 6, 2026
53b572f
Merge branch 'main' into web/atomic-store-refactor
justsomelegs Apr 6, 2026
8ccfe3e
Surface environment and repository identity metadata
juliusmarminge Apr 5, 2026
d1437f1
Include client-runtime in release smoke checks
juliusmarminge Apr 5, 2026
deb215e
Treat explicit null environments distinctly
juliusmarminge Apr 6, 2026
a16ee82
Support nested repo remotes and late URL resolution
juliusmarminge Apr 6, 2026
40ab9d9
Require environment IDs in web state sync
juliusmarminge Apr 6, 2026
97ba9f9
Preserve remote scoped state across snapshot syncs
juliusmarminge Apr 6, 2026
74250e9
non empty
juliusmarminge Apr 6, 2026
240438d
fine
juliusmarminge Apr 6, 2026
938f3d6
Cache repository identity lookups by TTL
juliusmarminge Apr 6, 2026
fc2de81
move
juliusmarminge Apr 6, 2026
403ac96
kewl
juliusmarminge Apr 6, 2026
70d3731
Handle ports in remote URL normalization
juliusmarminge Apr 6, 2026
babe73c
Handle empty server URLs and stale sidebar threads
juliusmarminge Apr 6, 2026
54f905c
Adapt multi-environment store to atomic refactor base
juliusmarminge Apr 6, 2026
010f452
Scope thread state by environment
juliusmarminge Apr 7, 2026
24ac444
Add draft routes for logical projects
juliusmarminge Apr 7, 2026
46c3251
Scope web native API and git queries by environment
juliusmarminge Apr 7, 2026
5e27490
Rename native API wrappers to local and environment APIs
juliusmarminge Apr 7, 2026
29b6385
Split local and environment API helpers
juliusmarminge Apr 7, 2026
580fe19
Canonicalize promoted drafts to server thread routes
juliusmarminge Apr 7, 2026
aab603f
Fix server environment test config generation
juliusmarminge Apr 7, 2026
74abf72
Scope bootstrap state to environment keys
juliusmarminge Apr 7, 2026
583f97c
Handle promoted drafts across scoped thread refs
juliusmarminge Apr 7, 2026
3e7db1d
Fix lint suppression comment syntax
juliusmarminge Apr 7, 2026
29f0cbb
Refactor draft routing to use stable draft IDs
juliusmarminge Apr 7, 2026
ee72797
render optimization 1
juliusmarminge Apr 7, 2026
8f76546
render optimization 2
juliusmarminge Apr 7, 2026
bb095b8
render optimization 3
juliusmarminge Apr 7, 2026
8fc0a84
render optimization 4
juliusmarminge Apr 7, 2026
339b035
redner optimization 5
juliusmarminge Apr 7, 2026
5770c74
render optimization 6
juliusmarminge Apr 7, 2026
2fb8b75
cleanup
juliusmarminge Apr 7, 2026
216a587
Type sidebar thread status props
juliusmarminge Apr 7, 2026
3696cb2
fix: replace redundant serverThread.id check with direct targetThread…
cursoragent Apr 7, 2026
3d2973a
Guard composer traits UI without a thread target
juliusmarminge Apr 7, 2026
5294bfd
fix: replace redundant serverThread.id check with direct targetThread…
cursor[bot] Apr 7, 2026
1c843f4
fix: memoize scopeThreadRef in BranchToolbar to stabilize useMemo dep…
cursoragent Apr 7, 2026
652aa66
fix: memoize scopeThreadRef in BranchToolbar to stabilize useMemo dep…
cursor[bot] Apr 7, 2026
bc35b85
Guard composer draft unload flush in non-DOM environments
juliusmarminge Apr 7, 2026
f18b15a
fix: remove self-provided RepositoryIdentityResolverLive from snapsho…
cursoragent Apr 7, 2026
b49a8a4
fix: remove self-provided RepositoryIdentityResolverLive from snapsho…
cursor[bot] Apr 7, 2026
77dc225
Reduce sidebar shortcut recomputation
juliusmarminge Apr 7, 2026
40b804c
fix: move repository identity resolution outside DB transaction in ge…
cursoragent Apr 7, 2026
e718b0d
Stabilize Git actions toast tests
juliusmarminge Apr 7, 2026
c1e7216
fix: move repository identity resolution outside DB transaction in ge…
cursor[bot] Apr 7, 2026
18b9087
fix: fall back to threadRef when draftId is absent in BranchToolbar
cursoragent Apr 7, 2026
6a24126
Merge remote-tracking branch 'origin/main' into ship-1765
juliusmarminge Apr 9, 2026
3481ed8
Fix pending user input option selection
juliusmarminge Apr 9, 2026
78aadd2
Stabilize pending input auto-advance callback
juliusmarminge Apr 9, 2026
aa92532
Use effect events for pending input option selection
juliusmarminge Apr 9, 2026
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
9 changes: 9 additions & 0 deletions apps/desktop/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const UPDATE_DOWNLOAD_CHANNEL = "desktop:update-download";
const UPDATE_INSTALL_CHANNEL = "desktop:update-install";
const UPDATE_CHECK_CHANNEL = "desktop:update-check";
const GET_WS_URL_CHANNEL = "desktop:get-ws-url";
const GET_LOCAL_ENVIRONMENT_BOOTSTRAP_CHANNEL = "desktop:get-local-environment-bootstrap";
const BASE_DIR = process.env.T3CODE_HOME?.trim() || Path.join(OS.homedir(), ".t3");
const STATE_DIR = Path.join(BASE_DIR, "userdata");
const DESKTOP_SCHEME = "t3";
Expand Down Expand Up @@ -1172,6 +1173,14 @@ function registerIpcHandlers(): void {
event.returnValue = backendWsUrl;
});

ipcMain.removeAllListeners(GET_LOCAL_ENVIRONMENT_BOOTSTRAP_CHANNEL);
ipcMain.on(GET_LOCAL_ENVIRONMENT_BOOTSTRAP_CHANNEL, (event) => {
event.returnValue = {
label: "Local environment",
wsUrl: backendWsUrl || null,
} as const;
});

ipcMain.removeHandler(PICK_FOLDER_CHANNEL);
ipcMain.handle(PICK_FOLDER_CHANNEL, async () => {
const owner = BrowserWindow.getFocusedWindow() ?? mainWindow;
Expand Down
8 changes: 8 additions & 0 deletions apps/desktop/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@ const UPDATE_CHECK_CHANNEL = "desktop:update-check";
const UPDATE_DOWNLOAD_CHANNEL = "desktop:update-download";
const UPDATE_INSTALL_CHANNEL = "desktop:update-install";
const GET_WS_URL_CHANNEL = "desktop:get-ws-url";
const GET_LOCAL_ENVIRONMENT_BOOTSTRAP_CHANNEL = "desktop:get-local-environment-bootstrap";

contextBridge.exposeInMainWorld("desktopBridge", {
getWsUrl: () => {
const result = ipcRenderer.sendSync(GET_WS_URL_CHANNEL);
return typeof result === "string" ? result : null;
},
getLocalEnvironmentBootstrap: () => {
const result = ipcRenderer.sendSync(GET_LOCAL_ENVIRONMENT_BOOTSTRAP_CHANNEL);
if (typeof result !== "object" || result === null) {
return null;
}
return result as ReturnType<DesktopBridge["getLocalEnvironmentBootstrap"]>;
},
pickFolder: () => ipcRenderer.invoke(PICK_FOLDER_CHANNEL),
confirm: (message) => ipcRenderer.invoke(CONFIRM_CHANNEL, message),
setTheme: (theme) => ipcRenderer.invoke(SET_THEME_CHANNEL, theme),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { CodexAdapter } from "../src/provider/Services/CodexAdapter.ts";
import { ProviderService } from "../src/provider/Services/ProviderService.ts";
import { AnalyticsService } from "../src/telemetry/Services/AnalyticsService.ts";
import { CheckpointReactorLive } from "../src/orchestration/Layers/CheckpointReactor.ts";
import { RepositoryIdentityResolverLive } from "../src/project/Layers/RepositoryIdentityResolver.ts";
import { OrchestrationEngineLive } from "../src/orchestration/Layers/OrchestrationEngine.ts";
import { OrchestrationProjectionPipelineLive } from "../src/orchestration/Layers/ProjectionPipeline.ts";
import { OrchestrationProjectionSnapshotQueryLive } from "../src/orchestration/Layers/ProjectionSnapshotQuery.ts";
Expand Down Expand Up @@ -338,6 +339,7 @@ export const makeOrchestrationIntegrationHarness = (
Layer.provideMerge(runtimeServicesLayer),
Layer.provideMerge(orchestrationReactorLayer),
Layer.provide(persistenceLayer),
Layer.provideMerge(RepositoryIdentityResolverLive),
Layer.provideMerge(ServerSettingsService.layerTest()),
Layer.provideMerge(ServerConfig.layerTest(workspaceDir, rootDir)),
Layer.provideMerge(NodeServices.layer),
Expand Down
2 changes: 2 additions & 0 deletions apps/server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface ServerDerivedPaths {
readonly providerEventLogPath: string;
readonly terminalLogsDir: string;
readonly anonymousIdPath: string;
readonly environmentIdPath: string;
}

/**
Expand Down Expand Up @@ -83,6 +84,7 @@ export const deriveServerPaths = Effect.fn(function* (
providerEventLogPath: join(providerLogsDir, "events.log"),
terminalLogsDir: join(logsDir, "terminals"),
anonymousIdPath: join(stateDir, "anonymous-id"),
environmentIdPath: join(stateDir, "environment-id"),
};
});

Expand Down
124 changes: 124 additions & 0 deletions apps/server/src/environment/Layers/ServerEnvironment.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import * as nodePath from "node:path";
import * as NodeServices from "@effect/platform-node/NodeServices";
import { expect, it } from "@effect/vitest";
import { Effect, Exit, FileSystem, Layer, PlatformError } from "effect";

import { deriveServerPaths, ServerConfig, type ServerConfigShape } from "../../config.ts";
import { ServerEnvironment } from "../Services/ServerEnvironment.ts";
import { ServerEnvironmentLive } from "./ServerEnvironment.ts";

const makeServerEnvironmentLayer = (baseDir: string) =>
ServerEnvironmentLive.pipe(Layer.provide(ServerConfig.layerTest(process.cwd(), baseDir)));

const makeServerConfig = Effect.fn(function* (baseDir: string) {
const derivedPaths = yield* deriveServerPaths(baseDir, undefined);

return {
...derivedPaths,
logLevel: "Error",
traceMinLevel: "Info",
traceTimingEnabled: true,
traceBatchWindowMs: 200,
traceMaxBytes: 10 * 1024 * 1024,
traceMaxFiles: 10,
otlpTracesUrl: undefined,
otlpMetricsUrl: undefined,
otlpExportIntervalMs: 10_000,
otlpServiceName: "t3-server",
cwd: process.cwd(),
baseDir,
mode: "web",
autoBootstrapProjectFromCwd: false,
logWebSocketEvents: false,
port: 0,
host: undefined,
authToken: undefined,
staticDir: undefined,
devUrl: undefined,
noBrowser: false,
} satisfies ServerConfigShape;
});

it.layer(NodeServices.layer)("ServerEnvironmentLive", (it) => {
it.effect("persists the environment id across service restarts", () =>
Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
const baseDir = yield* fileSystem.makeTempDirectoryScoped({
prefix: "t3-server-environment-test-",
});

const first = yield* Effect.gen(function* () {
const serverEnvironment = yield* ServerEnvironment;
return yield* serverEnvironment.getDescriptor;
}).pipe(Effect.provide(makeServerEnvironmentLayer(baseDir)));
const second = yield* Effect.gen(function* () {
const serverEnvironment = yield* ServerEnvironment;
return yield* serverEnvironment.getDescriptor;
}).pipe(Effect.provide(makeServerEnvironmentLayer(baseDir)));

expect(first.environmentId).toBe(second.environmentId);
expect(second.capabilities.repositoryIdentity).toBe(true);
}),
);

it.effect("fails instead of overwriting a persisted id when reading the file errors", () =>
Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
const baseDir = yield* fileSystem.makeTempDirectoryScoped({
prefix: "t3-server-environment-read-error-test-",
});
const serverConfig = yield* makeServerConfig(baseDir);
const environmentIdPath = serverConfig.environmentIdPath;
yield* fileSystem.makeDirectory(nodePath.dirname(environmentIdPath), { recursive: true });
yield* fileSystem.writeFileString(environmentIdPath, "persisted-environment-id\n");
const writeAttempts: string[] = [];
const failingFileSystemLayer = FileSystem.layerNoop({
exists: (path) => Effect.succeed(path === environmentIdPath),
readFileString: (path) =>
path === environmentIdPath
? Effect.fail(
PlatformError.systemError({
_tag: "PermissionDenied",
module: "FileSystem",
method: "readFileString",
description: "permission denied",
pathOrDescriptor: path,
}),
)
: Effect.fail(
PlatformError.systemError({
_tag: "NotFound",
module: "FileSystem",
method: "readFileString",
description: "not found",
pathOrDescriptor: path,
}),
),
writeFileString: (path) => {
writeAttempts.push(path);
return Effect.void;
},
});

const exit = yield* Effect.gen(function* () {
const serverEnvironment = yield* ServerEnvironment;
return yield* serverEnvironment.getDescriptor;
}).pipe(
Effect.provide(
ServerEnvironmentLive.pipe(
Layer.provide(
Layer.merge(Layer.succeed(ServerConfig, serverConfig), failingFileSystemLayer),
),
),
),
Effect.exit,
);

expect(Exit.isFailure(exit)).toBe(true);
expect(writeAttempts).toEqual([]);
expect(yield* fileSystem.readFileString(environmentIdPath)).toBe(
"persisted-environment-id\n",
);
}),
);
});
94 changes: 94 additions & 0 deletions apps/server/src/environment/Layers/ServerEnvironment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { EnvironmentId, type ExecutionEnvironmentDescriptor } from "@t3tools/contracts";
import { Effect, FileSystem, Layer, Path, Random } from "effect";

import { ServerConfig } from "../../config.ts";
import { ServerEnvironment, type ServerEnvironmentShape } from "../Services/ServerEnvironment.ts";
import { version } from "../../../package.json" with { type: "json" };

function platformOs(): ExecutionEnvironmentDescriptor["platform"]["os"] {
switch (process.platform) {
case "darwin":
return "darwin";
case "linux":
return "linux";
case "win32":
return "windows";
default:
return "unknown";
}
}

function platformArch(): ExecutionEnvironmentDescriptor["platform"]["arch"] {
switch (process.arch) {
case "arm64":
return "arm64";
case "x64":
return "x64";
default:
return "other";
}
}

export const makeServerEnvironment = Effect.fn("makeServerEnvironment")(function* () {
const fileSystem = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const serverConfig = yield* ServerConfig;

const readPersistedEnvironmentId = Effect.gen(function* () {
const exists = yield* fileSystem
.exists(serverConfig.environmentIdPath)
.pipe(Effect.orElseSucceed(() => false));
if (!exists) {
return null;
}

const raw = yield* fileSystem
.readFileString(serverConfig.environmentIdPath)
.pipe(Effect.map((value) => value.trim()));

return raw.length > 0 ? raw : null;
});

const persistEnvironmentId = (value: string) =>
fileSystem.writeFileString(serverConfig.environmentIdPath, `${value}\n`);

const environmentIdRaw = yield* Effect.gen(function* () {
const persisted = yield* readPersistedEnvironmentId;
if (persisted) {
return persisted;
}

const generated = yield* Random.nextUUIDv4;
yield* persistEnvironmentId(generated);
return generated;
});

const environmentId = EnvironmentId.makeUnsafe(environmentIdRaw);
const cwdBaseName = path.basename(serverConfig.cwd).trim();
const label =
serverConfig.mode === "desktop"
? "Local environment"
: cwdBaseName.length > 0
? cwdBaseName
: "T3 environment";

const descriptor: ExecutionEnvironmentDescriptor = {
environmentId,
label,
platform: {
os: platformOs(),
arch: platformArch(),
},
serverVersion: version,
capabilities: {
repositoryIdentity: true,
},
};

return {
getEnvironmentId: Effect.succeed(environmentId),
getDescriptor: Effect.succeed(descriptor),
} satisfies ServerEnvironmentShape;
});

export const ServerEnvironmentLive = Layer.effect(ServerEnvironment, makeServerEnvironment());
13 changes: 13 additions & 0 deletions apps/server/src/environment/Services/ServerEnvironment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { EnvironmentId, ExecutionEnvironmentDescriptor } from "@t3tools/contracts";
import { ServiceMap } from "effect";
import type { Effect } from "effect";

export interface ServerEnvironmentShape {
readonly getEnvironmentId: Effect.Effect<EnvironmentId>;
readonly getDescriptor: Effect.Effect<ExecutionEnvironmentDescriptor>;
}

export class ServerEnvironment extends ServiceMap.Service<
ServerEnvironment,
ServerEnvironmentShape
>()("t3/environment/Services/ServerEnvironment") {}
6 changes: 3 additions & 3 deletions apps/server/src/git/Layers/GitManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
"pr list --head jasonLaster:statemachine --state all --limit 20 --json number,title,url,baseRefName,headRefName,state,mergedAt,updatedAt,isCrossRepository,headRepository,headRepositoryOwner",
);
}),
12_000,
20_000,
);

it.effect(
Expand Down Expand Up @@ -962,7 +962,7 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
),
).toBe(false);
}),
12_000,
20_000,
);

it.effect("status returns merged PR state when latest PR was merged", () =>
Expand Down Expand Up @@ -1685,7 +1685,7 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
false,
);
}),
12_000,
20_000,
);

it.effect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
import { CheckpointStoreLive } from "../../checkpointing/Layers/CheckpointStore.ts";
import { CheckpointStore } from "../../checkpointing/Services/CheckpointStore.ts";
import { GitCoreLive } from "../../git/Layers/GitCore.ts";
import { RepositoryIdentityResolverLive } from "../../project/Layers/RepositoryIdentityResolver.ts";
import { CheckpointReactorLive } from "./CheckpointReactor.ts";
import { OrchestrationEngineLive } from "./OrchestrationEngine.ts";
import { OrchestrationProjectionPipelineLive } from "./ProjectionPipeline.ts";
Expand Down Expand Up @@ -256,6 +257,7 @@ describe("CheckpointReactor", () => {
Layer.provide(OrchestrationProjectionPipelineLive),
Layer.provide(OrchestrationEventStoreLive),
Layer.provide(OrchestrationCommandReceiptRepositoryLive),
Layer.provide(RepositoryIdentityResolverLive),
Layer.provide(SqlitePersistenceMemory),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
OrchestrationEventStore,
type OrchestrationEventStoreShape,
} from "../../persistence/Services/OrchestrationEventStore.ts";
import { RepositoryIdentityResolverLive } from "../../project/Layers/RepositoryIdentityResolver.ts";
import { OrchestrationEngineLive } from "./OrchestrationEngine.ts";
import { OrchestrationProjectionPipelineLive } from "./ProjectionPipeline.ts";
import { OrchestrationProjectionSnapshotQueryLive } from "./ProjectionSnapshotQuery.ts";
Expand All @@ -45,6 +46,7 @@ async function createOrchestrationSystem() {
Layer.provide(OrchestrationProjectionPipelineLive),
Layer.provide(OrchestrationEventStoreLive),
Layer.provide(OrchestrationCommandReceiptRepositoryLive),
Layer.provide(RepositoryIdentityResolverLive),
Layer.provide(SqlitePersistenceMemory),
Layer.provideMerge(ServerConfigLayer),
Layer.provideMerge(NodeServices.layer),
Expand Down Expand Up @@ -623,6 +625,7 @@ describe("OrchestrationEngine", () => {
Layer.provide(OrchestrationProjectionPipelineLive),
Layer.provide(Layer.succeed(OrchestrationEventStore, flakyStore)),
Layer.provide(OrchestrationCommandReceiptRepositoryLive),
Layer.provide(RepositoryIdentityResolverLive),
Layer.provide(SqlitePersistenceMemory),
Layer.provideMerge(ServerConfigLayer),
Layer.provideMerge(NodeServices.layer),
Expand Down Expand Up @@ -719,6 +722,7 @@ describe("OrchestrationEngine", () => {
Layer.provide(Layer.succeed(OrchestrationProjectionPipeline, flakyProjectionPipeline)),
Layer.provide(OrchestrationEventStoreLive),
Layer.provide(OrchestrationCommandReceiptRepositoryLive),
Layer.provide(RepositoryIdentityResolverLive),
Layer.provide(SqlitePersistenceMemory),
),
);
Expand Down Expand Up @@ -861,6 +865,7 @@ describe("OrchestrationEngine", () => {
Layer.provide(Layer.succeed(OrchestrationProjectionPipeline, flakyProjectionPipeline)),
Layer.provide(Layer.succeed(OrchestrationEventStore, nonTransactionalStore)),
Layer.provide(OrchestrationCommandReceiptRepositoryLive),
Layer.provide(RepositoryIdentityResolverLive),
Layer.provide(SqlitePersistenceMemory),
),
);
Expand Down
Loading
Loading