Skip to content

Commit 468c21a

Browse files
authored
Merge branch 'main' into fix/local-git-status-upstream
2 parents 696a3d4 + 012e4ec commit 468c21a

269 files changed

Lines changed: 7768 additions & 2530 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.

‎.github/actions/setup-ci-deps/action.yml‎

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,34 @@ runs:
1818
path: ~/.vite-plus
1919
key: vite-plus-home-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.vp.outputs.version }}
2020

21+
- name: Setup Vite+
22+
uses: voidzero-dev/setup-vp@v1
23+
with:
24+
node-version-file: package.json
25+
cache: false
26+
run-install: false
27+
28+
- name: Resolve pnpm store path
29+
id: pnpm_store
30+
shell: bash
31+
run: |
32+
store_path="$(vp pm cache dir)"
33+
echo "path=$store_path" >> "$GITHUB_OUTPUT"
34+
35+
# setup-vp's shared cache key ignores install filters. Keep full installs in a
36+
# separate namespace, including fallback restores.
2137
# The pnpm store stays a cache tarball on the runner's own disk. A store on a
2238
# Blacksmith sticky disk mounts in under a second, but pnpm then copies every
2339
# package across filesystems instead of hard-linking it: install took 28-49s
2440
# against 9s plus an 11s restore.
25-
- name: Setup Vite+
26-
uses: voidzero-dev/setup-vp@v1
41+
- name: Cache full pnpm store
42+
uses: actions/cache@v6
2743
with:
28-
node-version-file: package.json
29-
cache: true
30-
run-install: true
44+
path: ${{ steps.pnpm_store.outputs.path }}
45+
key: pnpm-full-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', 'package.json') }}
46+
restore-keys: |
47+
pnpm-full-v1-${{ runner.os }}-${{ runner.arch }}-
48+
49+
- name: Install dependencies
50+
shell: bash
51+
run: vp install

‎.github/workflows/ci.yml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,6 @@ jobs:
482482
!/apps/mobile/modules/t3-terminal/Vendor/**/*.a
483483
sparse-checkout-cone-mode: false
484484

485-
# A full install: a filtered one that misses the cache first saves its
486-
# partial store under the shared lockfile key for every later job.
487485
- name: Setup Vite+
488486
uses: ./.github/actions/setup-ci-deps
489487

‎.github/workflows/release.yml‎

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,8 @@ jobs:
129129
!/.repos/
130130
sparse-checkout-cone-mode: false
131131

132-
- name: Setup Vite+
133-
uses: voidzero-dev/setup-vp@v1
134-
with:
135-
node-version-file: package.json
136-
cache: true
137-
run-install: true
132+
- name: Setup dependencies
133+
uses: ./.github/actions/setup-ci-deps
138134
env:
139135
pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
140136

@@ -247,12 +243,8 @@ jobs:
247243
!/.repos/
248244
sparse-checkout-cone-mode: false
249245

250-
- name: Setup Vite+
251-
uses: voidzero-dev/setup-vp@v1
252-
with:
253-
node-version-file: package.json
254-
cache: true
255-
run-install: true
246+
- name: Setup dependencies
247+
uses: ./.github/actions/setup-ci-deps
256248

257249
- name: Ensure Electron runtime is installed
258250
run: vp run --filter @t3tools/desktop ensure:electron
@@ -281,12 +273,8 @@ jobs:
281273
!/.repos/
282274
sparse-checkout-cone-mode: false
283275

284-
- name: Setup Vite+
285-
uses: voidzero-dev/setup-vp@v1
286-
with:
287-
node-version-file: package.json
288-
cache: true
289-
run-install: true
276+
- name: Setup dependencies
277+
uses: ./.github/actions/setup-ci-deps
290278

291279
- name: Ensure Electron runtime is installed
292280
run: vp run --filter @t3tools/desktop ensure:electron
@@ -325,12 +313,8 @@ jobs:
325313
!/.repos/
326314
sparse-checkout-cone-mode: false
327315

328-
- name: Setup Vite+
329-
uses: voidzero-dev/setup-vp@v1
330-
with:
331-
node-version-file: package.json
332-
cache: true
333-
run-install: true
316+
- name: Setup dependencies
317+
uses: ./.github/actions/setup-ci-deps
334318

