Repository navigation
fix(mobile): track accepted live query outcomes - #5649
Merged
Merged
Conversation
Contributor
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Executive SummaryOrganization switches can be treated as live-session departures and empty every cached history list. Overview
Issue Details (click to expand)WARNING
Files Reviewed (21 files)
Fix these issues in Kilo Cloud Previous Review Summaries (5 snapshots, latest commit cf5e3c9)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit cf5e3c9)Status: No Issues Found | Recommendation: Merge Files Reviewed (19 files)
Previous review (commit 43168e4)Status: No Issues Found | Recommendation: Merge Files Reviewed (19 files)
Previous review (commit ee2ef4f)Status: No Issues Found | Recommendation: Merge Files Reviewed (4 files)
Previous review (commit 2b65e3a)Status: No Issues Found | Recommendation: Merge Files Reviewed (1 file)
Previous review (commit 107bd3c)Status: No Issues Found | Recommendation: Merge Files Reviewed (18 files)
Reviewed by grok-4.6 · Input: 241.4K · Output: 25K · Cached: 1.5M Review guidance: REVIEW.md from base branch |
iscekic
force-pushed
the
mobile-live-loading-2be5-s2
branch
from
August 30, 2026 00:22
ee2ef4f to
43168e4
Compare
eshurakov
approved these changes
Sep 1, 2026
iscekic
force-pushed
the
mobile-live-loading-2be5-s2
branch
from
September 1, 2026 11:04
dc86832 to
cf5e3c9
Compare
iscekic
force-pushed
the
mobile-live-loading-2be5-s2
branch
from
September 1, 2026 11:56
cf5e3c9 to
005fd98
Compare
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
Maintainer changelog
ActiveSessionsQueryMetadatarecordsacceptedRevisionand retryable/non-retryableterminalErrorforactiveSessions.list; old or manually written data does not establish accepted success.captureActiveSessionsQueryRefreshchecks query identity and a newer revision;fenceActiveSessionsQueryrejects results when their account or attachment expires.createKiloAppQueryClientinstalls the observer;getActiveSessionsQueryMetadataandsubscribeActiveSessionsQueryMetadataexpose metadata, withactiveSessionsQueryKeySchemalimiting which keys qualify.Files
apps/mobile/src/lib/query-client.ts— Source; modified; 127 changed lines. Keys metadata and listeners by Query without changing session payloads. Accepted responses increment the revision and clear errors; manual writes and cancellation preserve metadata. Query removal resets metadata, while the client-lifetime observer survives cache clearing. Adds terminal error classification, identity/revision capture, and cancellation fences before and after responses.apps/mobile/src/lib/query-client.test.ts— Test; modified; 221 changed lines. Updates the query-client suite.refreshActiveSessionsNowandActiveSessionsLiveSync.refreshNownow require aQueryKey;falsemeans no matching owner, while{ accepted: boolean }reports handled completion.Acceptance requires a newer server result for the exact query, current account, and current attachment; cancelled replacements remain pending.
LiveSyncQueryClientnow requires a fullQueryClient; callers must supply their scope and must not start a fallback fetch after a handled failure.Files
apps/mobile/src/lib/active-sessions-live-sync.ts— Source; modified; 219 changed lines. Copies owner options, guards writes and refreshes by account and attachment, and cancels only the exact query. Fetches wait for queued writes; manual refresh follows replacement fetches. Only accepted results clear pending reasons; failures retain them for retry.apps/mobile/src/lib/active-sessions-live-sync.attention.test.ts— Test; modified; 4 changed lines. Updates the attention 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-reasons suite.apps/mobile/src/lib/active-sessions-live-sync.race.test.ts— Test; modified; 96 changed lines. Updates the 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; modified; 202 changed lines. Updates the shared live-sync test helper.apps/mobile/src/lib/active-sessions-live-sync.test.ts— Test; modified; 38 changed lines. Updates the live-sync suite.useActiveSessionsshares exportedUseAgentSessionsOptionswithuseAgentSessions, exposesqueryKey/canRead, and gates reads and socket leases on authentication and organization readiness.useLiveAgentSessionsaddshasAcceptedSuccess,terminalError,isFetching, andisPaused; its booleanrefetchconfirms a new accepted response rather than a successful cache state.Legacy flags remain available; account changes block cached active rows and departure reconciliation, while obsolete organization scopes and unmounted callers cannot confirm refresh success.
Files
apps/mobile/src/lib/active-sessions-live-sync-mount.tsx— Source; modified; 115 changed lines. Centralizes guarded reads and exact-scope refreshes, preserving 30-second connected polling, 10-second disconnected polling, and five-second freshness. Authentication and organization readiness control socket leases; epoch, scope, query identity, and unmount checks fence completion. A handled failure does not trigger the plain-query fallback.apps/mobile/src/lib/hooks/use-agent-sessions.ts— Source; modified; 120 changed lines. Exports shared options, subscribes to query metadata, and hides unreadable active rows and history exclusion IDs. Tracks departure IDs by account epoch and guards deferred history resets; both consumers delegate active refresh to the shared hook.apps/mobile/src/lib/hooks/use-agent-sessions.combined.mounted.test.tsx— Test; added; 307 changed lines. Adds a mounted combined-session suite.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.useSessionMutationsbinds rename and delete work to its starting authentication epoch without changingcliSessionsV2.renameorcliSessionsV2.deleteinputs.After account changes, queued requests, late outcomes, optimistic writes, rollbacks, toasts, deletion callbacks, and deferred invalidation stop affecting the new account.
renameSessionAsynckeeps its rejecting promise contract, while current-account edits retain per-session sequencing, optimistic updates, and latest-generation rollback.Files
apps/mobile/src/lib/hooks/use-session-mutations.ts— Source; modified; 245 changed lines. Stores operation epochs beside mutation inputs in a WeakMap and checks them across asynchronous boundaries. Fences both mutation outcomes before global authentication callbacks, suppresses stale side effects, and retains current-account error handling and deletion announcements.apps/mobile/src/lib/hooks/use-session-mutations.test.ts— Test; modified; 640 changed lines. Updates the session-mutation suite.RemoteSessionRowlimits exit-triggered refreshes to the selected organization and the current query instance, rather than refreshing every cached context.refreshActiveSessionsNowreceives that exactQueryKey; only an unhandled request permits the fallback invalidation.Account changes, unresolved organization selection, unmounting, and replaced queries suppress obsolete completion work.
Files
apps/mobile/src/components/agents/remote-session-row.tsx— Source; modified; 42 changed lines. Replaces prefix invalidation with exact invalidation after an unhandled owner refresh. Checks organization readiness, row lifetime, query identity, and account epoch before refreshing or falling back.apps/mobile/src/components/agents/remote-session-row.mounted.test.tsx— Test; added; 267 changed lines. Adds a mounted remote-row suite.Tests: 13 changed files (12 suites, 1 helper), with 2 additions, 11 modifications, and 2,290 changed lines.
Generated: none (0 changed files).
Verification
Local end-to-end verification on an iOS simulator, 2026-09-01. Four of six checks passed. Two have no verdict.
This section covers the stack's three PRs together: #5641, #5649, and #5652.
No product bug was found. No product source changed. The worktree stayed clean.
56-live-recoverable-error.png50-create-ready-during-live-load.png32-pr-review-org-pending.png48-refresh-fresh-result.pngWhy two checks have no verdict
Both gaps are test-harness limits, not defects.
cli_sessions_v2andgithub_branch_pull_requests. No table belongs to history alone, so a table lock delays live loading too and cannot isolate the history request. A request-specific delay oncliSessionsV2.listwould close this.SecureStore.getItemAsyncatapps/mobile/src/lib/organization-context.tsx:45. A backend lock cannot delay or fail a local keychain read, so no fault seam exists for this timing.Setup
xcrun simctl io <udid> screenshot. Full report and images:/Users/igor/Projects/.scratch/local-e2e-live-loading/.