Compare commits

...
Author SHA1 Message Date
l0ng-ai e3764a7c96 feat(terminal): option to use the application title as the tab name always
The title a program sets (OSC 0/2) named the tab only while a command ran,
so a CLI agent's own title didn't show when shell integration couldn't tell
a command was running. Settings › Terminal now has IDEA's "Use application
title as tab name": When command is running (default), Always, or Never.
2026-11-19 17:43:56 +08:00
9 changed files with 54 additions and 4 deletions

No files matched your search

+4
View File
@@ -448,6 +448,9 @@ pub struct TerminalSettings {
/// Shell command line; empty = the login shell.
pub shell_path: String,
pub tab_name: String,
/// Title a program sets (OSC 0/2) as the tab's name: `running` (while a command runs),
/// `always`, or `off`.
pub app_title_as_tab_name: String,
pub audible_bell: bool,
pub close_on_exit: bool,
pub mouse_reporting: bool,
@@ -483,6 +486,7 @@ impl Default for TerminalSettings {
env: BTreeMap::new(),
shell_path: String::new(),
tab_name: "Local".into(),
app_title_as_tab_name: "running".into(),
audible_bell: true,
close_on_exit: true,
mouse_reporting: true,
+5
View File
@@ -11613,6 +11613,11 @@ export type TerminalSettings = {
/** Shell command line; empty = the login shell. */
shellPath?: string,
tabName?: string,
/**
* Title a program sets (OSC 0/2) as the tab's name: `running` (while a command runs),
* `always`, or `off`.
*/
appTitleAsTabName?: string,
audibleBell?: boolean,
closeOnExit?: boolean,
mouseReporting?: boolean,
+11
View File
@@ -33,6 +33,11 @@ const SEND_KEY_OPTIONS = [
{ value: "enter", label: "Enter" },
{ value: "modEnter", label: "⌘Enter" },
];
const APP_TITLE_OPTIONS = [
{ value: "running", label: "When command is running" },
{ value: "always", label: "Always" },
{ value: "off", label: "Never" },
];
const WHILE_RUNNING_OPTIONS = [
{ value: "queue", label: "Queues the message for after the turn" },
{ value: "steer", label: "Sends it into the turn" },
@@ -601,6 +606,12 @@ export const TOOLS_PAGES: PageSpec[] = [
options: [
{ kind: "custom", label: "Shell path", component: ShellPathRow },
{ kind: "text", key: "terminal.tabName", label: "Default Tab name", placeholder: "Local" },
{
kind: "select",
key: "terminal.appTitleAsTabName",
label: "Use application title as tab name",
options: APP_TITLE_OPTIONS,
},
{
kind: "custom",
label: "Audible bell",
+7 -2
View File
@@ -176,10 +176,15 @@ export function trimMiddle(text: string, max: number): string {
const APP_TITLE_MAX = 30;
/** The title the program in the tab set, while a command runs (at the prompt it is the shell's own). */
/**
* The title the program in the tab set (OSC 0/2), per Settings › Terminal: by default only
* while a command runs (at the prompt it is the shell's own), as IDEA does.
*/
function appTitle(tab: TerminalTab, sessions?: Record<string, SessionSnapshot>): string | null {
const s = sessions?.[tab.session];
return s?.commandRunning ? s.appTitle : null;
const when = workflowSettings().terminal.appTitleAsTabName;
if (!s?.appTitle || when === "off") return null;
return when === "always" || s.commandRunning ? s.appTitle : null;
}
/**
+15
View File
@@ -17,6 +17,8 @@ import {
} from "./store";
import type { SessionSnapshot } from "./session";
import { usePlatform } from "@/platform/platformInfo";
import { useProject } from "@/platform/project";
import type { Settings } from "@/bindings";
import { buildTheme, mix, parseColor, terminalFont, toHex } from "./theme";
describe("theme", () => {
@@ -476,6 +478,19 @@ describe("terminal tab titles", () => {
expect(tabFullTitle(tab, snap(long))).toBe(long);
});
it("uses the program's title always or never, per Settings › Terminal", () => {
const set = (appTitleAsTabName: string) =>
useProject.setState({ settings: { terminal: { appTitleAsTabName } } as unknown as Settings });
try {
set("always");
expect(tabTitle(tab, snap("claude", false))).toBe("claude");
set("off");
expect(tabTitle(tab, snap("vim notes.md"))).toBe("Local");
} finally {
useProject.setState({ settings: null });
}
});
it("keeps a name the user gave the tab", () => {
const renamed = { ...tab, customName: "Server" };
expect(tabTitle(renamed, snap("top"))).toBe("Server");
+1
View File
@@ -56,6 +56,7 @@ export const CLIENT_SETTINGS_KEYS = [
"editor.general.richTextCopy",
"editor.codeStyle.visualGuides",
"terminal.tabName",
"terminal.appTitleAsTabName",
"terminal.audibleBell",
"terminal.closeOnExit",
"terminal.mouseReporting",
+3 -1
View File
@@ -2632,5 +2632,7 @@
"Updated {n} branch": "Updated {n} branch",
"Updated {n} branches": "Updated {n} branches",
"No branches were updated": "No branches were updated",
"Selected branches are up-to-date": "Selected branches are up-to-date"
"Selected branches are up-to-date": "Selected branches are up-to-date",
"Use application title as tab name": "Use application title as tab name",
"When command is running": "When command is running"
}
+3 -1
View File
@@ -9011,5 +9011,7 @@
"Updated {n} branch": "已更新 {n} 个分支",
"Updated {n} branches": "已更新 {n} 个分支",
"No branches were updated": "没有分支被更新",
"Selected branches are up-to-date": "所选分支都是最新的"
"Selected branches are up-to-date": "所选分支都是最新的",
"Use application title as tab name": "使用应用标题作为标签页名称",
"When command is running": "命令运行时"
}
+5
View File
@@ -140,6 +140,8 @@ export interface ExternalDiffValid {
}
export type TerminalMaxFps = "unlimited" | "60" | "30" | "15" | "10";
/** When a title the program sets (OSC 0/2) names the terminal tab, as IDEA's option. */
export type TerminalAppTitle = "running" | "always" | "off";
export const TERMINAL_MAX_FPS_OPTIONS: readonly { value: TerminalMaxFps; label: string }[] = [
{ value: "unlimited", label: "Unlimited" },
@@ -154,6 +156,7 @@ export interface TerminalSettingsValid {
env: Record<string, string>;
shellPath: string;
tabName: string;
appTitleAsTabName: TerminalAppTitle;
audibleBell: boolean;
closeOnExit: boolean;
mouseReporting: boolean;
@@ -361,6 +364,7 @@ export const DEFAULT_WORKFLOW: WorkflowSettings = {
env: {},
shellPath: "",
tabName: "Local",
appTitleAsTabName: "running",
audibleBell: true,
closeOnExit: true,
mouseReporting: true,
@@ -570,6 +574,7 @@ export function validateTerminal(raw: unknown): TerminalSettingsValid {
env,
shellPath: text(v.shellPath, d.shellPath).trim(),
tabName: nonEmpty(v.tabName, d.tabName),
appTitleAsTabName: oneOf(v.appTitleAsTabName, ["running", "always", "off"] as const, d.appTitleAsTabName),
audibleBell: bool(v.audibleBell, d.audibleBell),
closeOnExit: bool(v.closeOnExit, d.closeOnExit),
mouseReporting: bool(v.mouseReporting, d.mouseReporting),