@zyro-sec/session-ui 0.0.0-stage → 1.0.4

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 (261) hide show
  1. package/AGENTS.md +25 -0
  2. package/bunfig.toml +2 -0
  3. package/component-tests/basic-tool.fixture.tsx +46 -0
  4. package/component-tests/basic-tool.spec.ts +63 -0
  5. package/component-tests/file-media.fixture.tsx +39 -0
  6. package/component-tests/file-media.spec.ts +13 -0
  7. package/component-tests/file-tool.spec.ts +62 -0
  8. package/component-tests/file-viewer.fixture.tsx +109 -0
  9. package/component-tests/file-viewer.spec.ts +134 -0
  10. package/component-tests/file.spec.ts +33 -0
  11. package/component-tests/line-comment-v2.spec.ts +15 -0
  12. package/component-tests/markdown-code-wrap.spec.ts +94 -0
  13. package/component-tests/markdown-readiness.spec.ts +95 -0
  14. package/component-tests/markdown.fixture.tsx +104 -0
  15. package/component-tests/markdown.spec.ts +1564 -0
  16. package/component-tests/mermaid-preview.spec.ts +43 -0
  17. package/component-tests/patch-group.spec.ts +79 -0
  18. package/component-tests/read-group.spec.ts +72 -0
  19. package/component-tests/read-image.fixture.tsx +66 -0
  20. package/component-tests/read-image.spec.ts +154 -0
  21. package/component-tests/session-compaction.spec.ts +254 -0
  22. package/component-tests/session-lifecycle.spec.ts +190 -0
  23. package/component-tests/session-message-projection.spec.ts +639 -0
  24. package/component-tests/session-notice-projection.spec.ts +20 -0
  25. package/component-tests/session-review-comments.spec.ts +179 -0
  26. package/component-tests/session-shell.spec.ts +93 -0
  27. package/component-tests/session-timeline-mobile.spec.ts +201 -0
  28. package/component-tests/session-timeline-notices.spec.ts +38 -0
  29. package/component-tests/session-timeline-reasoning.spec.ts +107 -0
  30. package/component-tests/session-timeline.spec.ts +157 -0
  31. package/component-tests/session-tool-projection.spec.ts +323 -0
  32. package/component-tests/text-lifecycle.fixture.tsx +26 -0
  33. package/component-tests/text-lifecycle.spec.ts +42 -0
  34. package/component-tests/timeline-subagent-rows.spec.ts +33 -0
  35. package/component-tests/tool-disclosure.spec.ts +48 -0
  36. package/component-tests/tool-group-sticky.spec.ts +37 -0
  37. package/component-tests/tool-group.spec.ts +290 -0
  38. package/component-tests/tool-status-title.fixture.tsx +22 -0
  39. package/component-tests/tool-status-title.spec.ts +30 -0
  40. package/component-tests/user-message-quotes.spec.ts +111 -0
  41. package/package.json +91 -4
  42. package/playwright.components.config.ts +4 -0
  43. package/playwright.local.config.ts +2 -0
  44. package/src/actions.ts +54 -0
  45. package/src/components/apply-patch-file.ts +122 -0
  46. package/src/components/basic-tool.css +487 -0
  47. package/src/components/basic-tool.tsx +258 -0
  48. package/src/components/copy-machine.ts +78 -0
  49. package/src/components/copy.ts +85 -0
  50. package/src/components/diagram-preview.tsx +28 -0
  51. package/src/components/disclosure-machine.ts +188 -0
  52. package/src/components/disclosure.ts +129 -0
  53. package/src/components/dock-prompt.stories.tsx +73 -0
  54. package/src/components/dock-prompt.tsx +29 -0
  55. package/src/components/file-comment-selection.tsx +146 -0
  56. package/src/components/file-media-machine.ts +165 -0
  57. package/src/components/file-media.stories.tsx +112 -0
  58. package/src/components/file-media.tsx +323 -0
  59. package/src/components/file-search.tsx +73 -0
  60. package/src/components/file.css +59 -0
  61. package/src/components/file.tsx +1300 -0
  62. package/src/components/image-preview.tsx +35 -0
  63. package/src/components/line-comment-annotations.tsx +580 -0
  64. package/src/components/line-comment-machine.ts +262 -0
  65. package/src/components/line-comment-styles.ts +293 -0
  66. package/src/components/line-comment.stories.tsx +152 -0
  67. package/src/components/line-comment.tsx +448 -0
  68. package/src/components/link-segments.ts +20 -0
  69. package/src/components/linked-text.tsx +21 -0
  70. package/src/components/markdown-cache-machine.ts +257 -0
  71. package/src/components/markdown-cache.tsx +556 -0
  72. package/src/components/markdown-clipboard.ts +101 -0
  73. package/src/components/markdown-code-machine.ts +200 -0
  74. package/src/components/markdown-code-state.ts +22 -0
  75. package/src/components/markdown-fragment-links.ts +74 -0
  76. package/src/components/markdown-github.svg +3 -0
  77. package/src/components/markdown-globe.svg +5 -0
  78. package/src/components/markdown-image-machine.ts +170 -0
  79. package/src/components/markdown-image.ts +156 -0
  80. package/src/components/markdown-inline-code-kind.ts +39 -0
  81. package/src/components/markdown-mermaid.ts +18 -0
  82. package/src/components/markdown-phase-machine.ts +102 -0
  83. package/src/components/markdown-projection.ts +13 -0
  84. package/src/components/markdown-session-links.ts +183 -0
  85. package/src/components/markdown-solid.test.tsx +92 -0
  86. package/src/components/markdown-solid.tsx +113 -0
  87. package/src/components/markdown-stream.ts +95 -0
  88. package/src/components/markdown-worker-machine.ts +516 -0
  89. package/src/components/markdown-worker-protocol.ts +73 -0
  90. package/src/components/markdown-worker.ts +250 -0
  91. package/src/components/markdown.css +672 -0
  92. package/src/components/markdown.stories.tsx +199 -0
  93. package/src/components/markdown.tsx +1612 -0
  94. package/src/components/markdown.worker.ts +188 -0
  95. package/src/components/message-file.ts +102 -0
  96. package/src/components/message-nav.css +134 -0
  97. package/src/components/message-nav.tsx +159 -0
  98. package/src/components/message-part.css +2109 -0
  99. package/src/components/message-part.tsx +3 -0
  100. package/src/components/question-prompt-experimental.css +576 -0
  101. package/src/components/question-prompt.css +527 -0
  102. package/src/components/quote-highlight.css +59 -0
  103. package/src/components/review-focus-driver.ts +142 -0
  104. package/src/components/review-focus-machine.ts +95 -0
  105. package/src/components/session-compaction.css +270 -0
  106. package/src/components/session-diff.ts +358 -0
  107. package/src/components/session-error.tsx +41 -0
  108. package/src/components/session-retry.tsx +92 -0
  109. package/src/components/session-review-machine.ts +241 -0
  110. package/src/components/session-review.css +264 -0
  111. package/src/components/session-review.stories.tsx +232 -0
  112. package/src/components/session-review.tsx +733 -0
  113. package/src/components/session-turn.css +282 -0
  114. package/src/components/shell-submessage.css +24 -0
  115. package/src/components/timeline-separator.tsx +69 -0
  116. package/src/components/tool-count-label.css +57 -0
  117. package/src/components/tool-count-label.tsx +76 -0
  118. package/src/components/tool-count-summary.css +102 -0
  119. package/src/components/tool-count-summary.stories.tsx +99 -0
  120. package/src/components/tool-count-summary.tsx +44 -0
  121. package/src/components/tool-error-card.css +178 -0
  122. package/src/components/tool-error-card.stories.tsx +113 -0
  123. package/src/components/tool-error-card.tsx +202 -0
  124. package/src/components/tool-status-title-machine.ts +128 -0
  125. package/src/components/tool-status-title.css +89 -0
  126. package/src/components/tool-status-title.tsx +163 -0
  127. package/src/context/data.tsx +107 -0
  128. package/src/context/index.ts +1 -0
  129. package/src/context/markdown.tsx +129 -0
  130. package/src/context/sources.tsx +34 -0
  131. package/src/document.ts +8 -0
  132. package/src/file-presentation.ts +34 -0
  133. package/src/message/action-machine.ts +72 -0
  134. package/src/message/agent-label.ts +3 -0
  135. package/src/message/attachment-card.css +119 -0
  136. package/src/message/attachment-card.tsx +40 -0
  137. package/src/message/attachment-media-machine.ts +213 -0
  138. package/src/message/comment-card.tsx +155 -0
  139. package/src/message/compaction-entrance-machine.ts +93 -0
  140. package/src/message/current-message.tsx +157 -0
  141. package/src/message/current-tool-state.ts +161 -0
  142. package/src/message/message-content.tsx +1391 -0
  143. package/src/message/paced-text-machine.ts +73 -0
  144. package/src/message/prompt-message.stories.tsx +149 -0
  145. package/src/message/relative-time.ts +45 -0
  146. package/src/message/user-message-quote-parts.ts +16 -0
  147. package/src/message/user-message-quotes.stories.tsx +797 -0
  148. package/src/message/user-message-quotes.tsx +135 -0
  149. package/src/pierre/comment-hover-machine.ts +53 -0
  150. package/src/pierre/comment-hover.ts +131 -0
  151. package/src/pierre/comment-selection-machine.ts +257 -0
  152. package/src/pierre/commented-lines.ts +106 -0
  153. package/src/pierre/diff-selection.ts +91 -0
  154. package/src/pierre/file-find-machine.ts +323 -0
  155. package/src/pierre/file-find.ts +537 -0
  156. package/src/pierre/file-runtime.ts +42 -0
  157. package/src/pierre/file-selection.ts +140 -0
  158. package/src/pierre/index.ts +344 -0
  159. package/src/pierre/media.ts +140 -0
  160. package/src/pierre/render-machine.ts +381 -0
  161. package/src/pierre/selection-bridge.ts +82 -0
  162. package/src/pierre/selection-machine.ts +198 -0
  163. package/src/pierre/virtualizer.ts +114 -0
  164. package/src/pierre/worker.ts +46 -0
  165. package/src/sources/experiment.ts +59 -0
  166. package/src/sources/site-icon.tsx +53 -0
  167. package/src/sources/sources-chip.tsx +57 -0
  168. package/src/sources/sources-expand-machine.ts +101 -0
  169. package/src/sources/sources-panel.tsx +249 -0
  170. package/src/sources/sources-title.tsx +21 -0
  171. package/src/sources/sources.css +266 -0
  172. package/src/sources/sources.ts +141 -0
  173. package/src/storybook/current-session-fixtures.ts +1492 -0
  174. package/src/storybook/current-session-scenarios.ts +76 -0
  175. package/src/storybook/current-session-story.tsx +154 -0
  176. package/src/storybook/index.ts +43 -0
  177. package/src/styles/index.css +19 -0
  178. package/src/timeline/__snapshots__/group-labels.test.ts.snap +110 -0
  179. package/src/timeline/__snapshots__/placement.test.ts.snap +1041 -0
  180. package/src/timeline/code-blocks.stories.tsx +105 -0
  181. package/src/timeline/commentary.stories.tsx +70 -0
  182. package/src/timeline/commentary.ts +38 -0
  183. package/src/timeline/detail.ts +111 -0
  184. package/src/timeline/error-card.stories.tsx +134 -0
  185. package/src/timeline/error-spacing.stories.tsx +71 -0
  186. package/src/timeline/facts.ts +493 -0
  187. package/src/timeline/file-changes.stories.tsx +436 -0
  188. package/src/timeline/group-label-fixtures.ts +97 -0
  189. package/src/timeline/mermaid.stories.tsx +131 -0
  190. package/src/timeline/place.ts +280 -0
  191. package/src/timeline/placement-fixtures.ts +365 -0
  192. package/src/timeline/placement-reactivity.ts +133 -0
  193. package/src/timeline/projection.ts +1261 -0
  194. package/src/timeline/research-and-agents.stories.tsx +461 -0
  195. package/src/timeline/session-timeline-row.tsx +1675 -0
  196. package/src/timeline/session-timeline.tsx +68 -0
  197. package/src/timeline/steer-arrival-machine.ts +134 -0
  198. package/src/timeline/terminal-work.stories.tsx +464 -0
  199. package/src/timeline/timeline-row.stories.tsx +1069 -0
  200. package/src/timeline/timeline-row.ts +238 -0
  201. package/src/timeline/turn-phase-machine.ts +112 -0
  202. package/src/timeline/user-message-fold.stories.tsx +194 -0
  203. package/src/timeline/user-runs.ts +87 -0
  204. package/src/timeline-next/__snapshots__/placement.test.ts.snap +990 -0
  205. package/src/timeline-next/compaction.tsx +236 -0
  206. package/src/timeline-next/errors.ts +101 -0
  207. package/src/timeline-next/event-row.tsx +168 -0
  208. package/src/timeline-next/events.ts +103 -0
  209. package/src/timeline-next/index.ts +10 -0
  210. package/src/timeline-next/nested-rail.ts +125 -0
  211. package/src/timeline-next/projection.ts +1028 -0
  212. package/src/timeline-next/row.tsx +1728 -0
  213. package/src/timeline-next/rules.ts +89 -0
  214. package/src/timeline-next/separator.tsx +73 -0
  215. package/src/timeline-next/spacing.ts +127 -0
  216. package/src/timeline-next/status-line.tsx +41 -0
  217. package/src/timeline-next/status.ts +33 -0
  218. package/src/timeline-next/stories/compare-renderer.stories.tsx +190 -0
  219. package/src/timeline-next/stories/compare-sessions/.gitignore +3 -0
  220. package/src/timeline-next/stories/compare.stories.tsx +486 -0
  221. package/src/timeline-next/stories/playground.stories.tsx +297 -0
  222. package/src/timeline-next/stories/session-replay.ts +1156 -0
  223. package/src/timeline-next/stories/session-timeline.tsx +50 -0
  224. package/src/timeline-next/stories/subagent-status.stories.tsx +132 -0
  225. package/src/timeline-next/timeline-next.css +649 -0
  226. package/src/timeline-next/tools/__snapshots__/activity-label.test.ts.snap +39 -0
  227. package/src/timeline-next/tools/activity-label.ts +166 -0
  228. package/src/timeline-next/tools/assistant-content.tsx +84 -0
  229. package/src/timeline-next/tools/context-group.tsx +619 -0
  230. package/src/timeline-next/tools/error-card.tsx +147 -0
  231. package/src/timeline-next/tools/explore.tsx +119 -0
  232. package/src/timeline-next/tools/file-group.tsx +128 -0
  233. package/src/timeline-next/tools/patch.tsx +174 -0
  234. package/src/timeline-next/tools/shell.tsx +186 -0
  235. package/src/timeline-next/tools/thought.tsx +87 -0
  236. package/src/timeline-next/tools/tool-display.tsx +119 -0
  237. package/src/tools/ansi.ts +8 -0
  238. package/src/tools/context-group-label.ts +123 -0
  239. package/src/tools/file-runs.ts +35 -0
  240. package/src/tools/project-path.ts +18 -0
  241. package/src/tools/read-group.stories.tsx +159 -0
  242. package/src/tools/run-machine.ts +185 -0
  243. package/src/tools/shell-output-machine.ts +233 -0
  244. package/src/tools/shell-output.ts +91 -0
  245. package/src/tools/subagent-row-variants.stories.tsx +129 -0
  246. package/src/tools/tool-group.stories.tsx +345 -0
  247. package/src/tools/tool-renderer.tsx +2876 -0
  248. package/src/v2/components/line-comment-annotations-v2.tsx +215 -0
  249. package/src/v2/components/session-file-panel-v2.tsx +149 -0
  250. package/src/v2/components/session-progress-indicator-v2.css +5 -0
  251. package/src/v2/components/session-progress-indicator-v2.stories.tsx +86 -0
  252. package/src/v2/components/session-progress-indicator-v2.tsx +16 -0
  253. package/src/v2/components/session-review-empty-changes-v2.tsx +17 -0
  254. package/src/v2/components/session-review-empty-no-git-v2.tsx +28 -0
  255. package/src/v2/components/session-review-file-preview-v2-virtualize.ts +5 -0
  256. package/src/v2/components/session-review-file-preview-v2.tsx +266 -0
  257. package/src/v2/components/session-review-v2.css +653 -0
  258. package/src/v2/components/session-review-v2.tsx +422 -0
  259. package/src/v2/components/sidebar-presence-machine.ts +69 -0
  260. package/tsconfig.json +20 -0
  261. package/README.md +0 -3