335319
# No Electron setup here: `t3` (apps/server) has no Electron dependency
336320
# and none of its tests touch the runtime. Only the non-server `test`
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
!macro customInstall
2+
!ifndef DO_NOT_CREATE_START_MENU_SHORTCUT
3+
${IfNot} ${FileExists} "$newStartMenuLink"
4+
!insertmacro createMenuDirectory
5+
CreateShortCut "$newStartMenuLink" "$appExe" "" "$appExe" 0 "" "" "${APP_DESCRIPTION}"
6+
ClearErrors
7+
WinShell::SetLnkAUMI "$newStartMenuLink" "${APP_ID}"
8+
${EndIf}
9+
!endif
10+
!macroend

‎apps/desktop/src/app/DesktopEarlyElectronStartup.test.ts‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as NodePath from "node:path";
33
import { assert, describe, it } from "@effect/vitest";
44

55
import {
6+
restoreEarlyLinuxDeviceScaleFactor,
67
resolveEarlyLinuxElectronOptions,
78
resolveEarlyLinuxPasswordStorePreference,
89
resolveLinuxDisableFeaturesSwitch,
@@ -269,3 +270,70 @@ describe("DesktopEarlyElectronStartup", () => {
269270
});
270271
});
271272
});
273+
274+
describe("Linux device scale persistence failures", () => {
275+
const input = {
276+
env: { T3CODE_HOME: "/isolated" },
277+
homeDirectory: "/home/user",
278+
joinPath: NodePath.posix.join,
279+
};
280+
281+
it.each(["0", "Infinity", "garbage"])("ignores invalid persisted scale %j", (value) => {
282+
const applied: Array<[string, string]> = [];
283+
const writes: Array<string> = [];
284+
restoreEarlyLinuxDeviceScaleFactor({
285+
...input,
286+
commandLine: {
287+
hasSwitch: () => false,
288+
getSwitchValue: () => "",
289+
appendSwitch: (name, scale) => applied.push([name, scale]),
290+
},
291+
readFileString: () => value,
292+
writeFileString: (_path, contents) => writes.push(contents),
293+
});
294+
assert.deepEqual(applied, []);
295+
assert.deepEqual(writes, []);
296+
});
297+
298+
it("keeps startup available with default scaling when saved state cannot be read", () => {
299+
const applied: Array<[string, string]> = [];
300+
restoreEarlyLinuxDeviceScaleFactor({
301+
...input,
302+
commandLine: {
303+
hasSwitch: () => false,
304+
getSwitchValue: () => "",
305+
appendSwitch: (name, value) => applied.push([name, value]),
306+
},
307+
readFileString: () => {
308+
throw new Error("ENOENT");
309+
},
310+
writeFileString: () => {},
311+
});
312+
assert.deepEqual(applied, []);
313+
});
314+
315+
it("keeps an explicit scale when saving it fails, without falling back to saved state", () => {
316+
const applied: Array<[string, string]> = [];
317+
const reads: Array<string> = [];
318+
const writes: Array<string> = [];
319+
restoreEarlyLinuxDeviceScaleFactor({
320+
...input,
321+
commandLine: {
322+
hasSwitch: () => true,
323+
getSwitchValue: () => "1",
324+
appendSwitch: (name, value) => applied.push([name, value]),
325+
},
326+
readFileString: (path) => {
327+
reads.push(path);
328+
return "1.75";
329+
},
330+
writeFileString: (_path, value) => {
331+
writes.push(value);
332+
throw new Error("EACCES");
333+
},
334+
});
335+
assert.deepEqual(writes, ["1"]);
336+
assert.deepEqual(reads, []);
337+
assert.deepEqual(applied, []);
338+
});
339+
});

