diff --git a/packages/coding-agent/src/modes/components/custom-editor.ts b/packages/coding-agent/src/modes/components/custom-editor.ts index 7c3c2e340..bb97c1598 100644 --- a/packages/coding-agent/src/modes/components/custom-editor.ts +++ b/packages/coding-agent/src/modes/components/custom-editor.ts @@ -1,8 +1,6 @@ import { Editor, type KeyId, matchesKey, parseKittySequence } from "@oh-my-pi/pi-tui"; import type { AppKeybinding } from "../../config/keybindings"; -import { highlightOrchestrate } from "../orchestrate"; -import { highlightUltrathink } from "../ultrathink"; -import { highlightWorkflow } from "../workflow"; +import { highlightMagicKeywords } from "../magic-keywords"; type ConfigurableEditorAction = Extract< AppKeybinding, @@ -47,8 +45,9 @@ const DEFAULT_ACTION_KEYS: Record = { * Custom editor that handles configurable app-level shortcuts for coding-agent. */ export class CustomEditor extends Editor { - /** Gradient-highlight the "ultrathink" / "orchestrate" / "workflow" keywords as the user types them. */ - decorateText = (text: string): string => highlightWorkflow(highlightOrchestrate(highlightUltrathink(text))); + /** Gradient-highlight the "ultrathink" / "orchestrate" / "workflow" keywords as the user types + * them, skipping any occurrence inside code spans, fenced blocks, or XML sections. */ + decorateText = (text: string): string => highlightMagicKeywords(text); onEscape?: () => void; shouldBypassAutocompleteOnEscape?: () => boolean; onClear?: () => void; diff --git a/packages/coding-agent/src/modes/components/user-message.ts b/packages/coding-agent/src/modes/components/user-message.ts index 5f1da9317..a51de6aa0 100644 --- a/packages/coding-agent/src/modes/components/user-message.ts +++ b/packages/coding-agent/src/modes/components/user-message.ts @@ -1,5 +1,6 @@ import { Container, Markdown, Spacer } from "@oh-my-pi/pi-tui"; import { getMarkdownTheme, theme } from "../../modes/theme/theme"; +import { highlightMagicKeywords } from "../magic-keywords"; // OSC 133 shell integration: marks prompt zones for terminal multiplexers const OSC133_ZONE_START = "\x1b]133;A\x07"; @@ -13,9 +14,15 @@ export class UserMessageComponent extends Container { constructor(text: string, synthetic = false) { super(); const bgColor = (value: string) => theme.bg("userMessageBg", value); + // Paint the magic keywords ("ultrathink"/"orchestrate"/"workflow") inside the rendered + // bubble too — matching the live editor glow. The Markdown component routes code spans and + // fenced blocks through its own code styling (never `color`), so those are already excluded; + // `highlightMagicKeywords` additionally restores the bubble's own foreground after each + // painted keyword so the gradient never bleeds into the rest of the line. + const keywordReset = theme.getFgAnsi("userMessageText") || "\x1b[39m"; const color = synthetic ? (value: string) => theme.fg("dim", value) - : (value: string) => theme.fg("userMessageText", value); + : (value: string) => theme.fg("userMessageText", highlightMagicKeywords(value, keywordReset)); this.addChild(new Spacer(1)); this.addChild( new Markdown(text, 1, 1, getMarkdownTheme(), {