Skip to content

fix(renderer): keep fenced details tags literal in release notes - #1270

Merged
iruriQ merged 1 commit into
mainfrom
fix/issue-1266
Nov 27, 2026
Merged

iruriQ merged 1 commit into
mainfrom
fix/issue-1266

Conversation

@iruriQ

@iruriQ iruriQ commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • <details> 收集器复用代码渲染器的围栏规则;收集围栏内的内容时,不把字面量 <details> 和 </details> 计入嵌套深度。
  • 回归测试同时检查原样保留的 HTML 代码、真正的嵌套折叠块,以及围栏后的文本和折叠块外的文本各自位于正确位置。

Related issues

Fixes #1266

UI Demo

在 macOS 上用无头 Chrome 渲染实际 Renderer 解析器和样式的脱敏示例。左侧未展开,右侧展开后可见完整代码及折叠块内的后续内容。

折叠与展开状态

Test plan

  • npx vitest run --config tests/vitest.config.js packages/renderer-extension/test/settings/release-notes.test.ts:新增用例在修复前失败,修复后 4 个测试全部通过。
  • npx tsc -b packages/renderer-extension:通过。
  • 已检查独立 Chrome 预览截图;未启动 Codex Desktop 或共享 Host。

@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

  • Bug 修复
    • 修复了展开内容中代码围栏内的 <details> 标签被误识别为折叠区块的问题。
    • 嵌套的折叠区块仍可正常解析,外层区块结束后的段落也会正确显示在区块之外。

更新 release notes 的 details 内容收集逻辑,使其在代码围栏内忽略 details 标签。新增测试覆盖围栏代码、嵌套 details 和 details 块外的段落。

Changes: details 围栏解析

Layer / File(s) Summary
围栏内的 details 标签处理
packages/renderer-extension/src/settings/release-notes.ts, packages/renderer-extension/test/settings/release-notes.test.ts
appendDetails 现在跟踪代码围栏状态,仅在围栏外识别嵌套的 <details> 和关闭标签。新增测试验证围栏代码文本、嵌套 details 展示状态及块外段落。

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

Change: Bug fix · Severity of issue fixed: Low

Suggested labels: 类型:缺陷修复

Suggested reviewers: bytepioneer-ai

Merge Risk: Minimal · up to a581f

