Skip to content

fix(web): sort and date sessions by conversation recency - #1297

Merged
iruriQ merged 2 commits into
BytePioneer-AI:mainfrom
zxd-666:fix/web-session-activity-time
Nov 28, 2026
Merged

iruriQ merged 2 commits into
BytePioneer-AI:mainfrom
zxd-666:fix/web-session-activity-time

Conversation

@zxd-666

@zxd-666 zxd-666 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem

An imported Codex conversation could finish yesterday but appear as “just now” at the top of the Web sidebar after its history or metadata was written today. The catalog requested updated_at, and Web list summaries and opened-session projections also used updatedAt, even when the Host supplied an older recencyAt.

Changes

  • Request native catalog pages in recency_at order and merge native/external rows using the same activity timestamp.
  • Use recencyAt ?? updatedAt for local and remote session labels, recent ordering, remote search results, and opened-session list metadata. Catalog updates notice recency-only changes without rebroadcasting metadata-only timestamp changes.
  • Preserve native updatedAt for history and usage refreshes. Missing/null recency falls back to the existing timestamp; zero remains a valid timestamp.
  • Type the optional recency field in snapshot/remote row contracts and align the existing feature documentation.

Validation

  • Confirmed the new local/remote regressions fail on the baseline because metadata update time is projected as conversation activity; catalog expectations also fail on the baseline's updated_at query.
  • npx vitest run --config tests/vitest.config.js packages/host-runtime/test/thread-catalog.test.ts — 20 passed.
  • npx vitest run --config tests/vitest.config.js packages/host-runtime/test/app-server-host.thread-catalog.test.ts — 6 passed after aligning all public-entry, cold-start, archive, and repeat-read sort-key expectations.
  • node --import tsx --test packages/web-server/test/ch-list-summary.test.ts packages/web-server/test/ch-catalog-updates.test.ts packages/web-server/test/remote-sessions.test.ts — 58 passed.
  • Targeted TypeScript builds completed for the affected packages and their dependencies (packages/host-runtime and packages/web-server).
  • npm run build:web:ui completed. Manually opened the real Web UI through an isolated synthetic CDP fixture in Chrome: the recent conversation appears first, the older conversation shows “1天”, and opening its history preserves that label and order. No live Harness turn or user data was used.
  • git diff --check passed. Full repository checks are left to CI.

Demo

Both synthetic conversations have the same current metadata update time; their conversation activity is approximately five minutes ago and one day ago. Screenshot captured and visually inspected after opening the older conversation.

Web sidebar preserves conversation recency after opening older history

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • 功能优化
    • 会话列表和搜索结果现按最近活动时间显示时间并排序;缺少最近活动时间时,回退到更新时间。
    • 官方线程列表及分页现按最近活动时间排序;会话详情中的最近活动时间与列表保持一致。

会话最近活动时间通过 recencyAt 表示;缺少该值时使用 updatedAt。官方目录排序、本地与远程会话时间投影及相关测试和文档已更新为该规则。

Changes: 会话最近活动时间

Layer / File(s) Summary
最近活动时间字段与换算
packages/shared-contracts/src/client-channel.ts, packages/shared-contracts/src/thread-catalog.ts, packages/web-server/src/ch-thread-view.ts, packages/web-server/src/remote-session-history.ts, packages/web-server/src/ch-thread-time.ts
线程数据结构增加可选的 recencyAt。threadRecencyMs 优先使用该值,否则使用 updatedAt,并将秒换算为毫秒。
官方目录按最近活动时间排序
packages/host-runtime/src/thread-catalog.ts, packages/host-runtime/test/thread-catalog.test.ts, packages/host-runtime/test/app-server-host.thread-catalog.test.ts, docs/architecture/host-client-channel.md
官方目录请求和条目使用 recency_at 排序。测试覆盖排序、回退规则及分页排序键,架构文档同步更新。
会话列表与远程搜索时间投影
packages/web-server/src/ch-sessions.ts, packages/web-server/src/ch-thread-view.ts, packages/web-server/src/remote-sessions.ts, packages/web-server/test/ch-list-summary.test.ts, packages/web-server/test/remote-sessions.test.ts, docs/product/standalone-web.md
本地和远程会话的列表时间、lastPromptAt 及远程搜索排序使用最近活动时间。测试覆盖回退、零值和原始 updatedAt 保留;产品文档补充时间规则与目录读取说明。

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

