Navigate to snapshots from the transcript
This commit is contained in:
+13
-2
@@ -1,6 +1,6 @@
|
||||
import { get, subscribe, type AgentSession, type ByreEvent, type InboxItem, type Project, type Task, type User } from "./api.js";
|
||||
import { get, subscribe, type AgentSession, type ByreEvent, type InboxItem, type Project, type Snapshot, type Task, type User } from "./api.js";
|
||||
|
||||
export type Topic = "me" | "projects" | "tasks" | "sessions" | "inbox" | "selection" | "transcript" | "stream" | "connection" | "event";
|
||||
export type Topic = "me" | "projects" | "tasks" | "sessions" | "inbox" | "selection" | "transcript" | "stream" | "connection" | "event" | "pin";
|
||||
|
||||
export const state = {
|
||||
me: undefined as User | undefined,
|
||||
@@ -11,6 +11,7 @@ export const state = {
|
||||
selectedTaskId: undefined as string | undefined,
|
||||
transcript: [] as ByreEvent[],
|
||||
lastTranscriptSeq: 0,
|
||||
pinned: undefined as number | undefined,
|
||||
connected: false,
|
||||
};
|
||||
|
||||
@@ -59,6 +60,15 @@ export function currentSession(taskId: string): AgentSession | undefined {
|
||||
return state.sessions.get(taskId)?.findLast((s) => s.state !== "completed") ?? state.sessions.get(taskId)?.at(-1);
|
||||
}
|
||||
|
||||
export function snapshots(): Snapshot[] {
|
||||
return state.transcript.filter((e) => e.kind === "snapshot.created").map((e) => e.payload as unknown as Snapshot);
|
||||
}
|
||||
|
||||
export function pinSnapshot(n: number | undefined): void {
|
||||
state.pinned = n;
|
||||
notify("pin");
|
||||
}
|
||||
|
||||
export async function loadMe(): Promise<void> {
|
||||
state.me = await get("/api/me");
|
||||
notify("me");
|
||||
@@ -115,6 +125,7 @@ export function selectTask(taskId: string | undefined): void {
|
||||
state.selectedTaskId = taskId;
|
||||
state.transcript = [];
|
||||
state.lastTranscriptSeq = 0;
|
||||
state.pinned = undefined;
|
||||
notify("selection");
|
||||
|
||||
if (!taskId) {
|
||||
|
||||
Reference in New Issue
Block a user