Conversation
|
|
Addressed the automated review findings (a92c175b):
Tests: 380/380 green (376 baseline + 4 new). |
…vior change) hermes-bots hardcodes every user-visible string, which blocks the zh-CN localization requested in NousResearch#91336. This commit lays the plumbing, mirroring the kanban plugin's pattern: - Inline BOTS_EN message template + BOTS_LOCALES bundle (plugin.js is the single-file bundle — sibling imports break the direct-file plugin loader and the .mjs test harness, so the en template lives inline). - ctx.i18n.register(BOTS_LOCALES) at load, guarded for pre-NousResearch#67303 hosts that lack plugin i18n. - useBots() binds the en template through sdk.usePluginI18n when available and falls back to the en template verbatim otherwise, so every rendered string is byte-identical to what it replaced. - Rewires the issue's named surfaces — Bots pane header, New Agent dialog (incl. Advanced tabs), Edit Profile dialog, bot context menu, delete confirmation, and the /new->/compact composer notice — from hardcoded literals to bundle lookups. Follow-up PRs add the zh locale bundle (and other languages) once this plumbing is reviewed. Refs NousResearch#91336
…contract Addresses review feedback on NousResearch#91489: - Move the surviving hardcoded strings into BOTS_EN — pin/unpin context menu item (menu.pin/menu.unpin), empty-state description, delete doneLabel, draft-cleanup failure, roster-unavailable error, roster search field (aria + placeholder), and the static export name/ description (sourced from the bundle; static metadata has no translator, noted in a comment). Renders stay byte-identical. - Document the remaining out-of-scope surfaces in a TODO list beside BOTS_LOCALES (group chat UI, cron UI, avatar editor, prompts, etc.). - useBots(): memoize the bound tree on the translator identity (useMemo(..., [t]), mirroring kanban's useKanban) so components no longer rebuild function identities on every render. - Add plugin-i18n.test.mjs contract tests: function-valued bundle leaves + positional args are the documented contract (NousResearch#67303 body and apps/desktop/src/i18n/plugin-i18n.ts PluginMessageValue/translateFrom), verified end-to-end on a stub host whose t receives args; verbatim en-template fallback without the feature; useBots memoization.
a92c175 to
97d62e3
Compare
|
Thanks @Finn763 — this landed on main through #113430 (fix(bot-mode): roster menu and group row speak the active language (#91667, #108978, salva), merged as 4d46d76. Your commits/analysis were carried in with credit (see that PR's body and Co-authored-by trailers); the salvage rebased onto current main, widened to sibling surfaces where the review found gaps, and was live-verified in the real Electron app. Closing this one as superseded — thank you for the fix. |
Context
The hermes-bots plugin (Bot Mode) hardcodes every user-visible string, which blocks the zh-CN localization requested in #91336. This PR lays the i18n plumbing; locale bundles land in follow-up PRs once the plumbing is reviewed.
Approach
Mirrors the kanban plugin's i18n pattern (#67303), with one deliberate difference — the en template lives inline in plugin.js:
BOTS_ENmessage template +BOTS_LOCALES = { en: BOTS_EN }bundle, defined inline.ctx.i18n.register(BOTS_LOCALES)at load, guarded — hosts predating plugin i18n (and the test sandbox, which strips the SDK import) don't crash.useBots()binds the en template throughsdk.usePluginI18n('hermes-bots')when available; otherwise it returns the en template verbatim, so every rendered string is byte-identical to the hardcoded literal it replaced./new→/compactcomposer middleware inregister(ctx)) usesctx.i18n.twith the same en-template fallback.Surfaces rewired
/new→/compactreroute noticeVerification
npm run typecheck(tsc -p ., tsconfig.electron.json, tsconfig.e2e.json) — all greennode --test apps/desktop/src/plugins/hermes-bots/tests/*.test.mjs— 376/376 pass (5 source-shape assertions updated in this PR to match the new bundle-lookup form; behavior tests get auseBotsstub since they never assert label text)Follow-up
Refs #91336
Rebase note
Rebased onto main @ 2026-08-23T23:34Z 解决合并冲突(冲突文件:apps/desktop/src/plugins/hermes-bots/plugin.js、apps/desktop/src/plugins/hermes-bots/tests/active-now-strip.test.mjs、apps/desktop/src/plugins/hermes-bots/tests/bot-delete.test.mjs、apps/desktop/src/plugins/hermes-bots/tests/hide-bots.test.mjs、apps/desktop/src/plugins/hermes-bots/tests/bots-search.test.mjs)。无行为变化。
Resolution notes for reviewers:
ensureBotMetadatacontext-menu actions, roster toolbar with gateway/activity filters, Hidden-section model); the i18n lookups were carried onto those structures.pinStayHintbundle key removed — main deleted the remote-row "stay pinned" toast, so the key had no call sites left.k.create.creating/k.create.createAgent; profile-prewarm.test.mjs i18n stub lint fix; plugin-i18n.test.mjs expectations updated for the renamed copy.npm run typecheckgreen (tsc -p ., tsconfig.electron.json, tsconfig.e2e.json);node --test src/plugins/hermes-bots/tests/*.test.mjs530/530 pass; vitest (dock-enforce, hide-only-strip-tabs, runtime-loader) 24/24 pass; eslint on hermes-bots clean.