a very good jj gui
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Sprint 3: Remove commented-out lineage/dimming code (~177 LOC)

Remove all disabled lineage/dimming calculations from 3 frontend files:
- db.ts: removed LineageRecord interface, commented collection, disabled invalidation
- useRevisionData.ts: removed createLineageLoader, lineageLoaders cache, getLineageLoader
- revision-graph/index.tsx: removed all DISABLED comments and commented-out lineage blocks

Backend lineage commands (tauri-commands.ts) kept for potential re-enablement.
Stub functions (useLineage, prefetchLineage, flushLineage) retained as clean no-ops.

+4 -177
+1 -34
apps/desktop/src/components/revision-graph/index.tsx
··· 2 2 import { useNavigate, useSearch } from "@tanstack/react-router"; 3 3 import { useVirtualizer } from "@tanstack/react-virtual"; 4 4 import type { RefObject } from "react"; 5 - import { 6 - forwardRef, 7 - useCallback, 8 - // DISABLED: useDeferredValue removed (lineage/dimming disabled) 9 - useEffect, 10 - useImperativeHandle, 11 - useMemo, 12 - useRef, 13 - } from "react"; 5 + import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from "react"; 14 6 import { Route } from "@/routes/project.$projectId"; 15 7 import { traceEnd, traceLog, traceStart } from "@/lib/trace"; 16 8 import { ··· 28 20 } from "@/components/revision-graph-utils"; 29 21 import { getRevisionKey } from "@/db"; 30 22 import { useFocusWithin } from "@/hooks/useFocusWithin"; 31 - // DISABLED: useLineage removed (lineage/dimming disabled) 32 23 import { usePrefetch } from "@/hooks/useRevisionData"; 33 24 import { useKeyboardShortcut } from "@/hooks/useKeyboard"; 34 25 import { useRevisionGraphNavigation } from "@/hooks/useRevisionGraphNavigation"; ··· 384 375 const stacks = useMemo(() => detectStacks(stableRevisions), [stableRevisions]); 385 376 386 377 // Setup prefetch hooks for visible revision data 387 - // DISABLED: prefetchLineage removed (lineage/dimming disabled) 388 378 const { prefetchDiffs, prefetchChanges, flushDiffs, flushChanges } = usePrefetch( 389 379 repoPath ?? "", 390 380 ); ··· 556 546 const revisionMapByKey = new Map(stableRevisions.map((r) => [getRevisionKey(r), r])); 557 547 const revisionMapByCommitId = new Map(stableRevisions.map((r) => [r.commit_id, r])); 558 548 559 - // DISABLED: Lineage/dimming calculations commented out 560 - // const deferredSelectedChangeId = useDeferredValue(selectedRevision?.change_id ?? null); 561 - // const focusedStack = focusedStackId ? stackById.get(focusedStackId) : null; 562 - // const topLineageChangeId = focusedStack ? focusedStack.topChangeId : null; 563 - // const bottomLineageChangeId = focusedStack ? focusedStack.bottomChangeId : null; 564 - // const primaryLineageChangeId = focusedStack ? null : deferredSelectedChangeId; 565 - // const { lineage: topLineage, isLoaded: topLoaded } = useLineage(repoPath ?? "", topLineageChangeId); 566 - // const { lineage: bottomLineage, isLoaded: bottomLoaded } = useLineage(repoPath ?? "", bottomLineageChangeId); 567 - // const { lineage: primaryLineage, isLoaded: primaryLoaded } = useLineage(repoPath ?? "", primaryLineageChangeId); 568 - // const lineageIsLoading = focusedStack ? !topLoaded || !bottomLoaded : deferredSelectedChangeId && !primaryLoaded; 569 - // DISABLED: Lineage/dimming completely removed 570 - // const relatedRevisions = useMemo(() => { ... }, [...]); 571 - 572 549 // Build revision key -> displayRow index map for scrolling and edge positioning 573 550 // IMPORTANT: Use displayRows indices (not rows) to match virtualizer positioning 574 551 // Uses getRevisionKey() to handle divergent revisions (same change_id, different divergent_index) ··· 955 932 const uniqueIds = [...new Set(changeIds)].slice(0, 50); 956 933 prefetchDiffs(uniqueIds); 957 934 prefetchChanges(uniqueIds); 958 - 959 - // DISABLED: Lineage prefetch removed (lineage/dimming disabled) 960 - // if (selectedRevision) { 961 - // prefetchLineage([selectedRevision.change_id]); 962 - // } 963 935 }, 200); 964 936 965 937 // Cleanup on unmount or when deps change ··· 1213 1185 const nodeAreaWidth = LANE_PADDING + (lane + 1) * LANE_WIDTH; 1214 1186 const count = stack.intermediateChangeIds.length; 1215 1187 1216 - // DISABLED: Dimming disabled (lineage calculations removed) 1217 - // const isStackRelated = relatedRevisions === null || stack.changeIds.some((id) => relatedRevisions.has(id)); 1218 - // const isStackDimmed = selectedRevision !== null && !isStackRelated; 1219 1188 const isStackDimmed = false; 1220 1189 const isStackFocused = focusedStackId === stack.id; 1221 1190 ··· 1291 1260 const { row } = displayRow; 1292 1261 const lane = changeIdToLane.get(row.revision.change_id) ?? 0; 1293 1262 const isFlashing = flash?.changeId === row.revision.change_id; 1294 - // DISABLED: Dimming disabled (lineage calculations removed) 1295 - // const isDimmed = relatedRevisions !== null && (selectedRevision !== null || focusedStackId !== null) && !relatedRevisions.has(row.revision.change_id); 1296 1263 const isDimmed = false; 1297 1264 // Only show focus if no stack is focused 1298 1265 const isFocused =
-36
apps/desktop/src/db.ts
··· 146 146 await queryClient.invalidateQueries({ queryKey: ["commit-recency", repoPath] }); 147 147 await queryClient.invalidateQueries({ queryKey: ["status", repoPath] }); 148 148 await queryClient.invalidateQueries({ queryKey: ["conflict-paths", repoPath] }); 149 - // DISABLED: Lineage calculations commented out 150 - // await queryClient.invalidateQueries({ queryKey: ["lineage"] }); 151 149 } 152 150 }); 153 151 ··· 900 898 }); 901 899 902 900 export type ChangesCollection = typeof changesCollection; 903 - 904 - // ============================================================================ 905 - // Unified Lineage Collection (single collection for all revision lineage data) 906 - // DISABLED: Lineage calculations commented out 907 - // ============================================================================ 908 - 909 - /** 910 - * Unified lineage record - stores related revision IDs keyed by repoPath:changeId. 911 - * Used for highlighting related revisions in the graph. 912 - */ 913 - export interface LineageRecord { 914 - repoPath: string; 915 - changeId: string; 916 - relatedIds: string[]; 917 - } 918 - 919 - // DISABLED: Lineage calculations commented out 920 - // function getLineageRecordKey(l: LineageRecord): string { 921 - // return `${l.repoPath}:${l.changeId}`; 922 - // } 923 - // 924 - // const lineageQueryKey = ["lineage"] as const; 925 - // 926 - // export const lineageCollection = createCollection({ 927 - // ...queryCollectionOptions({ 928 - // queryClient, 929 - // queryKey: lineageQueryKey, 930 - // queryFn: async () => [] as LineageRecord[], 931 - // getKey: getLineageRecordKey, 932 - // }), 933 - // startSync: true, 934 - // }); 935 - // 936 - // export type LineageCollection = typeof lineageCollection;
+3 -107
apps/desktop/src/hooks/useRevisionData.ts
··· 7 7 8 8 import { and, eq, useLiveQuery, useLiveSuspenseQuery } from "@tanstack/react-db"; 9 9 import { useMemo, useRef } from "react"; 10 - import { 11 - type ChangeRecord, 12 - changesCollection, 13 - type DiffRecord, 14 - diffsCollection, 15 - // DISABLED: Lineage calculations commented out 16 - // type LineageRecord, 17 - // lineageCollection, 18 - } from "@/db"; 10 + import { type ChangeRecord, changesCollection, type DiffRecord, diffsCollection } from "@/db"; 19 11 import { type BatchLoader, createBatchLoader } from "@/lib/batch-loader"; 20 12 import { traceLog } from "@/lib/trace"; 21 13 import { 22 14 getChangesBatchEffect, 23 15 getDiffsBatchEffect, 24 - // DISABLED: Lineage calculations commented out 25 - // getLineageBatchEffect, 26 - // type LineageResult, 27 16 type RevisionChanges, 28 17 type RevisionDiff, 29 18 } from "@/tauri-commands"; ··· 121 110 }, 122 111 }); 123 112 } 124 - 125 - // DISABLED: Lineage calculations commented out 126 - // /** 127 - // * Creates a BatchLoader for revision lineage. 128 - // * The loader batches IPC calls and syncs results to the unified lineageCollection. 129 - // */ 130 - // function createLineageLoader(repoPath: string): BatchLoader { 131 - // return createBatchLoader<LineageResult>({ 132 - // debounceMs: 50, 133 - // maxBatchSize: 20, 134 - // fetchBatch: (ids) => getLineageBatchEffect(repoPath, ids), 135 - // syncToCollection: (results) => { 136 - // // Wait for collection to be ready before writing 137 - // if (lineageCollection.status !== "ready") return; 138 - // const records: LineageRecord[] = results.map((r) => ({ 139 - // repoPath, 140 - // changeId: r.change_id, 141 - // relatedIds: r.related_ids, 142 - // })); 143 - // lineageCollection.utils.writeUpsert(records); 144 - // 145 - // // LRU eviction: keep only last 50 lineage records per repo 146 - // const MAX_LINEAGE = 50; 147 - // const allRecords = Array.from(lineageCollection.state.values()).filter( 148 - // (r) => r.repoPath === repoPath, 149 - // ); 150 - // if (allRecords.length > MAX_LINEAGE) { 151 - // // Remove oldest entries (first ones in the Map iteration order) 152 - // const toRemove = allRecords.slice(0, allRecords.length - MAX_LINEAGE); 153 - // for (const record of toRemove) { 154 - // const key = `${record.repoPath}:${record.changeId}`; 155 - // lineageCollection.state.delete(key); 156 - // } 157 - // } 158 - // }, 159 - // isLoaded: (id) => { 160 - // if (lineageCollection.status !== "ready") return false; 161 - // const key = `${repoPath}:${id}`; 162 - // return lineageCollection.state.has(key); 163 - // }, 164 - // }); 165 - // } 166 113 167 114 // ============================================================================ 168 115 // Loader Instance Cache ··· 171 118 // Cache loaders per repoPath to avoid creating multiple instances 172 119 const diffLoaders = new Map<string, BatchLoader>(); 173 120 const changesLoaders = new Map<string, BatchLoader>(); 174 - // DISABLED: Lineage calculations commented out 175 - // const lineageLoaders = new Map<string, BatchLoader>(); 176 121 177 122 /** 178 123 * Clean up loaders for repos we're no longer viewing. ··· 189 134 changesLoaders.delete(path); 190 135 } 191 136 } 192 - // DISABLED: Lineage calculations commented out 193 - // for (const [path] of lineageLoaders) { 194 - // if (path !== currentRepoPath) { 195 - // lineageLoaders.delete(path); 196 - // } 197 - // } 198 137 } 199 138 200 139 function getDiffLoader(repoPath: string): BatchLoader { ··· 214 153 } 215 154 return loader; 216 155 } 217 - 218 - // DISABLED: Lineage calculations commented out 219 - // function getLineageLoader(repoPath: string): BatchLoader { 220 - // let loader = lineageLoaders.get(repoPath); 221 - // if (!loader) { 222 - // loader = createLineageLoader(repoPath); 223 - // lineageLoaders.set(repoPath, loader); 224 - // } 225 - // return loader; 226 - // } 227 156 228 157 // ============================================================================ 229 158 // React Hooks ··· 335 264 * Read lineage (related revision IDs) for a revision from local DB. 336 265 * Returns { lineage, isLoaded } to allow callers to handle loading state. 337 266 * 338 - * DISABLED: Lineage calculations commented out - always returns empty/loaded. 267 + * Stub: lineage calculations disabled - always returns empty/loaded. 339 268 */ 340 269 export function useLineage( 341 270 _repoPath: string, 342 271 _changeId: string | null, 343 272 ): { lineage: Set<string>; isLoaded: boolean } { 344 - // DISABLED: Lineage calculations commented out 345 - // const { data: allLineage = [] } = useLiveQuery(lineageCollection); 346 - // 347 - // return useMemo(() => { 348 - // if (!changeId) { 349 - // return { lineage: new Set<string>(), isLoaded: true }; 350 - // } 351 - // 352 - // const record = allLineage.find((l) => l.repoPath === repoPath && l.changeId === changeId); 353 - // 354 - // if (record) { 355 - // return { lineage: new Set(record.relatedIds), isLoaded: true }; 356 - // } 357 - // 358 - // return { lineage: new Set<string>(), isLoaded: false }; 359 - // }, [allLineage, repoPath, changeId]); 360 - 361 273 return { lineage: new Set<string>(), isLoaded: true }; 362 274 } 363 275 ··· 376 288 // Use refs to avoid recreating loaders on each render 377 289 const diffLoaderRef = useRef<BatchLoader | null>(null); 378 290 const changesLoaderRef = useRef<BatchLoader | null>(null); 379 - // DISABLED: Lineage calculations commented out 380 - // const lineageLoaderRef = useRef<BatchLoader | null>(null); 381 291 const currentRepoPathRef = useRef<string>(repoPath); 382 292 383 293 // Reset loaders if repoPath changes ··· 385 295 currentRepoPathRef.current = repoPath; 386 296 diffLoaderRef.current = null; 387 297 changesLoaderRef.current = null; 388 - // DISABLED: Lineage calculations commented out 389 - // lineageLoaderRef.current = null; 390 298 // Clean up loaders for other repos to prevent memory leaks 391 299 cleanupLoadersExcept(repoPath); 392 300 } ··· 406 314 return changesLoaderRef.current; 407 315 } 408 316 409 - // DISABLED: Lineage calculations commented out 410 - // function getLineageLoaderInstance(): BatchLoader { 411 - // if (!lineageLoaderRef.current) { 412 - // lineageLoaderRef.current = getLineageLoader(repoPath); 413 - // } 414 - // return lineageLoaderRef.current; 415 - // } 416 - 417 317 return { 418 318 prefetchDiffs: (ids: string[]) => { 419 319 traceLog("prefetch-diffs", { count: ids.length, ids }); ··· 423 323 traceLog("prefetch-changes", { count: ids.length, ids }); 424 324 getChangesLoaderInstance().queueMany(ids); 425 325 }, 426 - // DISABLED: Lineage calculations commented out 427 - prefetchLineage: (_ids: string[]) => { 428 - // traceLog("prefetch-lineage", { count: ids.length, ids }); 429 - // getLineageLoaderInstance().queueMany(ids); 430 - }, 326 + prefetchLineage: (_ids: string[]) => {}, 431 327 flushDiffs: () => getDiffLoaderInstance().flushPromise(), 432 328 flushChanges: () => getChangesLoaderInstance().flushPromise(), 433 329 flushLineage: () => Promise.resolve(),