‎apps/desktop/src/app/DesktopEarlyElectronStartup.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,43 @@ export function resolveEarlyLinuxElectronOptions(
159159
}),
160160
};
161161
}
162+
163+
/** Remember the explicit Chromium scale across AppImage updates, which drop launch arguments. */
164+
export function restoreEarlyLinuxDeviceScaleFactor(
165+
input: EarlyDesktopSettingsInput & {
166+
readonly commandLine: {
167+
readonly hasSwitch: (name: string) => boolean;
168+
readonly getSwitchValue: (name: string) => string;
169+
readonly appendSwitch: (name: string, value: string) => void;
170+
};
171+
readonly writeFileString: (path: string, value: string) => void;
172+
},
173+
): void {
174+
// Keep this separate from desktop-settings.json: the settings service rewrites
175+
// that document, and Chromium needs the value before that service is available.
176+
const path = input.joinPath(
177+
resolveEarlyDesktopSettingsPath(input),
178+
"..",
179+
"linux-device-scale-factor",
180+
);
181+
const switchName = "force-device-scale-factor";
182+
const isValid = (value: string) =>
183+
value.trim().length > 0 && Number.isFinite(Number(value)) && Number(value) > 0;
184+
if (input.commandLine.hasSwitch(switchName)) {
185+
const value = input.commandLine.getSwitchValue(switchName);
186+
if (isValid(value)) {
187+
try {
188+
input.writeFileString(path, value);
189+
} catch {
190+
// A read-only state directory must not prevent startup with the explicit switch.
191+
}
192+
}
193+
return;
194+
}
195+
try {
196+
const value = input.readFileString(path).trim();
197+
if (isValid(value)) input.commandLine.appendSwitch(switchName, value);
198+
} catch {
199+
// First launch, missing state, or unreadable state: keep Chromium's default.
200+
}
201+
}

