fix(web): invalidate diff expansion cache when file changes (#501)

This commit is contained in:
Carlos Florêncio
2026-03-30 21:17:49 +01:00
committed by GitHub
parent be1b3a41db
commit 54b8d2939b
2 changed files with 52 additions and 1 deletions
@@ -114,11 +114,14 @@ export function useExpandableDiff({
const [error, setError] = useState<string | null>(null);
// Reset cached content when inputs change so stale data is never rendered.
// Including fileDiffMetadata ensures expansion content is invalidated when
// the diff changes (e.g., file modified while Diff panel is open), because
// @pierre/diffs uses oldLines/newLines for rendering when present.
useEffect(() => {
requestVersionRef.current += 1;
setLoadedContent(null);
setError(null);
}, [sessionId, filePath, baseRef]);
}, [sessionId, filePath, baseRef, fileDiffMetadata]);
const loadContent = useCallback(async () => {
if (!sessionId || !enableExpansion || loadedContent || isLoading) return;