fix: refetch git status when switching back to a previously viewed task (#198)

This commit is contained in:
João Salavisa
2026-02-06 00:54:22 +00:00
committed by GitHub
parent 5af2a10551
commit fc68eded38
@@ -96,12 +96,21 @@ export function useSessionGitStatus(sessionId: string | null) {
}
prevSessionIdRef.current = sessionId;
// Skip fetch if we already have status or already fetched for this session
const currentStatus = storeApi.getState().gitStatus.bySessionId[sessionId];
if (currentStatus || hasFetchedRef.current) {
// Skip fetch if we already fetched for this session (and session hasn't changed)
// When session changed, always refetch to get the latest status even if cached
if (hasFetchedRef.current) {
return;
}
// If we haven't fetched yet and status already exists (e.g., from WebSocket), skip
if (!sessionChanged) {
const currentStatus = storeApi.getState().gitStatus.bySessionId[sessionId];
if (currentStatus) {
hasFetchedRef.current = true;
return;
}
}
hasFetchedRef.current = true;
fetchSnapshot(sessionId);
}, [sessionId, connectionStatus, fetchSnapshot, storeApi]);