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:
2026-06-28 13:40:33 +02:00
co-authored by Claude Opus 4.8
parent ddbbe4d1ac
commit 5295e34898
4 changed files with 65 additions and 2 deletions
+18
View File
@@ -24,3 +24,21 @@ test("clearPending removes the widget", () => {
useSessionStore.getState().clearPending();
expect(useSessionStore.getState().pendingWidget).toBeNull();
});
test("ui_request sets currentPhase normalized to the short id", () => {
useSessionStore
.getState()
.applyEvent({ type: "ui_request", ui_request: { id: "u", widget: "select", phase: "F4_schema_linking" } });
expect(useSessionStore.getState().currentPhase).toBe("F4");
});
test("ui_request without a phase keeps the existing currentPhase", () => {
useSessionStore.getState().setPhase("F2");
useSessionStore.getState().applyEvent({ type: "ui_request", ui_request: { id: "u", widget: "select" } });
expect(useSessionStore.getState().currentPhase).toBe("F2");
});
test("pushToast appends an error toast", () => {
useSessionStore.getState().pushToast({ level: "error", text: "boom" });
expect(useSessionStore.getState().toasts.at(-1)).toEqual({ level: "error", text: "boom" });
});