feat(coding-agent): allow hiding working loader

closes #3674
This commit is contained in:
Mario Zechner
2026-04-24 23:16:39 +02:00
parent 02e694b580
commit 6580dae400
7 changed files with 211 additions and 21 deletions

View File

@@ -262,6 +262,7 @@ export class InteractiveMode {
private onInputCallback?: (text: string) => void;
private loadingAnimation: Loader | undefined = undefined;
private workingMessage: string | undefined = undefined;
private workingVisible = true;
private workingIndicatorOptions: LoaderIndicatorOptions | undefined = undefined;
private readonly defaultWorkingMessage = "Working...";
private readonly defaultHiddenThinkingLabel = "Thinking...";
@@ -1695,6 +1696,43 @@ export class InteractiveMode {
this.ui.requestRender();
}
private getWorkingLoaderMessage(): string {
return this.workingMessage ?? this.defaultWorkingMessage;
}
private createWorkingLoader(): Loader {
return new Loader(
this.ui,
(spinner) => theme.fg("accent", spinner),
(text) => theme.fg("muted", text),
this.getWorkingLoaderMessage(),
this.workingIndicatorOptions,
);
}
private stopWorkingLoader(): void {
if (this.loadingAnimation) {
this.loadingAnimation.stop();
this.loadingAnimation = undefined;
}
this.statusContainer.clear();
}
private setWorkingVisible(visible: boolean): void {
this.workingVisible = visible;
if (!visible) {
this.stopWorkingLoader();
this.ui.requestRender();
return;
}
if (this.session.isStreaming && !this.loadingAnimation) {
this.statusContainer.clear();
this.loadingAnimation = this.createWorkingLoader();
this.statusContainer.addChild(this.loadingAnimation);
}
this.ui.requestRender();
}
private setWorkingIndicator(options?: LoaderIndicatorOptions): void {
this.workingIndicatorOptions = options;
this.loadingAnimation?.setIndicator(options);
@@ -1794,6 +1832,7 @@ export class InteractiveMode {
this.defaultEditor.onExtensionShortcut = undefined;
this.updateTerminalTitle();
this.workingMessage = undefined;
this.workingVisible = true;
this.setWorkingIndicator();
if (this.loadingAnimation) {
this.loadingAnimation.setMessage(`${this.defaultWorkingMessage} (${keyText("app.interrupt")} to interrupt)`);
@@ -1946,15 +1985,10 @@ export class InteractiveMode {
setWorkingMessage: (message) => {
this.workingMessage = message;
if (this.loadingAnimation) {
if (message) {
this.loadingAnimation.setMessage(message);
} else {
this.loadingAnimation.setMessage(
`${this.defaultWorkingMessage} (${keyText("app.interrupt")} to interrupt)`,
);
}
this.loadingAnimation.setMessage(message ?? this.defaultWorkingMessage);
}
},
setWorkingVisible: (visible) => this.setWorkingVisible(visible),
setWorkingIndicator: (options) => this.setWorkingIndicator(options),
setHiddenThinkingLabel: (label) => this.setHiddenThinkingLabel(label),
setWidget: (key, content, options) => this.setExtensionWidget(key, content, options),
@@ -2355,7 +2389,7 @@ export class InteractiveMode {
// Set up handlers on defaultEditor - they use this.editor for text access
// so they work correctly regardless of which editor is active
this.defaultEditor.onEscape = () => {
if (this.loadingAnimation) {
if (this.session.isStreaming) {
this.restoreQueuedMessagesToEditor({ abort: true });
} else if (this.session.isBashRunning) {
this.session.abortBash();
@@ -2652,18 +2686,11 @@ export class InteractiveMode {
this.retryLoader.stop();
this.retryLoader = undefined;
}
if (this.loadingAnimation) {
this.loadingAnimation.stop();
this.stopWorkingLoader();
if (this.workingVisible) {
this.loadingAnimation = this.createWorkingLoader();
this.statusContainer.addChild(this.loadingAnimation);
}
this.statusContainer.clear();
this.loadingAnimation = new Loader(
this.ui,
(spinner) => theme.fg("accent", spinner),
(text) => theme.fg("muted", text),
this.workingMessage || this.defaultWorkingMessage,
this.workingIndicatorOptions,
);
this.statusContainer.addChild(this.loadingAnimation);
this.ui.requestRender();
break;