Skip to content

fix(web): 项目续页的重试保留范围、大页合并提速 / keep a project page's scope on retry and merge large pages quickly - #1097

Merged
iruriQ merged 1 commit into
BytePioneer-AI:mainfrom
sduhantao-maker:fix/web-load-more-followups
Nov 23, 2026
Merged

iruriQ merged 1 commit into
BytePioneer-AI:mainfrom
sduhantao-maker:fix/web-load-more-followups

Conversation

@sduhantao-maker

Copy link
Copy Markdown
Contributor

摘要

#1081 的后续修复,处理 CodeRabbit 在 #1081 上提出、核对后成立的三条意见:

  • 重试保留项目范围。 项目续页失败后,列表状态记录这次请求的工作区 ID(errorWorkspaceId / listErrorWorkspaceId),列表错误的「重试」带上它重新读取,仍会读到该项目的会话。原来会改成普通的 20 条续页:错误消失,但项目的会话仍不出现。「最近」和远程项目的重试不带工作区 ID。
  • 大页合并提速。 项目续页一次可返回约 1000 行。mergeOrderedBaseline 为新行找插入位置时,对每个后续候选都执行一次 merged.findIndex 全表扫描。现在先用 mergedKeys 判断候选是否已合并,未合并的直接跳过,插入位置不变。
  • 文档。 写明只有读到官方目录末尾时「展开显示」才消失;读满 10 页仍没有该项目的会话时入口保留,再点一次从停下的位置接着读;失败后的重试仍按项目范围读取。

另外:

CodeRabbit 对 docs/product/standalone-web.md 的两条 LanguageTool 用字提示(「不读」「不齐」)是误报,未改。

关联 Issue

#1081 的后续(CodeRabbit 在该 PR 上的意见)。

测试

基于 main(33d36737),macOS 27.2.1(arm64),Node 26.0.0:

  • npx vitest run --config tests/vitest.config.js apps/web-ui/packages/api/session-controller/test/:2 个文件,15 个通过。archived-query.test.ts 原有 10 个用例在 Node 中全部通过。「keeps the page cursor on errors…」新增断言:项目续页失败时请求带 workspaceId,快照的 errorPage 为 more、errorWorkspaceId 为该项目,下一次成功续页后清空。去掉 manager.ts 的改动后,这条用例失败。
  • 合并基准:在本机用同一输入比较修改前后的 mergeOrderedBaseline,结果顺序相同。100 条新行加 20 条已加载行:7.7 ms → 1.6 ms;1000 条新行加 20 条已加载行:1149 ms → 23 ms。没有新增基于耗时的测试,合并顺序由已有用例覆盖。
  • 变基到最新 main 后,npm run build:web:ui 通过。改动文件 prettier --check 通过,tests/vitest.config.js 的 eslint 没有错误。用 apps/web-ui/tsconfig.base.json 对改动的两个 Web UI 包运行 tsc,错误列表与改动前相同。
  • 未测试:在真实 Web 中让续页失败后点重试(没有可控的失败注入);Windows。

Summary

Follow-up to #1081 for the three CodeRabbit comments on #1081 that hold after checking:

  • Retry keeps the project scope. When a project page fails, the list state records that request's Workspace ID (errorWorkspaceId / listErrorWorkspaceId), and the list error's "Retry" sends it again, so the retry still reads on to the project's Threads. Before, Retry fetched a plain 20-row page: the error went away, but the project's Threads still did not appear. Retries for Recents and remote projects send no Workspace ID.
  • Faster merges of large pages. A project page can return about 1,000 rows. To place each new row, mergeOrderedBaseline ran a full merged.findIndex scan for every following candidate. It now checks mergedKeys first and skips candidates that are not merged yet; insertion positions do not change.
  • Docs. "Show more" disappears only at the end of the official catalog. When 10 pages hold no Thread of the project, the entry stays and another click reads on from where the last one stopped. A retry after a failure keeps the project scope.

