Skip to content

fix(mobile): hold stored sessions across blank refetch - #5411

Merged
iscekic merged 2 commits into
mainfrom
agents-list-stability-53a1
Aug 21, 2026
Merged

fix(mobile): hold stored sessions across blank refetch#5411
iscekic merged 2 commits into
mainfrom
agents-list-stability-53a1

Conversation

@iscekic

@iscekic iscekic commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

The Agents tab session list no longer flashes an empty "No sessions yet" or "No past sessions" message during a background refresh.

The session list keeps its scroll position when a live session ends or when a rename, delete, or create settles.


The stored session list now renders the last non-empty rows while reconcileFirstPage blanks the cache and refetches page one. The new resolveStoredSessionsHold contract and StoredSessionsHold type decide the render from the live rows, the fetch state, and the previous hold, scoped to the JSON-encoded infinite query key, so a filter or sort change still shows its skeleton instead of the previous filter's rows. The hold releases when the refetch settles with rows or with an empty result.

Files
  • apps/mobile/src/lib/agent-session-render-hold.ts — adds the StoredSessionsHold type and the pure resolveStoredSessionsHold helper.
  • apps/mobile/src/lib/hooks/use-agent-sessions.ts — computes the JSON query key, feeds the live rows and fetch state into the helper, stores the hold in a ref, and renders the resolved rows for date grouping and the returned storedSessions.

Tests: 2 files — apps/mobile/src/lib/agent-session-render-hold.test.ts (new) and apps/mobile/src/lib/query/infinite-retention.test.ts (updated).
Generated: none.


Visual Changes

Agents tab session list (iOS). When a live session ends, the list keeps its history rows and scroll position, and no empty state appears. The clipped row under the TODAY header and the 22:41 history rows below it show the kept scroll position.

s2-after-departure.png

Verification

Two cases ran on iOS.

Case What it proves Platform Result
s1 The list keeps its history rows and shows no empty state during the departure refetch, pull-to-refresh, and one poll cycle. iOS passed
s2 A list scrolled into the history keeps its position when the live session ends. iOS passed

The rounds reproduced no defect on an unfixed build; the fix was already in place, so no unfixed-build repro ran.
Recordings: /private/var/folders/pz/_kmbp8vs2755j415slh2hz100000gn/T/kilo-workflow-agents-list-stability-53a1.xPYOqS/e2e-verify-r1-BQRXsC/s1-blanking-refetch.mp4 and /private/var/folders/pz/_kmbp8vs2755j415slh2hz100000gn/T/kilo-workflow-agents-list-stability-53a1.xPYOqS/e2e-verify-r2-ANxpxY/s2-scroll-live-dead.mp4.

Reviewer Notes

No human steps are needed.

reconcileFirstPage empties the stored-list cache before refetching page one on session departure and mutation settle. Keep rendering the last non-empty rows for the same query key until the refetch delivers, so the Agents list never flashes its empty state and the SectionList never unmounts (which reset scroll to the top).
@iscekic iscekic self-assigned this Aug 20, 2026
@kilo-code-bot

kilo-code-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • apps/mobile/src/lib/agent-session-render-hold.ts
  • apps/mobile/src/lib/agent-session-render-hold.test.ts
  • apps/mobile/src/lib/hooks/use-agent-sessions.ts
  • apps/mobile/src/lib/query/infinite-retention.test.ts

Reviewed by grok-4.6 · Input: 200.7K · Output: 19.4K · Cached: 382.8K

Review guidance: REVIEW.md from base branch main

@iscekic iscekic added the human-ready The PR is ready for human review. label Aug 21, 2026
@iscekic
iscekic merged commit 83c9b31 into main Aug 21, 2026
18 checks passed
@iscekic
iscekic deleted the agents-list-stability-53a1 branch August 21, 2026 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

human-ready The PR is ready for human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants