Skip to content

Commit e85d2df

Browse files
vignesh07steipete
authored andcommitted
TUI: pick waiting phrase once per waiting session
1 parent fac66d4 commit e85d2df

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

‎src/tui/tui-waiting.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import type { ClawdbotTheme } from "./theme/theme.js";
1+
type MinimalTheme = {
2+
dim: (s: string) => string;
3+
bold: (s: string) => string;
4+
accentSoft: (s: string) => string;
5+
};
26

37
export const defaultWaitingPhrases = [
48
"flibbertigibbeting",
@@ -18,7 +22,7 @@ export function pickWaitingPhrase(tick: number, phrases = defaultWaitingPhrases)
1822
return phrases[idx] ?? phrases[0] ?? "waiting";
1923
}
2024

21-
export function shimmerText(theme: ClawdbotTheme, text: string, tick: number) {
25+
export function shimmerText(theme: MinimalTheme, text: string, tick: number) {
2226
const width = 6;
2327
const hi = (ch: string) => theme.bold(theme.accentSoft(ch));
2428

@@ -35,7 +39,7 @@ export function shimmerText(theme: ClawdbotTheme, text: string, tick: number) {
3539
}
3640

3741
export function buildWaitingStatusMessage(params: {
38-
theme: ClawdbotTheme;
42+
theme: MinimalTheme;
3943
tick: number;
4044
elapsed: string;
4145
connectionStatus: string;

‎src/tui/tui.ts‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ import { editorTheme, theme } from "./theme/theme.js";
2222
import { createCommandHandlers } from "./tui-command-handlers.js";
2323
import { createEventHandlers } from "./tui-event-handlers.js";
2424
import { formatTokens } from "./tui-formatters.js";
25-
import { buildWaitingStatusMessage } from "./tui-waiting.js";
25+
import {
26+
buildWaitingStatusMessage,
27+
defaultWaitingPhrases,
28+
} from "./tui-waiting.js";
2629
import { createOverlayHandlers } from "./tui-overlays.js";
2730
import { createSessionActions } from "./tui-session-actions.js";
2831
import type {
@@ -289,6 +292,7 @@ export async function runTui(opts: TuiOptions) {
289292

290293
let waitingTick = 0;
291294
let waitingTimer: NodeJS.Timeout | null = null;
295+
let waitingPhrase: string | null = null;
292296

293297
const updateBusyStatusMessage = () => {
294298
if (!statusLoader || !statusStartedAt) return;
@@ -302,6 +306,7 @@ export async function runTui(opts: TuiOptions) {
302306
tick: waitingTick,
303307
elapsed,
304308
connectionStatus,
309+
phrases: waitingPhrase ? [waitingPhrase] : undefined,
305310
}),
306311
);
307312
return;
@@ -326,6 +331,16 @@ export async function runTui(opts: TuiOptions) {
326331

327332
const startWaitingTimer = () => {
328333
if (waitingTimer) return;
334+
335+
// Pick a phrase once per waiting session.
336+
if (!waitingPhrase) {
337+
const idx = Math.floor(Math.random() * defaultWaitingPhrases.length);
338+
waitingPhrase =
339+
defaultWaitingPhrases[idx] ?? defaultWaitingPhrases[0] ?? "waiting";
340+
}
341+
342+
waitingTick = 0;
343+
329344
waitingTimer = setInterval(() => {
330345
if (activityStatus !== "waiting") return;
331346
updateBusyStatusMessage();
@@ -336,6 +351,7 @@ export async function runTui(opts: TuiOptions) {
336351
if (!waitingTimer) return;
337352
clearInterval(waitingTimer);
338353
waitingTimer = null;
354+
waitingPhrase = null;
339355
};
340356

341357
const renderStatus = () => {

0 commit comments

Comments
 (0)