Repository navigation
feat: 优化洞察卡片样式与 AI 语义呈现 - #74
Conversation
interstellarmt
commented
Nov 19, 2026
- 统一 Snippet 和对话图表的便签风格与客户端主题
- 通过 AI 生成 T8 洞察、分析意图、标签和标题高亮
- 完善洞察展开、Snippet 保存和编辑交互
There was a problem hiding this comment.
🟡 Changes recommended
Unvalidated AI presentations can alter and persist summary content, while legacy saved charts lose rendering support and long snippet titles can make confirmation buttons inaccessible.
3 open issues
What changed in this PR
This PR unifies analysis charts and saved Snippets with a paper-note design and client-aware themes. It also adds AI-generated insight annotations and improves saving, editing, and expanding insights.
Changes:
- Generate and persist analysis intent, tags, T8 annotations, and title highlights.
- Share insight-card components across conversations and Snippets, with light/dark chart themes.
- Improve Snippet interactions and add AI integration and persistence tests.
| File | Description |
|---|---|
| tests/main/services/snippet/index.test.ts | Tests metadata persistence, editing, and legacy inputs. |
| tests/main/ai/tools.test.ts | Tests presentation integration and cancellation forwarding. |
| tests/main/ai/insight.test.ts | Tests generation, fallback, cancellation, and JSON mode. |
| src/shared/snippets.ts | Adds optional presentation metadata. |
| src/shared/messages.ts | Removes the legacy chart HTML type. |
| src/shared/insight.ts | Defines presentation validation and tag deduplication. |
| src/renderer/theme.ts | Defines client-aligned chart themes. |
| src/renderer/styles.css | Adds chart palette variables. |
| src/renderer/pages/snippets/index.tsx | Restyles cards and updates editing and deletion interactions. |
| src/renderer/pages/analysis/AnalysisMessage.tsx | Integrates insight cards and adjusts analysis expansion. |
| src/renderer/pages/analysis/AnalysisChart.tsx | Adds conversation insight cards and saving controls. |
| src/renderer/components/Visualization.tsx | Applies client themes and handles summary visualizations. |
| src/renderer/components/InsightSummary.tsx | Renders T8 summaries with Markdown fallback. |
| src/renderer/components/InsightCard.tsx | Adds shared labels, highlights, notes, and figures. |
| src/renderer/App.tsx | Provides theme context and synchronizes document styling. |
| src/main/services/snippet/index.ts | Persists metadata and invalidates it after edits. |
| src/main/ai/tools.ts | Attaches presentation metadata to visualization results. |
| src/main/ai/insight.ts | Generates structured insight presentation through AI. |
| src/main/ai/agent.ts | Supplies the original question to presentation generation. |
| package.json | Updates the GPT-Vis dependency range. |
| assets/textures/paper-grain.svg | Adds the shared paper texture. |
Review effort: Balanced
| timeout: 120_000, | ||
| maxRetries: 0, | ||
| }); | ||
| return { ...output, tags: [...new Set(output.tags)] }; |
| {message.content.text && <Markdown>{message.content.text}</Markdown>} | ||
| <Chart html={message.content.chartHtml} /> | ||
| <AnalysisTable analysis={message.content} /> |
| <AlertDialog.Root open={!!deleting} onOpenChange={(open) => !busy && !open && setDeleting(null)}> | ||
| <AlertDialog.Portal> | ||
| <AlertDialog.Overlay className="fixed inset-0 z-50 bg-[#15202bcc]" /> | ||
| <AlertDialog.Content className="fixed top-1/2 left-1/2 z-50 w-[480px] max-w-[calc(100vw-32px)] -translate-x-1/2 -translate-y-1/2 rounded-2xl border bg-surface p-6 shadow-2xl"> |
9317f6b to
813b622
Compare
| ava, | ||
| dataset, | ||
| () => options.strategy, | ||
| (analysis, spec, abortSignal) => |
There was a problem hiding this comment.
传入 createTools 必要的参数,然后在 createTools 去组合其他 agent。
| @@ -0,0 +1,195 @@ | |||
| import { | |||
There was a problem hiding this comment.
可以抽离下所有的 snippet-layout 到一个目录中,然后后续增加布局模版,就是在这个目录新增组件,然后注册到模版池子里面。
There was a problem hiding this comment.
概念一致,不新增概念,可以使用 SnippetCart,看到名字就知道是哪里的 ui。和功能。
|
|
||
| export default defineConfig({ | ||
| resolve: { | ||
| alias: { '@shared': resolve('src/shared') }, |
| question: string; | ||
| spec: SnippetSpec; | ||
| summary: string; | ||
| presentation?: InsightPresentation; |
There was a problem hiding this comment.
这个结构可以拍平,不做嵌套,也不用兼容就得数据,保持干净。这里的改动会牵动其他地方的改动。
There was a problem hiding this comment.
-
question
-
intent
-
title
-
summary
-
spec
-
tags
| abortSignal, | ||
| }), | ||
| ), | ||
| tools: createTools(ava, dataset, options, languageModel), |
There was a problem hiding this comment.
options 需要使用回调方法,估计 languageModel 也需要,涉及到 setting 那边修改之后,这边要更新。可能需要测测。
| } from '@antv/ava'; | ||
| import { localFilePath } from '../util/localFile'; | ||
| import type { SnippetContent } from '@shared/schema'; | ||
| import { generateInsightPresentation } from './snippet-agent'; |
| @@ -2,7 +2,7 @@ import { createOpenAICompatible } from '@ai-sdk/openai-compatible'; | |||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; | |||
There was a problem hiding this comment.
这种 ai agent 单测依赖 llm,mock 之后测不出啥东西,可以不加的。现在加单侧的基本都是纯函数。
| summary: formatted?.summary ?? analysis.text, | ||
| spec, | ||
| tags: formatted?.tags ?? [], | ||
| metrics: formatted?.metrics ?? [], |
| summary TEXT NOT NULL, | ||
| spec TEXT NOT NULL, | ||
| tags TEXT NOT NULL, | ||
| metrics TEXT NOT NULL, |
| 'min-w-0 text-sm leading-7 text-pretty tabular-nums [&_.gpt-vis-summary]:bg-transparent! [&_.gpt-vis-summary]:p-0! [&_.t8-p]:m-0! [&_.t8-p]:text-sm! [&_.t8-p]:leading-7!'; | ||
|
|
||
| export const summaryToggleClassName = | ||
| 'mt-2 inline-flex items-center gap-1 p-0 text-xs leading-5 text-muted hover:text-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent'; |
There was a problem hiding this comment.
感觉这些不用复用,设想要自己写模板了,用户会有这些复用的吗?
不过这个对目前是小问题。
|
是不是模板和主题有点搞混淆了? |

