fix(mobile): track accepted live query outcomes - #5649
Open
iscekic wants to merge 3 commits into
Open
Conversation
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (1 file)
Previous Review Summary (commit 107bd3c)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 107bd3c)Status: No Issues Found | Recommendation: Merge Files Reviewed (18 files)
Reviewed by grok-4.6 · Input: 137.9K · Output: 4.3K · Cached: 134.7K Review guidance: REVIEW.md from base branch |
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
ActiveSessionsQueryMetadataaddsacceptedRevisionandterminalErrorto eachactiveSessions.listQuery; errors carryretryableornon-retryablekinds without changing cached responses.Only accepted server successes advance the revision and clear failures; manual writes, socket updates, cancellation, and observer remounts preserve the metadata.
getActiveSessionsQueryMetadataandsubscribeActiveSessionsQueryMetadataexpose legacy entries as unconfirmed; removal resets metadata, while observation survivesQueryClient.clear().Files
apps/mobile/src/lib/query-client.ts— Source; modified; 127 changed lines. Adds Query metadata getters, subscriptions, revision capture, and stale-query guards without altering response envelopes.apps/mobile/src/lib/query-client.test.ts— Test; modified; 221 changed lines. Updates the query-client suite.refreshActiveSessionsNow(queryKey)andActiveSessionsLiveSync.refreshNow(queryKey)replace the unscoped boolean contract withfalse | { accepted: boolean }; onlyfalseselects a fallback.captureActiveSessionsQueryRefreshrequires the same Query's neweracceptedRevision;useActiveSessions.refetchreports accepted results, whileRemoteSessionRowkeeps refreshes exact and ignores stale callbacks.LiveSyncQueryClientrequires a fullQueryClient;fenceActiveSessionsQueryrejects stale account or attachment results while serialized cancellation, replacement waits, polling, and reconnect edges remain.Files
apps/mobile/src/lib/active-sessions-live-sync.ts— Source; modified; 219 changed lines. Serializes exact cancellations and replacement fetches, fences account changes, and retains pending reasons until accepted success. Keeps copied owner inputs and enrichment throttling.apps/mobile/src/lib/active-sessions-live-sync-mount.tsx— Source; modified; 115 changed lines. Shares guarded queries and refreshes; gates both socket leases on authentication and organization readiness. Preserves 30-second connected polling, 10-second disconnected polling, and five-second freshness.apps/mobile/src/components/agents/remote-session-row.tsx— Source; modified; 42 changed lines. Binds exit refreshes to the mounted scope, account, organization, and Query; replaces broad invalidation with an exact key.apps/mobile/src/components/agents/remote-session-row.mounted.test.tsx— Test; added; 273 changed lines. Adds the mounted remote-row suite.apps/mobile/src/lib/active-sessions-live-sync.manual-refresh.test.ts— Test; modified; 67 changed lines. Updates the manual-refresh suite.apps/mobile/src/lib/active-sessions-live-sync.pending.test.ts— Test; modified; 8 changed lines. Updates the pending-refresh suite.apps/mobile/src/lib/active-sessions-live-sync.race.test.ts— Test; modified; 96 changed lines. Updates the refresh-race suite.apps/mobile/src/lib/active-sessions-live-sync.reconnect.test.ts— Test; modified; 8 changed lines. Updates the reconnect suite.apps/mobile/src/lib/active-sessions-live-sync.test-helpers.ts— Test helper; modified; 202 changed lines. Updates the shared live-sync test support.apps/mobile/src/lib/active-sessions-live-sync.test.ts— Test; modified; 38 changed lines. Updates the main live-sync suite.useLiveAgentSessionsaddshasAcceptedSuccess,terminalError,isFetching, andisPaused;isLoadingandisErrorremain compatible, and this level does not add the new loading presentation.Both session hooks hide unreadable live rows; the combined hook also clears history exclusions and guards deferred departure maintenance with the account epoch.
UseAgentSessionsOptionsbecomes shared;useAgentSessions.refetchstill returns no result while it awaits the accepted-result refresh path and serialized history refresh together.Files
apps/mobile/src/lib/hooks/use-agent-sessions.ts— Source; modified; 120 changed lines. Subscribes to Query metadata, guards row publication and deferred history resets, and reuses the shared refresh path.apps/mobile/src/lib/hooks/use-agent-sessions.combined.mounted.test.tsx— Test; added; 307 changed lines. Adds a mounted suite for combined sessions.apps/mobile/src/lib/hooks/use-agent-sessions.live.mounted.test.tsx— Test; modified; 427 changed lines. Updates the mounted live-session suite.apps/mobile/src/lib/hooks/use-agent-sessions.test.ts— Test; modified; 5 changed lines. Updates the session-hook suite.useSessionMutationstiesdeleteSession,renameSession, andrenameSessionAsyncto the originating account epoch without changing mutation inputs.Stale operations cannot start queued requests, update or restore caches, invalidate lists, or publish old authorization errors, outcome messages, or deletion callbacks.
renameSessionAsyncstill rejects, while non-awaited calls suppress stale failures; current-account operations keep per-session sequencing, generation-checked rollback, and existing notifications.Files
apps/mobile/src/lib/hooks/use-session-mutations.ts— Source; modified; 239 changed lines. Stores epochs outside request inputs and checks them across cancellation, network settlement, rollback, callbacks, and scheduled maintenance.apps/mobile/src/lib/hooks/use-session-mutations.test.ts— Test; modified; 633 changed lines. Updates the session-mutation suite.Tests: 12 changed files (11 suites, 1 helper):
query-client.test.ts,remote-session-row.mounted.test.tsx,active-sessions-live-sync.manual-refresh.test.ts,active-sessions-live-sync.pending.test.ts,active-sessions-live-sync.race.test.ts,active-sessions-live-sync.reconnect.test.ts,active-sessions-live-sync.test-helpers.ts,active-sessions-live-sync.test.ts,use-agent-sessions.combined.mounted.test.tsx,use-agent-sessions.live.mounted.test.tsx,use-agent-sessions.test.ts,use-session-mutations.test.ts.Generated: 0 files changed.
Verification
Visual Changes
Visual Changes: N/A
Reviewer Notes
Human steps
Focused validation
Scope and inventory
Kilo-Org/cloud./Users/igor/Projects/.worktrees/mobile-live-loading-2be5.mobile-live-loading-2be5-s2; base ref:mobile-live-loading-2be5.107bd3c5285a09abf5370c8edd95f3bb40baf8b2. Level 1 is cloud#5641; level 3 presentation is not implemented.Notes
Runtime verification is pending on the stack tip; this level has focused test coverage only.
Stacked PRs — merge bottom to top. Each level shows only its own diff.
Runtime verification (E2E, user advocacy, simplify) runs on the tip PR over every level.
Every level keeps its own checks, its own bot review, and its own threads; each one is answered on its own PR.
Each level is its own deliverable: it builds and passes its own checks alone.
A finding on a level is repaired on that level, then carried upward with stack.sh forward.
mobile-live-loading-2be5— fix(mobile): serialize development account replacement #5641mobile-live-loading-2be5-s2— fix(mobile): track accepted live query outcomes #5649 ← this PRmobile-live-loading-2be5-s3— fix(mobile): preserve live content during loading and reconnect #5652 (tip)