Commit 06c3e2a32ca5
Changed files (1)
dots
pi
agent
extensions
dots/pi/agent/extensions/prompt-editor.ts
@@ -334,14 +334,28 @@ function orderedModeNames(modes: Record<string, ModeSpec>): string[] {
return Object.keys(modes).filter((name) => name !== CUSTOM_MODE_NAME);
}
+/** Convert hex color (#rrggbb) to 24-bit ANSI foreground escape sequence */
+function hexToAnsi(hex: string): string {
+ const h = hex.replace("#", "");
+ const r = parseInt(h.substring(0, 2), 16);
+ const g = parseInt(h.substring(2, 4), 16);
+ const b = parseInt(h.substring(4, 6), 16);
+ return `\x1b[38;2;${r};${g};${b}m`;
+}
+
function getModeBorderColor(ctx: ExtensionContext, pi: ExtensionAPI, mode: string): (text: string) => string {
const theme = ctx.ui.theme;
const spec = runtime.data.modes[mode];
- // Explicit color override in JSON.
+ // Hex color from modes.json
+ if (spec?.color && /^#[0-9a-fA-F]{6}$/.test(spec.color)) {
+ const ansi = hexToAnsi(spec.color);
+ return (text: string) => `${ansi}${text}\x1b[0m`;
+ }
+
+ // Theme token fallback
if (spec?.color) {
try {
- // Validate early so we don't crash during render.
theme.getFgAnsi(spec.color as any);
return (text: string) => theme.fg(spec.color as any, text);
} catch {