feat(coding-agent): add hidden thinking label api closes #2673
This commit is contained in:
@@ -9,17 +9,20 @@ export class AssistantMessageComponent extends Container {
|
||||
private contentContainer: Container;
|
||||
private hideThinkingBlock: boolean;
|
||||
private markdownTheme: MarkdownTheme;
|
||||
private hiddenThinkingLabel: string;
|
||||
private lastMessage?: AssistantMessage;
|
||||
|
||||
constructor(
|
||||
message?: AssistantMessage,
|
||||
hideThinkingBlock = false,
|
||||
markdownTheme: MarkdownTheme = getMarkdownTheme(),
|
||||
hiddenThinkingLabel = "Thinking...",
|
||||
) {
|
||||
super();
|
||||
|
||||
this.hideThinkingBlock = hideThinkingBlock;
|
||||
this.markdownTheme = markdownTheme;
|
||||
this.hiddenThinkingLabel = hiddenThinkingLabel;
|
||||
|
||||
// Container for text/thinking content
|
||||
this.contentContainer = new Container();
|
||||
@@ -39,6 +42,16 @@ export class AssistantMessageComponent extends Container {
|
||||
|
||||
setHideThinkingBlock(hide: boolean): void {
|
||||
this.hideThinkingBlock = hide;
|
||||
if (this.lastMessage) {
|
||||
this.updateContent(this.lastMessage);
|
||||
}
|
||||
}
|
||||
|
||||
setHiddenThinkingLabel(label: string): void {
|
||||
this.hiddenThinkingLabel = label;
|
||||
if (this.lastMessage) {
|
||||
this.updateContent(this.lastMessage);
|
||||
}
|
||||
}
|
||||
|
||||
updateContent(message: AssistantMessage): void {
|
||||
@@ -70,8 +83,10 @@ export class AssistantMessageComponent extends Container {
|
||||
.some((c) => (c.type === "text" && c.text.trim()) || (c.type === "thinking" && c.thinking.trim()));
|
||||
|
||||
if (this.hideThinkingBlock) {
|
||||
// Show static "Thinking..." label when hidden
|
||||
this.contentContainer.addChild(new Text(theme.italic(theme.fg("thinkingText", "Thinking...")), 1, 0));
|
||||
// Show static thinking label when hidden
|
||||
this.contentContainer.addChild(
|
||||
new Text(theme.italic(theme.fg("thinkingText", this.hiddenThinkingLabel)), 1, 0),
|
||||
);
|
||||
if (hasVisibleContentAfter) {
|
||||
this.contentContainer.addChild(new Spacer(1));
|
||||
}
|
||||
|
||||
@@ -164,6 +164,8 @@ export class InteractiveMode {
|
||||
private loadingAnimation: Loader | undefined = undefined;
|
||||
private pendingWorkingMessage: string | undefined = undefined;
|
||||
private readonly defaultWorkingMessage = "Working...";
|
||||
private readonly defaultHiddenThinkingLabel = "Thinking...";
|
||||
private hiddenThinkingLabel = this.defaultHiddenThinkingLabel;
|
||||
|
||||
private lastSigintTime = 0;
|
||||
private lastEscapeTime = 0;
|
||||
@@ -1325,6 +1327,19 @@ export class InteractiveMode {
|
||||
this.ui.requestRender();
|
||||
}
|
||||
|
||||
private setHiddenThinkingLabel(label?: string): void {
|
||||
this.hiddenThinkingLabel = label ?? this.defaultHiddenThinkingLabel;
|
||||
for (const child of this.chatContainer.children) {
|
||||
if (child instanceof AssistantMessageComponent) {
|
||||
child.setHiddenThinkingLabel(this.hiddenThinkingLabel);
|
||||
}
|
||||
}
|
||||
if (this.streamingComponent) {
|
||||
this.streamingComponent.setHiddenThinkingLabel(this.hiddenThinkingLabel);
|
||||
}
|
||||
this.ui.requestRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an extension widget (string array or custom component).
|
||||
*/
|
||||
@@ -1405,6 +1420,7 @@ export class InteractiveMode {
|
||||
if (this.loadingAnimation) {
|
||||
this.loadingAnimation.setMessage(`${this.defaultWorkingMessage} (${keyText("app.interrupt")} to interrupt)`);
|
||||
}
|
||||
this.setHiddenThinkingLabel();
|
||||
}
|
||||
|
||||
// Maximum total widget lines to prevent viewport overflow
|
||||
@@ -1557,6 +1573,7 @@ export class InteractiveMode {
|
||||
this.pendingWorkingMessage = message;
|
||||
}
|
||||
},
|
||||
setHiddenThinkingLabel: (label) => this.setHiddenThinkingLabel(label),
|
||||
setWidget: (key, content, options) => this.setExtensionWidget(key, content, options),
|
||||
setFooter: (factory) => this.setExtensionFooter(factory),
|
||||
setHeader: (factory) => this.setExtensionHeader(factory),
|
||||
@@ -2262,6 +2279,7 @@ export class InteractiveMode {
|
||||
undefined,
|
||||
this.hideThinkingBlock,
|
||||
this.getMarkdownThemeWithSettings(),
|
||||
this.hiddenThinkingLabel,
|
||||
);
|
||||
this.streamingMessage = event.message;
|
||||
this.chatContainer.addChild(this.streamingComponent);
|
||||
@@ -2617,6 +2635,7 @@ export class InteractiveMode {
|
||||
message,
|
||||
this.hideThinkingBlock,
|
||||
this.getMarkdownThemeWithSettings(),
|
||||
this.hiddenThinkingLabel,
|
||||
);
|
||||
this.chatContainer.addChild(assistantComponent);
|
||||
break;
|
||||
|
||||
@@ -167,6 +167,10 @@ export async function runRpcMode(session: AgentSession): Promise<never> {
|
||||
// Working message not supported in RPC mode - requires TUI loader access
|
||||
},
|
||||
|
||||
setHiddenThinkingLabel(_label?: string): void {
|
||||
// Hidden thinking label not supported in RPC mode - requires TUI message rendering access
|
||||
},
|
||||
|
||||
setWidget(key: string, content: unknown, options?: ExtensionWidgetOptions): void {
|
||||
// Only support string arrays in RPC mode - factory functions are ignored
|
||||
if (content === undefined || Array.isArray(content)) {
|
||||
|
||||
Reference in New Issue
Block a user