perf(desktop): reuse the prepared shell environment in the local backend (#17384)
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
1 parent
aacefcd7e9
commit
03bd839554
11 files changed
+304
-66
No files matched your search
@@ -26,6 +26,21 @@ import { resolveServerConfig } from "./config.ts";
|
||||
const deriveExplicitServerPaths = (baseDir: string, devUrl: URL | undefined) =>
|
||||
deriveServerPaths(baseDir, devUrl, { baseDirIsExplicit: true });
|
||||
|
||||
const minimalDesktopFlags = (baseDir: string) => ({
|
||||
mode: Option.some("desktop" as const),
|
||||
port: Option.some(4888),
|
||||
host: Option.none<string>(),
|
||||
baseDir: Option.some(baseDir),
|
||||
cwd: Option.none<string>(),
|
||||
devUrl: Option.none<URL>(),
|
||||
noBrowser: Option.none<boolean>(),
|
||||
bootstrapFd: Option.none<number>(),
|
||||
autoBootstrapProjectFromCwd: Option.none<boolean>(),
|
||||
logWebSocketEvents: Option.none<boolean>(),
|
||||
tailscaleServeEnabled: Option.none<boolean>(),
|
||||
tailscaleServePort: Option.none<number>(),
|
||||
});
|
||||
|
||||
const encodeDesktopBootstrap = Schema.encodeEffect(Schema.fromJsonString(DesktopBackendBootstrap));
|
||||
const encodeUnknownJson = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));
|
||||
|
||||
@@ -515,6 +530,36 @@ it.layer(NodeServices.layer)("cli config resolution", (it) => {
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("carries the desktop's shell environment handoff only when the envelope sets it", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-cli-config-shell-env-" });
|
||||
const resolveWith = Effect.fn(function* (overrides: Partial<DesktopBackendBootstrapValue>) {
|
||||
const fd = yield* openBootstrapFd(makeDesktopBootstrap(overrides));
|
||||
return yield* resolveServerConfig(
|
||||
{
|
||||
...minimalDesktopFlags(baseDir),
|
||||
bootstrapFd: Option.some(fd),
|
||||
},
|
||||
Option.none(),
|
||||
).pipe(
|
||||
Effect.provide(
|
||||
Layer.mergeAll(
|
||||
ConfigProvider.layer(ConfigProvider.fromEnv({ env: {} })),
|
||||
NetService.layer,
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
assert.equal((yield* resolveWith({})).shellEnvironmentPrepared, undefined);
|
||||
assert.equal(
|
||||
(yield* resolveWith({ shellEnvironmentPrepared: true })).shellEnvironmentPrepared,
|
||||
true,
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("creates derived runtime directories during config resolution", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
|
||||
@@ -360,6 +360,7 @@ export const resolveServerConfig = (
|
||||
);
|
||||
const desktopBootstrapToken = bootstrap?.desktopBootstrapToken;
|
||||
const desktopBootstrapSecret = bootstrap?.desktopBootstrapSecret;
|
||||
const shellEnvironmentPrepared = bootstrap?.shellEnvironmentPrepared;
|
||||
const desktopTelemetryFd = bootstrap?.desktopTelemetryFd;
|
||||
const desktopTelemetryControlFd = bootstrap?.desktopTelemetryControlFd;
|
||||
const desktopBrowserFd = bootstrap?.desktopBrowserFd;
|
||||
@@ -468,6 +469,7 @@ export const resolveServerConfig = (
|
||||
startupPresentation,
|
||||
desktopBootstrapToken,
|
||||
...(desktopBootstrapSecret === undefined ? {} : { desktopBootstrapSecret }),
|
||||
...(shellEnvironmentPrepared === undefined ? {} : { shellEnvironmentPrepared }),
|
||||
desktopTelemetryFd,
|
||||
desktopTelemetryControlFd,
|
||||
desktopBrowserFd,
|
||||
|
||||
Reference in new issue
Block a user