Change: Bug fix

Suggested reviewers: bytepioneer-ai

Merge Risk: Minimal · up to 1a9ea

Session labels and ordering now follow conversation activity, falling back to the update time when recency is missing. No concrete merge-blocking risk was found; the native server's handling of the recency sort key was not verifiable from the repository.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题“fix(web): sort and date sessions by conversation recency”概括了主要变更:Web 会话的排序与时间标签改用会话最近活动时间(recencyAt,回退到 updatedAt)。原始变更摘要显示目录分页键、ch-thread-time、ch-sessions、remote-sessions 等文件都围绕该主题修改,标题与变更集一致。
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.
Description check Passed PR 描述与变更集高度相关。描述说明了问题(导入的 Codex 会话在 Web 侧边栏按 updatedAt 错误排序和显示时间)、具体改动(目录分页改用 recency_at、recencyAt ?? updatedAt 回退、类型与文档更新)以及验证步骤。这些内容与原始摘要中的文件级变更(thread-catalog.ts、ch-thread-time.ts、ch-sessions.ts、re…
Full details: Description check

Explanation

PR 描述与变更集高度相关。描述说明了问题(导入的 Codex 会话在 Web 侧边栏按 updatedAt 错误排序和显示时间)、具体改动(目录分页改用 recency_at、recencyAt ?? updatedAt 回退、类型与文档更新)以及验证步骤。这些内容与原始摘要中的文件级变更(thread-catalog.ts、ch-thread-time.ts、ch-sessions.ts、remote-sessions.ts、client-channel.ts 等)一致。

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

@iruriQ

iruriQ commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

感谢补充 recencyAt 排序修复!复审发现两处需要在合入前同步处理:

  1. Vitest 单测失败:packages/host-runtime/test/app-server-host.thread-catalog.test.ts:35 还有 2 处 sortKey 断言未同步更新,导致 Vitest 真实失败(Static checks 里的其余报错为 main 既有噪声,可忽略)。
  2. remote-sessions.ts 协调:待上述单测补齐并等主干近期 remote-sessions.ts 改动落地后,我们会安排真实 Codex/导入会话的隔离实测并推进合并。

@iruriQ iruriQ added the awaiting-author Waiting for the author to respond or update the PR. label Nov 27, 2026
@zxd-666

zxd-666 commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

@iruriQ 感谢复审,已按反馈补齐并推送 1a9eaf1。

  • 我方修复:app-server-host.thread-catalog.test.ts 两个用例中共 4 处旧断言已全部改为 recency_at,覆盖公开入口、冷启动、归档分支与重复读取。先复现原状态为 4 通过/2 失败,修复后该文件 6 项全部通过。还检查了其余 catalog 测试,没有遗留的 updated_at 排序断言。
  • 主干协调:已核对最新 main(fcceaeae5),远程 Peer 直接命令改动 f5ecfdf0a 已落地;本 PR 与该主干的合并预检没有文本冲突。本次补丁只改测试,没有重写 remote-sessions.ts,也没有合入其他主干改动。
  • 请上游按原计划安排真实 Codex/导入会话的隔离验收,重点确认原生 recency_at 分页可用,以及更新或重新打开旧历史后时间标签和顺序保持按最后会话时间。其余 Static checks 问题仍按你方复审结论由主干侧统一协调,本 PR 保持会话时间修复范围。

PR 描述已补充本次针对性验证,原有脱敏页面演示仍适用。

zxd-666 commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

@iruriQ 补充 #1297 最新 CI 结果。你指出的 app-server-host.thread-catalog.test.ts 现在 6 项全部通过。全仓 Vitest 的 6 条失败都在 renderer-binding-probe-host-catalog.test.ts,错误是 node.matches is not a function,已经逐项和 main 的日志核对,测试名和错误一致。 #1297 Vitest · main Vitest

麻烦将这个 Renderer 测试问题和已确认的 Static checks 一并在主干处理。#1297 仍可按原计划安排真实 Codex 和导入会话的隔离验收。

@iruriQ
iruriQ merged commit 1d196b0 into BytePioneer-AI:main Nov 28, 2026
6 of 8 checks passed
@iruriQ

iruriQ commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

感谢补齐 thread-catalog 断言并持续跟进,已合并到 main!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-author Waiting for the author to respond or update the PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants