Files
a87c94c89d feat(settings): restructure settings IA with course model config and token plan controls [AI-assisted] (#1644)
* feat(generation): propagate per-stage model routes via x-model-routes header

Course model config lets each pipeline stage pin its own model; send the
user-level stage routes alongside the main model credentials so servers
resolve overrides consistently. Server-side model-routes/resolve-model
learn to merge them; scene renderers, the scene generator and the
generation preview pass the header through.

* feat(settings): token plan enrollment markers, plan toggle and store rework

- Plans connect through an explicit tokenPlanEnrollments marker: a personal
  key on a shared provider (minimax/tokendance/doubao) is never mistaken for
  a connected plan, so startup reconciliation no longer hijacks its catalogue
- New per-plan authorization toggle (tokenPlanDisabled): toggling cascades
  to the plan's per-modality provider enabled flags while skipping providers
  another usable plan still owns; re-enabling clears the seed fingerprint and
  re-seeds through reconciliation
- Multi-plan priority: exclusive slots (main model, stage routes, per-modality
  selections) yield to plans earlier in TOKEN_PLAN_PRESETS order regardless
  of write order; picker ordering follows the same order
- Reconciliation skips plans disabled by the toggle; disconnect restores the
  built-in provider's enabled flag and clears stale authorization markers
- Stage routes are pruned when a provider becomes unusable; the homepage
  web-search toggle migrates into the settings store; server-provider init
  waits for persist hydration

* feat(settings): five-section IA with course model config and provider panels

- Settings dialog reorganized into Token Plan / Course Model Config /
  Model Services / Skills / System
- New Course Model Config section: station cards along the generation
  pipeline with a per-station inspector for model overrides, mainline
  model plus fine-grained sub-stage routes, invalid selections kept as
  disabled rows instead of blank triggers
- Model Services becomes a provider list + detail panel with a per-provider
  authorization toggle (disabled providers leave course model config);
  Qwen TTS voice-clone area redesigned (45:55 split, add-clone CTA)
- Token Plan panel gains the Enable-this-plan switch mirroring the provider
  toggle, connected/off status copy, and priority-ordered model groups

* refactor(generation): drop the media popover now that media providers live in settings

Media provider/model selection moved into Model Services and Course Model
Config; the generation-bar media popover (520 lines) goes away and the
toolbar slims to the remaining toggles.

* fix(ui): keep provider popovers inside the viewport

Voice/config popovers now cap their height against
--radix-popover-content-available-height and their width against the
viewport, so search boxes no longer clip near screen edges.

* feat(i18n): complete course-model stations and settings copy across 12 locales

- Translate stations.* labels and descriptions for the 9 locales that fell
  back to English; convert zh-TW descriptions to Traditional Chinese
- Add subStages.*, mainlineUnset, pickModel/pickProvider, optionInvalid and
  the token-plan toggle copy across all locales

* test(audio): mock getStageRoutesHeaderValue in refused-narration test

Companion mock to the x-model-routes plumbing commit.

* style: apply prettier to files touched by the settings IA refactor

* fix(settings): restore the homepage model pill and set-up CTA lost in the IA refactor

The refactor dropped the toolbar's model picker and "Set up model" CTA,
leaving the homepage without any model affordance (#580 dead-end) and
breaking the picker stress tests (#1447), the managed-provider specs
(#620) and the KV-persistence checks that anchor on the pill.

- Re-add the pill on the shared ModelPicker component (aria-label
  "Provider / Model"), backed by the extracted useLLMPickerGroups hook so
  the toolbar and course model config share one filtered, priority-ordered
  provider list
- Re-add the amber "Set up model" CTA when no usable provider exists; it
  opens settings at Model Services
- Specs: navigate to Model Services in #620 and scope its catalog
  assertion to the dialog; drop the provider-tab step in #1447 (providers
  are group headings now)

* fix(settings): write the full runtime stage set for classroom interaction

The interaction station wrote only chat-adapter, while quiz grading and
the PBL v2 runtime resolve quiz-grade / pbl-v2-runtime:*, so the override
never reached them and calls fell back to the main model (review P0).

- Add lib/config/station-stage-keys.ts as the single station -> runtime
  stage-keys contract; interaction now writes chat-adapter, quiz-grade,
  pbl-chat and pbl-v2-runtime together (PBL composite sub-stages inherit
  the base key via the existing colon fallback)
- Override and restore-follow now write/clear the whole key group,
  thinking-config changes included
- Regression tests: contract keys are LLM_STAGES members, no orphan
  runtime stages, the interaction override resolves for every runtime
  endpoint, and explicit sub-stage overrides keep precedence over
  inherited parents

* fix(settings): enforce provider authorization across sync fallback and gates

A disabled plan's provider could be resurrected on refresh: validateProvider
correctly rejected it, but the auto-recover branch adopted fallback[0],
whose order still included authorization-disabled entries; the homepage
generate gate (isLLMProviderConfigured) also ignored the toggle (review
P0-02). Excluded disabled entries from the fallback order (extracted as
buildUsableFallbackOrder; image/video keep adopting server-configured
entries whose enabled:false means not adopted yet) and taught
isLLMProviderConfigured to reject disabled providers, so an empty
selection is retained and submission stays blocked.

* fix(token-plan): assign shared provider credentials to the top enabled plan

Applying a plan overwrote shared provider slots (seedream) last-writer-
wins, and disabling the owning plan left the slot enabled with the
disabled plan's endpoint and key (review P0-03). Shared slots now always
belong to the highest-priority enabled plan targeting them: apply yields
credentials and seed catalogues to a higher-priority owner regardless of
connect order, and disable/enable/remove transitions hand the slot back
(restoreSharedProviderCredentials rewrites endpoint, key — taken from the
owner's LLM slot — and catalogue of the new owner).

* fix(token-plan): include the re-enabled plan in shared ownership and clean up on removal

Two transitions still mis-owned shared slots after the previous fix
(re-review of P0-03): re-enabling a higher-priority plan excluded itself
from ownership resolution, so the slot stayed with the lower-priority
plan; and removal skipped cleanup when another plan was merely enrolled
but disabled, leaving the removed plan's endpoint, key and model
catalogue active on the shared provider.

- restoreSharedProviderCredentials takes excludeConcerned: disabling and
  removal exclude the concerned plan, re-enabling includes it, so the
  newly enabled plan reclaims its slot and a lower-priority enable does
  not steal one it does not own
- removeTokenPlan skips shared-slot cleanup only for another USABLE plan;
  otherwise the slot is cleared and disabled instead of surviving behind
  an enrolled-but-disabled plan

* fix(chat): honor per-stage user routes for classroom chat

The classroom-interaction model override is sent by the client as the
`x-model-routes` header, but the two multi-agent classroom chat routes
resolved their `chat-adapter` stage from the request body without parsing
it, so a per-stage override was silently ignored and the main model was
used instead.

Forward the parsed user routes into `resolveModel` for both /api/chat and
/api/chat/pi (credentials still come from the body, not x-* headers),
and attach the header from the client fetches. Operator MODEL_ROUTES still
wins server-side.

Regression tests cover the user-route precedence, the operator override,
the x-model-routes parser, and both client fetches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(settings): drop the pro-mode override the server never honors

The Course Model Config UI offered a "Pro Mode" station that wrote a
user-level route for `maic-agent-driver`, but that stage is resolved only
from the operator's MODEL_ROUTES (it also needs an explicit api dialect
and contextWindow), so the override could never take effect.

Remove the station from the map and its pipeline card, stop seeding the
route from the TokenDance preset, and drop the now-unused label/i18n keys
in every locale. The settings store's rehydrate sanitizer also drops any
previously persisted `maic-agent-driver` user route, so upgraded installs
do not keep a dead entry. The "no orphan runtime stage" contract test now
expresses `maic-agent-driver` as an explicit operator-only exception.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(settings): neutralize token-plan comments

Rewrite comments that referenced an external deployment or implementation
into neutral descriptions of this file's own behavior and design intent.
No behavior change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Percy <percy@PercydeMacBook-Pro.local>
Co-authored-by: wyuc <wang-yc24@mails.tsinghua.edu.cn>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 18:11:21 +08:00
..