Skip to content

Improve iOS chat responsiveness - #919

Merged
arul28 merged 5 commits into
mainfrom
ade/start-skill-saw-tweet-wanted-5569c4b5
Jul 27, 2026
Merged

Improve iOS chat responsiveness#919
arul28 merged 5 commits into
mainfrom
ade/start-skill-saw-tweet-wanted-5569c4b5

Conversation

@arul28

@arul28 arul28 commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • prevent capped chat-event windows from replaying and duplicating transcript content
  • retain recent chat subscriptions and seed cached presentation for instant, blank-free reopening
  • coalesce opening snapshots, retry lost acknowledgements on a bounded cadence, and eliminate repeated 2 MB snapshot downloads
  • reduce Work-row, transcript, and context-usage recomputation on the SwiftUI render path
  • document the mobile transcript/subscription invariants and add focused regressions

Verification

  • iOS simulator build succeeded on iPhone 17 Pro (iOS 26.3.1) with isolated DerivedData and parallel testing disabled
  • 18 focused ADETests XCTest cases passed
  • live simulator: one opening snapshot over 2+ minutes; warm reopen emitted no subscribe/unsubscribe traffic
  • Time Profiler follow-up removed workContextUsageViewModel from the settled redraw sample
  • all Swift sources parse; plist lint and git diff checks pass

Summary by CodeRabbit

  • Improvements
    • Improved chat transcript loading and reopening, including smarter snapshot requests and more reliable recovery for incomplete or changing histories.
    • Preserved active chat subscriptions briefly when navigating away, enabling faster reopening while reducing unnecessary network activity.
    • Added clearer loading behavior while chat sessions initialize.
    • Improved rendering performance for chat transcripts, context usage details, and work-session previews.
    • Improved handling of offline and remote chat subscription scenarios.

@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
ade Ignored Ignored Preview Jul 27, 2026 11:30pm

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@arul28, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 233fc5e6-17f5-44d3-afdc-640f70bda5c5

📥 Commits

Reviewing files that changed from the base of the PR and between 9da4aee and 68fbdc9.

📒 Files selected for processing (7)
  • apps/ade-cli/src/tuiClient/__tests__/remoteLauncher.test.ts
  • apps/ios/ADE/Models/RemoteModels.swift
  • apps/ios/ADE/Services/SyncService.swift
  • apps/ios/ADE/Views/Work/WorkChatSessionView.swift
  • apps/ios/ADE/Views/Work/WorkSessionDestinationView.swift
  • apps/ios/ADE/Views/Work/WorkTimelineHelpers.swift
  • apps/ios/ADETests/ADETests.swift
📝 Walkthrough

Walkthrough

Changes

iOS chat flow

Layer / File(s) Summary
Chat subscription lifecycle
apps/ios/ADE/Services/SyncService.swift, apps/ios/ADETests/ADETests.swift
Delayed unsubscription, snapshot-request coalescing, remote activation tracking, retention, and cleanup are implemented and tested.
Transcript reconciliation and opening snapshots
apps/ios/ADE/Views/Work/WorkSessionDestinationView.swift, apps/ios/ADETests/ADETests.swift
Opening snapshot retries, cached hydration state, ring-buffer delta matching, loading UI, and conditional unsubscribe behavior are updated and tested.
Cached Work rendering state
apps/ios/ADE/Views/Work/WorkTimelineHelpers.swift, apps/ios/ADE/Views/Work/WorkChatSessionView.swift, apps/ios/ADE/Views/Work/WorkErrorAndMessageHelpers.swift, apps/ios/ADE/Views/Work/WorkRootComponents.swift, apps/ios/ADETests/ADETests.swift
Context usage values are memoized, sorted transcripts skip redundant sorting, and session rows render cached signature values.
iOS fixture validation
apps/ios/ADETests/ADETests.swift
A recorded command fixture updates status representation and adds a nil duration field.

CLI launcher test adjustment

Layer / File(s) Summary
Unreachable SSH assertion
apps/ade-cli/src/tuiClient/__tests__/remoteLauncher.test.ts
The test now requires at least one process spawn while retaining deadline and child-kill checks.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • arul28/ADE#577: Touches the Work timeline context-usage view-model path.
  • arul28/ADE#790: Changes the shared context-usage computation layer.

Suggested labels: ios, docs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.17% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and directly reflects the main goal of improving iOS chat responsiveness across the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ade/start-skill-saw-tweet-wanted-5569c4b5

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@arul28 arul28 changed the title t3code-mobile-performance -> Primary Improve iOS chat responsiveness Jul 27, 2026
@arul28
arul28 force-pushed the ade/start-skill-saw-tweet-wanted-5569c4b5 branch from f10ae37 to 9da4aee Compare July 27, 2026 22:18
@arul28

arul28 commented Jul 27, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9da4aee53e

ℹ️ 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".

Comment thread apps/ios/ADE/Views/Work/WorkSessionDestinationView.swift Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/ios/ADE/Views/Work/WorkSessionDestinationView.swift (1)

693-716: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Restore initialTranscriptTailHydrated before re-caching transcript/fallback.

setTranscript/setFallbackEntries (called at Lines 710/713) internally call cacheCurrentTranscriptPresentationIfNeeded(), which persists initialTranscriptTailHydrated from the current @State value. Since initialTranscriptTailHydrated = cached.initialTranscriptTailHydrated runs at Line 715, after those calls, the presentation cache entry gets briefly re-written with the stale (pre-restore) hydration flag. If the view disappears in that narrow window before the next natural cache write (later in loadTranscript), the persisted cache permanently loses the correct hydration state — causing an unnecessary opening-snapshot re-request (and the 2 MB download) on the next reopen, which is exactly what this PR is trying to avoid.

Move the assignment above the setTranscript/setFallbackEntries calls so the intermediate cache write already carries the correct value.

🐛 Proposed fix
     olderTranscriptCursor = cached.olderTranscriptCursor
     transcriptCursorKind = cached.transcriptCursorKind
     olderChatEventHistoryCursor = cached.olderChatEventHistoryCursor
     transcriptEntriesByIndex = workChatTranscriptEntriesByIndexForRestoredPresentation(
       fallbackEntries: cached.fallbackEntries,
       cursorKind: cached.transcriptCursorKind
     )
+    initialTranscriptTailHydrated = cached.initialTranscriptTailHydrated
     if !cached.transcript.isEmpty {
       setTranscript(cached.transcript)
     }
     if !cached.fallbackEntries.isEmpty {
       setFallbackEntries(cached.fallbackEntries)
     }
-    initialTranscriptTailHydrated = cached.initialTranscriptTailHydrated
   }
🤖 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 693 -
716, In seedTranscriptFromPresentationCacheIfNeeded(), assign
initialTranscriptTailHydrated from cached.initialTranscriptTailHydrated before
calling setTranscript or setFallbackEntries, so their internal cache writes
persist the restored hydration state; remove the later assignment.
🧹 Nitpick comments (2)
apps/ios/ADE/Views/Work/WorkChatSessionView.swift (1)

158-158: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Make the SwiftUI state private.

Change this to @State private var contextUsageViewModelCache. SwiftLint already reports private_swiftui_state; view-owned state should not be exposed through the view’s internal API. As per path instructions, this iOS SwiftUI state should follow SwiftUI ownership conventions.

