getShadowOption converted the shadow blur from px to pt but left the offset
in px. pptxgenjs expects both in points (ratioPx2Pt = 96/72 × viewportSize/960),
so shadows exported ~33% too far from their element at the default viewport
while the blur radius was correct. Divide the offset by ratioPx2Pt like blur.
Closes#678
Co-authored-by: ly-wang19 <ly-wang19@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: wyuc <wang-yc24@mails.tsinghua.edu.cn>
Promote the Action contract (Action union + variants, ActionType, the action-category lists, PercentageGeometry) into @openmaic/dsl/src/action.ts, zero-runtime-dep. Widget interaction actions graduate into the contract; Scene<TAction> defaults to the standard Action union; lib/types/action.ts becomes a re-export shim. Part A of #787 (Phase 2 under #720).
* feat(agent-edit): multi-session conversation history for the AI editor
The "Edit with AI" panel kept only one thread per stage in localStorage, and
"New conversation" deleted it, so previous conversations were unrecoverable.
Add a per-stage session list backed by IndexedDB (Dexie v12 `agentEditSessions`):
- "New conversation" now archives the current session and starts a fresh one
instead of deleting it; a history popover in the panel header lists past
sessions (auto-titled from the first user message) to switch back to or delete.
- One-time migration of the existing single-thread localStorage entry.
- The active session id is remembered per stage so a refresh restores it,
including a just-cleared empty session (clean slate survives reload).
- saveSession preserves the original createdAt and tombstones deleted ids so an
in-flight save can't resurrect a deleted session; switching stages drops the
previous thread synchronously so it can't leak into the new stage.
- Sessions are pruned to a soft cap per stage and removed when a course is
deleted.
- i18n for all 8 locales; unit tests for title derivation and the store.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(types): drop redundant Window.SpeechRecognition augmentation conflicting with @assistant-ui/core
@assistant-ui/core's speech adapter declares Window.SpeechRecognition and
webkitSpeechRecognition globally as SpeechRecognitionConstructor. Three files
(prompt-input, use-audio-recorder, use-browser-asr) re-declared them as `any`,
which conflicts (TS2717) once that adapter's types are pulled into the program,
and the constructed instance then lacks the event handlers the code sets
(TS2339/2551). Rely on the global declaration and cast the instance to the local
rich shape. Takes `tsc --noEmit` back to zero.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor: align widget actions with scene pipeline
* feat(edit): migrate legacy teacherActions off interactive content on load
The widget-actions pipeline no longer persists a teacherActions authoring
layer; playback reads only scene.actions. Add migrateInteractiveContent to
strip the dead field from existing documents as they load through migrateScene
(wired into all store/classroom load paths). Satisfies the #794 forward-migration
acceptance item.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(generation): default widget_setState.state to {} when the LLM omits it
The removed TeacherAction->Action converter always defaulted state to {}.
Restore that guard in the structured-output parser so an action missing
state can't forward state: undefined into the widget iframe, where
SET_WIDGET_STATE handlers dereference it.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(edit): also strip nested widgetConfig.teacherActions in migration
Legacy WidgetConfig variants each declared their own teacherActions, so existing
documents can carry the dead field nested inside content.widgetConfig as well as
at the top level. Extend migrateInteractiveContent to drop both, preserving all
other widgetConfig fields.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(prompts): document stable widget-action selectors for diagram/game/viz3d
The interactive-actions prompt documented stable target selectors only for
procedural-skill and simulation widgets. Add the canonical selectors the
diagram / game / visualization3d content prompts actually emit (node IDs via
revealOrder; #zoom-in-btn / #canvas-container / #speed-slider / ...; #start-btn),
plus a rule to use widget_setState or a speech-only beat instead of guessing a
target when no stable selector is known (e.g. free-form code widgets). Hardens
against widget actions silently no-oping on non-existent selectors.
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>
Adds automatic retry with exponential backoff for scene generation (content/actions/TTS): shared withGenerationRetry helper at the fetch boundary, smart error classification (retries 429/5xx/timeouts/network, fails fast on 401/403/404), AI SDK RetryError unwrapping, abort-aware backoff, per-route thinking config preserved, and upstream HTTP status surfaced for client retry classification. Fixes#755.
Add an append-only 'Add discussion' control + inline editor (topic/prompt/initiating agent) to the script timeline, respecting the action-parser invariant that a discussion is the scene's last action and at most one per scene. Yellow terminal-anchor styling; agent picker (with avatars) sourced from the selected agents the playback engine gates on. Runtime unchanged.
* chore(packages): publish the @openmaic/* SDK family to npm (#778)
Prepares the @openmaic/{dsl,renderer,importer} family for its first npm
publish, and moves the SDK packages onto the @openmaic scope.
Why the scope move: the @maic org name is unavailable on npm (an unscoped
`maic` package already holds the name), so @maic/* is not claimable. @openmaic
matches the project name, the scope is free, and the repo already ships an
@openmaic/docs package — so the SDK family now lines up with that convention.
- rename @maic/{dsl,renderer,importer} -> @openmaic/* across packages, the
workspace glob, the package dir, and all import sites; lockfile regenerated
- renderer: add publishConfig (public, registry.npmjs.org) — was missing, so
a scoped publish would default to the wrong registry / restricted access
- importer: add a files allowlist (dist, README, LICENSE) and drop the
fragile .npmignore blacklist that shipped src; add an exports map so ESM
consumers resolve dist/index.js instead of falling back to the .cjs main
- all three: add a prepublishOnly build (+ test/typecheck) guard so a publish
can never ship a stale or empty dist
- add a tag-triggered publish workflow with npm provenance, pinned by name to
the three @openmaic packages so the vendored forks (mathml2omml, pptxgenjs)
are never published
Refs #778, #720 (Phase 1).
* fix(packages): address cross-review on the @openmaic publish prep
Cross-review (Claude /code-review + codex) on this PR surfaced:
- renderer's advertised CJS entry was broken: it keeps @openmaic/dsl external
and imports a runtime enum from it, but dsl is ESM-only (no `require`
condition), so `require('@openmaic/renderer')` would throw
ERR_PACKAGE_PATH_NOT_EXPORTED. Make renderer ESM-only: drop the `.cjs`
rollup output, `main` now points at the ESM build, and the `require`
conditions are removed from `exports`. (importer is unaffected — it bundles
dsl, so its CJS build still works.)
- prepublishOnly re-ran the test suite during `pnpm -r publish`, so a flaky
test after dsl had already published gave a non-atomic partial release.
Reduce prepublishOnly to a build-only guard (never ship stale/empty dist)
and move the real test/typecheck gate into the workflow, before any publish.
- document that an @openmaic/* tag publishes the whole family via `pnpm -r`
(pnpm skips already-published versions); the tag is a release marker, not a
per-package gate.
Verified: dsl + renderer + importer build; renderer emits ESM only (0 .cjs),
all exports entries resolve; `npm pack` ships dist + README + LICENSE with no
src leak; frozen-lockfile passes.
Refs #778.
* style: reflow @openmaic/dsl type imports past print-width after rename
The @maic -> @openmaic rename lengthened two single-line type imports past
prettier's 100-col width; prettier --check flagged them. Pure formatting.
Refs #778.
* docs(importer): mark @openmaic/importer browser-only (cr-loop accepted limitation)
codex cross-review flagged that the published @openmaic/importer throws
`XMLHttpRequest is not a constructor` when loaded in a pure Node process —
its rollup build is browser-targeted (`nodeResolve({browser:true})` + a
browser pdf.js build). The app only consumes it client-side ('use client'),
so this is by design. Document it as an accepted limitation: prominent
browser-only note in the README and a `browser` field in the manifest.
Refs #778.
* feat(generation): changeOutlineType total constructor for valid type switches
Switching a scene outline's type in the editor only flipped `type` and left
the new type without its required config, so applyOutlineFallbacks silently
downgraded interactive/pbl back to slide. changeOutlineType returns a new
outline that strips foreign per-type config and seeds the target type's
required config from the shared fields, valid by construction.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* i18n(generation): keys for interactive widget kind and PBL project config
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(editor): make outline type changes take effect with config forms
TypePill now builds a valid outline via changeOutlineType (replace, not
partial-merge) so a type switch drops stale config and seeds the new type's
required config — no longer silently downgraded to slide by applyOutlineFallbacks.
Adds InteractiveConfigDisclosure (widget kind + concept) and PblConfigDisclosure
(topic / description / target skills), mirroring QuizConfigDisclosure, so users
can configure interactive and PBL scenes that previously had no input UI.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(editor): move type-specific config under the type pill
The quiz/interactive/PBL config disclosure rendered as a detached chip at the
bottom-left of the card, reading like a stray key point. Pin it to the
bottom-right of the key-points row instead, so it sits directly under the
TypePill it configures (type top-right -> its config bottom-right, same edge),
with key points flowing on the left.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(editor): cascade type config as a connected segment left of the type pill
Replace the standalone config chip with a cascading control in the header: the
type-specific config (quiz count / interactive widget kind / PBL project) renders
as a themed segment joined to the left of the TypePill, the two clipped into one
rounded pill split by a hairline divider. Reads as a single 'config › type'
cascade and groups the config with the selector it refines.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(editor): address cross-review — preserve widget config, drop stale fields
- changeOutlineType: preserve an existing procedural-skill widget config
instead of replacing it with a seeded simulation (codex P2 — task-engine
fields were silently dropped on Interactive re-select).
- InteractiveConfigDisclosure.setWidgetType: reset widgetOutline to the shared
concept only, so switching widget kind drops the previous kind's fields
(claude P2 — language/gameType/etc. leaked across kinds).
- i18n locale-coverage test now also checks ko-KR and pt-BR.
- Drop a redundant WidgetType cast; add tests for procedural-skill preservation
and pbl targetSkills dedupe/cap.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(editor): round 2 cross-review nits — procedural-skill label + skill a11y
- InteractiveConfigDisclosure: when an outline carries a preserved
procedural-skill widget, surface it as the current (selected) kind with its
own label instead of mislabeling it 'Simulation', and make a same-kind
re-select a no-op so its task-engine fields are never silently clobbered.
- PBL target-skill remove button uses a dedicated removeSkill aria-label.
- Add widgetProceduralSkill / removeSkill i18n keys (8 locales) + test coverage.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(generation): make re-selecting the current outline type a no-op
changeOutlineType rebuilt the outline on every type-menu click, so re-selecting
the already-current type dropped fields it doesn't re-seed — legacy
interactiveConfig, or a partial pblConfig whose projectTopic is empty — turning a
harmless click into data loss. Short-circuit same-type selections to return the
outline untouched (codex P2).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore(format): prettier --write files left unformatted on main
These 14 agent/edit files (not part of this PR's feature) fail the repo-wide
`prettier . --check` in the required Lint job — they landed on main unformatted,
turning main's CI (and therefore this PR after a branch update) red. Formatting
them here unblocks the required check; pure formatting, no logic changes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(lint): suppress intentional set-state-in-effect in reasoning timer
The reasoning timer does a deliberate one-shot setState in its effect to show
the right elapsed value before the first 1s interval tick. main's CI fails the
required Lint job on the new react-hooks/set-state-in-effect rule here; suppress
it with a justification (no behavior change). Unblocks the required check.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Deleting a slide in Pro/Edit mode removed it from `scenes` but left its
entry in the persisted `outlines` plan. On the next classroom mount the
resume-generation pass treats the now-missing `order` as a pending
outline and regenerates the slide, appending it as the last page.
Rather than prune outlines by `order` (which is rebalanced by Pro-mode
insert/duplicate/reorder, so it is not a stable key and would mis-target
or break delete-undo), gate resume on a persisted `generationComplete`
flag:
- The flag is recorded (alongside outlines, in the stageOutlines record)
when generation finishes — both generateRemaining completion paths, the
retry-to-completion path (markGenerationCompleteIfDone), and the
already-materialized-at-mount path — and restored on load. It is written
only after a verified scene flush, so it never outruns the deck's scenes.
- A finished deck is frozen for editing: loadFromStorage no longer derives
pending placeholders from orphaned outlines, the classroom resume effect
skips generateRemaining, media resume is filtered to materialized
outlines, and isCourseComplete honours the flag — so a deleted slide
neither regenerates nor leaves a phantom pending page.
- Decks generated before the flag existed self-heal on load (every outline
has a scene ⇒ inferred complete). deleteScene additionally records
completion when deleting from a deck that is complete right now, so the
"Course complete" end page and resume-suppression survive even when the
flag was never persisted (e.g. edited without a reload).
`outlines` are never pruned, so order-rebalancing and delete-undo are
unaffected. Genuinely interrupted generations (not complete) still resume.
Fixes#768
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(generation): infer concise courseTitle from outlines for readable course names
Generated courses were named after the raw user prompt (truncated to 500 chars
client-side, or 50 chars / first outline title server-side), which is long and
unreadable. The outline-generation step already understands the full course
semantics, so have it emit a concise `courseTitle` alongside `languageDirective`
and `outlines`, and use it as the stage name.
- Prompts (requirements-to-outlines, interactive-outlines): top-level JSON gains
a required `courseTitle` (≤30 chars, in the teaching language, noun phrase).
- Streaming route: extract `courseTitle` head-bound like `languageDirective`,
emit a `courseTitle` SSE event, and include it in the `done` event.
- Non-streaming outline-generator: parse and return optional `courseTitle`
(defensive trim + 120-char cap).
- Naming: stage.name = courseTitle || outlines[0]?.title || requirement fallback
(client preview path backfills stage.name after outlines resolve; server
classroom-generation uses it directly).
- Session: persist `courseTitle` on GenerationSessionState for reload safety.
- Tests: add courseTitle parsing coverage; e2e mock done event carries it.
Fully optional in the pipeline — every consumer falls back to the previous
behavior when the field is absent, so legacy/LLM-skipped cases are unaffected.
* fix(generation): make courseTitle propagation robust across all outline paths
Address review feedback on the courseTitle threading.
Prompts — align every outline-prompt schema statement to the 3-key shape.
The user-prompt "final reminder" / top-level shape blocks for
requirements-to-outlines, interactive-outlines, and task-engine-outlines still
demanded the old two-key {languageDirective, outlines} object; as the last
instruction the model reads, that caused it to omit courseTitle and the stage
name to fall back to the raw requirement. Task Engine prompts now emit
courseTitle as well.
Streaming route — normalize the streamed courseTitle (trim, ignore
whitespace-only, cap length) to match the non-streaming parser, and add a
full-buffer fallback so a title emitted after the outlines array or beyond the
head-scan window is still recovered before the done event.
Client — reset latched languageDirective/title on outline retry so a
succeeding attempt that omits them falls back instead of inheriting a failed
attempt's stale value; also carry courseTitle in the stream-end resolve path
that fires when the stream closes without an explicit done event.
courseTitle remains optional on every consumer path.
---------
Co-authored-by: wyuc <zdq1204@gmail.com>
* feat(model): optional per-stage LLM model routing (#745)
Add a config-only stage -> model map consulted during model resolution,
falling back to DEFAULT_MODEL when unset (zero behavior change unless opted in).
- lib/server/model-routes.ts: parse/validate/cache MODEL_ROUTES env JSON;
LLM_STAGES registry of routable stages; getStageModel(stage).
- resolveModel: resolution order x-model > stage route > DEFAULT_MODEL > builtin;
thread optional `stage` through resolveModelFromHeaders/FromRequest.
- Wire each route's resolveModel call site to its stage; classroom-generation
resolves generate-classroom and web-search-query-rewrite independently.
- .env.example: document MODEL_ROUTES; unit tests for both modules.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(model): address cross-review findings for per-stage routing (#745)
- classroom-generation: resolve the web-search-query-rewrite model lazily,
only when explicitly routed and inside the web-search branch, with try/catch
fallback to the classroom model. Fixes a regression where a misconfigured
optional route (keyless/invalid provider) threw and aborted ALL classroom
generation even with web search disabled; also avoids wasted resolution on the
common no-search path and preserves classroom-model inheritance when unrouted.
- resolve-model: type the stage param as LlmStage across resolveModel/
resolveModelFromHeaders/resolveModelFromRequest so a mistyped stage literal is
a compile error instead of silently falling through to DEFAULT_MODEL.
- model-routes: simplify the cache to a process singleton (matching
provider-config), dropping the raw-string-keyed cache and redundant STAGE_SET.
- .env.example: clarify x-model precedence and that a route to an unconfigured
provider fails at request time (no startup validation), like a bad DEFAULT_MODEL.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(model): stage route takes precedence over client x-model (#745)
Cross-review (codex P2 + Claude tracer) found that the browser UI always sends
its saved model as x-model, so the previous x-model > stage order made
MODEL_ROUTES inert for normal UI traffic on exactly the heavy stages the RFC
targets (scene-content, quiz, pbl-chat, chat). Flip resolution to
stage route > x-model > DEFAULT_MODEL: a configured route is the operator's
deliberate per-stage choice and wins, while unrouted stages still honor the
client's x-model. Update docs and tests accordingly.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* style(model): prettier-format changed files for #745 CI
Run the repo formatter (pnpm check / prettier) on the changed routes, the new
model-routes module, and the new tests so `prettier . --check` (CI) passes;
also correct a stale precedence comment in the resolve-model test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(model): isolate routed model from client connection params (#745)
When a stage route overrides the client's x-model and points at a different
provider, the client-sent apiKey/baseUrl/providerType (for the client's model)
must not bleed onto the routed provider — otherwise a routed Anthropic model
would be constructed with the client's OpenAI providerType/key and fail. A
routed model now resolves its connection params purely from server config, as
if no x-model was sent. Unrouted stages still honor the client params. Adds
tests covering both the drop (routed) and keep (unrouted) cases.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs(model): correct graceful-degradation comment in classroom (#745)
resolveModel does not throw on a missing key; clarify that a keyless route
surfaces later in callLLM (degraded by the outer try/catch), while only a
resolution-time failure is caught at the rewrite re-resolve. Comment-only.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(model): route scene-content per scene type (#745)
Extend MODEL_ROUTES with composite keys scene-content:<type> for the four core
scene types (slide/quiz/interactive/pbl). getStageModel now resolves composite
`a:b` stages most-specific-first, trimming `:` segments, so scene-content:<type>
falls back to the base scene-content route, then x-model, then DEFAULT_MODEL.
The scene-content route derives its stage from outline.type. Backward
compatible: with no composite key configured, behavior is unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(model): per-stage thinking effort + drop hardcoded gpt fallback (#745)
MODEL_ROUTES values may now be {model, effort} (not just a model string) to pin
the thinking effort per stage. Arbitration mirrors model routing: a routed stage
with effort set wins over the client's thinking (effort "none" disables); routed
with no effort uses the model's default and drops client thinking; unrouted
stages keep the client thinking. resolveModel is the single arbiter — body
thinking is threaded in via resolveModelFromRequest. classroom-generation passes
the resolved thinking into its callLLM calls so generate-classroom and
web-search-query-rewrite honor route effort too.
Also: removed the hardcoded `|| 'gpt-5.4-mini'` fallback in resolveModel — if no
model resolves (no route / x-model / DEFAULT_MODEL) it now throws instead of
silently picking a vendor default.
model-routes: getStageRoute returns {model, effort?}; getStageModel delegates to
it. Docs + tests updated.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor(model): route value carries full ThinkingConfig (#745)
Per-stage routing accepts the full unified ThinkingConfig in the route value
({model, thinking:{mode,effort,level,enabled,budgetTokens,excludeReasoningOutput}})
instead of just an effort string. The route's thinking is passed through
resolveModel and normalized per the model's capability by callLLM, so
budgetTokens (qwen), level (Gemini), enabled/mode, etc. all work.
(qwen3.7-plus/max thinking capability now comes from upstream #753, so this no
longer registers them.)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(model): honor routed thinking for chat-adapter; doc fixes (#745)
Cross-review (codex P2 + Claude) found chat-adapter was the only routable stage
that ignored the route's thinking: it took the routed model but built its own
thinkingConfig from the request body, so operator-pinned thinking never applied
and client thinking still leaked onto a routed model. Now pass the client
thinking into resolveModel and use the resolved thinkingConfig (route-pinned for
a routed stage, client otherwise; defaults to disabled for low-latency chat).
Also: clarify DEFAULT_MODEL is now required for server-side stages (the
hardcoded gpt-5.4-mini fallback was removed → resolveModel throws if nothing
resolves), and fix a stale {model,effort}→{model,thinking} doc comment.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds the Qwen3.7 series to the built-in qwen provider, mirroring the
existing Qwen3.6 model-card shape:
- qwen3.7-plus: 1M context, 64K output, vision, tools, toggleable
thinking + budget (default on)
- qwen3.7-max: 1M context, 64K output, text-only, tools, toggleable
thinking + budget (default on)
Both run over the already-configured DashScope OpenAI-compatible
endpoint; no transport changes. Thinking is wired through the existing
qwen request adapter (qwenBudgetEnabled, 0-81920 budget). Output ceiling
and thinking-budget max reuse the Qwen3.6 conventions, since the public
docs don't spell these out per-model.
Closes#752
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
proxyFetch routed every request through the configured HTTP(S) proxy,
including loopback targets. A deployment with HTTP_PROXY set would send
a http://localhost:8888 SearXNG (or any self-hosted service) request to
the external proxy, where localhost resolves to the proxy machine and
the request fails.
- Always bypass loopback hosts (localhost, *.localhost, 127.0.0.0/8, ::1).
- Honor the standard no_proxy / NO_PROXY env var: comma-separated hosts,
`*` wildcard, optional `:port` (with protocol-default ports), and
curl-style domain-suffix matching (`example.com` matches
`api.example.com`; a leading dot is equivalent).
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: wyuc <wang-yc24@mails.tsinghua.edu.cn>
* feat(dsl): promote Stage/Scene lesson skeleton into @maic/dsl (#740)
Phase 2 of the @maic SDK consumption epic (#720): move the universal lesson
skeleton into the contract package, with Scene generic so app-side feature
surfaces (Action, widgets, PBL) plug in via type parameters.
DSL (packages/@maic/dsl):
- New src/stage.ts: Stage, SceneType, StageMode, Whiteboard, VideoManifest,
GeneratedAgentConfig, MultiAgentConfig, SlideContent, QuizContent, and a
narrowed SceneContent (SlideContent | QuizContent).
- Scene<TAction = never, TContent extends { type: SceneType } = SlideContent |
QuizContent> — the contract owns only the structure + universal content
kinds; TContent is constrained structurally so an app can pass a wider
content union. Defaults give renderers/importers a feature-free skeleton.
- Pure guards isSlideContent / isQuizContent.
- Registered in index.ts barrel; README roadmap item checked off + 'Stage /
Scene split' section added.
- Added vitest config + test script + stage.test.ts (9 contract tests).
App (lib/types/stage.ts):
- Rewritten as a shim: re-exports the skeleton types from @maic/dsl, keeps
InteractiveContent / PBLContent (app feature surfaces), and aliases Scene =
Scene<Action, AppSceneContent> so all ~55 existing import sites keep their
semantics. The generation re-export block is dropped (verified zero
consumers import those five types via @/lib/types/stage).
Scope B from #740 (lesson container in DSL, features plug in). Decision:
generic Scene<TAction, TContent> over a registry/extension seam — explicit,
isolatedModules-friendly, no declaration-merge pitfalls.
* fix(dsl): address review — guard genericity, standalone tests, type pin
1. isSlideContent / isQuizContent: relax <T extends SceneContent> to
<T extends { type: SceneType }> so the guards accept an app-widened
content union (interactive / pbl) — the generic case Scene<TAction,
TContent> is meant to support. Add a regression test exercising the
widened union.
2. tests: resolve @maic/dsl to ./src/index.ts via resolve.alias in
vitest.config.ts, so 'pnpm --filter @maic/dsl test' is standalone on a
clean checkout (no dist build required). Verified by deleting dist and
re-running.
3. Pin the TAction-defaults-to-never type test to .toEqualTypeOf<never[] |
undefined> instead of the trivially-true .toMatchTypeOf<unknown[] | …>.
* style: prettier-format lib/types/stage.ts (CI prettier --check)
* fix(stage): value-export isSlideContent/isQuizContent from the compat shim
The two discriminant guards are runtime functions but were sitting inside the
shim's `export type { … }` block, which erases them: `import { isSlideContent }
from '@/lib/types/stage'` would resolve to `undefined` at runtime and TS-error
'cannot be used as a value'. No call sites import the guards through the shim
today (latent), but the shim's job is back-compat re-export, so move them to a
plain `export { … }`.
---------
Co-authored-by: 杨慎 <117187635+cosarah@users.noreply.github.com>
* test(orchestration): add answer-content eval for agent first-reply answering
The existing director question-answering eval only checks that the director
ROUTES to the teacher; it never generates the dispatched agent's reply, so it
cannot catch the case where routing is correct but the agent's first sentence
drifts (greets / opens a lecture / pivots) and only a later turn answers.
This adds an answer-content eval that runs the real agent-generate inputs
(buildStructuredPrompt + convertMessagesToOpenAI), parses the structured output
with the app's runtime parser, and uses an LLM judge for two signals:
leads_with_answer (first sentence addresses the literal ask) and
answered_anywhere (addressed at all). Their gap quantifies "drift-then-answer".
A/B mirrors the answering-runner rule-13 strip: baseline removes the
"Answering the User's Question" section from agent-system, with_rule is as-shipped.
Scenarios are synthetic/anonymized (opening-lecture override, ignored
format/capability/navigation request, ignored correction, frustration re-ask,
adjacent pivot, vague-clarify) plus clean controls; no real user data.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* test(orchestration): give answer-content scenarios live-shaped classroom context
The minimal store state (empty scenes, null stage, no profile) made the
assembled agent prompt far thinner than the live agent-generate path and
suppressed the slide-narration "lecture reflex" that drives opener drift.
Each scenario now carries a topical slide scene (title + body + latex elements
with ids), a stage (name/description/languageDirective), and a student profile,
so buildStructuredPrompt emits a "# Current State", "# Student Profile" and
"# Language" of the same shape and bulk as production. The runner reads this
context from the scenario instead of a hardcoded empty state.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(agent): respond to the user's turn before continuing the lecture
Generalize the agent-system "Answering the User's Question" section into
"Responding to the User's Turn": the user's latest message always takes priority
over continuing the planned lecture. Beyond factual questions it now explicitly
covers the interaction requests agents were ignoring — navigation/pacing
("skip to next page"), format/language ("explain in Chinese"), capability
requests it cannot fulfill ("make a video" -> say so + offer an alternative),
corrections, frustration re-asks, and vague asks (ask one clarifying question).
Strengthen the answer-content eval that measures this:
- the navigation case now uses a 3-slide deck so "skip to next page" is well-posed;
runner supports multi-scene state and strips the renamed section for the A/B;
- judge is fairer to legitimate behavior: explaining primarily in the requested
language while keeping technical terms standard counts; a verbal transition to
the next slide counts as honoring navigation (no page-turn action exists).
Result (gemini-3-flash-preview, n=10): mean leads-with-answer rises from 42%
(section stripped) to 93% (as-shipped); all 12 scenarios pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(agent): don't over-respond to bare acknowledgements; guard empty eval set
Code-review follow-ups on the "Responding to the User's Turn" change:
- Prompt: the absolute "every user message needs a direct response / treat
continuing the lecture as a failure" wording had no carve-out for bare
acknowledgements ("ok" / "嗯" / "good" / "thanks"), risking the agent halting
the lesson to manufacture a reply, and conflicted with agent-initiated
discussions where no user turn exists. Add a bare-acknowledgement carve-out,
allow a brief "好的"/"Sure" before the answer, and scope the override to actual
requests (and to "if there is a user turn to respond to").
- Eval: answer-content-runner exited 0 with a PASS verdict and NaN% aggregates
when the scenario set was empty (e.g. an EVAL_SCENARIO typo). Guard it: error
and exit 1 when no scenario matches.
Re-run unchanged otherwise (gemini-3-flash-preview, n=10): mean leads-with-answer
42% (stripped) -> 94% (as-shipped), 11/12 scenarios pass; the chem opener is
variance-prone around the 70% bar and not over-tuned.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* refactor(eval): cr-loop cleanups on answer-content-runner
- ScenarioAgentSpec extends the shared ScenarioAgent (./types) instead of
re-declaring id/name/role/priority.
- Drop the dead expectedPreFix plumbing from ScenarioResult (it was copied in
but never read; it stays as an informational annotation in the scenarios).
- extractTexts: replace the hand-rolled JSON fallback with the app's
finalizeParser, which recovers plain-prose / unclosed-array output the same
way the runtime does.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix: tighten acknowledgement carve-out; don't surface action-JSON as text (cr round 2)
Round-2 review follow-ups.
Prompt: the bare-acknowledgement carve-out was too loose — it could swallow
ack+request hybrids ("嗯,那为什么X?") as acks (re-introducing drift), double-listed
"好的" as both an allowed lead-in and a no-response ack, and listed pacing words
("继续"/"go on") that collide with the navigation bullet. Restrict it to a
STANDALONE acknowledgement with nothing else attached; route an embedded
question/request to that request; route pacing words to the navigation bullet.
Eval: extractTexts gated finalizeParser recovery on !state.jsonStarted, so an
actions-only / unclosed array yields "no text" (the judge's intended empty case)
instead of finalizeParser's raw-buffer fallback surfacing action JSON as fake speech.
Re-run (gemini-3-flash-preview, n=5): no regression — 11/12 pass, meta-requests
100/100/80/100; the chem opener remains variance-prone around the 70% bar.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix: address review — honest slide-nav, strict judge booleans, errors fail (cr)
Review follow-ups from @cosarah:
- Navigation (P2): agents have no slide-navigation action, so "do it" + a verbal
transition let "skip to next page" pass the eval while the UI stayed on the
same slide. Reframe prompt, judge, and scenario so a correct reply ACKNOWLEDGES
the request and is HONEST that it cannot change the slide itself (continue
verbally / tell the user how to navigate); pretending it flipped the slide no
longer counts.
- Judge booleans (P2): answer-content-judge coerced fields with Boolean(...), so a
string "false" became true. Parse strictly (real bool or "true"/"false");
malformed output is flagged as an error.
- Error accounting (P3): aggregate excluded errored samples from the denominator,
letting a scenario pass on one good sample. Errors now count as failures
(denominator = all requested samples).
Re-run (gemini-3-flash-preview, n=10): navigation 0% -> 100% under the honest
framing; aggregate leads-with-answer ~93%, no regression. Opener scenarios
(math/chem) remain variance-prone near the 70% bar.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(eval): judge first-sentence lead; use canonical teacher actions (cr round 2)
Second review round from @cosarah:
- leads_with_answer was judged against texts[0] (the whole first JSON text
block), so "Today we'll discuss parabolas. The formula is x=-b/(2a)." counted
as leading even though the first sentence drifted. Now extract the first ~2
sentences as the "opening" and have the judge make the call: a brief
acknowledgement of the user before the answer counts as leading, but a greeting
/ self-intro / topic preamble before the answer does not. (Two sentences +
semantic judge handles "Sorry, let me clarify. m is inertial mass." vs
"Welcome! …" without a brittle keyword list.)
- The runner hardcoded TEACHER_ACTIONS, omitting canonical teacher actions
(play_video, wb_draw_chart). Use getActionsForRole('teacher') so the available-
actions section matches production.
Re-run (gemini-3-flash-preview agent, n=10): 11/12 pass, aggregate leads ~90%.
The chem opener now correctly fails (~10%): its "Welcome! Today we…" persona
greets first, so at sentence granularity it is genuine first-sentence drift
(answered-anywhere ~90%) — exactly what the stricter lead measurement should
catch.
Note: the judge model is deepseek-v4-pro in this run because the anthropic
gateway is currently returning Bad Request in our environment; the eval is
judge-model-agnostic via EVAL_JUDGE_MODEL.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(eval): judge the opening across all text blocks, not just texts[0] (cr round 3)
Review follow-up from @cosarah: leadFromTexts only looked inside the first
text block, so a valid multi-block reply like
[{"type":"text","content":"Sure."},{"type":"text","content":"The derivative is 2x."}]
was judged on "Sure." alone and failed leads_with_answer despite following the
allowed acknowledgement-then-answer pattern. Build the opening from the first ~2
speech sentences across ALL ordered text chunks.
Re-run (gemini-3-flash-preview, n=10, deepseek judge): 11/12 pass, aggregate
leads ~93%. The chem opener stays sub-threshold (~50%) — its "Welcome! Today
we…" persona greets before answering about half the time, a genuine
first-sentence drift.
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>
#707 left lib/types/slides.ts as a thin `export * from '@maic/dsl'` shim so the
~100 existing `@/lib/types/slides` import sites kept working unchanged. Point
them at `@maic/dsl` directly and delete the shim, so the app consumes the
package contract with no indirection and the legacy module path is gone.
Pure module-specifier migration — every symbol imported from
`@/lib/types/slides` was already a re-export of the same `@maic/dsl` symbol, so
behavior is identical. Also redirects the two `lib/types` relative importers
(`./slides`), the e2e fixture's relative import, and the dynamic
`import('../types/slides').Slide` type alias in stage-storage; merges the now
same-module import pair in slide-edit-elements.
Verified: tsc --noEmit clean, eslint clean, vitest 804/804, next build OK,
e2e (Playwright) 19/19.
Part of #720 (Phase 1).
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* refactor(app): consume @maic/dsl + @maic/renderer for slide types and read-only thumbnails
The app extracted @maic/{dsl,renderer,importer} (#668) but kept rendering its
own duplicated copies. Start dogfooding the packages back into the app:
1. lib/types/slides.ts is now a thin re-export of @maic/dsl. The hand-kept
copy was the seed for @maic/dsl, so consuming the package stops the three
former copies (app / renderer / importer) from drifting again. All
`from '@/lib/types/slides'` import sites keep working unchanged.
(ShapePathFormulasKeys / ElementTypes move from local `const enum` to the
package's regular `enum` — required across a package boundary; runtime
value usage is identical.)
2. Read-only slide thumbnails now render via @maic/renderer's SlideCanvas
through a small SlideThumbnail wrapper, replacing the in-app ThumbnailSlide
element renderers at the three read-only surfaces: playback scene sidebar,
scene thumbnail content (editor rail), and home recent-course cards. The
wrapper preserves the legacy thumbnail video treatment (muted play-badged
<video>, placeholder filtering) via the renderer's renderVideo slot. The
full-size editing canvas is untouched (renderer v1 is read-only).
Verified: tsc --noEmit clean, next build OK, e2e 19/19 green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(thumbnail): resolve gen_* media placeholders so retries reflect in thumbnails
SlideThumbnail rendered slides through @maic/renderer with only a renderVideo
slot, so image (and video) `gen_img_*`/`gen_vid_*` placeholders were painted
as-is. @maic/renderer is a pure package and does not know about this app's
async media-generation store; the store also never mutates the slide's
`element.src` (it keeps the placeholder ref and tracks the generated objectUrl
in a task). Net effect inside a classroom: a thumbnail showed the broken
placeholder on first paint and — the reported bug — did NOT update when a
failed image's retry finally succeeded, because nothing re-resolved the src.
Add `useResolvedSlide`: resolve each placeholder element's `src` to its task
`objectUrl` (video `poster` too) against the media-generation store,
reactively. Unresolved (pending/failed) placeholders are blanked so the
renderer paints nothing instead of a broken-media icon. Off-classroom (no
stage context, e.g. home recent-course cards) renders raw, matching the legacy
thumbnail's behavior. Mirrors the app's existing `useResolvedImageSrc` resolver
that the full-size canvas already uses — restoring the reactive sync the
in-app ThumbnailElement had before the @maic/renderer migration.
The store subscription is a primitive signature of just this slide's
placeholder resolutions (src → done objectUrl), so unrelated task churn —
other slides' media generating or retrying — neither re-renders the thumbnail
nor invalidates the resolved-slide memo.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(thumbnail): key video tasks by mediaRef; use a visible signature delimiter
Review follow-ups (#707):
- Videos' media-generation tasks are keyed by mediaRef (with gen_vid_* src as
the legacy fallback), not by element src — resolve them through
getVideoMediaRefForElement, matching BaseVideoElement's subscription, so a
mediaRef-keyed video thumbnail updates when generation or a retry completes.
A mediaRef-keyed video that already carries a real playable src keeps it
while the task is unresolved; only placeholder srcs are blanked.
- The resolution-signature delimiter was a literal NUL byte, which made git
treat the source file as binary (degrading diffs and review tooling). Use a
visible '|' delimiter instead.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: 杨慎 <117187635+cosarah@users.noreply.github.com>
Add a full Korean locale (lib/i18n/locales/ko-KR.json, all 1018 keys translated
from en-US.json) and register it in lib/i18n/locales.ts per TRANSLATION_GUIDE.md.
i18next {{interpolation}} preserved; AI provider/model brand names kept per the
existing ja-JP convention.
Signed-off-by: moduvoice <moduvoicr77@gmail.com>
Two streaming generation paths do super-linear work on the model output and can
block the Node event loop (and balloon the heap) on large or pathological
responses:
1. app/api/generate/scene-outlines-stream re-parses the ENTIRE accumulated
buffer on every streamed chunk — extractLanguageDirective (full-buffer regex)
and extractNewOutlines (char-walk from the array start). That is O(n²) over
the stream; a ~300 KB response blocks the event loop for ~20 s.
2. lib/generation/interactive-post-processor convertLatexDelimiters restores
<script> placeholders by rebuilding the whole HTML string once per block —
O(blocks × length). A widget with many <script> tags blocks for tens of
seconds and allocates GBs.
Fixes:
- extractNewOutlines: parse incrementally, resuming from a cursor so the buffer
is scanned once across the stream (O(n)). Behaviour-equivalent — verified
across chunk sizes, markdown fences, flat arrays, prose preambles, and
braces/escapes inside string values.
- extractLanguageDirective: bound the regex to the buffer head (the directive is
the first wrapper key), O(1) per chunk.
- Restore <script> blocks in a single pass with a function replacer ($-safe).
- Stream-loop hardening: honor request abort and propagate the AbortSignal to
the LLM call so upstream generation stops on disconnect; cap the accumulated
buffer; guard controller.close() against double-close.
Standalone repro (copied functions): 300 KB outline stream 20.8 s -> 1.3 s;
45 MB widget HTML >30 s + OOM -> 45 ms.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* feat(audio): let resolveAgentVoice honor per-agent voice overrides
* feat(settings): persist per-agent voice overrides
* fix(agents): persist AgentBar voice picks via settings overrides
* fix(classroom): keep user's agent mode and selection across loads
* fix(agents): only carry user-set agent selection across classrooms
Review follow-ups: stage-derived defaults written by a classroom load were
re-read as a user choice on the next load, so visiting a preset classroom
permanently downgraded auto classrooms to preset agents. Track the origin
with a persisted agentSelectionIsUserSet flag (set by AgentBar interactions,
cleared by fallback writes). Also: voice overrides are now clearable
(undefined deletes), the override type is single-sourced in voice-resolver,
and persist rehydration of the new fields is pinned by tests.
* fix(agents): don't mark stage-derived selections as user choices
Round-2 review: clicking the already-active mode tab no longer flags the
selection as user-set (a visual no-op must not promote stage defaults to a
choice), generation-preview clears the flag when it writes the generated
roster, and tests now pin that setter writes actually reach storage.
* fix(agents): restore generated agent selection when switching back to Auto
Review follow-up (#723): handleModeChange('auto') left the preset ids
selected, so the UI said Auto while discussion playback kept using preset
agents, and the persisted user-set auto pair could never validate on
restore. Switching to Auto now selects the loaded classroom's generated
agents (empty when none are loaded, falling back to stage defaults on the
next classroom load).
* fix(audio): gate SpeechButton on ASR availability
SpeechButton only honored the `disabled` prop and never read ASR state, so
each call site had to wire it and the home page passed nothing — the mic
button stayed clickable even when ASR was turned off.
Add a `useASRAvailable()` hook as the single source of truth (the
`asrEnabled` toggle + whether the selected provider is usable + Web Speech
API support for browser-native) and consume it inside SpeechButton, so every
call site is gated uniformly. The external `disabled` prop still composes on
top, so existing call-site conditions keep working.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(audio): address review — trim API key, require custom-provider models
- Treat whitespace-only API keys as unconfigured: the recorder only sends
keys after trim(), so an untrimmed check enabled the button and then
failed server-side as missing credentials (review P3).
- Custom ASR providers now count as unavailable until at least one model
is configured, mirroring the media-popover rule that hides model-less
custom providers (review P2).
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>
* feat(import): add pptxtojson-pro workspace package and stage-1 PPTX import
Vendor the TypeScript pptxtojson-pro parser as a workspace package, sync its
bundle to public/vendor at install time (avoids Turbopack dynamic require
issues), and wire a home-page import hook that parses files for inspection.
Co-authored-by: Cursor <cursoragent@cursor.com>
* feat(import): extend pptxtojson-pro with PPTX → Slide[] pipeline
`importPptx` now turns a .pptx file directly into canvas `Slide[]`,
optionally uploading every base64 image and blob-backed media via a
caller-supplied OSS callback before resolving.
- Vendor OpenMAIC slide types and shapes config into `src/openmaic/`
so the bundled dist is self-contained and loadable via `/vendor/`
URL under Turbopack; add stubs for `resolveFont`, `getSvgPathRange`
and `parseVideoCodec` until the real PPTist helpers are ported.
- Move `import-pipeline/` under `src/` and re-export `importPptx`,
`parsedToSlides`, `OssUpload`, `ImportPptxOptions` and `CanvasSlide`
from the package main entry.
- Add `nanoid`, `katex` and `pptxtojson` as runtime deps of the package.
- Update `useImportPptx` to accept `upload` / `onImported` and return
the converted `Slide[]`.
- Document the new API surface, error semantics and Turbopack workaround
in the package README.
Co-authored-by: Cursor <cursoragent@cursor.com>
* feat(slide-renderer): package skeleton (rollup + tsc + empty index)
Workspace package scaffolding: package.json with peer deps (react/react-dom/motion/tailwindcss),
rollup ESM+CJS config, tsconfig (strict, jsx react-jsx), and empty entrypoints under src/.
Verified: pnpm --filter slide-renderer build produces dist/{index,elements/index,types/index}.{js,cjs,d.ts}
(empty chunks are expected at this stage).
* docs(slide-renderer): DESIGN.md + README.md
* feat(slide-renderer): copy Slide/Element types + add effects types
* feat(slide-renderer): add utils (geometry simplified to elements API, element ranges, cn)
* feat(slide-renderer): shared element hooks (fill/outline/shadow/flip) + ElementOutline
* feat(slide-renderer): BaseTextElement
* feat(slide-renderer): BaseShapeElement + GradientDefs + PatternDefs
* feat(slide-renderer): pure <img> BaseImageElement, decouple OpenMAIC media business
The base component drops:
- useMediaGenerationStore / isMediaPlaceholder (AI media generation polling)
- useSettingsStore (imageGenerationEnabled toggle)
- useMediaStageId / retryMediaTask (classroom-scoped retry orchestration)
- useI18n (placeholder/error/disabled copy)
- skeleton / error / disabled render branches
Retains: clip / filter / outline / shadow / colorMask, output <img src={elementInfo.src}>.
Adds a `renderImage` slot so consumers can re-inject business behavior (placeholders,
retry buttons, custom src resolvers) without modifying the package.
* feat(slide-renderer): Line / Table / Latex / Code base elements
- Line + LinePointMarker: copied with stroke-draw animation intact
- Table + StaticTable + tableUtils: copied with getTableSubThemeColor moved to package utils
- Latex: katex HTML + legacy SVG fallback, no business deps
- Code: shiki-based syntax highlighting (dynamic import); shiki added as optional peer
dependency so consumers without code slides pay zero install cost
* feat(slide-renderer): BaseChartElement + Chart + chartOption (echarts as optional peer)
* feat(slide-renderer): pure <video> BaseVideoElement, decouple OpenMAIC media business
Drops:
- useCanvasStore (playingVideoElementId / pauseVideo)
- useMediaGenerationStore / useMediaStageId / retryMediaTask / getVideoMediaRefForElement
- useSettingsStore (videoGenerationEnabled)
- useI18n, motion/react animate scope
- skeleton / error / disabled / placeholder branches
Retains <video src controls preload=metadata>. Adds a `renderVideo` slot so
consumers can re-inject orchestrator-driven playback or placeholders.
* feat(slide-renderer): canvas hooks (useSlideBackgroundStyle, useViewportSize simplified)
- useSlideBackgroundStyle: copied as-is (no business deps)
- useViewportSize: rewritten to take viewportSize/Ratio/canvasPercentage as args,
drop useCanvasStore, drop editor-only canvasDragged/dragViewport, return fitScale
instead of writing to a store
* feat(slide-renderer): 4 effect overlays (Highlight/Spotlight/Laser/Zoom), props-driven
All overlays now receive element/geometry/options through props instead of reading
useCanvasStore. SpotlightOverlay uses a configurable element-id prefix
(default 'slide-element-') to locate DOM nodes for measurement, matching the
convention SlideElement will set in T14.
HighlightEffectOptions extended with color/opacity/borderWidth/animated to surface
the original visual knobs through the public API.
* feat(slide-renderer): SlideElement dispatcher with renderImage/renderVideo slots
* feat(slide-renderer): SlideCanvas v1 main entry (props-driven, auto-fit viewport)
Mirrors ScreenCanvas structure but reads from props: slide.elements, slide.theme,
props.background ?? slide.background, props.scale ?? autoFit, props.effects.
Auto-fits viewport into container by default via useViewportSize+ResizeObserver;
pass scale=1 to opt out and render at slide-native dimensions.
* feat(slide-renderer): SlideRendererProvider + useSlideContext (props or context)
SlideCanvas now reads from context as a fallback when props are omitted. Allows
the wrap-then-compose pattern from spec §3.2: provider holds shared data,
sibling overlays read via useSlideContext.
* feat(slide-renderer): aggregate public exports
Main entry exposes SlideCanvas, SlideElement, Provider/hooks, effects, hooks,
utils. `slide-renderer/elements` re-exports all 9 Base*Element + shared
ElementOutline/useElementXxx for granular composition. `slide-renderer/types`
already lived in src/types/index.ts.
* docs(slide-renderer): complete README (install / quickstart / API / effects / Tailwind setup)
* feat(demo): /slide-renderer-demo route exercising the workspace package
Hand-written single Slide with shapes + text demonstrates the v1 API end-to-end:
- props-driven SlideCanvas
- auto-fit viewport via parent container
- gradient background, shape outline + text fill
Wires slide-renderer as a workspace dep and registers its dist as a Tailwind
@source so utility classes inside the package get picked up by the host PostCSS
pipeline.
* feat(pptxtojson-pro): align imported Slide JSON with renderer contract
- Drive `viewportWidth` from the deck's actual pixel width (json.size.width
× ratio) instead of the legacy 960 default, so 16:9 widescreen decks no
longer get text element widths clamped to 4:3 dimensions (e.g. titles
truncated to 842px and forced to wrap). Per-slide `viewportSize` now
reports the same value, keeping transform-time and render-time aligned.
- Replace the pass-through font STUB with real resolution: 22-font
self-hosted whitelist + alias map (微软雅黑/等线/宋体/楷体/仿宋/Arial/etc.)
→ 5-category primary font mapping, so unknown PPT fonts fall back to a
rendered open-source equivalent and the pipeline can surface the
replacement via `replacedFonts.fallback`.
- Translate cell `vAlign` from PPT-native (`up`/`mid`/`down`) to CSS-native
(`top`/`middle`/`bottom`) at the importer boundary, so the renderer can
transparently pass it through to `vertical-align` / `justify-content`
without per-component conversion.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(slide-renderer): drop Tailwind defaults, data-drive styles, ship fonts
Three intertwined changes that together make the package self-contained
and align it with the "slide JSON is the single source of visual truth"
contract.
1. Remove Tailwind utility classes from every element renderer.
- Replace `className="absolute ..."` / `className="rounded ..."` etc.
with inline `style={{ position: 'absolute', borderRadius: ... }}`.
- The few rules that can't be expressed inline (descendant selectors,
keyframes, browser-default <p> margin reset) move to a new
`src/styles.ts` injected once by `<SlideCanvas>` via `<style>`.
Named animation classes (`slide-renderer-pulse` / `-ping`) replace
`animate-pulse` / `animate-ping` so consumers don't need Tailwind.
2. Strip renderer-level positive defaults; surface them as data fields.
- `BaseTextElement`: drop hardcoded `overflowWrap: 'break-word'` and
the `paragraphSpace ?? 5` fallback. `--paragraphSpace` is only set
when defined in data; CSS `var()` fallback is 0.
- `StaticTable`: drop hardcoded `padding: '5px'`, `verticalAlign:
'middle'`, `wordBreak: 'break-word'`. Extend `TableCell` with
`padding?: string` and `vAlign?: 'top' | 'middle' | 'bottom'` so
PPT-extracted padding / vertical alignment flow through unchanged.
- `PPTTableElement` gets `rowHeights?: number[]` (per-row min-height;
content can still grow rows).
- Reshape `<td>` to match the classroom Vue layout: outer `<td>` carries
only border + textStyle; inner `slide-renderer-cell-text` <div> is
a flex column with `min-height = rowHeight - 4`, `padding =
cell.padding`, `line-height: 1`, `justify-content` from `cell.vAlign`.
Add `.slide-renderer-cell-text p + p { margin-top: 0.4em }` to give
adjacent paragraphs breathing room without breaking the reset.
3. Self-contained font shipping.
- Move the 22 woff2 files into `packages/slide-renderer/fonts/`.
- Ship a sibling `fonts.css` with @font-face declarations using
relative `./fonts/<name>.woff2` URLs.
- Expose both via `package.json` exports (`./fonts.css`, `./fonts/*`)
and the `files` array.
- Consumer adds one import (`import 'slide-renderer/fonts.css'`); the
bundler resolves the relative URLs against the package and emits
each woff2 as a static asset. Removes the dependency on consumer-
owned `app/globals.css` @font-face blocks and `public/font/` copies.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(demo): wire slide-renderer fonts and swap demo to a table-heavy slide
- Import `slide-renderer/fonts.css` in the root layout so consumer apps
pull the package's self-hosted @font-face declarations and woff2 assets
through Next.js' static-asset pipeline.
- Replace the hardcoded `demoSlides` array (24 mixed-element slides) in
`/slide-renderer-demo` with a single 5×7 table-heavy slide so the demo
exercises the new `TableCell.padding` / `TableCell.vAlign` /
`PPTTableElement.rowHeights` fields and the flex-based cell layout.
Convert the legacy `vAlign: 'up' | 'mid' | 'down'` values to the
CSS-native `'top' | 'middle' | 'bottom'` form the renderer now expects.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(slide-renderer): add slideToPng standalone snapshot util
Exposes a new `slide-renderer/snapshot` sub-export with `slideToPng(slide,
options)`, the foundation for the AI-driven visual diff loop (snapshot
the rendered slide, compare against PowerPoint's own PNG export, decide
whether a discrepancy belongs to the import algorithm or the renderer).
Implementation notes
- Mounts `<SlideCanvas>` into an off-screen container sized exactly to
the slide's native pixels, so `useViewportSize` collapses to a 1:1
render (no scale offset).
- `flushSync` for the initial commit so the snapshot doesn't fire on an
empty container; `requestAnimationFrame` × 2 to let the ResizeObserver
settle; then waits for `document.fonts.ready` and every `<img>` in the
container (with a configurable `timeoutMs`, default 5s).
- Snapshots the SlideCanvas root (`container.firstElementChild`) rather
than the outer wrapper — html2canvas-pro's bounding-box math otherwise
leaves white edges or drops absolutely-positioned children.
- Uses `html2canvas-pro` instead of `html-to-image`: the latter's SVG
`<foreignObject>` path loads embedded woff2 asynchronously, so the
drawImage fires before fonts decode and text re-wraps in the fallback
font. html2canvas-pro walks the DOM and inherits the parent document's
font registry, keeping wrap positions identical to the on-screen render.
- `onclone` hook injects a small CSS reset (`font-kerning: none`,
`font-feature-settings: normal`, `font-variant-east-asian: normal`,
`text-rendering: geometricPrecision`) scoped to the slide tree, to
prevent html2canvas-pro's CJK text measurement from clipping
full-width punctuation (e.g. `(` / `)`) past cell boundaries.
- Default `pixelRatio` follows `window.devicePixelRatio` for retina-sharp
output; consumers can override.
- Optional `debugVisibleMs` briefly shows the off-screen container after
snapshot so callers can compare what was captured vs the live render.
Wiring
- Sub-export added to `package.json` (`./snapshot`) and Rollup `entries`
for tree-shaking — apps that don't use snapshot don't pay the
`html2canvas-pro` bundle cost.
- Demo route adds an "导出 PNG" button that calls `slideToPng` on the
active slide and triggers a browser download.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore: build slide-renderer in root postinstall
Without this, fresh installs leave packages/slide-renderer/dist
missing and Next.js fails to resolve the `slide-renderer` import.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(parser+renderer): iteration-0601-002 fidelity fixes
Parser (pptxtojson-pro):
- shapeSerializer: stop painting parent fill on grpFill children; honor
explicit <a:ln><a:noFill/></a:ln> over theme lnRef (master logo dots
were rendering as visible green rings).
- imageSerializer: detect custGeom ellipses and 8-vertex chamfered-rect
photo frames; resolve to 'ellipse'/'octagon' instead of falling back
to 'rect'.
- textSerializer: emit text-shadow from rPr effectLst > outerShdw, and
compensate the half-leading PowerPoint puts above the first line for
unitless lnSpc > 1 (cover-title gap regression).
- border/tableSerializer: pass rgba()/hsla() colors through ensureHex
untouched so '#rgba(...)' never reaches the DOM.
- transformParsedToSlides: drop the 1.1 SAFE_PADDING wrap-fudge and
thread bodyPr@anchor through as vAlign.
- font config: add 思源黑体/思源宋体 + Source Han aliases and a trailing
region/weight suffix stripper so 'SourceHanSerif CN Light' resolves.
Renderer (slide-renderer):
- SlideCanvas: new chrome prop (default true) to opt out of the
preview-only card shadow + rounded corners; snapshot pipeline passes
false so html2canvas output matches PPT edges.
- BaseTextElement: flex-column + justifyContent driven by the new
vAlign field; width/height stay 100% so the box anchors correctly.
- BaseImageElement: maxWidth/maxHeight 'none' to prevent host CSS from
shrinking absolutely-positioned <img>.
- snapshot: render with chrome=false.
Docs: SKILL.md expanded with the iteration workflow + OOXML traps.
* fix(parser+renderer): iteration-0605-001 fidelity fixes
slide-renderer:
- PPTImageElement: add `softEdge` field (feather radius that fades image
alpha to transparent at every edge, per a:softEdge@rad).
- TableCell: add per-side `borders` so cells with partial dividers render
each side independently instead of falling back to the table-level
uniform outline.
- BaseTextElement: hoist `fill`/`opacity` to the outer wrapper so the
background covers the full shape rectangle, matching PowerPoint behavior
for short text inside tall shapes.
- Misc tweaks across image/latex/shape/video base elements, StaticTable
and the standalone snapshot util.
pptxtojson-pro:
- Parser/serializer fidelity improvements for text, math, image, shape
and table (notably ~500 lines in textSerializer and ~127 in
mathSerializer).
- Refinements in GroupNode, MathNode and ShapeNode models; richer Theme,
StyleResolver and RenderContext plumbing.
- Expanded shape presets and customGeometry utilities, plus adapter and
import-pipeline updates to surface the new fields.
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore: stop tracking local slide-renderer-demo sandbox
`app/slide-renderer-demo/page.tsx` is a personal scratchpad used for
ad-hoc rendering tests; it shouldn't ship with the package. Remove it
from the index (file stays on disk locally) and ignore the directory so
future tweaks don't show up in `git status`.
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore: rename packages pptxtojson-pro→maic-import and slide-renderer→maic-renderer
Align workspace package names with the MAIC product family:
packages/pptxtojson-pro → packages/maic-import
packages/slide-renderer → packages/maic-renderer
Functional references updated end to end:
- Root package.json: workspace deps + postinstall/sync scripts
- next.config.ts: transpilePackages
- app/globals.css: Tailwind `@source` for renderer dist
- app/layout.tsx: `maic-renderer/fonts.css` import
- lib/import/use-import-pptx.ts: imports + runtime URL
(`/vendor/maic-import/index.js`) + script comment
- scripts/sync-maic-import.mjs: renamed and pointed at the new dist
- .gitignore: vendor path and sync-script comment
- Package package.json `name` fields and cross-link in READMEs
Also re-include the gitignored `app/slide-renderer-demo/` in Tailwind's
source detection via an explicit `@source` so its classes (e.g.
`bg-violet-600`) keep getting generated — Tailwind v4 skips gitignored
paths by default, which was making the demo's import button render
white-on-white after the demo was excluded from version control.
CSS class names (`slide-renderer-prose` / `slide-renderer-cell-text` /
`slide-renderer-pulse` / `slide-renderer-ping` / `slide-renderer-code-
cursor-blink`) and internal source comments that still reference the old
package names are intentionally left untouched to keep the rename
diff minimal; they can be updated separately as the codebase evolves.
Co-authored-by: Cursor <cursoragent@cursor.com>
* feat(dsl): extract @maic/dsl contract package and adopt @maic/* scope
Establish the SDK family's contract keystone and align package naming with
the planned @maic/* scope, per PR #668 review.
1. New @maic/dsl package (packages/maic-dsl)
- Pure, zero-runtime-dependency spec: the canonical slide object model,
pure type-guards, and DSL version/migration scaffolding.
- Seeded from lib/types/slides.ts but reconciled into a *superset* of the
three previously-drifted copies (app / renderer / importer); merged
fields are annotated @since-merge. README documents the divergence and
the acyclic dependency arrows (renderer/importer -> dsl -> nothing).
- Enums are regular (not const) so consumers compiling with
isolatedModules can import them across the package boundary (TS2748).
2. Wire @maic/importer to @maic/dsl
- Import all slide types from @maic/dsl; delete the vendored
openmaic/types/slides.ts copy.
- Eliminate the Slide drift at the root: transformParsedToSlides now fills
viewportSize/viewportRatio/theme at construction and emits a complete
DSL Slide, removing the partial "draft slide" + post-fill step in
parsedToSlides (no DraftSlide type needed).
- Add @maic/dsl to the root postinstall build chain before the importer.
3. Adopt @maic/* scope (agent-noun names)
- maic-import -> @maic/importer
- maic-renderer -> @maic/renderer
- Update all package-name references (deps, app imports, transpilePackages,
fonts.css subpath import, Tailwind @source node_modules path, READMEs).
- Directory names and /vendor paths are intentionally left unchanged.
Note: @maic/renderer still vendors its own slide types; wiring it to
@maic/dsl is the next step.
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor(renderer): consume slide types from @maic/dsl, drop vendored copy
Wire @maic/renderer to the @maic/dsl contract keystone, completing the
de-duplication of the slide object model across the SDK family.
- Delete packages/maic-renderer/src/types/slides.ts (the vendored copy) and
repoint all ~30 internal imports at @maic/dsl. SlideElement's runtime
`ElementTypes` value import now resolves to the DSL enum.
- Re-export the DSL types from src/types/index.ts so the public
`@maic/renderer/types` entry keeps exporting the full slide contract
(alongside the renderer-only effect types).
- Add @maic/dsl as a regular dependency and mark it external in the rollup
build so consumers share a single copy (enum not inlined); the emitted
.d.ts references @maic/dsl directly.
@maic/dsl is a superset of the renderer's former types, so this is
non-breaking; the renderer additionally gains `script` and the
importer-origin fields it didn't previously declare.
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor(renderer): serve fonts from OSS, drop the 43.6MB bundled woff2
Move the 22 CJK fonts off the repo and onto object storage to fix the
PR #668 blocking repo-weight concern.
- fonts.css now points every @font-face src at
https://file.maic.chat/fonts/<name>.woff2 instead of bundled local files.
- Extract the CDN origin + font whitelist into fonts.config.mjs (single
source of truth) and generate fonts.css from it via
scripts/generate-fonts-css.mjs. `genfonts` runs first in the build, so the
CSS always reflects the config; changing the domain is now a one-liner.
- Delete packages/maic-renderer/fonts/*.woff2 (22 files, ~43.6MB) and drop
the now-unused "./fonts/*" export and "fonts" files entry from package.json
(fonts.css is kept).
Font names are unchanged, so consumers and the importer font whitelist are
unaffected. Note: this removes the files going forward only; purging them
from git history (LFS / filter-repo) is a separate follow-up.
Co-authored-by: Cursor <cursoragent@cursor.com>
* feat(home): gate the unwired PPTX import button behind a feature flag
The PPTX import flow is still scaffolding — `useImportPptx` has no
`onImported` consumer, so clicking it only logs the parsed slides. Hide both
PPTX import entry points (and the hidden file input) behind
NEXT_PUBLIC_ENABLE_PPTX_IMPORT (default off) so the UI doesn't expose a
no-op. The classroom import button is unaffected.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(import): harden the runtime URL-loaded PPTX parser
The PPTX parser is loaded at runtime from /vendor/maic-import/index.js — a
gitignored artifact synced into public/vendor during postinstall. If a deploy
skips that step the URL 404s and import() fails with an opaque SyntaxError
(404 HTML parsed as JS). Add guards on both ends plus docs.
- Build-time assertion: scripts/assert-vendor-maic-import.mjs verifies the
bundle exists and is non-empty; wired into `build` so a misconfigured deploy
fails early with an actionable message instead of shipping a broken runtime.
- Runtime guard: use-import-pptx.ts HEAD-probes the URL before import() and,
on a non-ok response, throws a clear error surfaced to the user via the new
import.error.parserUnavailable string (added to all 6 locales).
- Docs: document the postinstall deploy dependency and the pull-without-install
type/runtime drift in @maic/importer's README.
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore: unify the @maic/* license policy to AGPL-3.0
Pick one license for the SDK family and apply it uniformly, matching the
OpenMAIC root, per PR #668 review.
- @maic/dsl and @maic/importer: relicense MIT -> AGPL-3.0 (package.json +
full AGPL-3.0 LICENSE text).
- @maic/renderer: already AGPL-3.0; add the LICENSE file its package.json
`files` already referenced.
@maic/importer is derived from pptxtojson (MIT); MIT permits relicensing a
derivative under AGPL, and the upstream MIT attribution is retained in the
package README/index.html, so this is compliant.
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore: rename packages/maic-import dir to maic-importer
Align the importer's directory with its @maic/importer package name and the
maic-* sibling dirs (maic-dsl, maic-renderer). Package name is unchanged, so
imports/transpilePackages/node_modules resolution are unaffected.
- git mv packages/maic-import -> packages/maic-importer (history preserved).
- Rename the vendor sync/assert scripts and the runtime vendor path to match:
scripts/{sync,assert-vendor}-maic-importer.mjs, public/vendor/maic-importer,
URL /vendor/maic-importer/index.js.
- Update all path references: root postinstall/build/sync scripts, .gitignore,
use-import-pptx.ts, and doc links in the dsl/renderer/importer READMEs.
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore: nest the @maic packages under packages/@maic/
Mirror the @maic/* npm scope in the directory layout: move the three family
packages into packages/@maic/{dsl,importer,renderer}. Package names are
unchanged, so imports / transpilePackages / node_modules resolution are
unaffected.
- git mv packages/maic-{dsl,importer,renderer} -> packages/@maic/* (history
preserved).
- pnpm-workspace.yaml: add packages/@maic/* glob.
- Recompute the root postinstall cd chain for the nested layout.
- Update dir-path references: sync script srcDir, .gitignore comment, the dsl
source comment, and the renderer/importer README/SKILL cross-links.
Unchanged: the @maic/* package names, the runtime vendor path
(public/vendor/maic-importer) and its sync/assert scripts.
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore(renderer): clear font licenses, drop non-redistributable faces, remove importer font remapping
Address the PR #668 blocking font-license-clearance review.
Font licensing (renderer):
- Reduce the self-hosted whitelist to 6 clearly-redistributable faces:
SourceHanSans/SourceHanSerif/LXGWWenKai/ZhuQueFangSong (SIL OFL 1.1),
ZcoolHappy (ZCOOL free-use), WenDingPLKaiTi = AR PL KaitiM GB (Arphic PL 1999).
- Drop AlibabaPuHuiTi: free to *use* commercially but its license grants no
explicit redistribution/re-host right, unlike OFL — dropped to keep public
CDN serving unambiguous.
- Add FONTS.md (per-face attribution/clearance record, separate from the
package's AGPL LICENSE) and bundle the verbatim license texts under
font-licenses/ (OFL.txt, ZcoolHappy-LICENSE.txt, ARPHIC-PL.txt); ship both via
package.json `files`. Regenerate fonts.css from the trimmed config.
Importer font remapping removed:
- The importer no longer rewrites font-family names (alias -> category ->
primary). It passes each slide's original font-family through unchanged, so
it can never target a face the renderer doesn't ship. Delete configs/font.ts,
the resolveFont/replaceFontFamilyInHtml helpers, and the now-unused
FontReplacementBucket / ImportContext.replacedFonts plumbing.
Co-authored-by: Cursor <cursoragent@cursor.com>
* docs(renderer): document the CDN font runtime dependency
Add a "Fonts" section to the renderer README per PR #668: the optional
`@maic/renderer/fonts.css` loads woff2 from an external host
(https://file.maic.chat), which must be reachable + CORS-enabled or the
browser silently falls back to system fonts. Note that the import is optional
and that the origin is configurable via fonts.config.mjs + `pnpm run genfonts`.
Co-authored-by: Cursor <cursoragent@cursor.com>
* docs(renderer): verify WenDingPLKaiTi == AR PL KaitiM GB from the font name table
Record the embedded-name-table evidence (Family/Copyright/Trademark/Designer =
Arphic, nameID 13 = the full Arphic Public License) so the
WenDingPLKaiTi ⇄ AR PL KaitiM GB correspondence is provable, and correct the
copyright year to 1994–1999 to match the font metadata.
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore: fix `pnpm check` (prettier) after merging main
main added a `prettier . --check` CI step that flagged 180 files. Resolve it
consistently with the existing convention (vendored/workspace packages are
excluded from root Prettier):
- .prettierignore: exclude `packages/@maic/` (own rollup/tsc/eslint toolchains;
dist is generated, importer/src1 is a vendored oracle), matching how
pptxgenjs / mathml2omml / docs are already handled.
- Format the three root-level files we added/edited that root Prettier does
cover: lib/import/use-import-pptx.ts and the two scripts/*-maic-importer.mjs.
`pnpm check` now passes.
Co-authored-by: Cursor <cursoragent@cursor.com>
* style: align @maic/{dsl,renderer,importer} source to root Prettier
Per review preference, the @maic packages are our own code and should follow
the repo style rather than be ignored wholesale. Narrow .prettierignore to only
the generated build output (packages/@maic/*/dist/) and the vendored legacy
reference (packages/@maic/importer/src1/), then `prettier --write` the package
sources. Formatting-only; all three packages still build.
`pnpm check` passes.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(lint): scope ESLint to @maic source and clear all errors
- eslint.config.mjs: replace blanket packages/** ignore with precise
rules so @maic/{dsl,importer,renderer} source is linted, while skipping
third-party packages, dist output, importer/src1 and public/vendor
(the generated bundle was producing thousands of false errors in CI).
- importer: replace `any` with concrete narrowings/types, fix prefer-const.
- renderer: drop manual useMemo that React Compiler could not preserve.
- remove leftover debug console.log + stale eslint-disable in use-import-pptx.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(i18n): add missing PPTX import keys to pt-BR
pt-BR.json was missing import.{pptx,parsingPptx,pptxSuccess} and
import.error.{invalidPptx,parserUnavailable}, failing the i18n key
alignment check against en-US.json.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(generation): opt-in parallel scene-content generation
Scene generation was strictly serial — content -> actions -> TTS, one
outline at a time — so an N-scene classroom paid N x (content + actions
+ TTS) of wall-clock latency, which dominates the post-outline wait.
Add an opt-in hybrid two-phase path (#572):
- Phase 1 fetches scene *content* concurrently (bounded). Content is the
only per-scene step independent of cross-scene state, so it is safe to
parallelise; a content failure marks just that outline and does not
pause the batch.
- Phase 2 keeps the existing in-order actions + TTS loop, so
previousSpeeches threading, ordered addScene, the abort/epoch guards,
and the pause-on-failure UX are all unchanged.
Gated by a server-side PARALLEL_SCENE_CONCURRENCY (default 0 = off,
clamped to 10), surfaced to the client through the existing
/api/server-providers response. With it unset the content map is null
and the loop is byte-for-byte the original serial path, so out-of-box
behaviour is unchanged.
The bounded worker pool is extracted to lib/utils/concurrency.ts
(mapWithConcurrency, with an early-stop hook for abort/epoch) and
unit-tested; getParallelSceneConcurrency env parsing/clamping is tested
too.
Closes#572
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor(generation): pipeline content fetches instead of a barrier
Address @wyuc's review on #660. The previous version awaited the whole
bounded content pool before Phase 2, so for N > C scenes the user saw the
first scene, then a stall on a single page for the entire content phase,
then a burst — perceived as worse than serial despite the wall-clock win
(the gap scales with ceil((N-1)/C)).
Pipeline instead: lazyBoundedMap starts the content fetches (<= C in
flight) and returns one promise per outline immediately; the serial loop
awaits them in order, so each resolves as soon as its own content is ready
(usually already done, hidden behind the previous scene's actions/TTS). The
first scene now paints after content(1)+actions(1)+TTS(1) — same as serial
— with the full concurrency benefit and no stall.
Also from the review:
- a content fetch can no longer take its siblings down: an unexpected throw
is caught and returned as a failure result, routed through the same
mark-failed path as the serial loop (symmetric);
- drop the cosmetic Phase-1 setCurrentGeneratingOrder — the loop already
sets it per outline;
- note the intentional belt-and-suspenders clamp;
- concurrency.test.ts asserts <= limit (not == limit), and gains
lazyBoundedMap tests including the no-barrier property.
mapWithConcurrency is kept as a thin await-all wrapper over lazyBoundedMap.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: ly-wang19 <ly-wang19@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: wyuc <wang-yc24@mails.tsinghua.edu.cn>
* feat(tts): voxcpm voice-design types + deterministic voice id helpers (#670)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(tts): emit + persist per-agent voiceDesign descriptor (#670)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(tts): voxcpm voice registration backend client (#670)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(tts): voxcpm-voice ensure/register endpoint (#670)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(tts): client auto-voice registration + reference-clip cache (#670)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(tts): reference registered voice id in vLLM-Omni speech (#670)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(tts): thread voiceDesign + backend through tts call sites (#670)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(tts): match vLLM-Omni voice registration contract (#670)
Live e2e against the real backend revealed the assumed multipart contract was
wrong: POST /v1/audio/voices needs name + consent + audio_sample (not
voice_id/file), and there is no per-name GET (405) — existence must list
/v1/audio/voices and check membership.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* refactor(tts): make auto-voice register-once pattern provider-neutral (#670)
The descriptor + register-once/reference-by-id pattern is not VoxCPM-specific.
De-couple it into a provider-neutral seam so other registration-capable
providers (ElevenLabs/MiniMax/Doubao voice cloning, …) can plug in:
- lib/audio/voice-design.ts: VoiceDesign + buildVoiceDesignPrompt /
normalizeVoiceDesign / getDeterministicVoiceId (neutral 'auto-<hash>' id,
namespaced by providerId).
- lib/audio/voice-registration.ts: VoiceRegistrationAdapter interface +
providerId->adapter registry + supportsVoiceRegistration.
- lib/audio/voice-registration-client.ts: neutral ensureRegisteredVoice() +
IndexedDB clip cache.
- app/api/generate/voice (replaces .../voxcpm-voice): dispatches by providerId.
- voxcpm-registration.ts becomes the VoxCPM adapter (sole registered provider).
- AgentConfig.voiceDesign + DB cache table renamed neutral.
Behavior-preserving; VoxCPM-specific bits (inline (prompt)text, backend kinds,
capability gate) stay in the voxcpm modules. Full suite green (674).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(tts): build the voice clip Blob from an inline Uint8Array (#670)
A factored-out helper returning Uint8Array widened to Uint8Array<ArrayBufferLike>,
which next build (stricter than bare tsc) rejects as a BlobPart. Inline the
buffer like the rest of the repo does.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(tts): managed TTS providers resolve model server-side (#670)
A server-managed TTS provider's model was still client-driven, but the
managed-provider settings UI hides the model field — so a backend whose model
id isn't the client default (e.g. VoxCPM/vLLM-Omni serving the full model path)
always 500'd. resolveTTSModel() makes the model authoritative from server
config (${PREFIX}_MODELS, first entry) for managed providers, like key/baseUrl;
unmanaged/unconfigured providers keep the client model unchanged. Used by the
tts and voice routes.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(tts): single agent-voice resolver + stable teacher narration voice (#670)
Route all TTS voice resolution (narration, discussion, preview) through one
resolveAgentVoiceOptions(agent, ...) that reads the agent profile and registers
+ references the voice by id. Eagerly warm up generated agents' voices on save.
Critically fixes the teacher narration drifting (male/female jumps): the registry
is always seeded with DEFAULT_AGENTS, so the old narration lookup
find(role==='teacher') returned the default teacher (no voiceDesign) instead of
the generated one — so narration never registered a voice and fell back to the
inline prompt. pickNarratorAgent() now prefers the teacher carrying a voiceDesign.
Also: drop language from the deterministic voice id (descriptor already encodes
it) so narration (directive) and discussion (locale) resolve the same id; log
the effective registeredVoiceId. Regression tests for pickNarratorAgent.
Verified e2e: agent-profiles -> 1 voice registration -> 16 narration TTS all
referencing the same registeredVoiceId; voice present on the backend.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(tts): fall back to persona as the voice seed for agents without a voiceDesign (#670)
Preset/default agents carry no LLM voiceDesign. Rather than add a static field,
derive the bootstrap descriptor from the agent's persona when voiceDesign is
absent, so they still register one stable reference voice (stable-but-generic;
persona is not a vocal spec). Generated agents keep their LLM voiceDesign.
Also hardens replay: stage snapshots drop voiceDesign but keep persona.
Unit-tested: resolveAgentVoiceOptions uses real voiceDesign when present, persona
otherwise.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(tts): match Auto Voice by its localized label in the agent voice picker (#670)
The picker filtered on voice.name ('Auto Voice'), but Auto Voice is shown via
its localized label (自动音色). Searching '自动' returned '没有匹配音色'. Match
the localized label for the Auto Voice option so it's findable in any language.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(tts): address code-review round 1 (#670)
- strip parentheses in the voice-design prompt so a paren in the descriptor/
persona can't corrupt the (prompt)text bootstrap delimiter
- gate POST /api/generate/voice on isServerTTSProviderDisabled (#665): a
force-disabled provider was off for the tts route but not this sibling
- check voiceExists before re-registering a client-cached clip, so a cached
voice that's still live isn't needlessly re-uploaded every session
- dedup concurrent ensureRegisteredVoice calls via an in-flight promise map
(eager warm-up + first utterance no longer double bootstrap/register)
- warm up only the narrator (teacher), not every generated agent, to avoid
synthesizing voices at save time for agents that may never speak
- collapse the duplicated vLLM-Omni speech payload into one object
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore(tts): prettier formatting (#670)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(tts): key auto-voice memo by (voiceId, backend) so a base-URL change re-registers (#670)
Addresses review (cosarah): registeredThisSession/inFlight were keyed by voiceId
alone, so switching the VoxCPM base URL mid-session made ensureRegisteredVoice
short-circuit and return an id registered only on the old backend — TTS then sent
that stale registeredVoiceId and skipped the inline fallback, failing with
voice-not-found on the new backend. Memo key now includes the base URL; the
IndexedDB clip cache stays keyed by voiceId (the reference clip is
backend-independent and reused to re-register elsewhere). Regression test added.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(tts): include API key in the auto-voice memo key (#670)
Addresses review (cosarah, round 2): memoKeyFor was keyed by (voiceId, baseUrl)
but not the API key. Registration/existence checks and speech calls are
auth-scoped, so switching account/key on the same base URL could reuse a
registeredVoiceId from the old credentials and skip re-validation. Memo key now
includes the API key (in-memory only, never persisted/logged). Regression test
covers the key-switch case.
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>
Action generators sometimes scripted role-play dialogue into the speech
`text` — speaker-label parentheticals like (AI助教):/(显眼包):/(学生):
and stage-direction cues like (好奇发出)/(笔记动作)/(插话) — which then
got read aloud by TTS and shown as narration, even on single-presenter
slides. The `Classroom Agents` roster (incl. student personas) is injected
into these prompts for `discussion.agentId` selection, and the model
dramatized those personas into the teacher's monologue.
Add an explicit "single voice, teacher only" constraint to all four
*-actions system prompts (slide / quiz / interactive / pbl): no dialogue
or lines for other speakers, no parenthetical speaker labels, no stage
directions; the agent roster is only for picking a `discussion` agentId;
route student reactions through the `discussion` action instead of voicing
them inline. Also drop the dialogue-inviting word "conversational" from
the slide prompt.
Verified by replaying real production scene-actions prompts against
gemini-3-flash-preview: cue rate dropped from ~10% to 0/80 on the
cue-prone set, with narration quality intact (student reactions now route
to a discussion action).
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: 杨慎 <117187635+cosarah@users.noreply.github.com>
In the IndexedDB playback branch, the object URL created via
URL.createObjectURL is revoked only inside the 'ended' listener. When
audio.play() rejects (autoplay policy, decode error, interrupted load)
that listener never fires, so the blob URL — and its backing audio blob —
leaked for the lifetime of the document. During lecture playback play() is
called once per speech action, so repeated failures (e.g. autoplay blocked
before the first user gesture, or rapid stop/skip) accumulate.
Revoke the URL when play() rejects, then re-throw. Adds a regression test.
Co-authored-by: ly-wang19 <ly-wang19@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: wyuc <wang-yc24@mails.tsinghua.edu.cn>
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>
An SVG path whose first command is an arc (A) — or one whose leading
commands push no anchor point — reaches the arc branch with an empty
`points` array, so `points[points.length - 1].type` threw a TypeError
and aborted the entire PPTX export. toPoints() documents that a malformed
path should return [] (mirroring getSvgPathRange) so a single bad or
LLM-hallucinated shape does not take down the export; this restores that
contract with a `!lastPoint` guard. Adds a regression test for the
arc-first case.
Co-authored-by: ly-wang19 <ly-wang19@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: wyuc <wang-yc24@mails.tsinghua.edu.cn>
TTS providers throw a plain `Error` on any non-OK response, and the
`/api/generate/tts` route catches everything as `GENERATION_FAILED` (500),
so an upstream 429 (quota/concurrency) was indistinguishable from a real
failure — clients had no signal to retry/back off. `TTSRateLimitError`
already existed for exactly this (with a TODO noting the route collapses
everything uniformly), but only Doubao threw it and the route never mapped
it.
- Add a `RATE_LIMITED` API error code.
- Map upstream HTTP 429 to `TTSRateLimitError` at every provider's
`!response.ok` site via a shared `throwIfTtsRateLimited` helper.
- Return `429 RATE_LIMITED` from the TTS route when a `TTSRateLimitError`
is caught (all other errors unchanged).
Purely additive: non-429 responses keep their existing error messages.
Co-authored-by: ly-wang19 <ly-wang19@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: wyuc <wang-yc24@mails.tsinghua.edu.cn>
* fix(interactive): keep-alive iframe pool so interactive scenes don't reload on remount (#619)
Interactive scene iframes reloaded on every remount — Pro mode toggle,
scene switch and back, any PlaybackChromeRoot remount — because the
<iframe srcDoc> was rendered inline in the scene subtree and React's
unmount (or a DOM re-parent) makes the browser drop and re-run the doc.
Persist the iframes in a stable host at the Stage root, outside the
mode-swap/scene subtree, keyed by sceneId:
- lib/store/interactive-iframe-pool: per-scene entries (srcDoc/src, content
hash, tracked rect, visibility), LRU-bounded (CAP=3). Re-mounting with an
unchanged hash keeps the existing content reference, so the iframe is
never re-set; only a content-hash change rebuilds it.
- InteractiveIframeHost: mounted once in Stage, portals one persisted
<iframe> per entry to document.body, positioned over each scene's rect.
Hidden (visibility, never display:none) in edit mode and whenever the
placeholder is gone. Owns the widget-iframe postMessage registration.
- InteractiveRenderer: now a placeholder that registers content, marks the
scene active/visible, reports its rect via a rAF loop, and hides (not
evicts) on unmount.
Mode toggle, back-and-forth scene switching, and re-renders now hit the
cache with zero reload and zero flash. widget-iframe messaging API is
unchanged; no change to the playback engine / SSE / edit-lock.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* test(e2e): interactive iframe keep-alive across Pro toggle + scene switch (#619)
Seeds an interactive scene whose widget holds click-counter state, then drives
the two remount triggers (Pro mode toggle, scene switch and back). A
MutationObserver scoped to the keep-alive iframe's title asserts the element is
never removed or recreated across either trigger, and the in-iframe counter
state is preserved — i.e. zero reload.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(interactive): address review — widget callback timing, fullscreen, content compare, rect gate (#619)
Code-review round-1 fixes for the keep-alive iframe pool:
- PlaybackChromeRoot: resolve the widget postMessage callback lazily at send
time instead of capturing it once at engine construction. The iframe (and its
registration) now lives in the keep-alive host, which registers a commit after
the engine is built — so eager capture got null on a scene's first visit and
silently dropped every widget action.
- InteractiveIframeHost: portal target follows document.fullscreenElement so the
iframe stays inside the presentation-fullscreen subtree (requestFullscreen runs
on the stage, not body) instead of vanishing. Known tradeoff: entering/exiting
fullscreen re-parents the iframe and reloads it once — accepted over an
invisible widget during presentation.
- InteractiveIframeHost: reset the pool when the host unmounts (classroom switch)
so a new classroom doesn't retain the previous one's resident iframes.
- InteractiveIframeHost: only show the iframe once its rect has a real measured
size (width>0 && height>0), avoiding a 0x0 flash at the viewport origin before
first layout.
- pool: drop the djb2 hash; compare srcDoc/src by value (string === is value
equality, so an equal-but-new remount string still hits the keep-alive path).
Removes the hash-collision-skips-rebuild hole and simplifies the store.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(interactive): owner-token visibility so stale cross-fade cleanup can't blank the iframe (#619)
cosarah reproduced: after toggling Edit mode on an interactive scene and
returning to playback, the scene flashed its preserved state then went
permanently blank. Root cause is a visibility race, not a reload — the document
stayed alive. Visibility was keyed only by sceneId, so during Stage's
AnimatePresence mode cross-fade the outgoing PlaybackChromeRoot's placeholder
cleanup (hide) ran after the incoming placeholder had already shown the same
scene, hiding the live iframe.
Give each placeholder mount a visibility-ownership token (useId). The pool
records the owner on claim(); release() only clears visibility when the caller
still owns it, so a stale cleanup no-ops instead of blanking a newer instance.
The host now shows iff entry.owner !== null.
- store: replace visible boolean + show/hide with owner + claim/release.
- interactive-renderer: owner = useId(); claim on mount, release on unmount.
- e2e: after returning from Pro mode, wait out the cross-fade and re-assert the
iframe stays visible with its state (guards the blank-on-return regression).
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>
The interactive-outlines template (Ultra Mode) never included the
media-generation instructions, so the `mediaGenerations` field was only
ever produced by strong cloud models inferring it from context. Weak
local models followed the prompt literally and omitted it, so images
silently never generated.
Mirror requirements-to-outlines by including the same conditional
snippet blocks (image / video / media-safety), gated on the
imageEnabled / videoEnabled / mediaEnabled variables that both outline
paths already pass to buildPrompt. Reuses the existing snippets as the
single source of truth rather than duplicating the instructions.
Extends media-conditional.test.ts to hold INTERACTIVE_OUTLINES to the
same media-gating contract as the standard template.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* feat(maic-editor): framework primitives + edit StageMode (#564)
* feat(maic-editor): framework primitives + edit StageMode
Phase 1 framework foundation for the MAIC Editor (RFC #547,
tracking #560). Plumbing only — no UI consumers ship in this
sub-PR; the EditShell chrome and slide surface registration
land in follow-ups.
- StageMode gains 'edit' alongside 'autonomous' | 'playback';
setMode resets canvas selection when leaving 'edit'.
- <Stage> auto-exits 'edit' whenever the current scene becomes
uneditable (no scenes / pending generation / no current
scene) so a follow-up Pro toggle can never strand the user
in an empty edit shell.
- SceneEditorSurface contract + tiny registry under lib/edit/
so each SceneType plugs in a surface without the shell
importing surfaces directly. Surfaces declare CanvasComponent,
useSurfaceState(), insert palette items, floating actions,
commands, and (reserved for AI) inline coach hints.
- Slide kernel (lib/edit/slide-ops.ts): immutable, history-aware
operations covering slide-update, element add / update /
updateMany / delete / deleteMany / reorder / duplicate / align /
removeProps, and text content edit.
- Slide element factories (lib/edit/slide-edit-elements.ts) for
default text / shape / image elements + HTML <-> plain-text
helpers.
- i18n: stage.editCourse + stage.doneEditing across all 6
locales, consumed by the header toggle in the next sub-PR.
- Vitest coverage for the slide kernel (operations + history)
and the edit-mode store transition (entry + canvas reset on
exit).
PBLRenderer's mode prop is widened from the literal pair to
StageMode so <SceneRenderer> (which already passes StageMode)
type-checks. The prop is unused inside the renderer.
* style(maic-editor): apply prettier to lib/edit + tests/edit
CI runs on PRs to main only, so the prettier check did not fire
for this PR's target branch — applying formatting locally before
the merge train reaches main avoids a follow-up style commit.
* ci: also run on PRs targeting feat/maic-editor-v0
The MAIC Editor lands as a series of stacked sub-PRs against
the long-lived feat/maic-editor-v0 branch. Without this entry,
none of those sub-PRs get a CI gate — style/lint/type/test
regressions only surface when feat/maic-editor-v0 finally
merges back to main, at which point fixing them is a lot more
disruptive than catching them per sub-PR.
Push trigger is intentionally left main-only: nobody pushes
directly to feat/maic-editor-v0, every change arrives through
a PR that now runs the gate.
* fix(maic-editor): address kernel review on #564
Addresses cosarah's review against #561 scope:
Important:
- element.align now uses the canonical lib/utils/element.ts geometry
helper instead of a forked copy. The local fork ignored
PPTLineElement start/end and rotation, so bounds were wrong for
lines and rotated elements.
- Cap slide-edit history at MAX_HISTORY = 50; drop oldest on overflow.
- Narrow slide.update patch to Partial<Omit<Slide, 'elements' |
'animations'>> via a new SlideMetaPatch alias, so element /
animation collections can only be mutated through their dedicated
ops.
- element.add throws on id collision; element.duplicate throws when
idMap is missing entries or when new ids would collide with
existing elements.
- scene-editor-registry dev-warns on overwriting a *different*
surface for the same SceneType (HMR re-register of the same
instance stays silent); add unregister() for HMR cleanup and tests.
Minor:
- Unify on structuredClone over JSON.parse(JSON.stringify(...));
inside immer's produce, un-proxy with current() first.
- Skip history push when produce returns the same content reference
(true no-op detection). element.delete / deleteMany pre-check
membership so their unconditional filter assignments don't break
the ref-equality signal.
- Drop redundant cloneSlideContent calls in undo/redo/push paths;
immer's structural sharing already guarantees immutability of the
produced output. createSlideEditHistory keeps its defensive clone
since the initial value comes from outside immer.
Coverage:
- Extract auto-exit predicate into lib/edit/stage-mode.ts so the
policy can be unit-tested without rendering <Stage>.
- New tests: every align direction, line / rotated element align,
no-op paths for update/delete/reorder/removeProps/text/align,
element.add index clamping + id collision, element.duplicate
default offset + contract errors, history future cleared after
branching, history capped, registry register/unregister/HMR-safe
re-register, and the auto-exit predicate.
371 vitest tests pass (was 335). tsc/lint/prettier/i18n/build all
green locally.
* fix(maic-editor): close kernel escape hatches (subagent CR follow-up)
Two defense-in-depth fixes flagged by independent review after the
prior commit:
- element.duplicate now deep-clones the source via
structuredClone(current(element)). The previous shallow spread
shared nested mutable references (start/end tuples, outline,
points) with the source; immer's COW would have handled most
mutations but ops that operate on nested arrays in place
(sort/reverse/splice) would silently leak between source and
duplicate. The deep clone keeps the kernel's invariants
independent of how downstream op consumers write their recipes.
- slide.update gains a runtime guard that throws when patch
contains elements / animations. The type-level SlideMetaPatch
narrowing already forbids these keys, but the runtime guard
closes the `as any` escape hatch for callers that might bypass
the type system.
New tests cover both paths: meta-only slide.update succeeds, an
elements-containing patch throws, and a duplicated line element's
start/end/points tuples are independent from the source.
* feat(maic-editor): EditShell chrome and Pro mode toggle (#565)
* feat(maic-editor): EditShell chrome and Pro mode toggle
Adds the scene-type-agnostic editor chrome (EditShell + CommandBar +
FloatingToolbar + HintRail), an edit-mode sidebar, and the header Pro
toggle that flips into the 'edit' StageMode from #561.
No scene editor surfaces are registered yet — the next sub-PR wires up
the slide surface. In this PR every scene type falls through to the
i18n unsupportedScene placeholder, which is the verifiable visible
behavior.
- canEdit gating reuses the canonical isCurrentSceneEditable predicate
shipped in #561 so the toggle and the auto-exit effect are in
lock-step.
- handleToggleEditMode tears down live session / engine / TTS before
entering edit mode.
- ChatArea slides out in edit mode for a full-width canvas.
- reorderScene extracted from EditModeSidebar with unit tests; the
positional-order preservation is the part worth a guard test.
- i18n scoped to keys this PR's components actually reference;
surface-specific keys deferred to the slide-surface PR.
* test(reorder-scenes): single-element + reference-inequality cases; zh-CN newSlide distinct from addSlide
CR follow-ups:
- reorderScene tests now cover a 1-element array (both directions
return null) and explicitly assert the returned array is a new
reference, not the input.
- zh-CN edit.sidebar.newSlide was duplicating the addSlide label
("新建幻灯片" both); using "未命名幻灯片" for the default new-slide
title to match the English Add slide / New slide distinction.
* refactor(maic-editor): drop EditModeSidebar; clean Pro mode chrome (#568)
Course-correct on #565. EditModeSidebar was rejected by the design
owner as inappropriate for Pro mode (#560 wording is "minimal top
bar + slide thumbnail rail", not a file-list panel). #565 also left
the playback chrome wrapped around the editor — Header / sidebar /
Roundtable / ChatArea all stayed mounted with only the sidebar
swapped, and EditShell's CommandBar/FloatingToolbar/HintRail were
never visible since no surface registers yet.
Drop EditModeSidebar + reorder-scenes helper + tests + the edit.sidebar
i18n block (8 keys x 6 locales) + the CommandBar sidebar-toggle.
Stage keeps Header mounted in both modes — it owns the global Pro
toggle Switch, which is the entry AND exit affordance (closing the
Switch exits; no separate Done-editing button). In edit mode:
SceneSidebar / Roundtable / ChatArea are not mounted, and the canvas
slot renders <EditShell scene> instead of <CanvasArea>. EditShell
internally resolves the surface via sceneEditorRegistry; when none
is registered it falls through to edit.unsupportedScene. With no
surfaces registered, every scene type lands on that placeholder —
the visible v0 behavior.
New optional EditShell.leftRail slot reserves the spot for a
redesigned slide-navigation surface; v0 ships with the slot empty.
SceneRenderer is now playback-only — the mode === 'edit' branch and
its sidebarCollapsed / onToggleSidebar props moved up to EditShell /
Stage.
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): enablement infrastructure (pre-slide-surface) (#571)
* feat(maic-editor): enablement infrastructure (pre-slide-surface)
Pre-requisite for the slide surface (#562). Ships the safety
infrastructure so each subsequent surface PR is small and
recoverable:
1. Feature flag NEXT_PUBLIC_MAIC_EDITOR_ENABLED, default OFF —
gates the Pro toggle in Header. StageMode unchanged.
2. SlideContent.schemaVersion + pure idempotent migrateSlideContent
/ migrateScene; setScenes / addScene funnel legacy data through
the migrate at the store boundary.
3. tests/edit/round-trip/ harness: apply ops -> buildPptxBlob ->
JSZip parse -> assert content survived. No PPTX -> Slide reimport
exists in the codebase, so the full reimport-diff shape isn't
doable; per-op assertions extend the harness in #562.
buildPptxBlob is now exported (hook is still the only runtime
caller).
4. Per-scene slide-history persistence helpers (persist / load /
has / clear, keyed maic-editor:slide-history:${sceneId}, swallow
storage failures) + standalone SlideHistoryRestorePrompt dialog
+ 4 new i18n strings x 6 locales. Stage wiring deferred to #562.
5. Concurrency guards: isSceneEditLocked predicate (defensive; no
current call path structurally hits it); localStorage-backed
multi-tab edit lock with tryAcquire / refresh / release / heldByOther,
stale-lock takeover after 3x heartbeat; standalone
MultiTabEditConflictPrompt + 3 new i18n strings x 6 locales.
Stage wiring deferred to #562.
The slide-surface PR owns the edit-entry effect machinery (where
the history-state lifecycle and per-tab tabId ref naturally live),
so shipping half-wired dialogs here would speculatively build Stage
state we know we'll restructure on contact with the surface.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): migrateSlideContent forward-compat — no silent downgrade
CR follow-up: previously, content with schemaVersion newer than
CURRENT (e.g. v2 written by a future client) was silently truncated
back to the current version. Now: if schemaVersion >= CURRENT, return
the content untouched. The slide may not render correctly on an older
client, but its on-disk shape stays intact for the next compatible
client to read.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): slide surface skeleton + #571 wiring + geometry (#562) (#579)
PR1 of the slide-surface work (infra-first slice). Registers the slide
SceneEditorSurface so EditShell lights up Pro mode for slide scenes.
- SceneEditorSurface impl + sceneEditorRegistry registration; the surface
owns a SlideEditHistory via the #564 kernel.
- Reuse the unmodified slide renderer Canvas through a surface-owned
scene context; geometry drag/resize/rotate commits funnel into
element.update ops (scene-edit bridge), one gesture = one undo step.
- Geometry numeric x/y/w/h/rotate popover as the precise fallback; gated
off for line elements (PPTLineElement omits height/rotate).
- Wire #571 infra: cross-tab edit lock + conflict prompt, slide-history
persistence + restore prompt, regen-lock guard.
- Renderer-commit classification: a real geometry gesture commits
synchronously inside a pointer interaction; the renderer's
ResizeObserver text-normalization commits with none, so it is folded
into the baseline (no undo step / no persist / no spurious restore
prompt on entry) instead of being staged as a user edit.
- Per-op round-trip test for element.update geometry; bridge + session
unit tests; edit.geometry i18n across all 6 locales.
Upstream-shared changes are kept minimal and additive: an optional
`controller` prop on SceneProvider (uncontrolled/playback path
unchanged) so staged edits don't write through to the live stage store,
and a FloatingToolbar trigger-nesting fix (it wrapped PopoverTrigger
around <Tooltip>, a provider, so no popoverContent action could open).
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
* test(maic-editor): lock data-URL image PPTX round-trip (PR2 R1 gate)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): insert palette — text box + image (data-URL/URL)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(maic-editor): address Task 1 review — spy cleanup, popover-only comment, ImagePicker error log
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(maic-editor): drop PR1 debug geometry toolbar; element-aware floating bar
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(maic-editor): drop redundant PPTTextElement cast (Task 2 review)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): additive ProseMirror command bridge for the property bar (C1)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(maic-editor): exhaustiveness guard + tidy C1 adapter (Task 3 review)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): refresh property-bar attrs on caret/keyboard selection (C2)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* test(maic-editor): satisfy no-explicit-any in PR2 test stubs (Task 1+4 review)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): compact text property bar in the reused floating slot
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(maic-editor): Task 5 review — uniform selection-guard, Lucide icons, JSX, memo
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* i18n(maic-editor): edit.text.* + edit.insert.* across 6 locales
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* test(maic-editor): round-trip gate for formatted text + inserts
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* docs(maic-editor): clarify remote-URL image round-trip scope (Task 7 review)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* chore(maic-editor): drop stale scaffolding comment + orphaned geometry i18n keys
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* style(maic-editor): prettier --write PR2 files (pre-push check)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* test(maic-editor): make no-explicit-any suppression prettier-robust
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): CommandBar insert popover never opened (PopoverTrigger wrapped a Tooltip provider)
Insert→Image was unreachable: InsertButton wrapped <PopoverTrigger asChild>
around <Tooltip> (a context provider, no DOM node), so Radix's Slot bound
no element. Chain both triggers onto the real <button>, exactly mirroring
the PR1 fix already in FloatingToolbar's ActionButton. PR2's insert-image
is the first popoverContent InsertButton consumer to exercise this path.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): text property bar no longer clips/overflows in the floating popover
The ~450px single-row bar was jammed into FloatingToolbar's fixed w-72
(288px) PopoverContent and clipped. Let the popover size to content
(w-auto, max-w-[92vw], Radix handles edge collision) and harden the bar
row (w-max + no child shrink, fixed-width font select) so it renders as
one clean line. Chrome/surface layout only — no renderer change.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): property bar stays open across consecutive formatting steps
execCommand refocuses the editor after every command; the uncontrolled
Radix popover treated that focus-shift as focus-outside and dismissed,
forcing a re-open of the Text bar for each format action. Prevent
onOpenAutoFocus (don't steal the canvas selection on open) and
onFocusOutside (editor refocus must not dismiss); Escape and pointer-down
truly outside still close it. Chrome-only, no renderer change.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): editor canvas now resolves gen_img_* media placeholders
The editor's interactive ImageElement rendered elementInfo.src raw,
so entering Pro mode on any slide whose image was a generation
placeholder showed a broken-image icon (while playback's read-only
BaseImageElement correctly resolved the placeholder to the generated
objectUrl). Extract the resolution into a shared useResolvedImageSrc
hook so both variants stay aligned. Strictly additive: for any
non-placeholder src (legacy / direct URL / data URL) resolvedSrc ===
elementInfo.src and the media store is not subscribed to. Pre-existing
upstream gap surfaced by PR2 as the first real-user editor consumer —
same shape as the CommandBar popover-trigger fix.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* test(maic-editor): unit-test gen_img placeholder resolution (9 cases)
Splits useResolvedImageSrc into a pure resolveImageSrc function (no
hooks) wrapped by the hook, so the resolution logic can be unit-tested
in vitest's plain node environment (no jsdom/RTL needed in this repo).
Covers: done→objectUrl; no task→raw; pending/generating/failed→raw;
done with no objectUrl→raw; cross-stage isolation; no-stageId path;
non-placeholder src passes through (the additive contract).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(maic-editor): auto-save edits to stage store, drop staging UX
Reverses PR1's "staged edits don't write through to the live lesson"
design. The slide-edit-session now writes through every history move
(applyOp / user commit / ResizeObserver normalization / undo / redo)
to useStageStore.updateScene as the canonical source of truth, which
Dexie already auto-persists. The renderer reads from the stage store
via the controller's getSnapshot.
Removes the entire staging surface that has no place in a modern
editor (Figma/Notion/Google Docs have no "unsaved changes" concept):
- DEL lib/edit/slide-history-persistence.ts (localStorage layer)
- DEL tests/edit/slide-history-persistence.test.ts
- DEL components/edit/SlideHistoryRestorePrompt.tsx (restore dialog)
- DROP pendingRestore field + restore() action from slide-edit-session
- DROP restorePrompt branch + handlers from useSlideCanvasController
- DROP edit.history.restore.* keys across all 6 locales
Edits now flow: user input → renderer onUpdate → controller.updateSceneData
→ slide-edit-session.commitContent → writeThrough(useStageStore.updateScene)
→ Dexie. There is nothing "unsaved" to restore, by design.
The session retains its in-memory undo/redo history (per Pro session)
and the user-vs-ResizeObserver gesture classification (so reflow
doesn't push undo steps).
Test suite rewritten to assert write-through on every history move and
no write-through on seed (the stage already has that content).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): address PR review — element delete affordance + cross-platform fonts
Two issues from review on #586:
1. A selected image/text element couldn't be deleted — the renderer's
delete lives only in a right-click menu, undiscoverable in Pro mode.
Add a Delete button to the FloatingToolbar for any single selected
element (text or image), dispatching the existing element.delete op.
Button-only, consistent with #560's keyboard-shortcuts deferral.
2. Switching fonts had no effect on macOS Chrome — the property bar's
font list was a hardcoded SimSun/SimHei set (Windows-only system
fonts the renderer never loads). Use OpenMAIC's canonical FONTS
registry (configs/font.ts) — the web fonts the renderer actually
loads, so a pick renders identically on every platform.
Adds edit.delete × 6 locales + the parity-test key; floating-actions
unit tests for the delete action.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): selection-anchored text editing for the slide surface (#590)
* feat(maic-editor): add resolveEditingElementId text-editing policy
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): drop text-format floating action (moves to anchored bar)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): surface hooks to derive and sync editingElementId
Add useResolvedSlideContent / useEditingTextElementId / useSyncEditingElementId.
Realign the PR2 buildFloatingActions tests with the new behavior (text
formatting moved off the FloatingToolbar) and co-locate the editing-state test.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* chore(ui): export PopoverAnchor from the popover wrapper
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): add useTrackedRect for element screen-rect tracking
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): add AnchoredTextBar selection-anchored format bar
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): wire anchored text bar + editing flag into SlideCanvas
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): draw a clean solid frame for the text element being edited
Gated on the canvas store's editingElementId (default ""), so the dashed
select frame is unchanged for multi-select and for any consumer that never
sets the flag. Editor-path only; playback never renders Operate.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): drop the editor focus ring so text editing shows one frame
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* style(maic-editor): prettier-format the editing-state test import
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): anchor the bar to the text element node, not the wrapper
Code review caught that #editable-element-{id} is a zero-size absolute
wrapper — measuring it would pin the bar to the canvas origin. Measure the
.editable-element-text child, which carries the real geometry. Also correct
the dismiss-behavior comment: the bar is purely selection-driven.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): modernize the text format bar UI
Replace the native <select> font picker with the design-system Select,
rebuild the size control as one cohesive stepper pill, swap the color "A"
for a swatch chip, and unify every control to a single height and hover/
active language (violet accent, matching the editor's Pro-mode accent).
Behavior and the text commands are unchanged.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): curate the font picker to fonts the app actually loads
configs/font.ts listed 29 fonts but the app only ever loads Inter (via
next/font); the other 28 had no @font-face or bundled file, so picking them
silently fell back with no visible effect — and nothing but the format bar
even imports the registry. Trim it to what genuinely renders; the file's
comment records how to restore the rest (wire up font loading first).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): load the picker fonts via @fontsource
The font registry listed 29 fonts the app never loaded. Wire up a curated
set that genuinely renders — 思源黑/宋, 霞鹜文楷, 站酷快乐体, and 9 Latin
families — via @fontsource packages (npm-managed, no font binaries in the
repo; CJK faces are unicode-range-subsetted so they download lazily per
glyph range). app/editor-fonts.ts registers the @font-face CSS from the
root layout; configs/font.ts is now the real, honest 14-entry list.
The ~14 commercial decorative Chinese fonts are intentionally left out —
they need self-hosting + subsetting + a licensing review, separate work.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): quote font-family names so spaced/numeric ones work
Picking a font whose family name has spaces or a trailing digit (e.g.
"Source Sans 3") threw `Failed to execute 'check' on 'FontFaceSet'` —
`document.fonts.check(\`16px ${name}\`)` needs the family quoted — and the
fontname mark's toDOM emitted an invalid unquoted `font-family`, so the
font silently never applied. Quote the family in both spots; the mark's
parseDOM already strips quotes, so the attr still round-trips clean.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): make the editing frame pointer-events-none
The clean editing frame is a purely visual full-size overlay, but it was
pointer-events: auto — so it masked the text element's own move cursor,
text cursor, click-to-place-caret and drag-to-move; only a thin uncovered
sliver at the edges still triggered them. The dashed BorderLines it
replaced are thin edge lines, so they never had this problem. Mark the
frame pointer-events-none; the resize/rotate handles are separate and
keep their own pointer events.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* chore(maic-editor): drop the "font is loading" toast
With @fontsource fonts and font-display: swap, a picked font swaps in
smoothly on its own — the "Font is loading, please wait..." toast was
noise (and fired on most CJK picks while a unicode-range chunk loaded).
Remove it along with the now-unused document.fonts.check and toast import.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): move the delete action onto the anchored text bar
A text element's contextual actions now sit together on the anchored bar —
format controls + delete, hugging the element — instead of delete sitting
alone in the top-center FloatingToolbar. buildFloatingActions returns
nothing for text (its FloatingToolbar then renders null); non-text
elements still get their delete there. Delete logic is shared via a new
deleteSlideElement helper.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): anchor the delete action for image elements
A selected image element now gets a selection-anchored bar hugging it —
just a delete button (image replace/crop/flip stay in a later sub-PR) —
the same way text elements do. The anchoring shell is extracted out of
AnchoredTextBar into a reusable AnchoredBar, and the delete button into a
shared DeleteButton; AnchoredTextBar and the new AnchoredImageBar are thin
wrappers. useTrackedRect now measures .editable-element-text or
.editable-element-image. buildFloatingActions returns nothing for image
elements too (other element types still get their delete there).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* style(maic-editor): tighten the anchored bar padding (p-2 → p-1)
p-2 left a chunky white margin around the content — most visible on the
image bar, a lone delete button in an oversized box. p-1 (4px, the value
the FloatingToolbar used) makes both bars sit snug to their controls.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): anchor the delete bar for every element type
The selection-anchored delete bar now covers all non-text element types
(shape, line, table, chart, …), not just image — so every element's
editing chrome is anchored uniformly. AnchoredImageBar becomes the
type-agnostic AnchoredDeleteBar; useTrackedRect matches any
.editable-element-{type} content root; buildFloatingActions is dropped —
the surface no longer contributes top-center FloatingToolbar actions,
everything is on an anchored bar.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): show legacy font names in the picker trigger
When a text element's `fontname` was a value not in the curated FONTS
registry (e.g. `Microsoft YaHei`, `PingFang SC`, theme defaults), the
Select couldn't match it and `<SelectValue/>` rendered a blank trigger —
both reviewers (cosarah Important, xuyuanwei678 #1) caught this. Add a
placeholder fallback so the raw family name surfaces in the trigger.
Also clean up the dead `'默认字体'` label that `text-format-bar.tsx`
overrode unconditionally: introduce an optional `labelKey` field on
`FontEntry`, use it for the default entry, and let the picker prefer
the i18n key when present — no more by-value special case.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* chore(maic-editor): address cr minors
- `marks.ts` fontname `toDOM` rejects `"` or `\` instead of interpolating
them: a hand-crafted mark with `fontname: 'X"; background:url(...);'`
could otherwise close the quoted string and inject arbitrary CSS.
- `AnchoredBar` gains `onOpenChange` (clears the canvas selection on
Radix-initiated dismiss): silences the controlled-without-handler dev
warning, and brings back Esc / SR dismissal that our focus-outside
hardening had cut off.
- `useSyncEditingElementId` folds two `useLayoutEffect`s into one with
a cleanup; the previous unmount-only effect was structural noise.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix: pin body padding-right so popovers don't reflow the page
Radix Select / Popover wrap with `react-remove-scroll`, which adds a
compensation `padding-right` to <body> when they open. Our <html>
already reserves the scrollbar gutter (`scrollbar-gutter: stable` +
`overflow-y: scroll`), so the compensation added a visible ~15px shift
on every dropdown open. Pin body's padding-right with `!important` so
the page stays still. (xuyuanwei678 review #2.)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): surface legacy font names via SelectValue children
The earlier placeholder approach didn't work — Radix's `placeholder` only
fires for an empty `value`, not for an unmatched non-empty one. So an
element with a legacy fontname (e.g. `Microsoft YaHei`, `PingFang SC`,
theme defaults) outside the curated FONTS registry still rendered a blank
trigger. Render the trigger text via `SelectValue` children instead — the
new `currentFontLabel` helper covers all three cases: matched → entry's
i18n / fallback label, unmatched non-empty → the raw family name, empty
→ the default-font label. Unit tests cover each case.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): preventDefault on pointer-down-outside so drag/resize work
The onOpenChange handler added to silence the Radix dev warning + restore
Esc dismissal also fired on pointer-down-outside — i.e. on every mousedown
on the selected element to drag it or grab a resize handle. That cleared
the selection before the drag could start, so nothing on the canvas could
be moved or resized. preventDefault on `onPointerDownOutside` (matching
the existing `onFocusOutside` hardening) keeps the bar selection-driven
while leaving Esc as the legitimate onOpenChange path.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): arm-and-place insertion for text boxes
Replaces the "auto-insert at a hidden default position" UX. Click
`Text box` → arms text-insertion: the button takes the violet active
style, and the renderer's existing ElementCreateSelection overlay turns
the canvas cursor into a crosshair. On the canvas:
- click → 300×60 box at the click point
- drag → a box at the dragged rect
Either way the new box is auto-selected (addElement defaults that on),
and the surface's existing useEditingTextElementId picks it up so the
AnchoredTextBar opens on it. Esc disarms; clicking the armed button
again disarms (toggle).
Completes the text branch in the renderer's `useInsertFromCreateSelection`
(pptist scaffolding left it TODO) and bypasses the 200² square fallback
in `ElementCreateSelection` for the text type (a square wouldn't suit a
text box). `InsertPaletteItem` gains an `active?` field so `CommandBar`
can render the armed style.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): render list bullets in slide text
Tailwind's preflight resets `list-style` to none, so the format bar's
`bulletList` toggle wrapped selected text in `<ul><li>` but no marker
ever appeared — the button looked inert. Scope a list-style restoration
to `.editable-element-text ul/ol/li` so bullets / numbers render in the
slide text without leaking into the rest of the app.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): editable font-size input in the text format bar
The size was a read-only `<span>` between the −/+ steppers. Replace with
an `<input type=text>` that mirrors `attrs.fontsize` locally, commits on
Enter / blur (clamped to [8, 96]; non-numeric reverts), and reverts on
Escape. Adds the `edit.text.fontSize` aria-label key in all 6 locales.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): force list markers visible (defeat preflight specificity)
The earlier list CSS didn't survive Tailwind's preflight (which also
resets `padding: 0` on `<ul>`/`<ol>`, so with `list-style-position: outside`
the markers had no room to render). Add `!important` on `list-style` and
`padding-inline-start`, and broaden to also match `.prosemirror-editor ul`/
`ol`/`li` in case the markup ever nests differently than expected.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): reset richTextAttrs when the editing element changes
`richTextAttrs` is a single shared store updated by whichever ProseMirror
was last focused. Switching from one text element to another visibly
carried the previous element's toggle states (bold / italic / alignment /
list) on the format bar for a moment — until the new element's
ProseMirror took focus and repopulated the attrs. `useSyncEditingElementId`
now resets the attrs to defaults whenever the editing id changes, so the
bar shows a neutral state during the transition instead of stale.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): replace OS color dialog with a curated palette popover
Clicking the text-color swatch opened the browser's native `<input type=color>`
dialog — off-brand and inconsistent across platforms. Swap it for a
`ColorPicker` popover: a 12-swatch grid covering the common slide-text needs
(4 neutrals + warm + cool) plus a hex input for anything else. Closes on
pick. Selected swatch gets the violet outline; hex input commits on Enter /
blur (reverts if invalid).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): replace flat swatch popover with a real color picker
The previous popover was a chunky 12-swatch grid plus a hex input nobody
types into. Rebuild on `react-colorful` (3KB, well-tested):
- SV pad + hue slider for free-form picking, with scoped CSS overrides to
keep the picker tight (128px pad height) and rounded — not stock.
- OS eyedropper via the EyeDropper API, feature-detected (Chrome / Edge;
hidden on Safari / Firefox).
- Row of 10 small (18px) common colors at the foot for one-click reach.
- Current-color preview + read-only hex display.
- Hex input dropped entirely — picking is meant to be tactile.
Live preview while dragging; the popover closes on a swatch / eyedropper
commit (not on drag).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): keep the color popover open while dragging the picker
Each SV-pad / hue-slider drag tick fires onChange → dispatches the color
command → `editorView.focus()` pulls focus out of the popover into
ProseMirror. Radix's default onFocusOutside path was treating that as a
dismiss, so the popover closed the instant a drag started — clicking
anywhere on the picker shut it. preventDefault on `onFocusOutside`
(mirrors the AnchoredBar hardening) keeps it open; the popover still
closes on swatch / eyedropper commits and on outside-click / Esc.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): scope body padding override + gate ColorPicker mid-drag sync
Two follow-ups from a self-CR on the branch:
- `body { padding-right: 0 !important }` was global, overriding Radix's
`react-remove-scroll` compensation for every Dialog / Sheet / Select /
Popover across the app. Scope it to a `body[data-maic-editor='true']`
selector; `SlideCanvas` sets the attribute while mounted. Non-editor
pages get Radix's default behavior back.
- `ColorPicker`'s `useEffect(() => setColor(value), [value])` mirror
could race a stale `value` against the user's current pointer position
mid-drag — a single late round-trip would snap the picker back. Gate
the re-sync on `isDragging.current` (cleared on `pointerup`); external
commits (swatch / eyedropper) still sync immediately because they fire
while no drag is in flight.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* chore(maic-editor): polish from self-CR
- Gate the `richTextAttrs` reset in `useSyncEditingElementId` to only
fire on element-to-element transitions (track previous editing id via
a ref). The unconditional reset on the first selection briefly flashed
neutral defaults (color #000, fontsize 16px) before the focusing
ProseMirror repopulated the real values.
- Doc-comment the text-insertion add-element asymmetry: text uses the
renderer's `addElement` (because the rect math lives there and we get
auto-select for free), image uses surface-side `applyOp` (its source
is the ImagePicker, not a canvas gesture). Both commit through the
same store, but the text lane doesn't show as a typed `element.add`
op in the session history — acceptable, now explicit.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* chore(maic-editor): listen to every gesture-end channel in ColorPicker
CR round-2 residual nit: the single `pointerup` listener that clears the
drag-gate would silently keep the gate stuck on any browser / emulator
that only emits the older mouse/touch families. Listen on all four
(`mouseup`, `touchend`, `pointerup`, `pointercancel`) — belt-and-suspenders,
no behavior change on the common path.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): preserve image aspect ratio on insert
`createDefaultImageElement` hardcoded the new image's box to 360×220, so
anything not ~1.6:1 (which is almost everything users upload — photos,
screenshots, logos) ended up squashed or stretched the moment it landed
on the slide. Wrap the factory in `insertImageElement` that measures the
source via `new Image()`, then dispatches `element.add` with dimensions
scaled to fit MAX 600×400 while preserving the natural ratio. Load
failure falls back to the factory default so insertion always succeeds.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* chore(maic-editor): drop the now-dead addElement helper
`addElement` was only ever used by the inline image-insert which became
`insertImageElement`; text uses `armText` (toggle). PPTElement-typed
parameter was already unused after the text refactor — removing the dead
helper resolves the lint warning.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* chore(maic-editor): drop now-unused PPTElement import in use-slide-surface
After `addElement` was dropped (55a9a71), the `PPTElement` type import has
no remaining consumers in this file.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): nav rail, scene management, Pro mode chrome rework (#601)
* feat(maic-editor): slide nav rail + scene management (3/3)
PR3a Phase 1 ships the Pro mode left rail + slide-level management, the
last user-visible block of #562. Closes the gap where Pro mode locked
the user on the current scene with no way to navigate or manage the
deck.
SlideNavRail (Studio Editor aesthetic, mirrors playback `SceneSidebar`
visually — index badge + title above an aspect-video thumbnail card —
so the two sidebars read as the same component family across mode
toggle):
- Vertical thumbnail strip via `motion.dev` `Reorder.Group` with
drag-to-reorder. `Reorder.Item layout="position"` keeps the layout
animation on y-axis only; width changes from rail resize don't fight.
- Drag-to-resize handle on the right edge writes `style.width`
directly on the DOM during the gesture and commits to settings store
only on mouse-up; matches playback drag feel exactly and skips the
per-frame `persist` serialization that would otherwise burn the
frame budget at 60 Hz.
- Collapsed and expanded modes; width and collapsed flag persist in
`useSettingsStore` (`editRailWidth`, `editRailCollapsed`).
- All scene types are first-class — slides render a live
`ThumbnailSlide` (now with optional `size` prop → self-measures via
`ResizeObserver` when omitted, so the rail width is the single source
of truth), non-slide scenes render the same stylised mockups
playback `SceneSidebar` uses (extracted to `SceneThumbnailContent`).
Slide management:
- `+ Add` in the rail header inserts a blank slide after the current
scene; new store action `useStageStore.insertSceneAfter` validates
stage id, migrates the scene, splices, rebalances `order`, and
triggers `debouncedSave`.
- Three-dot menu per tile: Rename / Duplicate / Delete. Rename also
reachable via double-click on the title; Enter commits, Escape
cancels, blur commits, empty input reverts.
- Duplicate deep-clones slide content with fresh element IDs (avoid
React key collisions) and a `(copy)` title suffix.
- Delete uses a toast with Undo action; deleted scene is held in a
small `useDeletedSceneRecycle` zustand store and re-inserted at its
original index on Undo. Deck-empty guard at the rail layer.
- Inter-thumb `InsertionZone` reveals a violet `+` badge on hover,
right-anchored, with a popup motion (`cubic-bezier(0.34,1.56,0.64,1)`)
+ drop shadow + `z-20` so it lifts above the active tile's violet
ring. Zero layout shift.
Chrome bar:
- `HeaderControls` (settings pill + Pro Switch) extracted from
`Header` so Pro mode can mount it in the CommandBar's trailing slot
— single top chrome bar in Pro mode instead of stacking Header +
CommandBar.
- Back-to-home button in CommandBar mirrors the playback Header's
leftmost button.
i18n: new `edit.nav.*` namespace across en-US / zh-CN / zh-TW / ja-JP
/ ar-SA / ru-RU.
Tests: vitest for `insertSceneAfter`, `useDeletedSceneRecycle`,
`createBlankSlideScene` / `duplicateSlideScene`.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(maic-editor): split Stage chrome into mode-specific roots
Bug-driven architectural rework. Two symptoms motivated this:
1. Switching from a slide scene to a non-slide one (interactive / quiz
/ pbl) flickered the entire edit chrome — CommandBar and SlideNavRail
remounted along with the canvas. Root cause: EditShell returned a
different component type (EditShellWithSurface vs EditShellReadOnly)
based on whether a SceneEditorSurface was registered for the scene
type, so React reconciled the change as an unmount/remount of the
whole subtree.
2. `components/stage.tsx` had grown to 1391 lines — playback engine
state, chat / TTS / discussion wiring, presentation/fullscreen,
keyboard handling, AND the edit-mode dispatcher all in one place.
Any change to mode coordination meant touching this god component.
Changes:
- New `NOOP_SURFACE` (`lib/edit/noop-surface.tsx`) — a no-op
SceneEditorSurface used as a fallback when a scene type has no
registered editor surface. `SurfaceState.history` is now optional so
read-only surfaces can omit undo/redo cleanly. EditShell falls back
to NOOP for unregistered types.
- EditShell now mounts a single Frame across all scene types. Surface
state is published from a child `SurfaceStateRunner` keyed by
`scene.type` (so it remounts only when the runner's hook signature
changes — rules-of-hooks compliant), with a custom shallow
equality so the chrome doesn't re-render every render cycle for
reference-fresh state objects. Result: slide ↔ interactive no longer
remounts the CommandBar or the leftRail.
- `stage.tsx` → 113 lines. Mode dispatch + cross-tab edit-lock
coordination + Pro-Switch toggle wiring + multi-tab conflict prompt
only. Everything else moved into one of two new components:
- `PlaybackChromeRoot` (`components/edit/PlaybackChromeRoot.tsx`):
owns the entire playback / autonomous chrome — PlaybackEngine,
chat, discussion TTS, presentation mode, keyboard shortcuts,
SceneSidebar, Header, CanvasArea, Roundtable, ChatArea,
AlertDialog. Exposes `teardown()` via forwardRef so the toggle can
`await` SSE / engine / TTS shutdown before unmounting it.
- `EditChromeRoot` (`components/edit/EditChromeRoot.tsx`): the Pro
mode chrome wrapper — EditShell + SlideNavRail + HeaderControls
trailing slot. Owns `body[data-maic-editor]` lifecycle (lifted from
SlideCanvas so it covers read-only Pro-mode scene types too).
- New `StageGrid` (`components/edit/StageGrid.tsx`) — CSS-Grid named-
slot layout shell with top / left / center / right / bottom areas
for the Pro mode chrome. Future right panel (properties / AI) and
bottom timeline plug in as props with no structural code change.
EditShell's Frame now uses StageGrid internally.
- Deleted `components/edit/SlideTransitionBridge.tsx` (dead code from
the original A3 transition plan that this rework supersedes).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(maic-editor): cross-fade chrome roots on Pro mode toggle
Wrap the chrome-root dispatch in `AnimatePresence mode="wait"` with a
180 ms opacity fade-out / fade-in. The outgoing root fully exits before
the incoming one mounts, so:
- The single-canvasStore-writer guarantee from the chrome split is
preserved (ScreenCanvas and Editor/Canvas never coexist).
- Mode toggle reads as a smooth fade instead of a hard cut.
Stage's outer wrapper now carries the stable `bg-gray-50 dark:bg-gray-900`
background so neither root reveals raw page colour while it passes
through opacity 0. `initial={false}` skips the entry animation on first
mount so the initial playback render is instant.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): drawer-style mode swap transition
Pro toggle was a hard cut — playback chrome vanished, edit chrome
popped into place. Now wraps the swap in `AnimatePresence` with the
two chrome roots layered via `absolute inset-0` so they coexist for
~280ms:
- Edit chrome enters from above (`translateY: -32 → 0`) + fades in,
giving a "drawer drops down" feel that matches the inner
CommandBar/leftRail stagger choreography.
- Playback chrome cross-fades opacity-only; no transform so its
active slide canvas stays put underneath while edit drops over it.
Both roots keep rendering during the overlap, so `canvasStore`'s
scale writer doesn't briefly read zero and snap the slide to a stale
size when one root exits ahead of the other. Duration 280ms /
`CHROME_EASE` matches the inner Frame timing source.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): Pro Switch as a shared layout element across modes
The Pro Switch is the click anchor for the mode swap, but it lives in
two different positions: the 80px playback Header (top-right) vs the
56px edit CommandBar trailing slot (also top-right but at a different
y and with different padding). After the click the switch "jumped" —
it visibly moved + restyled — which felt unsmooth even though the
chrome itself was cross-fading.
Tag the Pro Switch label (and the settings pill) with `motion.layoutId`
so motion treats them as shared elements across the AnimatePresence
swap. During the ~280ms transition, motion measures both instances
and morphs position + size between them — the user's click target
slides into its new home instead of teleporting. Same easing source
as the chrome cross-fade so the two animations stay locked together.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(maic-editor): unify chrome shell across modes
Pro Switch + settings pill + download icon are the user's mode-toggle
"anchors" — they need to sit at the same screen pixel across
playback ↔ edit. They didn't, because the two chromes had different
shapes:
Playback: SceneSidebar (left, full height) | Header (h-20, 80px)
on top of CanvasArea + Roundtable
Edit: CommandBar (h-14, 56px, FULL width) on top of a row of
(SlideNavRail | content), so the rail sat *below* the bar
So when the user clicked Pro, the bar collapsed by 24px AND the rail
shifted down by 56px AND the right-side controls re-styled (compact
variant) — three simultaneous moves. layoutId masked some of it but
the underlying structure was wrong.
Unify the shells:
- `StageGrid` template flipped from `top top top / left center right /
bottom bottom bottom` to `left top top / left center right / left
bottom bottom`. The left column now spans all rows so the sidebar
always reaches the absolute top edge, matching playback exactly.
- `CommandBar` grows h-14 → h-20 + px-5 → px-8, identical to playback
Header.
- `EditChromeRoot` drops the `variant="compact"` flag on
`HeaderControls` so the settings pill renders at the same h-9 pill
it does in playback.
- `SlideNavRail` header replaces the "SCENES" label with the OpenMAIC
logo (click → home), matching `SceneSidebar`'s shape so the sidebar
top reads as the same component family in both modes.
- Download / Export dropdown moves out of `Header` and into
`HeaderControls` so it's present in both playback and edit chrome at
the same right-cluster position (was previously playback-only).
`Header.tsx` slimmed accordingly. Net effect: the right-edge cluster
(EN, theme, settings, download, Pro Switch) lives at the same screen
pixel across modes; the cross-fade transition only animates the
*contents* inside the bars + sidebar lists, not the bar/rail
positions themselves.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): drop sidebar header + button, add insert-before-first zone
The header `+` was a duplicate affordance — every gap between thumbs
already has its own `InsertionZone`. Remove the header button; insert
flows entirely through the gap zones now (with hover-popup + and
right-anchored visual).
Add one extra `InsertionZone` rendered BEFORE the first thumb so the
top padding of the rail is also clickable / hoverable. Insert-before-
first is implemented inline via `setScenes([blank, ...scenes])`
because the `insertSceneAfter` store API only handles insertion after
an existing anchor.
`PlusCircle` import dropped (no longer used).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): move Download out of settings pill, place right of Pro Switch
Download isn't a settings function (it's an export/share action), so
it shouldn't sit inside the pill that hosts language/theme/settings.
Move it back to a standalone button on the right side of the Pro
Switch — both in playback and edit chrome. Right cluster now reads:
[ EN · theme · settings ] [ PRO switch ] [ Download ]
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): floating insert toolbar above canvas (collapsible)
Text box / Image / future shape buttons no longer share CommandBar
with global stage controls (back / undo / redo / title / settings /
Pro Switch / Download). Insert is a content-creation action, not a
stage-navigation one — mixing them blurred the chrome's role.
Lift insert items into a new `FloatingInsertToolbar` that floats
centered ~12px above the slide canvas card. Default expanded; collapse
arrow tucks it into a small chevron handle at the same anchor. State
persists in `settings.editInsertToolbarCollapsed`. Reuses the existing
`InsertButton` (extracted from CommandBar into a sibling module so
both surfaces — the now-removed CommandBar slot and the floating bar —
can share styling).
CommandBar drops its `insertItems` prop / middle slot entirely;
right-side controls collapse to a single `flex shrink-0` cluster
matching playback Header's shape.
i18n: `edit.insert.expandToolbar` / `collapseToolbar` across 6 locales.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): auto-focus text element after toolbar insert
Inserting a Text box via the FloatingInsertToolbar + click/drag on
the canvas left the user one click short — the new element was
selected and the AnchoredTextBar opened, but the ProseMirror editor
never received focus, so the first keystroke went nowhere and the user
had to click inside the element again before typing.
`useEditingTextElementId` already mirrors the surface's editing-target
choice into `canvasStore.editingElementId`. Have `ProsemirrorEditor`
watch that flag in an effect: whenever its own elementId becomes the
editing target (insert, programmatic selection, etc.) and it doesn't
already have focus, push focus into the view. `hasFocus()` guard keeps
this from re-focusing on every re-render of an already-active editor.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* chore(maic-editor): prettier + drop ThumbItem rename sync effect
- prettier --write on three files touched by the recent edits.
- ThumbItem: drop the `useEffect(() => { if (!renaming) setDraft(...) })`
external-title sync that tripped `react-hooks/set-state-in-effect`.
Idle display now reads from `scene.title` directly (derived rather
than mirrored); `startRename` seeds `draft` at session start and
`cancelRename` resets it so the next session starts clean. Rename
e2e still passes the menu + double-click + Escape paths.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): CR-loop pass — pointer capture, stage-scoped recycle, equality docs
PR #601 reviewer feedback.
**Drag handle uses Pointer Events with `setPointerCapture`** so the rail
no longer gets stuck in "still dragging" state when the cursor leaves
the window, the OS reclaims focus, or a tab interrupt suppresses the
mouseup that the old document-bound mousemove/mouseup pair relied on.
The handle's onPointerMove/Up/Cancel are now bound directly on the
element; capture guarantees event delivery for the lifetime of the
gesture. Drag tracking e2e still PASS (1 px cursor lock).
**Toast Undo guards stage identity** before re-inserting the deleted
scene. If the user navigated to a different stage while the toast was
up, the recycle entry belongs to the previous stage and
`insertSceneAfter` would reject it on stage-id mismatch — silently
losing the deleted scene. New check drops the undo cleanly when stage
ids don't match. The `stageId` field was already captured on
RecycleEntry; just wasn't consulted.
**`surfaceStateEqual` extended** to compare per-item `id` / `disabled`
/ `label` on `floatingActions` (was length-only) and per-item
`id`/`severity`/`message` on `hints` (was length-only). Today's slide
surface returns `floatingActions: []` and `hints: []` so this is
dormant, but PR3b's z-order actions land in `floatingActions` — pinning
the equality semantics now keeps a future state field from silently
going stale in the chrome. SurfaceState gets a maintenance note
cross-linking to the equality function.
**Header.tsx mode guard comment** updated. The `mode !== 'edit'` guard
around the title block isn't dead — it covers the ~280ms
AnimatePresence exit window where playback chrome is still rendering
its exit animation while mode has flipped to 'edit'. Without the
guard, this title would briefly stack on top of the incoming
EditChromeRoot's CommandBar title during the cross-fade.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* docs(maic-editor): CR-loop round 2 minors — sharpen JSDocs
Round-2 reviewer flagged two doc-only refinements:
- `surfaceStateEqual`: clarify that callback identity (`onInvoke`,
`popoverContent`) is intentionally NOT compared, and that today's
safety comes from slide-surface returning `floatingActions: []`
rather than the per-item compare covering callbacks. A future
surface that emits closure-capturing actions must fold its own
change signal into the comparison or the stale callback fires at
click time.
- `setPointerCapture` catch: spell out that this is paranoia, not a
real fallback — if capture genuinely fails the gesture still
tracks for in-window moves but out-of-window `pointerup` won't
route here. Acceptable degradation; the catch exists only because
the spec permits an `InvalidPointerId` throw that browsers we ship
to don't actually emit on same-pointer `pointerdown`.
No functional changes.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(maic-editor): undo restore at index 0, reset mode on classroom load
Two issues from PR #601 manual-verification review:
**Undo of the first slide restored it as the second.** The toast undo
handler clamps `entry.index - 1` to 0 then calls
`insertSceneAfter(scenes[0], entry.scene)`, which lands the entry at
position 1 instead of position 0 — no scene exists before scenes[0] to
anchor on. Fall back to `setScenes([entry.scene, ...live])` when
`entry.index === 0` (or when the deck is empty). The store's existing
non-rebalancing `deleteScene` keeps the surviving scenes at orders
2..N, so the prepended entry's original order=1 lines up naturally;
StageGrid auto-selects the restored scene as current.
**`mode` survived SPA navigation between classrooms.** Refresh reset
mode to 'playback' via the initial store value, but switching
classrooms via Next.js navigation kept the zustand singleton intact;
entering Pro mode in A and then opening B left B in edit mode.
`loadFromStorage` and the server-side classroom-load path both now set
`mode: 'playback'` on every classroom load, normalising the SPA path
to match the refresh path. Mode stays transient UI state, not
persisted with the stage.
e2e: delete Slide 1 → Undo → restored to position 1 (was position 2
before fix).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
* feat(maic-editor): gate slide scene creation until inserted scenes are playable (#612)
* feat(maic-editor): gate slide scene creation until inserted scenes are playable
Editor-created slide scenes (blank insert + duplicate) ship without
playback actions, so the playback engine gives them zero dwell and skips
straight past them — a freshly inserted slide is effectively unplayable.
Seeding default actions on new scenes is a separate change; until then,
hide the two scene-creation entry points so the editor stays coherent as
an in-place "fine-tune the generated deck" tool.
- add lib/edit/scene-creation-enabled.ts (SCENE_CREATION_ENABLED=false)
- hide inter-thumb "+" insertion zones (SlideNavRail)
- hide per-slide Duplicate menu item (ThumbItem)
- keep reorder / delete / rename, which are playback-safe
Re-enable by flipping the flag once new scenes get default actions.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* test(maic-editor): e2e guard for slide scene-creation gate
Adds an e2e that generates a classroom (mocked), enters Pro mode, and
asserts the slide rail exposes no insertion "+" zones and the per-slide
overflow menu has only Rename + Delete (no Duplicate). Fails if
SCENE_CREATION_ENABLED is flipped back on without removing the gate.
Two stable test ids support locale-independent assertions:
- slide-nav-insert (InsertionZone button)
- slide-nav-more (ThumbItem overflow trigger)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* test(maic-editor): enable editor flag for the e2e webServer
The scene-creation gate e2e needs the Pro Switch, which only renders when
NEXT_PUBLIC_MAIC_EDITOR_ENABLED is on. It's a build-time NEXT_PUBLIC_* flag,
so set it in the Playwright webServer env (applies to `pnpm build` in CI and
`pnpm dev` locally). Fixes the e2e failure on CI.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* test(maic-editor): attach gate screenshot to report instead of fixed path
CR: e2e-artifacts/ is not gitignored, so writing the screenshot to a fixed
path left an untracked file that could be committed by accident. Use
testInfo.attach so the image lands in the (ignored) Playwright report.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
* i18n(maic-editor): add pt-BR translations for edit.* / stage.* keys
pt-BR locale (added on main post-stack) lacked the 51 editor keys, so
check:i18n-keys failed after rebase onto main.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(maic-editor): defer editor-only side effects behind Pro mode mount
editor-fonts (~23 @fontsource CSS tables) and slide-surface registration
were top-level static imports in app/layout.tsx and components/stage.tsx,
so flag-off classroom/playback users paid the font-face CSS + slide-edit
module-init cost on every page load.
Move both to a dynamic import in EditChromeRoot (mounts only when
mode==='edit', which requires NEXT_PUBLIC_MAIC_EDITOR_ENABLED). Hold the
EditShell render until the slide surface registers to avoid a NOOP/
read-only flash on first Pro mode paint.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(maic-editor): CR-loop correctness fixes (redo/groupId/edit-lock)
Three confirmed issues from the rebase code-review pass:
- slide-edit-session: a non-user (ResizeObserver auto-height) commit
updated history.present while preserving a now-stale future, so a
redo after undo silently resurrected pre-undo content. Clear future
on the non-user path (present has diverged from the redo branch);
past is left untouched so no spurious undo step is created.
- slide-defaults: duplicateSlideScene reassigned element ids inline,
leaving grouped elements pointing at the source slide's groupId.
Use the existing createElementIdMap so clones get a new shared
groupId. (Path is gated off today via SCENE_CREATION_ENABLED; fixes
a latent defect.)
- stage: wrap playback teardown on Pro-mode entry in try/catch and
release the just-acquired cross-tab lock on failure, so a rejected
teardown can't strand the lock with the UI stuck in playback.
Adds regression tests for the redo-stale and groupId cases.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(maic-editor): scope editor list-marker CSS to Pro mode
The .editable-element-text ul/ol/li rules used a bare selector, but
that class is the playback text wrapper rendered for every classroom
user — so the !important list-style overrides leaked into normal
playback. Scope them to body[data-maic-editor='true'] (set only while
Pro mode is mounted) so flag-off playback rendering stays unchanged;
markers still show while editing.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(maic-editor): smooth Pro mode transition and stabilize header controls
The Pro mode enter/exit animation janked and the right-side header
controls (settings pill + Pro Switch) drifted in width/position across
the swap. Three causes, all addressed:
- The flag-gating dynamic import gated EditShell behind surfaceReady, so
the chrome animated in empty and content popped in once the slide-surface
chunk loaded. Preload the editor chunk (fonts + surface registration) in
the Pro Switch handler BEFORE flipping mode (lib/edit/preload-editor.ts),
and drop the render gate — content is present when the animation starts.
- Mode-swap layers and EditShell chrome layers used translateY/translateX
slides; with backdrop-blur on the rail and pills that forced a per-frame
backdrop-filter recompute (dropped frames) and, as transform ancestors,
distorted the layoutId measurement. Switched all chrome enter animations
to pure opacity fades.
- HeaderControls rendered a fragment whose children were spaced by the
host's flex gap (Header gap-4 vs CommandBar trailing gap-2), so the
control cluster changed width/anchor between modes. Wrapped it in a
self-contained gap-4 container and dropped the cross-bar layoutId morph
so the cluster is pixel-stable across the swap.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(maic-editor): address review — image insert race, scene migration, i18n staleness
Review feedback from @cosarah on the integration PR:
- Image insert resolved size via Image.onload then applied the op to
whatever slide session was current at callback time, so switching
slides before the image loaded inserted it into the wrong slide. Bind
the insert to the scene active at click time and drop the op if the
session changed before onload fires.
- Classroom scenes loaded from IndexedDB (loadFromStorage) and from the
server API (classroom page) bypassed migrateScene, so legacy slide
content was not normalized with schemaVersion. Both load paths now
migrate on the way in, matching setScenes/addScene.
- surfaceStateEqual compared insert-item/command id/active/disabled but
not label/tooltip, so the Pro-mode insert toolbar text stayed stale
after a language switch. Compare label/tooltip too.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.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>
* Fix server API key fallback for provider base URLs
* Format verify PDF provider route
---------
Co-authored-by: wyuc <wang-yc24@mails.tsinghua.edu.cn>
* 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.