@xemahq/ui-kernel 0.9.0 → 0.9.1

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 (238) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/biome-host/biome-registry.d.ts.map +1 -1
  6. package/dist/lib/biome-host/biome-registry.js +14 -9
  7. package/dist/lib/biome-host/biome-registry.js.map +1 -1
  8. package/dist/lib/contribution-registry/contribution-registry.d.ts +24 -0
  9. package/dist/lib/contribution-registry/contribution-registry.d.ts.map +1 -0
  10. package/dist/lib/contribution-registry/contribution-registry.js +67 -0
  11. package/dist/lib/contribution-registry/contribution-registry.js.map +1 -0
  12. package/dist/lib/contribution-registry/index.d.ts +3 -0
  13. package/dist/lib/contribution-registry/index.d.ts.map +1 -0
  14. package/dist/lib/contribution-registry/index.js +3 -0
  15. package/dist/lib/contribution-registry/index.js.map +1 -0
  16. package/dist/lib/contribution-registry/renderable-registry.d.ts +33 -0
  17. package/dist/lib/contribution-registry/renderable-registry.d.ts.map +1 -0
  18. package/dist/lib/contribution-registry/renderable-registry.js +51 -0
  19. package/dist/lib/contribution-registry/renderable-registry.js.map +1 -0
  20. package/dist/ui/capture/field-spec-to-zod.d.ts +1 -0
  21. package/dist/ui/capture/field-spec-to-zod.d.ts.map +1 -1
  22. package/dist/ui/capture/field-spec-to-zod.js +19 -0
  23. package/dist/ui/capture/field-spec-to-zod.js.map +1 -1
  24. package/dist/ui/capture/field-spec-validate.d.ts +4 -0
  25. package/dist/ui/capture/field-spec-validate.d.ts.map +1 -0
  26. package/dist/ui/capture/field-spec-validate.js +129 -0
  27. package/dist/ui/capture/field-spec-validate.js.map +1 -0
  28. package/dist/ui/capture/field-spec.d.ts +13 -1
  29. package/dist/ui/capture/field-spec.d.ts.map +1 -1
  30. package/dist/ui/capture/field-spec.js +25 -0
  31. package/dist/ui/capture/field-spec.js.map +1 -1
  32. package/dist/ui/capture/index.d.ts +4 -2
  33. package/dist/ui/capture/index.d.ts.map +1 -1
  34. package/dist/ui/capture/index.js +4 -2
  35. package/dist/ui/capture/index.js.map +1 -1
  36. package/dist/ui/capture/schema-field-input.d.ts.map +1 -1
  37. package/dist/ui/capture/schema-field-input.js +39 -12
  38. package/dist/ui/capture/schema-field-input.js.map +1 -1
  39. package/dist/ui/capture/submit-values.d.ts +6 -0
  40. package/dist/ui/capture/submit-values.d.ts.map +1 -0
  41. package/dist/ui/capture/submit-values.js +28 -0
  42. package/dist/ui/capture/submit-values.js.map +1 -0
  43. package/dist/ui/index.d.ts +1 -0
  44. package/dist/ui/index.d.ts.map +1 -1
  45. package/dist/ui/index.js +1 -0
  46. package/dist/ui/index.js.map +1 -1
  47. package/dist/ui/primitives/overflow-tabs.d.ts +5 -0
  48. package/dist/ui/primitives/overflow-tabs.d.ts.map +1 -1
  49. package/dist/ui/primitives/overflow-tabs.js +4 -4
  50. package/dist/ui/primitives/overflow-tabs.js.map +1 -1
  51. package/dist/ui/primitives/url-preview-chrome.d.ts +8 -0
  52. package/dist/ui/primitives/url-preview-chrome.d.ts.map +1 -0
  53. package/dist/ui/primitives/url-preview-chrome.js +40 -0
  54. package/dist/ui/primitives/url-preview-chrome.js.map +1 -0
  55. package/dist/vista/GenericCatalogueSurface.d.ts +10 -0
  56. package/dist/vista/GenericCatalogueSurface.d.ts.map +1 -0
  57. package/dist/vista/GenericCatalogueSurface.js +80 -0
  58. package/dist/vista/GenericCatalogueSurface.js.map +1 -0
  59. package/dist/vista/SurfaceFallbackCard.d.ts +9 -0
  60. package/dist/vista/SurfaceFallbackCard.d.ts.map +1 -0
  61. package/dist/vista/SurfaceFallbackCard.js +44 -0
  62. package/dist/vista/SurfaceFallbackCard.js.map +1 -0
  63. package/dist/vista/VistaPanel.d.ts +21 -0
  64. package/dist/vista/VistaPanel.d.ts.map +1 -0
  65. package/dist/vista/VistaPanel.js +31 -0
  66. package/dist/vista/VistaPanel.js.map +1 -0
  67. package/dist/vista/html/CustomUiFrame.d.ts +20 -0
  68. package/dist/vista/html/CustomUiFrame.d.ts.map +1 -0
  69. package/dist/vista/html/CustomUiFrame.js +69 -0
  70. package/dist/vista/html/CustomUiFrame.js.map +1 -0
  71. package/dist/vista/html/custom-ui-frame-bridge.d.ts +13 -0
  72. package/dist/vista/html/custom-ui-frame-bridge.d.ts.map +1 -0
  73. package/dist/vista/html/custom-ui-frame-bridge.js +30 -0
  74. package/dist/vista/html/custom-ui-frame-bridge.js.map +1 -0
  75. package/dist/vista/html/custom-ui-frame-contract.d.ts +29 -0
  76. package/dist/vista/html/custom-ui-frame-contract.d.ts.map +1 -0
  77. package/dist/vista/html/custom-ui-frame-contract.js +16 -0
  78. package/dist/vista/html/custom-ui-frame-contract.js.map +1 -0
  79. package/dist/vista/html/custom-ui-intents.d.ts +20 -0
  80. package/dist/vista/html/custom-ui-intents.d.ts.map +1 -0
  81. package/dist/vista/html/custom-ui-intents.js +57 -0
  82. package/dist/vista/html/custom-ui-intents.js.map +1 -0
  83. package/dist/vista/html/custom-ui-srcdoc.d.ts +17 -0
  84. package/dist/vista/html/custom-ui-srcdoc.d.ts.map +1 -0
  85. package/dist/vista/html/custom-ui-srcdoc.js +70 -0
  86. package/dist/vista/html/custom-ui-srcdoc.js.map +1 -0
  87. package/dist/vista/html/index.d.ts +6 -0
  88. package/dist/vista/html/index.d.ts.map +1 -0
  89. package/dist/vista/html/index.js +6 -0
  90. package/dist/vista/html/index.js.map +1 -0
  91. package/dist/vista/index.d.ts +18 -0
  92. package/dist/vista/index.d.ts.map +1 -0
  93. package/dist/vista/index.js +18 -0
  94. package/dist/vista/index.js.map +1 -0
  95. package/dist/vista/surface-catalogue.d.ts +5 -0
  96. package/dist/vista/surface-catalogue.d.ts.map +1 -0
  97. package/dist/vista/surface-catalogue.js +30 -0
  98. package/dist/vista/surface-catalogue.js.map +1 -0
  99. package/dist/vista/surface-icons.d.ts +7 -0
  100. package/dist/vista/surface-icons.d.ts.map +1 -0
  101. package/dist/vista/surface-icons.js +26 -0
  102. package/dist/vista/surface-icons.js.map +1 -0
  103. package/dist/vista/surface-registry.d.ts +7 -0
  104. package/dist/vista/surface-registry.d.ts.map +1 -0
  105. package/dist/vista/surface-registry.js +7 -0
  106. package/dist/vista/surface-registry.js.map +1 -0
  107. package/dist/vista/surfaces/ChartSurface.d.ts +4 -0
  108. package/dist/vista/surfaces/ChartSurface.d.ts.map +1 -0
  109. package/dist/vista/surfaces/ChartSurface.js +17 -0
  110. package/dist/vista/surfaces/ChartSurface.js.map +1 -0
  111. package/dist/vista/surfaces/FilesSurface.d.ts +15 -0
  112. package/dist/vista/surfaces/FilesSurface.d.ts.map +1 -0
  113. package/dist/vista/surfaces/FilesSurface.js +121 -0
  114. package/dist/vista/surfaces/FilesSurface.js.map +1 -0
  115. package/dist/vista/surfaces/FormSurface.d.ts +4 -0
  116. package/dist/vista/surfaces/FormSurface.d.ts.map +1 -0
  117. package/dist/vista/surfaces/FormSurface.js +97 -0
  118. package/dist/vista/surfaces/FormSurface.js.map +1 -0
  119. package/dist/vista/surfaces/HtmlSurface.d.ts +4 -0
  120. package/dist/vista/surfaces/HtmlSurface.d.ts.map +1 -0
  121. package/dist/vista/surfaces/HtmlSurface.js +11 -0
  122. package/dist/vista/surfaces/HtmlSurface.js.map +1 -0
  123. package/dist/vista/surfaces/TableSurface.d.ts +4 -0
  124. package/dist/vista/surfaces/TableSurface.d.ts.map +1 -0
  125. package/dist/vista/surfaces/TableSurface.js +42 -0
  126. package/dist/vista/surfaces/TableSurface.js.map +1 -0
  127. package/dist/vista/surfaces/UrlSurface.d.ts +4 -0
  128. package/dist/vista/surfaces/UrlSurface.d.ts.map +1 -0
  129. package/dist/vista/surfaces/UrlSurface.js +7 -0
  130. package/dist/vista/surfaces/UrlSurface.js.map +1 -0
  131. package/dist/vista/surfaces/blob-surfaces.d.ts +6 -0
  132. package/dist/vista/surfaces/blob-surfaces.d.ts.map +1 -0
  133. package/dist/vista/surfaces/blob-surfaces.js +38 -0
  134. package/dist/vista/surfaces/blob-surfaces.js.map +1 -0
  135. package/dist/vista/surfaces/elicitation-transport.d.ts +18 -0
  136. package/dist/vista/surfaces/elicitation-transport.d.ts.map +1 -0
  137. package/dist/vista/surfaces/elicitation-transport.js +100 -0
  138. package/dist/vista/surfaces/elicitation-transport.js.map +1 -0
  139. package/dist/vista/surfaces/index.d.ts +11 -0
  140. package/dist/vista/surfaces/index.d.ts.map +1 -0
  141. package/dist/vista/surfaces/index.js +89 -0
  142. package/dist/vista/surfaces/index.js.map +1 -0
  143. package/dist/vista/surfaces/text-surfaces.d.ts +8 -0
  144. package/dist/vista/surfaces/text-surfaces.d.ts.map +1 -0
  145. package/dist/vista/surfaces/text-surfaces.js +54 -0
  146. package/dist/vista/surfaces/text-surfaces.js.map +1 -0
  147. package/dist/vista/use-vista-tabs.d.ts +30 -0
  148. package/dist/vista/use-vista-tabs.d.ts.map +1 -0
  149. package/dist/vista/use-vista-tabs.js +77 -0
  150. package/dist/vista/use-vista-tabs.js.map +1 -0
  151. package/dist/vista/vista-code-renderer.d.ts +12 -0
  152. package/dist/vista/vista-code-renderer.d.ts.map +1 -0
  153. package/dist/vista/vista-code-renderer.js +10 -0
  154. package/dist/vista/vista-code-renderer.js.map +1 -0
  155. package/dist/vista/vista-file-source.d.ts +20 -0
  156. package/dist/vista/vista-file-source.d.ts.map +1 -0
  157. package/dist/vista/vista-file-source.js +69 -0
  158. package/dist/vista/vista-file-source.js.map +1 -0
  159. package/dist/vista/vista-form-host.d.ts +16 -0
  160. package/dist/vista/vista-form-host.d.ts.map +1 -0
  161. package/dist/vista/vista-form-host.js +10 -0
  162. package/dist/vista/vista-form-host.js.map +1 -0
  163. package/dist/vista/vista-model.d.ts +12 -0
  164. package/dist/vista/vista-model.d.ts.map +1 -0
  165. package/dist/vista/vista-model.js +72 -0
  166. package/dist/vista/vista-model.js.map +1 -0
  167. package/dist/vista/vista-open-context.d.ts +9 -0
  168. package/dist/vista/vista-open-context.d.ts.map +1 -0
  169. package/dist/vista/vista-open-context.js +10 -0
  170. package/dist/vista/vista-open-context.js.map +1 -0
  171. package/dist/vista/vista-payloads.d.ts +107 -0
  172. package/dist/vista/vista-payloads.d.ts.map +1 -0
  173. package/dist/vista/vista-payloads.js +305 -0
  174. package/dist/vista/vista-payloads.js.map +1 -0
  175. package/dist/vista/vista-tabs-manifest.d.ts +17 -0
  176. package/dist/vista/vista-tabs-manifest.d.ts.map +1 -0
  177. package/dist/vista/vista-tabs-manifest.js +60 -0
  178. package/dist/vista/vista-tabs-manifest.js.map +1 -0
  179. package/dist/vista/vista-tools.d.ts +41 -0
  180. package/dist/vista/vista-tools.d.ts.map +1 -0
  181. package/dist/vista/vista-tools.js +113 -0
  182. package/dist/vista/vista-tools.js.map +1 -0
  183. package/package.json +3 -3
  184. package/src/index.ts +5 -0
  185. package/src/lib/biome-host/biome-registry.ts +31 -11
  186. package/src/lib/contribution-registry/contribution-registry.spec.ts +141 -0
  187. package/src/lib/contribution-registry/contribution-registry.ts +202 -0
  188. package/src/lib/contribution-registry/index.ts +9 -0
  189. package/src/lib/contribution-registry/renderable-registry.ts +142 -0
  190. package/src/ui/capture/field-spec-to-zod.ts +22 -0
  191. package/src/ui/capture/field-spec-validate.ts +147 -0
  192. package/src/ui/capture/field-spec.ts +62 -0
  193. package/src/ui/capture/index.ts +9 -1
  194. package/src/ui/capture/schema-field-input.tsx +134 -14
  195. package/src/ui/capture/submit-values.test.ts +70 -0
  196. package/src/ui/capture/submit-values.ts +63 -0
  197. package/src/ui/index.ts +4 -0
  198. package/src/ui/primitives/overflow-tabs.tsx +24 -4
  199. package/src/ui/primitives/url-preview-chrome.tsx +102 -0
  200. package/src/vista/GenericCatalogueSurface.tsx +177 -0
  201. package/src/vista/SurfaceFallbackCard.tsx +109 -0
  202. package/src/vista/VistaPanel.tsx +155 -0
  203. package/src/vista/form-payload.spec.ts +93 -0
  204. package/src/vista/html/CustomUiFrame.spec.tsx +125 -0
  205. package/src/vista/html/CustomUiFrame.tsx +204 -0
  206. package/src/vista/html/custom-ui-frame-bridge.spec.ts +191 -0
  207. package/src/vista/html/custom-ui-frame-bridge.ts +92 -0
  208. package/src/vista/html/custom-ui-frame-contract.ts +88 -0
  209. package/src/vista/html/custom-ui-intents.spec.ts +133 -0
  210. package/src/vista/html/custom-ui-intents.ts +151 -0
  211. package/src/vista/html/custom-ui-srcdoc.spec.ts +151 -0
  212. package/src/vista/html/custom-ui-srcdoc.ts +193 -0
  213. package/src/vista/html/index.ts +13 -0
  214. package/src/vista/index.ts +48 -0
  215. package/src/vista/surface-catalogue.spec.ts +140 -0
  216. package/src/vista/surface-catalogue.ts +84 -0
  217. package/src/vista/surface-icons.ts +57 -0
  218. package/src/vista/surface-registry.ts +56 -0
  219. package/src/vista/surfaces/ChartSurface.tsx +34 -0
  220. package/src/vista/surfaces/FilesSurface.tsx +268 -0
  221. package/src/vista/surfaces/FormSurface.tsx +264 -0
  222. package/src/vista/surfaces/HtmlSurface.tsx +43 -0
  223. package/src/vista/surfaces/TableSurface.tsx +99 -0
  224. package/src/vista/surfaces/UrlSurface.tsx +40 -0
  225. package/src/vista/surfaces/blob-surfaces.tsx +129 -0
  226. package/src/vista/surfaces/elicitation-transport.spec.ts +187 -0
  227. package/src/vista/surfaces/elicitation-transport.ts +175 -0
  228. package/src/vista/surfaces/index.tsx +157 -0
  229. package/src/vista/surfaces/text-surfaces.tsx +119 -0
  230. package/src/vista/use-vista-tabs.ts +188 -0
  231. package/src/vista/vista-code-renderer.tsx +46 -0
  232. package/src/vista/vista-file-source.tsx +163 -0
  233. package/src/vista/vista-form-host.tsx +78 -0
  234. package/src/vista/vista-model.ts +130 -0
  235. package/src/vista/vista-open-context.tsx +42 -0
  236. package/src/vista/vista-payloads.ts +514 -0
  237. package/src/vista/vista-tabs-manifest.ts +123 -0
  238. package/src/vista/vista-tools.ts +220 -0
