Skip to content

Commit 5f2a89c

Browse files
committed
refactor: 将所有 ASCII 字符图转换为 Mermaid 图表
- 14 个文件的 18 个 ASCII art <pre> 块转为 Mermaid/HTML/CodeBlock - 流程图/架构图 → MermaidDiagram 组件 - 表格 (TaskTracking) → HTML <table> - 目录树 (ConfigSystem, ExtensionSystem) → CodeBlock - 修复 SubagentResolutionAnimation 卡片布局溢出 - 移除未使用的 .ascii-diagram CSS 类
1 parent 5dcb0f0 commit 5f2a89c

15 files changed

Lines changed: 505 additions & 625 deletions

src/pages/Checkpointing.tsx

Lines changed: 32 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -775,61 +775,38 @@ async function restoreAction(
775775
{/* 架构图 */}
776776
<section>
777777
<h3 className="text-xl font-semibold text-heading mb-4">Checkpointing 架构</h3>
778-
<div className="bg-surface rounded-lg p-6">
779-
<pre className="text-sm text-body overflow-x-auto">
780-
{`┌─────────────────────────────────────────────────────────────────┐
781-
│ 用户批准工具执行 │
782-
└──────────────────────────┬──────────────────────────────────────┘
783-
784-
785-
┌─────────────────────────────────────────────────────────────────┐
786-
│ CheckpointService │
787-
│ │
788-
│ ┌─────────────────────────────────────────────────────────┐ │
789-
│ │ createCheckpoint() │ │
790-
│ │ │ │
791-
│ │ 1. 获取当前文件状态 │ │
792-
│ │ 2. 复制到影子仓库 │ │
793-
│ │ 3. Git commit │ │
794-
│ │ 4. 保存对话历史 │ │
795-
│ │ 5. 保存工具调用信息 │ │
796-
│ │ │ │
797-
│ └─────────────────────────────────────────────────────────┘ │
798-
│ │
799-
└──────────────────────────┬──────────────────────────────────────┘
800-
801-
┌──────────────────┼──────────────────┐
802-
│ │ │
803-
▼ ▼ ▼
804-
┌──────────────┐ ┌──────────────┐ ┌──────────────────────┐
805-
│ 影子 Git 仓库 │ │ 对话历史文件 │ │ 工具调用 JSON │
806-
│ │ │ │ │ │
807-
│ ~/.gemini/ │ │ ~/.gemini/ │ │ ~/.gemini/tmp/ │
808-
│ history/ │ │ tmp/<hash>/ │ │ <hash>/checkpoints/ │
809-
│ <hash>/ │ │ checkpoints/ │ │ <timestamp>.json │
810-
│ │ │ │ │ │
811-
│ ┌──────────┐ │ │ conversation │ │ { │
812-
│ │ commit 1 │ │ │ history │ │ toolName, │
813-
│ │ commit 2 │ │ │ │ │ toolCall, │
814-
│ │ ... │ │ │ │ │ targetFile │
815-
│ └──────────┘ │ │ │ │ } │
816-
└──────────────┘ └──────────────┘ └──────────────────────┘
817-
818-
/restore 命令
819-
820-
821-
┌─────────────────────────────────────────────────────────────────┐
822-
│ restoreCheckpoint() │
823-
│ │
824-
│ 1. 读取检查点 JSON │
825-
│ 2. git checkout <commit> 在影子仓库 │
826-
│ 3. 复制文件回项目目录 │
827-
│ 4. 恢复对话历史 │
828-
│ 5. 重新提议工具调用 │
829-
│ │
830-
└─────────────────────────────────────────────────────────────────┘`}
831-
</pre>
832-
</div>
778+
<MermaidDiagram chart={`flowchart TD
779+
Approve["用户批准工具执行"]
780+
781+
subgraph CPS["CheckpointService"]
782+
Create["createCheckpoint<br/>1. 获取当前文件状态<br/>2. 复制到影子仓库<br/>3. Git commit<br/>4. 保存对话历史<br/>5. 保存工具调用信息"]
783+
end
784+
785+
ShadowGit["影子 Git 仓库<br/>~/.gemini/history/hash/<br/>commit 1, commit 2, ..."]
786+
ConvoHistory["对话历史文件<br/>~/.gemini/tmp/hash/<br/>checkpoints/<br/>conversation history"]
787+
ToolJSON["工具调用 JSON<br/>~/.gemini/tmp/hash/<br/>checkpoints/timestamp.json<br/>toolName, toolCall, targetFile"]
788+
789+
Approve --> CPS
790+
Create --> ShadowGit
791+
Create --> ConvoHistory
792+
Create --> ToolJSON
793+
794+
Restore["/restore 命令"]
795+
RestoreFn["restoreCheckpoint<br/>1. 读取检查点 JSON<br/>2. git checkout commit 在影子仓库<br/>3. 复制文件回项目目录<br/>4. 恢复对话历史<br/>5. 重新提议工具调用"]
796+
797+
ShadowGit --> Restore
798+
ConvoHistory --> Restore
799+
ToolJSON --> Restore
800+
Restore --> RestoreFn
801+
802+
style Approve fill:${getThemeColor("--mermaid-info-fill", "#dbeafe")},color:${getThemeColor("--color-text", "#1c1917")}
803+
style CPS fill:${getThemeColor("--mermaid-warning-fill", "#fef3c7")},color:${getThemeColor("--color-text", "#1c1917")}
804+
style ShadowGit fill:${getThemeColor("--mermaid-purple-fill", "#ede9fe")},color:${getThemeColor("--color-text", "#1c1917")}
805+
style ConvoHistory fill:${getThemeColor("--mermaid-purple-fill", "#ede9fe")},color:${getThemeColor("--color-text", "#1c1917")}
806+
style ToolJSON fill:${getThemeColor("--mermaid-purple-fill", "#ede9fe")},color:${getThemeColor("--color-text", "#1c1917")}
807+
style Restore fill:${getThemeColor("--mermaid-success-fill", "#dcfce7")},color:${getThemeColor("--color-text", "#1c1917")}
808+
style RestoreFn fill:${getThemeColor("--mermaid-success-fill", "#dcfce7")},color:${getThemeColor("--color-text", "#1c1917")}
809+
`} title="Checkpointing 架构" />
833810
</section>
834811

835812
{/* 注意事项 */}

src/pages/ConfigSystem.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,31 +1382,31 @@ if (!trustedFolder && approvalMode !== ApprovalMode.DEFAULT) {
13821382
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
13831383
<div className="bg-elevated/10 border-2 border-edge rounded-lg p-4">
13841384
<h4 className="text-heading font-bold mb-2">~/.gemini/ (用户级)</h4>
1385-
<pre className="text-sm text-body whitespace-pre-wrap">{`├── settings.json # 用户配置
1386-
├── GEMINI.md # 用户级记忆
1387-
├── oauth_creds.json # OAuth 凭据
1388-
├── mcp-oauth-tokens.json # MCP OAuth tokens
1389-
├── agents/ # 用户级子代理
1390-
├── commands/ # 用户级自定义命令
1391-
├── extensions/ # 用户级扩展
1392-
├── themes/ # 主题文件
1393-
└── tmp/ # 临时文件
1394-
└── <project_hash>/
1395-
├── chats/ # 聊天记录
1396-
├── checkpoints/ # 检查点
1397-
└── shell_history # Shell 历史`}</pre>
1385+
<CodeBlock code={`├── settings.json # 用户配置
1386+
├── GEMINI.md # 用户级记忆
1387+
├── oauth_creds.json # OAuth 凭据
1388+
├── mcp-oauth-tokens.json # MCP OAuth tokens
1389+
├── agents/ # 用户级子代理
1390+
├── commands/ # 用户级自定义命令
1391+
├── extensions/ # 用户级扩展
1392+
├── themes/ # 主题文件
1393+
└── tmp/ # 临时文件
1394+
└── <project_hash>/
1395+
├── chats/ # 聊天记录
1396+
├── checkpoints/ # 检查点
1397+
└── shell_history # Shell 历史`} language="text" title="~/.gemini/ (用户级)" />
13981398
</div>
13991399

14001400
<div className="bg-elevated border-2 border-edge rounded-lg p-4">
14011401
<h4 className="text-heading font-bold mb-2">.gemini/ (项目级)</h4>
1402-
<pre className="text-sm text-body whitespace-pre-wrap">{`├── settings.json # 项目配置
1403-
├── GEMINI.md # 项目级记忆
1404-
├── agents/ # 项目级子代理
1405-
├── commands/ # 项目级自定义命令
1406-
├── extensions/ # 项目级扩展
1407-
├── sandbox.Dockerfile # 自定义沙箱镜像
1408-
├── sandbox.bashrc # 沙箱 shell 配置
1409-
└── sandbox-macos-*.sb # macOS 沙箱 profile`}</pre>
1402+
<CodeBlock code={`├── settings.json # 项目配置
1403+
├── GEMINI.md # 项目级记忆
1404+
├── agents/ # 项目级子代理
1405+
├── commands/ # 项目级自定义命令
1406+
├── extensions/ # 项目级扩展
1407+
├── sandbox.Dockerfile # 自定义沙箱镜像
1408+
├── sandbox.bashrc # 沙箱 shell 配置
1409+
└── sandbox-macos-*.sb # macOS 沙箱 profile`} language="text" title=".gemini/ (项目级)" />
14101410
</div>
14111411
</div>
14121412
</Layer>

src/pages/EnterpriseDeployment.tsx

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -264,19 +264,37 @@ npm run build:portable
264264

265265
<div className="bg-surface rounded-lg p-4 border border-edge">
266266
<h4 className="text-heading font-semibold mb-3">产物结构</h4>
267-
<pre className="text-sm text-body font-mono">
268-
{`portable-win-x64/
269-
├── node/ # Node.js 运行时 (v20.19.0)
270-
│ └── node.exe
271-
├── app/ # 应用代码
272-
│ ├── cli.js # esbuild 打包的主程序
273-
│ ├── vendor/ # 内置工具 (ripgrep 等)
274-
│ └── *.sb # 沙箱配置文件
275-
├── gemini.bat # Windows 启动器
276-
├── gemini.ps1 # PowerShell 启动器
277-
├── install.bat # 自动安装脚本
278-
└── INSTALL.md # 用户说明`}
279-
</pre>
267+
<MermaidDiagram chart={`graph LR
268+
Root["portable-win-x64/"]
269+
270+
Node["node/<br/>Node.js 运行时 v20.19.0"]
271+
NodeExe["node.exe"]
272+
273+
App["app/<br/>应用代码"]
274+
CliJS["cli.js<br/>esbuild 打包的主程序"]
275+
Vendor["vendor/<br/>内置工具 ripgrep 等"]
276+
SB["*.sb<br/>沙箱配置文件"]
277+
278+
Bat["gemini.bat<br/>Windows 启动器"]
279+
PS1["gemini.ps1<br/>PowerShell 启动器"]
280+
Install["install.bat<br/>自动安装脚本"]
281+
InstallMD["INSTALL.md<br/>用户说明"]
282+
283+
Root --> Node
284+
Node --> NodeExe
285+
Root --> App
286+
App --> CliJS
287+
App --> Vendor
288+
App --> SB
289+
Root --> Bat
290+
Root --> PS1
291+
Root --> Install
292+
Root --> InstallMD
293+
294+
style Root fill:${getThemeColor("--mermaid-info-fill", "#dbeafe")},color:${getThemeColor("--color-text", "#1c1917")}
295+
style Node fill:${getThemeColor("--mermaid-success-fill", "#dcfce7")},color:${getThemeColor("--color-text", "#1c1917")}
296+
style App fill:${getThemeColor("--mermaid-warning-fill", "#fef3c7")},color:${getThemeColor("--color-text", "#1c1917")}
297+
`} title="产物结构" />
280298
</div>
281299

282300
<CodeBlock

src/pages/ErrorHandling.tsx

Lines changed: 69 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -784,18 +784,30 @@ function attemptJSONFix(
784784
<h3 className="text-xl font-semibold text-heading mb-4">错误类型定义</h3>
785785
<CodeBlock code={errorTypesCode} language="typescript" title="自定义错误类" />
786786

787-
<div className="mt-4 bg-surface rounded-lg p-4">
788-
<h4 className="font-semibold text-heading mb-2">错误类型层级</h4>
789-
<pre className="text-sm text-body">
790-
{`CLIError (基类)
791-
├── APIError - API 调用错误 (状态码、响应)
792-
├── AuthenticationError - 认证错误 (登录失败)
793-
├── ToolExecutionError - 工具执行错误 (Shell、文件操作)
794-
├── ConfigurationError - 配置错误 (无效配置)
795-
├── NetworkError - 网络错误 (连接失败)
796-
└── TimeoutError - 超时错误 (操作超时)`}
797-
</pre>
798-
</div>
787+
<MermaidDiagram chart={`graph TD
788+
CLIError["CLIError<br/>基类"]
789+
APIError["APIError<br/>API 调用错误<br/>状态码、响应"]
790+
AuthError["AuthenticationError<br/>认证错误<br/>登录失败"]
791+
ToolError["ToolExecutionError<br/>工具执行错误<br/>Shell、文件操作"]
792+
ConfigError["ConfigurationError<br/>配置错误<br/>无效配置"]
793+
NetworkError["NetworkError<br/>网络错误<br/>连接失败"]
794+
TimeoutError["TimeoutError<br/>超时错误<br/>操作超时"]
795+
796+
CLIError --> APIError
797+
CLIError --> AuthError
798+
CLIError --> ToolError
799+
CLIError --> ConfigError
800+
CLIError --> NetworkError
801+
CLIError --> TimeoutError
802+
803+
style CLIError fill:${getThemeColor("--mermaid-info-fill", "#dbeafe")},color:${getThemeColor("--color-text", "#1c1917")}
804+
style APIError fill:${getThemeColor("--mermaid-danger-fill", "#fee2e2")},color:${getThemeColor("--color-text", "#1c1917")}
805+
style AuthError fill:${getThemeColor("--mermaid-warning-fill", "#fef3c7")},color:${getThemeColor("--color-text", "#1c1917")}
806+
style ToolError fill:${getThemeColor("--mermaid-danger-fill", "#fee2e2")},color:${getThemeColor("--color-text", "#1c1917")}
807+
style ConfigError fill:${getThemeColor("--mermaid-warning-fill", "#fef3c7")},color:${getThemeColor("--color-text", "#1c1917")}
808+
style NetworkError fill:${getThemeColor("--mermaid-danger-fill", "#fee2e2")},color:${getThemeColor("--color-text", "#1c1917")}
809+
style TimeoutError fill:${getThemeColor("--mermaid-warning-fill", "#fef3c7")},color:${getThemeColor("--color-text", "#1c1917")}
810+
`} title="错误类型层级" />
799811
</section>
800812

801813
{/* 错误分类器 */}
@@ -931,62 +943,51 @@ function attemptJSONFix(
931943
{/* 架构图 */}
932944
<section>
933945
<h3 className="text-xl font-semibold text-heading mb-4">错误处理架构</h3>
934-
<div className="bg-surface rounded-lg p-6">
935-
<pre className="text-sm text-body overflow-x-auto">
936-
{`┌──────────────────────────────────────────────────────────────────┐
937-
│ Error Sources │
938-
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
939-
│ │ API │ │ Tool │ │ Network │ │ UI │ │
940-
│ │ Calls │ │ Execute │ │ Request │ │ Render │ │
941-
│ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │
942-
│ │ │ │ │ │
943-
└───────┼────────────┼────────────┼────────────┼───────────────────┘
944-
│ │ │ │
945-
└────────────┴────────────┴────────────┘
946-
947-
948-
┌──────────────────────────────────────────────────────────────────┐
949-
│ Error Capture Layer │
950-
│ ┌───────────────────┐ ┌───────────────────┐ │
951-
│ │ Try-Catch │ │ Error Boundary │ │
952-
│ │ (Sync/Async) │ │ (React UI) │ │
953-
│ └─────────┬─────────┘ └─────────┬─────────┘ │
954-
│ │ │ │
955-
│ └──────────┬───────────┘ │
956-
│ │ │
957-
│ ┌────────────────────▼──────────────────────┐ │
958-
│ │ Global Error Handler │ │
959-
│ │ unhandledRejection | uncaughtException │ │
960-
│ └────────────────────┬──────────────────────┘ │
961-
│ │ │
962-
└───────────────────────┼──────────────────────────────────────────┘
963-
964-
965-
┌──────────────────────────────────────────────────────────────────┐
966-
│ Error Classification │
967-
│ ┌──────────────────────────────────────────────────────────┐ │
968-
│ │ Error Classifier │ │
969-
│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
970-
│ │ │ Category │ │ Severity │ │Recoverable│ │ Action │ │ │
971-
│ │ │ API │ │ MEDIUM │ │ true │ │ RETRY │ │ │
972-
│ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │
973-
│ └──────────────────────────────────────────────────────────┘ │
974-
│ │
975-
└───────────────────────┬──────────────────────────────────────────┘
976-
977-
┌───────────────┴───────────────┐
978-
│ │
979-
▼ ▼
980-
┌───────────────────┐ ┌───────────────────┐
981-
│ Recovery Handler │ │ Error Reporter │
982-
│ ┌───────────────┐ │ │ ┌───────────────┐ │
983-
│ │ Retry Logic │ │ │ │ User Display │ │
984-
│ │ Fallback │ │ │ │ File Logging │ │
985-
│ │ State Reset │ │ │ │ Telemetry │ │
986-
│ └───────────────┘ │ │ └───────────────┘ │
987-
└───────────────────┘ └───────────────────┘`}
988-
</pre>
989-
</div>
946+
<MermaidDiagram chart={`flowchart TD
947+
subgraph Sources["Error Sources"]
948+
API["API Calls"]
949+
Tool["Tool Execute"]
950+
Network["Network Request"]
951+
UI["UI Render"]
952+
end
953+
954+
subgraph Capture["Error Capture Layer"]
955+
TryCatch["Try-Catch<br/>Sync/Async"]
956+
ErrorBoundary["Error Boundary<br/>React UI"]
957+
TryCatch --> GlobalHandler
958+
ErrorBoundary --> GlobalHandler
959+
GlobalHandler["Global Error Handler<br/>unhandledRejection | uncaughtException"]
960+
end
961+
962+
subgraph Classification["Error Classification"]
963+
Classifier["Error Classifier"]
964+
Category["Category: API"]
965+
Severity["Severity: MEDIUM"]
966+
Recoverable["Recoverable: true"]
967+
Action["Action: RETRY"]
968+
Classifier --> Category
969+
Classifier --> Severity
970+
Classifier --> Recoverable
971+
Classifier --> Action
972+
end
973+
974+
Recovery["Recovery Handler<br/>Retry Logic<br/>Fallback<br/>State Reset"]
975+
Reporter["Error Reporter<br/>User Display<br/>File Logging<br/>Telemetry"]
976+
977+
API --> Capture
978+
Tool --> Capture
979+
Network --> Capture
980+
UI --> Capture
981+
GlobalHandler --> Classification
982+
Classifier --> Recovery
983+
Classifier --> Reporter
984+
985+
style Sources fill:${getThemeColor("--mermaid-danger-fill", "#fee2e2")},color:${getThemeColor("--color-text", "#1c1917")}
986+
style Capture fill:${getThemeColor("--mermaid-warning-fill", "#fef3c7")},color:${getThemeColor("--color-text", "#1c1917")}
987+
style Classification fill:${getThemeColor("--mermaid-info-fill", "#dbeafe")},color:${getThemeColor("--color-text", "#1c1917")}
988+
style Recovery fill:${getThemeColor("--mermaid-success-fill", "#dcfce7")},color:${getThemeColor("--color-text", "#1c1917")}
989+
style Reporter fill:${getThemeColor("--mermaid-purple-fill", "#ede9fe")},color:${getThemeColor("--color-text", "#1c1917")}
990+
`} title="错误处理架构" />
990991
</section>
991992

992993
{/* 失败场景速查表 */}

0 commit comments

Comments
 (0)