@xemahq/ui-kernel 0.11.0 → 0.11.2

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 (237) hide show
  1. package/dist/ui/chrome/page-shell.d.ts +1 -1
  2. package/dist/ui/chrome/page-shell.d.ts.map +1 -1
  3. package/dist/ui/chrome/page-shell.js +9 -4
  4. package/dist/ui/chrome/page-shell.js.map +1 -1
  5. package/package.json +6 -4
  6. package/src/index.ts +0 -17
  7. package/src/lib/biome-host/agent-validation.ts +0 -239
  8. package/src/lib/biome-host/biome-builders.ts +0 -112
  9. package/src/lib/biome-host/biome-mode.ts +0 -6
  10. package/src/lib/biome-host/biome-navigation.ts +0 -37
  11. package/src/lib/biome-host/biome-registry.ts +0 -299
  12. package/src/lib/biome-host/biome-scope-hooks.ts +0 -41
  13. package/src/lib/biome-host/biome-scope.tsx +0 -52
  14. package/src/lib/biome-host/biome-scoped-query.ts +0 -134
  15. package/src/lib/biome-host/create-biome-orval-config.ts +0 -82
  16. package/src/lib/biome-host/define-web-biome.spec.ts +0 -221
  17. package/src/lib/biome-host/define-web-biome.ts +0 -222
  18. package/src/lib/biome-host/errors.ts +0 -220
  19. package/src/lib/biome-host/frontend-biome.ts +0 -256
  20. package/src/lib/biome-host/host-bridge.ts +0 -281
  21. package/src/lib/biome-host/host-sources.ts +0 -54
  22. package/src/lib/biome-host/i18n-hooks.ts +0 -51
  23. package/src/lib/biome-host/i18n-port.test.ts +0 -50
  24. package/src/lib/biome-host/i18n-port.ts +0 -96
  25. package/src/lib/biome-host/index.ts +0 -35
  26. package/src/lib/biome-host/realtime-hooks.ts +0 -75
  27. package/src/lib/biome-host/realtime-port.ts +0 -115
  28. package/src/lib/biome-host/session-contributions.ts +0 -296
  29. package/src/lib/biome-host/use-mutation-with-error-toast.ts +0 -90
  30. package/src/lib/biome-host/use-page-state.ts +0 -248
  31. package/src/lib/capabilities/capability-context.ts +0 -25
  32. package/src/lib/capabilities/capability-provider.tsx +0 -73
  33. package/src/lib/capabilities/index.ts +0 -17
  34. package/src/lib/capabilities/types.ts +0 -69
  35. package/src/lib/capabilities/use-capability.ts +0 -79
  36. package/src/lib/contribution-registry/contribution-registry.spec.ts +0 -141
  37. package/src/lib/contribution-registry/contribution-registry.ts +0 -204
  38. package/src/lib/contribution-registry/index.ts +0 -9
  39. package/src/lib/contribution-registry/renderable-registry.ts +0 -142
  40. package/src/lib/system-bus/capability-invoke.ts +0 -92
  41. package/src/lib/system-bus/deeplink.ts +0 -210
  42. package/src/lib/system-bus/enums.ts +0 -86
  43. package/src/lib/system-bus/host-ports.ts +0 -93
  44. package/src/lib/system-bus/index.ts +0 -16
  45. package/src/lib/system-bus/intent-registry.ts +0 -109
  46. package/src/lib/system-bus/intents.ts +0 -113
  47. package/src/lib/system-bus/palette.ts +0 -78
  48. package/src/lib/system-bus/system-bus-builder.ts +0 -159
  49. package/src/lib/system-bus/system-bus.ts +0 -37
  50. package/src/lib/system-bus/windows.ts +0 -51
  51. package/src/offline/id.ts +0 -16
  52. package/src/offline/index.ts +0 -54
  53. package/src/offline/mutation.ts +0 -75
  54. package/src/offline/offline-status-badge.tsx +0 -51
  55. package/src/offline/online-controller.ts +0 -105
  56. package/src/offline/outbox.test.ts +0 -172
  57. package/src/offline/outbox.ts +0 -348
  58. package/src/offline/react-hooks.ts +0 -40
  59. package/src/offline/react.tsx +0 -32
  60. package/src/offline/storage.ts +0 -112
  61. package/src/offline/types.ts +0 -77
  62. package/src/org-db/components/DbResultTable.tsx +0 -176
  63. package/src/org-db/index.ts +0 -1
  64. package/src/pdf/index.ts +0 -11
  65. package/src/registry/index.ts +0 -9
  66. package/src/registry/lib/agent-validation-host.ts +0 -36
  67. package/src/registry/lib/biome-slot.tsx +0 -50
  68. package/src/registry/lib/biomes-enabled-context.ts +0 -20
  69. package/src/registry/lib/extension-points.ts +0 -134
  70. package/src/registry/lib/primitives/SessionEventCard.tsx +0 -164
  71. package/src/registry/lib/primitives/SessionEventTimeline.tsx +0 -95
  72. package/src/registry/lib/primitives/SessionMutationBar.tsx +0 -76
  73. package/src/registry/lib/primitives/SessionTabbedDrawer.tsx +0 -165
  74. package/src/registry/lib/primitives/index.ts +0 -18
  75. package/src/registry/lib/session-context-builder.ts +0 -84
  76. package/src/registry/lib/session-context-provider.tsx +0 -33
  77. package/src/registry/lib/session-context.ts +0 -21
  78. package/src/registry/lib/session-selectors.ts +0 -272
  79. package/src/session/comments/CommentRail.tsx +0 -164
  80. package/src/session/index.ts +0 -3
  81. package/src/session/lib/cn.ts +0 -11
  82. package/src/session/shell/SessionWorkspaceShell.tsx +0 -147
  83. package/src/session-kit/approvals/ApprovalButton.tsx +0 -89
  84. package/src/session-kit/approvals/ApprovalCard.tsx +0 -341
  85. package/src/session-kit/approvals/ApprovalsCenter.tsx +0 -336
  86. package/src/session-kit/approvals/CapabilityApprovalStickyBar.tsx +0 -118
  87. package/src/session-kit/approvals/Obligation.tsx +0 -111
  88. package/src/session-kit/approvals/ScopedBody.tsx +0 -392
  89. package/src/session-kit/approvals/approval-icons.ts +0 -31
  90. package/src/session-kit/approvals/approval-model.ts +0 -204
  91. package/src/session-kit/approvals/index.ts +0 -22
  92. package/src/session-kit/approvals/obligation-display.ts +0 -100
  93. package/src/session-kit/approvals/risk-accent.ts +0 -47
  94. package/src/session-kit/approvals/scope-icons.ts +0 -19
  95. package/src/session-kit/combobox/Combobox.tsx +0 -358
  96. package/src/session-kit/combobox/use-click-outside.ts +0 -21
  97. package/src/session-kit/display/ContextHeader.tsx +0 -148
  98. package/src/session-kit/display/FileDiffCard.tsx +0 -140
  99. package/src/session-kit/display/MD.tsx +0 -162
  100. package/src/session-kit/display/MessageTurn.tsx +0 -157
  101. package/src/session-kit/display/ThinkingPanel.tsx +0 -81
  102. package/src/session-kit/display/TodoChecklist.tsx +0 -120
  103. package/src/session-kit/display/TokenMeter.tsx +0 -89
  104. package/src/session-kit/display/ToolStrip.tsx +0 -278
  105. package/src/session-kit/display/TypingDots.tsx +0 -24
  106. package/src/session-kit/index.ts +0 -44
  107. package/src/session-kit/lib/enums.ts +0 -66
  108. package/src/session-kit/lib/portal-accent.ts +0 -30
  109. package/src/session-kit/lib/status-dot.ts +0 -68
  110. package/src/session-kit/primitives/Avatar.tsx +0 -44
  111. package/src/session-kit/primitives/PortalGlyph.tsx +0 -51
  112. package/src/session-kit/primitives/RiskPill.tsx +0 -95
  113. package/src/session-kit/primitives/ScopeDot.tsx +0 -47
  114. package/src/session-kit/primitives/Segmented.tsx +0 -71
  115. package/src/ui/branding/app-branding-context.ts +0 -20
  116. package/src/ui/branding/app-branding-provider.tsx +0 -123
  117. package/src/ui/branding/sanitize.ts +0 -89
  118. package/src/ui/breakpoints.ts +0 -14
  119. package/src/ui/capture/document-preview.tsx +0 -166
  120. package/src/ui/capture/field-spec-to-zod.test.ts +0 -81
  121. package/src/ui/capture/field-spec-to-zod.ts +0 -174
  122. package/src/ui/capture/field-spec-validate.ts +0 -236
  123. package/src/ui/capture/field-spec.test.ts +0 -49
  124. package/src/ui/capture/field-spec.ts +0 -274
  125. package/src/ui/capture/index.ts +0 -51
  126. package/src/ui/capture/schema-field-input.tsx +0 -620
  127. package/src/ui/capture/schema-form.tsx +0 -149
  128. package/src/ui/capture/submit-values.test.ts +0 -70
  129. package/src/ui/capture/submit-values.ts +0 -63
  130. package/src/ui/capture/use-prefill.ts +0 -186
  131. package/src/ui/capture/use-schema-validation.ts +0 -145
  132. package/src/ui/capture/use-wizard.ts +0 -180
  133. package/src/ui/capture/value-format.ts +0 -32
  134. package/src/ui/capture/wizard.tsx +0 -105
  135. package/src/ui/charts/bar-chart.tsx +0 -139
  136. package/src/ui/charts/chart-frame.tsx +0 -125
  137. package/src/ui/charts/chart-types.ts +0 -52
  138. package/src/ui/charts/chart-utils.ts +0 -190
  139. package/src/ui/charts/charts.test.tsx +0 -204
  140. package/src/ui/charts/donut-chart.tsx +0 -129
  141. package/src/ui/charts/index.ts +0 -27
  142. package/src/ui/charts/line-chart.tsx +0 -202
  143. package/src/ui/charts/sparkline.tsx +0 -109
  144. package/src/ui/chrome/AsyncBoundary.tsx +0 -74
  145. package/src/ui/chrome/EmptyState.tsx +0 -257
  146. package/src/ui/chrome/ErrorCard.tsx +0 -63
  147. package/src/ui/chrome/LoadingState.tsx +0 -61
  148. package/src/ui/chrome/PageHeader.tsx +0 -137
  149. package/src/ui/chrome/RecordCardList.tsx +0 -98
  150. package/src/ui/chrome/StateCard.tsx +0 -150
  151. package/src/ui/chrome/confirm-delete-dialog.tsx +0 -59
  152. package/src/ui/chrome/page-shell.tsx +0 -189
  153. package/src/ui/chrome/scope-badge.tsx +0 -40
  154. package/src/ui/chrome/status-badge.tsx +0 -79
  155. package/src/ui/cn.ts +0 -32
  156. package/src/ui/design-tokens.ts +0 -372
  157. package/src/ui/hooks/use-debounced-value.ts +0 -16
  158. package/src/ui/hooks/use-is-mobile.ts +0 -28
  159. package/src/ui/index.ts +0 -110
  160. package/src/ui/pdf/pdf-preview.tsx +0 -122
  161. package/src/ui/primitives/alert-dialog.tsx +0 -104
  162. package/src/ui/primitives/async-combobox.tsx +0 -182
  163. package/src/ui/primitives/badge-variants.ts +0 -21
  164. package/src/ui/primitives/badge.tsx +0 -25
  165. package/src/ui/primitives/button-variants.ts +0 -31
  166. package/src/ui/primitives/button.tsx +0 -29
  167. package/src/ui/primitives/card.tsx +0 -43
  168. package/src/ui/primitives/checkbox.tsx +0 -26
  169. package/src/ui/primitives/collapsible.tsx +0 -9
  170. package/src/ui/primitives/dialog.tsx +0 -103
  171. package/src/ui/primitives/dropdown-menu.tsx +0 -179
  172. package/src/ui/primitives/form-stepper.tsx +0 -94
  173. package/src/ui/primitives/form-stepper.types.ts +0 -15
  174. package/src/ui/primitives/input.tsx +0 -22
  175. package/src/ui/primitives/label.tsx +0 -17
  176. package/src/ui/primitives/overflow-tabs.tsx +0 -331
  177. package/src/ui/primitives/popover.tsx +0 -33
  178. package/src/ui/primitives/preview-device-frame.tsx +0 -213
  179. package/src/ui/primitives/radio-group.tsx +0 -36
  180. package/src/ui/primitives/resizable.tsx +0 -67
  181. package/src/ui/primitives/scroll-area.tsx +0 -38
  182. package/src/ui/primitives/select.tsx +0 -143
  183. package/src/ui/primitives/separator.tsx +0 -20
  184. package/src/ui/primitives/sheet.tsx +0 -107
  185. package/src/ui/primitives/skeleton.tsx +0 -99
  186. package/src/ui/primitives/switch.tsx +0 -27
  187. package/src/ui/primitives/table.tsx +0 -72
  188. package/src/ui/primitives/tabs.tsx +0 -53
  189. package/src/ui/primitives/tag-multi-select.tsx +0 -261
  190. package/src/ui/primitives/textarea.tsx +0 -21
  191. package/src/ui/primitives/tooltip.tsx +0 -30
  192. package/src/ui/primitives/url-preview-chrome.tsx +0 -103
  193. package/src/vista/GenericCatalogueSurface.tsx +0 -179
  194. package/src/vista/SurfaceFallbackCard.tsx +0 -109
  195. package/src/vista/VistaPanel.tsx +0 -163
  196. package/src/vista/form-payload.spec.ts +0 -139
  197. package/src/vista/html/CustomUiFrame.spec.tsx +0 -127
  198. package/src/vista/html/CustomUiFrame.tsx +0 -206
  199. package/src/vista/html/custom-ui-frame-bridge.spec.ts +0 -191
  200. package/src/vista/html/custom-ui-frame-bridge.ts +0 -98
  201. package/src/vista/html/custom-ui-frame-contract.ts +0 -88
  202. package/src/vista/html/custom-ui-intents.spec.ts +0 -135
  203. package/src/vista/html/custom-ui-intents.ts +0 -155
  204. package/src/vista/html/custom-ui-srcdoc.spec.ts +0 -151
  205. package/src/vista/html/custom-ui-srcdoc.ts +0 -193
  206. package/src/vista/html/index.ts +0 -13
  207. package/src/vista/index.ts +0 -52
  208. package/src/vista/surface-catalogue.spec.ts +0 -140
  209. package/src/vista/surface-catalogue.ts +0 -90
  210. package/src/vista/surface-icons.ts +0 -57
  211. package/src/vista/surface-registry.ts +0 -56
  212. package/src/vista/surfaces/ChartSurface.tsx +0 -34
  213. package/src/vista/surfaces/FilesSurface.tsx +0 -202
  214. package/src/vista/surfaces/FormSurface.tsx +0 -380
  215. package/src/vista/surfaces/HtmlSurface.tsx +0 -43
  216. package/src/vista/surfaces/TableSurface.tsx +0 -100
  217. package/src/vista/surfaces/UrlSurface.tsx +0 -40
  218. package/src/vista/surfaces/blob-surfaces.tsx +0 -139
  219. package/src/vista/surfaces/elicitation-transport.spec.ts +0 -369
  220. package/src/vista/surfaces/elicitation-transport.ts +0 -367
  221. package/src/vista/surfaces/file-surface-utils.ts +0 -69
  222. package/src/vista/surfaces/index.ts +0 -24
  223. package/src/vista/surfaces/register-surfaces.tsx +0 -139
  224. package/src/vista/surfaces/text-surfaces.tsx +0 -132
  225. package/src/vista/use-vista-tabs.ts +0 -196
  226. package/src/vista/vista-code-renderer-context.ts +0 -16
  227. package/src/vista/vista-code-renderer.tsx +0 -35
  228. package/src/vista/vista-file-context.ts +0 -14
  229. package/src/vista/vista-file-source.tsx +0 -141
  230. package/src/vista/vista-form-context.ts +0 -20
  231. package/src/vista/vista-form-host.tsx +0 -48
  232. package/src/vista/vista-model.ts +0 -137
  233. package/src/vista/vista-open-context.tsx +0 -27
  234. package/src/vista/vista-open-state.ts +0 -11
  235. package/src/vista/vista-payloads.ts +0 -635
  236. package/src/vista/vista-tabs-manifest.ts +0 -138
  237. package/src/vista/vista-tools.ts +0 -232
