Skip to content

fix(vocational): send taskEngineMode on the on-demand scene generation path#716

Open
ly-wang19 wants to merge 1 commit into
THU-MAIC:mainfrom
ly-wang19:fix/vocational-scene-content-gate
Open

fix(vocational): send taskEngineMode on the on-demand scene generation path#716
ly-wang19 wants to merge 1 commit into
THU-MAIC:mainfrom
ly-wang19:fix/vocational-scene-content-gate

Conversation

@ly-wang19

Copy link
Copy Markdown
Contributor

Fixes #715.

Problem

The vocational task-engine gate is driven by requirements.taskEngineMode in the /api/generate/scene-content request body (resolveVocationalActiveapplyOutlineFallbacks({ allowProceduralSkill })). Only the first scene sends it (app/generation-preview/page.tsx). Scenes 2..N and retries are generated by useSceneGenerator.generateRemaining / fetchSceneContent, which never included requirements — so vocationalActive was false for them and applyOutlineFallbacks rewrote every procedural-skill outline to diagram. The outline says procedural-skill, the content path strips it; most scenes of a vocational course silently lose the task-engine widget. (Full trace in #715.)

Fix (minimal, client-side)

taskEngineMode is already persisted on the stage (lib/types/stage.ts, lib/utils/database.ts, written in stage-storage.ts), so this mirrors what scene 1 already does:

  • add taskEngineMode?: boolean to GenerationParams
  • populate it at the single generateRemaining(...) call site from stage.taskEngineMode
  • include requirements: { taskEngineMode: params.taskEngineMode === true } in both fetchSceneContent bodies

The retry path (retrySingleOutline) inherits it automatically — it reuses lastParamsRef.current. Server contract is unchanged; the flag is still ANDed with the OPENMAIC_ENABLE_VOCATIONAL env gate, so this is not a security/routing change — it only stops the client from dropping a flag it already sends for scene 1.

Note on approach

This is the smallest fix that restores parity with the first-scene path. If you'd prefer a server-authoritative shape instead — e.g. persisting taskEngineMode onto the outline so the content route doesn't depend on the client re-sending it — I'm happy to revise this PR that way; it's your feature and I'd rather match your intended design.

Verification

  • prettier clean, eslint clean, tsc --noEmit error count unchanged (only pre-existing unresolved @maic/* workspace-module errors; neither edited file appears).
  • No test added: the server gate this feeds is already covered by tests/generation/scene-content-route-vocational-gate.test.ts; the gap is purely the client hook's request body, and the repo has no React-hook (renderHook + fetch-mock + Zustand) harness to assert it without adding disproportionate test infra. Happy to add one if you'd like to introduce that harness.

The vocational gate keys off requirements.taskEngineMode in the
/api/generate/scene-content body, but only the first scene
(generation-preview) sent it. Scenes 2..N and retries run through
useSceneGenerator.generateRemaining / fetchSceneContent, which never
sent requirements, so resolveVocationalActive returned false and
applyOutlineFallbacks rewrote every later procedural-skill scene to
diagram — silently dropping the task-engine training mechanism for
most of a vocational course (the outline says procedural-skill while
the content path strips it).

Thread the persisted stage.taskEngineMode through GenerationParams into
both fetchSceneContent bodies (the retry path inherits it via
lastParamsRef), mirroring what the first-scene request already sends.
Server contract is unchanged; the flag is still ANDed with the
OPENMAIC_ENABLE_VOCATIONAL env gate server-side.

Closes THU-MAIC#715
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(vocational): scenes 2..N lose procedural-skill — taskEngineMode not sent on the on-demand generation path

1 participant