fix(frontend): wire currentPhase to WorkflowBar (normalized) + WidgetHost error handling
- sessionStore.applyEvent: on ui_request set currentPhase normalized from the descriptor's phase to its short id (e.g. "F4_schema_linking" -> "F4"), so WorkflowBar actually highlights the active phase; falls back to the existing phase when the descriptor has none. setPhase kept for resume/getSession. - Add pushToast store action; WidgetHost wraps postResponse in try/catch, pushes an error toast and keeps the widget pending on failure (clearPending only on success) so the user can retry. - Tests: store currentPhase normalization + no-phase passthrough + pushToast; new WorkflowBar.test.tsx asserting the matching phase is highlighted. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@ interface SessionState {
|
||||
clearPending: () => void;
|
||||
resetSession: () => void;
|
||||
setPhase: (phase: string | null) => void;
|
||||
pushToast: (toast: { level: string; text: string }) => void;
|
||||
}
|
||||
|
||||
const empty = {
|
||||
@@ -30,7 +31,13 @@ export const useSessionStore = create<SessionState>((set) => ({
|
||||
...empty,
|
||||
applyEvent: (e) =>
|
||||
set((st) => {
|
||||
if (e.type === "ui_request") return { pendingWidget: e.ui_request };
|
||||
if (e.type === "ui_request")
|
||||
return {
|
||||
pendingWidget: e.ui_request,
|
||||
currentPhase: e.ui_request.phase
|
||||
? e.ui_request.phase.split("_")[0]
|
||||
: st.currentPhase,
|
||||
};
|
||||
if (e.type === "text_delta") {
|
||||
const t = [...st.transcript];
|
||||
const last = t.at(-1);
|
||||
@@ -45,4 +52,5 @@ export const useSessionStore = create<SessionState>((set) => ({
|
||||
clearPending: () => set({ pendingWidget: null }),
|
||||
resetSession: () => set({ ...empty }),
|
||||
setPhase: (phase) => set({ currentPhase: phase }),
|
||||
pushToast: (toast) => set((st) => ({ toasts: [...st.toasts, toast] })),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user