From 2d053b3cf2fbda3607b5e610e2a4e54f9be4716e Mon Sep 17 00:00:00 2001 From: NiveditJain Date: Fri, 8 May 2026 19:10:15 -0700 Subject: [PATCH] [luv-325] fix: stop translate-docs workflow from dropping translations when an auto-PR is open MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously the consolidate step exited early if any "[auto] update translations" PR was open and the cache-save step ran first, so translations queued during a busy push window were marked done in cache but never landed in any branch. Empirically verified against the README rewrite in #321: the per-language `Translate` jobs successfully translated all 14 i18n READMEs (visible in run 25588145237 logs as `translated (3258+3048 tokens)` lines), but the consolidate job logged `Translation PR already open. Skipping.` and PR #324 only contained 14 dashboard.mdx files — the 14 README translations were stuck on the pre-redesign 358-line layout while the English README dropped to 171 lines. Fix: when an auto-PR is open, snapshot the freshly-generated docs/ tree + merged cache via tar before any branch ops, fetch and force-checkout the existing PR's branch, then untar on top so the newest English source always wins. PR creation only fires when no existing PR matched. Co-Authored-By: Claude Opus 4.7 --- .github/workflows/translate-docs.yml | 63 ++++++++++++++++++++-------- CHANGELOG.md | 3 ++ 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/.github/workflows/translate-docs.yml b/.github/workflows/translate-docs.yml index 49a35ffe..6be4a5dc 100644 --- a/.github/workflows/translate-docs.yml +++ b/.github/workflows/translate-docs.yml @@ -179,33 +179,62 @@ jobs: echo "changed=true" >> "$GITHUB_OUTPUT" fi - - name: Create PR if translations changed + - name: Create or update PR with translations if: steps.changes.outputs.changed == 'true' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - EXISTING=$(gh pr list --base main --search "[auto] update translations" --state open --json number --jq length) - if [ "$EXISTING" -gt 0 ]; then - echo "Translation PR already open. Skipping." - exit 0 - fi + # When an auto-translation PR is already open, push to its branch + # instead of dropping these translations. Previously this step + # exited early if any open PR matched, which combined with the + # cache-save above meant lost translations were never re-attempted + # (cache marked them done, file changes were never committed). + EXISTING_PR=$(gh pr list --base main --search "[auto] update translations" --state open --json number,headRefName --limit 1) + EXISTING_COUNT=$(echo "$EXISTING_PR" | jq length) - BRANCH="auto/translate-docs-$(date +%Y%m%d-%H%M)" git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git checkout -b "$BRANCH" + + if [ "$EXISTING_COUNT" -gt 0 ]; then + EXISTING_BRANCH=$(echo "$EXISTING_PR" | jq -r '.[0].headRefName') + EXISTING_NUMBER=$(echo "$EXISTING_PR" | jq -r '.[0].number') + echo "Updating existing PR #$EXISTING_NUMBER on branch $EXISTING_BRANCH" + + # Snapshot freshly-generated translations and the merged cache, + # then switch branches and replay them on top so newer English + # source wins over whatever the existing PR branch had. + git reset HEAD + tar -czf /tmp/translations.tar.gz docs/ scripts/translate-docs/.translation-cache.json + git fetch origin "$EXISTING_BRANCH" + git checkout -f -B "$EXISTING_BRANCH" "origin/$EXISTING_BRANCH" + tar -xzf /tmp/translations.tar.gz + rm /tmp/translations.tar.gz + BRANCH="$EXISTING_BRANCH" + else + BRANCH="auto/translate-docs-$(date +%Y%m%d-%H%M)" + git checkout -b "$BRANCH" + fi + + git add -A + if git diff --cached --quiet; then + echo "No new translation changes to push. Done." + exit 0 + fi + git commit -m "docs: update translations for changed English sources" git push origin "$BRANCH" - PR_BODY="## Summary + if [ "$EXISTING_COUNT" -eq 0 ]; then + PR_BODY="## Summary - Automated translation update triggered by changes to English documentation sources. + Automated translation update triggered by changes to English documentation sources. - - Only changed pages were re-translated (content-hash cache) - - All 14 languages across 3 tiers (parallel matrix)" + - Only changed pages were re-translated (content-hash cache) + - All 14 languages across 3 tiers (parallel matrix)" - gh pr create \ - --title "[auto] update translations" \ - --body "$PR_BODY" \ - --base main \ - --head "$BRANCH" + gh pr create \ + --title "[auto] update translations" \ + --body "$PR_BODY" \ + --base main \ + --head "$BRANCH" + fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 44619735..fe3953ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ - `scripts/launch.ts`: redesign the dashboard-startup ASCII banner to mirror the hosted PNG wordmark — hand-crafted chunky pixel-block lowercase "failproof ai" compressed with Unicode 2x2 quadrant block characters (▖▗▘▙▚▛▜▝▞▟ + ▀ ▄ █ ▌ ▐) and horizontally scaled 4:3 so the full wordmark fits in ~75 cols × ~10 rows (clean on any standard ≥80-col terminal), with a plain-text fallback for narrower windows. Also drops the "Using default .claude projects path: …" log line at startup — it printed unconditionally on every dashboard launch and added no signal (#322). - Remove the undocumented `--projects-path ` / `-p ` CLI flag from `scripts/parse-script-args.ts` and the corresponding plumbing in `scripts/launch.ts` (custom-path branch + log line + spawn-env override). Custom Claude project folders can still be pointed at via the `CLAUDE_PROJECTS_PATH` environment variable, which `lib/paths.ts:getClaudeProjectsPath` already honors. `docs/cli/dashboard.mdx` updated to reflect the env-var-only path; tests in `__tests__/scripts/parse-script-args.test.ts` trimmed to drop the 6 cases that exercised the removed flag (#322). +### Fixes +- `.github/workflows/translate-docs.yml`: when an `[auto] update translations` PR is already open, push the new translations to its existing branch instead of skipping. Previously the consolidate step exited early on any open auto-PR but the cache-save step ran first, so the cache advanced to mark the lost translations as done — and the next workflow run saw them as cached and never re-translated. Empirically: the README rewrite in #321 *did* successfully translate all 14 `docs/i18n/README.*.md` files (visible in run 25588145237's per-language logs as `translated (3258+3048 tokens)` lines), but the consolidate job logged `Translation PR already open. Skipping.` because an unrelated auto-PR was mid-flight; the next two runs (#322 → #324) saw the README as cached and PR #324 only contained 14 dashboard.mdx files, leaving the 14 README translations stuck on the pre-redesign 358-line layout while English was 171 lines. The fix snapshots the freshly-generated `docs/` tree + merged cache via tar before any branch operations, fetches and force-checks-out the existing PR branch, then untars on top so the latest translation always wins over whatever the PR branch held; PR creation only fires when no existing PR matched (#325). + ### Docs - Rewrite the English `README.md`: new layout with shields.io badges (npm / CI / Slack / Docs / License), a CDN-hosted wordmark logo, the translation strip pulled back up to the header alongside the badges, the existing 7-CLI logo grid (Claude / Codex / Copilot / Cursor / OpenCode / Pi / Gemini) preserved with its install hint and beta caveat, a tighter "What it stops" table that leans on the git policies (`block-push-master` / `block-force-push` / `block-work-on-main` / `block-rm-rf` / `sanitize-api-keys`), a "License" section explaining the MIT + Commons Clause split, and a documentation index linking to docs.befailproof.ai. The hero GIF is the new `readme-arch-hq.gif` (added in this PR); the old `failproofai-hq.gif` is removed. The 14 translated `docs/i18n/README.*.md` files were swapped to the new GIF filename in the same PR — their structural rewrite is left to the next `translate-docs` workflow run on `main` (#321).