mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 22:51:23 +00:00
TUI: waiting shimmer helper + tests
This commit is contained in:
committed by
Peter Steinberger
parent
2e99369113
commit
fac66d4dda
@@ -22,6 +22,7 @@ import { editorTheme, theme } from "./theme/theme.js";
|
||||
import { createCommandHandlers } from "./tui-command-handlers.js";
|
||||
import { createEventHandlers } from "./tui-event-handlers.js";
|
||||
import { formatTokens } from "./tui-formatters.js";
|
||||
import { buildWaitingStatusMessage } from "./tui-waiting.js";
|
||||
import { createOverlayHandlers } from "./tui-overlays.js";
|
||||
import { createSessionActions } from "./tui-session-actions.js";
|
||||
import type {
|
||||
@@ -286,49 +287,23 @@ export async function runTui(opts: TuiOptions) {
|
||||
statusContainer.addChild(statusLoader);
|
||||
};
|
||||
|
||||
const waitingPhrases = [
|
||||
"flibbertigibbeting",
|
||||
"kerfuffling",
|
||||
"dillydallying",
|
||||
"twiddling thumbs",
|
||||
"noodling",
|
||||
"bamboozling",
|
||||
"moseying",
|
||||
"hobnobbing",
|
||||
"pondering",
|
||||
"conjuring",
|
||||
"vibing",
|
||||
"clawding",
|
||||
];
|
||||
|
||||
let waitingTick = 0;
|
||||
let waitingTimer: NodeJS.Timeout | null = null;
|
||||
|
||||
const shimmerWaitingText = (text: string, tick: number) => {
|
||||
const width = 6;
|
||||
const hi = (ch: string) => theme.bold(theme.accentSoft(ch));
|
||||
|
||||
const pos = tick % (text.length + width);
|
||||
const start = Math.max(0, pos - width);
|
||||
const end = Math.min(text.length - 1, pos);
|
||||
|
||||
let out = "";
|
||||
for (let i = 0; i < text.length; i++) {
|
||||
const ch = text[i];
|
||||
out += i >= start && i <= end ? hi(ch) : theme.dim(ch);
|
||||
}
|
||||
return out;
|
||||
};
|
||||
|
||||
const updateBusyStatusMessage = () => {
|
||||
if (!statusLoader || !statusStartedAt) return;
|
||||
const elapsed = formatElapsed(statusStartedAt);
|
||||
|
||||
if (activityStatus === "waiting") {
|
||||
waitingTick++;
|
||||
const phrase = waitingPhrases[Math.floor(waitingTick / 10) % waitingPhrases.length];
|
||||
const cute = shimmerWaitingText(`${phrase}…`, waitingTick);
|
||||
statusLoader.setMessage(`${cute} • ${elapsed} | ${connectionStatus}`);
|
||||
statusLoader.setMessage(
|
||||
buildWaitingStatusMessage({
|
||||
theme,
|
||||
tick: waitingTick,
|
||||
elapsed,
|
||||
connectionStatus,
|
||||
}),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user