Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions packages/zcode-tui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ const toolLifecycleEventKinds = new Set([
const terminalThemeQueryTimeoutMs = 100;
const exitUsageQueryTimeoutMs = 250;
const updateAvailableBlockId = "update_available";
const modelRetryBlockIdPrefix = "model_retry_status";

function modelRetryProgress(event: StreamEvent, phase: "scheduled" | "started"): string {
const retryNumber = phase === "started"
Expand Down Expand Up @@ -339,6 +340,7 @@ class ZCodeTui {
private activeTurnId?: string;
private turnEpoch = 0;
private activeTurnEpoch?: number;
private modelRetryBlockId?: string;
private pendingSteerInterrupt?: PendingSteerInterrupt;
private recentSteerCommit?: { at: number; turnEpoch: number };
private currentThinking?: ThinkingView;
Expand Down Expand Up @@ -1422,7 +1424,7 @@ class ZCodeTui {
title: event.type === "streamRecovery.updated" ? "Recovering model stream" : "Retrying model request",
summary: [retry, delay].filter(Boolean).join(" · "),
detail: event.message
});
}, this.modelRetryBlockId);
} else if (event.type === "model_request_failed") {
if (!isModelCancellationEvent(event)) {
this.updateActivity(
Expand Down Expand Up @@ -1627,6 +1629,7 @@ class ZCodeTui {
private beginTurn(prompt?: string): void {
this.completeThinking();
this.presentationRegistry.beginTurn();
this.modelRetryBlockId = `${modelRetryBlockIdPrefix}_${this.turnEpoch}`;
this.currentThinking = undefined;
this.currentThinkingPartId = undefined;
this.currentToolGroup = undefined;
Expand Down Expand Up @@ -1738,9 +1741,12 @@ class ZCodeTui {
this.ui.requestRender();
}

private addSystemEvent(event: SystemEventData): void {
private addSystemEvent(event: SystemEventData, blockId?: string): void {
this.currentToolGroup = undefined;
this.transcript.addBlock(new SystemEventView(this.theme, event), { kind: "system-event" });
this.transcript.addBlock(new SystemEventView(this.theme, event), {
id: blockId,
kind: "system-event"
});
this.ui.requestRender();
}

Expand Down
4 changes: 3 additions & 1 deletion packages/zcode-tui/src/protocol-part-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ export class ProtocolPartView implements Component {
];
}
if (this.part.type === "retry") {
return [`${this.theme.warning("↻")} ${this.theme.bold("Retrying model request")} ${this.theme.muted(sanitizeTerminalText(this.part.text, { preserveSgr: false }))}`];
const text = sanitizeTerminalText(this.part.text, { preserveSgr: false });
const line = `${this.theme.warning("↻")} ${this.theme.bold("Retrying model request")}`;
return text ? [`${line} ${this.theme.muted(text)}`] : [line];
}
if (this.part.type === "compaction") {
const reason = this.part.reason ? sanitizeTerminalText(this.part.reason, { preserveSgr: false }) : undefined;
Expand Down