Files
nanobot/tui/src/prompt-queue.ts
T
chengyongruandGitHub 4d204ba077 feat(tui): support pasting clipboard images (#5563)
* feat(tui): support pasting clipboard images

* fix(tui): keep image placeholders atomic

* fix(tui): reconcile duplicate image placeholders

* fix(tui): retain highlighted image placeholders

* fix(tui): preserve image placeholder layout

* fix(tui): keep image display state local

* fix(tui): reject images in commands
2026-08-27 20:37:43 +08:00

43 lines
816 B
TypeScript

import type { MessageOptions } from "./protocol"
export interface QueuedPrompt {
content: string
displayContent?: string
options: MessageOptions
}
/** Owns prompts that should start after the active turn finishes. */
export class PromptQueue {
private prompts: QueuedPrompt[] = []
get length(): number {
return this.prompts.length
}
enqueue(prompt: QueuedPrompt): void {
this.prompts.push(prompt)
}
takeLast(): QueuedPrompt | null {
return this.prompts.pop() ?? null
}
takeFollowUp(): QueuedPrompt | null {
return this.prompts.shift() ?? null
}
snapshot(): readonly QueuedPrompt[] {
return this.prompts
}
restore(): QueuedPrompt[] {
const prompts = this.prompts
this.prompts = []
return prompts
}
clear(): void {
this.prompts = []
}
}