feat: yakrunner AI 增加monaco删除/新增效果 - #4068
Merged
Merged
Conversation
Contributor
PR CI 汇总状态:全部通过
由 pull_request test workflow 自动生成 |
hjhke
force-pushed
the
hejiahui/yakrunnerCodePatch
branch
from
July 30, 2026 10:02
854e969 to
27f5e97
Compare
Contributor
There was a problem hiding this comment.
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
approved these changes
Jul 31, 2026
song-xiao-lin
approved these changes
Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
第二个合并方式