feat: update custom status line prompt input (#938)

This commit is contained in:
jnjpng
2026-02-12 16:23:00 -08:00
committed by GitHub
parent 58002fb28a
commit 86a0fc9b1d
8 changed files with 151 additions and 55 deletions

View File

@@ -34,6 +34,7 @@ export interface NormalizedStatusLineConfig {
debounceMs: number;
refreshIntervalMs?: number;
disabled?: boolean;
prompt?: string;
}
/**
@@ -67,6 +68,7 @@ export function normalizeStatusLineConfig(
),
...(refreshIntervalMs !== undefined && { refreshIntervalMs }),
...(config.disabled !== undefined && { disabled: config.disabled }),
...(config.prompt !== undefined && { prompt: config.prompt }),
};
}
@@ -164,3 +166,53 @@ export function resolveStatusLineConfig(
return null;
}
}
/**
* Resolve the prompt character from status line settings.
* Independent of whether a `command` is configured.
* Returns `">"` when disabled or no prompt is configured at any level.
*
* Precedence: local project > project > global.
*/
export function resolvePromptChar(
workingDirectory: string = process.cwd(),
): string {
try {
if (isStatusLineDisabled(workingDirectory)) return ">";
// Local project settings (highest priority)
try {
const local =
settingsManager.getLocalProjectSettings(workingDirectory)?.statusLine;
if (local?.prompt !== undefined) return local.prompt;
} catch {
// Not loaded
}
// Project settings
try {
const project =
settingsManager.getProjectSettings(workingDirectory)?.statusLine;
if (project?.prompt !== undefined) return project.prompt;
} catch {
// Not loaded
}
// Global settings
try {
const global = settingsManager.getSettings().statusLine;
if (global?.prompt !== undefined) return global.prompt;
} catch {
// Not initialized
}
return ">";
} catch (error) {
debugLog(
"statusline",
"resolvePromptChar: Failed to resolve prompt",
error,
);
return ">";
}
}

View File

@@ -33,7 +33,8 @@ export function formatStatusLineHelp(): string {
' "padding": 2,',
' "timeout": 5000,',
' "debounceMs": 300,',
' "refreshIntervalMs": 10000',
' "refreshIntervalMs": 10000,',
' "prompt": "→"',
" }",
"",
' type must be "command"',
@@ -42,6 +43,7 @@ export function formatStatusLineHelp(): string {
" timeout command timeout in ms (default 5000, max 30000)",
" debounceMs event debounce in ms (default 300)",
" refreshIntervalMs optional polling interval in ms (off by default)",
' prompt custom input prompt character (default ">")',
"",
"INPUT (via JSON stdin)",
fieldList,