Fourth revision: OpenRouter, live tool stages, Explain layout, share sections
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 29s

- Interactive blocks are encouraged by default; Explain gets a reduced library
  and never writes practice questions.
- Assistant tool steps breathe while running, show live stages from generation
  and the Python check, and read in the past tense when done.
- The assistant asks before searching the web when class materials do not
  cover a question; clarifying questions list every class's exams and never
  ask about format (always NCLEX).
- Explain opens beside the question from 900px wide, moving the question left
  while open and back on the next one.
- Generate dialog drops the practice set/exam switch (presets cover it) and the
  Generate buttons lose their icon.
- Python check notes are green when every check passed, applied fixes neutral.
- Share pages group by exam, then Quizzes, Flashcards, Notes, Class Materials,
  hiding empty groups; the class page uses the same order. "Documents" is now
  "Class Materials".
- OpenRouter provider replaces the Ollama type; migration 6 turns Ollama
  connections into OpenAI-compatible ones at /v1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-11-15 21:54:39 -07:00
parent c595e0ff2c
commit 25bc03ea75
45 changed files with 663 additions and 329 deletions

View file

@ -575,7 +575,11 @@ export function cancelGeneration(draftId: string): void {
running.delete(draftId);
}
/** Listeners for a running job's progress labels (the assistant shows them on its tool step). */
const progressListeners = new Map<string, (label: string) => void>();
function setProgress(db: DB, id: string, progress: number, label: string, payload?: ContentDraft): void {
if (label) progressListeners.get(id)?.(label);
if (payload) {
db.run('UPDATE drafts SET progress = ?, progress_label = ?, payload = ?, updated_at = ? WHERE id = ?', progress, label, JSON.stringify(payload), now(), id);
} else {
@ -703,7 +707,11 @@ const NOTE_TITLES: Record<string, string> = { study_guide: 'study guide', summar
* Starts a generation job in the background and returns the draft id immediately.
* The caller polls the draft (or awaits `done`) for progress.
*/
export function startGeneration(app: AppContext, input: z.input<typeof generateRequestSchema>, opts: { conversationId?: string | null; origin?: DraftMeta['origin'] } = {}): { draftId: string; done: Promise<DraftDto> } {
export function startGeneration(
app: AppContext,
input: z.input<typeof generateRequestSchema>,
opts: { conversationId?: string | null; origin?: DraftMeta['origin']; onProgress?: (label: string) => void } = {},
): { draftId: string; done: Promise<DraftDto> } {
const req = generateRequestSchema.parse(input);
if (req.classId) getClass(app.db, req.classId);
if (req.folderId) {
@ -723,6 +731,7 @@ export function startGeneration(app: AppContext, input: z.input<typeof generateR
});
const controller = new AbortController();
running.set(draftId, controller);
if (opts.onProgress) progressListeners.set(draftId, opts.onProgress);
const done = runGeneration(app, draftId, req, controller.signal)
.catch((err) => {
const message = err instanceof AIError ? err.message : err instanceof Error && 'status' in err ? err.message : 'Generation failed unexpectedly.';
@ -738,6 +747,7 @@ export function startGeneration(app: AppContext, input: z.input<typeof generateR
})
.then(() => {
running.delete(draftId);
progressListeners.delete(draftId);
return getDraft(app.db, draftId);
});
return { draftId, done };
@ -1017,7 +1027,7 @@ export const improveRequestSchema = z.object({
});
/** Rewrites existing questions (clearer stems, better distractors, fuller rationales) into a draft the user can apply. */
export function startImprove(app: AppContext, input: z.input<typeof improveRequestSchema>, opts: { conversationId?: string | null } = {}): { draftId: string; done: Promise<DraftDto> } {
export function startImprove(app: AppContext, input: z.input<typeof improveRequestSchema>, opts: { conversationId?: string | null; onProgress?: (label: string) => void } = {}): { draftId: string; done: Promise<DraftDto> } {
const req = improveRequestSchema.parse(input);
const quiz = getQuiz(app.db, req.quizId);
let questions = listQuestions(app.db, quiz.id);
@ -1035,6 +1045,7 @@ export function startImprove(app: AppContext, input: z.input<typeof improveReque
});
const controller = new AbortController();
running.set(draftId, controller);
if (opts.onProgress) progressListeners.set(draftId, opts.onProgress);
const done = (async () => {
const out: DraftQuestion[] = [];
const ids: string[] = [];
@ -1098,6 +1109,7 @@ Return the questions in the same order, one output question per input question.$
})
.then(() => {
running.delete(draftId);
progressListeners.delete(draftId);
return getDraft(app.db, draftId);
});
return { draftId, done };