@vibe-forge/client 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/cli.cjs +1 -1
  2. package/dist/assets/{arc-CwMXUVsq.js → arc-DgIxeTMg.js} +1 -1
  3. package/dist/assets/{blockDiagram-c4efeb88-CGxJV7KJ.js → blockDiagram-c4efeb88-CEAob3X9.js} +1 -1
  4. package/dist/assets/{c4Diagram-c83219d4-BKhin7cY.js → c4Diagram-c83219d4-DwIxpDKd.js} +1 -1
  5. package/dist/assets/channel-DhtnrNJ6.js +1 -0
  6. package/dist/assets/{classDiagram-beda092f-BASmn22R.js → classDiagram-beda092f-Cz1q8u_0.js} +1 -1
  7. package/dist/assets/{classDiagram-v2-2358418a-BUk9rNBX.js → classDiagram-v2-2358418a-CImgTuwd.js} +1 -1
  8. package/dist/assets/clone-7bHB6YkC.js +1 -0
  9. package/dist/assets/{createText-1719965b-2XqnWjQY.js → createText-1719965b-C1_HJcCc.js} +1 -1
  10. package/dist/assets/devicon-BWlTeAUU.woff +0 -0
  11. package/dist/assets/devicon-CirD-cQx.ttf +0 -0
  12. package/dist/assets/devicon-Dg8iWy0i.svg +1211 -0
  13. package/dist/assets/devicon-TqfHp33-.eot +0 -0
  14. package/dist/assets/{edges-96097737-B7e32Jeg.js → edges-96097737-BU8qStzd.js} +1 -1
  15. package/dist/assets/{erDiagram-0228fc6a-CCR2or72.js → erDiagram-0228fc6a-DNA1Fz2L.js} +1 -1
  16. package/dist/assets/{flowDb-c6c81e3f-B72HWT9x.js → flowDb-c6c81e3f-DjiCStMN.js} +1 -1
  17. package/dist/assets/{flowDiagram-50d868cf-WOi0KARY.js → flowDiagram-50d868cf-CSDi0-RD.js} +1 -1
  18. package/dist/assets/flowDiagram-v2-4f6560a1-_13Sz5Wh.js +1 -0
  19. package/dist/assets/{flowchart-elk-definition-6af322e1-i_Yd0LCE.js → flowchart-elk-definition-6af322e1-DrhIMas7.js} +1 -1
  20. package/dist/assets/{ganttDiagram-a2739b55-CFH9zF14.js → ganttDiagram-a2739b55-CTZnUP5z.js} +1 -1
  21. package/dist/assets/{gitGraphDiagram-82fe8481-DglKfMze.js → gitGraphDiagram-82fe8481-COOW7jTi.js} +1 -1
  22. package/dist/assets/{graph-BKbBNGPf.js → graph-CIkpD4Kx.js} +1 -1
  23. package/dist/assets/{index-5325376f-BK7F9nSl.js → index-5325376f-aVVRRTIu.js} +1 -1
  24. package/dist/assets/index-D1giUI7r.css +1 -0
  25. package/dist/assets/index-DRSI_ZIL.js +514 -0
  26. package/dist/assets/{infoDiagram-8eee0895-BLFL77_D.js → infoDiagram-8eee0895-DQpZ1LVD.js} +1 -1
  27. package/dist/assets/{journeyDiagram-c64418c1-CS9XctDL.js → journeyDiagram-c64418c1-DoKguIuk.js} +1 -1
  28. package/dist/assets/{layout-By3JZZGt.js → layout-Tnmha8Nh.js} +1 -1
  29. package/dist/assets/{line-9GUsXbwv.js → line-BQR2SOyl.js} +1 -1
  30. package/dist/assets/{linear-DzGV4E9N.js → linear-DlG0eemV.js} +1 -1
  31. package/dist/assets/{mermaid.core-CG3Ib42Q.js → mermaid.core-BnwYO0He.js} +6 -6
  32. package/dist/assets/{mindmap-definition-8da855dc-WQ3LPKJU.js → mindmap-definition-8da855dc-BllYwDID.js} +1 -1
  33. package/dist/assets/{pieDiagram-a8764435-DHVIUZiN.js → pieDiagram-a8764435-DwCkhPVc.js} +1 -1
  34. package/dist/assets/{quadrantDiagram-1e28029f-C3G9Ye8-.js → quadrantDiagram-1e28029f-c40GKTU0.js} +1 -1
  35. package/dist/assets/{requirementDiagram-08caed73-C9ES1D5G.js → requirementDiagram-08caed73-DnQp2Tk6.js} +1 -1
  36. package/dist/assets/{sankeyDiagram-a04cb91d-B4BKXclQ.js → sankeyDiagram-a04cb91d-CnJrs13b.js} +1 -1
  37. package/dist/assets/{sequenceDiagram-c5b8d532-DrgEb25G.js → sequenceDiagram-c5b8d532-1YBwnpKu.js} +1 -1
  38. package/dist/assets/{stateDiagram-1ecb1508-CF1XWARJ.js → stateDiagram-1ecb1508-BFBxQ6Fh.js} +1 -1
  39. package/dist/assets/{stateDiagram-v2-c2b004d7-IO3i3yXv.js → stateDiagram-v2-c2b004d7-Dmechvv2.js} +1 -1
  40. package/dist/assets/{styles-b4e223ce-DACN9aSc.js → styles-b4e223ce-DWWfWX8O.js} +1 -1
  41. package/dist/assets/{styles-ca3715f6-bekm2WLP.js → styles-ca3715f6-CKKvZxaU.js} +1 -1
  42. package/dist/assets/{styles-d45a18b0-OzTDVBb8.js → styles-d45a18b0-dKMOUh9p.js} +1 -1
  43. package/dist/assets/{svgDrawCommon-b86b1483-BWroJerr.js → svgDrawCommon-b86b1483-CBgjChPM.js} +1 -1
  44. package/dist/assets/{timeline-definition-faaaa080-CCfRNigO.js → timeline-definition-faaaa080-NCt-HHmb.js} +1 -1
  45. package/dist/assets/{xychartDiagram-f5964ef8-C3cbfVqN.js → xychartDiagram-f5964ef8-BJhXS4dG.js} +1 -1
  46. package/dist/index.html +2 -7
  47. package/index.html +0 -5
  48. package/package.json +11 -6
  49. package/src/App.tsx +2 -0
  50. package/src/api/README.md +26 -0
  51. package/src/api/automation.ts +88 -0
  52. package/src/api/base.ts +54 -0
  53. package/src/api/benchmark.ts +45 -0
  54. package/src/api/config.ts +24 -0
  55. package/src/api/knowledge.ts +72 -0
  56. package/src/api/projects.ts +15 -0
  57. package/src/api/sessions.ts +82 -0
  58. package/src/api/types.ts +20 -0
  59. package/src/api.ts +44 -269
  60. package/src/components/AutomationView/AutomationView.scss +5 -1
  61. package/src/components/AutomationView/RuleFormPanel.tsx +3 -2
  62. package/src/components/AutomationView/TaskList.scss +4 -6
  63. package/src/components/AutomationView/TaskList.tsx +2 -1
  64. package/src/components/AutomationView/TriggerList.scss +4 -1
  65. package/src/components/BenchmarkView/BenchmarkCasePanel.scss +267 -0
  66. package/src/components/BenchmarkView/BenchmarkCasePanel.tsx +309 -0
  67. package/src/components/BenchmarkView/BenchmarkSidebar.scss +182 -0
  68. package/src/components/BenchmarkView/BenchmarkSidebar.tsx +262 -0
  69. package/src/components/BenchmarkView/BenchmarkView.scss +78 -0
  70. package/src/components/BenchmarkView/index.tsx +197 -0
  71. package/src/components/BenchmarkView/types.ts +10 -0
  72. package/src/components/BenchmarkView/utils.ts +21 -0
  73. package/src/components/Chat.tsx +37 -29
  74. package/src/components/{chat/CodeBlock.tsx → CodeBlock.tsx} +3 -1
  75. package/src/components/ConfigView.tsx +7 -0
  76. package/src/components/{chat/MarkdownContent.tsx → MarkdownContent.tsx} +1 -1
  77. package/src/components/NavRail.tsx +7 -0
  78. package/src/components/chat/ChatHeader.scss +37 -19
  79. package/src/components/chat/ChatHeader.tsx +6 -9
  80. package/src/components/chat/ChatHistoryView.tsx +89 -45
  81. package/src/components/chat/CurrentTodoList.tsx +10 -9
  82. package/src/components/chat/{MessageItem.scss → Messages/MessageItem.scss} +14 -0
  83. package/src/components/chat/{MessageItem.tsx → Messages/MessageItem.tsx} +30 -8
  84. package/src/components/chat/{messageUtils.ts → Messages/message-utils.ts} +1 -1
  85. package/src/components/chat/{Sender.scss → Sender/Sender.scss} +80 -0
  86. package/src/components/chat/{Sender.tsx → Sender/Sender.tsx} +161 -5
  87. package/src/components/chat/tools/DefaultTool.tsx +184 -21
  88. package/src/components/chat/tools/adapter-claude/BashTool.scss +67 -51
  89. package/src/components/chat/tools/adapter-claude/BashTool.tsx +83 -49
  90. package/src/components/chat/tools/adapter-claude/GlobTool.scss +0 -79
  91. package/src/components/chat/tools/adapter-claude/GlobTool.tsx +16 -36
  92. package/src/components/chat/tools/adapter-claude/GrepTool.scss +0 -87
  93. package/src/components/chat/tools/adapter-claude/GrepTool.tsx +22 -41
  94. package/src/components/chat/tools/adapter-claude/LSTool.scss +0 -79
  95. package/src/components/chat/tools/adapter-claude/LSTool.tsx +15 -15
  96. package/src/components/chat/tools/adapter-claude/ReadTool.scss +0 -55
  97. package/src/components/chat/tools/adapter-claude/ReadTool.tsx +20 -42
  98. package/src/components/chat/tools/adapter-claude/TodoTool.scss +8 -23
  99. package/src/components/chat/tools/adapter-claude/TodoTool.tsx +24 -11
  100. package/src/components/chat/tools/adapter-claude/WriteTool.scss +21 -69
  101. package/src/components/chat/tools/adapter-claude/WriteTool.tsx +22 -58
  102. package/src/components/chat/tools/adapter-claude/index.ts +4 -10
  103. package/src/components/chat/tools/adapter-claude/utils.ts +54 -0
  104. package/src/components/chat/tools/core/ToolCallBox.scss +356 -0
  105. package/src/components/chat/{ToolGroup.tsx → tools/core/ToolGroup.tsx} +26 -7
  106. package/src/components/chat/{ToolRenderer.tsx → tools/core/ToolRenderer.tsx} +6 -4
  107. package/src/components/chat/tools/plugin-chrome-devtools/ChromeDevtoolsTool.scss +11 -0
  108. package/src/components/chat/tools/plugin-chrome-devtools/ChromeDevtoolsTool.tsx +75 -0
  109. package/src/components/chat/tools/plugin-chrome-devtools/index.ts +45 -0
  110. package/src/components/chat/tools/task/GetTaskInfoTool.scss +2 -27
  111. package/src/components/chat/tools/task/GetTaskInfoTool.tsx +48 -38
  112. package/src/components/chat/tools/task/ListTasksTool.scss +3 -28
  113. package/src/components/chat/tools/task/ListTasksTool.tsx +11 -8
  114. package/src/components/chat/tools/task/StartTasksTool.scss +3 -28
  115. package/src/components/chat/tools/task/StartTasksTool.tsx +14 -17
  116. package/src/components/chat/tools/task/components/TaskRow.scss +105 -0
  117. package/src/components/chat/tools/task/components/TaskRow.tsx +163 -0
  118. package/src/components/chat/tools/task/components/TaskToolCard.scss +15 -15
  119. package/src/components/chat/tools/task/components/TaskToolCard.tsx +8 -6
  120. package/src/components/config/ConfigSectionForm.tsx +12 -1
  121. package/src/components/config/channelDefinitions.ts +6 -0
  122. package/src/components/config/configSchema.ts +10 -1
  123. package/src/components/config/recordEditors/ChannelRecordEditor.scss +1 -0
  124. package/src/components/config/recordEditors/ChannelRecordEditor.tsx +397 -0
  125. package/src/components/config/recordEditors/index.tsx +1 -0
  126. package/src/components/knowledge-base/components/RuleItem.tsx +1 -1
  127. package/src/components/knowledge-base/components/SpecItem.tsx +1 -1
  128. package/src/hooks/chat/use-chat-interaction.ts +26 -0
  129. package/src/{components/chat/useChatModels.tsx → hooks/chat/use-chat-models.tsx} +46 -15
  130. package/src/hooks/chat/use-chat-permission-mode.ts +47 -0
  131. package/src/hooks/chat/use-chat-scroll.ts +51 -0
  132. package/src/hooks/chat/use-chat-session-actions.ts +147 -0
  133. package/src/hooks/chat/use-chat-session-messages.ts +250 -0
  134. package/src/hooks/chat/use-chat-session.ts +57 -0
  135. package/src/hooks/chat/use-chat-view.ts +39 -0
  136. package/src/main.tsx +10 -13
  137. package/src/resources/locales/en.json +66 -0
  138. package/src/resources/locales/zh.json +66 -0
  139. package/src/runtime-config.ts +52 -0
  140. package/src/vite-env.d.ts +11 -0
  141. package/src/ws.ts +5 -3
  142. package/vite.config.ts +12 -4
  143. package/dist/assets/channel-jbCEHqbG.js +0 -1
  144. package/dist/assets/clone-CCRKqS4L.js +0 -1
  145. package/dist/assets/flowDiagram-v2-4f6560a1-Baslbgn4.js +0 -1
  146. package/dist/assets/index-B0qfCb1G.css +0 -1
  147. package/dist/assets/index-CNo75dYr.js +0 -497
  148. package/src/components/chat/ToolCallBox.scss +0 -137
  149. package/src/components/chat/useChatSession.ts +0 -370
  150. /package/src/components/{chat/CodeBlock.scss → CodeBlock.scss} +0 -0
  151. /package/src/components/chat/{MessageFooter.tsx → Messages/MessageFooter.tsx} +0 -0
  152. /package/src/components/chat/{CompletionMenu.scss → Sender/CompletionMenu.scss} +0 -0
  153. /package/src/components/chat/{CompletionMenu.tsx → Sender/CompletionMenu.tsx} +0 -0
  154. /package/src/components/chat/{ThinkingStatus.scss → Sender/ThinkingStatus.scss} +0 -0
  155. /package/src/components/chat/{ThinkingStatus.tsx → Sender/ThinkingStatus.tsx} +0 -0
  156. /package/src/components/chat/{ToolCallBox.tsx → tools/core/ToolCallBox.tsx} +0 -0
  157. /package/src/components/chat/{ToolGroup.scss → tools/core/ToolGroup.scss} +0 -0
  158. /package/src/{components/chat/safeSerialize.ts → utils/safe-serialize.ts} +0 -0
@@ -0,0 +1,182 @@
1
+ .benchmark-view {
2
+ // Sidebar container
3
+ &__sidebar {
4
+ width: 408px;
5
+ height: 100%;
6
+ display: flex;
7
+ flex-direction: column;
8
+ gap: 16px;
9
+ overflow: hidden;
10
+ padding: 24px;
11
+ }
12
+
13
+ &__sidebar-header {
14
+ display: flex;
15
+ align-items: center;
16
+ gap: 8px;
17
+ flex-shrink: 0;
18
+
19
+ height: 32px;
20
+ }
21
+
22
+ &__sidebar-title.ant-typography {
23
+ font-size: 18px;
24
+ margin: 0;
25
+ }
26
+
27
+ &__sep.ant-divider {
28
+ margin: 0;
29
+ border-color: var(--border-color);
30
+ }
31
+
32
+ // Search row
33
+ &__search {
34
+ flex: 1;
35
+ min-width: 0;
36
+ }
37
+
38
+ &__search-row {
39
+ display: flex;
40
+ align-items: center;
41
+ gap: 6px;
42
+ flex-shrink: 0;
43
+ }
44
+
45
+ &__search-icon {
46
+ font-size: 16px;
47
+ color: var(--sub-text-color);
48
+ }
49
+
50
+ // Tree
51
+ &__tree-shell {
52
+ flex: 1;
53
+ min-height: 0;
54
+ overflow: auto;
55
+ }
56
+
57
+ &__tree-shell .ant-tree {
58
+ background: transparent;
59
+ }
60
+
61
+ &__tree-shell .ant-tree-list-holder-inner {
62
+ gap: 2px;
63
+ }
64
+
65
+ &__tree-shell .ant-tree-node-content-wrapper {
66
+ min-width: 0;
67
+ padding: 0 !important;
68
+ }
69
+
70
+ &__tree-shell .ant-tree-node-content-wrapper.ant-tree-node-selected,
71
+ &__tree-shell .ant-tree-node-content-wrapper:hover {
72
+ background: transparent !important;
73
+ }
74
+
75
+ &__tree-shell .ant-tree-treenode {
76
+ align-items: center;
77
+ padding: 0 !important;
78
+ }
79
+
80
+ &__tree-shell .ant-tree-switcher {
81
+ color: var(--sub-text-color);
82
+ align-self: center;
83
+ }
84
+
85
+ &__switcher {
86
+ font-size: 20px;
87
+ display: block;
88
+ transition: transform 0.2s ease;
89
+ }
90
+
91
+ &__tree-shell .ant-tree-switcher_open &__switcher {
92
+ transform: rotate(90deg);
93
+ }
94
+
95
+ &__tree-shell .ant-tree-switcher_close &__switcher {
96
+ transform: rotate(0deg);
97
+ }
98
+
99
+ &__tree-empty {
100
+ min-height: 100px;
101
+ display: grid;
102
+ place-items: center;
103
+ }
104
+
105
+ &__tree-category,
106
+ &__tree-case {
107
+ display: flex;
108
+ align-items: center;
109
+ gap: 6px;
110
+ padding: 5px 4px;
111
+ border-radius: 6px;
112
+ min-width: 0;
113
+ transition: background-color 0.15s;
114
+ }
115
+
116
+ &__tree-category {
117
+ padding: 7px 4px;
118
+ }
119
+
120
+ &__tree-shell .ant-tree-node-content-wrapper:hover &__tree-category,
121
+ &__tree-shell .ant-tree-node-content-wrapper:hover &__tree-case,
122
+ &__tree-shell .ant-tree-node-content-wrapper.ant-tree-node-selected &__tree-case {
123
+ background: var(--sub-bg-color);
124
+ }
125
+
126
+ &__tree-icon {
127
+ font-size: 16px;
128
+ flex-shrink: 0;
129
+ color: var(--sub-text-color);
130
+ }
131
+
132
+ &__tree-icon--category {
133
+ color: var(--warning-color);
134
+ }
135
+
136
+ &__tree-title {
137
+ flex: 1;
138
+ min-width: 0;
139
+ overflow: hidden;
140
+ text-overflow: ellipsis;
141
+ white-space: nowrap;
142
+ font-size: 13px;
143
+ }
144
+
145
+ &__tree-run-btn {
146
+ flex-shrink: 0;
147
+ opacity: 0;
148
+ transition: opacity 0.15s;
149
+ }
150
+
151
+ &__tree-run-btn--category {
152
+ opacity: 1;
153
+ }
154
+
155
+ &__tree-shell .ant-tree-node-content-wrapper:hover &__tree-run-btn,
156
+ &__tree-shell .ant-tree-node-content-wrapper.ant-tree-node-selected &__tree-run-btn {
157
+ opacity: 1;
158
+ }
159
+
160
+ // Status icons in tree
161
+ &__status-icon {
162
+ font-size: 16px;
163
+ flex-shrink: 0;
164
+ }
165
+
166
+ &__status-icon--pass {
167
+ color: var(--success-color);
168
+ }
169
+
170
+ &__status-icon--partial {
171
+ color: var(--warning-color);
172
+ }
173
+
174
+ &__status-icon--fail {
175
+ color: var(--danger-color);
176
+ }
177
+
178
+ &__status-icon--no-result {
179
+ color: var(--sub-sub-text-color);
180
+ opacity: 0.5;
181
+ }
182
+ }
@@ -0,0 +1,262 @@
1
+ import './BenchmarkSidebar.scss'
2
+
3
+ import { Badge, Button, Divider, Empty, Input, Tooltip, Tree, Typography } from 'antd'
4
+ import React, { useMemo } from 'react'
5
+ import { useTranslation } from 'react-i18next'
6
+
7
+ import type { BenchmarkCase, BenchmarkCategory } from '@vibe-forge/core'
8
+
9
+ import type { TreeNodeCase } from './types.js'
10
+ import { getResultStatusMeta } from './utils.js'
11
+
12
+ function ResultStatusIcon({ result }: { result: import('@vibe-forge/core').BenchmarkResult | null | undefined }) {
13
+ const meta = getResultStatusMeta(result)
14
+ return (
15
+ <span className={`material-symbols-rounded benchmark-view__status-icon benchmark-view__status-icon--${meta.statusKey}`}>
16
+ {meta.icon}
17
+ </span>
18
+ )
19
+ }
20
+
21
+ // ─── Tree builder ─────────────────────────────────────────────────────────────
22
+
23
+ function buildCaseTreeData(params: {
24
+ categories: BenchmarkCategory[]
25
+ cases: BenchmarkCase[]
26
+ query: string
27
+ t: ReturnType<typeof useTranslation>['t']
28
+ onRunCase: (item: BenchmarkCase) => void
29
+ onRunCategory: (category: string) => void
30
+ }) {
31
+ const { categories, cases, query, t, onRunCase, onRunCategory } = params
32
+ const keyword = query.trim().toLowerCase()
33
+
34
+ const categoriesOrder = categories.length > 0
35
+ ? categories
36
+ : Array.from(new Set(cases.map(item => item.category))).map(category => ({
37
+ category,
38
+ caseCount: cases.filter(item => item.category === category).length,
39
+ lastStatuses: { pass: 0, partial: 0, fail: 0 }
40
+ }))
41
+
42
+ return categoriesOrder
43
+ .map((category) => {
44
+ const categoryCases = cases.filter(item => item.category === category.category)
45
+ const categoryMatches = keyword === '' || category.category.toLowerCase().includes(keyword)
46
+ const matchedCases = categoryMatches
47
+ ? categoryCases
48
+ : categoryCases.filter((item) => {
49
+ const rfcTitle = item.frontmatter.title ?? ''
50
+ return (
51
+ item.title.toLowerCase().includes(keyword) ||
52
+ rfcTitle.toLowerCase().includes(keyword)
53
+ )
54
+ })
55
+
56
+ if (matchedCases.length === 0) return null
57
+
58
+ return {
59
+ key: `category:${category.category}`,
60
+ selectable: true,
61
+ title: (
62
+ <div className='benchmark-view__tree-category'>
63
+ <span className='material-symbols-rounded benchmark-view__tree-icon benchmark-view__tree-icon--category'>folder_open</span>
64
+ <Typography.Text strong className='benchmark-view__tree-title'>
65
+ {category.category}
66
+ </Typography.Text>
67
+ <Tooltip title={t('benchmark.runCategory')}>
68
+ <Button
69
+ type='text'
70
+ size='small'
71
+ className='benchmark-view__tree-run-btn benchmark-view__tree-run-btn--category'
72
+ icon={<span className='material-symbols-rounded'>play_circle</span>}
73
+ onClick={(e) => {
74
+ e.stopPropagation()
75
+ onRunCategory(category.category)
76
+ }}
77
+ />
78
+ </Tooltip>
79
+ </div>
80
+ ),
81
+ children: matchedCases.map((item) => {
82
+ const nodeCase: TreeNodeCase = { ...item, key: `case:${item.category}/${item.title}` }
83
+ const displayTitle = item.frontmatter.title ?? item.title
84
+ return {
85
+ key: nodeCase.key,
86
+ isLeaf: true,
87
+ title: (
88
+ <div className='benchmark-view__tree-case'>
89
+ <ResultStatusIcon result={nodeCase.latestResult} />
90
+ <span className='material-symbols-rounded benchmark-view__tree-icon'>draft</span>
91
+ <Typography.Text className='benchmark-view__tree-title'>{displayTitle}</Typography.Text>
92
+ <Tooltip title={t('benchmark.runCase')}>
93
+ <Button
94
+ type='text'
95
+ size='small'
96
+ className='benchmark-view__tree-run-btn'
97
+ icon={<span className='material-symbols-rounded'>play_circle</span>}
98
+ onClick={(e) => {
99
+ e.stopPropagation()
100
+ onRunCase(item)
101
+ }}
102
+ />
103
+ </Tooltip>
104
+ </div>
105
+ ),
106
+ caseData: nodeCase
107
+ }
108
+ })
109
+ }
110
+ })
111
+ .filter(Boolean)
112
+ }
113
+
114
+ // ─── Component ────────────────────────────────────────────────────────────────
115
+
116
+ interface BenchmarkSidebarProps {
117
+ cases: BenchmarkCase[]
118
+ categories: BenchmarkCategory[]
119
+ selectedCase: BenchmarkCase | null
120
+ query: string
121
+ expandedKeys: string[]
122
+ checkedKeys: string[]
123
+ checkedCaseCount: number
124
+ onQueryChange: (value: string) => void
125
+ onExpandedKeysChange: (keys: string[]) => void
126
+ onCheckedKeysChange: (keys: string[]) => void
127
+ onSelectCase: (category: string, title: string) => void
128
+ onRunCase: (item: BenchmarkCase) => void
129
+ onRunCategory: (category: string) => void
130
+ onBatchRun: () => void
131
+ }
132
+
133
+ export function BenchmarkSidebar({
134
+ cases,
135
+ categories,
136
+ selectedCase,
137
+ query,
138
+ expandedKeys,
139
+ checkedKeys,
140
+ checkedCaseCount,
141
+ onQueryChange,
142
+ onExpandedKeysChange,
143
+ onCheckedKeysChange,
144
+ onSelectCase,
145
+ onRunCase,
146
+ onRunCategory,
147
+ onBatchRun
148
+ }: BenchmarkSidebarProps) {
149
+ const { t } = useTranslation()
150
+
151
+ const treeData = useMemo(() =>
152
+ buildCaseTreeData({
153
+ categories,
154
+ cases,
155
+ query,
156
+ t,
157
+ onRunCase,
158
+ onRunCategory
159
+ }),
160
+ [cases, categories, query, t]
161
+ )
162
+
163
+ const handleTreeCheck = (
164
+ checked: React.Key[] | { checked: React.Key[]; halfChecked: React.Key[] }
165
+ ) => {
166
+ const keys = Array.isArray(checked) ? checked : checked.checked
167
+ onCheckedKeysChange(keys.map(String))
168
+ }
169
+
170
+ const handleTreeSelect = (_keys: React.Key[], info: {
171
+ node: {
172
+ key: React.Key
173
+ caseData?: TreeNodeCase
174
+ }
175
+ }) => {
176
+ const caseData = info.node.caseData
177
+ if (caseData != null) {
178
+ onSelectCase(caseData.category, caseData.title)
179
+ return
180
+ }
181
+ const categoryKey = String(info.node.key)
182
+ if (!categoryKey.startsWith('category:')) return
183
+ const category = categoryKey.replace('category:', '')
184
+ const nextCase = cases.find(item => item.category === category)
185
+ onSelectCase(category, nextCase?.title ?? '')
186
+ }
187
+
188
+ return (
189
+ <div className='benchmark-view__sidebar'>
190
+ <div className='benchmark-view__sidebar-header'>
191
+ <Typography.Title level={4} className='benchmark-view__sidebar-title'>
192
+ {t('benchmark.title')}
193
+ </Typography.Title>
194
+ </div>
195
+
196
+ <div className='benchmark-view__search-row'>
197
+ <Input
198
+ value={query}
199
+ placeholder={t('benchmark.searchPlaceholder')}
200
+ prefix={<span className='material-symbols-rounded benchmark-view__search-icon'>search</span>}
201
+ allowClear
202
+ onChange={event => onQueryChange(event.target.value)}
203
+ className='benchmark-view__search'
204
+ />
205
+ <Tooltip title={t('benchmark.expandAll')}>
206
+ <Button
207
+ type='text'
208
+ size='small'
209
+ icon={<span className='material-symbols-rounded'>unfold_more</span>}
210
+ onClick={() => onExpandedKeysChange(categories.map(item => `category:${item.category}`))}
211
+ />
212
+ </Tooltip>
213
+ <Tooltip title={t('benchmark.collapseAll')}>
214
+ <Button
215
+ type='text'
216
+ size='small'
217
+ icon={<span className='material-symbols-rounded'>unfold_less</span>}
218
+ onClick={() => onExpandedKeysChange([])}
219
+ />
220
+ </Tooltip>
221
+ <Tooltip
222
+ title={checkedCaseCount > 0
223
+ ? t('benchmark.runSelected', { count: checkedCaseCount })
224
+ : t('benchmark.runAll')}
225
+ >
226
+ <Badge count={checkedCaseCount} size='small'>
227
+ <Button
228
+ type='text'
229
+ size='small'
230
+ icon={<span className='material-symbols-rounded'>play_circle</span>}
231
+ onClick={onBatchRun}
232
+ />
233
+ </Badge>
234
+ </Tooltip>
235
+ </div>
236
+
237
+ <div className='benchmark-view__tree-shell'>
238
+ {treeData.length === 0
239
+ ? (
240
+ <div className='benchmark-view__tree-empty'>
241
+ <Empty description={t('benchmark.emptyCases')} image={Empty.PRESENTED_IMAGE_SIMPLE} />
242
+ </div>
243
+ )
244
+ : (
245
+ <Tree
246
+ blockNode
247
+ checkable
248
+ showIcon={false}
249
+ switcherIcon={<span className='material-symbols-rounded benchmark-view__switcher'>chevron_right</span>}
250
+ selectedKeys={selectedCase ? [`case:${selectedCase.category}/${selectedCase.title}`] : []}
251
+ expandedKeys={expandedKeys}
252
+ checkedKeys={checkedKeys}
253
+ treeData={treeData}
254
+ onExpand={(keys) => onExpandedKeysChange(keys.map(String))}
255
+ onSelect={handleTreeSelect}
256
+ onCheck={handleTreeCheck}
257
+ />
258
+ )}
259
+ </div>
260
+ </div>
261
+ )
262
+ }
@@ -0,0 +1,78 @@
1
+ .benchmark-view {
2
+ display: flex;
3
+ height: 100%;
4
+ overflow: hidden;
5
+
6
+ &__left {
7
+ display: flex;
8
+ flex-direction: column;
9
+ overflow: hidden;
10
+ }
11
+
12
+ &__divider {
13
+ width: 1px;
14
+ background: var(--border-color);
15
+ }
16
+
17
+ &__right {
18
+ flex: 1;
19
+ min-width: 0;
20
+ overflow: hidden;
21
+ padding: 24px 24px 24px 16px;
22
+ }
23
+
24
+ &__canvas {
25
+ height: 100%;
26
+ overflow: auto;
27
+ display: flex;
28
+ flex-direction: column;
29
+ padding-right: 4px;
30
+ }
31
+
32
+ &__empty {
33
+ height: 100%;
34
+ display: grid;
35
+ place-items: center;
36
+ }
37
+
38
+ &__sep.ant-divider {
39
+ margin: 0;
40
+ border-color: var(--border-color);
41
+ }
42
+ }
43
+
44
+ @media (max-width: 1100px) {
45
+ .benchmark-view {
46
+ flex-direction: column;
47
+
48
+ &__left {
49
+ width: 100%;
50
+ min-width: 0;
51
+ max-height: 300px;
52
+ padding-right: 0;
53
+ padding: 16px 16px 0;
54
+ }
55
+
56
+ &__divider {
57
+ width: 100%;
58
+ height: 1px;
59
+ }
60
+
61
+ &__right {
62
+ flex: 1;
63
+ padding: 0 16px 16px;
64
+ }
65
+ }
66
+ }
67
+
68
+ @media (max-width: 720px) {
69
+ .benchmark-view {
70
+ &__right {
71
+ padding: 0 12px 12px;
72
+ }
73
+
74
+ &__left {
75
+ padding: 12px 12px 0;
76
+ }
77
+ }
78
+ }