Skip to content

fix(qoder-cn): 解析新版 Qoder CN(com.qodercn.app.stable)的 ~/.qoder-cn/projects JSONL 会话 - #586

Merged
xiufengsun merged 1 commit into
xiufengsun:mainfrom
Hu9956:fix/qoder-cn-new-jsonl
Sep 7, 2026
Merged

fix(qoder-cn): 解析新版 Qoder CN(com.qodercn.app.stable)的 ~/.qoder-cn/projects JSONL 会话#586
xiufengsun merged 1 commit into
xiufengsun:mainfrom
Hu9956:fix/qoder-cn-new-jsonl

Conversation

@Hu9956

@Hu9956 Hu9956 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

背景

PR #549 修复了国际版新版 Qoder(com.qoder.app.stable)的 JSONL 会话追踪,并为 CN 预留了完整的接线(sync 块、qoderCnNew 游标、status 展示),但当时假设 CN 与国际版共享 ~/.qoder/projectsresolveQoderCnProjectsDir 的默认值也指向了国际目录。

实测新版 Qoder CN(com.qodercn.app.stable,app 0.1.8 / agent 1.1.44)把会话写在兄弟目录 ~/.qoder-cn/projects,于是 sync.js / status.js 中「CN 目录与国际目录分离才解析」的防重复守卫恒为假——新版 CN 的 usage 从未被解析(而旧 CN 库 QoderCN/SharedClientCache/cache/db/local.db 已于 2026-08 停写,CN 计数就此断流)。

改动

  • resolveQoderCnProjectsDir 默认改 ~/.qoder-cn/projectsQODER_CN_PROJECTS_DIR 仍可覆盖;Windows WSL 探测 .qoder-cn);QODER_HOME / QODER_PROJECTS_DIR(国际版专属)不会影响 CN 解析
  • 剥离 CN BYOK 模型 id 内嵌的安装级 provider UUID(qoder-custom-<uuid>/glm-5.3-flashglm-5.3-flash),桶键跨重装稳定、不按用户碎片化;官方 id(qmodel_*)原样保留
  • sync.js / status.js 逻辑零改动,仅更新过时注释(目录修正后守卫自动生效)
  • 测试 +3:CN 目录默认/覆盖回归(含「CN ≠ 国际」不变量)、CN 真实形态端到端(Anthropic 语义精确 token、流式重复 message id 去重、subagent transcript、无 usage 的 auto 行跳过、二次同步幂等)

验证

  • npm test:2643 项 / 2635 过;6 个失败为 upstream/main 基线同集合的环境性失败(stash 对比确认,零回归)
  • 真机只读端到端(macOS,CN 真实数据):41 个会话文件 → 1237 条 usage → 22 个桶;与独立脚本复算逐位一致(input 327,343,057 / cache_read 322,214,912 / cache_creation 0 / output 842,875 / 总 650,400,844);二次同步 0 桶
  • 旧版回退安全:迁移导入的 24 个旧会话 JSONL 均无 usage 行,不会与旧库已入库数据重复计数

Summary by CodeRabbit

  • Bug Fixes
    • Qoder CN projects are now read from the separate ~/.qoder-cn/projects directory, preventing duplicate reporting with international projects.
    • CN usage reports now consistently recognize BYOK model identifiers and group usage under the underlying model name.
    • Improved handling of cached-token usage, streamed duplicate messages, and automatic model rows in CN session data.

The new CN app (com.qoder.app.stable sibling com.qodercn.app.stable,
2026-08+) stopped writing SharedClientCache/local.db and now writes
Claude-style session JSONL under ~/.qoder-cn/projects. PR xiufengsun#549 assumed
CN shared ~/.qoder/projects with the international edition, so
resolveQoderCnProjectsDir pointed at the international directory and
the CN-dir-diverges guard in sync.js/status.js always skipped parsing —
new-version CN usage was silently untracked (legacy DB stalled 2026-08).

- resolveQoderCnProjectsDir now defaults to ~/.qoder-cn/projects
  (QODER_CN_PROJECTS_DIR still overrides; WSL probes .qoder-cn)
- strip the install-local BYOK provider UUID from CN model ids
  (qoder-custom-<uuid>/glm-5.3-flash -> glm-5.3-flash) so bucket keys
  stay stable instead of fragmenting per user
- tests: CN default/override resolver regression + end-to-end CN parser
  case (precise Anthropic-style usage, streamed duplicate message ids,
  subagent transcripts, 'auto' rows without usage)
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 355f9e60-653d-4644-8730-8692ecec384a

📥 Commits

Reviewing files that changed from the base of the PR and between 271bbd8 and d334b0d.

📒 Files selected for processing (4)
  • src/commands/status.js
  • src/commands/sync.js
  • src/lib/rollout.js
  • test/qoder-new-parser.test.js

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

Qoder CN project resolution now uses ~/.qoder-cn/projects. BYOK model identifiers are normalized without provider UUID prefixes. Tests cover path selection, token aggregation, duplicate messages, and repeated synchronization.

Changes

Qoder CN session handling

Layer / File(s) Summary
Separate CN resolution and model normalization
src/lib/rollout.js, src/commands/status.js, src/commands/sync.js
CN sessions use ~/.qoder-cn/projects, with directory divergence checks documented. BYOK UUID prefixes are removed before model normalization.
Resolver and incremental parser coverage
test/qoder-new-parser.test.js
Tests cover CN path precedence, Anthropic cache-token aggregation, duplicate message suppression, BYOK bucket keys, cursor handling, and no-op reprocessing.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to d334b

此变更将新版 Qoder CN 会话发现切换到独立目录,并稳定化 BYOK 模型统计键。现有覆盖验证了目录隔离、解析聚合、去重与重复同步无新增数据,当前可合并。

Suggested reviewers: kewen-dev

Sequence Diagram(s)

sequenceDiagram
  participant CNSessionFiles
  participant parseQoderNewIncremental
  participant qoderNewModelFromRecord
  participant BucketAndCursorState
  CNSessionFiles->>parseQoderNewIncremental: Provide CN transcript and subagent JSONL rows
  parseQoderNewIncremental->>qoderNewModelFromRecord: Normalize model identifier
  qoderNewModelFromRecord->>BucketAndCursorState: Use bare model id and preserve cursor identifier
  parseQoderNewIncremental->>BucketAndCursorState: Aggregate usage and update cursor
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: fixing parsing for the new Qoder CN JSONL sessions stored in ~/.qoder-cn/projects.
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: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. (1 skipped: 1 too large.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@xiufengsun
xiufengsun merged commit 5d6d214 into xiufengsun:main Sep 7, 2026
8 checks passed
@xiufengsun

Copy link
Copy Markdown
Owner

已通过 #589 合并,保留了你的原始提交。已验证 CN 独立目录、BYOK 模型归一化、去重及重复同步幂等性,完整回归和跨平台 CI 均通过。无需再修改;本次尚未发布新的 npm/桌面版本,谢谢!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants