Files
kandev/apps
João Salavisa a814379cf6 fix(web): refresh commits panel snapshot on mount (#1232)
* fix(web): fetch commits snapshot on mount even when prefilled by live events

The useSessionCommits hook gated its initial snapshot fetch on
`commits === undefined`. When a `commit_created` WS event populated the
list before mount (session already running when the panel opens, or
stream replay on reconnect) and carried zero stats, the bad data stuck —
the authoritative `git log --shortstat` snapshot never ran to overwrite
it, leaving older commits stranded with `+0 -0` in the Commits panel.

Anchor the initial-fetch gate to `sessionId` via a ref so the snapshot
fires once per session regardless of how `commits` got populated.

* fix(web): reset fetchedSessionRef when sessionId goes null

Without resetting the ref in the !sessionId early-return path, a hook
that stays mounted while sessionId cycles through null (and commits get
cleared via clearSessionCommits) would not refetch when the same
sessionId is reselected, because fetchedSessionRef.current would still
equal it. Now the ref clears on null so reselect always re-fetches.

Addresses Greptile P2 on #1232.

* fix(web): reset fetchedSessionRef during disconnect teardown

Move the `!sessionId` early-return ref clear before the connection
gate. Without this, a session teardown that runs while WS is
disconnected leaves `fetchedSessionRef.current` pinned to the old
sessionId, so reconnecting to the same session never triggers the
authoritative snapshot fetch.

Addresses cubic P2 on #1232.

---------

Co-authored-by: Kandev Agent <agent@kandev.dev>
2026-06-01 21:52:55 +01:00
..