Also:

The two LanguageTool wording hints CodeRabbit posted on docs/product/standalone-web.md ("不读", "不齐") are false positives and are left unchanged.

Related issues

Follow-up to #1081 (CodeRabbit's comments on that PR).

Test plan

On main (33d3673), macOS 27.2.1 (arm64), Node 26.0.0:

  • npx vitest run --config tests/vitest.config.js apps/web-ui/packages/api/session-controller/test/: 2 files, 15 passed. All 10 existing cases in archived-query.test.ts pass in Node. "keeps the page cursor on errors…" gains assertions: a failed project page sends workspaceId, the snapshot has errorPage more and errorWorkspaceId set to the project, and the next successful page clears it. The case fails without the change to manager.ts.
  • Merge benchmark: the old and new mergeOrderedBaseline on the same input on this machine give the same order. 100 new rows plus 20 loaded rows: 7.7 ms → 1.6 ms; 1,000 new rows plus 20 loaded rows: 1,149 ms → 23 ms. No timing-based test was added; the merge order is covered by existing cases.
  • After rebasing on the latest main, npm run build:web:ui passes. prettier --check passes on the changed files, and eslint reports no errors on tests/vitest.config.js. Running tsc with apps/web-ui/tsconfig.base.json on the two changed Web UI packages gives the same error list as before the change.
  • Not tested: a failed project page followed by Retry in a real Web session (no controllable failure injection); Windows.

…quickly

Follow-up to BytePioneer-AI#1081.

- A failed project page now records its Workspace ID in the list state,
  and the list error's Retry reads on for that project again instead of
  fetching a plain page.
- mergeOrderedBaseline skips candidates that are not merged yet before
  scanning for an insertion anchor. A project page can bring about a
  thousand rows; merging 1,000 new rows before 20 known ones took about
  1.1 s and now takes about 23 ms, with the same order.
- The docs state that "Show more" disappears only at the end of the
  catalog, and that a click stopped by the 10-page bound needs another
  click.
- archived-query.test.ts mocks the Gateway browser export like
  prompt-delivery.test.ts, so it loads in Node and runs in CI.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • 修复
    • 分页加载失败后,重试会保留对应的工作区上下文;分页成功后会清除相关错误状态。
    • 本机项目会话仍未找到时,「展开显示」入口会保留,并可从上次停止的位置继续读取;到达目录末尾后入口才会消失。
  • 文档
    • 更新了共享会话目录续页行为的说明。

会话列表分页请求使用 WorkspaceId 表示工作区。分页失败状态记录对应工作区,重试时沿用该工作区。测试覆盖此请求与状态传递;产品文档也更新了续页入口的说明。

Changes: 工作区分页失败重试

层 / 文件 摘要
请求类型与失败请求范围
apps/web-ui/packages/api/session-controller/src/types.ts、apps/web-ui/packages/api/session-controller/src/client/contract/sessions.ts、apps/web-ui/packages/api/session-controller/src/client/sessions/manager.ts、apps/web-ui/packages/api/session-controller/src/client/ordered-baseline.ts
请求参数和 loadMore 使用 WorkspaceId。管理器记录请求的工作区,并在快照中提供 errorWorkspaceId。ordered-baseline.ts 新增注释,说明插入锚点须为已合并的身份。
错误状态传递与分页重试
apps/web-ui/packages/api/session-controller/src/client/sessions/{manager,service}.ts、apps/web-ui/packages/client/ui-workspace/src/client/rows/SessionListError.tsx、apps/web-ui/packages/api/session-controller/test/archived-query.test.ts、tests/vitest.config.js、docs/product/standalone-web.md
服务层将错误工作区写入列表状态。分页错误行重试时传入该工作区;测试验证请求工作区、游标、错误状态及分页完成后的重置。Vitest 配置纳入该测试。文档将续页入口的消失条件描述为读到官方目录末尾。

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant SessionListError
  participant ClientSessions
  participant SessionManager
  SessionListError->>ClientSessions: 重试并传入 listErrorWorkspaceId
  ClientSessions->>SessionManager: loadMore(workspaceId)
  SessionManager-->>ClientSessions: 返回含 errorWorkspaceId 的列表快照
  ClientSessions-->>SessionListError: 更新分页错误状态
Loading

Possibly related PRs

Suggested reviewers: bytepioneer-ai, ash521

Merge Risk: Minimal · up to b9095

This change makes Retry after a failed project-page load keep the project scope, and it clarifies the related documentation. No actionable merge-blocking risk was found. The author did not test the retry flow in a real Web session or on Windows.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题“fix(web): 项目续页的重试保留范围、大页合并提速 / keep a project page's scope on retry and merge large pages quickly”准确概括了主要改动:项目续页失败后重试保留工作区范围(manager.ts、service.ts、SessionListError.tsx 等),并包含 mergeOrderedBaseline 的…
Description check Passed 描述与变更集高度相关:说明了 errorWorkspaceId/listErrorWorkspaceId 的重试范围保留、mergeOrderedBaseline 的 mergedKeys 优化及基准数据、文档中“展开显示”的说明、archived-query.test.ts 的 mock 与 vitest include 变更,以及 WorkspaceId 类型收紧。描述还列出了测试计划和未测试…
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.
Full details: Title check

Explanation

标题“fix(web): 项目续页的重试保留范围、大页合并提速 / keep a project page's scope on retry and merge large pages quickly”准确概括了主要改动:项目续页失败后重试保留工作区范围(manager.ts、service.ts、SessionListError.tsx 等),并包含 mergeOrderedBaseline 的性能优化。标题涵盖两个主要变更,属于与变更集完全相关。标题较长(97 字符),但未包含文件列表或模糊用词。

Full details: Description check

Explanation

描述与变更集高度相关:说明了 errorWorkspaceId/listErrorWorkspaceId 的重试范围保留、mergeOrderedBaseline 的 mergedKeys 优化及基准数据、文档中“展开显示”的说明、archived-query.test.ts 的 mock 与 vitest include 变更,以及 WorkspaceId 类型收紧。描述还列出了测试计划和未测试项。

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Fix failing CI checks

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 33d3673 and b9095c0.

Files selected for processing: 9

  • apps/web-ui/packages/api/session-controller/src/client/contract/sessions.ts
  • apps/web-ui/packages/api/session-controller/src/client/ordered-baseline.ts
  • apps/web-ui/packages/api/session-controller/src/client/sessions/manager.ts
  • apps/web-ui/packages/api/session-controller/src/client/sessions/service.ts
  • apps/web-ui/packages/api/session-controller/src/types.ts
  • apps/web-ui/packages/api/session-controller/test/archived-query.test.ts
  • apps/web-ui/packages/client/ui-workspace/src/client/rows/SessionListError.tsx
  • docs/product/standalone-web.md
  • tests/vitest.config.js

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Recent review details

Context from checks skipped due to timeout: 8

  • GitHub Check: CodeRabbit
  • GitHub Check: Check Linux ARM64
  • GitHub Check: Check ubuntu-22.04
  • GitHub Check: Static checks
  • GitHub Check: Check macos-26
  • GitHub Check: Web Host tests
  • GitHub Check: Check windows-latest
  • GitHub Check: Vitest
Additional context used

Code guidelines: 1

AGENTS.md — auto-discovered
Path-based instructions: 1

Source excerpt: Do not write browser, e2e, or component tests for Web pages (`apps/web-ui`); the user checks page changes directly.

CodeRabbit inference engine (AGENTS.md)

