refactor(coding-agent/src): migrated keyword decorators to shared helper
- Replaced composed keyword decorators in `CustomEditor.decorateText` with `highlightMagicKeywords`. - Adjusted `UserMessageComponent` rendering to use `highlightMagicKeywords` with `keywordReset` for consistent foreground.
This commit is contained in:
@@ -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<ConfigurableEditorAction, KeyId[]> = {
|
||||
* 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;
|
||||
|
||||
@@ -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(), {
|
||||
|
||||
Reference in New Issue
Block a user