From 6f0e40572c7247dc2eec2aaba46eb05d2ac6c353 Mon Sep 17 00:00:00 2001 From: JoeyWu-tech Date: Tue, 27 Oct 2026 06:20:03 -0700 Subject: [PATCH] gui tests: a plugin's words are its own when said as words (#3897) yetone (#3897): i18n-keys' "a plugin's words are its own" is red on main since 7f827b3b0, with 'plugins/library/i18n.js "Runs as": internal/cli/claude_code_cli.go says it too'. claude_code_cli.go doesn't say Library's "Runs as": 7f827b3b0's comment "// fetchClaudeRuns asks the gateway at base for its Claude Code runs" holds it, across a function's name and the next word, and the check took a key found anywhere in a file's text, inside a longer word too, as said there. internal/gateway/claude_runs_test.go's "listClaudeRuns asks" holds it as well. The check now counts a plugin's word where it stands as words: a letter, digit or _ just before a key that starts with one, or just after a key that ends with one, makes it part of a longer word. A key said in a string, a comment or markup counts as before, and goes back to i18n.js. docs/subsystems/plugin-runtime.md says so. What was run (tree 26d67096, on origin/main e056779a, Node 22.22.1): - i18n-keys (Node's test runner, no browser) at e056779a, twice: "a plugin's words are its own" red with #3897's line, the other three tests ok. Here, 6 runs: 4 of 4 each. - Broken by hand in claude_code_cli.go, a line added and then removed: - "// Runs as the gateway asks.", the key said as words: red, with 'plugins/library/i18n.js "Runs as": internal/cli/claude_code_cli.go says it too'. - "// fetchClaudeRuns as the gateway asks." and "// Runs asks the gateway.", the key glued to a longer word before it or after it: 4 of 4. - No Go file is changed and no other test reads this file, so the Go suite was not run for it. Taken from JoeyWu-tech's patch on #3897 (fd49dcc0f; the format-patch sha256 matches the one posted there), cherry-picked as is onto origin/main 7dcc0aedc. Run again on mote at that head: i18n-keys 4 of 4; with "// Runs as the gateway asks." added to claude_code_cli.go by hand, red with #3897's line. --- docs/subsystems/plugin-runtime.md | 4 +++- internal/gui/tests/i18n-keys.test.cjs | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/subsystems/plugin-runtime.md b/docs/subsystems/plugin-runtime.md index 720ce969e..165446bf4 100644 --- a/docs/subsystems/plugin-runtime.md +++ b/docs/subsystems/plugin-runtime.md @@ -101,7 +101,9 @@ Each page moves in a commit of its own, whole: its code into says from i18n.js into its `i18n.js` (a key app.js, another page, index.html or Go also says stays in i18n.js). It stays so after: `i18n-keys`' "a plugin's words are its own" fails when anything outside a plugin's folder -says one of its words, which goes back to i18n.js. +says one of its words, which goes back to i18n.js. A word inside a longer +one doesn't count: a comment's "fetchClaudeRuns asks" doesn't say "Runs +as" (#3897). - **Sessions** (`plugins/sessions`, `Client: i18n.js, sessions.css, client.js`): the page that was `sessions.js`, its markup all drawn by its diff --git a/internal/gui/tests/i18n-keys.test.cjs b/internal/gui/tests/i18n-keys.test.cjs index ed21b1bb4..f1499b64e 100644 --- a/internal/gui/tests/i18n-keys.test.cjs +++ b/internal/gui/tests/i18n-keys.test.cjs @@ -50,12 +50,22 @@ test("a plugin's words are its own", () => { } }; walk(repo); + // said as words, not inside longer ones: a comment's "fetchClaudeRuns + // asks" doesn't say Library's "Runs as" (#3897) + const letter = /[\p{L}\p{N}_]/u; + const says = (s, w) => { + for (let i = s.indexOf(w); i >= 0; i = s.indexOf(w, i + 1)) { + const glued = (letter.test(w[0]) && letter.test(s[i - 1] ?? "")) || (letter.test(w.at(-1)) && letter.test(s[i + w.length] ?? "")); + if (!glued) return true; + } + return false; + }; const shared = []; for (const { file, dict } of strings().files.slice(1)) { const own = path.join(assets, path.dirname(file)) + path.sep; const rest = texts.filter(([p]) => !p.startsWith(own)); for (const k of Object.keys(dict.zh)) { - const at = rest.find(([, s]) => s.includes(k) || s.includes(JSON.stringify(k).slice(1, -1))); + const at = rest.find(([, s]) => says(s, k) || says(s, JSON.stringify(k).slice(1, -1))); if (at) shared.push(`${file} ${JSON.stringify(k)}: ${path.relative(repo, at[0])} says it too`); } }