Skip to content

Commit 1185137

Browse files
Merge remote-tracking branch 'origin/main' into t3code/android-nav-chrome
# Conflicts: # apps/mobile/src/features/home/AndroidHomeFab.android.tsx # apps/mobile/src/features/home/ThreadListToolbar.tsx # apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx # pnpm-lock.yaml
2 parents 7758901 + fb99076 commit 1185137

512 files changed

Lines changed: 20209 additions & 3997 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`

‎.macroscope/check-run-agents/effect-service-conventions.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Review changed TypeScript for the conventions below. They apply when a pull requ
5757
- Define service failures with `Schema.TaggedError` and structured attributes: operation or stage, resource path or entity identifier, normalized category or status. Derive `message` from those attributes only. Never derive it from `cause`, `cause.message`, or a stringified defect, and do not add a `detail` field that copies `cause.message`.
5858
- When wrapping a real failure, keep the immediate underlying error as `cause` so the chain and stack survive. Make `cause` required if every construction wraps a failure. Pure validation or domain errors created without an underlying failure need no cause.
5959
- Keep attributes and log annotations safe and bounded: no raw wire payloads, command arguments or output, signed URLs, credentials, query strings, or arbitrary defect text. Preserve the exact value only as `cause`; expose normalized categories, lengths, counts, and safe URL protocol or hostname where useful.
60+
The documented exception is `DeviceBootError.diagnostics`: device hub launch commands and failure text are intentionally exposed to authorized device users and agents, capped at 2,000 characters and included in the error message. Do not apply this exception to other service errors.
6061
- At a translation boundary, pass through an already structured domain error when it is part of the target error channel; wrap only unknown or lower-level failures. Map failures where the context is known instead of wrapping a whole multi-step pipeline in one generic error.
6162
- Do not encode the same distinction twice with both a specific error tag and a single-value `operation`, `reason`, `kind`, or `phase` literal. Split into separate error classes when a discriminator drives caller control flow or the user-facing message; a discriminator used only for diagnostics may stay a field. Caller-visible messages exposed through HTTP, RPC, persisted state, or UI are behavior and must survive a structural refactor.
6263
- Do not add a helper whose only behavior is `(...args) => new SomeError({ ...args })`. Construct the error at the failure boundary. Keep a mapper only when it performs real normalization, passes through domain errors, or adds reusable context; when such a mapper belongs to the target error type, prefer a static factory on that class.
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/scripts/dev-electron.mjs‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,14 @@ function cleanupStaleDevApps() {
9494
return;
9595
}
9696

97-
NodeChildProcess.spawnSync("pkill", ["-f", "--", `--t3code-dev-root=${desktopDir}`], {
98-
stdio: "ignore",
99-
});
97+
const escapedDesktopDir = desktopDir.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
98+
NodeChildProcess.spawnSync(
99+
"pkill",
100+
["-f", "--", `(^| )--t3code-dev-root=${escapedDesktopDir}( |$)`],
101+
{
102+
stdio: "ignore",
103+
},
104+
);
100105
}
101106

102107
function startApp() {

‎apps/desktop/scripts/electron-launcher.test.mjs‎

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import * as NodeChildProcess from "node:child_process";
2+
import * as NodeEvents from "node:events";
13
import * as NodeFS from "node:fs";
24
import * as NodeOS from "node:os";
35
import * as NodePath from "node:path";
6+
import * as NodeVM from "node:vm";
47

58
import { assert, describe, it } from "vite-plus/test";
69

@@ -151,3 +154,93 @@ describe("electron development launcher", () => {
151154
assert.equal(production.generatedIconPath, "/runtime/icon-prod.icns");
152155
});
153156
});
157+
158+
async function startupCleanupPattern(desktopDir) {
159+
const source = NodeFS.readFileSync(new URL("./dev-electron.mjs", import.meta.url), "utf8");
160+
let pattern;
161+
// Supply inert imports so the real startup runs without launching Electron or signalling processes.
162+
await NodeVM.runInNewContext(
163+
`(async () => { ${source.replace(/^import\s[\s\S]*?;\n/gm, "")} })()`,
164+
{
165+
NodeChildProcess: {
166+
execFileSync: () => undefined,
167+
spawnSync: (command, args) => {
168+
if (command === "pkill" && args.includes("-f")) pattern = args.at(-1);
169+
},
170+
spawn: () => new NodeEvents.EventEmitter(),
171+
},
172+
NodeFS: { watch: () => ({ close: () => undefined }) },
173+
NodeOS: { platform: () => "linux" },
174+
NodePath,
175+
desktopDir,
176+
resolveDevProtocolClient: () => null,
177+
resolveElectronLaunchCommand: (args) => ({ electronPath: "electron", args }),
178+
waitForResources: async () => undefined,
179+
URL,
180+
process: {
181+
env: { VITE_DEV_SERVER_URL: "http://localhost:1234" },
182+
execPath: "node",
183+
once: () => undefined,
184+
},
185+
},
186+
);
187+
assert.isString(pattern);
188+
return pattern;
189+
}
190+
191+
it
192+
// oxlint-disable-next-line t3code/no-global-process-runtime -- Native pgrep is unavailable on Windows.
193+
.skipIf(NodeOS.platform() === "win32")
194+
.each([
195+
"/tmp/t3-feature.one/apps/desktop",
196+
"/tmp/t3-feature.one [two](three)+?^${four}|back\\slash*/apps/desktop",
197+
])("dev cleanup matches only the literal root argument: %s", async (desktopDir) => {
198+
const pattern = await startupCleanupPattern(desktopDir);
199+
const flag = `--t3code-dev-root=${desktopDir}`;
200+
const argvCases = [
201+
[flag],
202+
[flag, "main.cjs"],
203+
[flag.replace(".one", "Xone")],
204+
[`${flag}-two`],
205+
[`prefix${flag}`],
206+
[`--t3code-dev-root=/other${desktopDir}`],
207+
];
208+
const children = [];
209+
try {
210+
for (const args of argvCases) {
211+
const child = NodeChildProcess.spawn(
212+
process.execPath,
213+
["-e", "process.send('ready'); setInterval(() => {}, 1000)", "--", ...args],
214+
{ stdio: ["ignore", "ignore", "inherit", "ipc"] },
215+
);
216+
children.push(child);
217+
await Promise.race([
218+
NodeEvents.once(child, "message"),
219+
NodeEvents.once(child, "exit").then(() => {
220+
throw new Error("Fixture exited before readiness");
221+
}),
222+
]);
223+
}
224+
// Use the native ERE engine, but never execute the launcher's signal-producing command.
225+
const result = NodeChildProcess.spawnSync(
226+
"pgrep",
227+
["-P", String(process.pid), "-f", "--", pattern],
228+
{ encoding: "utf8" },
229+
);
230+
assert.equal(result.status, 0, result.stderr);
231+
const matches = result.stdout.trim().split(/\s+/).map(Number);
232+
assert.sameMembers(
233+
matches,
234+
children.slice(0, 2).map((child) => child.pid),
235+
);
236+
} finally {
237+
await Promise.all(
238+
children.map(async (child) => {
239+
if (child.exitCode !== null || child.signalCode !== null) return;
240+
const exited = NodeEvents.once(child, "exit");
241+
child.kill("SIGTERM");
242+
await exited;
243+
}),
244+
);
245+
}
246+
});

‎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+
}

0 commit comments

Comments
 (0)