Fix complete chat transcript paging across ADE clients - #926
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Warning Review limit reached
Next review available in: 35 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughADE adds byte-cursor chat history paging across RPC and sync protocols, desktop and TUI clients, and iOS chat views. The changes add scoped history actions, subscription cursor metadata, bounded page retrieval, detached-history handling, retry states, and older-history UI coverage. ChangesChat history protocol and host paging
Desktop history routing
TUI scrollback
iOS sync and views
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (2)
apps/ios/ADETests/ADETests.swift (1)
13498-13531: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winConsider adding a forward-cursor regression case.
workChatOlderTranscriptPageAdvancesis covered fornextCursor < beforeOffset(advances),== beforeOffset(stalls),nil(exhausted), and-1(invalid), but not for a cursor that moves the wrong way (nextCursor > beforeOffset), e.g. a misbehaving host returning a cursor further forward than the page just fetched. That's the same infinite-loop failure mode the-1and stall cases already guard against.♻️ Suggested additional assertion
XCTAssertFalse(workChatOlderTranscriptPageAdvances( beforeOffset: 4_096, nextCursor: -1 )) + XCTAssertFalse(workChatOlderTranscriptPageAdvances( + beforeOffset: 4_096, + nextCursor: 8_192 + ))🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/ios/ADETests/ADETests.swift` around lines 13498 - 13531, Add a regression assertion in testMobileHistoryRoutingRequiresScopedProgressingCursors verifying workChatOlderTranscriptPageAdvances returns false when nextCursor is greater than beforeOffset, such as beforeOffset 4,096 and nextCursor 8,192. Keep the existing advancing, exhausted, stalled, and negative-cursor cases unchanged.apps/ios/ADE/Views/Work/WorkSessionDestinationView.swift (1)
2229-2236: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReuse
workChatOlderTranscriptPageAdvancesinstead of reimplementing the advance check.This guard duplicates exactly the rule already encoded (and unit-tested via
testMobileHistoryRoutingRequiresScopedProgressingCursors) inworkChatOlderTranscriptPageAdvances, whichloadOlderTranscriptEntriesalready calls a few lines above for the canonical-fallback path. Reusing it here keeps the two paging paths' cursor-progress rules from drifting apart.♻️ Proposed refactor
- guard page.startOffset >= 0, page.startOffset < cursor else { - return .failed - } + guard workChatOlderTranscriptPageAdvances(beforeOffset: cursor, nextCursor: page.startOffset) else { + return .failed + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/ios/ADE/Views/Work/WorkSessionDestinationView.swift` around lines 2229 - 2236, In the loaded-page validation within loadOlderTranscriptEntries, replace the duplicated page.startOffset range guard with the existing workChatOlderTranscriptPageAdvances helper. Preserve the current .failed result for invalid or non-progressing cursor advances and keep the surrounding sessionFound handling unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/ade-cli/src/services/sync/brainProjectActionsSyncHandler.ts`:
- Around line 913-921: Update the chat history paging handler around
personalChatScope.call and normalizeChatHistoryPage to log failures in the catch
block using the existing sync.chat_history_failed event and established logging
conventions from syncHostService.ts or nearby handlers, while preserving the
unavailableChatHistoryPage fallback behavior.
In `@apps/ade-cli/src/services/sync/syncHostService.ts`:
- Around line 7646-7663: Update the chat_history scope resolution near
subscribedScope and requestedScope to reuse the same local-versus-foreign
classification as chat_subscribe’s resolveForeignChatScope. Ensure
projectId/projectRootPath values matching the host produce the "project" scope,
while only genuinely foreign projects produce "foreign-project", so the scope
comparison remains consistent across subscribe, unsubscribe, and history paging.
In `@apps/ios/ADE/Services/SyncService.swift`:
- Line 2751: Update the chat_history pagination flow in SyncService and its
chatHistoryCursorBySession state so each validated page stores startOffset when
hasMore is true, or clears the cursor to 0 when history is complete; leave the
existing cursor unchanged for unavailable or invalid pages. Add a regression
test covering page fetch, live event synchronization via
WorkSessionDestinationView.syncTranscriptFromLiveEvents, and the subsequent page
request to verify the cursor advances and no page repeats.
In `@apps/ios/ADE/Views/Work/WorkChatSessionView.swift`:
- Around line 1118-1122: Update the .onDisappear handler in WorkChatSessionView
to reset olderHistoryLoadInFlight and olderHistoryLoadError after cancelling and
clearing olderHistoryLoadTask, matching the four-field reset behavior in
resetScrollStateForCurrentSession and resetTimelineSourceIfNeeded. Preserve the
existing timeline snapshot cancellation.
---
Nitpick comments:
In `@apps/ios/ADE/Views/Work/WorkSessionDestinationView.swift`:
- Around line 2229-2236: In the loaded-page validation within
loadOlderTranscriptEntries, replace the duplicated page.startOffset range guard
with the existing workChatOlderTranscriptPageAdvances helper. Preserve the
current .failed result for invalid or non-progressing cursor advances and keep
the surrounding sessionFound handling unchanged.
In `@apps/ios/ADETests/ADETests.swift`:
- Around line 13498-13531: Add a regression assertion in
testMobileHistoryRoutingRequiresScopedProgressingCursors verifying
workChatOlderTranscriptPageAdvances returns false when nextCursor is greater
than beforeOffset, such as beforeOffset 4,096 and nextCursor 8,192. Keep the
existing advancing, exhausted, stalled, and negative-cursor cases unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: a6b50780-0ea8-46a8-9187-f4377daf2d48
⛔ Files ignored due to path filters (7)
docs/ARCHITECTURE.mdis excluded by!docs/**docs/features/ade-code/README.mdis excluded by!docs/**docs/features/chat/composer-and-ui.mdis excluded by!docs/**docs/features/chat/transcript-and-turns.mdis excluded by!docs/**docs/features/sync-and-multi-device/README.mdis excluded by!docs/**docs/features/sync-and-multi-device/ios-companion.mdis excluded by!docs/**docs/features/web-client/README.mdis excluded by!docs/**
📒 Files selected for processing (32)
apps/ade-cli/src/adeRpcServer.test.tsapps/ade-cli/src/adeRpcServer.tsapps/ade-cli/src/services/sync/brainProjectActionsSyncHandler.tsapps/ade-cli/src/services/sync/syncHostService.test.tsapps/ade-cli/src/services/sync/syncHostService.tsapps/ade-cli/src/tuiClient/__tests__/ChatView.test.tsxapps/ade-cli/src/tuiClient/__tests__/olderHistory.test.tsapps/ade-cli/src/tuiClient/adeApi.tsapps/ade-cli/src/tuiClient/app.tsxapps/ade-cli/src/tuiClient/components/ChatView.tsxapps/ade-cli/src/tuiClient/olderHistory.tsapps/desktop/src/main/services/ipc/registerIpc.tsapps/desktop/src/main/services/ipc/runtimeBridge.test.tsapps/desktop/src/preload/global.d.tsapps/desktop/src/preload/preload.test.tsapps/desktop/src/preload/preload.tsapps/desktop/src/renderer/components/chat/AgentChatMessageList.tsxapps/desktop/src/renderer/components/chat/AgentChatPane.test.tsxapps/desktop/src/renderer/components/chat/AgentChatPane.tsxapps/desktop/src/renderer/components/chat/ChatUserMinimap.test.tsxapps/desktop/src/renderer/components/chat/ChatUserMinimap.tsxapps/desktop/src/renderer/webclient/adapter/__tests__/adapter.test.tsapps/desktop/src/renderer/webclient/adapter/agentChat.tsapps/desktop/src/shared/types/sync.tsapps/ios/ADE/Models/RemoteModels.swiftapps/ios/ADE/Services/SyncService.swiftapps/ios/ADE/Views/Work/WorkChatRichCardViews.swiftapps/ios/ADE/Views/Work/WorkChatSessionView+Actions.swiftapps/ios/ADE/Views/Work/WorkChatSessionView.swiftapps/ios/ADE/Views/Work/WorkSessionDestinationView.swiftapps/ios/ADE/Views/Work/WorkTimelineHelpers.swiftapps/ios/ADETests/ADETests.swift
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9336681608
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const subscribedScope = peer.chatSubscriptionScopes.get(sessionId); | ||
| const requestedScope = requestedChatSubscriptionScope(payload); | ||
| if ( | ||
| !peer.subscribedChatSessionIds.has(sessionId) | ||
| || subscribedScope !== requestedScope |
There was a problem hiding this comment.
Match history requests to the exact subscribed project
For foreign-project subscriptions, this comparison only checks the coarse "foreign-project" category. If two projects contain the same session ID, a peer subscribed to project A can send a chat_history request scoped to project B and pass this gate; the response is then read from project A's stored resolvedChatTranscriptPaths entry. Track and compare the exact project/root scope so stale or colliding cross-project requests cannot return another project's transcript.
Useful? React with 👍 / 👎.
| truncated: boolean; | ||
| tailStartOffset: number; | ||
| }> { | ||
| const size = await readHistoryFileSize(transcriptPath); |
There was a problem hiding this comment.
Return an empty snapshot when the transcript file is absent
When a registered foreign chat has not created its transcript yet, createForeignChatTranscriptResolver intentionally returns its confined candidate path even if it does not exist. Removing the previous catch means readHistoryFileSize now rejects in that normal state (and when a transcript disappears during a race); the outer message queue only logs the error and sends no chat_subscribe response, leaving the client waiting for a timeout instead of receiving the former empty snapshot. Preserve the empty-snapshot fallback for filesystem-not-found/read failures while still propagating cancellation.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7e9c577d60
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if topY < -workChatOlderHistoryRearmDistance { | ||
| olderHistoryTriggerArmed = true |
There was a problem hiding this comment.
Re-arm pagination when the content remains shorter than the viewport
When the first automatic request adds too little visible content to move topY below the 420-point re-arm threshold—for example, after a sparse page or six event pages that produce no timeline rows—olderHistoryTriggerArmed remains false after line 1054. The view has removed the normal manual load button, and a short timeline cannot be scrolled far enough to satisfy this condition, so the remaining positive history cursor becomes permanently inaccessible until the view is recreated. Re-arm after a successful page when host history remains and the content still cannot scroll away from the trigger zone.
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Validation
Research
The design follows bounded cursor paging and stable-list lessons from SQLite scrolling windows, TanStack Virtual, Legend List, and the T3 Code cache-first snapshot and resume flow while avoiding T3 Code mobile full-thread blob loading.
Open this PR in ADE
Summary by CodeRabbit
New Features
Bug Fixes
Style