Skip to content

feat(web): Study Buddy panel — api, hook, component (AI-038a)#329

Merged
mrviduus merged 1 commit into
mainfrom
ai-038a-studybuddy-panel
Jun 15, 2026
Merged

feat(web): Study Buddy panel — api, hook, component (AI-038a)#329
mrviduus merged 1 commit into
mainfrom
ai-038a-studybuddy-panel

Conversation

@mrviduus

Copy link
Copy Markdown
Owner

Phase 6 AI-038, slice a — the web UI for the agent: an api client, a streaming hook, and the panel. Wiring it into the reader's selection toolbar is slice b (touches the complex ReaderPage/ReaderHighlights, kept separate for a reviewable diff).

Changes

  • api/studybuddy.tsrunStudyBuddy(editionId, passage, chapter, callbacks) consumes the AI-037 SSE (step / done / error) via postSse; getStudyBuddyRun(runId) fetches a persisted run for the "show steps" view.
  • useStudyBuddy hooksteps grow live as the agent works, answer lands on done, status (idle/running/done/error); a new run aborts the in-flight one (and on unmount); 401 surfaces as error: 'auth'.
  • StudyBuddyPanel — right slide-in panel (mirrors AskPanel): passage echoed at top, final answer, a spinner while running, and a collapsible step transcript (each step summarized — tool name + ✓/✗, or the model's text / Looking up: …). Auth-gated with a sign-in CTA.
  • lib/sse.tspostSse now sends credentials: 'include' (needed for the authed Study Buddy stream; harmless for the public Explain one) and maps 401 → new SseUnauthorizedError.

Verification

  • useStudyBuddy: step accumulation → answer on done; terminal error keeps the partial steps; 401 → auth; no-op on empty passage / missing edition; reset.
  • postSse: 401 → SseUnauthorizedError and credentials: 'include' sent.
  • Full web suite green (517); tsc --noEmit + pnpm build clean. The panel renders end-to-end once wired (AI-038b); a live run is exercised on prod / AI-039.

🤖 Generated with Claude Code

api/studybuddy.ts (runStudyBuddy over SSE + getStudyBuddyRun); useStudyBuddy
hook (live steps, answer on done, status, 401->auth); StudyBuddyPanel (passage
echo, answer, collapsible step transcript, auth-gated). postSse now sends
credentials + maps 401 to SseUnauthorizedError. Reader wiring is AI-038b.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mrviduus mrviduus merged commit 2a5800d into main Jun 15, 2026
5 checks passed
@mrviduus mrviduus deleted the ai-038a-studybuddy-panel branch June 15, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant