Skip to content

fix(i18n): translate pet import and repo icon upload refusals by code - #35861

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/i18n-main-codes-23
Oct 29, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/i18n-main-codes-23

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​51 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​48
Prod 27 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​945 $\color{#cf222e}{\Huge{\mathbf{−}}}$​134 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​811

Summary

Pet import (image and .codex-pet bundle) and repo icon upload refusals were thrown as English Errors from Electron IPC, so the renderer toasted Error invoking remote method 'pet:import': Error: … in every language. These desktop-only handlers now return a coded failure for known refusals, and the renderer shows it in the UI language. The English error text is byte-identical to the old messages. Stored default pet names are shown translated.

What Changed

  • src/shared/pet-import-failure-copy.ts: one English table, plus PetImportError (thrown inside main's import steps; it carries { ok: false, error, errorCode, errorParams?, errorDetail? }), isPetImportFailure, and the stored default labels Custom pet / Pet bundle.
  • pet.ts, pet-bundle-import.ts, pet-bundle-sprite-metadata.ts, pet-bundle-spritesheet-source.ts: the English throws now throw PetImportError. File sizes, sheet and frame dimensions, and animation names and counts are params. The zod/JSON parse message is verbatim errorDetail. pet:import and pet:importPetBundle return the coded failure for these, and any other error still throws as before. Preload types are widened to match.
  • shell:pickRepoIconImage: the "must be PNG" and "256KB or smaller" refusals are now returned as coded failures (src/shared/repo-icon-pick-failure-copy.ts). The web shell API still returns null.
  • Renderer: components/pet/pet-import-failure-text.ts (petImportFailureText, customPetLabel) and settings/repository/identity/repo-icon-pick-failure-text.ts. These narrow with Object.hasOwn and check each code's params. An unknown code or missing params shows the English error. PetStatusSegment and RepositoryIconTabs handle the result and keep their existing catch.
  • Default pet names stay stored in English (older builds and other readers still see a valid label). They are translated at render when the stored label equals the default sentinel for that pet kind. A user file literally named Custom pet would also show translated. This is the accepted sentinel trade-off and avoids a persisted-schema change.
  • New keys pet.importErrors.*, pet.defaultLabels.*, settings.repository.iconPickErrors.* in all 11 catalogs. Translations with counts use count-neutral wording.

Why

Issue #32207: main-produced English was shown verbatim in non-English UIs.

Linked Issue

Refs #32207

Visual Proof

N/A, copy/i18n only.

Testing

  • pnpm tc passed
  • pnpm test src/main/ipc/pet.test.ts src/main/ipc/pet-bundle.test.ts src/main/ipc/shell* src/renderer/src/components/pet src/renderer/src/components/status-bar src/renderer/src/components/settings/repository: passed (the bundle-refusal test now asserts the coded result with its unchanged English)
  • pnpm sync:localization-runtime-catalog and all five verify:localization-* checks: passed
  • oxlint on changed files: clean; pnpm format: applied
  • pnpm check:changed --maxWorkers=2 was not run to completion on this loaded machine (it timed out at 20 minutes on the sibling PR because of local Electron suites), so CI is the gate

@OrcaWin
OrcaWin requested a review from brennanb2025 as a code owner October 29, 2026 08:49
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

Pet imports and repository icon uploads now return known refusals with codes. The renderer uses those codes to show translated messages while keeping the English fallback.

  • Pet imports show localized refusal messages and default names.
  • Repository icon uploads explain PNG and size refusals in the UI language.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[User imports a pet or icon] --> B[Main checks the selected file]
  B --> C[Known refusal returns code and English text]
  C --> D[Preload returns the result]
  D --> E[Renderer shows translated toast]
  B --> F[Success returns pet or icon]
  F --> D
  D --> G[Renderer saves successful result]
Loading

Reviews (1) · Last reviewed commit: "fix(i18n): translate pet import and repo..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 294477ae-7b9a-4d21-8d62-70f001c4d209
Commits

Reviewing files that changed from the base of the PR and between 7f4c8f6 and 4529e6f.

Files selected for processing: 29
  • src/main/ipc/pet-bundle-import.ts
  • src/main/ipc/pet-bundle-sprite-metadata.ts
  • src/main/ipc/pet-bundle-spritesheet-source.ts
  • src/main/ipc/pet.test.ts
  • src/main/ipc/pet.ts
  • src/main/ipc/shell.ts
  • src/preload/api/pet-api.ts
  • src/preload/api/pet-bridge.ts
  • src/preload/api/shell-api.ts
  • src/preload/api/shell-bridge.ts
  • src/renderer/src/components/pet/pet-import-failure-text.test.ts
  • src/renderer/src/components/pet/pet-import-failure-text.ts
  • src/renderer/src/components/settings/repository/identity/RepositoryIconTabs.tsx
  • src/renderer/src/components/settings/repository/identity/repo-icon-pick-failure-text.ts
  • src/renderer/src/components/status-bar/PetStatusSegment.tsx
  • src/renderer/src/i18n/en-runtime-required.json
  • src/renderer/src/i18n/locales/de.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/pt.json
  • src/renderer/src/i18n/locales/ru.json
  • src/renderer/src/i18n/locales/tr.json
  • src/renderer/src/i18n/locales/zh-Hant.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/pet-import-failure-copy.ts
  • src/shared/repo-icon-pick-failure-copy.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Walkthrough

Pet image and bundle imports now return structured failure data for recognized validation and save errors. Repository-icon selection returns structured failures for non-PNG extensions and oversized files. Preload types expose these results, and renderer components format and display failure messages. The change adds localized messages and default pet labels, with tests for pet failure text and structured import results.

Priority: Low

Merge Risk: Minimal · up to 4529e

Pet and repository-icon validation failures can be localized. No merge-blocking issue was identified.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description explains the change, motivation, testing, and visual-proof status, but it is incomplete against the required template. It omits the ELI5, Review, Agent skill upstream boundary, Notes, … Add all required template sections. Replace “Refs #32207” with the applicable issue-link format, such as “Fixes #32207”. Complete the testing and checklist items, and state whether the Agent skill upstream boundary and Notes requirements ar…
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: translating pet import and repository icon upload refusals by error code.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the change, motivation, testing, and visual-proof status, but it is incomplete against the required template. It omits the ELI5, Review, Agent skill upstream boundary, Notes, and Checklist sections, and uses “Refs #32207” instead of the required linked-issue format such as “Fixes #32207”.

Resolution

Add all required template sections. Replace “Refs #32207” with the applicable issue-link format, such as “Fixes #32207”. Complete the testing and checklist items, and state whether the Agent skill upstream boundary and Notes requirements are applicable.

Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 12 functions across 17 files. (12 skipped: 12 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@OrcaWin
OrcaWin merged commit f06cc6e into main Oct 29, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant