Skip to content

Fix: M2 client history paging review feedback#9247

Merged
ashleeradka merged 1 commit into
mainfrom
swarm/history-pagination/fix-m2
Feb 25, 2026
Merged

Fix: M2 client history paging review feedback#9247
ashleeradka merged 1 commit into
mainfrom
swarm/history-pagination/fix-m2

Conversation

@ashleeradka
Copy link
Copy Markdown
Contributor

@ashleeradka ashleeradka commented Feb 25, 2026

Summary

Addresses review feedback on #9235. Fixes three scenarios where isLoadingMoreMessages can get permanently stuck, blocking all future "Load more" history pagination attempts.

Implementation

1. Timeout for unresponsive daemon (ChatViewModel.swift)

loadPreviousMessagePage() sets isLoadingMoreMessages = true before requesting history from the daemon, but relies on populateFromHistory to clear it. If the daemon drops the connection or never responds, the flag stays true forever. Added a 15-second timeout task that resets the flag if the daemon never responds. The timeout is cancelled when populateFromHistory successfully processes the response.

2. Guard failure cleanup on macOS (ThreadSessionRestorer.swift)

When requestPaginatedHistory guard for thread fails (e.g., thread removed during a concurrent reconnect/refresh), the method returned early without resetting isLoadingMoreMessages. Added a existingChatViewModel(forSessionId:) method to the ThreadRestorerDelegate protocol and ThreadManager implementation that looks up VMs by iterating the chatViewModels dictionary, enabling cleanup even when the thread is no longer in the threads array.

3. Guard failure cleanup on iOS (IOSThreadStore.swift)

Same pattern as macOS — the compound guard (daemonClient as? DaemonClient + thread lookup) could fail without resetting loading state. The daemon cast specifically fails when using HTTPDaemonClient (remote daemon mode). Added cleanup in the else block that re-attempts the thread lookup (which succeeds when only the daemon cast failed) and resets isLoadingMoreMessages.

Files Changed

  • clients/shared/Features/Chat/ChatViewModel.swift — Added timeout task property + 15s timeout in loadPreviousMessagePage(), cancel in populateFromHistory
  • clients/macos/vellum-assistant/Features/MainWindow/ThreadSessionRestorer.swift — Added existingChatViewModel(forSessionId:) to protocol, guard failure cleanup
  • clients/macos/vellum-assistant/Features/MainWindow/ThreadManager.swift — Implemented existingChatViewModel(forSessionId:) with dictionary iteration
  • clients/macos/vellum-assistantTests/ThreadSessionRestorerTests.swift — Added mock implementation of new protocol method
  • clients/ios/App/IOSThreadStore.swift — Guard failure cleanup with thread re-lookup

Testing

  • Load more history on a thread, then disconnect the daemon mid-request — verify the spinner clears after 15 seconds
  • On iOS, test load-more with HTTP transport — verify the spinner doesn't get permanently stuck
  • Normal load-more should work as before (timeout cancelled on successful response)

Open with Devin

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ashleeradka ashleeradka self-assigned this Feb 25, 2026
@ashleeradka ashleeradka merged commit be003d3 into main Feb 25, 2026
1 of 2 checks passed
@ashleeradka ashleeradka deleted the swarm/history-pagination/fix-m2 branch February 25, 2026 23:44
Copy link
Copy Markdown

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

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: 5ebc6a0585

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread clients/shared/Features/Chat/ChatViewModel.swift
@ashleeradka
Copy link
Copy Markdown
Contributor Author

Addressed in #9327

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