@@ -0,0 +1,99 @@
1
+ import { Button } from "@zyro-sec/ui/button"
2
+ import { createEffect } from "solid-js"
3
+ import { createStore } from "solid-js/store"
4
+ import { AnimatedCountList, type CountItem } from "./tool-count-summary"
5
+ import { ToolStatusTitle } from "./tool-status-title"
6
+
7
+ const text = {
8
+ active: "Exploring",
9
+ done: "Explored",
10
+ } as const
11
+
12
+ type Counts = { reads: number; searches: number; lists: number; active: boolean }
13
+
14
+ function ContextProgress(props: Counts) {
15
+ const [state, setState] = createStore({ ...props })
16
+
17
+ for (const key of ["reads", "searches", "lists", "active"] as const) {
18
+ createEffect(() => setState({ [key]: props[key] }))
19
+ }
20
+
21
+ const items = (): CountItem[] => [
22
+ { key: "ui.messagePart.context.read", count: state.reads },
23
+ { key: "ui.messagePart.context.search", count: state.searches },
24
+ { key: "ui.messagePart.context.list", count: state.lists },
25
+ ]
26
+
27
+ const reset = () => setState({ ...props })
28
+
29
+ return (
30
+ <div class="flex max-w-[620px] flex-col gap-5 rounded-lg border border-border-weak-base bg-background-base p-5">
31
+ <span class="flex min-w-0 items-center gap-2 text-14-medium text-text-strong">
32
+ <span class="shrink-0">
33
+ <ToolStatusTitle active={state.active} activeText={text.active} doneText={text.done} split={false} />
34
+ </span>
35
+ <span class="min-w-0 truncate text-14-regular text-text-base">
36
+ <AnimatedCountList items={items()} fallback="" />
37
+ </span>
38
+ </span>
39
+ <div class="flex flex-wrap gap-2">
40
+ <Button size="small" variant="neutral" onClick={() => setState("reads", (value) => value + 1)}>
41
+ Read file
42
+ </Button>
43
+ <Button size="small" variant="neutral" onClick={() => setState("searches", (value) => value + 1)}>
44
+ Search code
45
+ </Button>
46
+ <Button size="small" variant="neutral" onClick={() => setState("lists", (value) => value + 1)}>
47
+ List directory
48
+ </Button>
49
+ <Button size="small" variant="contrast" onClick={() => setState("active", false)}>
50
+ Finish
51
+ </Button>
52
+ <Button size="small" variant="ghost" onClick={reset}>
53
+ Reset
54
+ </Button>
55
+ </div>
56
+ </div>
57
+ )
58
+ }
59
+
60
+ export default {
61
+ title: "OpenCode/Work/Context progress",
62
+ id: "components-animated-count-list",
63
+ component: AnimatedCountList,
64
+ argTypes: Object.fromEntries(
65
+ ["reads", "searches", "lists"].map((key) => [key, { control: { type: "range", min: 0, max: 100, step: 1 } }]),
66
+ ),
67
+ parameters: {
68
+ docs: {
69
+ description: {
70
+ component:
71
+ "The production summary for grouped read, search, and list tools. The controls advance deterministic user actions without timers or random state.",
72
+ },
73
+ },
74
+ },
75
+ }
76
+
77
+ export const Exploring = {
78
+ args: { reads: 2, searches: 1, lists: 0, active: true },
79
+ render: (args: Counts) => <ContextProgress {...args} />,
80
+ }
81
+
82
+ export const Completed = {
83
+ args: { reads: 5, searches: 3, lists: 1, active: false },
84
+ render: (args: Counts) => (
85
+ <span class="flex items-center gap-2 text-14-medium text-text-strong">
86
+ <ToolStatusTitle active={args.active} activeText={text.active} doneText={text.done} split={false} />
87
+ <span class="text-14-regular text-text-base">
88
+ <AnimatedCountList
89
+ items={[
90
+ { key: "ui.messagePart.context.read", count: args.reads },
91
+ { key: "ui.messagePart.context.search", count: args.searches },
92
+ { key: "ui.messagePart.context.list", count: args.lists },
93
+ ]}
94
+ fallback=""
95
+ />
96
+ </span>
97
+ </span>
98
+ ),
99
+ }
@@ -0,0 +1,44 @@
1
+ import { Index, createMemo } from "solid-js"
2
+ import { useI18n, type UiI18nPluralKey } from "@zyro-sec/ui/context"
3
+ import { AnimatedCountLabel } from "./tool-count-label"
4
+
5
+ export type CountItem = {
6
+ key: UiI18nPluralKey
7
+ count: number
8
+ }
9
+
10
+ export function AnimatedCountList(props: { items: CountItem[]; fallback?: string; class?: string }) {
11
+ const i18n = useI18n()
12
+ const firstPositive = createMemo(() => props.items.findIndex((item) => item.count > 0))
13
+ const active = createMemo(() => props.items.flatMap((item, index) => (item.count > 0 ? [index] : [])))
14
+ const fallback = createMemo(() => props.fallback ?? "")
15
+ const showEmpty = createMemo(() => firstPositive() === -1 && fallback().length > 0)
16
+
17
+ return (
18
+ <span data-component="tool-count-summary" class={props.class}>
19
+ <span data-slot="tool-count-summary-empty" data-active={showEmpty() ? "true" : "false"}>
20
+ <span data-slot="tool-count-summary-empty-inner">{fallback()}</span>
21
+ </span>
22
+
23
+ <Index each={props.items}>
24
+ {(item, index) => {
25
+ const visible = createMemo(() => item().count > 0)
26
+ const position = createMemo(() => active().indexOf(index))
27
+
28
+ return (
29
+ <>
30
+ <span data-slot="tool-count-summary-prefix" data-active={visible() && position() > 0 ? "true" : "false"}>
31
+ {i18n.listSeparator(position(), active().length)}
32
+ </span>
33
+ <span data-slot="tool-count-summary-item" data-active={visible() ? "true" : "false"}>
34
+ <span data-slot="tool-count-summary-item-inner">
35
+ <AnimatedCountLabel plural={item().key} count={Math.max(0, Math.round(item().count))} />
36
+ </span>
37
+ </span>
38
+ </>
39
+ )
40
+ }}
41
+ </Index>
42
+ </span>
43
+ )
44
+ }
@@ -0,0 +1,178 @@
1
+ [data-component="card"][data-kind="tool-error-card"] {
2
+ --card-pad-y: 0px;
3
+ --card-line-pad: 0px;
4
+ --card-pad-r: 0px;
5
+ --card-pad-l: 0px;
6
+
7
+ &::before {
8
+ display: none;
9
+ }
10
+
11
+ /* Figma's leading-none would clip Inter descenders at 13px; keep the compact metric. */
12
+ [data-slot="basic-tool-tool-title"] {
13
+ font-family: var(--v2-font-family-sans);
14
+ font-size: 13px;
15
+ font-weight: 530;
16
+ line-height: var(--line-height-compact);
17
+ letter-spacing: -0.04px;
18
+ color: var(--v2-text-text-base);
19
+ }
20
+
21
+ [data-slot="basic-tool-tool-subtitle"] {
22
+ font-family: var(--v2-font-family-sans);
23
+ font-size: 13px;
24
+ font-weight: 440;
25
+ line-height: var(--line-height-compact);
26
+ letter-spacing: -0.04px;
27
+ color: var(--v2-text-text-muted);
28
+ }
29
+
30
+ [data-slot="tool-error-card-summary"] {
31
+ font-family: var(--v2-font-family-sans);
32
+ font-size: 13px;
33
+ font-weight: 440;
34
+ line-height: var(--line-height-compact);
35
+ letter-spacing: -0.04px;
36
+ color: var(--v2-state-fg-danger);
37
+ white-space: nowrap;
38
+ overflow: hidden;
39
+ text-overflow: ellipsis;
40
+ }
41
+
42
+ [data-slot="tool-error-card-summary"] {
43
+ flex-shrink: 1;
44
+ min-width: 0;
45
+ }
46
+
47
+ [data-slot="basic-tool-tool-info-main"] {
48
+ align-items: center;
49
+ gap: 6px;
50
+ }
51
+
52
+ [data-slot="basic-tool-tool-trigger-content"] {
53
+ /* Reserve the 14px arrow + 6px gap. */
54
+ max-width: calc(100% - 20px);
55
+ }
56
+
57
+ [data-slot="collapsible-arrow"] {
58
+ width: 14px;
59
+ height: 14px;
60
+ margin-inline-start: 6px;
61
+ /* Always visible; the base collapsible reveals arrows only on hover. */
62
+ opacity: 1;
63
+ }
64
+
65
+ [data-slot="collapsible-arrow"],
66
+ [data-slot="collapsible-arrow-icon"] {
67
+ color: var(--v2-text-text-faint);
68
+ }
69
+
70
+ > [data-component="collapsible"].tool-collapsible {
71
+ gap: 0px;
72
+
73
+ > [data-slot="collapsible-trigger"] {
74
+ height: 24px;
75
+ }
76
+
77
+ > [data-slot="collapsible-content"] {
78
+ border-inline-start: none;
79
+ margin-inline-start: 0;
80
+ padding-inline-start: 0;
81
+ padding-bottom: 0;
82
+
83
+ &::before {
84
+ display: none;
85
+ }
86
+ }
87
+ }
88
+
89
+ [data-component="tool-error-card-icon"] [data-slot="icon-svg"] {
90
+ color: var(--card-accent);
91
+ }
92
+
93
+ [data-slot="tool-error-card-content"] {
94
+ position: relative;
95
+ padding-left: 24px;
96
+ -webkit-user-select: text;
97
+ user-select: text;
98
+ }
99
+
100
+ [data-slot="tool-error-card-subtitle"],
101
+ [data-slot="tool-error-card-content"] [data-slot="card-description"] {
102
+ margin: 0;
103
+ font-family: var(--v2-font-family-sans);
104
+ font-size: 13px;
105
+ font-weight: 440;
106
+ line-height: var(--line-height-base);
107
+ letter-spacing: -0.04px;
108
+ white-space: pre-wrap;
109
+ overflow-wrap: anywhere;
110
+ }
111
+
112
+ &[data-tool="shell"] [data-slot="basic-tool-tool-subtitle"],
113
+ &[data-tool="shell"] [data-slot="tool-error-card-subtitle"] {
114
+ font-family: var(--v2-font-family-code);
115
+ }
116
+
117
+ [data-slot="tool-error-card-subtitle"] {
118
+ max-height: 240px;
119
+ overflow-y: auto;
120
+ margin-bottom: 4px;
121
+ color: var(--v2-text-text-muted);
122
+ }
123
+
124
+ [data-slot="tool-error-card-content"] [data-slot="card-description"] {
125
+ color: var(--v2-state-fg-danger);
126
+ }
127
+
128
+ > [data-component="collapsible"].tool-collapsible[data-open="true"] [data-slot="tool-error-card-content"] {
129
+ padding-right: 40px;
130
+ }
131
+
132
+ [data-slot="tool-error-card-copy"] {
133
+ position: absolute;
134
+ top: 0;
135
+ right: 0;
136
+ transition: opacity 0.15s ease;
137
+ will-change: opacity;
138
+
139
+ @media (hover: hover) {
140
+ opacity: 0;
141
+ pointer-events: none;
142
+ }
143
+ }
144
+
145
+ &:hover [data-slot="tool-error-card-copy"],
146
+ &:focus-within [data-slot="tool-error-card-copy"] {
147
+ opacity: 1;
148
+ pointer-events: auto;
149
+ }
150
+
151
+ [data-slot="tool-error-card-content"] {
152
+ --timeline-quote-background: var(--v2-state-bg-danger);
153
+ }
154
+
155
+ /* Matches the content, not each descendant, where highlights inherit; see quote-highlight.css. */
156
+ @supports selector(:host-context(*)) {
157
+ [data-slot="tool-error-card-content"]::selection,
158
+ [data-slot="tool-error-card-content"]::highlight(timeline-quote-source),
159
+ [data-slot="tool-error-card-content"]::highlight(timeline-quote-source-active) {
160
+ background: var(--v2-state-bg-danger);
161
+ color: var(--v2-text-text-base);
162
+ }
163
+ }
164
+
165
+ @supports not selector(:host-context(*)) {
166
+ [data-slot="tool-error-card-content"] :where(*)::selection,
167
+ [data-slot="tool-error-card-content"] :where(*)::highlight(timeline-quote-source),
168
+ [data-slot="tool-error-card-content"] :where(*)::highlight(timeline-quote-source-active) {
169
+ background: var(--v2-state-bg-danger);
170
+ color: var(--v2-text-text-base);
171
+ }
172
+ }
173
+
174
+ [data-slot="tool-error-card-content"] :where(*)::-moz-selection {
175
+ background: var(--v2-state-bg-danger);
176
+ color: var(--v2-text-text-base);
177
+ }
178
+ }
@@ -0,0 +1,113 @@
1
+ import { For } from "solid-js"
2
+ import { ToolErrorCard } from "./tool-error-card"
3
+
4
+ const docs = `### Overview
5
+ Tool call failure summary styled like a tool trigger.
6
+
7
+ ### API
8
+ - Required: \`tool\` (tool id, e.g. patch, shell)
9
+ - Required: \`error\` (error string)
10
+
11
+ ### Behavior
12
+ - Collapsible; click header to expand/collapse.
13
+ `
14
+
15
+ const samples: { tool: string; error: string; subtitle?: string; defaultOpen?: boolean }[] = [
16
+ {
17
+ tool: "shell",
18
+ subtitle: "sleep 30",
19
+ error: "Tool execution interrupted",
20
+ },
21
+ {
22
+ tool: "shell",
23
+ subtitle: "sleep 30",
24
+ error: "Tool execution interrupted",
25
+ defaultOpen: true,
26
+ },
27
+ {
28
+ tool: "patch",
29
+ error:
30
+ "patch verification failed: Failed to find expected lines in packages/session-ui/src/timeline/session-timeline.tsx",
31
+ },
32
+ {
33
+ tool: "shell",
34
+ error: "shell Command failed: exit code 1: bun test src/timeline",
35
+ },
36
+ {
37
+ tool: "read",
38
+ error:
39
+ "read File not found: /Users/davidhill/Documents/Local/opencode/packages/ui/src/components/does-not-exist.tsx",
40
+ },
41
+ {
42
+ tool: "glob",
43
+ error: "glob Pattern error: Invalid glob pattern: **/*[",
44
+ },
45
+ {
46
+ tool: "grep",
47
+ error: "grep Regex error: Invalid regular expression: (unterminated group",
48
+ },
49
+ {
50
+ tool: "webfetch",
51
+ error: "webfetch Request failed: 502 Bad Gateway",
52
+ },
53
+ {
54
+ tool: "websearch",
55
+ error: "websearch Rate limited: Please try again in 30 seconds",
56
+ },
57
+ {
58
+ tool: "question",
59
+ error: "question Dismissed: user dismissed this question",
60
+ },
61
+ ]
62
+
63
+ export default {
64
+ title: "OpenCode/Tools/Failure details",
65
+ id: "components-tool-error-card",
66
+ component: ToolErrorCard,
67
+ tags: ["autodocs"],
68
+ parameters: {
69
+ docs: {
70
+ description: {
71
+ component: docs,
72
+ },
73
+ },
74
+ },
75
+ args: {
76
+ tool: samples[0].tool,
77
+ error: samples[0].error,
78
+ subtitle: samples[0].subtitle,
79
+ defaultOpen: false,
80
+ },
81
+ argTypes: {
82
+ tool: {
83
+ control: "select",
84
+ options: ["patch", "shell", "read", "glob", "grep", "webfetch", "websearch", "question"],
85
+ },
86
+ error: {
87
+ control: "text",
88
+ },
89
+ subtitle: {
90
+ control: "text",
91
+ },
92
+ },
93
+ }
94
+
95
+ export const All = {
96
+ render: (args: { tool: string; error: string; subtitle?: string; defaultOpen: boolean }) => {
97
+ return (
98
+ <div style="display: flex; flex-direction: column; gap: 12px; max-width: 720px;">
99
+ <ToolErrorCard {...args} />
100
+ <For each={samples.slice(1)}>
101
+ {(item) => (
102
+ <ToolErrorCard
103
+ tool={item.tool}
104
+ error={item.error}
105
+ subtitle={item.subtitle}
106
+ defaultOpen={item.defaultOpen}
107
+ />
108
+ )}
109
+ </For>
110
+ </div>
111
+ )
112
+ },
113
+ }
@@ -0,0 +1,202 @@
1
+ import { type ComponentProps, createMemo, onMount, Show, splitProps } from "solid-js"
2
+ import { createStore } from "solid-js/store"
3
+ import { Card, CardDescription } from "@zyro-sec/ui/card"
4
+ import { Collapsible } from "@zyro-sec/ui/collapsible"
5
+ import { Icon } from "@zyro-sec/ui/icon"
6
+ import { IconButton } from "@zyro-sec/ui/icon-button"
7
+ import { Tooltip } from "@zyro-sec/ui/tooltip"
8
+ import { useI18n } from "@zyro-sec/ui/context/i18n"
9
+ import { createCopyFeedback } from "./copy"
10
+ import { createDisclosure } from "./disclosure"
11
+
12
+ export interface ToolErrorCardProps extends Omit<ComponentProps<typeof Card>, "children" | "variant"> {
13
+ tool: string
14
+ error: string
15
+ title?: string
16
+ defaultOpen?: boolean
17
+ open?: boolean
18
+ onOpenChange?: (open: boolean) => void
19
+ subtitle?: string
20
+ href?: string
21
+ onSubtitleClick?: (event: MouseEvent) => void
22
+ }
23
+
24
+ export function ToolErrorCard(props: ToolErrorCardProps) {
25
+ const i18n = useI18n()
26
+
27
+ const [state, setState] = createStore({ clipped: false })
28
+ const copy = createCopyFeedback()
29
+
30
+ const disclosure = createDisclosure({
31
+ open: () => props.open,
32
+ defaultOpen: () => props.defaultOpen ?? false,
33
+ onOpenChange: (open) => props.onOpenChange?.(open),
34
+ })
35
+
36
+ const open = disclosure.open
37
+ const copied = copy.copied
38
+ let subtitle: HTMLSpanElement | undefined
39
+
40
+ // Measured in the collapsed layout: a clipped subtitle moves from the one-line header into the open body.
41
+ const measure = () => {
42
+ if (!subtitle) return
43
+ setState("clipped", subtitle.textContent!.includes("\n") || subtitle.scrollWidth > subtitle.clientWidth)
44
+ }
45
+
46
+ onMount(() => {
47
+ if (open()) measure()
48
+ })
49
+
50
+ const [split, rest] = splitProps(props, [
51
+ "tool",
52
+ "error",
53
+ "title",
54
+ "defaultOpen",
55
+ "open",
56
+ "onOpenChange",
57
+ "subtitle",
58
+ "href",
59
+ "onSubtitleClick",
60
+ ])
61
+
62
+ const setOpen = (value: boolean) => {
63
+ if (value) measure()
64
+ disclosure.setOpen(value)
65
+ }
66
+
67
+ const name = createMemo(() => {
68
+ if (split.title) return split.title
69
+
70
+ const map = new Map([
71
+ ["read", "ui.tool.read"],
72
+ ["list", "ui.tool.list"],
73
+ ["glob", "ui.tool.glob"],
74
+ ["grep", "ui.tool.grep"],
75
+ ["subagent", "ui.tool.agent.default"],
76
+ ["webfetch", "ui.tool.webfetch"],
77
+ ["websearch", "ui.tool.websearch"],
78
+ ["shell", "ui.tool.shell"],
79
+ ["execute", "ui.tool.execute"],
80
+ ["edit", "ui.messagePart.title.edit"],
81
+ ["write", "ui.messagePart.title.write"],
82
+ ["skill", "ui.tool.skill"],
83
+ ["patch", "ui.tool.patch"],
84
+ ["question", "ui.tool.questions"],
85
+ ])
86
+
87
+ const key = map.get(split.tool)
88
+
89
+ if (!key) return split.tool
90
+
91
+ if (!key.includes(".")) return key
92
+
93
+ return i18n.t(key)
94
+ })
95
+
96
+ const cleaned = createMemo(() => split.error.replace(/^Error:\s*/, "").trim())
97
+
98
+ const tail = createMemo(() => {
99
+ const value = cleaned()
100
+ const prefix = `${split.tool} `
101
+
102
+ if (value.startsWith(prefix)) return value.slice(prefix.length)
103
+
104
+ return value
105
+ })
106
+
107
+ const summary = createMemo(() => {
108
+ const head = (tail().split(": ")[0] ?? "").trim()
109
+
110
+ if (!head) return i18n.t("ui.toolErrorCard.failed")
111
+
112
+ return head[0].toUpperCase() + head.slice(1)
113
+ })
114
+
115
+ const copyButton = () => (
116
+ <Tooltip
117
+ appearance="compact"
118
+ value={copied() ? i18n.t("ui.message.copied") : i18n.t("ui.toolErrorCard.copyError")}
119
+ placement="top"
120
+ gutter={4}
121
+ forceOpen={copied() || undefined}
122
+ >
123
+ <IconButton
124
+ icon={<Icon name={copied() ? "check" : "copy"} />}
125
+ size="normal"
126
+ variant="ghost"
127
+ onMouseDown={(e) => e.preventDefault()}
128
+ onClick={(e) => {
129
+ e.stopPropagation()
130
+ copy.copy(cleaned())
131
+ }}
132
+ aria-label={copied() ? i18n.t("ui.message.copied") : i18n.t("ui.toolErrorCard.copyError")}
133
+ />
134
+ </Tooltip>
135
+ )
136
+
137
+ return (
138
+ <Card
139
+ {...rest}
140
+ data-kind="tool-error-card"
141
+ data-tool={split.tool}
142
+ data-open={open() ? "true" : "false"}
143
+ variant="error"
144
+ >
145
+ <Collapsible class="tool-collapsible" data-open={open() ? "true" : "false"} open={open()} onOpenChange={setOpen}>
146
+ <Collapsible.Trigger>
147
+ <div data-component="tool-trigger">
148
+ <div data-slot="basic-tool-tool-trigger-content">
149
+ <span data-slot="basic-tool-tool-indicator" data-component="tool-error-card-icon">
150
+ <Icon name="outline-hexagonal-warning" />
151
+ </span>
152
+ <div data-slot="basic-tool-tool-info">
153
+ <div data-slot="basic-tool-tool-info-structured">
154
+ <div data-slot="basic-tool-tool-info-main">
155
+ <span data-slot="basic-tool-tool-title">{name()}</span>
156
+ <Show when={split.subtitle && (split.href || !(open() && state.clipped))}>
157
+ <Show
158
+ when={split.href}
159
+ fallback={
160
+ <span ref={subtitle} data-slot="basic-tool-tool-subtitle">
161
+ {split.subtitle}
162
+ </span>
163
+ }
164
+ >
165
+ <a
166
+ data-slot="basic-tool-tool-subtitle"
167
+ class="clickable subagent-link"
168
+ href={split.href!}
169
+ onClick={(event) => {
170
+ event.stopPropagation()
171
+ split.onSubtitleClick?.(event)
172
+ }}
173
+ >
174
+ {split.subtitle}
175
+ </a>
176
+ </Show>
177
+ </Show>
178
+ <Show when={!open()}>
179
+ <span data-slot="tool-error-card-summary">{summary()}</span>
180
+ </Show>
181
+ </div>
182
+ </div>
183
+ </div>
184
+ </div>
185
+ <Collapsible.Arrow />
186
+ </div>
187
+ </Collapsible.Trigger>
188
+ <Collapsible.Content>
189
+ <div data-slot="tool-error-card-content">
190
+ <Show when={open()}>
191
+ <div data-slot="tool-error-card-copy">{copyButton()}</div>
192
+ </Show>
193
+ <Show when={state.clipped && split.subtitle}>
194
+ {(text) => <p data-slot="tool-error-card-subtitle">{text()}</p>}
195
+ </Show>
196
+ <CardDescription>{cleaned()}</CardDescription>
197
+ </div>
198
+ </Collapsible.Content>
199
+ </Collapsible>
200
+ </Card>
201
+ )
202
+ }