feat(providers): add recovery category taxonomy for provider error normalization#399
feat(providers): add recovery category taxonomy for provider error normalization#399mmmself wants to merge 1 commit into
Conversation
…rmalization - Add RecoveryCategory type (16 categories + unknown fallback) - Add classifyRecoveryCategory(status, code, message, wire) for error taxonomy - Add recoveryHintFor(category) returning per-category actionable hints - Extend NormalizedProviderError with recovery_category field - Tag upstream_recovery_category on IPC-bound error objects via normalizeGenerationFailure - Add extractUpstreamSystemCode helper for network error detection - Add recoveryCategory to DiagnosticHypothesis in shared diagnostics - Surface recovery category in renderer toast via buildGenerateErrorDescription - Thread wire param through normalizeProviderError → retry layer
There was a problem hiding this comment.
Review mode: initial
Findings
-
[Minor]
classifyRecoveryCategorypriority comment does not match implementation — the docstring says "Priority: status code > message patterns > network/system code > fallback" but the code checks system code before status (packages/providers/src/errors.ts:220-226). This is a documentation inconsistency that could confuse future maintainers. Update the comment to reflect actual ordering (system code > status > message patterns).Suggested fix: Change the comment to
Priority: network/system code > status code > message patterns > fallback. -
[Minor] No unit tests added for the new recovery classification logic.
classifyRecoveryCategory,recoveryHintFor,extractUpstreamSystemCode, and the updatedbuildGenerateErrorDescriptionhave no Vitest coverage. PerCLAUDE.md: "New features require at least one Vitest test." At minimum, add tests forclassifyRecoveryCategorycovering the major categories (auth, network, rate-limit, gateway, unknown) and forbuildGenerateErrorDescriptionverifying thatrecoveryCategoryappears in the output when present.Suggested fix: Add Vitest tests in
packages/providers/src/errors.test.tsandapps/desktop/src/renderer/src/store/slices/errors.test.ts. -
[Minor] The
buildGenerateErrorDescriptionfunction appends a non-i18n "Recovery: " string derived from therecoveryCategoryenum value (apps/desktop/src/renderer/src/store/slices/errors.ts:248-256). This is English-only and not passed through thetr()i18n layer. WhilerecoveryHintForprovides English hints for programmatic use, the toast display should eventually use i18n keys. Consider adding an i18n key or deferring to a future i18n pass.Suggested fix: Either use
recoveryHintFor()and pass through i18n, or mark with aTODO(i18n)comment. -
[Major] Linked issue #212 is claimed as "Implements" but the issue content is not accessible in the public repository to verify acceptance criteria against the diff. From the PR description, the changes appear to match: adding a
RecoveryCategorytaxonomy and flowing it throughnormalizeProviderError→ IPC → renderer store → toast. However, without seeing the issue's stated requirements, completeness cannot be confirmed. If the issue has additional acceptance criteria (e.g., UI test, specific recovery hints), this PR may be partial.Suggested fix: The author should verify that the issue's acceptance criteria are fully met, or change the PR body from "Implements #212" to "Refs #212" and open follow-up issues for any remaining scope. Maintainers should inspect the issue before merging.
Summary
This PR adds a structured recovery category taxonomy to provider error normalization. The core logic lives in packages/providers/src/errors.ts with new exports RecoveryCategory, classifyRecoveryCategory, and recoveryHintFor. It flows through normalizeGenerationFailure in apps/desktop/src/main/ipc/generate.ts and the renderer-side error handling in errors.ts. The implementation is directionally sound and follows project patterns. No license or dependency issues. The main gaps are missing test coverage and the linked issue completeness validation.
Testing
- Not run (automation). Recommend adding Vitest unit tests for
classifyRecoveryCategory(all 16 categories + unknown),recoveryHintFor,extractUpstreamSystemCode, and the updatedbuildGenerateErrorDescription.
Open-CoDesign Bot
Summary
Implements #212 — adds a recovery category taxonomy to provider error normalization so the UI can show targeted, actionable recovery hints instead of generic "something went wrong" messages.
What was added
packages/providers/src/errors.ts(core):RecoveryCategorytype — 16 categories +unknownfallbackclassifyRecoveryCategory(status, code, message, wire)— classifies errors by priority: HTTP status > message patterns > system code > fallbackrecoveryHintFor(category)— returns per-category human-readable recovery textNormalizedProviderErrorextended withrecovery_categoryfieldnormalizeProviderErrornow computes the recovery categoryData flow:
Files changed: 6 files, +243/-8
Verification
biome checkpasses with 0 errors, 0 warnings