@devries-cameron20 / t3code Mirror · read-only / commits / 759a173e15
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 07:15 UTC

fix(web): idle numbered terminals show their name in the app language (#38565)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Wout Stiens committed Nov 18, 2026 at 12:56 UTC 759a173e1576d1d78fb04d16580fdf9641c80c30
3 files changed +73 -5
packages/shared/src/terminalLabels.test.ts
+21
@@ -2,11 +2,32 @@ import { describe, expect, it } from "vite-plus/test";
2
3 import { DEFAULT_TERMINAL_ID, TerminalOpenInput } from "@t3tools/contracts";
4 import * as Schema from "effect/Schema";
5 +import { mFallback } from "gt-i18n";
6 +import type { MFunctionType } from "gt-i18n/types";
7
8 import { getTerminalLabel, nextTerminalId } from "./terminalLabels.ts";
9 +import { resolveTerminalSessionLabel } from "./terminalLabelsCopy.ts";
10
11 const decodeTerminalOpen = Schema.decodeUnknownSync(TerminalOpenInput);
12
13 +const japanese: MFunctionType = (encodedMsg, options) => {
14 + const english = mFallback(encodedMsg, options);
15 + return (
16 + typeof english === "string" ? english.replace("Terminal", "ターミナル") : english
17 + ) as typeof english;
18 +};
19 +
20 +describe("resolveTerminalSessionLabel", () => {
21 + it("translates the idle default and keeps process names", () => {
22 + const resolve = (label: string, hasRunningSubprocess: boolean) =>
23 + resolveTerminalSessionLabel("term-2", { label, hasRunningSubprocess }, japanese);
24 + expect(resolve("Terminal 2", false)).toBe("ターミナル 2");
25 + expect(resolve(" ", false)).toBe("ターミナル 2");
26 + expect(resolve("sleep", true)).toBe("sleep");
27 + expect(resolve("Terminal 2", true)).toBe("Terminal 2");
28 + });
29 +});
30 +
31 describe("nextTerminalId", () => {
32 it("skips over taken term-N slots", () => {
33 expect(nextTerminalId([DEFAULT_TERMINAL_ID, "term-2", "term-3"])).toBe("term-4");
packages/shared/src/terminalLabelsCopy.ts
+10 -5
@@ -2,7 +2,7 @@ import type { TerminalSummary } from "@t3tools/contracts";
2 import { mFallback, msg } from "gt-i18n";
3 import type { MFunctionType } from "gt-i18n/types";
4
5 -import { terminalNumber } from "./terminalLabels.ts";
5 +import { getTerminalLabel as getServerTerminalLabel, terminalNumber } from "./terminalLabels.ts";
6
7 /** @public */
8 export function getTerminalLabel(terminalId: string, resolve: MFunctionType = mFallback): string {
@@ -10,12 +10,17 @@ export function getTerminalLabel(terminalId: string, resolve: MFunctionType = mF
10 return numericSuffix ? resolve(msg("Terminal {number}", { number: numericSuffix })) : terminalId;
11 }
12
13 -/** @public */
13 +/**
14 + * The server sends the running process name, or its English idle default, which is shown translated.
15 + * @public
16 + */
17 export function resolveTerminalSessionLabel(
18 terminalId: string,
16 - summary: Pick<TerminalSummary, "label"> | null | undefined,
19 + summary: Pick<TerminalSummary, "label" | "hasRunningSubprocess"> | null | undefined,
20 resolve: MFunctionType = mFallback,
21 ): string {
19 - const trimmed = summary?.label?.trim();
20 - return trimmed && trimmed.length > 0 ? trimmed : getTerminalLabel(terminalId, resolve);
22 + const trimmed = summary?.label.trim();
23 + const isIdleDefault =
24 + !summary?.hasRunningSubprocess && trimmed === getServerTerminalLabel(terminalId);
25 + return trimmed && !isIdleDefault ? trimmed : getTerminalLabel(terminalId, resolve);
26 }
scripts/scenarios/idle-terminal-label-follows-language.e2e.ts new
+42
@@ -0,0 +1,42 @@
1 +import { expect } from "e2e";
2 +
3 +import { test, WEB } from "./t3.ts";
4 +
5 +test(
6 + "An idle numbered terminal shows its name in the app's language after switching threads",
7 + WEB,
8 + async ({ t3, app, browser, screen }) => {
9 + const project = await t3.project("demo");
10 + const thread = await t3.thread({ project, title: "Terminal work", messages: ["Start"] });
11 + await t3.thread({ project, title: "Other work", messages: ["Start"] });
12 +
13 + await t3.open("/settings/general");
14 + await screen.getByLabel("Language", { exact: true }).tap();
15 + await screen.getByText("日本語", { exact: true }).tap();
16 + await screen.getByLabel("言語", { exact: true }).waitFor();
17 +
18 + await t3.open(thread);
19 + const drawerToggle = screen.getByRole("button", "ターミナルドロワーの切り替え");
20 + await drawerToggle.tap();
21 + const input = browser.locator('[aria-label="ターミナルの入力"][data-workspace-focus-default]');
22 + await input.waitFor();
23 + await screen.getByRole("button", /^新しいターミナル(?: \(|$)/).tap();
24 + const secondTerminal = screen.getByRole("button", /^(?:Terminal 2|ターミナル 2)$/);
25 + await secondTerminal.waitFor();
26 + await screen.getByRole("button", "Other work", { exact: false }).tap();
27 + await screen.getByRole("button", "Terminal work", { exact: false }).tap();
28 +
29 + // Wait for a real process label so the idle assertion reads server metadata, not the fallback
30 + // shown while the second terminal is opening.
31 + await secondTerminal.tap();
32 + await input.focus();
33 + await browser.keyboard.type("sleep 60\n");
34 + await screen.getByRole("button", "sleep", { exact: true }).waitFor({ timeout: 40_000 });
35 + await input.focus();
36 + await browser.keyboard.press("Control+C");
37 + await secondTerminal.waitFor({ timeout: 40_000 });
38 +
39 + await app.screenshot("idle-terminal-after-switch");
40 + await expect(secondTerminal).toHaveText("ターミナル 2");
41 + },
42 +);