@@ -0,0 +1,70 @@
1
+ // Pure-logic proofs for the ONE values→wire projection and the declared
2
+ // transform. Runs under the host-web vitest runner (this package carries no
3
+ // vitest dep — see tsconfig exclude).
4
+ import { describe, expect, it } from 'vitest';
5
+
6
+ import { applyCaptureTransform, CaptureFieldTransform, CaptureFieldType, type CaptureFieldSpec } from './field-spec';
7
+ import { fieldSpecToZod } from './field-spec-to-zod';
8
+ import { captureValuesToStringMap, captureValuesToSubmitPayload } from './submit-values';
9
+
10
+ const fields: CaptureFieldSpec[] = [
11
+ { key: 'apiKey', label: 'API key', type: CaptureFieldType.String, required: true, isSecret: true },
12
+ { key: 'baseUrl', label: 'Base URL', type: CaptureFieldType.Url, required: true },
13
+ { key: 'serviceAccount', label: 'Service account', type: CaptureFieldType.Json, required: false },
14
+ ];
15
+
16
+ describe('applyCaptureTransform', () => {
17
+ it('applies only the DECLARED transform', () => {
18
+ expect(applyCaptureTransform(' a ', CaptureFieldTransform.Trim)).toBe('a');
19
+ expect(applyCaptureTransform('a', CaptureFieldTransform.Uppercase)).toBe('A');
20
+ expect(applyCaptureTransform('A', CaptureFieldTransform.Lowercase)).toBe('a');
21
+ expect(applyCaptureTransform(' a ', CaptureFieldTransform.None)).toBe(' a ');
22
+ // Absent = no normalization. There is no implicit blanket trim.
23
+ expect(applyCaptureTransform(' a ', undefined)).toBe(' a ');
24
+ });
25
+ });
26
+
27
+ describe('captureValuesToStringMap', () => {
28
+ it('projects ONLY declared keys, as strings', () => {
29
+ expect(
30
+ captureValuesToStringMap(fields, {
31
+ apiKey: 'sk-1',
32
+ baseUrl: 'https://acme.test',
33
+ rogue: 'should not travel',
34
+ }),
35
+ ).toEqual({ apiKey: 'sk-1', baseUrl: 'https://acme.test', serviceAccount: '' });
36
+ });
37
+ });
38
+
39
+ describe('captureValuesToSubmitPayload', () => {
40
+ it('parses a json field and leaves the rest untouched', () => {
41
+ expect(
42
+ captureValuesToSubmitPayload(fields, {
43
+ apiKey: 'sk-1',
44
+ baseUrl: 'https://acme.test',
45
+ serviceAccount: '{"a":1}',
46
+ }),
47
+ ).toEqual({ apiKey: 'sk-1', baseUrl: 'https://acme.test', serviceAccount: { a: 1 } });
48
+ });
49
+
50
+ it('does not drop an unparseable json value — validation is the gate', () => {
51
+ expect(captureValuesToSubmitPayload(fields, { serviceAccount: '{' }).serviceAccount).toBe('{');
52
+ });
53
+ });
54
+
55
+ describe('json field validation', () => {
56
+ const schema = fieldSpecToZod(fields);
57
+
58
+ it('rejects an unparseable json blob', () => {
59
+ expect(schema.safeParse({ apiKey: 'k', baseUrl: 'u', serviceAccount: '{' }).success).toBe(false);
60
+ });
61
+
62
+ it('accepts a parseable json blob and an omitted optional one', () => {
63
+ expect(schema.safeParse({ apiKey: 'k', baseUrl: 'u', serviceAccount: '{"a":1}' }).success).toBe(true);
64
+ expect(schema.safeParse({ apiKey: 'k', baseUrl: 'u' }).success).toBe(true);
65
+ });
66
+
67
+ it('requires a non-empty url/email field when required', () => {
68
+ expect(schema.safeParse({ apiKey: 'k', baseUrl: '' }).success).toBe(false);
69
+ });
70
+ });
@@ -0,0 +1,63 @@
1
+ // ═══════════════════════════════════════════════════════════════════════════
2
+ // Capture values → submit payload
3
+ //
4
+ // The ONE projection from the form's in-memory `CaptureValues` to what goes on
5
+ // the wire. Two faces, because two wire contracts exist and neither should grow
6
+ // its own inline projection:
7
+ //
8
+ // • `captureValuesToStringMap` — every field as a STRING (the shape a
9
+ // credential submit takes: `fields: Record<string, string>`).
10
+ // • `captureValuesToSubmitPayload` — same, except a `json` field is PARSED
11
+ // into its structured value (the shape the connection credential write
12
+ // takes: `credentials: Record<string, unknown>`).
13
+ //
14
+ // Both are field-driven: only DECLARED keys are projected, so a stray key in
15
+ // the values record can never reach the wire. Neither performs an undeclared
16
+ // normalization — trimming/casing is `CaptureFieldTransform`, applied once at
17
+ // the input boundary. A blanket trim here would silently override a field that
18
+ // declared `transform: none`.
19
+ // ═══════════════════════════════════════════════════════════════════════════
20
+ import { CaptureFieldType, toFieldList, type CaptureFieldSpec, type CaptureSchema, type CaptureSection, type CaptureValues } from './field-spec';
21
+ import { asString } from './value-format';
22
+
23
+ type Schema = CaptureSchema | readonly CaptureFieldSpec[] | readonly CaptureSection[];
24
+
25
+ /** Project the declared fields to a flat `string` map (fields-only wire). */
26
+ export function captureValuesToStringMap(
27
+ schema: Schema,
28
+ values: CaptureValues,
29
+ ): Record<string, string> {
30
+ const payload: Record<string, string> = {};
31
+ for (const field of toFieldList(schema)) {
32
+ payload[field.key] = asString(values[field.key]);
33
+ }
34
+ return payload;
35
+ }
36
+
37
+ /**
38
+ * Project the declared fields, parsing `json` fields into structured values.
39
+ *
40
+ * A `json` field that does not parse is left as its raw string — validation is
41
+ * `useSchemaValidation`'s job and it must run first; this projection does not
42
+ * silently drop a value it cannot parse.
43
+ */
44
+ export function captureValuesToSubmitPayload(
45
+ schema: Schema,
46
+ values: CaptureValues,
47
+ ): CaptureValues {
48
+ const payload: CaptureValues = {};
49
+ for (const field of toFieldList(schema)) {
50
+ const raw = values[field.key];
51
+ if (field.type !== CaptureFieldType.Json) {
52
+ payload[field.key] = raw;
53
+ continue;
54
+ }
55
+ const text = asString(raw);
56
+ try {
57
+ payload[field.key] = JSON.parse(text);
58
+ } catch {
59
+ payload[field.key] = text;
60
+ }
61
+ }
62
+ return payload;
63
+ }
package/src/ui/index.ts CHANGED
@@ -54,6 +54,10 @@ export {
54
54
  PreviewDeviceFrame,
55
55
  type PreviewDevice,
56
56
  } from './primitives/preview-device-frame';
57
+ export {
58
+ UrlPreviewChrome,
59
+ type UrlPreviewChromeProps,
60
+ } from './primitives/url-preview-chrome';
57
61
 
58
62
  // ── chart primitives (Wave 9.2 — pure SVG, no external chart lib) ──
59
63
  export * from './charts';
@@ -15,7 +15,14 @@
15
15
  * am I." Same for tabs marked `pinned: true` (indicator dot is sticky).
16
16
  */
17
17
  import { ChevronDown, X } from 'lucide-react';
18
- import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
18
+ import {
19
+ useEffect,
20
+ useLayoutEffect,
21
+ useMemo,
22
+ useRef,
23
+ useState,
24
+ type ComponentType,
25
+ } from 'react';
19
26
 
20
27
  import {
21
28
  DropdownMenu,
@@ -32,6 +39,14 @@ export interface OverflowTab {
32
39
  readonly indicator?: boolean;
33
40
  /** Optional numeric badge. */
34
41
  readonly count?: number;
42
+ /**
43
+ * A pinned tab is ALWAYS in the visible set (never collapsed into "More…")
44
+ * and never renders a close affordance, even when `onClose` is supplied.
45
+ * Used for a panel's permanent first tab (e.g. the Vista file browser).
46
+ */
47
+ readonly pinned?: boolean;
48
+ /** Optional leading glyph (a `lucide-react` icon component). */
49
+ readonly icon?: ComponentType<{ className?: string }>;
35
50
  }
36
51
 
37
52
  interface OverflowTabsProps {
@@ -105,7 +120,9 @@ export function OverflowTabs({
105
120
  let used = 0;
106
121
  for (let i = 0; i < tabs.length; i++) {
107
122
  const w = tabWidths[i] + (vis.length > 0 ? gap : 0);
108
- if (used + w <= budget) {
123
+ // A pinned tab is never collapsed — it stays visible whatever the budget
124
+ // says, so a panel's permanent first tab can't hide behind "More…".
125
+ if (tabs[i].pinned === true || used + w <= budget) {
109
126
  vis.push(tabs[i]);
110
127
  used += w;
111
128
  } else {
@@ -155,7 +172,9 @@ export function OverflowTabs({
155
172
  tab={t}
156
173
  active={t.value === value}
157
174
  onClick={() => onChange(t.value)}
158
- onClose={onClose ? () => onClose(t.value) : undefined}
175
+ onClose={
176
+ onClose && t.pinned !== true ? () => onClose(t.value) : undefined
177
+ }
159
178
  />
160
179
  ))}
161
180
  </div>
@@ -192,7 +211,7 @@ export function OverflowTabs({
192
211
  className="ml-2 inline-block h-1.5 w-1.5 rounded-full bg-warning"
193
212
  />
194
213
  )}
195
- {onClose && (
214
+ {onClose && t.pinned !== true && (
196
215
  <button
197
216
  type="button"
198
217
  aria-label={`Close ${t.label}`}
@@ -241,6 +260,7 @@ function TabPill({
241
260
  onClick={onClick}
242
261
  className="inline-flex items-center gap-2 outline-none"
243
262
  >
263
+ {tab.icon && <tab.icon className="h-3.5 w-3.5 shrink-0" />}
244
264
  {tab.label}
245
265
  {tab.count !== undefined && (
246
266
  <span className="rounded bg-paper-elev px-1 font-mono text-[10px] tabular-nums leading-4 text-ink-4">
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Mock browser chrome for a URL preview.
3
+ *
4
+ * Renders the traffic-light dots + an address bar + a refresh affordance, then
5
+ * the caller-supplied live content (the real iframe) below.
6
+ *
7
+ * Owned by the UI kernel so the Vista `url` surface, the thin session
8
+ * workspace, and any biome preview reuse ONE chrome — there is no second
9
+ * implementation.
10
+ */
11
+ import { RotateCw } from 'lucide-react';
12
+ import type { ReactElement, ReactNode } from 'react';
13
+
14
+ const TRAFFIC_LIGHTS = ['#e5645a', '#e8b13d', '#5bb35b'] as const;
15
+
16
+ export interface UrlPreviewChromeProps {
17
+ /** Address shown in the mock address bar. */
18
+ readonly url: string;
19
+ /** Live preview content (the real iframe). */
20
+ readonly children: ReactNode;
21
+ /** Optional reload handler wired to the refresh glyph. */
22
+ readonly onReload?: () => void;
23
+ }
24
+
25
+ export function UrlPreviewChrome({
26
+ url,
27
+ children,
28
+ onReload,
29
+ }: UrlPreviewChromeProps): ReactElement {
30
+ return (
31
+ <div style={{ height: '100%', display: 'flex', flexDirection: 'column' }}>
32
+ <div
33
+ style={{
34
+ display: 'flex',
35
+ alignItems: 'center',
36
+ gap: 8,
37
+ padding: '8px 12px',
38
+ borderBottom: '1px solid hsl(var(--rule))',
39
+ background: 'hsl(var(--paper) / 0.5)',
40
+ flexShrink: 0,
41
+ }}
42
+ >
43
+ <span style={{ display: 'flex', gap: 5 }}>
44
+ {TRAFFIC_LIGHTS.map((color) => (
45
+ <span
46
+ key={color}
47
+ style={{
48
+ width: 9,
49
+ height: 9,
50
+ borderRadius: '50%',
51
+ background: color,
52
+ }}
53
+ />
54
+ ))}
55
+ </span>
56
+ <span
57
+ className="mono"
58
+ style={{
59
+ fontSize: 11,
60
+ color: 'hsl(var(--ink-4))',
61
+ marginLeft: 6,
62
+ padding: '3px 10px',
63
+ background: 'hsl(var(--paper-sunk))',
64
+ borderRadius: 6,
65
+ flex: 1,
66
+ overflow: 'hidden',
67
+ textOverflow: 'ellipsis',
68
+ whiteSpace: 'nowrap',
69
+ }}
70
+ >
71
+ {url}
72
+ </span>
73
+ {onReload ? (
74
+ <button
75
+ type="button"
76
+ onClick={onReload}
77
+ aria-label="Reload preview"
78
+ style={{
79
+ display: 'inline-flex',
80
+ color: 'hsl(var(--ink-4))',
81
+ padding: 2,
82
+ borderRadius: 5,
83
+ }}
84
+ >
85
+ <RotateCw size={13} />
86
+ </button>
87
+ ) : (
88
+ <RotateCw size={13} style={{ color: 'hsl(var(--ink-4))' }} />
89
+ )}
90
+ </div>
91
+ <div
92
+ style={{
93
+ flex: 1,
94
+ minHeight: 0,
95
+ background: 'hsl(var(--paper-elev))',
96
+ }}
97
+ >
98
+ {children}
99
+ </div>
100
+ </div>
101
+ );
102
+ }
@@ -0,0 +1,177 @@
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') return value;
34
+ if (typeof value === 'number' || typeof value === 'boolean') {
35
+ return String(value);
36
+ }
37
+ if (value === null || value === undefined) return '—';
38
+ try {
39
+ return JSON.stringify(value);
40
+ } catch {
41
+ return String(value);
42
+ }
43
+ }
44
+
45
+ function isPlainObject(value: unknown): value is Record<string, unknown> {
46
+ return (
47
+ typeof value === 'object' && value !== null && !Array.isArray(value)
48
+ );
49
+ }
50
+
51
+ /**
52
+ * Ordered, labelled fields for a payload, derived from the kind's JSON Schema.
53
+ * Schema-declared keys first (declaration order), then any undeclared payload
54
+ * key. Total: never throws, never drops a payload key.
55
+ */
56
+ export function deriveGenericSurfaceFields(
57
+ payloadSchema: Record<string, unknown>,
58
+ payload: unknown,
59
+ ): readonly GenericSurfaceField[] {
60
+ const payloadKeys = isPlainObject(payload) ? Object.keys(payload) : [];
61
+ const properties = payloadSchema['properties'];
62
+ if (!isPlainObject(properties)) {
63
+ return payloadKeys.map((key) => ({ key, label: key }));
64
+ }
65
+ const declared: GenericSurfaceField[] = [];
66
+ for (const [key, raw] of Object.entries(properties)) {
67
+ const spec = isPlainObject(raw) ? raw : {};
68
+ const title = spec['title'];
69
+ const description = spec['description'];
70
+ declared.push({
71
+ key,
72
+ label: typeof title === 'string' && title.length > 0 ? title : key,
73
+ ...(typeof description === 'string' && description.length > 0
74
+ ? { description }
75
+ : {}),
76
+ });
77
+ }
78
+ const declaredKeys = new Set(declared.map((field) => field.key));
79
+ const extra = payloadKeys
80
+ .filter((key) => !declaredKeys.has(key))
81
+ .map((key) => ({ key, label: key }));
82
+ return [...declared, ...extra];
83
+ }
84
+
85
+ function readValue(payload: unknown, key: string): unknown {
86
+ return isPlainObject(payload) ? payload[key] : payload;
87
+ }
88
+
89
+ function renderGenericSurface({
90
+ displayName,
91
+ payloadSchema,
92
+ payload,
93
+ }: Readonly<{
94
+ displayName: string;
95
+ payloadSchema: Record<string, unknown>;
96
+ payload: unknown;
97
+ }>): ReactElement {
98
+ const fields = deriveGenericSurfaceFields(payloadSchema, payload);
99
+ const rows: readonly GenericSurfaceField[] =
100
+ fields.length > 0 ? fields : [{ key: 'value', label: 'value' }];
101
+ return (
102
+ <div
103
+ style={{
104
+ margin: 9,
105
+ border: '1px solid hsl(var(--rule))',
106
+ borderRadius: 9,
107
+ overflow: 'hidden',
108
+ background: 'hsl(var(--paper-elev))',
109
+ }}
110
+ >
111
+ <div
112
+ style={{
113
+ padding: '7px 11px',
114
+ borderBottom: '1px solid hsl(var(--rule))',
115
+ background: 'hsl(var(--muted))',
116
+ color: 'hsl(var(--ink-3))',
117
+ fontSize: 12,
118
+ fontWeight: 600,
119
+ }}
120
+ >
121
+ {displayName}
122
+ </div>
123
+ <div style={{ padding: '4px 0' }}>
124
+ {rows.map((field) => (
125
+ <div
126
+ key={field.key}
127
+ style={{
128
+ display: 'flex',
129
+ gap: 11,
130
+ padding: '4px 11px',
131
+ fontSize: 12.5,
132
+ }}
133
+ >
134
+ <span style={{ color: 'hsl(var(--ink-4))', minWidth: 128 }}>
135
+ {field.label}
136
+ {field.description !== undefined && (
137
+ <span
138
+ style={{
139
+ display: 'block',
140
+ fontSize: 11,
141
+ color: 'hsl(var(--ink-5, var(--ink-4)))',
142
+ }}
143
+ >
144
+ {field.description}
145
+ </span>
146
+ )}
147
+ </span>
148
+ <span
149
+ style={{ color: 'hsl(var(--ink-2))', wordBreak: 'break-word' }}
150
+ >
151
+ {stringify(
152
+ field.key === 'value' && !isPlainObject(payload)
153
+ ? payload
154
+ : readValue(payload, field.key),
155
+ )}
156
+ </span>
157
+ </div>
158
+ ))}
159
+ </div>
160
+ </div>
161
+ );
162
+ }
163
+
164
+ /**
165
+ * Build a renderer bound to a catalogue entry's `displayName` + `payloadSchema`
166
+ * for a biome surface kind with no dedicated frontend renderer.
167
+ */
168
+ export function makeGenericSurfaceRenderer(
169
+ displayName: string,
170
+ payloadSchema: Record<string, unknown>,
171
+ ): (payload: unknown) => ReactElement {
172
+ // `renderGenericSurface` is a pure presentational function (no hooks); call
173
+ // it directly so the renderer is a plain element factory, not a nested
174
+ // component definition.
175
+ return (payload: unknown) =>
176
+ renderGenericSurface({ displayName, payloadSchema, payload });
177
+ }
@@ -0,0 +1,109 @@
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
+ }