@@ -1,179 +0,0 @@
1
- /**
2
- * Generic schema-driven Vista surface — layer 2 of the three-layer
3
- * zero-maintenance guarantee (own renderer > THIS > safe fallback card).
4
- *
5
- * Renders a biome-contributed surface kind that has NO dedicated frontend
6
- * renderer yet: the catalogue `displayName` over a labelled key/value view of
7
- * the payload, ORDERED and LABELLED from the kind's catalogue `payloadSchema`
8
- * (an opaque JSON Schema the kernel passes through verbatim).
9
- *
10
- * The projection is a pure, total function of `(payloadSchema, payload)`:
11
- * • when the schema declares an object `properties` map, the declared keys
12
- * are shown FIRST, in declaration order, labelled by each property's
13
- * `title` (falling back to the key) and annotated with its `description`;
14
- * • any payload key the schema did not declare is appended after them, so a
15
- * payload is NEVER silently truncated by a stale schema;
16
- * • a schema with no usable `properties` map degrades to plain
17
- * `Object.entries(payload)` — the same view the ChatWidget generic renderer
18
- * has always given.
19
- *
20
- * A biome that ships its OWN renderer overrides this: the catalogue sync only
21
- * registers here where no renderer exists.
22
- */
23
- import { type ReactElement } from 'react';
24
-
25
- /** One resolved row: the label to show, and the payload key to read. */
26
- interface GenericSurfaceField {
27
- readonly key: string;
28
- readonly label: string;
29
- readonly description?: string;
30
- }
31
-
32
- function stringify(value: unknown): string {
33
- if (typeof value === 'string') {
34
- return value;
35
- }
36
- if (typeof value === 'number' || typeof value === 'boolean') {
37
- return String(value);
38
- }
39
- if (value === null || value === undefined) {
40
- return '—';
41
- }
42
- try {
43
- return JSON.stringify(value);
44
- } catch {
45
- return String(value);
46
- }
47
- }
48
-
49
- function isPlainObject(value: unknown): value is Record<string, unknown> {
50
- return typeof value === 'object' && value !== null && !Array.isArray(value);
51
- }
52
-
53
- /**
54
- * Ordered, labelled fields for a payload, derived from the kind's JSON Schema.
55
- * Schema-declared keys first (declaration order), then any undeclared payload
56
- * key. Total: never throws, never drops a payload key.
57
- */
58
- export function deriveGenericSurfaceFields(
59
- payloadSchema: Record<string, unknown>,
60
- payload: unknown,
61
- ): readonly GenericSurfaceField[] {
62
- const payloadKeys = isPlainObject(payload) ? Object.keys(payload) : [];
63
- const properties = payloadSchema['properties'];
64
- if (!isPlainObject(properties)) {
65
- return payloadKeys.map((key) => ({ key, label: key }));
66
- }
67
- const declared: GenericSurfaceField[] = [];
68
- for (const [key, raw] of Object.entries(properties)) {
69
- const spec = isPlainObject(raw) ? raw : {};
70
- const title = spec['title'];
71
- const description = spec['description'];
72
- declared.push({
73
- key,
74
- label: typeof title === 'string' && title.length > 0 ? title : key,
75
- ...(typeof description === 'string' && description.length > 0
76
- ? { description }
77
- : {}),
78
- });
79
- }
80
- const declaredKeys = new Set(declared.map((field) => field.key));
81
- const extra = payloadKeys
82
- .filter((key) => !declaredKeys.has(key))
83
- .map((key) => ({ key, label: key }));
84
- return [...declared, ...extra];
85
- }
86
-
87
- function readValue(payload: unknown, key: string): unknown {
88
- return isPlainObject(payload) ? payload[key] : payload;
89
- }
90
-
91
- function renderGenericSurface({
92
- displayName,
93
- payloadSchema,
94
- payload,
95
- }: Readonly<{
96
- displayName: string;
97
- payloadSchema: Record<string, unknown>;
98
- payload: unknown;
99
- }>): ReactElement {
100
- const fields = deriveGenericSurfaceFields(payloadSchema, payload);
101
- const rows: readonly GenericSurfaceField[] =
102
- fields.length > 0 ? fields : [{ key: 'value', label: 'value' }];
103
- return (
104
- <div
105
- style={{
106
- margin: 9,
107
- border: '1px solid hsl(var(--rule))',
108
- borderRadius: 9,
109
- overflow: 'hidden',
110
- background: 'hsl(var(--paper-elev))',
111
- }}
112
- >
113
- <div
114
- style={{
115
- padding: '7px 11px',
116
- borderBottom: '1px solid hsl(var(--rule))',
117
- background: 'hsl(var(--muted))',
118
- color: 'hsl(var(--ink-3))',
119
- fontSize: 12,
120
- fontWeight: 600,
121
- }}
122
- >
123
- {displayName}
124
- </div>
125
- <div style={{ padding: '4px 0' }}>
126
- {rows.map((field) => (
127
- <div
128
- key={field.key}
129
- style={{
130
- display: 'flex',
131
- gap: 11,
132
- padding: '4px 11px',
133
- fontSize: 12.5,
134
- }}
135
- >
136
- <span style={{ color: 'hsl(var(--ink-4))', minWidth: 128 }}>
137
- {field.label}
138
- {field.description !== undefined && (
139
- <span
140
- style={{
141
- display: 'block',
142
- fontSize: 11,
143
- color: 'hsl(var(--ink-5, var(--ink-4)))',
144
- }}
145
- >
146
- {field.description}
147
- </span>
148
- )}
149
- </span>
150
- <span
151
- style={{ color: 'hsl(var(--ink-2))', wordBreak: 'break-word' }}
152
- >
153
- {stringify(
154
- field.key === 'value' && !isPlainObject(payload)
155
- ? payload
156
- : readValue(payload, field.key),
157
- )}
158
- </span>
159
- </div>
160
- ))}
161
- </div>
162
- </div>
163
- );
164
- }
165
-
166
- /**
167
- * Build a renderer bound to a catalogue entry's `displayName` + `payloadSchema`
168
- * for a biome surface kind with no dedicated frontend renderer.
169
- */
170
- export function makeGenericSurfaceRenderer(
171
- displayName: string,
172
- payloadSchema: Record<string, unknown>,
173
- ): (payload: unknown) => ReactElement {
174
- // `renderGenericSurface` is a pure presentational function (no hooks); call
175
- // it directly so the renderer is a plain element factory, not a nested
176
- // component definition.
177
- return (payload: unknown) =>
178
- renderGenericSurface({ displayName, payloadSchema, payload });
179
- }
@@ -1,109 +0,0 @@
1
- /**
2
- * Safe fallback card for the Vista surface registry — layer 3 of the
3
- * three-layer zero-maintenance guarantee (own renderer > generic schema-driven
4
- * renderer > this).
5
- *
6
- * Rendered for an unknown kind, an unparseable payload, or a payload version
7
- * newer than the host supports. It NEVER throws and NEVER blanks — it states
8
- * what happened and discloses the raw payload, so a biome shipping a
9
- * not-yet-known surface degrades VISIBLY instead of silently. The fallback is
10
- * itself part of the contract, not an error path.
11
- */
12
- import { AlertTriangle, ChevronDown, ChevronRight } from 'lucide-react';
13
- import { useState, type ReactElement } from 'react';
14
-
15
- import { ContributionFallbackReason } from '../lib/contribution-registry';
16
-
17
- const REASON_LABEL: Record<ContributionFallbackReason, string> = {
18
- [ContributionFallbackReason.UnknownKind]:
19
- "This view isn't available in your client.",
20
- [ContributionFallbackReason.InvalidPayload]:
21
- "This view couldn't be displayed (its data didn't match the expected shape).",
22
- [ContributionFallbackReason.UnsupportedVersion]:
23
- 'This view needs a newer client — refresh to see it.',
24
- };
25
-
26
- export function SurfaceFallbackCard({
27
- kind,
28
- reason,
29
- payload,
30
- title,
31
- }: Readonly<{
32
- kind: string;
33
- reason: ContributionFallbackReason;
34
- payload: unknown;
35
- /** The tab title, when the envelope carried one. */
36
- title?: string;
37
- }>): ReactElement {
38
- const [open, setOpen] = useState(false);
39
- let raw: string;
40
- try {
41
- raw = JSON.stringify(payload, null, 2);
42
- } catch {
43
- raw = String(payload);
44
- }
45
- return (
46
- <div
47
- style={{
48
- margin: 9,
49
- border: '1px solid hsl(var(--rule))',
50
- borderRadius: 9,
51
- background: 'hsl(var(--paper-elev))',
52
- overflow: 'hidden',
53
- }}
54
- >
55
- <button
56
- type="button"
57
- onClick={() => setOpen((v) => !v)}
58
- style={{
59
- display: 'flex',
60
- alignItems: 'center',
61
- gap: 9,
62
- width: '100%',
63
- padding: '9px 11px',
64
- textAlign: 'left',
65
- cursor: 'pointer',
66
- }}
67
- >
68
- <AlertTriangle
69
- size={14}
70
- style={{ color: 'hsl(var(--warning))', flexShrink: 0 }}
71
- />
72
- <div style={{ flex: 1, minWidth: 0 }}>
73
- <div
74
- style={{ fontSize: 12.5, fontWeight: 600, color: 'hsl(var(--ink-2))' }}
75
- >
76
- {title ?? 'Unsupported view'}
77
- </div>
78
- <div style={{ fontSize: 11.5, color: 'hsl(var(--ink-4))', marginTop: 1 }}>
79
- {REASON_LABEL[reason]}
80
- </div>
81
- </div>
82
- <span
83
- className="mono"
84
- style={{ fontSize: 10.5, color: 'hsl(var(--ink-4))', flexShrink: 0 }}
85
- >
86
- {kind}
87
- </span>
88
- {open ? <ChevronDown size={12} /> : <ChevronRight size={12} />}
89
- </button>
90
- {open && (
91
- <pre
92
- className="mono"
93
- style={{
94
- margin: 0,
95
- padding: '8px 11px',
96
- borderTop: '1px solid hsl(var(--rule))',
97
- fontSize: 11,
98
- lineHeight: 1.55,
99
- color: 'hsl(var(--ink-3))',
100
- whiteSpace: 'pre-wrap',
101
- overflowX: 'auto',
102
- }}
103
- >
104
- {raw}
105
- </pre>
106
- )}
107
- </div>
108
- );
109
- }
@@ -1,163 +0,0 @@
1
- /**
2
- * `VistaPanel` — the ONE tabbed render plane.
3
- *
4
- * It replaces the three hand-rolled tab strips the frontend carried (the thin
5
- * session workspace, the Design-System-Builder preview, and App Forge's
6
- * preview): tab chrome is {@link OverflowTabs} (auto-collapsing "More…" instead
7
- * of a horizontal-scroll strip, active + pinned always visible), tab STATE is
8
- * {@link useVistaTabs}, and the body is whatever the Vista surface registry
9
- * resolves the active {@link VistaTab} to.
10
- *
11
- * The panel is presentation only: it never fetches, never authorises, and never
12
- * decides what a kind means. Resolution follows the three-layer guarantee —
13
- * a registered renderer wins, else the generic schema-driven renderer the
14
- * catalogue sync installed, else {@link SurfaceFallbackCard} with a typed
15
- * reason. It never throws and never blanks.
16
- */
17
- import { type ReactElement, type ReactNode } from 'react';
18
-
19
- import { surfaceKindIcon } from './surface-icons';
20
- import { vistaSurfaceRegistry } from './surface-registry';
21
- import { SurfaceFallbackCard } from './SurfaceFallbackCard';
22
- import { cn } from '../ui/cn';
23
- import { OverflowTabs, type OverflowTab } from '../ui/primitives/overflow-tabs';
24
-
25
- import type { VistaTab } from './vista-model';
26
-
27
- export interface VistaPanelProps {
28
- /** Every open tab, in display order (pinned first). */
29
- readonly tabs: readonly VistaTab[];
30
- /** The focused tab, or `null` when the panel holds no tabs. */
31
- readonly activeTabId: string | null;
32
- readonly onActivate: (tabId: string) => void;
33
- /**
34
- * Close handler. Omit for a panel whose tabs are all host-owned; pinned tabs
35
- * never render a close affordance regardless.
36
- */
37
- readonly onClose?: (tabId: string) => void;
38
- /** Optional action rendered at the right edge of the tab bar. */
39
- readonly tabBarAction?: ReactNode;
40
- /**
41
- * Tab ids to mark with the strip's attention dot — "this tab changed while
42
- * you were looking elsewhere". The panel does not decide what "changed"
43
- * means; the owner does.
44
- */
45
- readonly indicatorTabIds?: readonly string[];
46
- /** Rendered when there are no tabs at all. */
47
- readonly emptyState?: ReactNode;
48
- readonly className?: string;
49
- }
50
-
51
- export function VistaPanel({
52
- tabs,
53
- activeTabId,
54
- onActivate,
55
- onClose,
56
- tabBarAction,
57
- indicatorTabIds,
58
- emptyState,
59
- className,
60
- }: VistaPanelProps): ReactElement {
61
- const active = tabs.find((t) => t.tabId === activeTabId) ?? null;
62
- return (
63
- <div
64
- className={cn(
65
- 'flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden',
66
- className,
67
- )}
68
- >
69
- <VistaTabBar
70
- tabs={tabs}
71
- activeTabId={activeTabId}
72
- onActivate={onActivate}
73
- {...(onClose ? { onClose } : {})}
74
- {...(tabBarAction === undefined ? {} : { tabBarAction })}
75
- {...(indicatorTabIds === undefined ? {} : { indicatorTabIds })}
76
- />
77
- <div className="min-h-0 flex-1 overflow-hidden">
78
- {active === null ? (
79
- <>{emptyState ?? null}</>
80
- ) : (
81
- <VistaSurfaceBody tab={active} />
82
- )}
83
- </div>
84
- </div>
85
- );
86
- }
87
-
88
- export type VistaTabBarProps = Omit<
89
- VistaPanelProps,
90
- 'emptyState' | 'className'
91
- > & { readonly className?: string };
92
-
93
- /**
94
- * The tab STRIP alone. Exported so a surface whose chrome interleaves other
95
- * controls between the tabs and the body (the Design-System-Builder's browser
96
- * chrome puts a URL + action row there) composes the SAME strip instead of
97
- * hand-rolling a second one. `VistaPanel` is just this plus
98
- * {@link VistaSurfaceBody}.
99
- */
100
- export function VistaTabBar({
101
- tabs,
102
- activeTabId,
103
- onActivate,
104
- onClose,
105
- tabBarAction,
106
- indicatorTabIds,
107
- className,
108
- }: VistaTabBarProps): ReactElement {
109
- const overflowTabs: OverflowTab[] = tabs.map((tab) => {
110
- const entry: {
111
- value: string;
112
- label: string;
113
- pinned?: boolean;
114
- indicator?: boolean;
115
- icon?: OverflowTab['icon'];
116
- } = { value: tab.tabId, label: tab.title };
117
- if (tab.pinned === true) {
118
- entry.pinned = true;
119
- }
120
- if (indicatorTabIds?.includes(tab.tabId) === true) {
121
- entry.indicator = true;
122
- }
123
- const icon = surfaceKindIcon(tab.kind);
124
- if (icon !== undefined) {
125
- entry.icon = icon;
126
- }
127
- return entry;
128
- });
129
- return (
130
- <div className={cn('flex shrink-0 items-end gap-2 px-2', className)}>
131
- <div className="min-w-0 flex-1">
132
- <OverflowTabs
133
- tabs={overflowTabs}
134
- value={activeTabId ?? ''}
135
- onChange={onActivate}
136
- {...(onClose ? { onClose } : {})}
137
- />
138
- </div>
139
- {tabBarAction}
140
- </div>
141
- );
142
- }
143
-
144
- /**
145
- * Resolve ONE tab through the registry and draw it. Split out so the resolution
146
- * decision (and therefore the fallback reason) is inspectable in isolation.
147
- */
148
- export function VistaSurfaceBody({
149
- tab,
150
- }: Readonly<{ tab: VistaTab }>): ReactElement {
151
- const resolution = vistaSurfaceRegistry.resolve(tab);
152
- if (resolution.matched) {
153
- return resolution.rendered;
154
- }
155
- return (
156
- <SurfaceFallbackCard
157
- kind={resolution.kind}
158
- reason={resolution.reason}
159
- payload={tab.payload}
160
- title={tab.title}
161
- />
162
- );
163
- }
@@ -1,139 +0,0 @@
1
- /**
2
- * Guards `validateFormPayload` — the structural half of "the value never
3
- * reaches the agent".
4
- *
5
- * The payload has no network authority: it carries only a base64url opaque ref,
6
- * while the trusted service base URL comes from `VistaFormHost`.
7
- */
8
- import { describe, expect, it } from 'vitest';
9
-
10
- import { validateFormPayload } from './vista-payloads';
11
- import { CaptureFieldType } from '../ui/capture/field-spec';
12
-
13
- const BASE = {
14
- ref: 'ref-1',
15
- purpose: 'Connect Acme so I can read your tickets.',
16
- fields: [
17
- {
18
- key: 'apiKey',
19
- label: 'API key',
20
- type: CaptureFieldType.String,
21
- required: true,
22
- isSecret: true,
23
- transform: 'trim',
24
- },
25
- {
26
- key: 'baseUrl',
27
- label: 'Base URL',
28
- type: CaptureFieldType.Url,
29
- required: true,
30
- isSecret: false,
31
- },
32
- ],
33
- };
34
-
35
- describe('validateFormPayload', () => {
36
- it('accepts a well-formed field-mode payload and preserves declared secrecy', () => {
37
- const payload = validateFormPayload(BASE);
38
- expect(payload).not.toBeNull();
39
- expect(payload?.fields).toHaveLength(2);
40
- expect(payload?.fields[0]?.isSecret).toBe(true);
41
- expect(payload?.fields[1]?.isSecret).toBe(false);
42
- expect(payload?.fields[0]?.transform).toBe('trim');
43
- });
44
-
45
- it('rejects old or malicious payload-selected submit/status authorities', () => {
46
- for (const target of [
47
- 'https://evil.example/steal',
48
- 'https://trusted.example@evil.example/steal',
49
- '//evil.example/steal',
50
- '/credential-elicitations/ref-1/submit',
51
- 'javascript:alert(1)',
52
- ]) {
53
- expect(validateFormPayload({ ...BASE, submitUrl: target })).toBeNull();
54
- expect(validateFormPayload({ ...BASE, statusUrl: target })).toBeNull();
55
- }
56
- });
57
-
58
- it('accepts an EMPTY field schema — the service is the authority, not the client', () => {
59
- const payload = validateFormPayload({ ...BASE, fields: [] });
60
- expect(payload).not.toBeNull();
61
- expect(payload?.fields).toEqual([]);
62
- });
63
-
64
- it('rejects a malformed field spec rather than half-rendering it', () => {
65
- expect(
66
- validateFormPayload({
67
- ...BASE,
68
- fields: [{ key: 'a', label: 'A', type: 'nope' }],
69
- }),
70
- ).toBeNull();
71
- expect(
72
- validateFormPayload({ ...BASE, fields: [{ key: 'a', label: 'A' }] }),
73
- ).toBeNull();
74
- expect(
75
- validateFormPayload({
76
- ...BASE,
77
- fields: [
78
- {
79
- key: 'a',
80
- label: 'A',
81
- type: CaptureFieldType.String,
82
- isSecret: 'yes',
83
- },
84
- ],
85
- }),
86
- ).toBeNull();
87
- expect(validateFormPayload({ ...BASE, fields: {} })).toBeNull();
88
- });
89
-
90
- it('accepts a launch payload with a root-relative trusted-service path', () => {
91
- const payload = validateFormPayload({
92
- ...BASE,
93
- fields: [],
94
- launch: {
95
- path: '/oauth/authorize?x=1',
96
- label: 'Continue to Acme',
97
- hint: 'h',
98
- },
99
- });
100
- expect(payload?.launch).toEqual({
101
- path: '/oauth/authorize?x=1',
102
- label: 'Continue to Acme',
103
- hint: 'h',
104
- });
105
- });
106
-
107
- it('rejects launch authority/scheme confusion and malformed paths', () => {
108
- for (const path of [
109
- 'authorize',
110
- '//evil.example/authorize',
111
- 'https://evil.example/authorize',
112
- 'javascript:alert(1)',
113
- '\\\\evil.example\\authorize',
114
- ]) {
115
- expect(
116
- validateFormPayload({ ...BASE, launch: { path, label: 'Go' } }),
117
- ).toBeNull();
118
- }
119
- expect(
120
- validateFormPayload({
121
- ...BASE,
122
- launch: { url: 'https://evil.example/a', label: 'Go' },
123
- }),
124
- ).toBeNull();
125
- expect(
126
- validateFormPayload({
127
- ...BASE,
128
- launch: { path: '/authorize', label: '' },
129
- }),
130
- ).toBeNull();
131
- });
132
-
133
- it('rejects missing refs and path-traversal/encoding input', () => {
134
- for (const ref of ['', '.', '..', '../steal', 'a/b', '%2e%2e', 'réf']) {
135
- expect(validateFormPayload({ ...BASE, ref })).toBeNull();
136
- }
137
- expect(validateFormPayload({ ...BASE, ref: undefined })).toBeNull();
138
- });
139
- });