Release notes with literal details tags inside fenced code now stay inside the correct disclosure block, and nested disclosures are preserved. No merge-blocking risk was identified.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed 标题“fix(renderer): keep fenced details tags literal in release notes”与变更内容直接相关。变更使 release-notes 解析器在代码围栏内忽略字面量
Details 和
标签,标题准确描述了这一主要修复。标题为英文,与仓库中其他标题的语言未作核对,但这不影响相关性判断。
Description check Passed 描述说明了修复的内容:
Details 收集器复用代码渲染器的围栏规则,不再把围栏内的字面量标签计入嵌套深度。描述还列出了回归测试覆盖的场景、关联的 Issue #1266、测试命令及 UI 示例。描述与变更集高度相关。
Linked Issues check Passed [#1266] 要求:在收集 <details> 内容时维护 inFence 状态,忽略围栏内的 <details> 与 </details>,并新增回归测试。

证据:
- release-notes.ts 的 appendDetails 在 head 中维护 inFence。遇到 FENCE_PATTERN 行时切换状态。仅在围栏外统计 `DETAILS_OPE…
Out of Scope Changes check Passed 变更仅涉及两个文件:packages/renderer-extension/src/settings/release-notes.ts 与 packages/renderer-extension/test/settings/release-notes.test.ts。

- appendDetails 的围栏状态跟踪直接实现 #1266。
- 新增测试直接验证该修复的行为。
- PR …
Full details: Linked Issues check

Explanation

[#1266] 要求:在收集 &lt;details&gt; 内容时维护 inFence 状态,忽略围栏内的 &lt;details&gt; 与 &lt;/details&gt;,并新增回归测试。

证据:

  • release-notes.ts 的 appendDetails 在 head 中维护 inFence。遇到 FENCE_PATTERN 行时切换状态。仅在围栏外统计 DETAILS_OPEN_PATTERN 与 DETAILS_CLOSE_PATTERN。因此围栏内的字面标签不改变 depth。
  • 围栏行和围栏内行仍按 depth &gt; 0 写入 innerLines,原始 HTML 文本得以保留。
  • release-notes.test.ts 新增用例 keeps literal details tags inside fenced code。该用例验证:代码块内容为 language-html 的 code.textContent;围栏后的嵌套 details 保持为可展开元素;外层结束标签后的段落位于 details 外。
  • 未直接读取 PR 描述中的测试运行结果。该结果不影响代码证据的判断。

结论:所有编码要求均有对应实现和测试。

Full details: Out of Scope Changes check

Explanation

变更仅涉及两个文件:packages/renderer-extension/src/settings/release-notes.ts 与 packages/renderer-extension/test/settings/release-notes.test.ts。

  • appendDetails 的围栏状态跟踪直接实现 #1266。
  • 新增测试直接验证该修复的行为。
  • PR 描述中的 UI 示例仅用于说明,不引入代码变更。

未发现与 #1266 无关的代码变更。

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • 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 d0b0892 and a581fb6.

Files selected for processing: 2

  • packages/renderer-extension/src/settings/release-notes.ts
  • packages/renderer-extension/test/settings/release-notes.test.ts

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

Recent review details

Context from checks skipped due to timeout: 8

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

Code guidelines: 2

CLAUDE.md — auto-discovered
AGENTS.md — auto-discovered
Path-based instructions: 2

Source excerpt: `renderer-extension` must not import Node.js built-ins, Electron private APIs, or Harness SDKs.

CodeRabbit inference engine (CLAUDE.md)

Files:

  • packages/renderer-extension/src/settings/release-notes.ts
  • packages/renderer-extension/test/settings/release-notes.test.ts
Source excerpt: Use package public exports for cross-package dependencies.

CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/renderer-extension/src/settings/release-notes.ts
  • packages/renderer-extension/test/settings/release-notes.test.ts
Learnings: 1

Common learnings

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

## Testing & Completion

- Writing tests. Every test is code to maintain and CI time to pay; add one only when it earns that.
  - Small, low-risk changes need no new tests. Add focused tests for high-risk or cross-package changes, or when asked.
  - A new test must catch a regression the existing tests would miss. Extend the nearest existing case or `test.each` instead of adding near-duplicates.
  - Assert observable behavior (inputs, outputs, protocol messages, persisted state), not internal call order, private state, or mock call counts.
  - Mock only external boundaries (network, clock, real CLIs, the OS), never the code under test. Avoid large snapshots and long literal expectations that can only be updated mechanically.
  - A bug-fix test must fail before the fix. Never weaken assertions or delete tests just to make a change pass; report the conflict instead.
  - When a change makes existing tests redundant or ties them to removed internals...
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

- Writing tests. Every test is code to maintain and CI time to pay; add one only when it earns that.
  - Small, low-risk changes need no new tests. Add focused tests for high-risk or cross-package changes, or when asked.
  - A new test must catch a regression the existing tests would miss. Extend the nearest existing case or `test.each` instead of adding near-duplicates.
  - Assert observable behavior (inputs, outputs, protocol messages, persisted state), not internal call order, private state, or mock call counts.
  - Mock only external boundaries (network, clock, real CLIs, the OS), never the code under test. Avoid large snapshots and long literal expectations that can only be updated mechanically.
  - A bug-fix test must fail before the fix. Never weaken assertions or delete tests just to make a change pass; report the conflict instead.
  - When a change makes existing tests redundant or ties them to removed internals...

@iruriQ
iruriQ merged commit 6229d8d into main Nov 27, 2026
7 of 8 checks passed
@iruriQ
iruriQ deleted the fix/issue-1266 branch November 27, 2026 01:07
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.

[Bug] Release Notes 折叠块解析器在围栏代码块内出现 </details> 时会提前闭合

2 participants