feat(knowledge-graph): 统一画布外框 + 3D 标签 + 全屏 + 工具栏三段式 + 右栏抽屉 - #525
Merged
Conversation
- 新增 GraphCanvasFrame 公共外框组件:收敛 Cytoscape/d3/3D/Sigma/Force Graph 五大渲染器 的圆角边框、stats 浮层与全屏按钮(Fullscreen API + Safari webkitRequestFullscreen 兜底; data-fullscreen 修正全屏黑底;lucide-react Maximize2/Minimize2 切换); - 新增 BuildButton 紧凑工具栏构建按钮:无 corpusId 自禁用、lastBuildError 红点指示, 与既有 BuildPanel 正交(后者继续服务 d3 空态分支); - 3D 节点持久文字标签:引入 three-spritetext,nodeThreeObjectExtend=true 在球体上叠加 SpriteText,深浅模式背景/色对比度均充足; - 工具栏三段式重排:左 CorpusSelector / 中 SearchBar(结果浮层 z-20 absolute 贴近输入框)/ 右 viewTab + 渲染器选择器 + 构建图谱按钮 + KgBuildProgressPill; - 右栏抽屉式收起:w-72 ↔ w-0 平滑过渡、chevron toggle 嵌入 main/aside 间隙、 localStorage 持久化(kg.sidebarOpen)、SSR 守卫; - 构建历史分页:BuildHistoryList 默认每页 5 条,runs.length 变化时采用 React 19 「render 期间根据 props 调整 state」范式重置分页索引,避免 useEffect+setState 级联渲染; - d3 SVG 接入 GraphCanvasFrame:删除原「Graph Canvas 标题 + 虚线双层卡片」结构, 与其他四渲染器视觉契约一致;空态分支统一为 rounded-2xl border-dashed 范式; - 底边间隙修正:内容 flex 行追加 pb-4,画布与浏览器底沿留 16px 留白; - 移除右栏「构建」卡片:能力已迁入工具栏。 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
…n 与分页跨语料库重置 - 修复右栏抽屉首屏开→收动画 + storage 噪声:用 hasHydratedRef 区分挂载读 vs 用户写,挂载阶段写 effect 短路;新增 sidebarHydrated 状态条件挂载 `transition-[width]`/`transition-opacity`,避免 localStorage 持久值为 "0" 时首屏可见的 200ms 关闭动画与回写 "1" 引发的 storage 事件抖动; - GraphCanvasFrame 全屏切换吞掉 Promise rejection:requestFullscreen / exitFullscreen 在用户拒绝权限、跨域 iframe 缺 allow="fullscreen"、 其它元素已占据全屏等场景会 reject,旧 `await` 直接冒泡为 unhandled rejection 污染控制台;现以 try/catch 包裹并 console.warn 保留可观测性; - BuildHistoryList 分页重置改为引用比较:原按 runs.length 比较,两个语料库 恰好等长的构建历史互切时不会重置,用户停留在第 N 页却看着新语料的数据; 改比 runs 引用(父 useMemo 在 payload 切换时整体重建),覆盖切语料 / 时间穿梭 / 构建后重拉所有刷新场景。 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
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.
背景
.claude/plans/system-instruction-you-are-working-bubbly-quill.md)。核心变更
GraphCanvasFrame(_components/GraphCanvasFrame.tsx):五大渲染器共享外框 + Stats 右上角浮层 + 全屏按钮(Fullscreen API + SafariwebkitRequestFullscreen兜底;data-fullscreen修正全屏黑底;lucide-reactMaximize2/Minimize2切换)。BuildButton(_components/BuildButton.tsx):紧凑工具栏构建按钮,未选语料库自禁用并title提示,lastBuildError时右上叠加红点;与既有BuildPanel正交,后者继续服务 d3 空态分支。three-spritetext@^1.10.0,nodeThreeObject返回SpriteText、nodeThreeObjectExtend=true保留球体高亮,深浅模式背景/色对比度均充足。CorpusSelector/ 中SearchBar(结果浮层absolute z-20贴近输入框)/ 右viewTab+ 渲染器选择器 +BuildButton+KgBuildProgressPill;删除独占行的搜索栏卡片。w-72 ↔ w-0平滑过渡、chevron toggle 嵌入 main/aside 间隙、localStorage键kg.sidebarOpen持久化、SSR 守卫;移除「构建」卡片。BuildHistoryList默认每页 5 条,runs.length变化时采用 React 19「render 期间根据 props 调整 state」范式(替代useEffect+setState,规避react-hooks/set-state-in-effect)。GraphCanvasFrame:删除原「Graph Canvas 标题 + 虚线双层卡片」结构,与其他四渲染器视觉契约一致;空态分支统一为rounded-2xl border-dashed。pb-4,画布与浏览器底沿留 16px 留白。风险与回滚
svgRef/simulationRef/layout与 page.tsx 强耦合),未触碰 d3 simulation 逻辑,理论上行为零退化;但需关注 viewport resize 时的布局节奏。three-spritetext为新依赖(3KB,react-force-graph 同作者维护,复用已传递引入的three);500 节点上限下显存占用约 1-2 MB,可接受。webkitRequestFullscreen兜底,已覆盖;全屏元素默认黑底由data-[fullscreen=true]:bg-white dark:bg-zinc-900显式声明。localStorageSSR 安全已用typeof window !== "undefined"守卫,避免 Next.js hydration mismatch。fe650780体量集中,git revert fe650780即可整体回滚;新增的three-spritetext依赖未被其他模块引用,回滚后自动失活。验证证据
BuildHistoryList/GraphCanvas3D此前无单元用例,未新增。pnpm typecheck✅ +pnpm lint✅ 全过;ESLint react-hooks 规则触发后已切换至 React 19 推荐范式。mcp__chrome_devtools__*端到端验证 10 项(见.context/kg-*.png)——viewportHeight - rect.bottom === 16)Cytoscape / d3 SVG / 3D WebGL / Sigma WebGL / Force CanvasCanyon Robbins / Marina Long)absolute z-20浮层渲染kg.sidebarOpen=0/1持久化影响范围
apps/negentropy-ui/app/knowledge/graph/下page.tsx+ 5 个渲染器组件 +BuildPanel.tsx,新增GraphCanvasFrame.tsx与BuildButton.tsx;package.json新增three-spritetext@^1.10.0。docs/issue.md补充本次 UI 重构摘要(按 AGENTS.md「Issue」准则)。Next Best Action
GraphCanvasFrame全屏切换在 Safari 的兜底分支;② 构建历史分页是否影响实时构建中状态的可见性(默认在第 1 页,应能立即看到最新构建);③ 工具栏在更窄屏(< 1280px)下三段式是否仍可读,必要时引入flex-wrap。docs/issue.md,登记本次 UI 重构条目以便跨上下文检索。🤖 Generated with Claude Code, CodeX, Gemini