‎apps/desktop/src/app/DesktopPreReadyPlatform.test.ts‎

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const {
1515
writeFileSyncMock,
1616
copyFileSyncMock,
1717
execFileSyncMock,
18+
readFileSyncMock,
1819
} = vi.hoisted(() => ({
1920
appendSwitchMock: vi.fn(),
2021
getSwitchValueMock: vi.fn(),
@@ -25,6 +26,7 @@ const {
2526
writeFileSyncMock: vi.fn(),
2627
copyFileSyncMock: vi.fn(),
2728
execFileSyncMock: vi.fn(),
29+
readFileSyncMock: vi.fn(),
2830
}));
2931

3032
vi.mock("electron", () => ({
@@ -45,7 +47,7 @@ vi.mock("electron", () => ({
4547
}));
4648

4749
vi.mock("node:fs", () => ({
48-
readFileSync: () => "{}",
50+
readFileSync: readFileSyncMock,
4951
mkdirSync: mkdirSyncMock,
5052
writeFileSync: writeFileSyncMock,
5153
copyFileSync: copyFileSyncMock,
@@ -68,6 +70,66 @@ describe("DesktopPreReadyPlatform", () => {
6870
writeFileSyncMock.mockReset();
6971
copyFileSyncMock.mockReset();
7072
execFileSyncMock.mockReset();
73+
readFileSyncMock.mockReset().mockReturnValue("{}");
74+
});
75+
76+
it.effect("persists Linux scaling synchronously across relaunches and settings rewrites", () => {
77+
vi.stubEnv("T3CODE_HOME", "/isolated");
78+
vi.stubEnv("VITE_DEV_SERVER_URL", "");
79+
const settingsPath = "/isolated/userdata/desktop-settings.json";
80+
const files = new Map([[settingsPath, "{}"]]);
81+
const commandLine = new Map<string, string>();
82+
readFileSyncMock.mockImplementation((path: string) => {
83+
const contents = files.get(path);
84+
if (contents === undefined) throw new Error("ENOENT");
85+
return contents;
86+
});
87+
writeFileSyncMock.mockImplementation((path: string, contents: string) => {
88+
files.set(path, contents);
89+
});
90+
hasSwitchMock.mockImplementation((name: string) => commandLine.has(name));
91+
getSwitchValueMock.mockImplementation((name: string) => commandLine.get(name) ?? "");
92+
appendSwitchMock.mockImplementation((name: string, value: string) => {
93+
commandLine.set(name, value);
94+
});
95+
const launch = Effect.gen(function* () {
96+
const startup = Promise.resolve().then(() => commandLine.get("force-device-scale-factor"));
97+
yield* DesktopPreReadyPlatform.make;
98+
return yield* Effect.promise(() => startup);
99+
});
100+
101+
return Effect.gen(function* () {
102+
for (const explicitScale of ["1.75", "1"]) {
103+
commandLine.clear();
104+
commandLine.set("force-device-scale-factor", explicitScale);
105+
appendSwitchMock.mockClear();
106+
assert.equal(yield* launch, explicitScale);
107+
assert.isFalse(
108+
appendSwitchMock.mock.calls.some(([name]) => name === "force-device-scale-factor"),
109+
);
110+
111+
// The settings service discards fields it does not own when rewriting its document.
112+
files.set(settingsPath, JSON.stringify({ linuxPasswordStore: "basic" }));
113+
commandLine.clear();
114+
assert.equal(yield* launch, explicitScale);
115+
}
116+
}).pipe(
117+
Effect.provideService(HostProcess.Platform, "linux"),
118+
Effect.ensuring(Effect.sync(() => vi.unstubAllEnvs())),
119+
);
120+
});
121+
122+
it.effect.each(["darwin", "win32"] as const)("leaves device scaling alone on %s", (platform) => {
123+
readFileSyncMock.mockReturnValue("1.75");
124+
hasSwitchMock.mockImplementation((name: string) => name === "force-device-scale-factor");
125+
getSwitchValueMock.mockReturnValue("2");
126+
127+
return Effect.gen(function* () {
128+
yield* DesktopPreReadyPlatform.make;
129+
assert.deepEqual(readFileSyncMock.mock.calls, []);
130+
assert.deepEqual(writeFileSyncMock.mock.calls, []);
131+
assert.deepEqual(appendSwitchMock.mock.calls, []);
132+
}).pipe(Effect.provideService(HostProcess.Platform, platform));
71133
});
72134

73135
it.effect("preserves an explicit Linux password-store switch", () => {

‎apps/desktop/src/app/DesktopPreReadyPlatform.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ export const make = Effect.gen(function* () {
6262
platform === "linux" ? resolveEarlyLinuxElectronOptionsFromProcess(homeDirectory) : null;
6363

6464
if (linux !== null) {
65+
DesktopEarlyElectronStartup.restoreEarlyLinuxDeviceScaleFactor({
66+
env: process.env,
67+
homeDirectory,
68+
joinPath: NodePath.posix.join,
69+
commandLine: Electron.app.commandLine,
70+
readFileString: (path) => NodeFS.readFileSync(path, "utf8"),
71+
writeFileString: (path, value) => {
72+
NodeFS.mkdirSync(NodePath.posix.dirname(path), { recursive: true });
73+
NodeFS.writeFileSync(path, value, "utf8");
74+
},
75+
});
6576
// The portal also requires a valid desktop entry. An AppImage update may
6677
// have removed the executable referenced by the previous launch's entry.
6778
try {

‎apps/desktop/src/window/DesktopApplicationMenu.test.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,13 @@ describe("DesktopApplicationMenu", () => {
247247
}),
248248
);
249249

250-
it.effect("routes View menu zoom to the main window instead of zoom roles", () =>
250+
it.effect("registers macOS command-plus once and routes it through main-window zoom", () =>
251251
Effect.gen(function* () {
252252
const selectedAction = yield* Deferred.make<string>();
253253
const applicationMenuTemplate =
254254
yield* Deferred.make<readonly Electron.MenuItemConstructorOptions[]>();
255255

256-
yield* configureMenu(selectedAction, applicationMenuTemplate);
256+
yield* configureMenu(selectedAction, applicationMenuTemplate, { platform: "darwin" });
257257

258258
const template = yield* Deferred.await(applicationMenuTemplate);
259259
const viewMenu = template.find((item) => item.label === "View");
@@ -268,9 +268,17 @@ describe("DesktopApplicationMenu", () => {
268268
),
269269
);
270270

271-
const zoomIn = viewMenu.submenu.find((item) => item.label === "Zoom In");
271+
const shiftedEqual = viewMenu.submenu.filter(
272+
(item) => item.accelerator === "CmdOrCtrl+Shift+=",
273+
);
274+
assert.lengthOf(shiftedEqual, 1);
275+
assert.lengthOf(
276+
viewMenu.submenu.filter((item) => item.accelerator === "CmdOrCtrl+numadd"),
277+
1,
278+
);
279+
const zoomIn = shiftedEqual[0];
272280
assert.isDefined(zoomIn);
273-
assert.equal(zoomIn.accelerator, "CmdOrCtrl+=");
281+
assert.isFalse(zoomIn.visible);
274282
if (typeof zoomIn.click !== "function") {
275283
throw new Error("Expected Zoom In menu item to have a click handler.");
276284
}

0 commit comments

Comments
 (0)