Skip to content

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

fix: preserve valid translations during release CI recovery (#7172)

Ezra Ellette474f641f520b
diff --git a/.github/workflows/test-release-workflows.yml b/.github/workflows/test-release-workflows.yml
index 2219a394f..39689d5df 100644
--- a/.github/workflows/test-release-workflows.yml
+++ b/.github/workflows/test-release-workflows.yml
@@ -5,6 +5,7 @@
name: Release workflow contracts
on:
+ workflow_dispatch:
pull_request:
paths:
- .github/workflows/release-app.yml
@@ -61,3 +62,74 @@ jobs:
with:
bun-version: "1.3.10"
- run: bun test ./.github/scripts/release-workflows.test.ts ./.github/scripts/release-performance.test.ts
+
+ localization-generation:
+ if: github.event_name == 'workflow_dispatch'
+ needs: release-contracts
+ runs-on: ubuntu-latest
+ timeout-minutes: 30
+ permissions:
+ contents: read
+ actions: read
+ outputs:
+ snapshot-digest: ${{ steps.verify.outputs.digest }}
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ ref: ${{ github.sha }}
+ - uses: ./.github/actions/prepare-desktop-localization
+ with:
+ release-sha: ${{ github.sha }}
+ token: ${{ github.token }}
+ gt-project-id: ${{ secrets.GT_PROJECT_ID }}
+ gt-api-key: ${{ secrets.GT_API_KEY }}
+ - name: Require complete, valid translations
+ id: verify
+ working-directory: apps/screenpipe-app-tauri
+ run: |
+ bun - <<'JS'
+ import assert from "node:assert/strict";
+ import { appendFileSync, readFileSync } from "node:fs";
+ import { createHash } from "node:crypto";
+ import { verifySnapshot } from "./scripts/i18n/prepare.mjs";
+ const bytes = readFileSync("../../.release-localization/snapshot.json");
+ const snapshot = verifySnapshot(JSON.parse(bytes));
+ assert.equal(snapshot.mode, "generate");
+ assert(snapshot.locales.length > 0, "No bundled languages");
+ assert.deepEqual(snapshot.causes, [], "Translation service did not complete cleanly");
+ for (const locale of snapshot.locales) {
+ for (const surface of ["frontend", "native"]) {
+ const coverage = snapshot.coverage[locale][surface];
+ assert(coverage.total > 0, `${locale}: no ${surface} messages`);
+ assert.equal(coverage.translated, coverage.total, `${locale}: incomplete ${surface}`);
+ assert.equal(coverage.fallback, 0, `${locale}: ${surface} fallbacks`);
+ }
+ assert.deepEqual(snapshot.fallbacks[locale], {}, `${locale}: invalid translations`);
+ }
+ appendFileSync(process.env.GITHUB_OUTPUT, `digest=${createHash("sha256").update(bytes).digest("hex")}\n`);
+ console.log(JSON.stringify({ revision: snapshot.revision, coverage: snapshot.coverage }));
+ JS
+
+ localization-handoff:
+ if: github.event_name == 'workflow_dispatch'
+ needs: localization-generation
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+ permissions:
+ contents: read
+ actions: read
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ ref: ${{ github.sha }}
+ # Exercise the enterprise handoff on a clean worker with no GT credentials.
+ - uses: ./.github/actions/prepare-desktop-localization
+ with:
+ release-sha: ${{ github.sha }}
+ source-run-id: ${{ github.run_id }}
+ token: ${{ github.token }}
+ - name: Verify byte-identical offline handoff
+ env:
+ EXPECTED_DIGEST: ${{ needs.localization-generation.outputs.snapshot-digest }}
+ run: |
+ echo "$EXPECTED_DIGEST .release-localization/snapshot.json" | sha256sum --check
diff --git a/apps/screenpipe-app-tauri/scripts/i18n/service.mjs b/apps/screenpipe-app-tauri/scripts/i18n/service.mjs
index a07cbbc44..8054fcf11 100644
--- a/apps/screenpipe-app-tauri/scripts/i18n/service.mjs
+++ b/apps/screenpipe-app-tauri/scripts/i18n/service.mjs
@@ -71,7 +71,10 @@ export async function translateMissing({ root, source, native, config, policy, c
const valid = validateCatalog(messages, content, config.defaultLocale, file.locale).valid;
const target = batch.kind === "gt" ? current.translations : current.native;
target[file.locale] = { ...target[file.locale], ...valid };
- downloads[batch.kind][file.locale] = { ...downloads[batch.kind][file.locale], ...content };
+ // Retain rejected entries for diagnostics, but an incompatible legacy
+ // file must not replace an accepted translation recovered earlier.
+ // A valid provider correction still supersedes the previous wording.
+ downloads[batch.kind][file.locale] = { ...content, ...downloads[batch.kind][file.locale], ...valid };
await writeJson(path.join(dir, batch.kind, `${file.locale}.json`), downloads[batch.kind][file.locale]);
downloaded = true;
}
diff --git a/apps/screenpipe-app-tauri/scripts/i18n/service.test.ts b/apps/screenpipe-app-tauri/scripts/i18n/service.test.ts
index f482f38b2..c3199b89d 100644
--- a/apps/screenpipe-app-tauri/scripts/i18n/service.test.ts
+++ b/apps/screenpipe-app-tauri/scripts/i18n/service.test.ts
@@ -26,6 +26,31 @@ test("unchanged source hashes make zero translation requests", async () => {
expect(calls).toHaveLength(0);
});
+test("cold recovery keeps a valid rich-text translation when a legacy file has incompatible attributes", async () => {
+ const f = await fixture();
+ const source = { field: ["Your correction", { i: 1, t: "textarea" }] };
+ const accepted = ["修正内容", { i: 1, t: "textarea" }];
+ const legacy = ["修正内容", { i: 1, t: "textarea", d: { arl: "Your correction" } }];
+ const calls: string[] = [];
+ const result = await translateMissing({ ...f, source, cache: null, request: async (endpoint: string, body: any) => {
+ calls.push(endpoint);
+ if (endpoint.endsWith("branches/info")) return { branches: [{ id: "branch", name: "desktop-test-policy" }] };
+ if (endpoint.endsWith("files/orphaned")) return { orphanedFiles: [
+ { fileId: "current", versionId: "current", fileName: "desktop/gt/current.json" },
+ { fileId: "legacy", versionId: "legacy", fileName: "__INTERNAL_GT_TEMPLATE_NAME__" },
+ ] };
+ if (endpoint.endsWith("files/download")) return { files: body.map((ref: any) => ({
+ ...ref, fileFormat: "GTJSON", data: Buffer.from(JSON.stringify({ field: ref.fileId === "current" ? accepted : legacy })).toString("base64"),
+ })) };
+ throw new Error(`Unexpected request: ${endpoint}`);
+ } });
+ expect(result.exitCode).toBe(0);
+ expect(result.output).toContain("zero translation requests");
+ expect(calls).not.toContain("/v2/translate");
+ const downloaded = JSON.parse(await fs.readFile(path.join(f.root, ".localization/gt/ja.json"), "utf8"));
+ expect(downloaded.field).toEqual(accepted);
+});
+
test("only missing messages are sent, with file context, and provider corrections are downloaded without regeneration", async () => {
const f = await fixture();
const calls: string[] = [];