Skip to content

Mobile performance: paginated history loading#181

Merged
PureWeen merged 3 commits intomainfrom
perf/mobile-performance
Feb 23, 2026
Merged

Mobile performance: paginated history loading#181
PureWeen merged 3 commits intomainfrom
perf/mobile-performance

Conversation

@PureWeen
Copy link
Owner

Summary

Dramatically reduces mobile load time by paginating chat history over the WebSocket bridge. Previously the server sent full history for every active session on connect (~13s). Now it sends only the last 10 messages per session.

Changes

Bridge Protocol

  • GetHistoryPayload gains Limit field (null = all messages)
  • SessionHistoryPayload gains TotalCount and HasMore fields
  • Server respects limit, returning only the most recent N messages
  • Backward compatible: new fields have sensible defaults (0, false, null)

Server (WsBridgeServer.cs)

  • Initial connect: sends last 10 messages per session (was: all)
  • Session switch: sends last 10 messages (was: all)
  • Explicit GetHistory request: respects client-specified limit

Client (WsBridgeClient.cs)

  • RequestHistoryAsync accepts optional limit parameter
  • Tracks SessionHistoryHasMore per session from server response

UI (ExpandedSessionView.razor)

  • Loading spinner shown while history is being fetched from remote
  • "⬆️ Load rest of conversation" button when server has more history
  • Clicking it fetches full (unlimited) history from the server

Testing

  • All 1127 tests passing
  • Manually verified on Android — load time went from ~13s to near-instant
  • Code reviewed by Opus 4.6, Opus 4.5, Sonnet 4.6, Sonnet 4.5

Known follow-ups from review

  • Snapshot History list before pagination to avoid TOCTOU race
  • Optimistically set HasMore=false on click to prevent duplicate requests
  • Guard HasMore update when local history already >= TotalCount

PureWeen and others added 3 commits February 22, 2026 08:54
In Remote mode (mobile), when a session has messages (MessageCount > 0)
but history hasn't been fetched yet (History.Count == 0), show a spinner
with 'Loading conversation…' text instead of a blank chat area.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mobile initially fetches only the 10 most recent messages per session,
significantly reducing payload size and load time. A 'Load rest of
conversation' button appears when the server has more history available.

- GetHistoryPayload gains Limit field (null = all)
- SessionHistoryPayload gains TotalCount and HasMore fields
- Server respects limit, returning most recent N messages
- Client tracks HasMore per session
- ExpandedSessionView shows load-full-history button when HasMore is true

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The server was sending full history for ALL sessions on client connect,
causing ~13s load time. Now sends only the 10 most recent per session.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@PureWeen PureWeen merged commit f07c4ff into main Feb 23, 2026
@PureWeen PureWeen deleted the perf/mobile-performance branch February 23, 2026 01:45
PureWeen added a commit that referenced this pull request Feb 23, 2026
The rebase onto origin/main brought in PR #181 (paginated history loading)
which uses OnLoadFullHistory. The PR #111 dead-code cleanup had removed it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant