Promote the editor-agent line to main: read-then-act editor agent (read_scene_content, regenerate_scene, regenerate_scene_actions, edit_interactive_html), a routable maic-agent model stage, the agent sidebar UI, interactive-scene runtime-error capture, and the timeline/script editor. Cross-reviewed and smoke-verified; see #777.
A single TTS provider-enablement model honored everywhere (picker,
auto-assignment, fallback, lecture/playback, server).
Model
- lib/audio/provider-enablement.ts: isTTSProviderConfigured /
isTTSProviderEnabled / listEnabledTTSProviderIds. Availability drops the
registry defaultBaseUrl fallback (fixes Lemonade's always-shown voices),
honors the per-provider `enabled` flag, server-disable overrides (server
precedence).
- voice-resolver: getEnabledProvidersWithVoices (enabled server/custom
providers) and getSelectableProvidersWithVoices (the ONE client source of
truth = enabled providers + opt-in browser-native when the browser exposes
voices). resolveAgentVoice picks deterministically among the given providers,
honors a voiceConfig only while its provider is present.
- Picker + discussion build their list from getSelectableProvidersWithVoices, so
the AgentBar and the live discussion agree on selectable voices (fixes
student agents going silent in auto mode). Students resolve via
resolveAgentVoice; the teacher uses the global lecture voice verbatim (same
voice the pre-generated lecture sends), so lecture and discussion never
diverge.
- Voice assignment vs fallback: an agent's voice is bound at generation (the
agent-profile LLM picks from availableVoices; preset uses the user's pick).
The fallback for a missing/invalid/unavailable voice is applied only at the
live TTS calls, not baked into the saved agent — so it reflects current
provider availability.
Defaults / opt-in
- Browser-native: first-class, default OFF, opt-in. Built-in providers default
enabled:true (only surface once configured).
- TTS master toggle defaults OFF; first server-sync auto-enables it when a
provider is configured (mirrors image/video).
- Persist v3->v4 migration normalizes the never-user-editable flags.
Server/admin disable (server precedence): server-providers.yml `enabled:false`
and env `TTS_<P>_ENABLED=false` (incl. browser-native). Surfaced as a per-provider
`disabled` flag on /api/server-providers; merged as serverDisabled; enforced at
the /api/generate/tts trust boundary, classroom media generation, and /api/health.
UI
- Settings TTS panel: per-provider enable toggle, disabled (with a hint) when the
provider is unavailable, locked off (with a note) when server-disabled.
- AgentBar voice pills render disabled with a "No voice" placeholder when no
provider is enabled. The toolbar media-popover TTS tab keeps its existing
on/off toggle (no picker/CTA).
Tests: predicates, resolver determinism + unified selectable list, server
force-disable, store merge + migration + TTS auto-enable, i18n parity. Verified
in a real browser (Playwright): settings toggle states + a full Gemini classroom
generation whose TTS requests used the picked voice.
Found on main @ 2586cb5.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: 杨慎 <117187635+cosarah@users.noreply.github.com>
* refactor(providers): make server-configured providers admin-managed, not client-overridable
A server-configured provider is now authoritative: the operator owns its API
key and base URL, and the client cannot override either. This collapses the
tri-state (server key / client base URL / client key) that was the root of a
recurring "missing API key" bug class — when the settings UI echoed a base URL
with an empty key, routes that treated "any base URL ⇒ fully client-configured"
dropped the server key. #533 patched that per-route via canUseServerApiKeyForBaseUrl;
this removes the guard entirely by fixing the design.
Server:
- resolve*ApiKey/BaseUrl ignore client values when the provider is server-
configured; add isServerConfiguredProvider(section, id); drop
canUseServerApiKeyForBaseUrl + normalizeProviderBaseUrl.
- getServer*Providers() no longer return base URLs — only allowed models
(LLM/image) and the managed flag (presence) — so an internal gateway/proxy
endpoint is never exposed to the client.
- routes (chat/image/video/tts/asr/pdf + verify-*) resolve managed providers
purely server-side; SSRF validation now applies only to unmanaged (client)
base URLs.
Client:
- drop serverBaseUrl from ProviderSettings, the settings store, request-building
(TTS base URL no longer echoes the server URL) and voice resolution.
- settings UI renders managed providers read-only: the key/base-URL override
inputs and region toggles are hidden, leaving the "managed by server" notice.
Tradeoff: overriding a server provider's key with your own for the same provider
is removed; add a separate custom provider instead. Closes#620.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore(providers): refresh managed-provider copy, drop dead audio-settings, add #620 e2e
- serverConfiguredNotice now says the provider is managed and not editable here,
pointing users to add a separate provider for their own credentials (7 locales).
- delete components/settings/audio-settings.tsx — unreferenced dead code.
- add e2e/tests/managed-provider-620.spec.ts: managed provider hides the
key/base-URL inputs; unmanaged provider keeps them.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(providers): lock the model catalog for managed providers with a pinned list
When the operator pins an allowed model list (MODELS env/yaml ⇒ serverModels),
the model catalog is admin-managed too: the LLM provider panel shows the pinned
models read-only with a "Server" badge and no add / reset / edit / delete
affordances. Without a pinned list the server manages only credentials and the
user keeps curating models.
This removes the prior inconsistency where the settings panel let you add models
to a pinned managed provider that the generation toolbar then filtered out.
e2e: the managed-openai case now also asserts the catalog is locked.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(providers): ignore (not reject) client overrides for managed web-search; clear legacy serverBaseUrl
Addresses review feedback on #624:
1. Managed web-search providers now ignore a client-sent key/baseUrl instead of
validating and rejecting it. A server-configured provider is admin-owned, so
the server config is authoritative and a stale client base URL is dropped
rather than 400-ing the request. The allowlist validation still runs for
unmanaged providers, where the client base URL is actually used.
2. Drop the removed `serverBaseUrl` field from persisted localStorage on
rehydrate (settings version 2 -> 3, stripped in both migrate and merge), so
old clients don't keep a stale server URL in client state.
Tests: web-search route test split into unmanaged-rejects-allowlist and
managed-ignores-client-baseUrl; settings rehydrate test asserts a legacy
serverBaseUrl is stripped. Full suite 381 pass; e2e 2 pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: 杨慎 <117187635+cosarah@users.noreply.github.com>
* test(orchestration): add premature-END regression eval (#598 follow-up)
Adds eval/orchestration/ following the outline-language pattern: a runner
that A/B-tests the director against the same scenario with two prompt
variants — current main (post-#554) and a synthesised pre-#554 baseline
that strips the role-aware summary labels AND the new system.md rules
10/11/12 together.
Pass criterion is now framed as a regression guard rather than a fixture
discrimination test: every scenario's post-fix END rate must stay below
EVAL_END_THRESHOLD (default 20%). The pre-vs-post Δ is reported as
informational data, since #554's reviewer feedback was that earlier
fixtures didn't discriminate.
Empirical finding across 7 shipped model configs (gpt-4.1-mini,
gpt-4o-mini, gpt-5.4-nano, qwen-plus, qwen3.5-flash, deepseek-chat,
deepseek-v4-flash, gemini-2.5-flash, claude-haiku-4-5) with 5 scenarios
modelled on #511 (incl. the exact Tiananmen-3D objection trace, soft
pushback after a long resolved-looking discussion, topic pivot, brief
acknowledgement, and explicit teacher-signals-end-then-user-objects):
no scenario produced a non-zero END rate in either variant. Useful
data for the #554/#598 discussion — the prompt-layer rules don't
measurably change behavior on these shipped models with these prompts,
but the eval is now wired so future regressions show up.
* test(orchestration): add director question-answering eval (#598 follow-up)
Adds an A/B eval probing whether the director routes correctly when the
conversation contains an unanswered user question — both in the first-turn
drift case (agents started answering but drifted onto adjacent topics,
no frustration yet) and in the escalated frustration case (user has
already complained multiple times).
The prod symptom this targets ("答非所问"): agents reply on adjacent
topics rather than answering the literal question, and the director
keeps picking peer agents for "variety" instead of routing back to
the teacher to actually answer.
Scenarios: 5 synthesized cases across math, biology, English grammar,
physics, and calculus. 3 are first-turn drift (no frustration yet),
2 include frustration signals. Each captures: user asks specific
question, agents reply on adjacent topics, director is asked to pick
the next move.
Decision rule-judged into USER | TEACHER | OTHER_AGENT | END:
- USER → ✓ valid (cue user to clarify)
- TEACHER → ✓ valid (re-route to teacher to answer)
- OTHER_AGENT → ✗ wrong (peer-agent "variety" routing — the bug)
- END → ✗ wrong
A/B:
- baseline : current director template with rule 13 stripped
- with_rule : current director template as-shipped
Pass = with_rule.correctRate ≥ EVAL_PASS_THRESHOLD (default 0.7).
Pre-vs-post Δ is reported as informational only.
Note this commit only adds the eval; the rule it strips/restores in
the A/B is injected in the next commit.
* fix(orchestration): inject director rule for answering user questions
Adds rule 13 to lib/prompts/templates/director/system.md so the director
recognizes when the conversation contains an unanswered user question
and routes appropriately — to the teacher (literal role match) by
default, or to USER cue when the question is ambiguous or the user
has already complained multiple times.
This addresses the "答非所问" symptom: when agents drift onto adjacent
topics, the director keeps picking peer agents for "variety" rather
than routing back to the teacher to actually answer. The rule is
preventive (applies whenever the question is unanswered, including
the first turn after drift) rather than reactive-only (waiting for
the user to express frustration).
Rule wording uses constrained-output framing: literal `role: teacher`
match (not "best fit" / "highest priority" / "most knowledgeable"),
and an explicit list of forbidden choices (peer agents, END). Earlier
softer wordings let the model pick the assistant when it seemed more
topically relevant; the literal-match wording prevents that.
Validated by the question-answering eval added in the previous commit.
On google:gemini-3-flash-preview, 5 samples per variant across 5
synthesized scenarios:
| Scenario | baseline | with_rule |
|----------------------------------------------------|----------|-----------|
| math_quadratic_axis_drift_no_frustration | 100% | 100% |
| bio_dark_reaction_drift_no_frustration | 80% | 100% |
| english_team_isare_drift_no_frustration | 20% | 100% |
| physics_inertial_mass_escalated_frustration | 0% | 100% |
| calculus_product_rule_drift_no_frustration | 60% | 100% |
| **mean** | **52%** | **100%** |
3 of 5 scenarios reproduce the bug at baseline (correct rate ≤ 60%);
the rule lifts every scenario to 100%. The remaining 2 baselines are
already high — the rule doesn't regress them.
* fix(orchestration): teach agents to answer the user's literal question
Adds an "Answering the User's Question" section to the agent system
prompt. Before this, the agent SP had no rule for direct-answering — the
persona, role guideline, current-state context, and length guidelines all
pushed the agent to advance the lesson and inspire thought, with no
explicit directive to first answer the user's literal question.
The result observed in prod ("答非所问"): when the user asks a specific
question (a formula, a yes/no, a term), agents reply with adjacent
concepts, examples, or follow-up questions — but never the literal
answer.
The new section directs the agent, on every response where the user
message contains a question, to:
- lead with the concrete answer to the literal question,
- not pivot to an adjacent topic even when it seems pedagogically
richer,
- treat "inspire thought" and peer-differentiation guidance as
applying only AFTER the literal question is answered,
- say "I don't know" directly when uncertain rather than answering
a different question,
- on frustration signals from prior turns, look back at the original
question (before the frustration) and answer THAT specifically.
This is the agent-side counterpart to the director rule landed in the
previous commit. Director routes to the teacher when the question is
unanswered; the teacher now has explicit guidance for what to do when
dispatched.
* refactor+fix(orchestration): rip maxTurns end-to-end; distinguish errors from completion
Two coupled cleanups in one commit since the outcome-handler rewrite
naturally falls out of removing the client-side max-turns loop.
The director graph used `maxTurns: turnCount + 1` to force "one
director→agent cycle per request" — a hack expressing the single-round
contract as a turn limit. This commit removes the hack and the
surrounding user-facing setting, replacing implicit intent with explicit
graph topology.
Server:
- `director-graph.ts`: drop `maxTurns` from state, drop the hard-cap
check at the top of `directorNode`, change `agent_generate → director`
edge to `agent_generate → END`. Single-round contract is now expressed
by topology.
- `lib/types/chat.ts`: drop `maxTurns` and `currentTurn` from
`SessionConfig`; drop `maxTurns?` from `CreateSessionRequest.trigger`.
Client:
- `lib/store/settings.ts`: drop `maxTurns` state, `setMaxTurns` action,
the `'10'` default, and the localStorage migration path.
- `components/agent/agent-bar.tsx`: drop the entire compact-stepper UI
block plus the unused MessageSquare/Minus/Plus lucide imports.
- `components/settings/agent-settings.tsx`: drop the AgentSettings prop
and the multi-agent-only Input block.
- `lib/chat/agent-loop.ts`: drop `maxTurns` parameter, change
`while (turnCount < maxTurns)` to `while (true)` controlled by inner
exits, drop `'max_turns'` reason from `AgentLoopOutcome`.
- `components/chat/use-chat-sessions.ts`: drop the maxTurns lookup, drop
the trailing arg to runAgentLoop, drop vestigial `maxTurns: 0` /
`currentTurn: 0` from session creation.
- `eval/whiteboard-layout/runner.ts`: drop unused MAX_AGENT_TURNS plus
the trailing arg.
i18n: drop `settings.maxTurns` and `settings.maxTurnsDesc` from six
locales (en-US, zh-CN, zh-TW, ja-JP, ar-SA, ru-RU).
Motivation for removing the user-facing setting: the LLM director
controls round length via cue_user / END decisions, so a numeric
"max discussion turns" knob is redundant with rule-driven routing.
When the director prompt was buggy, the cap masked the bug by force-
ending; once director routing is fixed, the cap just removes user
agency.
Before, every non-`cue_user` outcome of the agent loop mapped to
`status: 'completed'` in `use-chat-sessions.ts`. That conflated four
distinct paths:
- `end`: director chose END (legitimate completion)
- `empty_turns`: two consecutive agents returned no text or actions
(parser failure, model timeout, etc.)
- `no_done`: SSE stream ended without a `done` event (infrastructure
failure)
- `aborted`: user pressed stop (handled elsewhere)
The new switch routes `end` to completed, `empty_turns` and `no_done`
through `clearLiveSessionAfterError` so the user sees an inline System
message describing what went wrong instead of a quiet "completed".
- `lib/types/chat.ts`: add `'error'` to `SessionStatus`.
- `components/chat/use-chat-sessions.ts`: rewrite the outcome handler
as a switch; have `clearLiveSessionAfterError` set `status: 'error'`
so all entry points (the runAgentLoop outcome AND existing throw
paths from fetchChat / SSE error events) converge on the same
visible state.
- `components/chat/session-list.tsx`: add `AlertCircle` red icon for
the new error status.
- i18n: add `chat.error.emptyAgentResponses` and
`chat.error.streamInterrupted` strings to all six locales.
This is the in-product fix that the prod investigation surfaced as
an independent root cause of the #511 "discussion ended unexpectedly"
symptom — separate from the director and agent prompt fixes in the
earlier commits of this PR.
* fix(chat): drop dead settingsState binding; wire eval:orchestration:answering script
Two minor CR follow-ups:
- components/chat/use-chat-sessions.ts: the `settingsState` lookup at the
top of runAgentLoopFn was the entry point for the maxTurns lookup
ripped in the previous commit; with maxTurns gone, the binding is
unused and ESLint flags it. Drop the line. (Other uses of
useSettingsStore.getState() elsewhere in this file are unaffected.)
- package.json: the answering eval runner had no convenience script,
while the premature-end runner did. Add eval:orchestration:answering
for symmetry and discoverability.
* fix(orchestration): route ambiguous/unaddressed user turns to teacher, never USER cue
Addresses reviewer issues 2 & 3 (ambiguous "帮我看一下这个" / "Can you take a
look at this?"): the director was cueing USER for vague input, which makes no
agent speak — the user faces dead air with nothing to react to ("nobody
responds"); and when an agent did speak it guessed a topic instead of asking
what the user meant.
Root cause was the previous rule 13, which offered `{"next_agent":"USER"}` as
a valid response to an ambiguous user turn. A USER cue is the wrong tool here:
it returns control to the user without any agent speaking. The right behavior
is to dispatch the teacher, who either answers or — if the message is too
vague — asks a clarifying question out loud.
Director (`director/system.md` rule 13):
- When the most recent user turn is unaddressed (clear question, vague
request, OR frustration signal), the only acceptable output is the literal
`role: teacher` agent id.
- USER cue is now explicitly forbidden as a response to a user turn (reserved
for rule 7, where an agent has just asked the user something).
- Tightened the END prohibition: a high turn count or a thoroughly-discussed
topic does NOT mean the specific question was answered. Added rule 5
(don't-drag-on) to the override list, since that pressure was driving the
director to END on well-discussed-but-unanswered turns.
Agent (`agent-system/system.md`):
- Added a clause to "Answering the User's Question": if the user's message is
too vague to answer (no clear referent), ask ONE short clarifying question
with a concrete option or two — do not guess a topic and lecture, do not
stay silent.
Eval (`answering-runner.ts` + `scenarios/answering.json`):
- Reclassified USER as wrong (dead air); only TEACHER counts as correct now
(teacher answers, or asks a clarifying question for vague input).
- Added two ambiguity scenarios: a bare "帮我看一下这个" opener, and a vague
"再帮我看看这个吧" follow-up after a real Q&A.
- Made the rule-13 strip regex match by rule number rather than heading text,
so it survives heading rewrites.
On google:gemini-3-flash-preview, 10 samples per variant, all 7 scenarios
PASS (with_rule mean ~97%, baseline ~57%). The two ambiguity scenarios:
ambiguous_look_at_this 100%/100%, ambiguous_vague_followup 20%→100%.
Manually verified the agent side: for "帮我看一下这个" the teacher now replies
"…你想讨论的是具体的代码逻辑,还是 Agent 的决策流程图呢?" (clarifying question +
concrete options) instead of guessing.
Note: reviewer issue 1 (follow-up not answered) could not be reproduced on
this branch across 7 configurations; it is consistent with the deployed
environment running older code and/or provider API flakiness, which the C7
error-vs-completion distinction in this PR already surfaces instead of a
silent 已结束.
* docs(eval): fix stale physics scenario description after USER→wrong reclassification
The physics_inertial_mass scenario description still said "USER-cue signal —
but TEACHER re-answer is also valid", which contradicts the new classifier
(USER is dead air = wrong; only TEACHER is correct). Cosmetic only — the
description field is printed into the report, never used in classification.
* add Azure ASR config and localization
* add transcribeAzureASR func
* fix(settings): prevent Azure STT crash in ASR modal
* feat(i18n): add Azure STT provider support in language locales
* fix(settings): enforce "usable provider ⇒ concrete model" invariant (#580)
Layer 1 — resolve provider AND model atomically at every source:
- add resolveSelectedModel(): like validateModel but no empty-input
short-circuit, so it returns '' only when the provider has no models
- fetchServerProviders: symmetric LLM/image/video provider recovery +
resolveSelectedModel; remove the asymmetric #577 isServerConfigured-gated
LLM tail and the separate first-load auto-select block (now subsumed,
and covers client-API-key providers too)
- setProviderConfig: entering an API key for the active/unset LLM provider
resolves a concrete model in the same set()
- setVideoProvider: resolve a model on switch (was id-only); setImageProvider
routed through the shared resolver
Layer 2 — remove states unreachable under the invariant:
- add shared isLLMProviderConfigured / hasUsableLLMProvider; gate the
landing-page generate button on a usable provider (state A vs B) and drop
the modelNotConfigured toast + forced SettingsDialog
- generation-toolbar: use the shared predicate; drop the dead "Select Model"
label/tooltip fallback
- delete dead components/settings/model-selector.tsx (zero refs) and the
now-orphan settings.selectModel i18n key (6 locales)
Note: generation-toolbar's `providerEntries.length === 0` branch is KEPT —
it is reachable via search (search-no-results), not the dead no-provider
state the issue assumed. modelNotConfigured i18n key kept (still used by
the chat path in use-chat-sessions).
Tests: resolveSelectedModel + hasUsableLLMProvider unit tests; server-sync
invariant tests (client-key resolution, atomic API-key entry, provider
switch, serverModels-preference + first-load regression guards).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(settings): address code review — symmetric image/video config resolution
Code review Important #1: fold atomic model resolution into
setImageProviderConfig / setVideoProviderConfig (design doc Layer 1 step 2
scoped these). Deleting the selected custom image/video model on the active
provider now resolves to a valid model in the same set() instead of leaving
it stale until the next server sync — restores LLM/image/video symmetry.
Minor #2/#3: document the deliberate store-level (credential path) vs
UX-level (incl. ≥1 model) "usable" split on isProviderUsable; clarify that
setProviderConfig also adopts providerId on the first-load API-key path.
Tests: +2 invariant tests (delete selected custom image/video model →
falls back to a valid model). 89/89 store tests pass, tsc clean.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(settings): keyless providers need explicit baseUrl to count as usable (#580)
Code-review/e2e follow-up. ollama/lemonade ship requiresApiKey:false +
a registry defaultBaseUrl, so the old isLLMProviderConfigured counted them
as configured on a fresh install — but buildFallback/reconcile never
auto-selects keyless providers, so hasUsableProvider could be true while
modelId stayed '', re-enabling generation with no model (the exact #498/#580
class of bug, just via the keyless path).
Narrow isLLMProviderConfigured to be consistent with isProviderUsable:
keyless ⇒ usable only once the user sets an explicit baseUrl (registry
defaultBaseUrl alone is not user intent); server-config and key-requiring
paths unchanged. Now gate + toolbar + reconcile agree, and genuine State A
(no usable provider) is reachable again.
Add e2e/tests/model-invariant-580.spec.ts: State A (no provider → generate
disabled + single "Set up model" affordance, no toast/forced dialog) and
State B (server-configured → concrete model auto-resolved, generation
enabled). +3 keyless unit tests. 92/92 store tests + 2 e2e pass, tsc clean.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(settings): re-resolve selection on bulk provider-config change (#580)
Self-test found: deleting the selected provider in Settings left the model
selector pointing at the deleted/invalid provider (or, via the component's
hand-rolled fallback, at an unusable built-in like openai with no key).
Root cause: setProvidersConfig (the bulk setter behind delete-provider /
delete-model) did ZERO re-resolution — Layer 1 covered setProviderConfig
(singular) + image/video setters + the reconcile, but not this path. The
component's confirmDeleteProvider then picked Object.keys()[0] (always a
built-in, ignoring usability), the exact per-call-site hand-rolled shape
#580 condemns.
Fix at the source: setProvidersConfig now re-resolves (providerId, modelId)
via the canonical isLLMProviderConfigured + resolveSelectedModel — keep the
current provider if still usable, else first usable, else State A. Removed
the brittle confirmDeleteProvider override (kept only its local Settings-tab
selection). Now every bulk config mutation (delete, import, reset) holds the
invariant.
Tests: +2 store tests (delete selected/only-usable provider → State A, not
the deleted/invalid one; delete non-selected → keep usable selection).
94/94 store tests, full suite green (only pre-existing ssrf DNS), tsc/eslint clean.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(settings): one shared LLM-selection resolver for all config edits (#580)
Clarified repro: the realistic case isn't deleting a custom provider — it's
clearing the SELECTED provider's API key so it becomes invalid. setProvider
Config only re-resolved when the edit made a provider *usable*; the
"became unusable" transition fell through (return base) → the now-invalid
provider stayed selected. The previous commit fixed only the bulk path.
Root-cause fix: extract one shared `resolveLLMSelection(config, providerId,
modelId)` — keep current provider if still usable, else first usable, else
State A; then resolve the model. Use it in BOTH setProviderConfig (single
edit: key add/clear, model-list edit) and setProvidersConfig (bulk: delete,
import, reset). The two paths can no longer diverge — exactly the per-call-
site asymmetry #580 set out to eliminate. Drops the now-unused
isProviderUsable import.
Tests: +2 store tests (clear selected provider key → drops stale selection;
clear non-selected key → keeps usable selection). 96/96 store tests, full
suite green except pre-existing ssrf DNS; tsc + eslint clean.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* style: prettier-format #580 test specs
CI 'Lint, Typecheck & Unit Tests' ran prettier . --check and failed on the
two added test specs (only tsc/eslint/vitest were run locally). Pure
whitespace reformat, no logic change — 96/96 store tests still green.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Add Alibaba Cloud DashScope HappyHorse text-to-video support as an OpenMAIC video generation provider.
Co-authored-by: xuruiray <15962843+xuruiray@users.noreply.github.com>
* feat(providers): add international base URL chips for GLM/Kimi/MiniMax
- Add optional alternateBaseUrls field to ProviderConfig
- Populate GLM, Kimi, MiniMax with China/International endpoints
- Settings UI renders chips below base URL input; clicking fills and auto-saves
- i18n: settings.baseUrlRegion.{china,international} in all 5 locales
- README / README-zh: list GLM and add quick-examples block
Closes#448
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* docs: use glm-5.1 as the GLM default model example
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: 杨慎 <117187635+cosarah@users.noreply.github.com>
* feat(pdf): add MinerU Cloud API as PDF parsing provider
Add MinerU Cloud (v4 API) as a new PDF provider alongside unpdf (built-in)
and MinerU (self-hosted). Users can now parse PDFs via the cloud API without
deploying a self-hosted MinerU instance.
- New provider `mineru-cloud` with API key auth and optional base URL
- Cloud flow: batch create → presigned upload → poll → ZIP download → parse
- Extract shared `mineru-parser.ts` from inline code (used by both paths)
- Settings UI adapted for cloud (API key required) vs self-hosted (base URL required)
- Server-side env var support: PDF_MINERU_CLOUD_API_KEY / PDF_MINERU_CLOUD_BASE_URL
- SSRF protection on cloud verification endpoint
- i18n translations for en-US, zh-CN, ja-JP, ru-RU
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(provider-config): revert PDF activation to requiresBaseUrl
Reverts the PDF section from keylessProviders back to requiresBaseUrl: true
to fix failing test: mineru with only apiKey (no baseUrl) should not activate.
mineru-cloud API key can be configured via browser settings UI instead.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(pdf-settings): enable test button when API key is server-configured
The test connection button was disabled when the API key was only
configured server-side (not entered by user in browser). Now checks
isServerConfigured in addition to user-entered values.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Keyless providers (e.g. Ollama) with a hardcoded defaultBaseUrl were
unconditionally passing the provider filter because `!requiresApiKey`
short-circuited to true. Now keyless providers require an explicit
user-provided baseUrl or server configuration to appear.
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(audio): extend TTSProviderId/ASRProviderId to support custom providers
* feat(audio): update provider registry helpers for custom provider support
* feat(audio): route custom providers to OpenAI-compatible implementations
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(audio): add custom TTS/ASR provider CRUD to settings store
* feat(audio): add dialog for creating custom audio providers
* feat(audio): add custom provider UI with voice management and delete
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(i18n): add custom audio provider translation strings
* fix(audio): resolve remaining type errors for custom provider support
Add `as keyof typeof` casts where TTSProviderId/ASRProviderId (which now
include template literal types) index into the built-in-only registries
TTS_PROVIDERS, ASR_PROVIDERS, DEFAULT_TTS_VOICES, and DEFAULT_TTS_MODELS.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(audio): allow custom provider IDs to reach switch default branch
The early guard `if (!provider) throw` blocked custom provider IDs from
reaching the switch-case default branch where they get routed to
OpenAI-compatible implementations.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(audio): add default model field to dialog and polish voice list UI
- Add "Default Model" input to custom audio provider dialog (fixes
Kokoro needing model:"kokoro" instead of fallback "gpt-4o-mini-tts")
- Redesign voice list as aligned table with column headers, hover
reveal delete buttons, and empty state message
- Add Enter key support to voice add inputs
- Use consistent grid layout for add voice row
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(audio): fallback to customDefaultBaseUrl when testing custom TTS provider
The baseUrl field in provider config is empty by default (it's an
override field). Custom providers store their default URL in
customDefaultBaseUrl, which needs to be used as fallback for test.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(audio): auto-select first voice when adding to custom TTS provider
When a custom provider's voice is 'default' (initial state before any
voices are added), adding the first voice now automatically updates the
active voice selection so test TTS works immediately.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(audio): fallback to customDefaultBaseUrl in all TTS call sites
Scene generator, discussion TTS, and agent bar voice preview all read
providerConfig.baseUrl which is empty for custom providers (the default
URL is stored in customDefaultBaseUrl). Add fallback chain to all 4
call sites so custom providers work during actual playback, not just
in the settings test.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(audio): include custom provider voices in agent voice picker
getAvailableProvidersWithVoices only iterated built-in TTS_PROVIDERS,
so custom providers never appeared in the agent bar voice dropdown.
Now also iterates ttsProvidersConfig for custom-tts-* entries and
includes their customVoices in the picker.
Also updated getServerVoiceList, findVoiceDisplayName, and
resolveAgentVoice to handle custom provider voice lookups.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(audio): fallback to customDefaultBaseUrl in all ASR call sites
Same issue as TTS: audio-recorder, asr-settings, and audio-settings
all read providerConfig.baseUrl which is empty for custom providers.
Add customDefaultBaseUrl fallback to all 3 ASR call sites.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(audio): add model list management for custom ASR providers
Custom ASR providers now support adding/removing models with a table
UI (same design as TTS voice list). The model selector dropdown shows
custom models and auto-selects the first one.
Also adds custom ASR providers to the Toolbar's ASR provider dropdown
and fixes custom provider handling in audio-settings.tsx (baseUrl
fallback, request URL preview, API key section visibility).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(audio): seed customModels from defaultModel and fix ASR model label
- When creating custom ASR provider with a defaultModel, auto-add it
to customModels so the model list isn't empty on first visit
- Fix ASR settings label from "TTS Model" to "Default Model"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(audio): separate ASR model management from creation dialog
ASR models should be managed in provider settings (add/remove from
list, select default), not pre-filled at creation time. Unlike TTS
where a single default model suffices, ASR users need to manage
multiple models (e.g. whisper-small, whisper-large-v3).
- Remove Default Model field from ASR creation dialog (keep for TTS)
- Remove defaultModel parameter from addCustomASRProvider
- ASR models are added via the model list UI in provider settings
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(audio): simplify ASR model management — first model is default
Remove the separate model selector dropdown for custom ASR providers.
The first model in the list is always used as default. Users manage
the model list only (add/remove), no separate "default" selection.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(audio): add loading state and detailed errors to ASR test
- Show spinner with "Processing..." while waiting for transcription
- Disable record button during processing
- Show specific error messages from API (e.g. "No transcription
generated") instead of generic failure text
- Handle empty transcription result as an error with helpful message
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(i18n): use correct key for processing label in ASR test button
* fix(audio): polish custom provider UX and type safety
- Add proper type declarations for custom provider fields (customName,
customDefaultBaseUrl, customVoices, etc.) eliminating 30+ unsafe casts
- Show custom ASR providers in toolbar with default language list
- Hide custom ASR providers without models from toolbar selection
- Add no-models warning in ASR settings panel
- Add delete confirmation dialog for custom TTS/ASR providers
- Add duplicate voice/model ID validation with toast error
- Add dedicated i18n keys for ASR model management (modelNamePlaceholder, addModel)
- Fix i18n key for ASR processing label (settings.asrProcessing)
- Add radio-button model selection in custom ASR provider settings
- Add visible OpenAI-compatible description in provider creation dialog
- Add CUSTOM_ASR_DEFAULT_LANGUAGES constant for toolbar language options
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(test): add isCustomTTSProvider/isCustomASRProvider to audio types mock
The settings-server-sync test mocked @/lib/audio/types as an empty object,
but settings.ts now imports isCustomASRProvider for provider validation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(audio): add customDefaultBaseUrl fallback in all TTS/ASR call sites
When a custom provider is created, the actual URL is stored in
customDefaultBaseUrl while baseUrl is initialized empty. Several call
sites only checked baseUrl, causing fetch failures during course
generation. Add fallback to customDefaultBaseUrl in:
- generation-preview/page.tsx (course generation TTS)
- tts-providers.ts (getCurrentTTSConfig)
- asr-providers.ts (getCurrentASRConfig)
- media-popover.tsx (TTS preview)
- tts-config-popover.tsx (TTS preview)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* style: format generation-preview/page.tsx
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: remove unused ttsSpeedRange variable in media-popover
Flagged by CodeQL code quality check.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: update Ollama logo to official version
Closes#399
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: improve OpenAI and Ollama logo visibility across themes
OpenAI logo (white fill) was invisible on light backgrounds, and Ollama
logo (black fill) was invisible on dark backgrounds. Normalize OpenAI SVG
to black fill and apply dark:invert via a central MONO_LOGO_PROVIDERS set.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(i18n): add missing Ollama and Doubao provider names for ru-RU
Closes#388
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(i18n): use translated provider names in settings detail panel
The provider detail header was showing hardcoded names from the provider
registry (e.g. "豆包", "硅基流动") instead of i18n-translated names.
Apply the same providerNames lookup used in the provider list.
Also adds missing Ollama and Doubao keys for ru-RU.
Closes#388
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor(i18n): migrate to i18next framework
Replace hand-rolled i18n with i18next + react-i18next so that adding a
new language only requires dropping a JSON file in lib/i18n/locales/.
- Add i18next, react-i18next, i18next-browser-languagedetector deps
- Generate zh-CN.json / en-US.json from existing TS translation modules
- Rewrite lib/i18n/index.ts as a thin wrapper around i18n.t()
- Rewrite use-i18n hook to delegate to useTranslation(); external API
(locale, setLocale, t) is unchanged so consumers need no changes
- SSR-safe: LanguageDetector only loaded on client side
Closes#327
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(i18n): use interpolation for greeting to support natural phrasing
Replace string concatenation (greeting + displayName) with two
i18next keys: greetingWithName (with {{name}} interpolation) and
greetingDefault (standalone, no name).
This lets each locale choose natural phrasing independently:
- zh-CN: "嗨,同学" / "嗨,Alice"
- en-US: "Hi there" / "Hi, Alice"
- Future locales can avoid gender issues by choosing genderless defaults
Also widen the t() type signature to accept interpolation options.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor(i18n): auto-discover locale files via dynamic import
Replace hardcoded zh-CN/en-US imports with i18next-resources-to-backend
and dynamic import(`./locales/${language}.json`). Bundler scans the
locales/ directory at build time, so adding a new language now requires
only dropping a JSON file — zero changes to existing code.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(i18n): resolve hydration mismatch by deferring language detection
LanguageDetector ran during i18next init(), detecting browser language
before React hydrated — server rendered zh-CN while client switched to
en-US immediately, causing a hydration mismatch.
Fix: remove i18next-browser-languagedetector; init with a fixed lng
(zh-CN) so server and client agree on the first render. Language
detection is now done in I18nProvider's useEffect after hydration.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor(i18n): remove hardcoded locale list from language detection
Replace manual locale validation and startsWith('zh') prefix matching
with i18next's built-in fallback mechanism. Now changeLanguage() is
called with navigator.language directly — if the exact locale has no
JSON file, i18next automatically falls back to fallbackLng.
Also widen Locale type from union to string so adding new languages
doesn't require modifying types.ts.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(i18n): add course language config with 11 languages and UI linkage
- Add lib/i18n/course-languages.ts with curated language list
(zh-CN, zh-TW, en-US, ja, ko, fr, de, es, pt, ru, ar) including
native labels and English prompt names
- Course language defaults to UI locale on first visit; once user
explicitly picks a language, that choice persists across sessions
- Replace toggle button with dropdown selector showing native labels
- Widen language types from 'zh-CN'|'en-US' to string throughout
- Fix hardcoded language ternaries in LLM prompt injection:
- prompt-builder.ts: use getCourseLanguagePromptName()
- classroom-generation.ts: remove normalizeLanguage() that forced
all non-English to zh-CN
- PBL system prompt, agent templates, generate-pbl: append language
instruction for non-zh/en languages
- quiz-grade API: add language suffix for grading feedback
Closes#327
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(quiz): use course language instead of UI locale for grading
quiz-view was passing the UI locale to the grading API, causing AI
feedback to follow the student's answer language instead of the course
language. Now reads stage.language from the store.
Also strengthen the grading prompt: explicitly instruct the LLM to
write comments in the course language regardless of the student's
input language.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* revert: remove course language config and quiz fix from i18next branch
Reverts f7bd6bd and 5bb5133 — these are independent features that
should go into a separate branch/PR.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* chore(i18n): regenerate locale JSON after merging latest main
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* chore(i18n): remove obsolete TS translation files
These files are replaced by lib/i18n/locales/*.json and are no longer
imported anywhere in the codebase.
Removed: chat.ts, common.ts, generation.ts, settings.ts, stage.ts
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* style(i18n): fix prettier formatting in locale JSON files
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor(i18n): replace hardcoded language options with central locale registry
Add lib/i18n/locales.ts as a single source of truth for supported languages.
Language selectors in header and homepage now render dynamically from this
registry. Also adds supportedLngs to i18next config so unsupported languages
fall back correctly. Adding a new language now only requires a JSON file and
one line in the registry.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(i18n): add missing rename keys to JSON locale files
Add classroom.rename, classroom.renamePlaceholder, and
classroom.renameFailed that were added to generation.ts on main
but missing from the JSON locale files.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor(i18n): extract LanguageSwitcher, restore type safety, fix locale resolution
- Extract shared <LanguageSwitcher /> component from page.tsx and header.tsx
- Derive Locale type from supportedLocales registry (as const satisfies)
- Add resolveLocale() to match browser language prefixes (e.g. 'en' → 'en-US')
- Remove config.ts changes (nonExplicitSupportedLngs + inline resources) that
broke translation loading when combined with resourcesToBackend
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(i18n): use i18next double-brace interpolation instead of manual .replace()
- Convert all {var} placeholders in locale JSONs to {{var}} (i18next default)
- Replace .replace('{var}', value) calls with t(key, {var: value}) in all
consuming components: lecture-notes-view, pbl-renderer, use-pbl-chat,
generation-preview, whiteboard-history, agent-settings
- Widen t() type signature in handleIssueComplete to accept interpolation options
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(i18n): unify greeting with default nickname, add translation guide
- Remove greetingDefault key; greeting always uses greetingWithName
with displayName (falls back to profile.defaultNickname)
- Change en-US defaultNickname from "Student" to "Learner"
- Add TRANSLATION_GUIDE.md documenting how to add languages and
explaining keys with non-obvious UX design intent
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(tts): unify model selection to per-provider and fix ElevenLabs model_id (#324)
- Move model selection from global ttsModelId to per-provider
ttsProvidersConfig[providerId].modelId
- Remove supportsModelSelection flag, use models.length > 0 instead
- Add defaultModelId to TTSProviderConfig and ASRProviderConfig
- Add providerOptions field to TTSModelConfig for future extensibility
- Fix ElevenLabs hardcoded model_id: 'eleven_multilingual_v2'
- Fix MiniMax TTS using config.model instead of config.modelId
- Update model lists from provider docs:
- Qwen: add qwen3-tts-instruct-flash, qwen-tts
- ElevenLabs: add eleven_flash_v2_5, eleven_flash_v2
- MiniMax: remove non-existent speech-2.8 series
- Replace custom model CRUD UI with simple Select dropdown
- Remove MiniMax-specific hardcoded model selector from audio-settings
- Add migration for old ttsModelId/asrModelId/model fields
* feat(tts): voice picker groups by provider:model, sets both model and voice
Voice selection in agent bar now groups voices by model. Picking a
voice from a model group sets both modelId and voiceId on the agent.
TTS settings shows available models as display-only chips.
- Add compatibleModels field to TTSVoiceInfo (OpenAI marin/cedar restricted to gpt-4o-mini-tts)
- Add modelId to agent voiceConfig and ResolvedVoice
- Add ModelVoiceGroup to ProviderWithVoices, build groups in getAvailableProvidersWithVoices
- Update AgentVoicePill and TeacherVoicePill to iterate modelGroups
- Thread modelId from voice selection through discussion TTS pipeline
- Replace model Select with display-only chips in tts-settings
* fix(tts): show provider name in voice picker group headers
* fix(tts): restore MiniMax speech-01 models per official API docs
* fix(tts): add MiniMax speech-2.8 models per official docs, default to speech-2.8-hd
* feat(tts): expand MiniMax voice list with recommended voices
* fix(tts): remove non-official MiniMax recommended voices, keep 10 from official list
* fix: address CR findings - align defaults, fix test mocks, ASR modelId fallback
* fix(tts): pass modelId in voice preview and classroom generation
* fix(tts): voice picker highlights only the exact model:voice match
---------
Co-authored-by: 杨慎 <117187635+cosarah@users.noreply.github.com>
* fix(settings): allow model-level test connection without client-side API key and fix i18n keys
Remove the client-side apiKey guard in model edit dialog so test connection
delegates to the server (matching provider-level behavior). Also replace
non-existent common.save/common.cancel i18n keys with settings.saveModel/
settings.cancelEdit in image and video model dialogs.
Closes#308
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(settings): disable model-level test button when no API key is available
Match provider-level behavior: disable the test connection button in the
model edit dialog when requiresApiKey && !apiKey && !isServerConfigured.
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add MiniMax LLM models (M2–M2.7), TTS provider (speech-2.8/2.6/02/01),
image generation (image-01), and video generation (Hailuo 2.3/02,
T2V-01). Unify base URLs to api.minimaxi.com and add MiniMax-specific
base URL normalization for the Anthropic-compatible endpoint.
Co-authored-by: Hi-Jiajun <3138947285@qq.com>
Add ttsModelId/asrModelId to persisted settings, model management UI
for providers that support model selection, and propagate selected
model through preview, generation, and transcription flows.
Co-authored-by: 刘少杰 <liushaojie@cvte.com>
* feat(tts): add Doubao TTS 2.0 (Volcengine Seed-TTS 2.0) provider
Add Doubao TTS as a new TTS provider with 17 voices (14 Chinese, 3 English),
streaming response parsing for Volcengine's chunked JSON format, rate-limit
error handling, and full integration across types, constants, provider
implementation, server config, settings store, i18n, and UI components.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* ui(tts): split Doubao API key into separate App ID and Access Key fields
Show two input fields (App ID + Access Key) for Doubao TTS in settings,
instead of requiring the compound "appId:accessKey" format. The values
are combined internally so no changes are needed to the API layer.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(tts): address code review feedback for Doubao TTS provider
- Add TODO note explaining TTSRateLimitError's future use for retry/backoff
- Replace atob() + manual byte loop with Buffer.from() for server-side code
- Trim supportedFormats to ['mp3'] since only mp3 is used in requests
- Add i18n keys for Doubao App ID / Access Key labels (zh-CN + en-US)
- Add show/hide toggle to Access Key input field
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(tts): add resolveVoice() and getServerVoiceList() utilities
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(tts): add AudioIndicator equalizer bars component
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(tts): add onSegmentSealed callback to StreamBuffer
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(tts): add voiceOverrides field to AgentConfig and AgentTemplate
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(tts): add useDiscussionTTS hook with audio queue and cleanup
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(tts): add audio state indicator to Roundtable bubble
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(tts): wire onSegmentSealed callback through chat sessions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(tts): add per-agent voice dropdown to AgentBar
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(tts): integrate useDiscussionTTS in Stage and pass state to Roundtable
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* style(tts): refine voice dropdown to pill-style selector
Replace native select styling with a compact rounded-full pill
that blends into the agent row. Remove border, use muted bg,
smaller text, and a custom chevron icon.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* style(tts): use shadcn Select for voice dropdown, link with TTS toggle
- Replace native <select> with shadcn Select component for consistent UI
- Hide voice dropdown when TTS is muted (ttsMuted)
- Compact pill-style trigger with rounded-full, no border, muted bg
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* style(tts): add voice label prefix and always show dropdown
Show "音色: Alloy" instead of plain "Alloy" in the voice pill.
Always show dropdown regardless of mute state (voice config is
independent of playback).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* style(tts): add volume icon hint in collapsed AgentBar
Show a small Volume2 icon in the collapsed pill when voice config
is available, hinting that voice settings are inside.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(tts): fix voice dropdown layout and click handling
- Move voice pill below agent name (second line) to prevent
horizontal overflow in English
- Wrap Select in div with onPointerDown stopPropagation to fix
Radix click-through to parent row
- Add line-clamp-1 to descriptions for consistent row height
- Use items-start instead of items-center for better multi-line alignment
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor(tts): redesign AgentBar voice layout for compactness
- Single-line layout: checkbox · avatar · name · role · voice pill
- Remove descriptions from agent rows (saves vertical space)
- Extract AgentVoicePill component to isolate Select event handling
- Smaller avatars (size-7), tighter row padding (py-1.5)
- Voice pill uses Volume2 icon + voice name (no prefix text)
- Works in both Chinese and English without overflow
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(tts): cross-provider voice selection per agent
- Change voiceConfig from per-provider lookup to explicit
{ providerId, voiceId } per agent
- Each agent can use a different TTS provider's voice
- Voice picker dropdown groups voices by provider
- useDiscussionTTS routes TTS requests per agent's provider
- resolveAgentVoice falls back to global provider if no config
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(tts): align role badge and voice pill across agent rows
Give role badge fixed width (w-14 text-right) so role text
and voice pills align vertically across all rows regardless
of agent name length.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(tts): fix role badge and voice pill alignment
Wrap role badge + voice pill in a fixed-width container
(w-[9.5rem] justify-end) so both align vertically across
all agent rows regardless of name or role text length.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* style(tts): align role badge and voice pill across agent rows
Add min-w-[52px] text-right to role badge so it starts at a
consistent position regardless of agent name length.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(tts): use fixed w-[60px] for role badge alignment
* fix(tts): use fixed w-[88px] for voice pill alignment
* fix(tts): prevent click-outside from closing AgentBar when Select portal is open
* fix(tts): comprehensive voice picker rewrite
- Replace Radix Select with Popover + button list (fixes click issue)
- Fix getAvailableProvidersWithVoices to always include global provider
- Widen panel from w-80 to w-96 (prevents name truncation)
- Voice pill uses primary color instead of gray (more visible)
- Extract renderAgentRow helper to reduce duplication
- Popover shows voices grouped by provider with active state
- Add findVoiceDisplayName utility
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(tts): align voice provider availability with toolbar logic
* fix(tts): fallback to first available provider when global provider has no voices
* refactor(tts): remove global provider fallback from voice resolution
Voice resolution now only depends on available providers (those with
API keys or server-configured). No more globalProviderId parameter.
Fallback is first available provider, then browser-native-tts.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(tts): add browser native TTS voices to agent voice picker
Load speechSynthesis.getVoices() in AgentBar and include as a
"Browser Native" provider group in the voice popover. No API key
needed - always available if browser supports it.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(tts): simplify toolbar TTS to on/off toggle, add disabled state
Toolbar:
- Replace volume slider with simple TTS on/off toggle button
- Remove ttsMuted/ttsVolume/onVolumeChange props from CanvasToolbar
- Toggle now controls ttsEnabled (not ttsMuted)
AgentBar:
- Collapsed: show VolumeX icon when TTS disabled
- Voice pills show disabled state (gray, cursor-not-allowed, no popover)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor(tts): simplify Settings TTS tab to toggle + provider config
Remove voice selection, speed slider, preview/test, Azure locale
filter from Settings TTS tab. Voice is now per-agent in AgentBar.
Keep: on/off toggle, provider selector, API key + base URL config.
Add hint text pointing to AgentBar for voice configuration.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor(tts): simplify media popover TTS tab to toggle only
* fix(tts): add voice config hint to media popover TTS tab
* feat(tts): add per-voice preview button in voice picker
Each voice row in the popover has a small speaker icon button.
Click to preview the voice with "欢迎来到AI课堂" / "Welcome to
AI Classroom" (follows i18n). Browser native uses Web Speech API,
server TTS calls /api/generate/tts. Click again or close popover
to stop. Shows spinner while generating.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(tts): preview text follows course language instead of UI language
* refactor(tts): redesign AgentBar expanded panel layout
- Teacher always at top with voice pill (works in both modes)
- Mode tabs moved below teacher
- Auto mode: single compact row with shuffle icon + description
- Max turns: compact inline row with smaller input
- Preset mode: only student agents listed (teacher already above)
- Remove large shuffle animation from auto mode
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor(tts): merge max turns into teacher row
* refactor(tts): separate teacher row and max turns, use stepper UI
- Teacher row: avatar + name + voice pill only
- Max turns: bottom row with MessageSquare icon + compact stepper
(minus/number/plus in a rounded pill)
- Remove Input component dependency
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(tts): increase voice pill contrast in dark mode
* fix(tts): make max turns input editable, tighten panel padding
* fix(tts): restore shuffle animation in auto mode (compact version)
* fix(tts): adjust auto mode text spacing and add voice auto-assign hint
* fix(tts): auto-close voice popover after selecting a voice
* fix(tts): increase auto mode vertical padding for better balance
* fix(tts): push auto mode text toward bottom with flex spacer
* fix(tts): reduce auto mode bottom padding
* feat(tts): wait for TTS audio to finish before next agent turn
Add waitForDrain() to useDiscussionTTS that returns a promise
resolving when the audio queue is empty. The agent loop in
useChatSessions now awaits this after buffer drain, so the next
agent's turn doesn't start until the current agent's TTS audio
finishes playing.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(tts): keep bubble visible while TTS audio is still playing
When buffer drains (text=null) but audio indicator is still active,
don't clear liveSpeech. Clear it only when audio state goes idle.
This keeps the speech bubble visible until TTS finishes.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(tts): hold discussion bubble until TTS audio finishes
When StreamBuffer fires the done signal (onLiveSpeech null), Stage
now checks if TTS is still playing. If so, it defers clearing the
bubble state. The bubble stays visible until onAllAudioEnd fires
from the TTS hook (queue empty + nothing playing), then clears.
This prevents the jarring UX where the bubble disappears while
the agent's voice is still audible.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(tts): fix bubble hold - guard onStopSession instead of onLiveSpeech
Root cause: bubble disappears because doSessionCleanup fires via
onStopSession when the agent loop ends naturally, NOT because of
onLiveSpeech(null, null).
Fix: when onStopSession fires and TTS is still playing, defer
doSessionCleanup to onAllAudioEnd callback. Manual stop (user
presses button) still cleans up immediately via handleStopDiscussion.
Use doSessionCleanupRef to avoid circular dependency between
discussionTTS hook and doSessionCleanup useCallback.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(tts): guard BOTH onLiveSpeech and onStopSession for bubble hold
Two paths clear the bubble:
1. onLiveSpeech(null, null) from StreamBuffer done → clears liveSpeech
2. onStopSession → doSessionCleanup → clears all state
Both fire when agent loop ends. Path 1 fires first (tick loop),
path 2 fires after (waitUntilDrained resolves). Both must be
guarded when TTS is still playing.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(tts): hold bubble during TTS playback and respect playback speed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(tts): LLM picks voice matching agent persona during generation
- Client sends available voices (providerId + voiceId + name) to
/api/generate/agent-profiles
- LLM prompt asks to pick a voice matching each agent's personality
- Parse "providerId::voiceId" from response, save as voiceConfig
- Fallback to index-based assignment if LLM doesn't pick
- Browser native voices hidden when server providers are available
- saveGeneratedAgents accepts and persists voiceConfig
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(tts): restore volume slider in classroom toolbar
Revert the toolbar simplification from 36e3997 that replaced the
volume slider with a TTS on/off toggle. The volume control with
hover slider is a core classroom UX. TTS on/off is controlled via
Settings and Media popover instead.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(tts): teacher uses global lecture voice in discussion when no voiceConfig override
* fix(tts): teacher always uses global lecture voice, no overrides
* fix(tts): sync playback speed to currently playing audio in real-time
* fix(tts): address code review issues
- Issue 2: enabled flag now checks ttsEnabled && !ttsMuted in stage.tsx
- Issue 4: remove unused browserAvailableVoices from useDiscussionTTS
- Issue 5: remove dead code in audio-settings.tsx (Slider, Loader2, handleTTSVoiceChange, handleTTSSpeedChange, handleTestTTS, testingTTS, ttsTestStatus, ttsTestMessage, testText, ttsSpeed, setTTSSpeed, and unused browser-tts-preview imports)
- Issue 6: shouldHold now checks queue length in addition to isPlayingRef
- Issue 8: hide AgentVoicePill for teacher row in agent-bar.tsx (teacher voice is controlled in Settings)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(tts): address PR review — abort preview fetch, defer error recovery
1. Add AbortController to voice preview server TTS fetch, abort on
stopPreview to prevent stale responses on rapid switching
2. Use queueMicrotask for processQueue calls in error/ended handlers
to prevent synchronous recursion if multiple items fail consecutively
3. Add ordering invariant comment on sealLastText's onSegmentSealed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(tts): restore teacher voice pill, respect voiceConfig override
* fix(tts): sync volume and mute to discussion TTS audio in real-time
* fix(tts): allow browser-native TTS alongside server providers
* fix(tts): remove top padding from voice popover content
* fix(tts): make selectedAgents reactive to voiceConfig changes
* fix(tts): use agents record instead of listAgents() to avoid infinite loop
* fix(tts): single source of truth for teacher voice
Teacher voice pill now reads/writes global ttsProviderId + ttsVoice
(same settings used by lecture TTS). This ensures lecture and
discussion always use the same teacher voice. Student agents still
use per-agent voiceConfig.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: add avatar descriptions for smarter LLM avatar selection
Each avatar now has a one-line description (appearance, vibe) sent
to the agent-profiles generation API. LLM picks avatars matching
agent personality instead of guessing from file paths.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: 杨慎 <117187635+cosarah@users.noreply.github.com>
* feat: add Grok (xAI) provider support for LLM, Image and Video generation
- Add Grok as LLM provider (OpenAI-compatible, 11 models including grok-4.20, grok-4, grok-3)
- Add Grok Image generation provider (grok-imagine-image, grok-imagine-image-pro)
- Add Grok Video generation provider with async polling (grok-imagine-video)
- Add env vars: GROK_*, IMAGE_GROK_*, VIDEO_GROK_*
- Add web search note: Grok search is via chat completions, not standalone API
- Update README/README-zh with Grok in supported providers
Closes#87
* fix: ensure new image/video providers are auto-added to persisted settings
Add ensureBuiltInImageProviders and ensureBuiltInVideoProviders functions
that run on every store rehydrate, mirroring the existing LLM provider
sync logic. Without this, Grok Image/Video providers would not appear
for users with existing localStorage settings.
* fix: add missing English translation for providerGrokVideo
* style: fix prettier formatting for grok video provider
* fix: remove unsupported grok multi-agent model and improve video error
When localStorage contains a provider ID that no longer exists in the
code (e.g. after a provider is removed or renamed), the Settings dialog
crashes with 'Cannot read properties of undefined'.
- Add ensureValidProviderSelections() to validate all 6 provider IDs
(PDF, web search, image, video, TTS, ASR) during store rehydration
- Hook validation into both migrate and merge paths
- Add null guards in settings UI header for PDF and web search providers
Closes#135
* fix: use browser speechSynthesis for playback when browser-native-tts is selected
Previously, selecting browser-native-tts as the TTS provider would
produce sound in the settings test but remain silent during classroom
playback. This happened because:
1. The scene generator correctly skipped pre-generation for browser TTS
(it runs client-side, not via API)
2. The playback engine fell back to a silent reading timer when no
pre-generated audio was found, instead of calling speechSynthesis
This commit adds Web Speech API integration directly in the
PlaybackEngine:
- New playBrowserTTS() method speaks text via speechSynthesis
- Properly wires onend/onerror to advance to the next action
- pause()/resume() now handle speechSynthesis.pause()/resume()
- stop() and handleUserInterrupt() cancel browser TTS
Fixes#25, fixes#12, fixes#5
* fix: handle "default" ttsVoice, extract CJK_LANG_THRESHOLD constant
- When ttsVoice is "default" (set by Browser Native TTS which has no
voice picker), the voiceURI lookup silently fails and no lang is set,
causing Chinese text to be spoken with an English voice.
- Extract the 0.3 CJK detection threshold as a named constant
CJK_LANG_THRESHOLD with JSDoc explaining the rationale.
- Fall through to language auto-detection when voice lookup fails,
regardless of the reason (missing voice, "default" sentinel, etc.).
* fix: support browser-native tts previews
* refactor: extract shared TTS preview logic into useTTSPreview hook
The browser-native and API-based TTS preview code was duplicated across
tts-config-popover, media-popover, and tts-settings. Extract it into a
reusable useTTSPreview hook that handles refs, cancellation, audio
lifecycle, and staleness checks in one place.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: yangshen <1322568757@qq.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When testing a TTS provider different from the currently active one, the
voice from the active provider was sent (e.g. OpenAI's 'alloy' to GLM API),
causing error 1214. Now falls back to the selected provider's default voice.
Also extracts duplicated default voice mappings into a shared constant.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove bundled MinerU Docker service and Dockerfile; link to official API and self-host docs instead
- Set MinerU requiresApiKey to false (self-hosted doesn't need it)
- Add test connection button to PDF settings panel with backend proxy to avoid CORS
- Add verify-pdf-provider API route for server-side connection testing
- Set Vercel API body size limit to 50MB for document uploads
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>