Repository navigation
#981 Page Home sessions and roll up busy sub-agents off the main thread - #984
Merged
Merged
Conversation
Home's live session list downloaded every session of a project (v2 followed every cursor page; v1 took the server's 100-row default including children) and rebuilt each row's family on the main thread for every status or list event. With thousands of sessions that blocked the main thread for seconds. - Load Home as a roots-only window: 50 newest roots in one request (v1 roots=true&limit, v2 parentID=null&archived=false&order=desc&limit), growing by 50 when the list nears its end. Every refetch asks for the current window size; full listSessions stays for other callers. - Roll a busy sub-agent up to its root from the busy set only. A per-profile session ancestry learns parent links from loaded windows and fetches unknown parents one session at a time; busy roots outside the window join Home until their family is idle. - Build Home rows off the main thread (Android Default dispatcher with conflation, iOS detached task) and apply only the result on main. - Drop session counts from the Home dock, project picker and Worktrees screen; running counts stay. The load-more footer is a skeleton row. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
Author
ivanfenenko
marked this pull request as ready for review
November 5, 2026 08:07
Collaborator
Author
|
@cursor review |
There was a problem hiding this comment.
Automated review: no finding that 2+ of 3 passes agreed on.
10 finding(s) from a single pass, not posted
android/app/src/main/java/dev/opencode/mobile/ui/main/HomeSessionRows.kt:40high: empty parentId roots dropped from rows (muse-spark-1.3-contributor)ios/OpenCode Mobile/OpenCode Mobile/UI/Main/HomeSessionRows.swift:31high: empty parentID roots dropped from rows (muse-spark-1.3-contributor)android/app/src/main/java/dev/opencode/mobile/domain/session/V1SessionRemote.kt:32medium: hasMore misses servers that return more than limit (muse-spark-1.3-contributor)ios/OpenCode Mobile/OpenCode Mobile/Domain/Session/SessionWindow.swift:17medium: hasMore misses replies larger than limit (muse-spark-1.3-contributor)android/app/src/main/java/dev/opencode/mobile/domain/live/DefaultSessionLiveStore.kt:109medium: failed loadMore permanently inflates window (muse-spark-1.3-contributor)android/app/src/main/java/dev/opencode/mobile/domain/live/SessionAncestry.kt:179medium: fetch accepts session with wrong id, retry storm (muse-spark-1.3-contributor)ios/OpenCode Mobile/OpenCode Mobile/UI/Main/ProjectListHomeViewModel.swift:2296medium: First-load row build skipped when status and ready streams already emitted, leaving the load skeleton stuck (glm-5.3-flash)ios/OpenCode Mobile/OpenCode Mobile/UI/Main/ProjectListHomeViewModel.swift:2453medium: Load-more on a worktree scope pages sibling worktrees and shows a footer for rows that are not displayed (deepseek-v4.1-flash)android/app/src/main/java/dev/opencode/mobile/domain/session/SessionModels.kt:520low: homeActivityByRoot tie-break between two non-root busy sessions is non-deterministic (glm-5.3-flash)android/app/src/main/java/dev/opencode/mobile/ui/main/MainScreenViewModel.kt:1895low: Unresolvable Home scope pages every observed directory (deepseek-v4.1-flash)
opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.158 · 1 pass(es) stopped early
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9484edb. Configure here.
The Home list asked for older sessions only from a near-end row, so an empty worktree filter never paged, and a window that turned hasMore after a cache seed with the same rows did not ask again until a scroll. The list now treats no rows as its end and samples again when more becomes available or a load ends. A filter with no rows yet but more to load shows its loading placeholder. A window whose refresh failed stops paging until a refresh succeeds, so the list never retries in a loop. Renames the Android remove-worktree note to worktrees_remove_sessions_stay to match the iOS key. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Summary
Home froze on large projects. The live session list downloaded every session (v2 followed every cursor page; v1 took the server's 100-row default including sub-agent children), and every status or list event rebuilt each row's family on the main thread: O(roots × sessions × depth). This PR changes how Home loads and rolls up sessions, on both apps and both protocols.
roots=true&limit, v2parentID=null&archived=false&order=desc&limit). The window grows by 50 when the list scrolls near its end, and a skeleton row shows while the next page loads. Every refetch (events, reconnect, pull to refresh) asks for the current window size in one request. The fulllistSessionsstays for its other callers.Dispatchers.Defaultwithconflate(); iOS builds them in a detached task and drops stale results. Only the state assignment runs on main.Checks
Low-end Android (Galaxy A15, Helio G99, 4 GB) running the release-like
benchmarkbuild against the scenario harness (opencode v2dev, about 9,000 sessions: 901 roots and 8,101 sub-agents), with live load of 4 prompts every 1.5 s:At 3,000 sessions,
mainalready spent about 0.7 s per update (121 s of main-thread work in a 136 s run)../gradlew :app:testDebugUnitTest(3,402 tests, 0 failures) and:app:assembleDebugpass after the rebase. ktlint still fails on existing violations; the new code adds none except two lines indented to match the surrounding call.Evidence
Screenshots in the evidence comment (harness data only).
Issue
Fixes #981
Risks / Follow-ups
SessionChatInbox). Separate follow-up.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Changes core Home data loading, live-store refresh, and activity roll-up across v1/v2; behavior is heavily tested but affects the primary session list path.
Overview
Fixes Home freezing on large projects by loading sessions in windows instead of full lists or multi-page v2 cursors. Home now uses
listRootSessionsWindow(50 roots per page on v1/v2),SessionLiveStore.loadMoregrows the window on scroll, andSessionListSnapshot.hasMoredrives infinite scroll with a footer skeleton.Busy sub-agent roll-up no longer walks every listed session:
SessionAncestrylearns parent links from windows and fetches missing parents one at a time;SessionActivitySnapshot.homeActivityByRootpicks the status row per root;HomeSessionRowsmerges the window with active roots outside it. Row assembly runs off the main thread viaobserveHomeRows/homeRowsDispatcher.UI/product: scope tabs use
hasSessionsinstead of session counts (dock, picker, worktrees, strings). Filter empty-state logic and gallery/tests follow the same model.Reviewed by Cursor Bugbot for commit 9484edb. Bugbot is set up for automated code reviews on this repo. Configure here.