Skip to content

Commit ee68131

Browse files
committed
fix(webview): resolve the command exit-status tooltip key
What: CommandExecution.tsx:200 called t("chat.commandExecution.exitStatus", { exitStatus }) — a dot-form key. i18next only splits a namespace on ":", so it looks for a "chat.commandExecution.exitStatus" key inside the default namespace, misses, and renders the raw key string in the tooltip. Changed to t("chat:commandExecution.exitStatus", { exitCode }) and added a two-case regression test. Why: found while sweeping dead i18n keys. The AST pass correctly classified the dot form as a non-reference, which made the underlying key look dead and would have led to deleting a key that the UI needs. The key is live; the call site was the bug. The interpolation variable also did not match the resource ("{{exitCode}}" vs the passed exitStatus), so even a resolved lookup would have printed the literal placeholder. Impact: the exit-status tooltip now shows "Exited with status 0" instead of "chat.commandExecution.exitStatus". No other behaviour change.
1 parent 2128f5e commit ee68131

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

‎webview-ui/src/components/chat/CommandExecution.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export const CommandExecution = ({ executionId, text, icon, title, isDenied = fa
197197
{status?.status === "exited" && (
198198
<div className="flex flex-row items-center gap-2 font-mono text-xs">
199199
<StandardTooltip
200-
content={t("chat.commandExecution.exitStatus", { exitStatus: status.exitCode })}>
200+
content={t("chat:commandExecution.exitStatus", { exitCode: status.exitCode })}>
201201
<div
202202
className={cn(
203203
"rounded-full size-2",

‎webview-ui/src/components/chat/__tests__/CommandExecution.spec.tsx‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
import React from "react"
44
import { render, screen, fireEvent, act } from "@testing-library/react"
5+
import i18next from "i18next"
56

67
import { CommandExecution } from "../CommandExecution"
78
import { ExtensionStateContext } from "../../../context/ExtensionStateContext"
9+
import enChat from "../../../i18n/locales/en/chat.json"
810

911
// Mock dependencies
1012
vi.mock("react-use", () => ({
@@ -836,4 +838,38 @@ Output:
836838
expect(fragments.some((f) => f.includes("hello"))).toBe(false)
837839
})
838840
})
841+
842+
describe("exit status tooltip", () => {
843+
// The tooltip key must be written in i18next's namespace form ("ns:path").
844+
// A dot-form key ("chat.commandExecution.exitStatus") carries no namespace
845+
// separator, so i18next looks for a "chat.commandExecution.exitStatus" key
846+
// inside the default namespace, misses, and renders the raw key to the user.
847+
it("resolves the exit-status copy instead of rendering the raw key", async () => {
848+
const instance = i18next.createInstance()
849+
await instance.init({
850+
lng: "en",
851+
fallbackLng: "en",
852+
resources: { en: { chat: enChat } },
853+
interpolation: { escapeValue: false },
854+
})
855+
856+
const resolved = instance.t("chat:commandExecution.exitStatus", { exitCode: 0 })
857+
expect(resolved).toBe("Exited with status 0")
858+
expect(resolved).not.toContain("chat:commandExecution")
859+
})
860+
861+
it("does not resolve the dot form, which is why the namespace separator matters", async () => {
862+
const instance = i18next.createInstance()
863+
await instance.init({
864+
lng: "en",
865+
fallbackLng: "en",
866+
resources: { en: { chat: enChat } },
867+
interpolation: { escapeValue: false },
868+
})
869+
870+
expect(instance.t("chat.commandExecution.exitStatus", { exitCode: 0 })).toBe(
871+
"chat.commandExecution.exitStatus",
872+
)
873+
})
874+
})
839875
})

0 commit comments

Comments
 (0)