Skip to content

fix(wizard): no perder el checkpoint al cambiar de carpeta a mitad de un paso - #258

Merged
IAnMove merged 1 commit into
developmentfrom
cursor/critical-bug-management-9247
Sep 8, 2026
Merged

fix(wizard): no perder el checkpoint al cambiar de carpeta a mitad de un paso#258
IAnMove merged 1 commit into
developmentfrom
cursor/critical-bug-management-9247

Conversation

@cursor

@cursor cursor Bot commented Sep 8, 2026

Copy link
Copy Markdown

Resumen ejecutivo

Qué cambia

El runtime del Wizard ahora guarda el checkpoint de un paso en el workspace donde empezó, aunque el usuario cambie de carpeta de salida mientras execute() sigue en curso.

Para qué sirve

Un cambio de workspace a mitad de un paso asíncrono (por ejemplo, crear escena en un workflow rítmico 3D) dejaba el origen en running sin outputRefs y no escribía el resultado. Recargar mostraba el workflow interrumpido aunque el paso hubiera terminado.

Impacto para el usuario

Los workflows largos (rítmico 3D, videoclip) ya no pierden el progreso si se cambia de carpeta mientras un paso trabaja.

Riesgo

  • Bajo
  • Medio
  • Alto

Estado

  • En desarrollo
  • Listo para revisión
  • Bloqueado por CI o revisión
  • Requiere migración o acción manual

Summary

persist() already pinned the workspace at the start of a save so a CAS retry could not follow open(). That pin happened too late for the common case: advanceUnlocked() awaits step.execute(), the footer workspace changes (busy is already false after the original ask), open() replaces this.collection, and the later persist cloned the destination collection. The finished step mutated an orphaned source object that never reached disk.

The fix captures {workspace, collection, openSequence} before the execute loop and reuses that owner for every persist in the same advance. Destination stores stay untouched. Emit still no-ops after the live pointer moves, so the new chat does not receive the old workflow card.

Overview

  1. User starts a multi-step wizard workflow (e.g. rhythmic 3D).
  2. First step queues a task; the ask turn ends and busy becomes false.
  3. The task completes and the next step starts async I/O (create-scene, bake, export, …).
  4. User changes the output folder. shouldFollowWizardWorkspace allows the switch.
  5. open(destination) replaces the in-memory collection.
  6. The step finishes and now writes the source collection back to the source workspace.

Without this change, source stayed running and destination was unchanged. Reload asked to resume a step that had already succeeded.

Detailed changes

Backend

No backend changes.

UI and Wizard

  • WizardWorkflowRuntime.advanceUnlocked captures the persist owner before yielding to execute().
  • persist / persistAndEmit accept that owner so post-execute checkpoints and CAS retries stay on the source store.
  • Existing in-flight persist-during-open() coverage is unchanged.

Data, provenance and compatibility

Workspace isolation is stricter: a late persist cannot adopt the destination collection. No migration.

Files and ownership

  • ui/src/features/agent/wizardWorkflowRuntime.ts — pin persist owner across execute().
  • ui/tests/wizardWorkflowRuntime.test.mjs — gated second step + open() mid-execute.
  • Conversation persist, Story Lab merge, and lyrics language were left untouched.

Validation

  • python3 scripts/verify_clean_repo.py — PASS
  • python -m compileall -q app/services app/launch.py scripts — N/A (UI-only)
  • Focused Python tests: N/A (UI-only)
  • cd ui && npm run i18n:check — not required (no catalog changes)
  • UI tests: npx tsx --tsconfig tsconfig.app.json --import ./tests/setupI18n.ts --test tests/wizardWorkflowRuntime.test.mjs tests/wizardConversationPersistence.test.mjs tests/rhythmic3dWorkflow.test.mjs — 34/34 pass
  • npx eslint src/features/agent/wizardWorkflowRuntime.ts tests/wizardWorkflowRuntime.test.mjs --max-warnings=0 — pass
  • cd ui && npm run build — not run (logic-only runtime change)
  • git diff --check — clean
  • E2E/smoke checks: N/A (unit-reproduced persist race; no UI surface change)
  • Validation scope: fast

