@xemahq/ui-kernel 0.11.1 → 0.12.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 (257) hide show
  1. package/dist/errors/http-error-status.d.ts +17 -0
  2. package/dist/errors/http-error-status.d.ts.map +1 -0
  3. package/dist/errors/http-error-status.js +59 -0
  4. package/dist/errors/http-error-status.js.map +1 -0
  5. package/dist/errors/index.d.ts +2 -0
  6. package/dist/errors/index.d.ts.map +1 -0
  7. package/dist/errors/index.js +2 -0
  8. package/dist/errors/index.js.map +1 -0
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/lib/biome-host/errors.d.ts.map +1 -1
  14. package/dist/lib/biome-host/errors.js +1 -19
  15. package/dist/lib/biome-host/errors.js.map +1 -1
  16. package/dist/offline/index.d.ts.map +1 -1
  17. package/dist/offline/index.js.map +1 -1
  18. package/dist/offline/online-controller.d.ts.map +1 -1
  19. package/dist/offline/online-controller.js +6 -1
  20. package/dist/offline/online-controller.js.map +1 -1
  21. package/dist/offline/outbox.d.ts.map +1 -1
  22. package/dist/offline/outbox.js +2 -24
  23. package/dist/offline/outbox.js.map +1 -1
  24. package/package.json +1 -2
  25. package/src/index.ts +0 -17
  26. package/src/lib/biome-host/agent-validation.ts +0 -239
  27. package/src/lib/biome-host/biome-builders.ts +0 -112
  28. package/src/lib/biome-host/biome-mode.ts +0 -6
  29. package/src/lib/biome-host/biome-navigation.ts +0 -37
  30. package/src/lib/biome-host/biome-registry.ts +0 -299
  31. package/src/lib/biome-host/biome-scope-hooks.ts +0 -41
  32. package/src/lib/biome-host/biome-scope.tsx +0 -52
  33. package/src/lib/biome-host/biome-scoped-query.ts +0 -134
  34. package/src/lib/biome-host/create-biome-orval-config.ts +0 -82
  35. package/src/lib/biome-host/define-web-biome.spec.ts +0 -221
  36. package/src/lib/biome-host/define-web-biome.ts +0 -222
  37. package/src/lib/biome-host/errors.ts +0 -220
  38. package/src/lib/biome-host/frontend-biome.ts +0 -256
  39. package/src/lib/biome-host/host-bridge.ts +0 -281
  40. package/src/lib/biome-host/host-sources.ts +0 -54
  41. package/src/lib/biome-host/i18n-hooks.ts +0 -51
  42. package/src/lib/biome-host/i18n-port.test.ts +0 -50
  43. package/src/lib/biome-host/i18n-port.ts +0 -96
  44. package/src/lib/biome-host/index.ts +0 -35
  45. package/src/lib/biome-host/realtime-hooks.ts +0 -75
  46. package/src/lib/biome-host/realtime-port.ts +0 -115
  47. package/src/lib/biome-host/session-contributions.ts +0 -296
  48. package/src/lib/biome-host/use-mutation-with-error-toast.ts +0 -90
  49. package/src/lib/biome-host/use-page-state.ts +0 -248
  50. package/src/lib/capabilities/capability-context.ts +0 -25
  51. package/src/lib/capabilities/capability-provider.tsx +0 -73
  52. package/src/lib/capabilities/index.ts +0 -17
  53. package/src/lib/capabilities/types.ts +0 -69
  54. package/src/lib/capabilities/use-capability.ts +0 -79
  55. package/src/lib/contribution-registry/contribution-registry.spec.ts +0 -141
  56. package/src/lib/contribution-registry/contribution-registry.ts +0 -204
  57. package/src/lib/contribution-registry/index.ts +0 -9
  58. package/src/lib/contribution-registry/renderable-registry.ts +0 -142
  59. package/src/lib/system-bus/capability-invoke.ts +0 -92
  60. package/src/lib/system-bus/deeplink.ts +0 -210
  61. package/src/lib/system-bus/enums.ts +0 -86
  62. package/src/lib/system-bus/host-ports.ts +0 -93
  63. package/src/lib/system-bus/index.ts +0 -16
  64. package/src/lib/system-bus/intent-registry.ts +0 -109
  65. package/src/lib/system-bus/intents.ts +0 -113
  66. package/src/lib/system-bus/palette.ts +0 -78
  67. package/src/lib/system-bus/system-bus-builder.ts +0 -159
  68. package/src/lib/system-bus/system-bus.ts +0 -37
  69. package/src/lib/system-bus/windows.ts +0 -51
  70. package/src/offline/id.ts +0 -16
  71. package/src/offline/index.ts +0 -54
  72. package/src/offline/mutation.ts +0 -75
  73. package/src/offline/offline-status-badge.tsx +0 -51
  74. package/src/offline/online-controller.ts +0 -105
  75. package/src/offline/outbox.test.ts +0 -172
  76. package/src/offline/outbox.ts +0 -348
  77. package/src/offline/react-hooks.ts +0 -40
  78. package/src/offline/react.tsx +0 -32
  79. package/src/offline/storage.ts +0 -112
  80. package/src/offline/types.ts +0 -77
  81. package/src/org-db/components/DbResultTable.tsx +0 -176
  82. package/src/org-db/index.ts +0 -1
  83. package/src/pdf/index.ts +0 -11
  84. package/src/registry/index.ts +0 -9
  85. package/src/registry/lib/agent-validation-host.ts +0 -36
  86. package/src/registry/lib/biome-slot.tsx +0 -50
  87. package/src/registry/lib/biomes-enabled-context.ts +0 -20
  88. package/src/registry/lib/extension-points.ts +0 -134
  89. package/src/registry/lib/primitives/SessionEventCard.tsx +0 -164
  90. package/src/registry/lib/primitives/SessionEventTimeline.tsx +0 -95
  91. package/src/registry/lib/primitives/SessionMutationBar.tsx +0 -76
  92. package/src/registry/lib/primitives/SessionTabbedDrawer.tsx +0 -165
  93. package/src/registry/lib/primitives/index.ts +0 -18
  94. package/src/registry/lib/session-context-builder.ts +0 -84
  95. package/src/registry/lib/session-context-provider.tsx +0 -33
  96. package/src/registry/lib/session-context.ts +0 -21
  97. package/src/registry/lib/session-selectors.ts +0 -272
  98. package/src/session/comments/CommentRail.tsx +0 -164
  99. package/src/session/index.ts +0 -3
  100. package/src/session/lib/cn.ts +0 -11
  101. package/src/session/shell/SessionWorkspaceShell.tsx +0 -147
  102. package/src/session-kit/approvals/ApprovalButton.tsx +0 -89
  103. package/src/session-kit/approvals/ApprovalCard.tsx +0 -341
  104. package/src/session-kit/approvals/ApprovalsCenter.tsx +0 -336
  105. package/src/session-kit/approvals/CapabilityApprovalStickyBar.tsx +0 -118
  106. package/src/session-kit/approvals/Obligation.tsx +0 -111
  107. package/src/session-kit/approvals/ScopedBody.tsx +0 -392
  108. package/src/session-kit/approvals/approval-icons.ts +0 -31
  109. package/src/session-kit/approvals/approval-model.ts +0 -204
  110. package/src/session-kit/approvals/index.ts +0 -22
  111. package/src/session-kit/approvals/obligation-display.ts +0 -100
  112. package/src/session-kit/approvals/risk-accent.ts +0 -47
  113. package/src/session-kit/approvals/scope-icons.ts +0 -19
  114. package/src/session-kit/combobox/Combobox.tsx +0 -358
  115. package/src/session-kit/combobox/use-click-outside.ts +0 -21
  116. package/src/session-kit/display/ContextHeader.tsx +0 -148
  117. package/src/session-kit/display/FileDiffCard.tsx +0 -140
  118. package/src/session-kit/display/MD.tsx +0 -162
  119. package/src/session-kit/display/MessageTurn.tsx +0 -157
  120. package/src/session-kit/display/ThinkingPanel.tsx +0 -81
  121. package/src/session-kit/display/TodoChecklist.tsx +0 -120
  122. package/src/session-kit/display/TokenMeter.tsx +0 -89
  123. package/src/session-kit/display/ToolStrip.tsx +0 -278
  124. package/src/session-kit/display/TypingDots.tsx +0 -24
  125. package/src/session-kit/index.ts +0 -44
  126. package/src/session-kit/lib/enums.ts +0 -66
  127. package/src/session-kit/lib/portal-accent.ts +0 -30
  128. package/src/session-kit/lib/status-dot.ts +0 -68
  129. package/src/session-kit/primitives/Avatar.tsx +0 -44
  130. package/src/session-kit/primitives/PortalGlyph.tsx +0 -51
  131. package/src/session-kit/primitives/RiskPill.tsx +0 -95
  132. package/src/session-kit/primitives/ScopeDot.tsx +0 -47
  133. package/src/session-kit/primitives/Segmented.tsx +0 -71
  134. package/src/ui/branding/app-branding-context.ts +0 -20
  135. package/src/ui/branding/app-branding-provider.tsx +0 -123
  136. package/src/ui/branding/sanitize.ts +0 -89
  137. package/src/ui/breakpoints.ts +0 -14
  138. package/src/ui/capture/document-preview.tsx +0 -166
  139. package/src/ui/capture/field-spec-to-zod.test.ts +0 -81
  140. package/src/ui/capture/field-spec-to-zod.ts +0 -174
  141. package/src/ui/capture/field-spec-validate.ts +0 -236
  142. package/src/ui/capture/field-spec.test.ts +0 -49
  143. package/src/ui/capture/field-spec.ts +0 -274
  144. package/src/ui/capture/index.ts +0 -51
  145. package/src/ui/capture/schema-field-input.tsx +0 -620
  146. package/src/ui/capture/schema-form.tsx +0 -149
  147. package/src/ui/capture/submit-values.test.ts +0 -70
  148. package/src/ui/capture/submit-values.ts +0 -63
  149. package/src/ui/capture/use-prefill.ts +0 -186
  150. package/src/ui/capture/use-schema-validation.ts +0 -145
  151. package/src/ui/capture/use-wizard.ts +0 -180
  152. package/src/ui/capture/value-format.ts +0 -32
  153. package/src/ui/capture/wizard.tsx +0 -105
  154. package/src/ui/charts/bar-chart.tsx +0 -139
  155. package/src/ui/charts/chart-frame.tsx +0 -125
  156. package/src/ui/charts/chart-types.ts +0 -52
  157. package/src/ui/charts/chart-utils.ts +0 -190
  158. package/src/ui/charts/charts.test.tsx +0 -204
  159. package/src/ui/charts/donut-chart.tsx +0 -129
  160. package/src/ui/charts/index.ts +0 -27
  161. package/src/ui/charts/line-chart.tsx +0 -202
  162. package/src/ui/charts/sparkline.tsx +0 -109
  163. package/src/ui/chrome/AsyncBoundary.tsx +0 -74
  164. package/src/ui/chrome/EmptyState.tsx +0 -257
  165. package/src/ui/chrome/ErrorCard.tsx +0 -63
  166. package/src/ui/chrome/LoadingState.tsx +0 -61
  167. package/src/ui/chrome/PageHeader.tsx +0 -137
  168. package/src/ui/chrome/RecordCardList.tsx +0 -98
  169. package/src/ui/chrome/StateCard.tsx +0 -150
  170. package/src/ui/chrome/confirm-delete-dialog.tsx +0 -59
  171. package/src/ui/chrome/page-shell.spec.tsx +0 -117
  172. package/src/ui/chrome/page-shell.tsx +0 -221
  173. package/src/ui/chrome/scope-badge.tsx +0 -40
  174. package/src/ui/chrome/status-badge.tsx +0 -79
  175. package/src/ui/cn.ts +0 -32
  176. package/src/ui/design-tokens.ts +0 -372
  177. package/src/ui/hooks/use-debounced-value.ts +0 -16
  178. package/src/ui/hooks/use-is-mobile.ts +0 -28
  179. package/src/ui/index.ts +0 -110
  180. package/src/ui/pdf/pdf-preview.tsx +0 -122
  181. package/src/ui/primitives/alert-dialog.tsx +0 -104
  182. package/src/ui/primitives/async-combobox.tsx +0 -182
  183. package/src/ui/primitives/badge-variants.ts +0 -21
  184. package/src/ui/primitives/badge.tsx +0 -25
  185. package/src/ui/primitives/button-variants.ts +0 -31
  186. package/src/ui/primitives/button.tsx +0 -29
  187. package/src/ui/primitives/card.tsx +0 -43
  188. package/src/ui/primitives/checkbox.tsx +0 -26
  189. package/src/ui/primitives/collapsible.tsx +0 -9
  190. package/src/ui/primitives/dialog.tsx +0 -103
  191. package/src/ui/primitives/dropdown-menu.tsx +0 -179
  192. package/src/ui/primitives/form-stepper.tsx +0 -94
  193. package/src/ui/primitives/form-stepper.types.ts +0 -15
  194. package/src/ui/primitives/input.tsx +0 -22
  195. package/src/ui/primitives/label.tsx +0 -17
  196. package/src/ui/primitives/overflow-tabs.tsx +0 -331
  197. package/src/ui/primitives/popover.tsx +0 -33
  198. package/src/ui/primitives/preview-device-frame.tsx +0 -213
  199. package/src/ui/primitives/radio-group.tsx +0 -36
  200. package/src/ui/primitives/resizable.tsx +0 -67
  201. package/src/ui/primitives/scroll-area.tsx +0 -38
  202. package/src/ui/primitives/select.tsx +0 -143
  203. package/src/ui/primitives/separator.tsx +0 -20
  204. package/src/ui/primitives/sheet.tsx +0 -107
  205. package/src/ui/primitives/skeleton.tsx +0 -99
  206. package/src/ui/primitives/switch.tsx +0 -27
  207. package/src/ui/primitives/table.tsx +0 -72
  208. package/src/ui/primitives/tabs.tsx +0 -53
  209. package/src/ui/primitives/tag-multi-select.tsx +0 -261
  210. package/src/ui/primitives/textarea.tsx +0 -21
  211. package/src/ui/primitives/tooltip.tsx +0 -30
  212. package/src/ui/primitives/url-preview-chrome.tsx +0 -103
  213. package/src/vista/GenericCatalogueSurface.tsx +0 -179
  214. package/src/vista/SurfaceFallbackCard.tsx +0 -109
  215. package/src/vista/VistaPanel.tsx +0 -163
  216. package/src/vista/form-payload.spec.ts +0 -139
  217. package/src/vista/html/CustomUiFrame.spec.tsx +0 -127
  218. package/src/vista/html/CustomUiFrame.tsx +0 -206
  219. package/src/vista/html/custom-ui-frame-bridge.spec.ts +0 -191
  220. package/src/vista/html/custom-ui-frame-bridge.ts +0 -98
  221. package/src/vista/html/custom-ui-frame-contract.ts +0 -88
  222. package/src/vista/html/custom-ui-intents.spec.ts +0 -135
  223. package/src/vista/html/custom-ui-intents.ts +0 -155
  224. package/src/vista/html/custom-ui-srcdoc.spec.ts +0 -151
  225. package/src/vista/html/custom-ui-srcdoc.ts +0 -193
  226. package/src/vista/html/index.ts +0 -13
  227. package/src/vista/index.ts +0 -52
  228. package/src/vista/surface-catalogue.spec.ts +0 -140
  229. package/src/vista/surface-catalogue.ts +0 -90
  230. package/src/vista/surface-icons.ts +0 -57
  231. package/src/vista/surface-registry.ts +0 -56
  232. package/src/vista/surfaces/ChartSurface.tsx +0 -34
  233. package/src/vista/surfaces/FilesSurface.tsx +0 -202
  234. package/src/vista/surfaces/FormSurface.tsx +0 -380
  235. package/src/vista/surfaces/HtmlSurface.tsx +0 -43
  236. package/src/vista/surfaces/TableSurface.tsx +0 -100
  237. package/src/vista/surfaces/UrlSurface.tsx +0 -40
  238. package/src/vista/surfaces/blob-surfaces.tsx +0 -139
  239. package/src/vista/surfaces/elicitation-transport.spec.ts +0 -369
  240. package/src/vista/surfaces/elicitation-transport.ts +0 -367
  241. package/src/vista/surfaces/file-surface-utils.ts +0 -69
  242. package/src/vista/surfaces/index.ts +0 -24
  243. package/src/vista/surfaces/register-surfaces.tsx +0 -139
  244. package/src/vista/surfaces/text-surfaces.tsx +0 -132
  245. package/src/vista/use-vista-tabs.ts +0 -196
  246. package/src/vista/vista-code-renderer-context.ts +0 -16
  247. package/src/vista/vista-code-renderer.tsx +0 -35
  248. package/src/vista/vista-file-context.ts +0 -14
  249. package/src/vista/vista-file-source.tsx +0 -141
  250. package/src/vista/vista-form-context.ts +0 -20
  251. package/src/vista/vista-form-host.tsx +0 -48
  252. package/src/vista/vista-model.ts +0 -137
  253. package/src/vista/vista-open-context.tsx +0 -27
  254. package/src/vista/vista-open-state.ts +0 -11
  255. package/src/vista/vista-payloads.ts +0 -635
  256. package/src/vista/vista-tabs-manifest.ts +0 -138
  257. package/src/vista/vista-tools.ts +0 -232
