You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(i18n): translate pet import and repo icon upload refusals by code - #35861
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.
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
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]
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: 3 · 2
Failed checks: 2 warnings
Check name
Status
Explanation
Resolution
Description check
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
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 checks: 3 passed
Check name
Status
Explanation
Title check
The title clearly identifies the main change: translating pet import and repository icon upload refusals by error code.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pet import (image and
.codex-petbundle) and repo icon upload refusals were thrown as EnglishErrors from Electron IPC, so the renderer toastedError 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 Englisherrortext 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, plusPetImportError(thrown inside main's import steps; it carries{ ok: false, error, errorCode, errorParams?, errorDetail? }),isPetImportFailure, and the stored default labelsCustom pet/Pet bundle.pet.ts,pet-bundle-import.ts,pet-bundle-sprite-metadata.ts,pet-bundle-spritesheet-source.ts: the English throws now throwPetImportError. File sizes, sheet and frame dimensions, and animation names and counts are params. The zod/JSON parse message is verbatimerrorDetail.pet:importandpet:importPetBundlereturn 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 returnsnull.components/pet/pet-import-failure-text.ts(petImportFailureText,customPetLabel) andsettings/repository/identity/repo-icon-pick-failure-text.ts. These narrow withObject.hasOwnand check each code's params. An unknown code or missing params shows the Englisherror.PetStatusSegmentandRepositoryIconTabshandle the result and keep their existingcatch.Custom petwould also show translated. This is the accepted sentinel trade-off and avoids a persisted-schema change.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 tcpassedpnpm 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-catalogand all fiveverify:localization-*checks: passedoxlinton changed files: clean;pnpm format: appliedpnpm check:changed --maxWorkers=2was 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