️ perf(native-window): 稳定结果同步回调避免全量序列化

This commit is contained in:
Syngnat
2026-07-22 08:54:24 +08:00
parent 92dd0cc650
commit 5424f22677
2 changed files with 123 additions and 18 deletions

View File

@@ -335,6 +335,16 @@ const NativeDetachedWindowApp: React.FC<NativeDetachedWindowAppProps> = ({
const hostEventSequenceRef = useRef(0);
const workbenchStateSourceRef = useRef<NativeDetachedStoreSnapshot>({});
const syncedWorkbenchTabIdsRef = useRef<Set<string>>(new Set());
const handleQueryResultDataChange = useCallback((rows: Array<Record<string, unknown>>) => {
const resultWindow = queryResultWindowRef.current;
if (!resultWindow) return;
queryResultWindowRef.current = {
...resultWindow,
result: { ...resultWindow.result, rows },
};
queryResultDirtyGenerationRef.current += 1;
scheduleSyncRef.current(false);
}, []);
const themeMode = useStore((state) => state.theme);
const uiVersion = useStore((state) => state.appearance.uiVersion);
@@ -1179,16 +1189,7 @@ const NativeDetachedWindowApp: React.FC<NativeDetachedWindowAppProps> = ({
aiTerminalGuardRef.current = guard;
}}
interactionDisabled={Boolean(terminalAction)}
onQueryResultDataChange={(rows) => {
const resultWindow = queryResultWindowRef.current;
if (!resultWindow) return;
queryResultWindowRef.current = {
...resultWindow,
result: { ...resultWindow.result, rows },
};
queryResultDirtyGenerationRef.current += 1;
scheduleSyncRef.current(false);
}}
onQueryResultDataChange={handleQueryResultDataChange}
/>
</React.Suspense>
) : null}