11import { computeCurrentStep } from "@/components/widget/utils" ;
2+ import { useViewModel } from "@/stores/view-model" ;
23import { FeedbackType } from "@/types/feedback" ;
34import type {
45 EvolutionTelemetry ,
56 EvolveEvent ,
6- EvolveState ,
77 FileDiffContents ,
8- GitStatus ,
9- HistoryItem ,
108 PermissionsState ,
119 RecommendedPrompt ,
12- SemanticChangeMap ,
1310 UpdateChannel ,
1411} from "@/ipc/types" ;
1512import { create } from "zustand" ;
@@ -34,7 +31,6 @@ export type {
3431export type SettingsTab = "general" | "api-keys" | "ai-models" | "preferences" | "tuning" | "developer" ;
3532export type WidgetStep = "permissions" | "nix-setup" | "setup" | "begin" | "evolve" | "commit" | "manualEvolve" | "manualCommit" | "history" | "filesystem" ;
3633type ProcessingAction = "evolve" | "apply" | "merge" | "cancel" | null ;
37- export type FileDiffContentEntry = FileDiffContents | null ;
3834export type ConfirmPrefKey = "confirmBuild" | "confirmClear" | "confirmRollback" ;
3935export type BoolPrefKey = ConfirmPrefKey | "autoSummarizeOnFocus" | "scanHomebrewOnStartup" | "defaultToDiffTab" ;
4036
@@ -90,13 +86,8 @@ export interface WidgetState {
9086 darwinRebuildAvailable : boolean | null ; // null = not checked yet
9187 darwinRebuildPrefetching : boolean ;
9288
93- // Evolve state derived from backend source of truth
94- evolveState : EvolveState | null ;
95- externalBuildDetected : boolean ;
89+ fileDiffContents : Record < string , FileDiffContents > ;
9690
97- // Git (from backend)
98- gitStatus : GitStatus | null ;
99- fileDiffContents : Record < string , FileDiffContentEntry > ;
10091 // Evolution
10192 evolvePrompt : string ;
10293 isProcessing : boolean ;
@@ -106,8 +97,6 @@ export interface WidgetState {
10697 conversationalResponse : string | null ;
10798 evolutionTelemetry : EvolutionTelemetry | null ;
10899
109- changeMap : SemanticChangeMap | null ;
110-
111100 // Commit message suggestion (generated on merge screen)
112101 commitMessageSuggestion : string | null ;
113102
@@ -117,13 +106,9 @@ export interface WidgetState {
117106 // Console
118107 consoleLogs : string ;
119108
120- // History
121- history : HistoryItem [ ] ;
122- historyLoading : boolean ;
123109 analyzingHistoryForHashes : Set < string > ;
124110
125111 // UI
126- summaryAvailable : boolean ;
127112 isSummarizing : boolean ;
128113 isGenerating : boolean ;
129114 settingsOpen : boolean ;
@@ -192,13 +177,9 @@ interface WidgetActions {
192177 setNixDownloadProgress : ( progress : { downloaded : number ; total : number } | null ) => void ;
193178 setDarwinRebuildAvailable : ( available : boolean | null ) => void ;
194179 setDarwinRebuildPrefetching : ( prefetching : boolean ) => void ;
195- setEvolveState : ( state : EvolveState | null ) => void ;
196- setExternalBuildDetected : ( detected : boolean ) => void ;
197- setGitStatus : ( status : GitStatus | null ) => void ;
198- setFileDiffContents : ( contents : Record < string , FileDiffContentEntry > ) => void ;
180+ setFileDiffContents : ( contents : Record < string , FileDiffContents > ) => void ;
199181 setEvolvePrompt : ( prompt : string ) => void ;
200182 setProcessing : ( isProcessing : boolean , action ?: ProcessingAction ) => void ;
201- setChangeMap : ( map : SemanticChangeMap | null ) => void ;
202183 setSettingsOpen : ( open : boolean , tab ?: SettingsTab | null ) => void ;
203184 setPrefsLoaded : ( loaded : boolean ) => void ;
204185 setShowHistory : ( show : boolean ) => void ;
@@ -213,12 +194,9 @@ interface WidgetActions {
213194 details : { message : string ; location ?: string ; backtrace ?: string ; timestamp : string } | null ,
214195 ) => void ;
215196 setPromptHistory : ( history : string [ ] ) => void ;
216- setSummaryAvailable : ( available : boolean ) => void ;
217197 setRecommendedPrompt : ( prompt : RecommendedPrompt | null | undefined ) => void ;
218198
219199 // History
220- setHistory : ( history : HistoryItem [ ] ) => void ;
221- setHistoryLoading : ( loading : boolean ) => void ;
222200 addAnalyzingHistoryHash : ( hash : string ) => void ;
223201 removeAnalyzingHistoryHash : ( hash : string ) => void ;
224202
@@ -237,7 +215,6 @@ interface WidgetActions {
237215 // Client-side state (NOT from server)
238216 setSummarizing : ( summarizing : boolean ) => void ;
239217 setGenerating : ( generating : boolean ) => void ;
240- clearPreview : ( ) => void ;
241218 setFeedbackTypeOverride : ( type : FeedbackType | null ) => void ;
242219 openFeedback : ( type ?: FeedbackType , initialText ?: string ) => void ;
243220
@@ -301,12 +278,6 @@ const initialWidgetState: WidgetState = {
301278 darwinRebuildAvailable : null ,
302279 darwinRebuildPrefetching : false ,
303280
304- // Routing state
305- evolveState : null ,
306- externalBuildDetected : false ,
307-
308- // Git
309- gitStatus : null ,
310281 fileDiffContents : { } ,
311282
312283 // Evolution
@@ -318,14 +289,8 @@ const initialWidgetState: WidgetState = {
318289 conversationalResponse : null ,
319290 evolutionTelemetry : null ,
320291
321- // History
322- history : [ ] ,
323- historyLoading : false ,
324292 analyzingHistoryForHashes : new Set < string > ( ) ,
325293
326- changeMap : null ,
327- summaryAvailable : false ,
328-
329294 // Commit message suggestion
330295 commitMessageSuggestion : null ,
331296
@@ -398,18 +363,13 @@ export function createWidgetStore(initialState?: Partial<WidgetState>) {
398363 setConfigDir : ( configDir ) => set ( { configDir } ) ,
399364 setHosts : ( hosts ) => set ( { hosts } ) ,
400365 setHost : ( host ) => set ( { host } ) ,
401- setEvolveState : ( evolveState ) => set ( { evolveState : evolveState } ) ,
402- setExternalBuildDetected : ( externalBuildDetected ) => set ( { externalBuildDetected } ) ,
403- setGitStatus : ( gitStatus ) => set ( { gitStatus } ) ,
404366 setFileDiffContents : ( fileDiffContents ) => set ( { fileDiffContents } ) ,
405367 setEvolvePrompt : ( evolvePrompt ) => set ( { evolvePrompt } ) ,
406368 setProcessing : ( isProcessing , action = null ) =>
407369 set ( {
408370 isProcessing,
409371 processingAction : isProcessing ? action : null ,
410372 } ) ,
411- setChangeMap : ( changeMap ) => set ( { changeMap } ) ,
412- setSummaryAvailable : ( summaryAvailable ) => set ( { summaryAvailable } ) ,
413373 setBoolPref : ( key : BoolPrefKey , value : boolean ) => set ( { [ key ] : value } ) ,
414374 initConfirmPrefs : ( prefs ) =>
415375 set ( {
@@ -421,8 +381,6 @@ export function createWidgetStore(initialState?: Partial<WidgetState>) {
421381 setDeveloperMode : ( value ) => set ( { developerMode : value } ) ,
422382 setPinnedVersion : ( value ) => set ( { pinnedVersion : value } ) ,
423383 setUpdateChannel : ( value ) => set ( { updateChannel : value } ) ,
424- setHistory : ( history ) => set ( { history } ) ,
425- setHistoryLoading : ( historyLoading ) => set ( { historyLoading } ) ,
426384 addAnalyzingHistoryHash : ( hash ) =>
427385 set ( ( state ) => ( {
428386 analyzingHistoryForHashes : new Set ( [ ...state . analyzingHistoryForHashes , hash ] ) ,
@@ -462,11 +420,6 @@ export function createWidgetStore(initialState?: Partial<WidgetState>) {
462420 setDarwinRebuildPrefetching : ( darwinRebuildPrefetching ) => set ( { darwinRebuildPrefetching } ) ,
463421 setSummarizing : ( isSummarizing ) => set ( { isSummarizing } ) ,
464422 setGenerating : ( isGenerating ) => set ( { isGenerating } ) ,
465- clearPreview : ( ) =>
466- set ( {
467- changeMap : null ,
468- summaryAvailable : false ,
469- } ) ,
470423
471424 // Console
472425 appendLog : ( text ) => set ( ( state ) => ( { consoleLogs : state . consoleLogs + text } ) ) ,
@@ -554,5 +507,6 @@ export const useWidgetStore = createWidgetStore();
554507 * Uses a selector so components only re-render when the step actually changes.
555508 */
556509export function useCurrentStep ( ) : WidgetStep {
557- return useWidgetStore ( ( state ) => computeCurrentStep ( state ) ) ;
510+ const evolveState = useViewModel ( ( state ) => state . evolve ) ;
511+ return useWidgetStore ( ( state ) => computeCurrentStep ( { ...state , evolveState } ) ) ;
558512}
0 commit comments