fix: restore model activity reasoning stream
This commit is contained in:
@@ -15,6 +15,15 @@ test("text_delta accumulates into transcript", () => {
|
||||
expect(useSessionStore.getState().transcript.at(-1)?.text).toBe("Analisi");
|
||||
});
|
||||
|
||||
test("activity_delta accumulates separately from the assistant transcript", () => {
|
||||
const s = useSessionStore.getState();
|
||||
s.applyEvent({ type: "activity_delta", text: "Valuto " });
|
||||
s.applyEvent({ type: "activity_delta", text: "le ambiguità" });
|
||||
|
||||
expect(useSessionStore.getState().activity.at(-1)?.text).toBe("Valuto le ambiguità");
|
||||
expect(useSessionStore.getState().transcript).toEqual([]);
|
||||
});
|
||||
|
||||
test("info appends to stepMessages", () => {
|
||||
useSessionStore.getState().applyEvent({ type: "info", level: "warning", text: "attenzione" });
|
||||
expect(useSessionStore.getState().stepMessages.at(-1)).toEqual({ level: "warning", text: "attenzione" });
|
||||
@@ -122,4 +131,5 @@ test("resetSession clears lastUserEntry and stepMessages", () => {
|
||||
st.resetSession();
|
||||
expect(useSessionStore.getState().lastUserEntry).toBeNull();
|
||||
expect(useSessionStore.getState().stepMessages).toEqual([]);
|
||||
expect(useSessionStore.getState().activity).toEqual([]);
|
||||
});
|
||||
|
||||
@@ -9,6 +9,7 @@ interface Entry {
|
||||
interface SessionState {
|
||||
pendingWidget: WidgetDescriptor | null;
|
||||
transcript: Entry[];
|
||||
activity: Entry[];
|
||||
toasts: { level: string; text: string }[];
|
||||
stepMessages: { level: string; text: string }[];
|
||||
lastUserEntry: { kind: "input" | "choice"; text: string } | null;
|
||||
@@ -31,6 +32,7 @@ interface SessionState {
|
||||
const empty = {
|
||||
pendingWidget: null,
|
||||
transcript: [] as Entry[],
|
||||
activity: [] as Entry[],
|
||||
toasts: [] as { level: string; text: string }[],
|
||||
stepMessages: [] as { level: string; text: string }[],
|
||||
lastUserEntry: null as { kind: "input" | "choice"; text: string } | null,
|
||||
@@ -63,6 +65,13 @@ export const useSessionStore = create<SessionState>((set) => ({
|
||||
// Streamed text means the turn is alive (also covers reattaching mid-turn).
|
||||
return { transcript: t, agentActive: true };
|
||||
}
|
||||
if (e.type === "activity_delta") {
|
||||
const activity = [...st.activity];
|
||||
const last = activity.at(-1);
|
||||
if (last) activity[activity.length - 1] = { role: "assistant", text: last.text + e.text };
|
||||
else activity.push({ role: "assistant", text: e.text });
|
||||
return { activity, agentActive: true };
|
||||
}
|
||||
if (e.type === "info") {
|
||||
const stepMessages = [...st.stepMessages, { level: e.level ?? "info", text: e.text }];
|
||||
// An error during the active phase marks that phase red until the next gate.
|
||||
|
||||
Reference in New Issue
Block a user