@@ -1,358 +0,0 @@
1
- /**
2
- * Generic searchable picker. Use it wherever a closed set
3
- * is selected (agents, models, skills/tools, …).
4
- *
5
- * - Shows a search field when `items.length > searchThreshold` (default
6
- * 7) with a live `shown/total` count.
7
- * - Scrolls a long list (max-height 240).
8
- * - Single OR multi (checkbox) select via a discriminated `multi` flag.
9
- * - Long labels truncate with ellipsis in the trigger; the list always
10
- * shows the full label.
11
- * - Opens up/down, left/right aligned, with an optional footer slot.
12
- * - Click-outside closes (and clears the query).
13
- *
14
- * Standalone (not built on a host Popover): the design's behaviour is a
15
- * small self-contained surface (click-outside + absolute positioning),
16
- * and this package is layer-agnostic ui-kernel — it must not depend on
17
- * host primitives. So we ship a minimal, faithful standalone impl. The
18
- * search/check/checkbox icons are host-supplied (icon-agnostic kit).
19
- */
20
- import {
21
- useEffect,
22
- useRef,
23
- useState,
24
- type CSSProperties,
25
- type ReactElement,
26
- type ReactNode,
27
- } from 'react';
28
-
29
- import { useClickOutside } from './use-click-outside';
30
-
31
- export interface ComboboxItem<V extends string> {
32
- readonly value: V;
33
- readonly label: string;
34
- /** Secondary muted line under the label. */
35
- readonly hint?: string;
36
- /** Leading icon node (host-supplied). */
37
- readonly icon?: ReactNode;
38
- /** Small uppercase kind tag on the right (`.cap`). */
39
- readonly kind?: string;
40
- /** Render the label in the mono face. */
41
- readonly mono?: boolean;
42
- }
43
-
44
- /**
45
- * Trigger render-prop state. The consumer renders its own interactive
46
- * trigger element (typically a `<button>`) and wires `toggle` to its
47
- * `onClick`, so the picker never nests interactive elements.
48
- */
49
- export interface ComboboxTriggerState<V extends string> {
50
- readonly open: boolean;
51
- /** The selected item (single-select only; `undefined` in multi mode). */
52
- readonly selected: ComboboxItem<V> | undefined;
53
- /** Toggle the dropdown open/closed. */
54
- readonly toggle: () => void;
55
- }
56
-
57
- export type ComboboxTrigger<V extends string> = (
58
- state: ComboboxTriggerState<V>,
59
- ) => ReactNode;
60
-
61
- /** Host-supplied icons (kit carries no icon set). */
62
- export interface ComboboxIcons {
63
- readonly search?: ReactNode;
64
- /** Check mark for the selected single-select row. */
65
- readonly check?: ReactNode;
66
- /** Check mark rendered inside a ticked multi-select box. */
67
- readonly multiCheck?: ReactNode;
68
- }
69
-
70
- export type ComboboxAlign = 'left' | 'right';
71
-
72
- interface ComboboxBaseProps<V extends string> {
73
- readonly items: ReadonlyArray<ComboboxItem<V>>;
74
- readonly trigger: ComboboxTrigger<V>;
75
- readonly icons?: ComboboxIcons;
76
- readonly placeholder?: string;
77
- readonly searchThreshold?: number;
78
- readonly align?: ComboboxAlign;
79
- /** Open upward instead of downward. */
80
- readonly up?: boolean;
81
- readonly width?: number;
82
- readonly footer?: ReactNode;
83
- }
84
-
85
- interface ComboboxSingleProps<V extends string> extends ComboboxBaseProps<V> {
86
- readonly multi?: false;
87
- readonly value: V | undefined;
88
- readonly onChange: (value: V) => void;
89
- }
90
-
91
- interface ComboboxMultiProps<V extends string> extends ComboboxBaseProps<V> {
92
- readonly multi: true;
93
- readonly value: ReadonlyArray<V>;
94
- readonly onChange: (value: V) => void;
95
- }
96
-
97
- export type ComboboxProps<V extends string> =
98
- | ComboboxSingleProps<V>
99
- | ComboboxMultiProps<V>;
100
-
101
- const POP_STYLE: CSSProperties = {
102
- position: 'absolute',
103
- zIndex: 60,
104
- borderRadius: 11,
105
- background: 'hsl(var(--paper-elev))',
106
- border: '1px solid hsl(var(--rule-2))',
107
- boxShadow: 'var(--shadow-28, var(--shadow-pop))',
108
- overflow: 'hidden',
109
- };
110
-
111
- export function Combobox<V extends string>(
112
- props: ComboboxProps<V>,
113
- ): ReactElement {
114
- const {
115
- items,
116
- trigger,
117
- icons,
118
- placeholder = 'Search…',
119
- searchThreshold = 7,
120
- align = 'left',
121
- up = false,
122
- width = 240,
123
- footer,
124
- } = props;
125
-
126
- const [open, setOpen] = useState(false);
127
- const [query, setQuery] = useState('');
128
- const ref = useClickOutside<HTMLDivElement>(() => {
129
- setOpen(false);
130
- setQuery('');
131
- });
132
- const searchRef = useRef<HTMLInputElement>(null);
133
-
134
- const showSearch = items.length > searchThreshold;
135
-
136
- // Move focus to the search field when the dropdown opens (replaces the
137
- // a11y-discouraged `autoFocus` attribute).
138
- useEffect(() => {
139
- if (open && showSearch) {
140
- searchRef.current?.focus();
141
- }
142
- }, [open, showSearch]);
143
-
144
- const filtered = query
145
- ? items.filter((it) =>
146
- `${it.label} ${it.hint ?? ''}`
147
- .toLowerCase()
148
- .includes(query.toLowerCase()),
149
- )
150
- : items;
151
-
152
- const isOn = (value: V): boolean =>
153
- props.multi ? props.value.includes(value) : props.value === value;
154
-
155
- const selected = props.multi
156
- ? undefined
157
- : items.find((it) => it.value === props.value);
158
-
159
- function pick(value: V): void {
160
- props.onChange(value);
161
- if (!props.multi) {
162
- setOpen(false);
163
- setQuery('');
164
- }
165
- }
166
-
167
- const pos: CSSProperties = up
168
- ? { bottom: 'calc(100% + 6px)' }
169
- : { top: 'calc(100% + 6px)' };
170
-
171
- return (
172
- <div
173
- ref={ref}
174
- style={{ position: 'relative', display: 'inline-flex', flexShrink: 0 }}
175
- >
176
- {trigger({ open, selected, toggle: () => setOpen((o) => !o) })}
177
- {open && (
178
- <div style={{ ...POP_STYLE, ...pos, [align]: 0, width }}>
179
- {showSearch && (
180
- <div
181
- style={{
182
- display: 'flex',
183
- alignItems: 'center',
184
- gap: 7,
185
- padding: '9px 11px',
186
- borderBottom: '1px solid hsl(var(--rule))',
187
- }}
188
- >
189
- {icons?.search && (
190
- <span
191
- style={{ display: 'inline-flex', color: 'hsl(var(--ink-3))' }}
192
- >
193
- {icons.search}
194
- </span>
195
- )}
196
- <input
197
- ref={searchRef}
198
- value={query}
199
- onChange={(e) => setQuery(e.target.value)}
200
- placeholder={placeholder}
201
- style={{
202
- flex: 1,
203
- border: 'none',
204
- outline: 'none',
205
- background: 'transparent',
206
- fontSize: 13,
207
- color: 'hsl(var(--ink))',
208
- }}
209
- />
210
- {items.length > 0 && (
211
- <span
212
- className="mono"
213
- style={{ fontSize: 10, color: 'hsl(var(--ink-4))' }}
214
- >
215
- {filtered.length}/{items.length}
216
- </span>
217
- )}
218
- </div>
219
- )}
220
- <div style={{ maxHeight: 240, overflowY: 'auto', padding: 5 }}>
221
- {filtered.map((it) => {
222
- const on = isOn(it.value);
223
- const singleSelected = on && !props.multi;
224
- return (
225
- <button
226
- type="button"
227
- key={it.value}
228
- onClick={() => pick(it.value)}
229
- style={{
230
- display: 'flex',
231
- alignItems: 'center',
232
- gap: 9,
233
- width: '100%',
234
- padding: '7px 9px',
235
- borderRadius: 7,
236
- textAlign: 'left',
237
- background: singleSelected
238
- ? 'hsl(var(--accent) / 0.6)'
239
- : 'transparent',
240
- transition: 'background 140ms ease',
241
- }}
242
- onMouseEnter={(e) => {
243
- if (!singleSelected) {
244
- e.currentTarget.style.background =
245
- 'hsl(var(--paper-sunk))';
246
- }
247
- }}
248
- onMouseLeave={(e) => {
249
- if (!singleSelected) {
250
- e.currentTarget.style.background = 'transparent';
251
- }
252
- }}
253
- >
254
- {it.icon && (
255
- <span
256
- style={{
257
- display: 'inline-flex',
258
- color: 'hsl(var(--ink-3))',
259
- flexShrink: 0,
260
- }}
261
- >
262
- {it.icon}
263
- </span>
264
- )}
265
- <span style={{ flex: 1, minWidth: 0 }}>
266
- <span
267
- className={it.mono ? 'mono' : ''}
268
- style={{
269
- display: 'block',
270
- fontSize: it.mono ? 12 : 12.5,
271
- color: 'hsl(var(--ink))',
272
- overflow: 'hidden',
273
- textOverflow: 'ellipsis',
274
- whiteSpace: 'nowrap',
275
- }}
276
- >
277
- {it.label}
278
- </span>
279
- {it.hint && (
280
- <span
281
- style={{
282
- display: 'block',
283
- fontSize: 10.5,
284
- color: 'hsl(var(--ink-4))',
285
- overflow: 'hidden',
286
- textOverflow: 'ellipsis',
287
- whiteSpace: 'nowrap',
288
- }}
289
- >
290
- {it.hint}
291
- </span>
292
- )}
293
- </span>
294
- {it.kind && (
295
- <span
296
- className="cap"
297
- style={{ fontSize: 8.5, flexShrink: 0 }}
298
- >
299
- {it.kind}
300
- </span>
301
- )}
302
- {props.multi ? (
303
- <span
304
- style={{
305
- width: 17,
306
- height: 17,
307
- borderRadius: 5,
308
- flexShrink: 0,
309
- display: 'grid',
310
- placeItems: 'center',
311
- background: on ? 'hsl(var(--primary))' : 'transparent',
312
- border: on ? 'none' : '1.5px solid hsl(var(--rule-2))',
313
- color: '#fff',
314
- }}
315
- >
316
- {on && icons?.multiCheck}
317
- </span>
318
- ) : (
319
- on && (
320
- <span
321
- style={{
322
- display: 'inline-flex',
323
- color: 'hsl(var(--primary))',
324
- flexShrink: 0,
325
- }}
326
- >
327
- {icons?.check}
328
- </span>
329
- )
330
- )}
331
- </button>
332
- );
333
- })}
334
- {filtered.length === 0 && (
335
- <div
336
- style={{
337
- padding: '18px 0',
338
- textAlign: 'center',
339
- fontSize: 12,
340
- color: 'hsl(var(--ink-4))',
341
- }}
342
- >
343
- No matches
344
- </div>
345
- )}
346
- </div>
347
- {footer && (
348
- <div
349
- style={{ borderTop: '1px solid hsl(var(--rule))', padding: 6 }}
350
- >
351
- {footer}
352
- </div>
353
- )}
354
- </div>
355
- )}
356
- </div>
357
- );
358
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Close-on-outside-click hook. Returns a ref to attach to the element
3
- * whose interior clicks should NOT trigger `onClose`.
4
- */
5
- import { useEffect, useRef, type RefObject } from 'react';
6
-
7
- export function useClickOutside<T extends HTMLElement>(
8
- onClose: () => void,
9
- ): RefObject<T> {
10
- const ref = useRef<T>(null);
11
- useEffect(() => {
12
- function handle(event: MouseEvent): void {
13
- if (ref.current && !ref.current.contains(event.target as Node)) {
14
- onClose();
15
- }
16
- }
17
- document.addEventListener('mousedown', handle);
18
- return () => document.removeEventListener('mousedown', handle);
19
- }, [onClose]);
20
- return ref;
21
- }
@@ -1,148 +0,0 @@
1
- /**
2
- * Session context header — agent / model / environment / audience meta
3
- * row with the token meter pinned to the right. Icons are host-supplied
4
- * (`ReactNode`) so the kit stays icon-agnostic.
5
- */
6
- import { TokenMeter, type TokenCounts } from './TokenMeter';
7
- import { SessionSkin } from '../lib/enums';
8
-
9
- import type { CSSProperties, ReactElement, ReactNode } from 'react';
10
-
11
-
12
- export interface ContextHeaderSession {
13
- readonly agent: string;
14
- readonly model: string;
15
- readonly environment: string;
16
- readonly audience: string;
17
- readonly tokens: TokenCounts;
18
- readonly cost: number;
19
- }
20
-
21
- /** Host-supplied icon nodes for each meta row. All optional. */
22
- export interface ContextHeaderIcons {
23
- readonly agent?: ReactNode;
24
- readonly model?: ReactNode;
25
- readonly environment?: ReactNode;
26
- readonly audience?: ReactNode;
27
- }
28
-
29
- export interface ContextHeaderProps {
30
- readonly session: ContextHeaderSession;
31
- readonly icons?: ContextHeaderIcons;
32
- readonly skin?: SessionSkin;
33
- /**
34
- * Audience value treated as the default (un-flagged) audience. When the
35
- * session's audience differs, the audience meta is shown with a warn tone.
36
- */
37
- readonly defaultAudience?: string;
38
- /**
39
- * Environment value treated as production (shown with a warn tone).
40
- */
41
- readonly productionEnvironment?: string;
42
- readonly style?: CSSProperties;
43
- }
44
-
45
- function MetaDot(): ReactElement {
46
- return (
47
- <span
48
- style={{
49
- width: 3,
50
- height: 3,
51
- borderRadius: '50%',
52
- background: 'hsl(var(--ink-4) / 0.6)',
53
- }}
54
- />
55
- );
56
- }
57
-
58
- type MetaTone = 'default' | 'strong' | 'warn';
59
-
60
- function Meta({
61
- icon,
62
- label,
63
- mono,
64
- tone = 'default',
65
- }: {
66
- readonly icon?: ReactNode;
67
- readonly label: string;
68
- readonly mono?: boolean;
69
- readonly tone?: MetaTone;
70
- }): ReactElement {
71
- const color =
72
- tone === 'warn'
73
- ? 'hsl(var(--warning))'
74
- : tone === 'strong'
75
- ? 'hsl(var(--ink))'
76
- : 'hsl(var(--ink-3))';
77
- return (
78
- <span
79
- style={{
80
- display: 'inline-flex',
81
- alignItems: 'center',
82
- gap: 5,
83
- color,
84
- fontSize: 12,
85
- fontWeight: tone === 'strong' ? 600 : 450,
86
- whiteSpace: 'nowrap',
87
- }}
88
- >
89
- {icon && (
90
- <span style={{ display: 'inline-flex', opacity: 0.8 }}>{icon}</span>
91
- )}
92
- <span
93
- className={mono ? 'mono' : ''}
94
- style={{ fontSize: mono ? 11.5 : 12, whiteSpace: 'nowrap' }}
95
- >
96
- {label}
97
- </span>
98
- </span>
99
- );
100
- }
101
-
102
- export function ContextHeader({
103
- session,
104
- icons,
105
- skin = SessionSkin.Minimal,
106
- defaultAudience = 'internal-org',
107
- productionEnvironment = 'production',
108
- style,
109
- }: ContextHeaderProps): ReactElement {
110
- const showAudience = session.audience !== defaultAudience;
111
- return (
112
- <div
113
- style={{
114
- display: 'flex',
115
- alignItems: 'center',
116
- gap: 10,
117
- flexWrap: 'wrap',
118
- padding: '8px 14px',
119
- borderBottom: '1px solid hsl(var(--rule))',
120
- background:
121
- skin === SessionSkin.Functional
122
- ? 'hsl(var(--paper-elev))'
123
- : 'hsl(var(--paper) / 0.6)',
124
- backdropFilter: 'blur(6px)',
125
- ...style,
126
- }}
127
- >
128
- <Meta icon={icons?.agent} label={session.agent} tone="strong" />
129
- <MetaDot />
130
- <Meta icon={icons?.model} label={session.model} mono />
131
- <MetaDot />
132
- <Meta
133
- icon={icons?.environment}
134
- label={session.environment}
135
- mono
136
- tone={session.environment === productionEnvironment ? 'warn' : 'default'}
137
- />
138
- {showAudience && (
139
- <>
140
- <MetaDot />
141
- <Meta icon={icons?.audience} label={session.audience} mono tone="warn" />
142
- </>
143
- )}
144
- <div style={{ flex: 1 }} />
145
- <TokenMeter tokens={session.tokens} cost={session.cost} skin={skin} />
146
- </div>
147
- );
148
- }
@@ -1,140 +0,0 @@
1
- /**
2
- * Collapsible file-diff card — path + add/del counts in the header, an
3
- * optional expandable unified-diff body. Disclosure + file icons are
4
- * host-supplied.
5
- */
6
- import { useState, type ReactElement, type ReactNode } from 'react';
7
-
8
- import { SessionSkin } from '../lib/enums';
9
-
10
- /**
11
- * A single diff line: first character is the marker (`+` add, `-` del,
12
- * ` ` context), the remainder is the line text.
13
- */
14
- export type DiffLine = string;
15
-
16
- export interface DiffFile {
17
- readonly path: string;
18
- readonly add: number;
19
- readonly del: number;
20
- readonly hunks?: ReadonlyArray<DiffLine>;
21
- }
22
-
23
- export interface FileDiffCardProps {
24
- readonly file: DiffFile;
25
- readonly skin?: SessionSkin;
26
- readonly collapsedIcon?: ReactNode;
27
- readonly expandedIcon?: ReactNode;
28
- readonly fileIcon?: ReactNode;
29
- }
30
-
31
- const DANGER_VAR = 'var(--destructive, var(--danger))';
32
- const DANGER = `hsl(${DANGER_VAR})`;
33
- const DANGER_SOFT = `hsl(${DANGER_VAR} / 0.06)`;
34
-
35
- export function FileDiffCard({
36
- file,
37
- skin = SessionSkin.Minimal,
38
- collapsedIcon,
39
- expandedIcon,
40
- fileIcon,
41
- }: FileDiffCardProps): ReactElement {
42
- const [open, setOpen] = useState(false);
43
- const hasHunks = Boolean(file.hunks && file.hunks.length > 0);
44
- return (
45
- <div
46
- style={{
47
- marginTop: 9,
48
- border: '1px solid hsl(var(--rule))',
49
- borderRadius: 9,
50
- overflow: 'hidden',
51
- background: 'hsl(var(--paper-elev))',
52
- }}
53
- >
54
- <button
55
- type="button"
56
- onClick={() => hasHunks && setOpen((v) => !v)}
57
- style={{
58
- display: 'flex',
59
- alignItems: 'center',
60
- gap: 9,
61
- width: '100%',
62
- padding: '8px 11px',
63
- textAlign: 'left',
64
- cursor: hasHunks ? 'pointer' : 'default',
65
- background:
66
- skin === SessionSkin.Functional ? 'hsl(var(--muted))' : 'transparent',
67
- }}
68
- >
69
- {hasHunks && (open ? expandedIcon : collapsedIcon)}
70
- {fileIcon && (
71
- <span style={{ display: 'inline-flex', color: 'hsl(var(--warning))' }}>
72
- {fileIcon}
73
- </span>
74
- )}
75
- <span
76
- className="mono"
77
- style={{
78
- fontSize: 12,
79
- color: 'hsl(var(--ink))',
80
- overflow: 'hidden',
81
- textOverflow: 'ellipsis',
82
- whiteSpace: 'nowrap',
83
- }}
84
- >
85
- {file.path}
86
- </span>
87
- <span style={{ flex: 1 }} />
88
- <span className="mono" style={{ fontSize: 11, color: 'hsl(var(--success))' }}>
89
- +{file.add}
90
- </span>
91
- <span className="mono" style={{ fontSize: 11, color: DANGER }}>
92
- −{file.del}
93
- </span>
94
- </button>
95
- {open && file.hunks && (
96
- <div
97
- className="mono"
98
- style={{
99
- borderTop: '1px solid hsl(var(--rule))',
100
- fontSize: 11.5,
101
- lineHeight: 1.6,
102
- overflowX: 'auto',
103
- }}
104
- >
105
- {file.hunks.map((line, index) => {
106
- const marker = line[0];
107
- const text = line.slice(1);
108
- const bg =
109
- marker === '+'
110
- ? 'hsl(var(--success) / 0.07)'
111
- : marker === '-'
112
- ? DANGER_SOFT
113
- : 'transparent';
114
- const color =
115
- marker === '+'
116
- ? 'hsl(var(--success))'
117
- : marker === '-'
118
- ? DANGER
119
- : 'hsl(var(--ink-3))';
120
- return (
121
- <div key={index} style={{ display: 'flex', background: bg, padding: '0 11px' }}>
122
- <span style={{ width: 14, color, flexShrink: 0 }}>
123
- {marker === ' ' ? '' : marker}
124
- </span>
125
- <span
126
- style={{
127
- color: marker === ' ' ? 'hsl(var(--ink-3))' : 'hsl(var(--ink-2))',
128
- whiteSpace: 'pre',
129
- }}
130
- >
131
- {text}
132
- </span>
133
- </div>
134
- );
135
- })}
136
- </div>
137
- )}
138
- </div>
139
- );
140
- }