Skip to content

Commit a83b79d

Browse files
committed
merge: sync main into branch switch status improvement
2 parents 2036943 + 2b1021c commit a83b79d

61 files changed

Lines changed: 3003 additions & 374 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/desktop/scripts/main-process-bundle.test.mjs‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as NodeFSP from "node:fs/promises";
33
import * as NodeOS from "node:os";
44
import * as NodePath from "node:path";
55
import * as NodeVM from "node:vm";
6+
import * as NodeURL from "node:url";
67
import { build } from "vite-plus/pack";
78
import { assert, it } from "vite-plus/test";
89

@@ -114,18 +115,16 @@ it("loads the emitted packaged boot entry and backend cache preload", async () =
114115
const directory = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-desktop-boot-"));
115116
try {
116117
const entries = ["src/boot.ts", "src/compileCache.ts"];
117-
await NodeFSP.mkdir(NodePath.join(directory, "src"));
118-
await Promise.all(
119-
entries.map((entry) =>
120-
NodeFSP.copyFile(new URL(`../${entry}`, import.meta.url), NodePath.join(directory, entry)),
121-
),
122-
);
123118
assert.ok(Array.isArray(desktopConfig.pack));
124119
for (const packConfig of desktopConfig.pack) {
125120
if (!Array.isArray(packConfig.entry)) continue;
126121
if (!packConfig.entry.some((entry) => entries.includes(entry))) continue;
127122
await build({
128123
...packConfig,
124+
entry: packConfig.entry.map((entry) =>
125+
NodeURL.fileURLToPath(new URL(`../${entry}`, import.meta.url)),
126+
),
127+
outDir: NodePath.join(directory, "dist-electron"),
129128
config: false,
130129
cwd: directory,
131130
tsconfig: false,

‎apps/desktop/src/backend/DesktopBackendConfiguration.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as Layer from "effect/Layer";
88
import * as ManagedRuntime from "effect/ManagedRuntime";
99
import * as Option from "effect/Option";
1010
import * as Path from "effect/Path";
11+
import * as Stream from "effect/Stream";
1112
import { ChildProcessSpawner } from "effect/process";
1213

1314
import * as DesktopEnvironment from "../app/DesktopEnvironment.ts";
@@ -22,6 +23,8 @@ import * as DesktopWslServerTree from "../wsl/DesktopWslServerTree.ts";
2223
const layerShellEnvironment = (prepared = true) =>
2324
Layer.succeed(DesktopShellEnvironment.DesktopShellEnvironment, {
2425
installIntoProcess: Effect.succeed(prepared),
26+
awaitDiscovery: Effect.succeed(prepared),
27+
updates: Stream.empty,
2528
});
2629

2730
const layerBackendConfiguration = (prepared = true) =>
@@ -237,6 +240,7 @@ describe("DesktopBackendConfiguration", () => {
237240
assert.equal(first.cwd, environment.backendCwd);
238241
assert.equal(first.captureOutput, true);
239242
assert.equal(first.env.ELECTRON_RUN_AS_NODE, "1");
243+
assert.equal(first.env.T3CODE_DESKTOP_SHELL_DISCOVERY_PENDING, "1");
240244
assert.isUndefined(first.env.T3CODE_PORT);
241245
assert.isUndefined(first.env.T3CODE_MODE);
242246
assert.isUndefined(first.env.T3CODE_DESKTOP_LAN_HOST);

‎apps/desktop/src/backend/DesktopBackendConfiguration.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ const resolvePrimaryStartConfig = Effect.fn("desktop.backendConfiguration.resolv
532532
env: {
533533
...backendChildEnvPatch(),
534534
ELECTRON_RUN_AS_NODE: "1",
535+
T3CODE_DESKTOP_SHELL_DISCOVERY_PENDING: "1",
535536
T3CODE_CLI_PATH: Option.getOrUndefined(input.cliPath),
536537
},
537538
extendEnv: true,

‎apps/desktop/src/compileCache.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@
22
import * as NodeModule from "node:module";
33
import * as NodeOS from "node:os";
44
import * as NodePath from "node:path";
5+
import { enablePreparedServerCache } from "../../../scripts/lib/server-compile-cache.ts";
56

67
// Linux /tmp is shared; macOS and Windows temp dirs are per user.
78
// AppImage mounts change paths each launch, so Node's path-keyed cache would miss and accumulate copies.
89
try {
9-
if (!process.env.APPIMAGE) {
10+
if (!process.env.APPIMAGE || process.env.ELECTRON_RUN_AS_NODE === "1") {
1011
const cacheRoot =
1112
// oxlint-disable-next-line t3code/no-global-process-runtime -- Loads before any Effect runtime.
1213
process.platform === "linux"
1314
? process.env.XDG_CACHE_HOME || NodePath.join(NodeOS.homedir(), ".cache")
1415
: NodeOS.tmpdir();
15-
NodeModule.enableCompileCache(NodePath.join(cacheRoot, "t3code", "compile-cache"));
16+
const directory = NodePath.join(cacheRoot, "t3code", "compile-cache");
17+
const prepared =
18+
process.env.ELECTRON_RUN_AS_NODE === "1" &&
19+
enablePreparedServerCache(process.argv[1] ?? "", directory);
20+
if (!prepared && !process.env.APPIMAGE) {
21+
NodeModule.enableCompileCache(directory);
22+
}
1623
}
1724
} catch {}

‎apps/desktop/src/main.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ const layerDesktopAppActivation = DesktopAppActivation.layer.pipe(
186186
const layerDesktopBackend = DesktopBackendPool.layer.pipe(
187187
Layer.provideMerge(DesktopAppIdentity.layer),
188188
Layer.provideMerge(DesktopBackendConfiguration.layer),
189-
Layer.provideMerge(DesktopShellEnvironment.layer),
190189
Layer.provideMerge(DesktopWslEnvironment.layer),
191190
Layer.provideMerge(DesktopWslServerTree.layer),
192191
Layer.provideMerge(DesktopTelemetryPublisher.layer),
192+
Layer.provideMerge(DesktopShellEnvironment.layer),
193193
Layer.provideMerge(layerDesktopWindow),
194194
);
195195

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { generatePreparedServerCache } from "../../../scripts/lib/server-compile-cache.ts";

0 commit comments

Comments
 (0)