fix(sidebar): fix session list block (#1762)#1772
Conversation
侧边栏只展示 regular 会话,但分页请求携带 includeSubagents:true, 使一页 30 条结果混入子代理会话并被显示层过滤,导致可见会话远少于一页。 改为 includeSubagents:false,让后端按 session_kind='regular' 分页。 Refs #1762
首屏返回的 regular 会话过少时列表内容不足以撑出滚动条,scroll 事件 永不触发,loadNextPage 永远不会被调用。新增 ensureSessionListFilled, 加载/过滤变化后检测视口是否填满,未满且仍有更多数据则继续加载, 并以重入锁与轮数上限兜底。 Closes #1762
📝 WalkthroughWalkthroughThis PR fixes sidebar history pagination getting stuck (issue ChangesSidebar History Pagination Fix
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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.
🧹 Nitpick comments (1)
docs/issues/sidebar-history-pagination-stuck/plan.md (1)
40-49: ⚡ Quick winSplit the sidebar FTS search work out of this pagination-fix issue.
T3 is a separate feature with its own backend/API surface, so keeping it in the same spec/plan/tasks makes this PR read as if it includes search work even though the current fix is about pagination and viewport auto-fill. Please move the FTS item to its own issue doc, or mark it explicitly out-of-scope here.
docs/issues/sidebar-history-pagination-stuck/plan.md#L40-L49: move T3 into a separate plan or mark it as future work only.docs/issues/sidebar-history-pagination-stuck/spec.md#L34-L37: trim the user story to the pagination fix unless search is actually in scope.docs/issues/sidebar-history-pagination-stuck/tasks.md#L21-L27: remove T3 from this task list or point it at the separate search issue.🤖 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 `@docs/issues/sidebar-history-pagination-stuck/plan.md` around lines 40 - 49, The sidebar FTS search enhancement (Change 3 / T3) is a separate feature that should not be part of this pagination-fix issue. In docs/issues/sidebar-history-pagination-stuck/plan.md lines 40-49, remove or mark the FTS search work as explicitly out-of-scope future work rather than a deliverable of this issue. In docs/issues/sidebar-history-pagination-stuck/spec.md lines 34-37, trim the user story to focus only on the pagination and viewport auto-fill fix, removing any search-related requirements. In docs/issues/sidebar-history-pagination-stuck/tasks.md lines 21-27, remove task T3 from the task list entirely or replace it with a reference to a separate search issue if one will be created, so this PR is clearly scoped to pagination work only.
🤖 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.
Nitpick comments:
In `@docs/issues/sidebar-history-pagination-stuck/plan.md`:
- Around line 40-49: The sidebar FTS search enhancement (Change 3 / T3) is a
separate feature that should not be part of this pagination-fix issue. In
docs/issues/sidebar-history-pagination-stuck/plan.md lines 40-49, remove or mark
the FTS search work as explicitly out-of-scope future work rather than a
deliverable of this issue. In
docs/issues/sidebar-history-pagination-stuck/spec.md lines 34-37, trim the user
story to focus only on the pagination and viewport auto-fill fix, removing any
search-related requirements. In
docs/issues/sidebar-history-pagination-stuck/tasks.md lines 21-27, remove task
T3 from the task list entirely or replace it with a reference to a separate
search issue if one will be created, so this PR is clearly scoped to pagination
work only.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 90ed45c1-2537-4bd8-adda-0708abee4a45
📒 Files selected for processing (7)
docs/issues/sidebar-history-pagination-stuck/plan.mddocs/issues/sidebar-history-pagination-stuck/spec.mddocs/issues/sidebar-history-pagination-stuck/tasks.mdsrc/renderer/src/components/WindowSideBar.vuesrc/renderer/src/stores/ui/session.tstest/renderer/components/WindowSideBar.test.tstest/renderer/stores/sessionStore.test.ts
问题
Closes #1762
用户数据库中有 100+ 个 regular 会话(数据完整、schema 正常),但侧边栏只显示最近十几个,滚动到底部不触发"加载更多",搜索也找不到未加载的旧会话。
根因
两个相互叠加的缺陷:
listLightweight时传includeSubagents: true,使一页 30 条混入session_kind = 'subagent'的会话;但显示层只渲染 regular 会话(isRegularSession),被子代理占用的名额直接消失,可见会话远少于 30。performSessionListScrollCheck仅在scroll事件中触发。首屏 regular 会话太少时内容高度 < 容器高度,没有可滚动空间,scroll永不触发,loadNextPage()永远不被调用。改动
stores/ui/session.ts:首屏与翻页分页请求includeSubagents: true → false,让后端按WHERE session_kind='regular'分页,页槽不再被子代理会话浪费。components/WindowSideBar.vue:新增ensureSessionListFilled(),加载/过滤变化后检测scrollHeight <= clientHeight && hasMore,未填满则循环loadNextPage()直到填满或无更多数据;带重入锁 + 50 轮上限 + "无新增即停"兜底。主进程 4 处
includeSubagents: true走.list()(agent 迁移/删除/级联删),与本修复无关,未改动。行为对比
测试
sessionStore.test.ts:+3 例(首屏/翻页includeSubagents=false、cursor 推进与累积去重、hasMore=false不再请求)WindowSideBar.test.ts:+2 例(未填满视口持续加载至hasMore=false、无更多数据不自动加载)format/lint/architecture guard/typecheck通过后续
侧边栏搜索接入后端 FTS(命中未加载的历史会话)按计划留作独立后续 PR,不阻塞本次根治。
SDD
docs/issues/sidebar-history-pagination-stuck/(spec / plan / tasks)🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Documentation
Tests