Files:

  • apps/web-ui/packages/api/session-controller/src/client/contract/sessions.ts
  • apps/web-ui/packages/api/session-controller/src/client/ordered-baseline.ts
  • apps/web-ui/packages/api/session-controller/src/client/sessions/manager.ts
  • apps/web-ui/packages/api/session-controller/src/client/sessions/service.ts
  • apps/web-ui/packages/api/session-controller/src/types.ts
  • apps/web-ui/packages/api/session-controller/test/archived-query.test.ts
  • apps/web-ui/packages/client/ui-workspace/src/client/rows/SessionListError.tsx
Learnings: 3

Learning: 2026-11-23T14:09:43.936Z

Learnt from: CR
Repo: BytePioneer-AI/codex-host PR: 0
File: docs/product/standalone-web.md:0-0
Timestamp: 2026-11-23T14:09:43.936Z
Learning: Applicability reference:
AGENTS.md: # Repository Guidelines
## Testing & Completion
- `npm start` / `npm start web` rebuild and relaunch the user's Desktop / Web and may restart the shared Host; `npm stop` stops all local codexhost services across worktrees. Both interrupt running tasks: run them only when the user asks, never as validation. Details: `docs/product/standalone-web.md`.

Source excerpt:
# 独立 Web 应用

## 手机连接与恢复

浏览器控制台的 `[connection]` 记录提供后台停留时长、连接代次就绪耗时、WebSocket 建连耗时与关闭码,以及前台心跳探测的结果和耗时。关闭原因仅记录已知协议文案,其他对端文本记为 `unclassified`;日志不包含连接 URL、令牌、会话正文或任意对端错误文本。日志反映浏览器观察到的事实,异常关闭码本身不能区分手机系统、VPN 和中转网络故障。

Applied to files:

  • apps/web-ui/packages/api/session-controller/src/client/sessions/service.ts
Learning: 2026-11-17T12:08:52.064Z

Learnt from: CR
Repo: BytePioneer-AI/codex-host PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-11-17T12:08:52.064Z
Learning: Source excerpt:
# Repository Guidelines

## Testing & Completion

- Do not write browser, e2e, or component tests for Web pages (`apps/web-ui`); the user checks page changes directly. Codex Desktop compatibility after an update is checked with `npm run audit:codex-desktop` and `npm run probe:renderer-binding` (`codexhost-update-impact-audit`).

Applied to files:

  • apps/web-ui/packages/client/ui-workspace/src/client/rows/SessionListError.tsx
Learning: 2026-11-23T12:41:24.916Z

Learnt from: CR
Repo: BytePioneer-AI/codex-host PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-11-23T12:41:24.916Z
Learning: Applies to apps/web-ui/** : Source excerpt:
# Repository Guidelines

## Testing & Completion

- Do not write browser, e2e, or component tests for Web pages (`apps/web-ui`); the user checks page changes directly. Codex Desktop compatibility after an update is checked with `npm run audit:codex-desktop` and `npm run probe:renderer-binding` (`codexhost-update-impact-audit`).

Applied to files:

  • apps/web-ui/packages/client/ui-workspace/src/client/rows/SessionListError.tsx
LanguageTool

docs/product/standalone-web.md

[uncategorized] ~390-~390: 您的意思是“"不"读”?
Context: ...条探测本页未返回的旧会话。原生置顶独立并行读取,不在首批的置顶按 ID 有界并发补读摘要(includeTurns:false),与最近记录去重,保留原生置顶...

(BU)

[uncategorized] ~390-~390: 您的意思是“"不"齐”?
Context: ...deTurns:false`),与最近记录去重,保留原生置顶顺序;首批响应前完成补齐。完整项目定义独立获取,不依赖加载全部会话,不为项目计数扫描历史。Host 返...

(BU)

@iruriQ
iruriQ merged commit 09bd16e into BytePioneer-AI:main Nov 23, 2026
6 of 8 checks passed
@iruriQ

iruriQ commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

感谢迅速跟进 #1081 的后续优化!重试保留项目范围、mergeOrderedBaseline 大页合并提速(1149ms → 23ms)、文档补齐与 archived-query.test.ts 接入 CI 都很干净,现已合入 main。

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.

2 participants