feat(frontend): store lastUserEntry + stepMessages; record user input/choice

This commit is contained in:
2026-06-29 21:39:02 +02:00
parent 3a97ab3b2f
commit 068c6f197d
4 changed files with 45 additions and 3 deletions
+7 -1
View File
@@ -10,6 +10,8 @@ interface SessionState {
pendingWidget: WidgetDescriptor | null;
transcript: Entry[];
toasts: { level: string; text: string }[];
stepMessages: { level: string; text: string }[];
lastUserEntry: { kind: "input" | "choice"; text: string } | null;
lastSystemEvent: StreamEvent | null;
currentPhase: string | null;
applyEvent: (e: StreamEvent) => void;
@@ -17,12 +19,15 @@ interface SessionState {
resetSession: () => void;
setPhase: (phase: string | null) => void;
pushToast: (toast: { level: string; text: string }) => void;
setLastUserEntry: (e: { kind: "input" | "choice"; text: string }) => void;
}
const empty = {
pendingWidget: null,
transcript: [] as Entry[],
toasts: [] as { level: string; text: string }[],
stepMessages: [] as { level: string; text: string }[],
lastUserEntry: null as { kind: "input" | "choice"; text: string } | null,
lastSystemEvent: null,
currentPhase: null as string | null,
};
@@ -45,7 +50,7 @@ export const useSessionStore = create<SessionState>((set) => ({
else t.push({ role: "assistant", text: e.text });
return { transcript: t };
}
if (e.type === "info") return { toasts: [...st.toasts, { level: e.level ?? "info", text: e.text }] };
if (e.type === "info") return { stepMessages: [...st.stepMessages, { level: e.level ?? "info", text: e.text }] };
if (e.type === "system_event") return { lastSystemEvent: e };
return {};
}),
@@ -53,4 +58,5 @@ export const useSessionStore = create<SessionState>((set) => ({
resetSession: () => set({ ...empty }),
setPhase: (phase) => set({ currentPhase: phase }),
pushToast: (toast) => set((st) => ({ toasts: [...st.toasts, toast] })),
setLastUserEntry: (e) => set({ lastUserEntry: e, stepMessages: [] }),
}));