Skip to content

feat: yakrunner AI 增加monaco删除/新增效果 - #4068

Merged
hubin4826 merged 1 commit into
masterfrom
hejiahui/yakrunnerCodePatch
Jul 31, 2026
Merged

feat: yakrunner AI 增加monaco删除/新增效果#4068
hubin4826 merged 1 commit into
masterfrom
hejiahui/yakrunnerCodePatch

Conversation

@hjhke

@hjhke hjhke commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

第二个合并方式

Copilot AI review requested due to automatic review settings July 30, 2026 08:04
@hjhke hjhke added the need more test 需要更多的测试 label Jul 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

PR CI 汇总

状态:全部通过

  • ✅ i18n(renderer src/main zh/zh-TW/en)
  • ✅ i18n(engine-link zh/zh-TW/en)
  • ✅ ESLint(renderer src/main)
  • ✅ TypeScript(renderer src/main)
  • ✅ ESLint(engine-link-startup)
  • ✅ TypeScript(engine-link-startup)
  • ✅ 图片/视频体积
  • ○ Vitest(main / renderer / engine-link;test 同目录·别名·相对路径)(skipped)
  • ✅ Prettier

由 pull_request test workflow 自动生成

@hjhke
hjhke force-pushed the hejiahui/yakrunnerCodePatch branch from 854e969 to 27f5e97 Compare July 30, 2026 10:02
@01XoX10 01XoX10 added ready and removed need more test 需要更多的测试 labels Jul 31, 2026
@hubin4826
hubin4826 requested a review from Copilot July 31, 2026 06:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (3)

app/renderer/src/main/src/pages/ai-agent/components/aiYaklangCode/AIYaklangCode.tsx:127

  • 配合上面稳定空数组的改动,这里应使用 hunks={emptyDiffHunks},避免每次 render 都传入新的 [] 触发 diff 组件内部更新。
                original={patchOriginal}
                incoming={patchIncoming}
                hunks={[]}
                onDecision={() => {}}
                language={diffLanguage}

app/renderer/src/main/src/pages/ai-agent/components/aiYaklangCode/AIYaklangCode.tsx:26

  • 注释描述与实现不一致:这里实际会跳过所有以 @@ 开头的 hunk 头行,但注释写的是“@@ 行两边都放”。建议修改注释以匹配当前行为(或取消对 @@ 的 skip)。
// 将 `*** Begin Patch` 文本块解析为 original / incoming 两份,供 diff 高亮。
// 约定(unified 风格):`-` 删除行、`+` 新增行、其余(`*** ` 文件头 / `@@ ` 行 / 上下文)两边都放。
const parsePatchToDiff = (block: string): { original: string; incoming: string } => {
  const original: string[] = []
  const incoming: string[] = []
  for (const raw of block.split(/\r?\n/)) {
    if (raw === '*** Begin Patch' || raw === '*** End Patch' || raw.startsWith('@@')) continue

app/renderer/src/main/src/pages/ai-agent/components/aiYaklangCode/AIYaklangCode.tsx:61

  • 这里在 JSX 里直接写 hunks={[]} 会导致每次渲染都创建新数组引用,从而触发 YakitMonacoDiffInline 内部的 useUpdateEffect(依赖 hunks)重复执行,带来不必要的重绘/闪动。建议用一个 memo/creation 的稳定空数组引用。

This issue also appears on line 123 of the same file.

  const diffLanguage = useCreation(() => (type === 'yaklang' ? 'yak' : type), [type])
  // 仅当 content 以 `*** Begin Patch` 开头时,才以 YakitMonacoDiffInline 只读展示
  const isPatch = useCreation(() => defContent.trimStart().startsWith('*** Begin Patch'), [defContent])
  const { original: patchOriginal, incoming: patchIncoming } = useCreation(
    () => (isPatch ? parsePatchToDiff(defContent) : { original: '', incoming: '' }),

@hubin4826
hubin4826 merged commit b676e85 into master Jul 31, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants