Skip to content

fix: ai-agent UI polish, xterm crash guard & window/milkdown fixes#3987

Merged
b1rdfree merged 8 commits into
masterfrom
feat/improve-ai-chat-some-case-and-exceptions
Jul 13, 2026
Merged

fix: ai-agent UI polish, xterm crash guard & window/milkdown fixes#3987
b1rdfree merged 8 commits into
masterfrom
feat/improve-ai-chat-some-case-and-exceptions

Conversation

@VillanCh

@VillanCh VillanCh commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

概述 / Summary

本 PR 汇总渲染端若干修复:AI Agent 对话模块的 UI 体验优化、xterm.js 终端崩溃修复、窗口默认尺寸调整、Milkdown 编辑器卸载守卫与 flushSync 警告修复;并包含 memfit 启动右栏动画的实验性增改与回退。

改动内容 / What changed

提交 内容
fix: window default size, milkdown destroyed-view guard & flushSync warning 窗口尺寸:默认值由 900×650 改为 1400×880(minWidth/minHeight 仍为下限)。Milkdown 守卫setEditorValue 增加 view?.isDestroyed 守卫,避免对已销毁 view dispatch。flushSync 警告AIReActChat 切换会话时 setValue('')queueMicrotask 延后执行,规避 Milkdown/prosemirror-adapter 内部 flushSync 撞上 React 渲染周期,并加 cancelled 守卫。
fix(xterm): guard reset/resize against renderer-not-ready crash 修复 xterm.js 在 renderer 未就绪时 reset/resize 抛 Cannot read properties of undefined (reading 'dimensions')xtermUtils(renderer + engine-link-startup)新增 isTerminalReady() 守卫并 try/catch 包裹 resize/resetYakitXtermopen()fit() 延后一帧(requestAnimationFrame)执行;TerminalBox 两处直接 terminal.reset() 改走安全的 xtermClear()
fix(ai-agent): refine ToolInvokerCard copy btn & history chat overflow 复制按钮:放大至 22×22、图标居中、right:24px、hover 背景;json 容器右内边距 28px 防遮挡;SVG 尺寸收敛 13×13;移除 <OutlineDocumentduplicateIcon> 内联 style。历史标题:新增 .title-text(nowrap + ellipsis),标题包 <span> 截断。文案historyChat/HistoryChat.title 精简为「历史」。
improve toolcall compact and chat group 工具调用结果紧凑展示 + 会话分组优化。
feat(memfit) + Revert memfit 启动右栏纯 canvas 动画实验,已回退(净变化为 0)。

产生影响 / Impact

  • 稳定性(xterm):终端面板在组件未完成 open、或已被 dispose 的时序下不再因 _renderService.dimensions 未就绪而抛错崩溃;reset/resize 失败被安全吞掉,后续 resize 监听会补偿。
  • 稳定性(Milkdown):编辑器卸载后不再对已销毁 view dispatch;切换会话不再触发 flushSync 渲染警告。
  • 窗口:首次启动窗口更接近实际可用尺寸(1400×880),minWidth/minHeight 仍兜底。
  • 视觉:工具卡片复制按钮点击热区更大、对齐更规整;历史会话长标题以省略号截断、计数 tag 不被挤压。
  • 展示:工具调用更紧凑,会话分组更清晰。
  • 无数据流变更:改动集中在展示层、主进程窗口参数与终端/编辑器工具方法,不影响后端业务逻辑。

如何测试 / How to test

  1. 本地启动渲染端:app/renderer/src/mainyarn electron-render
  2. 窗口:删除 yakit-window-state.json 后冷启动,确认默认窗口为 1400×880 且不能缩到小于 900×650。
  3. Milkdown:在 AI 输入框输入后快速切换会话/卸载组件,确认无 isDestroyed 报错、无 flushSync 警告。
  4. xterm 终端:打开终端面板(如 Yak Runner 底部 Terminal),快速切换/重载终端、在终端未渲染完成时触发 clear,确认不再出现 dimensions 报错或白屏;切换缓存会话确认 xtermClear + writeXTerm 正常回填。
  5. 复制按钮:打开任意工具调用的参数弹窗,确认复制按钮尺寸/位置/hover/点击复制均正常,且不遮挡 JSON。
  6. 历史会话标题:构造超长标题或缩窄侧栏,确认标题省略号截断、计数 tag 完整。
  7. 工具调用紧凑/分组:发起多轮含工具调用的对话,确认结果展示紧凑且分组合理。
  8. CI:ESLint / TypeScript(renderer src/main + engine-link-startup)/ Vitest / Prettier / i18n 均需通过。