Code quality

  • Score: pending CI
  • Complexity trend: pending CI
  • Production LOC trend: pending CI
  • Regression versus main: pending CI
  • Ratchet: pending CI

CI and review

  • CI of this HEAD: pending
  • Cursor/Bugbot of this HEAD: pending
  • Independent agent review of this HEAD: pending
  • Human merge click (operational, not code review): pending

Coste de la tarea

  • Tests simulados: 0 tokens externos
  • Tests reales: N/A
  • Llamadas LLM externas: 0
  • Tokens de prompt: N/A
  • Tokens de respuesta: N/A
  • Tokens totales: N/A
  • Generaciones de imágenes/audio/vídeo: 0
  • Tiempo transcurrido: N/A
  • Proveedores/modelos: N/A

Notes and limitations

  • Reproduced with an in-memory persistence double; the race is the same as production saveWizardWorkflows.
  • Switching folders still moves the live event subscription. This PR only fixes the lost post-execute() checkpoint, not missed task events after the switch.
  • Distinct from the earlier conversation-transcript workspace-switch work (PR fix(wizard): no mezclar el chat al cambiar de workspace a mitad de turno #48 / later conversation pinning).

Follow-up work

  • Consider keeping task-event subscription pinned to in-flight workflow workspaces.
  • Story Lab last-write-wins merge can still drop a pending song row from another tab; not addressed here.

Checklist

  • The executive summary is understandable without reading the code.
  • The detailed Summary/Overview has not been removed or shortened.
  • Tests and their actual results are recorded.
  • Generated assets, secrets and local-only files are not committed.
  • Required CI and Cursor/Bugbot review are complete, or the PR is clearly marked as waiting for them.
Open in Web View Automation 

Note

Low Risk
UI-only wizard persistence logic with tighter workspace isolation; no auth or backend changes, covered by focused runtime tests.

Overview
Fixes a race where changing the output folder while a wizard step’s execute() is still running could drop the finished checkpoint: open() swapped this.collection, so a later persist cloned the destination store and never wrote the completed workflow back to the source workspace.

advanceUnlocked now captures a persist owner (workspace, collection, openSequence) before the step loop and passes it into every persistAndEmit for that advance. persist saves from that pinned collection, updates the owner’s revision on success/CAS merge, and only refreshes the live in-memory collection when the runtime still owns that open target—same idea as the existing in-flight persist during open(), extended across await execute() yields.

Adds a unit test that switches workspaces while the second step is blocked mid-execute and asserts the source workspace ends completed with merged outputRefs while the destination store stays unchanged.

Reviewed by Cursor Bugbot for commit c18ef4d. Configure here.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

PR Review — Loreframe Studio

Risk: low
Scope: 2 file(s); +98/-19; React UI

Automated review from scripts/analyze_pr.py. This is a heuristic pass (no LLM) so humans still own the merge decision.

Findings

  • low — UI changed — rebuild before merge
    Run cd ui && npm run build (CI already does this). Pinokio Update rebuilds for end users; keep ui/dist untracked.

Changed files

  • modified: ui/src/features/agent/wizardWorkflowRuntime.ts, ui/tests/wizardWorkflowRuntime.test.mjs

CONTRIBUTING checklist

  • python scripts/verify_clean_repo.py
  • python -m compileall -q app/services app/launch.py scripts
  • cd ui && npm run build if the UI changed
  • No weights, CivitAI sidecars, or generated guides
  • Stays local-first (no required accounts / telemetry)

Posted by the repo PR review workflow. Re-runs on each push to the PR.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Code health

Quality score: 55.5/100

Higher is better. The score is a trend dashboard; the independent ratchet below remains the CI gate.

Component Weight Current Change
Cyclomatic health 45% 54.7 +0.0
File concentration 25% 62.1 +0.0
Oversized-file debt 20% 38.0 +0.0
Modularity 10% 77.9 +0.0

Change vs PR base: +0.0 points.

Metric Value
Production LOC 266,931
Production files 741
Test LOC 96,549
Functions measured 17,420
Functions complexity ≥ 15 845
Maximum complexity 672
Policy code-health-policy-v1
HEAD a84567e3abd974cd50529d9e4d3839510da35d4c
Base 20729439779dd62c566c99013313d78f121198cc
UI measurement complete

Markdown, JSON catalogs and tests are out of this table. Only app/ runtime + ui/src TS/JS count.

Most complex functions

Complexity Where
672 app/wgp.py:7219 generate_video
381 ui/src/stores/useStore.ts:4084 Async method 'startGeneration'
355 app/_launch_runtime.py:23613 _run_generation
308 app/wgp.py:12359 generate_video_tab
268 ui/src/stores/useStore.ts:8636 Async method 'loadSettingsFromOutput'
260 ui/src/components/Sidebar/SceneAnimatorPanel.tsx:496 Function 'SceneAnimatorPanel'
258 app/services/director/planners/short_film.py:3433 ShortFilmPlanner._plan_story_driven
248 app/services/director_pipeline.py:13607 _run_video_generation
245 app/services/director_pipeline.py:7712 _run_pipeline
244 ui/src/features/agent/agentActions.ts:1145 Function 'parseAction'
226 app/services/director_pipeline.py:6541 update_comic_preview
225 ui/src/features/agent/agentActions.ts:2898 Async function 'executeAgentActions'

Trend vs baseline

Metric Δ
Production LOC +22
Test LOC +57
Functions ≥ 15 +0
Maximum complexity +0

Warnings

  • production LOC increased by +22

Ratchet passed.

@IAnMove
IAnMove changed the base branch from main to development September 8, 2026 20:22
@IAnMove
IAnMove marked this pull request as ready for review September 8, 2026 20:22
@cursor

cursor Bot commented Sep 8, 2026

Copy link
Copy Markdown
Author

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_df20f312-0d52-436e-b048-6c7fec1e02bc)

