refactor: extraer el slice LLM de useStore - #107
Merged
Conversation
Move Studio LLM status, models, load/unload, prompt enhance and H3 window prompt edits into llmSlice, composed with bindSlice. Callers still import useStore. startGeneration, stopGeneration and job reconnect stay in the facade.
PR Review — Loreframe StudioRisk: low Automated review from Findings
Changed files
CONTRIBUTING checklist
Posted by the repo PR review workflow. Re-runs on each push to the PR. |
Code health
Markdown, JSON catalogs and tests are out of this table. Only Most complex functions
Trend vs baseline
Warnings
Ratchet passed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contrato
PR medio y cohesivo del slice LLM del drawer de Studio. No mueve
startGeneration.Se mueve a
ui/src/stores/llmSlice.ts(fachada públicauseStoresin cambios de import):llmStatus,llmLoading,llmModels,isEnhancing,h3WindowPlanloadLlmStatus,loadLlmModels,loadLlm,unloadLlm,enhancePrompt,updateH3WindowPrompt,clearH3WindowPlanenhancePromptsí se mueve. No está inlined enstartGeneration; lee params/imágenes/ventanas del host y escribe el prompt (o el plan H3) sin llevarse el motor de generación.updateH3WindowPromptes del drawer y no llama a generate.Se queda en
useStore.ts:startGeneration,stopGeneration, reconnect de jobs/pipelinesUNLOADED_LLM_STATUSdel slice)llmStreamText/llmStreamDone(Director stream, no el drawer)llm_providerpara listar modelos)Composición:
bindSlice(set, get, createLlmSlice)sinas never.SliceCreatoradmite un host más ancho para que el drawer lea sibling config sin castear en el call site.Cómo probar
Local: tsc OK, eslint
--max-warnings=0OK,architectureSlices12/12,npm test506/506, H3 planner OK, architecture fixtures sin--write, code-health ratchet PASS. El inventario no cambia: el test de H3 sigue leyendouseStore.tsy ahora tambiénllmSlice.ts.Pendiente de CI. No mezclar hasta que los checks estén verdes. No aprobar este PR desde el mismo agente.
Generate
startGeneration/stopGeneration/ job reconnect siguen en useStore. El slice aislado no expone esas acciones.SLICE_QUEUE
No se edita
docs/development/SLICE_QUEUE.md(conflicto con PRs paralelos). Tras el merge, anotar en la cola: slice LLM del drawer extraído (llmSlice.ts); generate sigue en la fachada.No toca
_launch_runtime.py, WanGP,app/wgp.py,app/models/**, launchers niagentActions.ts.Note
Low Risk
Structural refactor with tests and no backend changes; behavior should match the moved
enhancePromptand LLM load/unload paths, with slightly higher coupling risk via the wider slice host typing.Overview
Moves Studio LLM drawer state and actions out of
useStore.tsinto a newllmSlice.ts, composed withbindSlice(set, get, createLlmSlice)so the publicuseStoreAPI stays the same.The slice owns
llmStatus, model loading,enhancePrompt, and H3 window plan editing (h3WindowPlan,updateH3WindowPrompt,clearH3WindowPlan).enhancePromptbehavior is unchanged in intent: it still gathers media, branches toplanH3Windowsfor multi-window H3 pacing, or callsllmEnhancePromptotherwise.startGeneration, job reconnect, and best-effort LLM unload before GPU work remain inuseStore, now resetting status via sharedUNLOADED_LLM_STATUS.storeApigains aSliceCreator<TSlice, THost>host type so the LLM slice can read/write sibling fields (params, images, sliding windows) withoutas never;bindSlicepasses the full storeset/getdirectly instead of wrapping them.Tests:
architectureSlices.test.mjsadds LLM isolation/facade coverage;test_h3_window_plannerincludesllmSlice.tswhen asserting UI/runtime H3 prompt wiring.Reviewed by Cursor Bugbot for commit 164146e. Configure here.