From e4ac29486cc8ce2e1693a9d3a5cfbd01452ef352 Mon Sep 17 00:00:00 2001 From: Vadim Lazuk Date: Mon, 16 Nov 2026 20:19:42 +0300 Subject: [PATCH] feat(terminal): notify when a long-running command finishes (#3758) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A command run in the integrated terminal gave no sign of finishing once its tab could not be seen. The shell integration now writes the exit status with the OSC 133 end mark (zsh, bash, fish); a session reports a started command's duration, status and whether Ctrl-C stopped it. When the tab cannot be seen, a finished command raises a balloon in a new terminal group (and so an OS notification in the background): long-running ones by default (10 s threshold), all, or none, set in Settings › Notifications › Terminal. A non-zero exit always reports its code. The balloon's Show action focuses the tab; tabs with an unseen finished command show a dot until focused. Co-authored-by: Inf1mum <8135225+Inf1mum@users.noreply.github.com> --- crates/ide-core/src/settings.rs | 21 +- crates/ide-terminal/src/integration.rs | 21 +- docs/en/reference/settings.mdx | 16 +- docs/zh/reference/settings.mdx | 16 +- src/bindings.ts | 4 + .../settings/__tests__/behavior.test.ts | 12 + src/features/settings/model/behaviorSchema.ts | 15 ++ src/features/settings/pages/behavior.tsx | 27 +- src/features/terminal/TerminalView.tsx | 8 + src/features/terminal/cli.ts | 11 + src/features/terminal/cliSessions.ts | 44 ++- src/features/terminal/completion.test.ts | 253 ++++++++++++++++++ src/features/terminal/completion.ts | 82 ++++++ src/features/terminal/index.ts | 5 +- src/features/terminal/session.ts | 63 ++++- src/features/terminal/store.ts | 30 +++ src/features/terminal/terminal.test.ts | 2 +- src/platform/locales/text/en.json | 9 +- src/platform/locales/text/zh.json | 8 +- src/workbench/contributions.ts | 2 +- src/workbench/notificationStore.ts | 1 + 21 files changed, 618 insertions(+), 32 deletions(-) create mode 100644 src/features/terminal/completion.test.ts create mode 100644 src/features/terminal/completion.ts diff --git a/crates/ide-core/src/settings.rs b/crates/ide-core/src/settings.rs index 6901ef87c..fe11c58e0 100644 --- a/crates/ide-core/src/settings.rs +++ b/crates/ide-core/src/settings.rs @@ -653,6 +653,10 @@ pub struct NotificationSettings { /// Mirror balloon notifications to the OS when no OpenIDEA window is focused. #[serde(default = "default_true")] pub system_notifications: bool, + /// Terminal command completions (#3712): `off` | `longRunning` | `all`. + pub terminal_completion: String, + /// `longRunning`: the run time a finished command must reach, in seconds. + pub terminal_threshold_seconds: u32, /// Group id → display; groups not listed use their default. pub groups: BTreeMap, } @@ -661,9 +665,24 @@ fn default_true() -> bool { true } +fn default_terminal_completion() -> String { + "longRunning".to_owned() +} + +fn default_terminal_threshold_seconds() -> u32 { + 10 +} + impl Default for NotificationSettings { fn default() -> Self { - Self { balloons: true, sound: false, system_notifications: true, groups: BTreeMap::new() } + Self { + balloons: true, + sound: false, + system_notifications: true, + terminal_completion: default_terminal_completion(), + terminal_threshold_seconds: default_terminal_threshold_seconds(), + groups: BTreeMap::new(), + } } } diff --git a/crates/ide-terminal/src/integration.rs b/crates/ide-terminal/src/integration.rs index 0b96fc672..eea63e7a7 100644 --- a/crates/ide-terminal/src/integration.rs +++ b/crates/ide-terminal/src/integration.rs @@ -2,7 +2,9 @@ //! shell reports its working directory (OSC 7) at every prompt, so links and //! new splits resolve against the directory the user `cd`-ed into, and marks //! where a command starts and ends (OSC 133 C / D), so the tab shows the -//! running program's title only while one runs. +//! running program's title only while one runs. The end mark carries the +//! command's exit status (`OSC 133;D;`), so a finished long-running +//! command can be reported as finished or failed. //! //! zsh starts with `ZDOTDIR` pointing at generated startup files that source //! the user's own ones first; bash gets an `--init-file` that replays the @@ -34,7 +36,7 @@ ZDOTDIR=$OPENIDEA_USER_ZDOTDIR [[ -f $ZDOTDIR/.zshrc ]] && . $ZDOTDIR/.zshrc OPENIDEA_USER_ZDOTDIR=$ZDOTDIR ZDOTDIR=$_openidea_dir -_openidea_osc7() { printf '\e]133;D\a\e]7;file://%s%s\a' "${HOST}" "${PWD}" } +_openidea_osc7() { printf '\e]133;D;%s\a\e]7;file://%s%s\a' "$?" "${HOST}" "${PWD}" } _openidea_preexec() { printf '\e]133;C\a' } # First, so the command counts as finished before other hooks set the prompt's title. precmd_functions=(_openidea_osc7 ${precmd_functions:#_openidea_osc7}) @@ -68,7 +70,7 @@ if [ "${OPENIDEA_LOGIN:-}" = 1 ]; then else [ -f ~/.bashrc ] && . ~/.bashrc fi -__openidea_osc7() { printf '\e]133;D\a\e]7;file://%s%s\a' "${HOSTNAME}" "${PWD}"; } +__openidea_osc7() { printf '\e]133;D;%s\a\e]7;file://%s%s\a' "$?" "${HOSTNAME}" "${PWD}"; } case ";${PROMPT_COMMAND:-};" in *";__openidea_osc7;"*) ;; *) PROMPT_COMMAND="__openidea_osc7${PROMPT_COMMAND:+;$PROMPT_COMMAND}" ;; @@ -81,7 +83,7 @@ esac "#; const FISH_INIT: &str = concat!( - r#"function __openidea_osc7 --on-event fish_prompt; printf '\e]133;D\a\e]7;file://%s%s\a' (hostname) $PWD; end; "#, + r#"function __openidea_osc7 --on-event fish_prompt; printf '\e]133;D;%s\a\e]7;file://%s%s\a' "$status" (hostname) $PWD; end; "#, r#"function __openidea_preexec --on-event fish_preexec; printf '\e]133;C\a'; end"#, ); @@ -166,6 +168,17 @@ pub(crate) fn apply(shell_name: &str, args: &mut Vec, env: &mut BTreeMap mod tests { use super::*; + #[test] + fn command_end_reports_the_exit_status() { + // The D mark carries the shell's exit status (`OSC 133;D;`), so + // a finished long-running command can be told from a failed one. + // zsh and bash read `$?`, fish `$status`, each at hook entry before any + // other command runs. + assert!(ZSHRC.contains(r"\e]133;D;%s\a") && ZSHRC.contains("\"$?\"")); + assert!(BASHRC.contains(r"\e]133;D;%s\a") && BASHRC.contains("\"$?\"")); + assert!(FISH_INIT.contains(r"\e]133;D;%s\a") && FISH_INIT.contains("\"$status\"")); + } + #[test] fn powershell_clear_integration_only_changes_plain_windows_starts() { for shell in ["pwsh", "powershell", "PwSh"] { diff --git a/docs/en/reference/settings.mdx b/docs/en/reference/settings.mdx index 33911969c..ea47c4b55 100644 --- a/docs/en/reference/settings.mdx +++ b/docs/en/reference/settings.mdx @@ -152,13 +152,15 @@ Sub-tables such as `[editor.general]`, `[editor.appearance]`, `[editor.completio ### `[notifications]` -| Key | Default | Description | -| --------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `balloons` | `true` | **Display balloon notifications**. | -| `sound` | `false` | **Play sound**. | -| `systemNotifications` | `true` | **Enable system notifications**. When a balloon is shown and no OpenIDEA window is focused, the same title and text also go to the OS notification centre. On by default; client/local only. Click focuses the window that raised the toast; balloon actions stay in the IDE. **Windows:** a click is reported only while the toast is on screen, not after it moves to Action Center. Desktop `permission_state` always reports Granted without an OS prompt — that is not proof Do Not Disturb or system notification settings allow delivery. | -| `groups..display` | `"balloon"` | Popup type per group: `balloon`, `sticky` or `none`. | -| `groups..log` | `true` | Also list the notification in the Notifications tool window. | +| Key | Default | Description | +| --------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `balloons` | `true` | **Display balloon notifications**. | +| `sound` | `false` | **Play sound**. | +| `systemNotifications` | `true` | **Enable system notifications**. When a balloon is shown and no OpenIDEA window is focused, the same title and text also go to the OS notification centre. On by default; client/local only. Click focuses the window that raised the toast; balloon actions stay in the IDE. **Windows:** a click is reported only while the toast is on screen, not after it moves to Action Center. Desktop `permission_state` always reports Granted without an OS prompt — that is not proof Do Not Disturb or system notification settings allow delivery. | +| `terminalCompletion` | `"longRunning"` | **Notify when a terminal command finishes**: `off`, `longRunning` (only commands that ran at least `terminalThresholdSeconds`) or `all`. Only commands in a terminal tab that cannot be seen notify; a command stopped with Ctrl-C, shell startup and short commands stay quiet, a non-zero exit reports its code. Client/local only. | +| `terminalThresholdSeconds` | `10` | The run time a command must reach to count as long-running. | +| `groups..display` | `"balloon"` | Popup type per group: `balloon`, `sticky` or `none`. | +| `groups..log` | `true` | Also list the notification in the Notifications tool window. | ### `[terminal]` diff --git a/docs/zh/reference/settings.mdx b/docs/zh/reference/settings.mdx index eda7ccc1b..6ff007552 100644 --- a/docs/zh/reference/settings.mdx +++ b/docs/zh/reference/settings.mdx @@ -152,13 +152,15 @@ exclude = ["**/.git", "**/node_modules", "**/target", "**/dist"] ### `[notifications]` -| 键 | 默认值 | 说明 | -| --------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `balloons` | `true` | **显示气球通知**。 | -| `sound` | `false` | **播放声音**。 | -| `systemNotifications` | `true` | **启用系统通知**。气球通知显示且没有任何 OpenIDEA 窗口处于焦点时,相同的标题和正文也会发到操作系统通知中心。默认开启;仅客户端/本机设置。点击会聚焦发出该通知的窗口;气球操作仍只在 IDE 内。**Windows:**仅在 toast 仍显示在屏幕上时可收到点击,进入操作中心后不再触发。桌面端 `permission_state` 始终返回 Granted 且不会弹出系统授权——这并不表示勿扰模式或系统通知设置允许显示。 | -| `groups..display` | `"balloon"` | 每个分组的弹出方式:`balloon`、`sticky` 或 `none`。 | -| `groups..log` | `true` | 同时在通知工具窗口中列出。 | +| 键 | 默认值 | 说明 | +| --------------------------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `balloons` | `true` | **显示气球通知**。 | +| `sound` | `false` | **播放声音**。 | +| `systemNotifications` | `true` | **启用系统通知**。气球通知显示且没有任何 OpenIDEA 窗口处于焦点时,相同的标题和正文也会发到操作系统通知中心。默认开启;仅客户端/本机设置。点击会聚焦发出该通知的窗口;气球操作仍只在 IDE 内。**Windows:**仅在 toast 仍显示在屏幕上时可收到点击,进入操作中心后不再触发。桌面端 `permission_state` 始终返回 Granted 且不会弹出系统授权——这并不表示勿扰模式或系统通知设置允许显示。 | +| `terminalCompletion` | `"longRunning"` | **终端命令结束时的通知**:`off`、`longRunning`(仅运行至少 `terminalThresholdSeconds` 的命令)或 `all`。只有看不见的终端标签页中的命令会通知;Ctrl-C 停止的命令、shell 启动和短命令保持安静,非零退出会报告退出代码。仅客户端/本机设置。 | +| `terminalThresholdSeconds` | `10` | 命令被算作长时间运行所需达到的运行时间。 | +| `groups..display` | `"balloon"` | 每个分组的弹出方式:`balloon`、`sticky` 或 `none`。 | +| `groups..log` | `true` | 同时在通知工具窗口中列出。 | ### `[terminal]` diff --git a/src/bindings.ts b/src/bindings.ts index 69c737b74..ae8dfb4c0 100644 --- a/src/bindings.ts +++ b/src/bindings.ts @@ -8222,6 +8222,10 @@ export type NotificationSettings = { sound?: boolean, /** Mirror balloon notifications to the OS when no OpenIDEA window is focused. */ systemNotifications?: boolean, + /** Terminal command completions (#3712): `off` | `longRunning` | `all`. */ + terminalCompletion?: string, + /** `longRunning`: the run time a finished command must reach, in seconds. */ + terminalThresholdSeconds?: number, /** Group id → display; groups not listed use their default. */ groups?: { [key in string]: NotificationGroupSettings }, }; diff --git a/src/features/settings/__tests__/behavior.test.ts b/src/features/settings/__tests__/behavior.test.ts index 4276b7788..553f270bc 100644 --- a/src/features/settings/__tests__/behavior.test.ts +++ b/src/features/settings/__tests__/behavior.test.ts @@ -157,9 +157,21 @@ describe("appearance & behavior settings", () => { balloons: true, sound: false, systemNotifications: true, + terminalCompletion: "longRunning", + terminalThresholdSeconds: 10, groups: { vcs: { display: "balloon", log: false } }, }); expect(validateNotifications({ systemNotifications: false }).systemNotifications).toBe(false); + expect(validateNotifications({ terminalCompletion: "sometimes", terminalThresholdSeconds: "10" })).toMatchObject({ + terminalCompletion: "longRunning", + terminalThresholdSeconds: 10, + }); + // Out-of-range numbers clamp, as every numeric setting does. + expect(validateNotifications({ terminalThresholdSeconds: 0 }).terminalThresholdSeconds).toBe(1); + expect(validateNotifications({ terminalCompletion: "all", terminalThresholdSeconds: 5 })).toMatchObject({ + terminalCompletion: "all", + terminalThresholdSeconds: 5, + }); }); }); diff --git a/src/features/settings/model/behaviorSchema.ts b/src/features/settings/model/behaviorSchema.ts index 463fb616b..7d61202ef 100644 --- a/src/features/settings/model/behaviorSchema.ts +++ b/src/features/settings/model/behaviorSchema.ts @@ -105,11 +105,18 @@ export interface NotificationGroupValid { log: boolean; } +/** When a finished terminal command notifies (#3712, Settings › Notifications › Terminal). */ +export type TerminalCompletionMode = "off" | "longRunning" | "all"; + export interface NotificationsValid { balloons: boolean; sound: boolean; /** Mirror balloon notifications to the OS when no OpenIDEA window is focused. */ systemNotifications: boolean; + /** Terminal command completions: off, long-running ones only (default), or every one. */ + terminalCompletion: TerminalCompletionMode; + /** Mode `longRunning`: the run time a command must reach, in seconds. */ + terminalThresholdSeconds: number; groups: Record; } @@ -166,6 +173,8 @@ export const DEFAULT_NOTIFICATIONS: NotificationsValid = { balloons: true, sound: false, systemNotifications: true, + terminalCompletion: "longRunning", + terminalThresholdSeconds: 10, groups: {}, }; @@ -180,6 +189,7 @@ const int = (v: unknown, d: number, { min, max }: { min: number; max: number }) const AA: readonly Antialiasing[] = ["subpixel", "greyscale", "none"]; const concrete = (v: unknown, d: ConcreteTheme): ConcreteTheme => (isThemeChoiceId(v) ? v : d); const DISPLAYS: readonly NotificationDisplay[] = ["balloon", "sticky", "none"]; +const TERMINAL_COMPLETIONS: readonly TerminalCompletionMode[] = ["off", "longRunning", "all"]; export function validateAppearanceExtras(raw: unknown): AppearanceExtras { const a = obj(raw); @@ -271,6 +281,11 @@ export function validateNotifications(raw: unknown): NotificationsValid { balloons: bool(n.balloons, DEFAULT_NOTIFICATIONS.balloons), sound: bool(n.sound, DEFAULT_NOTIFICATIONS.sound), systemNotifications: bool(n.systemNotifications, DEFAULT_NOTIFICATIONS.systemNotifications), + terminalCompletion: oneOf(n.terminalCompletion, TERMINAL_COMPLETIONS, DEFAULT_NOTIFICATIONS.terminalCompletion), + terminalThresholdSeconds: int(n.terminalThresholdSeconds, DEFAULT_NOTIFICATIONS.terminalThresholdSeconds, { + min: 1, + max: 86_400, + }), groups, }; } diff --git a/src/features/settings/pages/behavior.tsx b/src/features/settings/pages/behavior.tsx index 29ec9445e..b273e30dd 100644 --- a/src/features/settings/pages/behavior.tsx +++ b/src/features/settings/pages/behavior.tsx @@ -1086,7 +1086,7 @@ export const BEHAVIOR_PAGES: PageSpec[] = [ title: "Notifications", group: APPEARANCE_GROUP, order: 2, - keywords: ["balloon", "popup", "sound", "alerts", "system", "os"], + keywords: ["balloon", "popup", "sound", "alerts", "system", "os", "terminal", "command"], sections: [ { options: [ @@ -1099,6 +1099,31 @@ export const BEHAVIOR_PAGES: PageSpec[] = [ }, ], }, + { + title: "Terminal", + options: [ + { + kind: "select", + key: "notifications.terminalCompletion", + label: "Notify when a terminal command finishes", + hint: "Only while the tab cannot be seen. A command stopped with Ctrl-C, shell startup and short commands stay quiet; a non-zero exit always reports its code.", + options: [ + { value: "off", label: "Off" }, + { value: "longRunning", label: "Long-running commands" }, + { value: "all", label: "All commands" }, + ], + }, + { + kind: "number", + key: "notifications.terminalThresholdSeconds", + label: "Minimum run time of a long-running command", + min: 1, + max: 86_400, + integer: true, + unit: "seconds", + }, + ], + }, { title: "Groups", options: [ diff --git a/src/features/terminal/TerminalView.tsx b/src/features/terminal/TerminalView.tsx index 4c57a74ad..b93738fa5 100644 --- a/src/features/terminal/TerminalView.tsx +++ b/src/features/terminal/TerminalView.tsx @@ -5,6 +5,7 @@ import { toolWindowService } from "@/workbench/contributions"; import { ToolWindowHeader, useOwnToolWindowHeader } from "@/workbench/toolwindows/ToolWindows"; import { usePlatform } from "@/platform/platformInfo"; import { commands, isTauri } from "@/platform/ipc"; +import { useTx } from "@/platform/i18n"; import { Badge, dropZoneAt, @@ -358,6 +359,7 @@ function GroupTabs({ group }: { group: string }) { const [shells, setShells] = useState([]); const menuRef = useRef(null); const focusRaf = useRef(0); + const tx = useTx(); const items: TabItem[] = tabs.map((t) => { const session = sessions[t.session]; @@ -372,6 +374,12 @@ function GroupTabs({ group }: { group: string }) { {status === "error" ? "Failed" : "Exited"} + ) : session?.unseenDone ? ( + // A finished command not seen yet (#3712): clears when the tab is focused + // or opened from its notification. + + {tx("Finished")} + ) : null; return { id: t.id, diff --git a/src/features/terminal/cli.ts b/src/features/terminal/cli.ts index 509e74fe6..4431b0cd2 100644 --- a/src/features/terminal/cli.ts +++ b/src/features/terminal/cli.ts @@ -5,9 +5,12 @@ * xterm-free part: the input kind and the session snapshot store the tab strip reads. * The sessions themselves live in `cliSessions.ts`, behind the terminal runtime. */ +import { createElement } from "react"; import { create } from "zustand"; import { editorService, toolWindowService, type EditorInput } from "@/workbench/contributions"; +import { useTx } from "@/platform/i18n"; import { useProject } from "@/platform/project"; +import { Badge } from "@/ui"; import { loadTerminalRuntime } from "./loader"; import type { SessionSnapshot } from "./session"; @@ -48,6 +51,14 @@ export function cliInput(name: string, command: string, cwd?: string): EditorInp /** Snapshots of the live editor sessions, by editor input key (an empty record: no live tab). */ export const useClis = create<{ sessions: Record }>(() => ({ sessions: {} })); +/** The editor tab's unseen-completion dot (#3712): a finished command, not seen yet. */ +export function CliDoneMark({ inputKey }: { inputKey: string }) { + const unseen = useClis((s) => !!s.sessions[inputKey]?.unseenDone); + const tx = useTx(); + if (!unseen) return null; + return createElement(Badge, { dot: true, tone: "accent", children: tx("Finished") }); +} + /** * Move to Editor: tab `id` of the Terminal tool window (the active one when omitted) * leaves the tool window and opens as an editor tab, its session still running. diff --git a/src/features/terminal/cliSessions.ts b/src/features/terminal/cliSessions.ts index fd8146b66..933d13b6d 100644 --- a/src/features/terminal/cliSessions.ts +++ b/src/features/terminal/cliSessions.ts @@ -5,8 +5,10 @@ * Sessions outlive React: they belong to the tab, which reattaches the same xterm * host when it is shown again. */ +import { editorService } from "@/workbench/contributions"; import { workflowSettings } from "@/platform/workflowSettings"; -import { useClis } from "./cli"; +import { CLI_KIND, useClis } from "./cli"; +import { completionAlert, completionPrefs, raiseCompletionNotification, type CompletionInfo } from "./completion"; import { TerminalSession, type SessionSnapshot } from "./session"; const sessions = new Map(); @@ -40,10 +42,39 @@ function onChange(key: string, snapshot: SessionSnapshot) { useClis.setState((s) => ({ sessions: { ...s.sessions, [key]: snapshot } })); } +/** + * A shell-integration command finished in an editor tab (#3712): like a tool + * window tab, it notifies when the tab cannot be seen — here, when it is not + * the active editor tab of a focused window — and marks it until seen. + */ +function noteCliCompletion(key: string, info: CompletionInfo) { + let watched = false; + try { + watched = document.hasFocus() && editorService().activeInput?.()?.key === key; + } catch { + /* no workbench */ + } + const alert = completionAlert(completionPrefs(), info, watched); + if (!alert) return; + const snapshot = useClis.getState().sessions[key]; + sessions.get(key)?.markUnseenDone(); + raiseCompletionNotification(key, snapshot?.appTitle ?? snapshot?.title ?? "Terminal", alert, () => { + void editorService().openInput( + { kind: CLI_KIND, key, data: { name: snapshot?.appTitle ?? snapshot?.title ?? "Terminal" } }, + { focus: true }, + ); + }); +} + /** Tab `key` takes over `session`, a running tool window session (Move to Editor). */ export function adoptCli(key: string, session: TerminalSession) { sessions.set(key, session); - session.rebind({ onChange: (_, snapshot) => onChange(key, snapshot), onFocus() {}, onExit: undefined }); + session.rebind({ + onChange: (_, snapshot) => onChange(key, snapshot), + onFocus() {}, + onExit: undefined, + onCompletion: (_, info) => noteCliCompletion(key, info), + }); } /** @@ -53,7 +84,14 @@ export function adoptCli(key: string, session: TerminalSession) { export function startCli(key: string, cwd: string, command: string, fallbackRoot?: string): TerminalSession { const existing = sessions.get(key); if (existing) return existing; - const session = new TerminalSession({ key, cwd, fallbackRoot, onChange, onFocus() {} }); + const session = new TerminalSession({ + key, + cwd, + fallbackRoot, + onChange, + onFocus() {}, + onCompletion: (_, info) => noteCliCompletion(key, info), + }); sessions.set(key, session); useClis.setState((s) => ({ sessions: { ...s.sessions, [key]: session.state } })); // Typed while the PTY is still starting: sent as the shell's first input. diff --git a/src/features/terminal/completion.test.ts b/src/features/terminal/completion.test.ts new file mode 100644 index 000000000..d57f1c783 --- /dev/null +++ b/src/features/terminal/completion.test.ts @@ -0,0 +1,253 @@ +/** + * Finished terminal commands (#3712): the completion policy (Settings › + * Notifications › Terminal) decides per finished shell-integration command; + * the session reports C → D with the exit status and Ctrl-C stops; the store + * wires the decision to a notification and the tab's unseen marker. + */ +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import type { Settings } from "@/platform/ipc"; +import { useProject } from "@/platform/project"; +import { completionAlert, completionPrefs } from "./completion"; +import { newTab, useTerminals, closeAll, getSession } from "./store"; +import { TerminalSession } from "./session"; + +const ipc = vi.hoisted(() => ({ + call: vi.fn(async (v: unknown) => v), + commands: { + fsReadDir: vi.fn(), + fsEntryKind: vi.fn(), + findFiles: vi.fn(), + termSpawn: vi.fn(), + termKill: vi.fn(), + termResize: vi.fn(), + termIsBusy: vi.fn(), + termWrite: vi.fn(), + }, +})); +const workbench = vi.hoisted(() => ({ + notify: vi.fn(), + visible: false, + show: vi.fn(), +})); + +vi.mock("@/platform/ipc", () => ({ call: ipc.call, commands: ipc.commands, isTauri: () => true })); +vi.mock("@/workbench/contributions", async (importOriginal) => ({ + ...(await importOriginal()), + notifications: () => ({ notify: workbench.notify }), + toolWindowService: () => ({ isVisible: () => workbench.visible, show: workbench.show, hide: vi.fn() }), +})); +// `Channel` needs the Tauri runtime; a start() test only hands it to the mocked spawn call. +vi.mock("@tauri-apps/api/core", async (importOriginal) => ({ + ...(await importOriginal()), + Channel: class { + onmessage: ((chunk: string) => void) | null = null; + }, +})); + +const write = (session: TerminalSession, data: string) => + new Promise((resolve) => session.term.write(data, resolve)); + +const info = (over: Partial[1]> = {}) => ({ + durationMs: 60_000, + exitCode: 0, + interrupted: false, + ...over, +}); + +describe("completion policy", () => { + const long = { mode: "longRunning" as const, thresholdMs: 10_000 }; + + it("notifies for a long-running command when the tab cannot be seen", () => { + expect(completionAlert(long, info(), false)).toEqual({ level: "info", body: "Finished" }); + expect(completionAlert(long, info(), true)).toBeNull(); + }); + + it("keeps short commands and the shell's first prompt quiet", () => { + expect(completionAlert(long, info({ durationMs: 9_999 }), false)).toBeNull(); + expect(completionAlert(long, info({ durationMs: 10_000 }), false)).toEqual({ level: "info", body: "Finished" }); + }); + + it("reports a failure's exit code however briefly it ran", () => { + expect(completionAlert(long, info({ durationMs: 200, exitCode: 1 }), false)).toEqual({ + level: "warning", + body: "Exited with code 1", + }); + // No exit status sent: not a known failure, so the long-running gate applies. + expect(completionAlert(long, info({ durationMs: 200, exitCode: null }), false)).toBeNull(); + }); + + it("never notifies when the mode is off, the command was stopped, or the tab is watched", () => { + const off = { mode: "off" as const, thresholdMs: 10_000 }; + expect(completionAlert(off, info({ exitCode: 1 }), false)).toBeNull(); + expect(completionAlert(long, info({ interrupted: true, exitCode: 130 }), false)).toBeNull(); + expect(completionAlert({ mode: "all", thresholdMs: 10_000 }, info(), true)).toBeNull(); + }); + + it("mode all notifies for every seen finish, short ones included", () => { + const all = { mode: "all" as const, thresholdMs: 10_000 }; + expect(completionAlert(all, info({ durationMs: 50 }), false)).toEqual({ level: "info", body: "Finished" }); + }); + + it("defaults to long-running with a 10 s threshold", () => { + expect(completionPrefs()).toEqual({ mode: "longRunning", thresholdMs: 10_000 }); + }); + + it.each([ + [ + { terminalCompletion: "all", terminalThresholdSeconds: 5 }, + { mode: "all", thresholdMs: 5_000 }, + ], + [{ terminalCompletion: "off" }, { mode: "off", thresholdMs: 10_000 }], + [ + { terminalCompletion: "sometimes", terminalThresholdSeconds: 0 }, + { mode: "longRunning", thresholdMs: 10_000 }, + ], + ] as const)("reads the settings %o as %o", (notifications, expected) => { + useProject.setState({ settings: { notifications } as unknown as Settings }); + expect(completionPrefs()).toEqual(expected); + }); +}); + +describe("command completion detection", () => { + beforeEach(() => { + useProject.setState({ settings: { notifications: { terminalCompletion: "all" } } as unknown as Settings }); + }); + afterEach(() => { + closeAll(); + useProject.setState({ project: null, settings: null }); + vi.clearAllMocks(); + }); + + const feed = async (session: TerminalSession, ...chunks: string[]) => { + for (const chunk of chunks) await write(session, chunk); + }; + + it("reports C → D with the exit status once", async () => { + const onCompletion = vi.fn(); + const session = new TerminalSession({ key: "k1", cwd: "/repo", onChange() {}, onFocus() {}, onCompletion }); + try { + // The shell's first prompt is a bare D: no command ran, nothing is reported. + await feed(session, "\x1b]133;D;0\x07"); + expect(onCompletion).not.toHaveBeenCalled(); + await feed(session, "\x1b]133;C\x07", "\x1b]133;D;3\x07"); + expect(onCompletion).toHaveBeenCalledExactlyOnceWith("k1", expect.objectContaining({ exitCode: 3 })); + expect(session.state).toMatchObject({ commandRunning: false }); + } finally { + session.dispose(); + } + }); + + it("accepts the status-less D and clears the unseen marker when a new command starts", async () => { + const session = new TerminalSession({ key: "k2", cwd: "/repo", onChange() {}, onFocus() {} }); + try { + await feed(session, "\x1b]133;C\x07", "\x1b]133;D\x07"); + expect(session.state).toMatchObject({ commandRunning: false }); + session.markUnseenDone(); + expect(session.state.unseenDone).toBe(true); + await feed(session, "\x1b]133;C\x07"); + expect(session.state).toMatchObject({ commandRunning: true, unseenDone: false }); + } finally { + session.dispose(); + } + }); + + it("does not count a command stopped with Ctrl-C as finished", async () => { + const onCompletion = vi.fn(); + const session = new TerminalSession({ key: "k3", cwd: "/repo", onChange() {}, onFocus() {}, onCompletion }); + try { + ipc.commands.termSpawn.mockImplementationOnce(async () => ({ id: 42, title: "zsh" })); + await session.start(); + await feed(session, "\x1b]133;C\x07"); + session.input("\x03"); + await write(session, ""); + await feed(session, "\x1b]133;D;130\x07"); + expect(onCompletion).toHaveBeenCalledExactlyOnceWith( + "k3", + expect.objectContaining({ exitCode: 130, interrupted: true }), + ); + } finally { + session.dispose(); + } + }); +}); + +describe("completion notification wiring", () => { + const hasFocus = vi.spyOn(document, "hasFocus"); + + beforeEach(() => { + hasFocus.mockReturnValue(false); + useProject.setState({ settings: { notifications: { terminalCompletion: "all" } } as unknown as Settings }); + }); + afterEach(() => { + closeAll(); + useProject.setState({ project: null, settings: null }); + vi.clearAllMocks(); + workbench.visible = false; + }); + + /** A tab with a session whose shell integration reports a finished command. */ + const finishedTab = async (exitStatus: string) => { + const tab = newTab("/repo"); + const session = getSession(tab.session)!; + await write(session, `\x1b]133;C\x07`); + await write(session, `\x1b]133;D${exitStatus}\x07`); + return tab; + }; + + it("notifies once per tab, marks it unseen, and Show focuses the tab", async () => { + const tab = await finishedTab(";0"); + expect(workbench.notify).toHaveBeenCalledExactlyOnceWith( + expect.objectContaining({ + group: "terminal", + level: "info", + key: `terminal-done-${tab.session}`, + title: tab.name, + body: "Finished", + actions: [expect.objectContaining({ label: "Show" })], + }), + ); + expect(useTerminals.getState().sessions[tab.session]?.unseenDone).toBe(true); + // The next command replaces the notice instead of piling up. + const session = getSession(tab.session)!; + await write(session, "\x1b]133;C\x07"); + await write(session, "\x1b]133;D;2\x07"); + expect(workbench.notify).toHaveBeenCalledTimes(2); + expect(workbench.notify.mock.calls[1]![0]).toMatchObject({ key: `terminal-done-${tab.session}`, level: "warning" }); + // The action selects the tab, shows the tool window and focuses the session. + workbench.notify.mock.calls[0]![0].actions[0].run(); + expect(workbench.show).toHaveBeenCalledWith("terminal", true); + expect(useTerminals.getState().activeTab).toBe(tab.id); + // The focus lands one frame later, after the tool window's pane re-mounts. + await new Promise((r) => requestAnimationFrame(r)); + expect(useTerminals.getState().sessions[tab.session]?.unseenDone).toBe(false); + }); + + it("stays quiet while the tab is watched", async () => { + hasFocus.mockReturnValue(true); + workbench.visible = true; + const tab = await finishedTab(";0"); + const state = useTerminals.getState(); + expect(state.selected[state.tabs.find((t) => t.id === tab.id)!.group]).toBe(tab.id); + expect(workbench.notify).not.toHaveBeenCalled(); + expect(useTerminals.getState().sessions[tab.session]?.unseenDone).toBe(false); + }); + + it("mode off silences everything", async () => { + useProject.setState({ + settings: { notifications: { terminalCompletion: "off" } } as unknown as Settings, + }); + const tab = await finishedTab(";0"); + expect(workbench.notify).not.toHaveBeenCalled(); + expect(useTerminals.getState().sessions[tab.session]?.unseenDone).toBe(false); + }); + + it("a failure notifies however briefly it ran", async () => { + useProject.setState({ + settings: { notifications: { terminalCompletion: "longRunning" } } as unknown as Settings, + }); + await finishedTab(";1"); + expect(workbench.notify).toHaveBeenCalledExactlyOnceWith( + expect.objectContaining({ group: "terminal", level: "warning" }), + ); + }); +}); diff --git a/src/features/terminal/completion.ts b/src/features/terminal/completion.ts new file mode 100644 index 000000000..b97e7270b --- /dev/null +++ b/src/features/terminal/completion.ts @@ -0,0 +1,82 @@ +/** + * Terminal command completion (#3712): a command the shell integration marked + * with OSC 133 C … D is an attention event when it ran long, failed, or the + * tab cannot be seen. The decision is Settings › Notifications › Terminal's + * completion mode plus a watched check; the notification goes through the + * normal balloons (and, in the background, the OS toasts they mirror to). + */ +import { tx } from "@/platform/i18n"; +import { useProject } from "@/platform/project"; +import { notifications } from "@/workbench/contributions"; + +export type TerminalCompletionMode = "off" | "longRunning" | "all"; + +export interface CompletionInfo { + /** Wall-clock time from OSC 133 C to D. */ + durationMs: number; + /** Exit status of `OSC 133;D;`; null when the shell sent none. */ + exitCode: number | null; + /** Ctrl-C was typed while this command ran. */ + interrupted: boolean; +} + +export interface CompletionPrefs { + mode: TerminalCompletionMode; + /** Mode `longRunning`: a command must run at least this long to notify. */ + thresholdMs: number; +} + +export interface CompletionAlert { + level: "info" | "warning"; + body: string; +} + +/** Settings › Notifications › Terminal (raw settings: the terminal does not depend on the settings feature). */ +export function completionPrefs(): CompletionPrefs { + const n = useProject.getState().settings?.notifications; + const mode: TerminalCompletionMode = + n?.terminalCompletion === "off" || n?.terminalCompletion === "all" ? n.terminalCompletion : "longRunning"; + const seconds = n?.terminalThresholdSeconds; + const thresholdMs = (typeof seconds === "number" && Number.isFinite(seconds) && seconds >= 1 ? seconds : 10) * 1000; + return { mode, thresholdMs }; +} + +/** + * Whether a finished command is worth telling the user about, and how. A + * failure notifies however briefly it ran; anything at all only when the tab + * cannot be seen (a watched terminal answers itself), and a command stopped + * with Ctrl-C never counts as finished. + */ +export function completionAlert( + prefs: CompletionPrefs, + info: CompletionInfo, + watched: boolean, +): CompletionAlert | null { + if (prefs.mode === "off" || info.interrupted || watched) return null; + if (info.exitCode !== null && info.exitCode !== 0) + return { level: "warning", body: tx`Exited with code ${info.exitCode}` }; + if (prefs.mode === "longRunning" && info.durationMs < prefs.thresholdMs) return null; + return { level: "info", body: tx("Finished") }; +} + +/** + * Raises the notification. `key` is per terminal session, so a tab's next + * command replaces the previous notice instead of piling up. + */ +export function raiseCompletionNotification( + sessionKey: string, + title: string, + alert: CompletionAlert, + show: () => void, +) { + notifications().notify({ + group: "terminal", + level: alert.level, + key: `terminal-done-${sessionKey}`, + // The title is the tab's own (a command or app title), not UI text. + title, + body: alert.body, + verbatim: true, + actions: [{ label: tx("Show"), run: show }], + }); +} diff --git a/src/features/terminal/index.ts b/src/features/terminal/index.ts index 844f633fd..daa5ef9d9 100644 --- a/src/features/terminal/index.ts +++ b/src/features/terminal/index.ts @@ -3,6 +3,7 @@ * "Terminal" tool window (tabs, split tab groups, links, IDEA-style shortcuts), * plus the CLI editor tabs (#2202): full-size agent CLIs as editor-area tabs. */ +import { createElement } from "react"; import { registerActions } from "@/platform/actions"; import { onIdeEvent } from "@/platform/ipc"; import { useProject } from "@/platform/project"; @@ -16,7 +17,7 @@ import { toolWindowService, } from "@/workbench/contributions"; import { lazyComponent } from "@/ui"; -import { CLI_KIND, cliData, moveTerminalToEditor } from "./cli"; +import { CLI_KIND, CliDoneMark, cliData, moveTerminalToEditor } from "./cli"; import { installTerminalKeys } from "./keys"; import { loadTerminalRuntime, terminalRuntime } from "./loader"; import { SAMPLE_TUI_END, SAMPLE_TUI_START, sampleTuiFrame } from "./sampleTui"; @@ -129,6 +130,8 @@ export function activate(): () => void { component: lazyComponent(() => loadTerminalRuntime().then((rt) => rt.CliEditor)), title: (input) => cliData(input)?.name ?? "Terminal", icon: () => "terminal", + // A finished command not seen yet (#3712). + trailing: (input) => createElement(CliDoneMark, { inputKey: input.key }), // A reopened tab shows Start: nothing runs on its own. restorable: true, keepAlive: true, diff --git a/src/features/terminal/session.ts b/src/features/terminal/session.ts index 2bdb8e115..fbaffabfb 100644 --- a/src/features/terminal/session.ts +++ b/src/features/terminal/session.ts @@ -30,6 +30,7 @@ import { hostOs, useRemote } from "@/platform/remote"; import { usePlatform } from "@/platform/platformInfo"; import { workflowSettings, type TerminalSettingsValid } from "@/platform/workflowSettings"; import { editorPrefs } from "@/platform/editorSettings"; +import type { CompletionInfo } from "./completion"; import { readLinkColor, readSearchDecorations, @@ -66,6 +67,11 @@ export interface SessionSnapshot { commandRunning: boolean; /** Current directory (initial cwd, updated by OSC 7). */ cwd: string; + /** + * A finished command has not been seen yet (#3712): the tab shows a dot + * until it is focused or opened from its notification. + */ + unseenDone: boolean; } export interface SessionOptions { @@ -75,6 +81,11 @@ export interface SessionOptions { onFocus: (key: string) => void; /** The shell exited (after the exit message was printed). */ onExit?: (key: string) => void; + /** + * A shell-integration command finished (OSC 133 D): how long it ran, its + * exit status, and whether it was stopped with Ctrl-C (#3712). + */ + onCompletion?: (key: string, info: CompletionInfo) => void; /** * Run this program instead of the configured shell (e.g. `docker exec -it sh`). * `shell`: it is a shell (a predefined session), so shell integration still applies. @@ -235,6 +246,10 @@ export class TerminalSession { private lastSize = { cols: 0, rows: 0 }; /** Per-tab font size offset (px) relative to `workflowSettings().terminal.fontSize`. */ private fontZoom = 0; + /** Kept while a shell-integration command runs, for its completion time (#3712). */ + private commandStartedAt: number | null = null; + /** Ctrl-C was typed while the current command ran: it was stopped, not finished. */ + private commandInterrupted = false; /** Bumped on restart so late output from a previous PTY is ignored. */ private generation = 0; /** WebKitGTK delivers one IME commit' worth of text more than once; see `ImeCommitGate`. */ @@ -246,7 +261,7 @@ export class TerminalSession { * Hands the session to another owner (a terminal tab moved to the editor): its * snapshots, focus and exit go there from now on. The PTY keeps running. */ - rebind(owner: Pick) { + rebind(owner: Pick) { this.opts = { ...this.opts, ...owner, onExit: owner.onExit }; this.opts.onChange(this.key, this.snapshot); } @@ -261,6 +276,7 @@ export class TerminalSession { appTitle: null, commandRunning: false, cwd: opts.cwd, + unseenDone: false, }; this.host = document.createElement("div"); this.host.className = "openidea-terminal-host"; @@ -344,9 +360,31 @@ export class TerminalSession { } return true; }), - // OSC 133 (shell integration): C = a command starts, D = it finished. + // OSC 133 (shell integration): C = a command starts, D; = it + // finished (plain D carries no status; both are accepted). this.term.parser.registerOscHandler(133, (data) => { - if (data === "C" || data.startsWith("D")) this.update({ commandRunning: data === "C" }); + if (data === "C") { + this.commandStartedAt = Date.now(); + this.commandInterrupted = false; + // A new command in the tab: the previous completion has been seen. + this.update({ commandRunning: true, unseenDone: false }); + } else if (data === "D" || data.startsWith("D;")) { + const status = data.length > 2 ? Number.parseInt(data.slice(2), 10) : Number.NaN; + const startedAt = this.commandStartedAt; + this.commandStartedAt = null; + const interrupted = this.commandInterrupted; + this.commandInterrupted = false; + this.update({ commandRunning: false }); + // A D without a C (shell startup, a restored tab's first prompt) is + // not a command finishing. + if (startedAt !== null) { + this.opts.onCompletion?.(this.key, { + durationMs: Date.now() - startedAt, + exitCode: Number.isFinite(status) ? status : null, + interrupted, + }); + } + } return true; }), this.term.registerLinkProvider({ @@ -465,6 +503,16 @@ export class TerminalSession { return this.snapshot; } + /** Marks the tab: a finished command here has not been seen yet (#3712). */ + markUnseenDone() { + if (!this.snapshot.unseenDone) this.update({ unseenDone: true }); + } + + /** The completion has been seen (the tab was focused). */ + private clearUnseenDone() { + if (this.snapshot.unseenDone) this.update({ unseenDone: false }); + } + get hasSelection(): boolean { return this.term.hasSelection(); } @@ -527,7 +575,10 @@ export class TerminalSession { () => !this.disposed, () => this.scheduleFit(), ); - this.term.textarea?.addEventListener("focus", () => this.opts.onFocus(this.key)); + this.term.textarea?.addEventListener("focus", () => { + this.clearUnseenDone(); + this.opts.onFocus(this.key); + }); this.watchImeCommit(); if (this.pendingFocus) this.focus(); } @@ -759,6 +810,8 @@ export class TerminalSession { this.pendingInput += data; return; } + // Ctrl-C stops the running command: its D mark must not count as a completion (#3712). + if (this.snapshot.commandRunning && data.includes("\x03")) this.commandInterrupted = true; void call(commands.termWrite(this.ptyId, data)).catch((error) => { notifications().notify({ level: "error", @@ -822,6 +875,8 @@ export class TerminalSession { /** Asks xterm to take the caret. Remembered when the textarea does not exist yet. */ focus() { if (this.disposed) return; + // The tab is becoming visible either way: its finished command counts as seen. + this.clearUnseenDone(); if (!this.opened || !this.term.textarea) { this.pendingFocus = true; this.scheduleFit(); diff --git a/src/features/terminal/store.ts b/src/features/terminal/store.ts index 899c8a694..3fee843f8 100644 --- a/src/features/terminal/store.ts +++ b/src/features/terminal/store.ts @@ -10,6 +10,7 @@ import { basename } from "@/platform/project"; import { workflowSettings } from "@/platform/workflowSettings"; import { toolWindowService } from "@/workbench/contributions"; import { confirm } from "@/workbench/messages"; +import { completionAlert, completionPrefs, raiseCompletionNotification, type CompletionInfo } from "./completion"; import { readStored, writeStored, type StoredTerminals } from "./persist"; import { TerminalSession, type SessionOptions, type SessionSnapshot } from "./session"; @@ -83,6 +84,34 @@ export function sessionForTerminalId(id: number): TerminalSession | undefined { return allSessions().find((s) => s.terminalId === id); } +/** + * A shell-integration command finished in a tool-window tab (#3712): per + * Settings › Notifications › Terminal, a long-running (or failing) command + * whose tab cannot be seen notifies and marks its tab until it is seen. + */ +function notifyCompletion(key: string, info: CompletionInfo) { + const state = useTerminals.getState(); + const tab = state.tabs.find((t) => t.session === key); + if (!tab) return; + let watched = document.hasFocus(); + if (watched) { + try { + watched = toolWindowService().isVisible("terminal") && state.selected[tab.group] === tab.id; + } catch { + watched = false; + } + } + const alert = completionAlert(completionPrefs(), info, watched); + if (!alert) return; + sessions.get(key)?.markUnseenDone(); + raiseCompletionNotification(key, tabTitle(tab, state.sessions), alert, () => { + selectTab(tab.id); + toolWindowService().show("terminal", true); + // The pane re-mounts once the tool window is shown; then give xterm the caret. + requestAnimationFrame(() => sessions.get(key)?.focus()); + }); +} + function createSession(cwd: string, command?: SessionOptions["command"], fallbackRoot?: string): TerminalSession { const key = `s${++seq}`; const session = new TerminalSession({ @@ -95,6 +124,7 @@ function createSession(cwd: string, command?: SessionOptions["command"], fallbac const tab = tabOfSession(k); if (tab) selectTab(tab.id); }, + onCompletion: notifyCompletion, onExit: (k) => { const tab = tabOfSession(k); if (!tab || !workflowSettings().terminal.closeOnExit) return; diff --git a/src/features/terminal/terminal.test.ts b/src/features/terminal/terminal.test.ts index d02e143fb..96d5dca03 100644 --- a/src/features/terminal/terminal.test.ts +++ b/src/features/terminal/terminal.test.ts @@ -422,7 +422,7 @@ describe("terminalFont", () => { describe("terminal tab titles", () => { const tab: TerminalTab = { id: "t1", name: "Local", customName: null, shell: null, session: "s1", group: "g1" }; const snap = (appTitle: string | null, commandRunning = true): Record => ({ - s1: { status: "running", exitCode: null, title: "zsh", appTitle, commandRunning, cwd: "/p" }, + s1: { status: "running", exitCode: null, title: "zsh", appTitle, commandRunning, cwd: "/p", unseenDone: false }, }); it("shows the default name at the prompt, whatever title the shell sets", () => { diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json index ee348e73d..1a8c9e5ab 100644 --- a/src/platform/locales/text/en.json +++ b/src/platform/locales/text/en.json @@ -2156,5 +2156,12 @@ "Reconnecting opens the project again. Unsaved changes in {count} files can't be saved to {host} and will be lost.": "Reconnecting opens the project again. Unsaved changes in {count} files can't be saved to {host} and will be lost.", "Reconnecting to {host}…": "Reconnecting to {host}…", "Lost the connection to {host}. Click to reconnect.": "Lost the connection to {host}. Click to reconnect.", - "{label} (disconnected)": "{label} (disconnected)" + "{label} (disconnected)": "{label} (disconnected)", + "Notify when a terminal command finishes": "Notify when a terminal command finishes", + "Long-running commands": "Long-running commands", + "All commands": "All commands", + "Minimum run time of a long-running command": "Minimum run time of a long-running command", + "Exited with code {code}": "Exited with code {code}", + "Finished": "Finished", + "Only while the tab cannot be seen. A command stopped with Ctrl-C, shell startup and short commands stay quiet; a non-zero exit always reports its code.": "Only while the tab cannot be seen. A command stopped with Ctrl-C, shell startup and short commands stay quiet; a non-zero exit always reports its code." } diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json index c489837e8..9efbc156c 100644 --- a/src/platform/locales/text/zh.json +++ b/src/platform/locales/text/zh.json @@ -8544,5 +8544,11 @@ "Reconnecting opens the project again. Unsaved changes in {count} files can't be saved to {host} and will be lost.": "重新连接会重新打开项目。{count} 个文件中未保存的更改无法保存到 {host},将会丢失。", "Reconnecting to {host}…": "正在重新连接到 {host}…", "Lost the connection to {host}. Click to reconnect.": "与 {host} 的连接已断开。点击重新连接。", - "{label} (disconnected)": "{label}(已断开)" + "{label} (disconnected)": "{label}(已断开)", + "Notify when a terminal command finishes": "终端命令结束时的通知", + "Long-running commands": "长时间运行的命令", + "All commands": "所有命令", + "Minimum run time of a long-running command": "长时间运行命令的最短运行时间", + "Exited with code {code}": "退出代码 {code}", + "Only while the tab cannot be seen. A command stopped with Ctrl-C, shell startup and short commands stay quiet; a non-zero exit always reports its code.": "仅当标签页不可见时通知。用 Ctrl-C 停止的命令、shell 启动和短命令保持安静;非零退出始终报告退出代码。" } diff --git a/src/workbench/contributions.ts b/src/workbench/contributions.ts index 5d9df27d4..e8feaa273 100644 --- a/src/workbench/contributions.ts +++ b/src/workbench/contributions.ts @@ -774,7 +774,7 @@ export interface NotificationService { verbatim?: boolean; /** * Notification group (Settings › Notifications): `system` (default), `lsp`, - * `vcs`, `run`, `tools`, `plugins`, `search`, `updates`. + * `vcs`, `run`, `tools`, `plugins`, `search`, `terminal`, `updates`. */ group?: string; /** diff --git a/src/workbench/notificationStore.ts b/src/workbench/notificationStore.ts index 8a8e7bc2f..4b47e682e 100644 --- a/src/workbench/notificationStore.ts +++ b/src/workbench/notificationStore.ts @@ -37,6 +37,7 @@ export const NOTIFICATION_GROUPS: ReadonlyArray<{ id: string; title: string }> = { id: "tools", title: "External Tools" }, { id: "search", title: "Find in Files" }, { id: "plugins", title: "Plugins" }, + { id: "terminal", title: "Terminal" }, { id: "updates", title: "IDE Updates" }, { id: "distractionFree", title: "Distraction Free Mode" }, ];