🤖 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/WorkChatSessionView.swift` at line 158, Update the
contextUsageViewModelCache declaration in WorkChatSessionView to make the `@State`
property private, preserving its existing initialization and behavior.

Sources: Path instructions, Linters/SAST tools

apps/ios/ADE/Services/SyncService.swift (1)

8394-8447: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract the pending-unsubscribe capacity bound into a named constant.

scheduleChatEventUnsubscribe hardcodes the retention bound (4) inline, whereas the sibling chatSnapshotRequestCoalescingInterval is a named constant. Extracting a chatEventUnsubscribeRetentionLimit constant would make the bound easier to find/tune and keep the two related knobs consistent.

♻️ Proposed refactor
   private let chatSnapshotRequestCoalescingInterval: TimeInterval = 5
+  private let chatEventUnsubscribeRetentionLimit = 4
   private var recentFullChatSnapshotRequestAtBySession: [String: Date] = [:]
-    while pendingChatUnsubscribesBySession.count >= 4,
+    while pendingChatUnsubscribesBySession.count >= chatEventUnsubscribeRetentionLimit,
🤖 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/Services/SyncService.swift` around lines 8394 - 8447, Define a
named chatEventUnsubscribeRetentionLimit constant alongside
chatSnapshotRequestCoalescingInterval, then update scheduleChatEventUnsubscribe
to use it instead of the inline 4 capacity bound. Preserve the existing
retention behavior and eviction logic.
🤖 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/tuiClient/__tests__/remoteLauncher.test.ts`:
- Line 550: The test around openRemoteRpcSession currently only verifies that
spawnProcess was called, allowing excessive retry attempts to pass. Replace this
assertion with an upper-bound assertion on spawnProcess call count tied to the
expected route or retry attempt count, preferably deriving it from the route
matrix rather than using an arbitrary hard-coded limit.

In `@apps/ios/ADE/Views/Work/WorkTimelineHelpers.swift`:
- Around line 3566-3603: Scope WorkContextUsageViewModelCache to the chat
session by including sessionId in Key and passing it through value, ensuring
cached entries cannot be reused across sessions with matching
transcriptRenderSignature. Update callers such as contextUsageViewModelCache
usage accordingly and add a regression test that switches sessions while reusing
the render signature and verifies fresh context usage is returned.

---

Outside diff comments:
In `@apps/ios/ADE/Views/Work/WorkSessionDestinationView.swift`:
- Around line 693-716: In seedTranscriptFromPresentationCacheIfNeeded(), assign
initialTranscriptTailHydrated from cached.initialTranscriptTailHydrated before
calling setTranscript or setFallbackEntries, so their internal cache writes
persist the restored hydration state; remove the later assignment.

---

Nitpick comments:
In `@apps/ios/ADE/Services/SyncService.swift`:
- Around line 8394-8447: Define a named chatEventUnsubscribeRetentionLimit
constant alongside chatSnapshotRequestCoalescingInterval, then update
scheduleChatEventUnsubscribe to use it instead of the inline 4 capacity bound.
Preserve the existing retention behavior and eviction logic.

In `@apps/ios/ADE/Views/Work/WorkChatSessionView.swift`:
- Line 158: Update the contextUsageViewModelCache declaration in
WorkChatSessionView to make the `@State` property private, preserving its existing
initialization and behavior.
🪄 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: b81bce64-5e17-4a5f-91a6-b24084538316

📥 Commits

Reviewing files that changed from the base of the PR and between eba3111 and 9da4aee.

⛔ Files ignored due to path filters (1)
  • docs/features/sync-and-multi-device/ios-companion.md is excluded by !docs/**
📒 Files selected for processing (8)
  • apps/ade-cli/src/tuiClient/__tests__/remoteLauncher.test.ts
  • apps/ios/ADE/Services/SyncService.swift
  • apps/ios/ADE/Views/Work/WorkChatSessionView.swift
  • apps/ios/ADE/Views/Work/WorkErrorAndMessageHelpers.swift
  • apps/ios/ADE/Views/Work/WorkRootComponents.swift
  • apps/ios/ADE/Views/Work/WorkSessionDestinationView.swift
  • apps/ios/ADE/Views/Work/WorkTimelineHelpers.swift
  • apps/ios/ADETests/ADETests.swift

Comment thread apps/ade-cli/src/tuiClient/__tests__/remoteLauncher.test.ts Outdated
Comment thread apps/ios/ADE/Views/Work/WorkTimelineHelpers.swift
@arul28

arul28 commented Jul 27, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 550d60a143

ℹ️ 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".

Comment thread apps/ios/ADE/Services/SyncService.swift Outdated
Comment thread apps/ios/ADE/Views/Work/WorkSessionDestinationView.swift Outdated
@arul28

arul28 commented Jul 27, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2dcc44b9ba

ℹ️ 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".

Comment thread apps/ios/ADE/Views/Work/WorkSessionDestinationView.swift
@arul28

arul28 commented Jul 27, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 68fbdc9f39

ℹ️ 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".

@arul28
arul28 merged commit 29d2da7 into main Jul 27, 2026
33 checks passed
@arul28
arul28 deleted the ade/start-skill-saw-tweet-wanted-5569c4b5 branch July 28, 2026 01:00
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