fix(session): poll sidebar session list via query cache to surface externally created sessions#1584
Open
Formatted wants to merge 3 commits intodifferent-ai:devfrom
Open
fix(session): poll sidebar session list via query cache to surface externally created sessions#1584Formatted wants to merge 3 commits intodifferent-ai:devfrom
Formatted wants to merge 3 commits intodifferent-ai:devfrom
Conversation
…ternally created sessions Automated runs, messaging bot sessions (Slack/Telegram), and other externally created sessions were invisible in the sidebar until the user triggered an indirect refresh (e.g. renaming a session). Replaces the closed useEffect+setInterval approach (PR different-ai#1551) with a visibility-aware polling hook backed by TanStack Query caching: - New session-list-cache.ts module with query key factory and useSessionListPolling hook - Session lists written to TanStack Query cache alongside imperative state - Lightweight refreshSessionLists callback avoids heavy refreshRouteState work - Existing refreshInFlightRef dedup guard prevents overlapping calls - Only fires when tab is visible; also fires immediately on visibility change Fixes different-ai#1262
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
@Formatted is attempting to deploy a commit to the Different AI Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
src-opn
requested changes
May 4, 2026
Collaborator
src-opn
left a comment
There was a problem hiding this comment.
Requesting changes.
Code verification issue:
apps/app/src/react-app/shell/session-route.tsx:565-587:refreshSessionListsonly checksrefreshInFlightRef.currentbut never sets an in-flight guard for its own polling work. IflistSessionstakes longer than the 30s interval, or if the tab becomes visible while a poll is already running, multiple session-list refreshes can overlap. The visibility event can also race with the existing visibility handler atsession-route.tsx:728-732, causing the new lightweight refresh and fullrefreshRouteState()to run concurrently. This contradicts the PR description/comment that the existing guard prevents overlapping calls, and it can reintroduce the event-loop/network pressure this area is trying to avoid. Please add a dedicated polling in-flight guard, or reuse the existing guard consistently, and avoid double refreshes on visibility restore.
Verification performed:
pnpm install --frozen-lockfilepassed.pnpm --filter @openwork/app typecheckpassed.pnpm --filter @openwork/app buildpassed.
…nd stop double refresh on visibility restore Addresses review feedback on different-ai#1584: - refreshSessionLists previously only checked refreshInFlightRef but never set its own guard, so a slow listSessions call (or a visibility-triggered refresh during an active poll) could overlap with itself. Add pollSessionsInFlightRef and toggle it in try/finally. - useSessionListPolling's visibilitychange handler raced with session-route's existing handleVisibility, which already runs the heavier refreshRouteState (and therefore re-fetches sessions). Drop the polling hook's visibility handler so we don't fire two concurrent session-list refreshes on every tab focus.
# Conflicts: # apps/app/src/react-app/shell/session-route.tsx
Author
|
Addressed in 30183fe (on top of the merge with Changes vs. the original commit:
Verified locally: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
useEffect+setInterval(as requested in closed PR fix(session): poll sidebar session list to surface externally created sessions #1551)Changes
session-list-cache.ts- Query key factory anduseSessionListPollinghook for visibility-aware pollingsession-route.tsx- Lightweight session-only refresh callback + polling integrationrefreshInFlightRefdedup guard prevents overlapping callsProblem
Automated runs, messaging bot sessions, and other externally created sessions were invisible in the sidebar until the user triggered an indirect refresh (e.g. renaming a session).
Solution
Added a lightweight polling hook backed by the TanStack Query caching system. The
refreshSessionListscallback only re-fetches session lists (avoiding the heavyrefreshRouteStatework of re-resolving connections and workspaces).Fixes #1262