Improve the transcript: tool grouping, report auto-ack, context meter, spinner, Enter to send
This commit is contained in:
+14
-3
@@ -87,26 +87,33 @@ export async function loadInbox(): Promise<void> {
|
||||
notify("inbox");
|
||||
}
|
||||
|
||||
let liveDuringLoad: ByreEvent[] | undefined;
|
||||
|
||||
export async function selectTask(taskId: string | undefined): Promise<void> {
|
||||
state.selectedTaskId = taskId;
|
||||
state.transcript = [];
|
||||
state.lastTranscriptSeq = 0;
|
||||
liveDuringLoad = undefined;
|
||||
notify("selection");
|
||||
|
||||
if (!taskId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const held: ByreEvent[] = [];
|
||||
liveDuringLoad = held;
|
||||
for (;;) {
|
||||
const page = await get("/api/tasks/{taskId}/events", { path: { taskId }, query: { after: state.lastTranscriptSeq, limit: 1000 } });
|
||||
if (state.selectedTaskId !== taskId) {
|
||||
if (state.selectedTaskId !== taskId || liveDuringLoad !== held) {
|
||||
return;
|
||||
}
|
||||
appendTranscript(page);
|
||||
if (page.length < 1000) {
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
liveDuringLoad = undefined;
|
||||
appendTranscript(held);
|
||||
}
|
||||
|
||||
function appendTranscript(events: ByreEvent[]): void {
|
||||
@@ -121,7 +128,11 @@ function appendTranscript(events: ByreEvent[]): void {
|
||||
|
||||
export function handleEvent(ev: ByreEvent): void {
|
||||
if (ev.task_id && ev.task_id === state.selectedTaskId) {
|
||||
appendTranscript([ev]);
|
||||
if (liveDuringLoad) {
|
||||
liveDuringLoad.push(ev);
|
||||
} else {
|
||||
appendTranscript([ev]);
|
||||
}
|
||||
}
|
||||
|
||||
switch (ev.kind) {
|
||||
|
||||
Reference in New Issue
Block a user