/** * Terminal tab/window title management for the TUI. * * Terminals label their tab from the window title, which an application sets * with an OSC 0 sequence; without one the tab shows the process name ("node"). * The title text is untrusted display content (session names arrive through * events and user input), so it is sanitized before emission: control * characters and bidi/invisible formatting codepoints are stripped, whitespace * runs collapse to single spaces, and the result is bounded. Clearing writes * an empty OSC payload and the terminal falls back to its own default; the * previously set title is not portable to read back and is never restored. * * @module @deepseek-ai/dsh-code/ui/terminal-title */ /** Tab label before a session carries a name. */ export declare const DEFAULT_TERMINAL_TITLE = "deepseek"; /** Practical upper bound on title length, in visible characters: long enough * for session names, short enough for tab bars and window managers. */ export declare const MAX_TERMINAL_TITLE_CHARS = 240; /** Normalize untrusted title text into one bounded display line: disallowed * codepoints dropped, whitespace runs collapsed to single spaces, leading and * trailing whitespace removed, length bounded. */ export declare function sanitizeTerminalTitle(text: string): string; /** Build one OSC 0 title sequence. An empty sanitized title yields an empty * string: emitting nothing is distinct from clearing, which is a separate * policy decision made by the caller. */ export declare function terminalTitleSequence(text: string): string; /** Clear the managed title with an empty OSC payload; the terminal falls back * to its own default label. */ export declare function clearTerminalTitleSequence(): string; /** * Resolve the VS Code stable user-settings file for one platform and * environment: `%APPDATA%` on Windows, the bundle data folder on macOS (NOT * XDG `~/.config` — VS Code never reads that path there, so writing it * silently no-ops and the tab kept showing the process name "node"), and * XDG config on Linux. */ export declare function vscodeSettingsPath(platform: NodeJS.Platform, env: NodeJS.ProcessEnv): string | undefined; /** Outcome of the VS Code settings alignment. */ export interface VsCodeTitleSettingResult { wrote: boolean; reason?: 'not-vscode' | 'unparseable' | 'key-present' | 'error'; } /** VS Code renders an application-set tab title only when * "terminal.integrated.tabs.title" maps to the sequence variable; the editor * default shows the process name instead ("node" for a Node CLI). Inside a VS * Code integrated terminal, align the user settings once: if the key is * absent, insert it and keep a one-shot backup of the original file. A value * the user already set is never overwritten, an unparseable file is never * touched, and every failure degrades to a no-op - the OSC and process-title * channels keep working everywhere else. */ export declare function ensureVsCodeTabTitleSetting(options?: { env?: NodeJS.ProcessEnv; settingsFile?: string; isTTY?: boolean; }): VsCodeTitleSettingResult; /** * Keep the terminal tab label on `title` (sanitized; empty titles leave the * current label alone). Two delivery channels run in parallel: the OSC 0 * sequence to stdout, and the host process title. Writes are deduplicated by * title, and on unmount the managed title is cleared and the process title * restored so the host shell regains its default label. */ export declare function useTerminalTitle(title: string, options?: { clearOnUnmount?: boolean; }): void;