Skip to content

fix(desktop): i18n ErrorBoundary fallback strings#59

Merged
hqhq1025 merged 1 commit intomainfrom
wt/loop-fix-error-boundary-i18n-strings
Apr 19, 2026
Merged

fix(desktop): i18n ErrorBoundary fallback strings#59
hqhq1025 merged 1 commit intomainfrom
wt/loop-fix-error-boundary-i18n-strings

Conversation

@hqhq1025
Copy link
Copy Markdown
Collaborator

ErrorBoundary fallback UI shipped hardcoded English ('crashed', 'Reload', 'Copy stack', body, '(no stack)') that bypassed the i18n layer — same pattern codex flagged on PRs #35, #47, #48, #49. Adds errorBoundary.* keys (en + zh-CN) and routes the fallback render through useT() via a function child component (since ErrorBoundary is class-based).

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • [Minor] Missing regression test for localized ErrorBoundary fallback copy — this PR replaces hardcoded fallback text with i18n keys, but no Vitest coverage was added to lock this behavior. Without a test, hardcoded strings or missing keys can regress silently. Evidence: apps/desktop/src/renderer/src/components/ErrorBoundary.tsx:107, apps/desktop/src/renderer/src/components/ErrorBoundary.tsx:113, packages/i18n/src/locales/en.json:375, packages/i18n/src/locales/zh-CN.json:374.
    Suggested fix:
    // apps/desktop/src/renderer/src/components/ErrorBoundary.test.tsx
    it('renders localized fallback copy when child throws', () => {
      const Boom = () => {
        throw new Error('boom');
      };
    
      render(
        <I18nProvider locale="en">
          <ErrorBoundary scope="Preview">
            <Boom />
          </ErrorBoundary>
        </I18nProvider>
      );
    
      expect(screen.getByText('Preview crashed')).toBeInTheDocument();
      expect(screen.getByRole('button', { name: 'Reload' })).toBeInTheDocument();
      expect(screen.getByRole('button', { name: 'Copy stack' })).toBeInTheDocument();
    });

Summary

  • Review mode: initial
  • 1 issue found (test coverage gap for this behavior change).
  • Context limit: docs/VISION.md and docs/PRINCIPLES.md were not found in repo/docs.

Testing

  • Not run (automation)

open-codesign Bot

onReset,
onCopyStack,
}: ErrorBoundaryFallbackProps): ReactNode {
const t = useT();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Minor] Please add a Vitest regression test for this fallback path now that copy is i18n-driven. This guards against accidental reintroduction of hardcoded strings and missing locale keys for the error UI.

Suggested fix:

it('renders localized fallback copy when child throws', () => {
  const Boom = () => {
    throw new Error('boom');
  };

  render(
    <I18nProvider locale="en">
      <ErrorBoundary scope="Preview">
        <Boom />
      </ErrorBoundary>
    </I18nProvider>
  );

  expect(screen.getByText('Preview crashed')).toBeInTheDocument();
  expect(screen.getByRole('button', { name: 'Reload' })).toBeInTheDocument();
  expect(screen.getByRole('button', { name: 'Copy stack' })).toBeInTheDocument();
});

@hqhq1025 hqhq1025 merged commit 153d261 into main Apr 19, 2026
5 of 6 checks passed
@hqhq1025 hqhq1025 deleted the wt/loop-fix-error-boundary-i18n-strings branch April 19, 2026 04:31
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