mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 12:56:01 -06:00
fix(tui): keep spinner active when toggling tools (#92909)
* fix(tui): keep spinner active when toggling tools * fix(tui): preserve finishing status when toggling tools --------- Co-authored-by: zengwen <zeng_wen@foxmail.com> Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
resolveFinalAssistantText,
|
||||
resolveGatewayDisconnectState,
|
||||
resolveInitialTuiAgentId,
|
||||
resolveTuiToolsToggleActivityStatus,
|
||||
isTuiBusyActivityStatus,
|
||||
resolveLocalAuthCliInvocation,
|
||||
resolveLocalAuthSpawnCwd,
|
||||
@@ -191,6 +192,35 @@ describe("isTuiBusyActivityStatus", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveTuiToolsToggleActivityStatus", () => {
|
||||
it("preserves busy status while an active run exists", () => {
|
||||
expect(
|
||||
resolveTuiToolsToggleActivityStatus({
|
||||
currentStatus: "streaming",
|
||||
toolsExpanded: true,
|
||||
}),
|
||||
).toBe("streaming");
|
||||
});
|
||||
|
||||
it("preserves finishing context after the active run id clears", () => {
|
||||
expect(
|
||||
resolveTuiToolsToggleActivityStatus({
|
||||
currentStatus: "finishing context",
|
||||
toolsExpanded: false,
|
||||
}),
|
||||
).toBe("finishing context");
|
||||
});
|
||||
|
||||
it("uses the tool toggle status when activity is idle", () => {
|
||||
expect(
|
||||
resolveTuiToolsToggleActivityStatus({
|
||||
currentStatus: "idle",
|
||||
toolsExpanded: false,
|
||||
}),
|
||||
).toBe("tools collapsed");
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveTuiShutdownHardExitMs", () => {
|
||||
it("keeps gateway shutdown bounded by the hard-exit timer", () => {
|
||||
expect(resolveTuiShutdownHardExitMs({ localMode: false })).toBe(2000);
|
||||
|
||||
+19
-1
@@ -411,6 +411,17 @@ export function isTuiBusyActivityStatus(status: string): boolean {
|
||||
return TUI_BUSY_ACTIVITY_STATUSES.has(status);
|
||||
}
|
||||
|
||||
export function resolveTuiToolsToggleActivityStatus(params: {
|
||||
currentStatus: string;
|
||||
toolsExpanded: boolean;
|
||||
}): string {
|
||||
const toolsStatus = params.toolsExpanded ? "tools expanded" : "tools collapsed";
|
||||
if (isTuiBusyActivityStatus(params.currentStatus)) {
|
||||
return params.currentStatus;
|
||||
}
|
||||
return toolsStatus;
|
||||
}
|
||||
|
||||
export function resolveTuiShutdownHardExitMs(params: { localMode?: boolean } = {}): number {
|
||||
return TUI_SHUTDOWN_HARD_EXIT_MS + (params.localMode ? resolveLocalRunShutdownGraceMs() : 0);
|
||||
}
|
||||
@@ -1460,7 +1471,14 @@ export async function runTui(opts: RunTuiOptions): Promise<TuiResult> {
|
||||
editor.onCtrlO = () => {
|
||||
toolsExpanded = !toolsExpanded;
|
||||
chatLog.setToolsExpanded(toolsExpanded);
|
||||
setActivityStatus(toolsExpanded ? "tools expanded" : "tools collapsed");
|
||||
// Ctrl+O is presentation-only; preserve busy activity so the status loader
|
||||
// does not disappear before the run lifecycle ends.
|
||||
setActivityStatus(
|
||||
resolveTuiToolsToggleActivityStatus({
|
||||
currentStatus: activityStatus,
|
||||
toolsExpanded,
|
||||
}),
|
||||
);
|
||||
tui.requestRender();
|
||||
};
|
||||
editor.onCtrlL = () => {
|
||||
|
||||
Reference in New Issue
Block a user