Skip to content

fix(memory): share bounded highlighting with cancellable Markdown retries - #1117

Merged
xintaofei merged 4 commits into
spacering-net:mainfrom
kogekiplay:fix/memory-highlight-latest
Nov 10, 2026
Merged

xintaofei merged 4 commits into
spacering-net:mainfrom
kogekiplay:fix/memory-highlight-latest

Conversation

@kogekiplay

@kogekiplay kogekiplay commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Markdown、文件和工具代码视图原来各自保留 Shiki engine / token 缓存,流式代码的历史前缀会累计。这个 PR 共享一个惰性 Shiki engine,将完成结果按 16 MiB / 128 项 LRU 缓存,合并相同请求,不缓存 incomplete 前缀,并在视图更新和卸载时撤销订阅。

这是按 #1097 维护者建议拆出的第 3 批,直接基于最新官方 main:5c03d7af865f54cf42a994327daf2c45ab4a946f。可独立安装,依赖配置仅携带本批 Streamdown 生命周期补丁。

这次补齐维护者指出的饱和问题:

  • Markdown 调用的 callback API 也会在 16 个 in-flight 请求腾出容量后重试,包括重试时结果已缓存的情况。
  • Streamdown 2.7.0 的真实高亮组件通过可选 AbortSignal 通知代码/语言/主题变更及卸载;其他插件可以忽略这个新选项,现有接口仍兼容。
  • 每个挂载中的代码视图只有一个当前等待项,流式替换/卸载立即移除旧等待项和 callback。实际计算始终最多 16 个,等待项不保留 token tree 或额外 cache key,避免历史前缀积压。没有生命周期信号的 callback-only 调用另设 128 个等待项的上限,超出后保持纯文本。
  • 如果最后一个订阅者在 engine/grammar 加载期间消失,跳过这个已过期请求的 tokenization。

验证:

  • 删除此工作树的 node_modules 后重新 pnpm install --frozen-lockfile,确认 package patch 独立生效。
  • 真实 Streamdown + 真实 Shiki 的 24 个并发 Markdown 代码块全部收到高亮回调,in-flight 峰值为 16;真实组件替换及卸载都会 abort 请求。
  • 服务回归覆盖 200 次被替换的流式前缀、饱和后的挂载/卸载、缓存字节/项数预算、请求合并和旧 callback-only 调用的等待上限。
  • 完整 TypeScript(tsc --noEmit --incremental false,包含测试)、ESLint 和 production build 全部通过。
  • 最终全量 Vitest:765 个测试文件、11,372 项全部通过(vitest run --maxWorkers=3,默认超时)。初轮并行运行多个构建/测试时,activity-rows 与 forge-page 各有一项超时/等待失败;相同源码单独复跑相关文件和新增回归共 134 项通过,降低同时运行的编译任务后,最终完整轮次全部通过,未修改这些既有测试。

补丁与生命周期边界说明见 patches/README.md。

Refs #1097

…ile-view highlighting

pnpm-workspace.yaml now lists patches/streamdown@2.7.0.patch, so the
Dockerfile's frozen install aborted with ENOENT before patches/ was copied.

The shared highlighter's 100k-character plaintext cutoff also dropped
highlighting for source files the file view still shows (up to 512 KiB /
5,000 lines); align the cutoff with that view's ceilings.
…code

The shared highlighter replaced @streamdown/code, so nothing imports it.
Streamdown 2.7.1 only renames the highlighted-body chunk; its highlight
effect is unchanged, so the AbortSignal patch is carried over verbatim
(re-generated against the 2.7.1 tarball). The lockfile is edited to just
these packages: a plain install also re-resolved unrelated transitive
dependencies (micromark, parse5, overlayscrollbars-react).
@xintaofei

Copy link
Copy Markdown
Collaborator

codeg work task 498 is done — #1117 (8 files, +37/-31).

@xintaofei
xintaofei merged commit da23542 into spacering-net:main Nov 10, 2026
2 of 10 checks passed
xintaofei added a commit that referenced this pull request Nov 11, 2026
This release reduces memory growth during extended use, fixes missing collaboration tools in forked Codex conversations, restores skill selection for custom agents, and updates several agents.

## Improved

- **Claude Code is updated to 2.1.322 with adapter 0.106.0.**
- **Updated OpenCode to 2.2.7, Kimi Code to 2.5.3, Hermes Agent to 0.23.1 and the ZCode bridge to 0.83.3.**

## Fixed

- **Reduced memory buildup during repeated scrolling, view changes and streaming code generation**, improving memory usage during extended sessions. (#1114, #1115, #1117 by @kogekiplay)
- **Custom agents with a configured skill directory or shared skill store now list their skills in the `/` menu**, in both chat and automation editors. (#1121 by @ana52070)
- **Forked Codex conversations retain their enabled MCP tools**, allowing you to continue delegating work to sub-agents and retrieving their results. (#1105)
- **Reopening a conversation no longer adds duplicate context compaction cards after the existing history.**
- **OpenCode commands that time out or are terminated no longer incorrectly appear as successful.**
- **OpenCode file previews correctly display reads beyond the end of a file**, while reads counted from the end no longer show a misleading line range.
- **Reopening older ZCode conversations correctly restores their saved titles.**

Thanks to @kogekiplay (#1114, #1115, #1117) and @ana52070 (#1121) for their contributions, and to @lxpsxx (#1105) for the report.

-----------------------------

# 发布版本 0.42.3

这一版改善长时间使用时的内存占用,修复 Codex 分叉会话后协作工具丢失、自定义智能体无法选择技能等问题,并更新多个智能体。

## 改进

- **Claude Code 更新至 2.1.322,适配器更新至 0.106.0。**
- **OpenCode 更新至 2.2.7,Kimi Code 更新至 2.5.3,Hermes Agent 更新至 0.23.1,ZCode 桥接更新至 0.83.3。**

## 修复

- **减少反复滚动、切换视图和持续生成代码时的内存累积**,改善长时间使用时的内存占用。(#1114、#1115、#1117 by @kogekiplay)
- **配置了技能目录或共享技能库的自定义智能体,可以在 `/` 菜单中选择技能**,聊天输入框和自动化编辑器均可使用。(#1121 by @ana52070)
- **Codex 分叉会话后会保留已启用的 MCP 工具**,可以继续委派子智能体并获取执行结果。(#1105)
- **重新打开会话时,已有的上下文压缩卡片不会再重复出现在历史记录末尾。**
- **OpenCode 中超时或被终止的命令,不再被误标为执行成功。**
- **OpenCode 读取位置超出文件末尾时,返回内容仍能正确预览**,从文件末尾倒数读取时也不会再显示错误的行号范围。
- **重新打开较早的 ZCode 会话时,能正确恢复已保存的会话标题。**

感谢 @kogekiplay(#1114、#1115、#1117)和 @ana52070(#1121)的贡献,以及 @lxpsxx(#1105)的反馈。
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