Skip to content

Commit a60a965

Browse files
committed
Revert "fix(native): guard diff prefetch results"
This reverts commit ee12094.
1 parent 5c70c7b commit a60a965

4 files changed

Lines changed: 8 additions & 166 deletions

File tree

apps/native/src/components/widget/summaries/full-file-diff-editor.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { DiffLineStatsBadge, sumDiffLineStats } from "./diff-line-stats";
1717
interface FullFileDiffEditorProps {
1818
filename: string;
1919
changes: ChangeWithRichType[];
20-
contents?: FileDiffContents | null;
20+
contents?: FileDiffContents;
2121
isOpen: boolean;
2222
onOpenChange: (open: boolean) => void;
2323
}
@@ -105,10 +105,6 @@ export function FullFileDiffEditor({ filename, changes, contents, isOpen, onOpen
105105
) : (
106106
<DiffView contents={displayContents} filename={filename} onMount={handleMount} />
107107
)
108-
) : contents === null ? (
109-
<div className="flex items-center justify-center py-8 text-muted-foreground text-xs">
110-
Unable to load diff contents.
111-
</div>
112108
) : (
113109
<div className="flex items-center justify-center py-8 text-muted-foreground text-xs">
114110
Loading...

apps/native/src/hooks/use-git-operations.test.ts

Lines changed: 0 additions & 100 deletions
This file was deleted.

apps/native/src/hooks/use-git-operations.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@ import { mirrorEvolveState } from "@/viewmodel/evolve";
66
import { mirrorGitState } from "@/viewmodel/git";
77
import { toast } from "sonner";
88

9-
let fileDiffContentsRequestId = 0;
10-
119
/**
1210
* Hook for git operations.
1311
* Provides functions for refreshing git status changes.
1412
*/
1513
export const prefetchFileDiffContents = async (status: { changes: { filename: string }[] } | null) => {
16-
const requestId = ++fileDiffContentsRequestId;
1714
const setFileDiffContents = useWidgetStore.getState().setFileDiffContents;
1815
if (!status) {
1916
setFileDiffContents({});
@@ -24,16 +21,11 @@ export const prefetchFileDiffContents = async (status: { changes: { filename: st
2421
setFileDiffContents({});
2522
return;
2623
}
27-
setFileDiffContents({});
2824
try {
2925
const result = await tauriAPI.git.fileDiffContents(filenames);
30-
if (requestId === fileDiffContentsRequestId) {
31-
setFileDiffContents(result ?? {});
32-
}
26+
setFileDiffContents(result ?? {});
3327
} catch {
34-
if (requestId === fileDiffContentsRequestId) {
35-
setFileDiffContents(Object.fromEntries(filenames.map((filename) => [filename, null])));
36-
}
28+
setFileDiffContents({});
3729
}
3830
};
3931

apps/native/src/stores/widget-store.impl.ts

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import { computeCurrentStep } from "@/components/widget/utils";
2+
import { useViewModel } from "@/stores/view-model";
23
import { FeedbackType } from "@/types/feedback";
34
import 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";
1512
import { create } from "zustand";
@@ -34,7 +31,6 @@ export type {
3431
export type SettingsTab = "general" | "api-keys" | "ai-models" | "preferences" | "tuning" | "developer";
3532
export type WidgetStep = "permissions" | "nix-setup" | "setup" | "begin" | "evolve" | "commit" | "manualEvolve" | "manualCommit" | "history" | "filesystem";
3633
type ProcessingAction = "evolve" | "apply" | "merge" | "cancel" | null;
37-
export type FileDiffContentEntry = FileDiffContents | null;
3834
export type ConfirmPrefKey = "confirmBuild" | "confirmClear" | "confirmRollback";
3935
export 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
*/
556509
export 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

Comments
 (0)