YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(release): stabilize localization source discovery order
Ezra Ellette7df29a4e5d0d
diff --git a/apps/screenpipe-app-tauri/scripts/i18n/collect.mjs b/apps/screenpipe-app-tauri/scripts/i18n/collect.mjsindex 7053bc16f..0737477d7 100644--- a/apps/screenpipe-app-tauri/scripts/i18n/collect.mjs+++ b/apps/screenpipe-app-tauri/scripts/i18n/collect.mjs@@ -5,10 +5,16 @@// exactly the ones its compiler/runtime use. This step is entirely offline.import { generateSettings } from "gt/config/generateSettings";import { collectFiles } from "gt/formats/files/collectFiles";+import { matchFiles } from "gt/fs/matchFiles";import path from "node:path";import { writeJson } from "./prepare.mjs";const settings = await generateSettings({ config: process.argv[2], omitConfigIds: true });+// GT keeps the first source for a shared message ID, including icon metadata.+// Resolve exclusions first, then give every runner the same relative file order.+settings.src = matchFiles(process.cwd(), settings.src)+ .map((file) => path.relative(process.cwd(), file).split(path.sep).join("/"))+ .sort();const { files } = await collectFiles({ inline: true }, settings, "gt-react");const file = files.find((file) => file.fileFormat === "GTJSON");const destination = path.join(process.cwd(), ".localization/source");diff --git a/apps/screenpipe-app-tauri/scripts/i18n/collect.test.ts b/apps/screenpipe-app-tauri/scripts/i18n/collect.test.tsnew file mode 100644index 000000000..38e180163--- /dev/null+++ b/apps/screenpipe-app-tauri/scripts/i18n/collect.test.ts@@ -0,0 +1,39 @@+// screenpipe — AI that knows everything you've seen, said, or heard+// https://screenpipe.com++import { expect, test } from "bun:test";+import fs from "node:fs/promises";+import os from "node:os";+import path from "node:path";+import { prepareLocalization, writeJson } from "./prepare.mjs";++test("release snapshot handoff is independent of source file discovery order", async () => {+ const root = await fs.mkdtemp(path.join(os.tmpdir(), "screenpipe-i18n-handoff-"));+ const originalSnapshot = process.env.SCREENPIPE_I18N_SNAPSHOT;+ delete process.env.SCREENPIPE_I18N_SNAPSHOT;+ try {+ const config = {+ defaultLocale: "en", locales: ["ja"],+ src: ["components/**/*.tsx", "app/**/*.tsx", "!**/*.test.*"],+ files: { gt: { output: ".localization/gt/[locale].json", parsingFlags: {+ enableAutoJsxInjection: true, autoderive: false, includeSourceCodeContext: false,+ } } },+ };+ await writeJson(path.join(root, "gt.config.json"), config);+ for (const [file, icon] of [["components/manage.tsx", "Bell"], ["app/manage.tsx", "Plus"], ["app/private.test.tsx", "Private"]]) {+ await fs.mkdir(path.dirname(path.join(root, file)), { recursive: true });+ await fs.writeFile(path.join(root, file), `export function Probe() { return <button><${icon} />Manage</button>; }`);+ }+ const snapshot = await prepareLocalization({ root, config, mode: "cached" });+ expect(snapshot.coverage.ja.frontend.total).toBe(1);+ process.env.SCREENPIPE_I18N_SNAPSHOT = path.join(root, ".localization/snapshot.json");+ const handedOff = await prepareLocalization({ root, config: { ...config, src: [...config.src].reverse() }, mode: "cached" });+ expect(handedOff).toEqual(snapshot);+ await fs.appendFile(path.join(root, "app/manage.tsx"), '\nexport function Changed() { return <p>New source text</p>; }');+ await expect(prepareLocalization({ root, config, mode: "cached" })).rejects.toThrow("snapshot does not match");+ } finally {+ if (originalSnapshot === undefined) delete process.env.SCREENPIPE_I18N_SNAPSHOT;+ else process.env.SCREENPIPE_I18N_SNAPSHOT = originalSnapshot;+ await fs.rm(root, { recursive: true, force: true });+ }+}, 30_000);