Skip to content

fix(app): localize the built-in /init and /review descriptions - #61064

Open
imgusguo wants to merge 3 commits into
anomalyco:devfrom
imgusguo:localize-builtins
Open

imgusguo wants to merge 3 commits into
anomalyco:devfrom
imgusguo:localize-builtins

Conversation

@imgusguo

@imgusguo imgusguo commented Nov 1, 2026 •

Copy link
Copy Markdown

Issue for this PR

Part of #57828

Type of change

  • Bug fix

What does this PR do?

Route the built-in /init and /review descriptions through app i18n. An optional source: "builtin" marker travels from registration through the command list, so same-named user/plugin commands keep their own descriptions, even when their wording matches a built-in.

English wording is unchanged. This adds English source keys and fallback; other translations follow language review. Compaction prompts/headings and TUI localization remain separate.

How did you verify your code works?

On af2043dd, based on dev at 69269e4e, with Bun 1.4.4:

  • bun run check: lint and all 35 typecheck tasks pass.
  • Core command/command-plugin tests: 5 pass. Schema command wire test: 1 pass.
  • Chromium composer regression: 4 pass, covering order, built-in descriptions, English fallback in Chinese, custom overrides and unknown built-in names.
  • Client and Protocol bun run check:generated: pass.

The browser fixture deliberately supplies different server text for marked built-ins, so merely passing the server description through fails the assertions. This was run against the mock-server web app, not a packaged desktop build.

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" role="img" aria-label="Built-in command descriptions use the app dictionary">
  <style>
    .flow { animation: flow 2.5s ease-in-out infinite; }
    @keyframes flow { 0%,100% { opacity:.4; } 50% { opacity:1; } }
    @media (prefers-reduced-motion:reduce) { .flow { animation:none; opacity:1; } }
  </style>
  <rect x="6" y="8" width="228" height="56" rx="8" fill="none" stroke="currentColor" opacity=".35"/>
  <g fill="currentColor" font-size="11">
    <text x="16" y="29">/init</text><text x="16" y="49">/review</text>
    <text x="133" y="29">app dictionary</text><text x="133" y="49">English fallback</text>
  </g>
  <path class="flow" d="M78 36h42m-5-5 5 5-5 5" fill="none" stroke="currentColor"/>
</svg>

Screenshots / recordings

English text and layout are unchanged. A local Chromium fixture screenshot was captured for review; no packaged-desktop recording was made.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

AI assistance: Codex helped implement and verify this change.


Added by the opencode bot (AI-generated).

Related: #57828

Public API: adds optional source: "builtin" to Command.Info (HTTP/OpenAPI/client); plugin API unchanged (backwards compatible)

Route the two built-in command descriptions through the app dictionary. The
command list now carries an optional source marker so the composer can tell
a built-in command from a same-named custom one.

Part of anomalyco#57828

@opencodejr opencodejr Bot left a comment

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.

The change is small and the approach is reasonable, but I couldn't check the composer in a browser. The core command tests (5 of 5) and the schema test (1 of 1) pass, and tsc --noEmit is clean in schema, plugin, core and app. The new Playwright test couldn't run here because Chromium is missing a system library (libnspr4). Following packages/app/AGENTS.md, only English keys are added. Until translations land, every locale (including zh) shows the same English text as before, so this is the groundwork for #57828 rather than the visible fix. The issue's compaction-heading part isn't addressed.

Public API (all additions, optional, backwards compatible):

  • Command.Info (schema, OpenAPI Command.Info, generated client CommandInfo): new optional source?: "builtin".
  • Plugin CommandDefinition (effect and promise): new optional source?: "builtin".

Existing clients and plugins are unaffected. One design point is noted inline: any plugin can declare itself builtin.

Related: #57828

Comment thread packages/plugin/src/effect/command.ts Outdated
export interface CommandDefinition {
readonly name: string
readonly description?: string
readonly source?: Command.Info["source"]

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.

This makes source: "builtin" something any third-party plugin can set on its own commands, so it doesn't actually prove a command is built in. The app only checks it for init and review, so a plugin that replaces those and copies the marker would silently get the stock description. If the marker should mean "registered by OpenCode itself", it may be better for core to set it from the registering plugin's id (e.g. opencode.command) instead of trusting the definition. If letting plugins set it is intended, it's worth a line in the plugin docs.

@opencodejr opencodejr Bot left a comment

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.

The new commit fixes the earlier point. Plugin CommandDefinition no longer has source, the plugin host drops anything except name, description and execute, and only core's own command plugin sets source: "builtin". A new test covers a plugin trying to pass the marker. I ran the core command, MCP-pool and plugin tests and the schema test (all pass), and tsc --noEmit is clean in core, plugin, app and schema. The composer itself wasn't checked in a browser (Chromium couldn't start here). Since only English keys are added, the visible text is unchanged in every locale for now.

Public API: one optional addition, source?: "builtin" on Command.Info (schema, OpenAPI, generated client CommandInfo). It's backwards compatible, and the plugin API is now unchanged.

No new concerns.

@xvcezrqpbxtpzblrt

Copy link
Copy Markdown

Thanks @imgusguo — happy to help from the wording side.

One thing that would make this change visible for non-English users: as it stands the PR adds only the English source keys plus fallback, so after it merges the Chinese composer still shows "guided AGENTS.md setup" and "review changes [commit|branch|pr], defaults to uncommitted" — identical to today (the bot review reaches the same conclusion). Could the two zh-CN strings ride along in this PR, or is there a separate place where locale strings are submitted for review?

If they can land here, these are the wordings a Chinese user would expect (desktop 2.1.2, Windows 11, UI locale zh-CN):

  • command.init -> 引导式生成 AGENTS.md
  • command.review -> 审查改动 [commit|branch|pr],默认未提交的改动

I kept [commit|branch|pr] verbatim so the argument hint stays readable.

On the A vs B question from the issue: as the reporter I'm fine with B. The source: "builtin" marker is what keeps a plugin's own /init description from being overwritten by the built-in translation, and the bot review confirms it is backwards compatible and off the plugin API.

The compaction-heading half of #57828 stays with #49889 — nothing needed from you there.

This branch has not been deployed

No deployments
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.

2 participants