@IAnMove

IAnMove commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Revisión independiente (worktree aislado).

El fallo es real: persist() fijaba el workspace demasiado tarde, después de execute(). Un open() a mitad de paso dejaba el origen en running sin checkpoint. El pin de {workspace, collection, openSequence} antes del bucle es el arreglo correcto. Tests dirigidos 34/34.

Retargeteado de main a development (trabajo ordinario, no hotfix de publicación). El diff aplica limpio. Residuos no bloqueantes: el emit al volver a la carpeta origen a mitad de paso, y la suscripción de eventos de tarea que sigue al puntero vivo.

Ready for review; esperar CI required en development.

…en()

Pin the collection that still holds the running workflow before execute()
yields. Switching folders mid-step no longer drops the finished checkpoint
on the source workspace or writes it into the destination.

Co-authored-by: ignaciodelcano+dcl <ignaciodelcano+dcl@gmail.com>
@IAnMove
IAnMove force-pushed the cursor/critical-bug-management-9247 branch from 6426524 to c18ef4d Compare September 8, 2026 22:06
@cursor

cursor Bot commented Sep 8, 2026

Copy link
Copy Markdown
Author

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_6caa67d5-d411-4124-a14a-f829f0dbdc72)

@IAnMove

IAnMove commented Sep 8, 2026

Copy link
Copy Markdown
Owner

El score 49.9 no lo bajó este arreglo. Era el comentario de code-health cuando la base era main (541 archivos, 245k LOC). En development el dashboard anda ~55.4 (734 archivos, 266k LOC). Al retargetear sin rebase, CI no se relanzó y el comentario se quedó midiendo el árbol de main.

El parche real es +22 LOC de producción, +0 funciones ≥15, +0 complejidad máxima, ratchet OK. wizardWorkflowRuntime.ts pasa de 899 a 921 líneas (sigue bajo el umbral de 1.000).

He rebasado sobre origin/development actual (20729439, incluye #259 y #262) y he empujado c18ef4de. Tests dirigidos 34/34. El próximo CI debería publicar el score de development + este delta (~0.0), no el de main.

@IAnMove
IAnMove merged commit 5274ba0 into development Sep 8, 2026
11 checks passed
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.

2 participants