Skip to content

fix(desktop-service): show the crash-consent dialog in the active UI language - #858

Open
Yuncan050115 wants to merge 1 commit into
dataelement:mainfrom
Yuncan050115:fix/crash-consent-locale
Open

Yuncan050115 wants to merge 1 commit into
dataelement:mainfrom
Yuncan050115:fix/crash-consent-locale

Conversation

@Yuncan050115

@Yuncan050115 Yuncan050115 commented Nov 5, 2026 •

Copy link
Copy Markdown

Refs #855.

What

createAggregatedUploadConfirmation passes literal Chinese strings straight to dialog.showMessageBox — title, message, detail and both buttons:

title: '发送故障报告',
buttons: ['不发送', '发送一次'],

so on any non-Chinese UI the dialog that decides whether diagnostic data gets uploaded cannot be read. Unlike #844, this surface never consults a locale at all: the main process has the application-locale catalog the window-recovery prompts use, the consent dialog simply was not wired to it.

Change

src/main/desktop-service/index.ts renders the dialog through that catalog. Six crashConsent.* keys join src/main/application-locale.ts — the zh strings are kept verbatim, including the aggregation clause the existing test asserts — and a small formatApplicationText helper interpolates the per-report values (version, kind, line count, aggregation). The locale is resolved per prompt through an injected getLocale; index.ts passes the same harnessLocale the other native dialogs already use, and initializeDesktopService falls back to the machine language instead of freezing Chinese if a future caller forgets to wire it. defaultId/cancelId, the button order and approved === response === 1 keep their meaning; a dialog already open is not re-rendered mid-flight.

Test plan

  • Two new behavior cases in test/aggregated-upload-confirmation.test.ts: the English prompt carries every interpolated value and no CJK text, and a locale switch between prompts is honored. Verified red with only the three source files reverted (expected '发送故障报告' to be 'Send crash report'); the six existing zh cases — including the aggregation assertion — pass before and after.
  • vitest run test/aggregated-upload-confirmation.test.ts test/application-locale.test.ts test/window-restart-prompt.test.ts test/desktop-service.test.ts: 4 files / 59 tests passed.
  • vitest run with the same exclusions release.yml uses: 59 failed / 2724 passed against 59 failed / 2722 passed on the parent commit — failure set unchanged, delta is exactly the two new cases.
  • npm run typecheck passed; git diff --check clean.
  • Live dialog check in a packaged app: npm test's pretest (office:prepare) hits EPERM creating a LibreOffice temp dir in this environment, so build/packaging acceptance did not run here.

…language

The aggregated upload confirmation passed literal Chinese strings to
dialog.showMessageBox, so every non-Chinese locale received a consent
dialog it could not read (issue dataelement#855). This is the same surface class the
window-recovery prompts already solve through application-locale.

Route title, message, detail and both buttons through the existing
en/zh catalog, extended with crashConsent.* keys, and interpolate the
per-report values (version, kind, line count, aggregation clause) with a
new formatApplicationText helper. The factory resolves the locale per
prompt via an injected getter, so a mid-session language switch applies
to the next dialog; index.ts passes the same harnessLocale used by the
other native dialogs, and initializeDesktopService falls back to the
machine language (resolveHarnessLocale) rather than freezing Chinese
when no source is wired.

zh copy is preserved verbatim, including the aggregation clause the
existing test asserts. Adds behavior regressions: an English prompt with
interpolated values and no CJK characters, and a per-prompt re-resolution
across a locale switch. Both fail on the previous hardcoded strings.
@Yuncan050115
Yuncan050115 force-pushed the fix/crash-consent-locale branch from 1836d58 to 7bce562 Compare November 5, 2026 17:41
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