VillanCh and others added 3 commits July 10, 2026 23:17
…lue gradient bars

- Remove @react-three/fiber / three.js (incompatible with React 18, added 900KB)
- Add src/components/react-bits/memfit-animated-bg.tsx: pure Canvas 2D implementation
  of the flowing vertical blue gradient bars animation, matching the memfit palette
  (#4373BB light / #66A2EB dark), infinite loop via requestAnimationFrame, no deps
- Support both light and dark themes; theme switch reacts instantly via ref
- Remove the two memfit-right.webm video assets from bundle
- Commit built dist/ so teammates can use without re-building (dist removed from .gitignore)
- Fix pre-existing TS error: onOkText -> okText in SoftwareBasics

Bundle JS: 4.5MB -> 3.6MB (gzip 1.24GB -> 986KB)

Co-authored-by: Cursor <cursoragent@cursor.com>
…imated blue gradient bars"

This reverts commit 55c8292.
@github-actions

Copy link
Copy Markdown
Contributor

PR CI 汇总

状态:全部通过

  • ✅ i18n(zh/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 自动生成

- aiAgent.json: shorten AIAgentTabs.historyChat / HistoryChat.title
  to "历史" for compactness
- ToolInvokerCard: enlarge copy button to 22x22 with centered icon,
  move padding into CSS; drop inline style on the duplicate icon
- HistoryChat: wrap title in a span with ellipsis (nowrap + truncate)
  so long titles no longer break layout
@VillanCh VillanCh changed the title Feat/improve ai chat some case and exceptions fix(ai-agent): ToolInvokerCard copy btn, chat history overflow & toolcall compact Jul 11, 2026
VillanCh added 2 commits July 12, 2026 11:14
修复 xterm.js 在 renderer 未就绪时 reset/resize 抛
"Cannot read properties of undefined (reading 'dimensions')" 的问题:

- xtermUtils(renderer + engine-link-startup): 新增 isTerminalReady()
  守卫(element + _renderService.hasRenderer), xtermFit/xtermClear
  改用守卫并 try/catch 包裹 resize/reset
- YakitXterm: open() 后 fit() 延后一帧(requestAnimationFrame)执行
  并 try/catch, 规避 Viewport.syncScrollArea 时序竞态
- TerminalBox: 两处直接 terminal.reset() 改走安全的 xtermClear()
…arning

- main/index.js: 窗口默认尺寸从 minWidth/minHeight(900x650)改为更合理的
  默认值 1400x880, minWidth/minHeight 仍作为下限兜底
- aiMilkdownInput/utils: setEditorValue 增加 view?.isDestroyed 守卫,
  防止对已销毁的 prosemirror view dispatch
- AIReActChat: 切换会话时 setValue('') 用 queueMicrotask 延后执行,
  规避 Milkdown/prosemirror-adapter 内部 flushSync 撞上 React 渲染周期
  的警告, 并加 cancelled 守卫防止卸载后写入
@VillanCh VillanCh changed the title fix(ai-agent): ToolInvokerCard copy btn, chat history overflow & toolcall compact fix: ai-agent UI polish, xterm crash guard & window/milkdown fixes Jul 12, 2026
@b1rdfree b1rdfree requested a review from Copilot July 13, 2026 02:48

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

This PR consolidates several renderer/main-process stability and UI refinements across the AI Agent experience, xterm terminal integration, window sizing defaults, and Milkdown editor lifecycle safety.

Changes:

  • Harden xterm operations (fit/resize/reset) against renderer-not-ready/disposed timing to prevent UI crashes, and route terminal clears through guarded helpers.
  • Improve AI Agent UI presentation (tool-call output compaction, history title truncation, copy affordances) and reduce Milkdown-related React flushSync warnings via deferred updates.
  • Adjust Electron window default size while preserving minimum constraints; add BrowserWindow/webContents destroyed guards in IPC stream send paths.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
app/renderer/src/main/src/utils/xtermUtils.ts Adds isTerminalReady() and wraps reset/resize with guards/try-catch to avoid xterm render-service crash conditions.
app/renderer/engine-link-startup/src/utils/xtermUtils.ts Mirrors the xterm safety guards in engine-link-startup utilities.
app/renderer/src/main/src/pages/yakRunner/BottomEditorDetails/TerminalBox/TerminalBox.tsx Switches direct terminal.reset() calls to guarded xtermClear() usage.
app/renderer/src/main/src/components/yakitUI/YakitXterm/YakitXterm.tsx Defers fit() until the next animation frame after open() to avoid renderer timing crashes.
app/renderer/src/main/src/pages/ai-re-act/aiReActChat/AIReActChat.tsx Defers editor value reset with queueMicrotask + cancellation guard to avoid flushSync warnings during session switches.
app/renderer/src/main/src/pages/ai-agent/components/aiMilkdownInput/utils.ts Adds a destroyed-view guard before dispatching editor transactions.
app/renderer/src/main/src/pages/ai-agent/historyChat/HistoryChat.tsx Wraps title text for truncation to prevent overflow.
app/renderer/src/main/src/pages/ai-agent/historyChat/HistoryChat.module.scss Adds .title-text styles for nowrap/ellipsis truncation behavior.
app/renderer/src/main/src/pages/ai-agent/components/ToolInvokerCard.tsx Refactors tool result rendering into a compact “pseudo-terminal” view and adds params modal/copy interactions.
app/renderer/src/main/src/pages/ai-agent/components/ToolInvokerCard.module.scss Updates styles to match the new tool output/params UI (border/status styling, copy button sizing/positioning).
app/renderer/src/main/src/pages/ai-agent/components/aiGroupStreamCard/AIGroupStreamCard.tsx Wraps group card in a tooltip and adjusts layout for expand/collapse interactions.
app/renderer/src/main/src/pages/ai-agent/chatTemplate/AIAgentChatTemplate.module.scss Adjusts footer padding to improve layout/spacing.
app/renderer/src/main/public/locales/zh/aiAgent.json Simplifies “历史会话” labeling to “历史” in relevant keys.
app/main/index.js Updates default window dimensions while keeping min constraints.
app/main/handlers/yakRunnerTerminal.js Adds destroyed-window/webContents guards before sending terminal IPC events.
app/main/handlers/handleStreamWithContext.js Adds destroyed-window/webContents guards for generic stream event forwarding.

Comment thread app/renderer/src/main/src/pages/ai-agent/components/ToolInvokerCard.tsx Outdated
Comment on lines +463 to +465
<span className={styles['params-json']} onClick={() => setOpen(true)} title={jsonStr}>
{jsonStr}
</span>
Comment on lines +462 to +470
<span className={styles['params-label']}>Params:</span>
<span className={styles['params-json']} onClick={() => setOpen(true)} title={jsonStr}>
{jsonStr}
</span>
</div>
<YakitModal
visible={open}
title="Params"
onCancel={() => setOpen(false)}
Comment on lines +177 to +180
const collapseTooltip = !expand && elements.length > 1 ? `折叠${elements.length}条信息` : ''

return (
<div
className={classNames(styles.container, {
[styles['container-focus']]: isFocus,
})}
ref={containerRef}
>
<Tooltip title={collapseTooltip} mouseEnterDelay={0.3}>
Defer YakitXterm resize fits via requestAnimationFrame with isTerminalReady checks, and avoid calling setValue when the chat textarea ref is unavailable.

Co-authored-by: Cursor <cursoragent@cursor.com>
@b1rdfree b1rdfree merged commit f606d31 into master Jul 13, 2026
10 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