Skip to content

refactor: extraer el slice de galería y workspaces de useStore - #101

Merged
IAnMove merged 1 commit into
mainfrom
refactor/useStore-outputs-slice
Sep 2, 2026
Merged

refactor: extraer el slice de galería y workspaces de useStore#101
IAnMove merged 1 commit into
mainfrom
refactor/useStore-outputs-slice

Conversation

@IAnMove

@IAnMove IAnMove commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Objetivo

PR medio y cohesivo del slice de galería/workspaces. No mueve startGeneration.

  • Nuevo ui/src/stores/gallerySlice.ts: workspaces CRUD, vista Uploads, listado/filtro/búsqueda/refresh de outputs, metadata, favorito, borrar y rejoin de clips.
  • useStore sigue siendo la fachada pública y compone el slice con bindSlice (sin as never).
  • Los epochs y abort controllers de workspace/outputs/metadata se quedan juntos en el slice para que un cambio de workspace anule cargas en vuelo.
  • loadSettingsFromOutput, rerollGeneration, startGeneration y el overlay de almacenamiento siguen en useStore.
  • developerMode sigue saliendo de auditdev a través de la fachada (setMediaFilter('all')).

Verificación local

  • npx tsc -b --pretty false
  • npx eslint de los archivos tocados (--max-warnings=0)
  • npm test: 504 passed (incluye architectureSlices y workspaceOutputs)
  • python scripts/code_health.py --check: ratchet passed; funciones nuevas de gallerySlice ≤ 14 (tope de hotspot nuevo: 25)

Pendiente de CI. No mezclar hasta que los checks estén verdes.

No toca StoryLabPanel.tsx ni _launch_runtime.py.


Note

Medium Risk
Large state move touching gallery loading, workspace transitions, and selection/metadata sync; behavior is intended to be unchanged but regressions would affect core browsing UX.

Overview
Moves gallery and workspace state out of the monolithic useStore into a dedicated gallerySlice, composed with the same bindSlice pattern as other slices. useStore remains the public facade—call sites keep using useStore for workspaces, outputs, filters, metadata, favorites, delete, and rejoin.

The extracted slice keeps the existing epoch counters and AbortController wiring so workspace switches still cancel in-flight output/metadata loads. While moving code, filtering is refactored to a FILTER_PREDICATES map, API rows go through toOutputFile, and incremental refresh uses mergeRefreshedOutputs / clearedFeedState helpers. galleryWorkspaceName (and galleryWorkspaceEpoch) are exported for tests and cross-slice use.

loadSettingsFromOutput, rerollGeneration, startGeneration, and storage overlay logic stay in useStore. Architecture tests assert the gallery slice is isolated and that composition includes createGallerySlice without as never casts.

Reviewed by Cursor Bugbot for commit 95edcca. Configure here.

Move workspace CRUD, gallery list/filter/search/refresh, metadata,
favorite, delete and clip rejoin into gallerySlice. Keep the public
useStore facade, shared request epochs, and loadSettingsFromOutput
in the composer. Architecture tests cover bindSlice and client-side
filters.
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

PR Review — Loreframe Studio

Risk: medium
Scope: 3 file(s); +626/-544; React UI

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

Findings

  • medium — Very large file change (ui/src/stores/gallerySlice.ts)
    ui/src/stores/gallerySlice.ts adds 569 lines. Consider splitting the PR.
  • 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

  • added: ui/src/stores/gallerySlice.ts
  • modified: ui/src/stores/useStore.ts, ui/tests/architectureSlices.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.

@IAnMove

IAnMove commented Sep 2, 2026

Copy link
Copy Markdown
Owner Author

cursor review

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Code health

Metric Value
Production LOC 234,290
Production files 500
Test LOC 64,107
Functions measured 14,635
Functions complexity ≥ 15 777
Maximum complexity 667

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

Most complex functions

Complexity Where
667 app/wgp.py:7157 generate_video
374 ui/src/stores/useStore.ts:4426 Async method 'startGeneration'
356 app/_launch_runtime.py:23733 _run_generation
308 app/wgp.py:12274 generate_video_tab
272 ui/src/components/Sidebar/SceneAnimatorPanel.tsx:469 Function 'SceneAnimatorPanel'
266 ui/src/stores/useStore.ts:9164 Async method 'loadSettingsFromOutput'
258 app/services/director/planners/short_film.py:3433 ShortFilmPlanner._plan_story_driven
254 app/services/director_pipeline.py:13539 _run_video_generation
245 app/services/director_pipeline.py:7663 _run_pipeline
241 ui/src/features/agent/agentActions.ts:1077 Function 'parseAction'
227 ui/src/features/agent/agentActions.ts:2672 Async function 'executeAgentActions'
226 app/services/director_pipeline.py:6492 update_comic_preview

Trend vs baseline

Metric Δ
Production LOC +625
Test LOC +293
Functions ≥ 15 +3
Maximum complexity +0

Warnings

  • production LOC increased by +625
  • functions at complexity >= 15 increased by +3
  • complexity hotspot ui/src/stores/useStore.ts rose 373 -> 374
  • complexity hotspot app/services/model3d_service.py rose 51 -> 54
  • hotspot app/_launch_runtime.py increased by +66 lines
  • hotspot ui/src/features/agent/agentActions.ts increased by +3 lines
  • hotspot ui/src/types/index.ts increased by +3 lines
  • hotspot app/services/model3d_service.py increased by +58 lines
  • hotspot ui/src/features/agent/capabilityRegistry.ts increased by +2 lines
  • hotspot ui/src/features/agent/applicationAdapters.ts increased by +5 lines

Ratchet passed.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 95edcca. Configure here.

@IAnMove
IAnMove merged commit ac00b26 into main Sep 2, 2026
5 checks passed
@IAnMove
IAnMove deleted the refactor/useStore-outputs-slice branch September 5, 2026 11:53
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.

1 participant