fix(web): mux additions trigger refresh; cli: read version from package.json
- useSessionEvents: detect unknown ids in mux patches and trigger refresh. Previously additions were filtered out before the membership comparison, so new sessions on a project page only appeared via the 15s stale-refresh path. - cli/index.ts: replace hardcoded "0.1.0" with version from package.json so 'ao --version' stays in sync with releases.
This commit is contained in:
parent
a95f0ca881
commit
1fa88cdf9d
|
|
@ -209,12 +209,22 @@ export function useSessionEvents(
|
|||
// Note: empty array is intentional — it means all sessions were removed and we
|
||||
// must still run the membership-key comparison to trigger scheduleRefresh().
|
||||
|
||||
dispatch({ type: "snapshot", patches: muxSessions as SSESnapshotEvent["sessions"] });
|
||||
// muxSessions is global (all projects). Filter to only sessions in the
|
||||
// current project-scoped state so we don't trigger spurious refreshes
|
||||
// when viewing a single-project page.
|
||||
const currentIds = new Set(sessionsRef.current.map((s) => s.id));
|
||||
const scopedMuxSessions = muxSessions.filter((s) => currentIds.has(s.id));
|
||||
// The mux feed is global, but the page is project-scoped. We can't tell from
|
||||
// a mux patch whether an unknown ID belongs to this project — only /api/sessions
|
||||
// knows. So if we see ANY id we don't have, trigger a refresh to find out.
|
||||
const hasUnknownIds = muxSessions.some((s) => !currentIds.has(s.id));
|
||||
|
||||
dispatch({ type: "snapshot", patches: scopedMuxSessions as SSESnapshotEvent["sessions"] });
|
||||
|
||||
const currentMembershipKey = createMembershipKey(sessionsRef.current);
|
||||
const snapshotMembershipKey = createMembershipKey(muxSessions);
|
||||
const snapshotMembershipKey = createMembershipKey(scopedMuxSessions);
|
||||
|
||||
if (currentMembershipKey !== snapshotMembershipKey) {
|
||||
if (hasUnknownIds || currentMembershipKey !== snapshotMembershipKey) {
|
||||
pendingMembershipKeyRef.current = snapshotMembershipKey;
|
||||
scheduleRefresh();
|
||||
} else if (Date.now() - lastRefreshAtRef.current >= STALE_REFRESH_INTERVAL_MS) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue