@xemahq/ui-kernel 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/LICENSE +17 -0
  2. package/README.md +72 -0
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +19 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/lib/biome-host/biome-mode.d.ts +2 -0
  8. package/dist/lib/biome-host/biome-mode.d.ts.map +1 -0
  9. package/dist/lib/biome-host/biome-mode.js +3 -0
  10. package/dist/lib/biome-host/biome-mode.js.map +1 -0
  11. package/dist/lib/biome-host/biome-registry.d.ts +30 -0
  12. package/dist/lib/biome-host/biome-registry.d.ts.map +1 -0
  13. package/dist/lib/biome-host/biome-registry.js +134 -0
  14. package/dist/lib/biome-host/biome-registry.js.map +1 -0
  15. package/dist/lib/biome-host/composition-validation.d.ts +22 -0
  16. package/dist/lib/biome-host/composition-validation.d.ts.map +1 -0
  17. package/dist/lib/biome-host/composition-validation.js +127 -0
  18. package/dist/lib/biome-host/composition-validation.js.map +1 -0
  19. package/dist/lib/biome-host/frontend-biome.d.ts +47 -0
  20. package/dist/lib/biome-host/frontend-biome.d.ts.map +1 -0
  21. package/dist/lib/biome-host/frontend-biome.js +3 -0
  22. package/dist/lib/biome-host/frontend-biome.js.map +1 -0
  23. package/dist/lib/biome-host/host-bridge.d.ts +55 -0
  24. package/dist/lib/biome-host/host-bridge.d.ts.map +1 -0
  25. package/dist/lib/biome-host/host-bridge.js +16 -0
  26. package/dist/lib/biome-host/host-bridge.js.map +1 -0
  27. package/dist/lib/biome-host/host-sources.d.ts +12 -0
  28. package/dist/lib/biome-host/host-sources.d.ts.map +1 -0
  29. package/dist/lib/biome-host/host-sources.js +3 -0
  30. package/dist/lib/biome-host/host-sources.js.map +1 -0
  31. package/dist/lib/biome-host/index.d.ts +10 -0
  32. package/dist/lib/biome-host/index.d.ts.map +1 -0
  33. package/dist/lib/biome-host/index.js +26 -0
  34. package/dist/lib/biome-host/index.js.map +1 -0
  35. package/dist/lib/biome-host/nav.d.ts +17 -0
  36. package/dist/lib/biome-host/nav.d.ts.map +1 -0
  37. package/dist/lib/biome-host/nav.js +52 -0
  38. package/dist/lib/biome-host/nav.js.map +1 -0
  39. package/dist/lib/biome-host/session-contributions.d.ts +143 -0
  40. package/dist/lib/biome-host/session-contributions.d.ts.map +1 -0
  41. package/dist/lib/biome-host/session-contributions.js +3 -0
  42. package/dist/lib/biome-host/session-contributions.js.map +1 -0
  43. package/dist/lib/biome-host/session-profiles.d.ts +18 -0
  44. package/dist/lib/biome-host/session-profiles.d.ts.map +1 -0
  45. package/dist/lib/biome-host/session-profiles.js +39 -0
  46. package/dist/lib/biome-host/session-profiles.js.map +1 -0
  47. package/dist/lib/system-bus/capability-invoke.d.ts +18 -0
  48. package/dist/lib/system-bus/capability-invoke.d.ts.map +1 -0
  49. package/dist/lib/system-bus/capability-invoke.js +3 -0
  50. package/dist/lib/system-bus/capability-invoke.js.map +1 -0
  51. package/dist/lib/system-bus/deeplink.d.ts +33 -0
  52. package/dist/lib/system-bus/deeplink.d.ts.map +1 -0
  53. package/dist/lib/system-bus/deeplink.js +99 -0
  54. package/dist/lib/system-bus/deeplink.js.map +1 -0
  55. package/dist/lib/system-bus/enums.d.ts +27 -0
  56. package/dist/lib/system-bus/enums.d.ts.map +1 -0
  57. package/dist/lib/system-bus/enums.js +35 -0
  58. package/dist/lib/system-bus/enums.js.map +1 -0
  59. package/dist/lib/system-bus/host-ports.d.ts +24 -0
  60. package/dist/lib/system-bus/host-ports.d.ts.map +1 -0
  61. package/dist/lib/system-bus/host-ports.js +3 -0
  62. package/dist/lib/system-bus/host-ports.js.map +1 -0
  63. package/dist/lib/system-bus/index.d.ts +11 -0
  64. package/dist/lib/system-bus/index.d.ts.map +1 -0
  65. package/dist/lib/system-bus/index.js +27 -0
  66. package/dist/lib/system-bus/index.js.map +1 -0
  67. package/dist/lib/system-bus/intent-registry.d.ts +14 -0
  68. package/dist/lib/system-bus/intent-registry.d.ts.map +1 -0
  69. package/dist/lib/system-bus/intent-registry.js +66 -0
  70. package/dist/lib/system-bus/intent-registry.js.map +1 -0
  71. package/dist/lib/system-bus/intents.d.ts +30 -0
  72. package/dist/lib/system-bus/intents.d.ts.map +1 -0
  73. package/dist/lib/system-bus/intents.js +3 -0
  74. package/dist/lib/system-bus/intents.js.map +1 -0
  75. package/dist/lib/system-bus/palette.d.ts +25 -0
  76. package/dist/lib/system-bus/palette.d.ts.map +1 -0
  77. package/dist/lib/system-bus/palette.js +3 -0
  78. package/dist/lib/system-bus/palette.js.map +1 -0
  79. package/dist/lib/system-bus/system-bus-builder.d.ts +10 -0
  80. package/dist/lib/system-bus/system-bus-builder.d.ts.map +1 -0
  81. package/dist/lib/system-bus/system-bus-builder.js +82 -0
  82. package/dist/lib/system-bus/system-bus-builder.js.map +1 -0
  83. package/dist/lib/system-bus/system-bus.d.ts +13 -0
  84. package/dist/lib/system-bus/system-bus.d.ts.map +1 -0
  85. package/dist/lib/system-bus/system-bus.js +3 -0
  86. package/dist/lib/system-bus/system-bus.js.map +1 -0
  87. package/dist/lib/system-bus/windows.d.ts +21 -0
  88. package/dist/lib/system-bus/windows.d.ts.map +1 -0
  89. package/dist/lib/system-bus/windows.js +3 -0
  90. package/dist/lib/system-bus/windows.js.map +1 -0
  91. package/dist/org-db/components/DbResultTable.d.ts +13 -0
  92. package/dist/org-db/components/DbResultTable.d.ts.map +1 -0
  93. package/dist/org-db/components/DbResultTable.js +58 -0
  94. package/dist/org-db/components/DbResultTable.js.map +1 -0
  95. package/dist/org-db/index.d.ts +2 -0
  96. package/dist/org-db/index.d.ts.map +1 -0
  97. package/dist/org-db/index.js +6 -0
  98. package/dist/org-db/index.js.map +1 -0
  99. package/dist/registry/index.d.ts +9 -0
  100. package/dist/registry/index.d.ts.map +1 -0
  101. package/dist/registry/index.js +25 -0
  102. package/dist/registry/index.js.map +1 -0
  103. package/dist/registry/lib/biome-slot.d.ts +7 -0
  104. package/dist/registry/lib/biome-slot.d.ts.map +1 -0
  105. package/dist/registry/lib/biome-slot.js +18 -0
  106. package/dist/registry/lib/biome-slot.js.map +1 -0
  107. package/dist/registry/lib/biomes-enabled-context.d.ts +3 -0
  108. package/dist/registry/lib/biomes-enabled-context.d.ts.map +1 -0
  109. package/dist/registry/lib/biomes-enabled-context.js +11 -0
  110. package/dist/registry/lib/biomes-enabled-context.js.map +1 -0
  111. package/dist/registry/lib/composition-validation-host.d.ts +3 -0
  112. package/dist/registry/lib/composition-validation-host.d.ts.map +1 -0
  113. package/dist/registry/lib/composition-validation-host.js +10 -0
  114. package/dist/registry/lib/composition-validation-host.js.map +1 -0
  115. package/dist/registry/lib/extension-points.d.ts +15 -0
  116. package/dist/registry/lib/extension-points.d.ts.map +1 -0
  117. package/dist/registry/lib/extension-points.js +17 -0
  118. package/dist/registry/lib/extension-points.js.map +1 -0
  119. package/dist/registry/lib/primitives/SessionEventCard.d.ts +14 -0
  120. package/dist/registry/lib/primitives/SessionEventCard.d.ts.map +1 -0
  121. package/dist/registry/lib/primitives/SessionEventCard.js +60 -0
  122. package/dist/registry/lib/primitives/SessionEventCard.js.map +1 -0
  123. package/dist/registry/lib/primitives/SessionEventTimeline.d.ts +13 -0
  124. package/dist/registry/lib/primitives/SessionEventTimeline.d.ts.map +1 -0
  125. package/dist/registry/lib/primitives/SessionEventTimeline.js +35 -0
  126. package/dist/registry/lib/primitives/SessionEventTimeline.js.map +1 -0
  127. package/dist/registry/lib/primitives/SessionMutationBar.d.ts +10 -0
  128. package/dist/registry/lib/primitives/SessionMutationBar.d.ts.map +1 -0
  129. package/dist/registry/lib/primitives/SessionMutationBar.js +37 -0
  130. package/dist/registry/lib/primitives/SessionMutationBar.js.map +1 -0
  131. package/dist/registry/lib/primitives/SessionTabbedDrawer.d.ts +19 -0
  132. package/dist/registry/lib/primitives/SessionTabbedDrawer.d.ts.map +1 -0
  133. package/dist/registry/lib/primitives/SessionTabbedDrawer.js +75 -0
  134. package/dist/registry/lib/primitives/SessionTabbedDrawer.js.map +1 -0
  135. package/dist/registry/lib/primitives/index.d.ts +5 -0
  136. package/dist/registry/lib/primitives/index.d.ts.map +1 -0
  137. package/dist/registry/lib/primitives/index.js +21 -0
  138. package/dist/registry/lib/primitives/index.js.map +1 -0
  139. package/dist/registry/lib/session-context-builder.d.ts +13 -0
  140. package/dist/registry/lib/session-context-builder.d.ts.map +1 -0
  141. package/dist/registry/lib/session-context-builder.js +39 -0
  142. package/dist/registry/lib/session-context-builder.js.map +1 -0
  143. package/dist/registry/lib/session-context-provider.d.ts +10 -0
  144. package/dist/registry/lib/session-context-provider.d.ts.map +1 -0
  145. package/dist/registry/lib/session-context-provider.js +24 -0
  146. package/dist/registry/lib/session-context-provider.js.map +1 -0
  147. package/dist/registry/lib/session-selectors.d.ts +9 -0
  148. package/dist/registry/lib/session-selectors.d.ts.map +1 -0
  149. package/dist/registry/lib/session-selectors.js +149 -0
  150. package/dist/registry/lib/session-selectors.js.map +1 -0
  151. package/dist/session/comments/CommentRail.d.ts +20 -0
  152. package/dist/session/comments/CommentRail.d.ts.map +1 -0
  153. package/dist/session/comments/CommentRail.js +16 -0
  154. package/dist/session/comments/CommentRail.js.map +1 -0
  155. package/dist/session/index.d.ts +4 -0
  156. package/dist/session/index.d.ts.map +1 -0
  157. package/dist/session/index.js +10 -0
  158. package/dist/session/index.js.map +1 -0
  159. package/dist/session/lib/cn.d.ts +3 -0
  160. package/dist/session/lib/cn.d.ts.map +1 -0
  161. package/dist/session/lib/cn.js +9 -0
  162. package/dist/session/lib/cn.js.map +1 -0
  163. package/dist/session/shell/SessionWorkspaceShell.d.ts +16 -0
  164. package/dist/session/shell/SessionWorkspaceShell.d.ts.map +1 -0
  165. package/dist/session/shell/SessionWorkspaceShell.js +15 -0
  166. package/dist/session/shell/SessionWorkspaceShell.js.map +1 -0
  167. package/package.json +84 -0
  168. package/src/index.ts +2 -0
  169. package/src/lib/biome-host/biome-mode.ts +6 -0
  170. package/src/lib/biome-host/biome-registry.ts +245 -0
  171. package/src/lib/biome-host/composition-validation.ts +215 -0
  172. package/src/lib/biome-host/frontend-biome.ts +162 -0
  173. package/src/lib/biome-host/host-bridge.ts +178 -0
  174. package/src/lib/biome-host/host-sources.ts +41 -0
  175. package/src/lib/biome-host/index.ts +23 -0
  176. package/src/lib/biome-host/nav.ts +83 -0
  177. package/src/lib/biome-host/session-contributions.ts +293 -0
  178. package/src/lib/biome-host/session-profiles.ts +99 -0
  179. package/src/lib/system-bus/capability-invoke.ts +92 -0
  180. package/src/lib/system-bus/deeplink.ts +200 -0
  181. package/src/lib/system-bus/enums.ts +86 -0
  182. package/src/lib/system-bus/host-ports.ts +96 -0
  183. package/src/lib/system-bus/index.ts +16 -0
  184. package/src/lib/system-bus/intent-registry.ts +106 -0
  185. package/src/lib/system-bus/intents.ts +109 -0
  186. package/src/lib/system-bus/palette.ts +77 -0
  187. package/src/lib/system-bus/system-bus-builder.ts +157 -0
  188. package/src/lib/system-bus/system-bus.ts +37 -0
  189. package/src/lib/system-bus/windows.ts +51 -0
  190. package/src/org-db/components/DbResultTable.tsx +143 -0
  191. package/src/org-db/index.ts +1 -0
  192. package/src/registry/index.ts +8 -0
  193. package/src/registry/lib/biome-slot.tsx +47 -0
  194. package/src/registry/lib/biomes-enabled-context.ts +20 -0
  195. package/src/registry/lib/composition-validation-host.ts +37 -0
  196. package/src/registry/lib/extension-points.ts +134 -0
  197. package/src/registry/lib/primitives/SessionEventCard.tsx +138 -0
  198. package/src/registry/lib/primitives/SessionEventTimeline.tsx +89 -0
  199. package/src/registry/lib/primitives/SessionMutationBar.tsx +76 -0
  200. package/src/registry/lib/primitives/SessionTabbedDrawer.tsx +155 -0
  201. package/src/registry/lib/primitives/index.ts +18 -0
  202. package/src/registry/lib/session-context-builder.ts +68 -0
  203. package/src/registry/lib/session-context-provider.tsx +50 -0
  204. package/src/registry/lib/session-selectors.ts +231 -0
  205. package/src/session/comments/CommentRail.tsx +164 -0
  206. package/src/session/index.ts +3 -0
  207. package/src/session/lib/cn.ts +11 -0
  208. package/src/session/shell/SessionWorkspaceShell.tsx +141 -0
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Generic event-row primitive a biome can use as the rendered form of
3
+ * a `SessionActivityEvent` it owns. Matches the host's built-in
4
+ * console row visually (time gutter + icon chip + title + detail) so
5
+ * biome-rendered events sit inside the host timeline without looking
6
+ * grafted on.
7
+ *
8
+ * Biomes compose this when they register an `ActivityRendererContribution`:
9
+ *
10
+ * render: ({ event }) => (
11
+ * <SessionEventCard
12
+ * time={event.createdAt}
13
+ * icon={<JiraIcon />}
14
+ * title={event.title}
15
+ * detail={event.detail}
16
+ * tone={event.status === 'error' ? 'error' : 'default'}
17
+ * />
18
+ * )
19
+ *
20
+ * Inline-styled with CSS-variable tokens for the same portability
21
+ * reasons as `SessionMutationBar`.
22
+ */
23
+ import { type CSSProperties, type ReactNode, type ReactElement } from 'react';
24
+
25
+ export type SessionEventCardTone = 'default' | 'pending' | 'success' | 'error' | 'info';
26
+
27
+ const TONE_DOT: Record<SessionEventCardTone, string> = {
28
+ default: 'hsl(var(--ink-4, 228 6% 58%))',
29
+ pending: 'hsl(var(--info, 220 70% 50%))',
30
+ success: 'hsl(var(--success, 152 50% 35%))',
31
+ error: 'hsl(var(--destructive, 8 70% 50%))',
32
+ info: 'hsl(var(--info, 220 70% 50%))',
33
+ };
34
+
35
+ const TONE_BG: Record<SessionEventCardTone, string> = {
36
+ default: 'hsl(var(--paper-elev, 0 0% 100%))',
37
+ pending: 'hsl(var(--info, 220 70% 50%) / 0.08)',
38
+ success: 'hsl(var(--success, 152 50% 35%) / 0.08)',
39
+ error: 'hsl(var(--destructive, 8 70% 50%) / 0.10)',
40
+ info: 'hsl(var(--info, 220 70% 50%) / 0.08)',
41
+ };
42
+
43
+ export interface SessionEventCardProps {
44
+ /** ISO timestamp; the primitive renders HH:MM:SS in the gutter. */
45
+ readonly time: string;
46
+ readonly icon?: ReactNode;
47
+ readonly title: ReactNode;
48
+ readonly detail?: ReactNode;
49
+ /** Optional inline body (collapsible content, code block, …). */
50
+ readonly children?: ReactNode;
51
+ readonly tone?: SessionEventCardTone;
52
+ readonly style?: CSSProperties;
53
+ readonly className?: string;
54
+ }
55
+
56
+ function formatTime(iso: string): string {
57
+ const date = new Date(iso);
58
+ if (Number.isNaN(date.getTime())) return '—';
59
+ return date.toLocaleTimeString([], {
60
+ hour: '2-digit',
61
+ minute: '2-digit',
62
+ second: '2-digit',
63
+ });
64
+ }
65
+
66
+ export function SessionEventCard({
67
+ time,
68
+ icon,
69
+ title,
70
+ detail,
71
+ children,
72
+ tone = 'default',
73
+ style,
74
+ className,
75
+ }: SessionEventCardProps): ReactElement {
76
+ return (
77
+ <div
78
+ className={className}
79
+ style={{
80
+ display: 'flex',
81
+ gap: 10,
82
+ padding: '4px 8px',
83
+ borderRadius: 6,
84
+ fontSize: 12,
85
+ ...style,
86
+ }}
87
+ >
88
+ <span
89
+ style={{
90
+ width: 56,
91
+ flexShrink: 0,
92
+ fontFamily: 'var(--font-mono, ui-monospace, monospace)',
93
+ fontSize: 11,
94
+ color: 'hsl(var(--ink-4, 228 6% 58%))',
95
+ fontVariantNumeric: 'tabular-nums',
96
+ }}
97
+ >
98
+ {formatTime(time)}
99
+ </span>
100
+ <div
101
+ style={{
102
+ width: 20,
103
+ height: 20,
104
+ flexShrink: 0,
105
+ display: 'flex',
106
+ alignItems: 'center',
107
+ justifyContent: 'center',
108
+ borderRadius: 4,
109
+ background: TONE_BG[tone],
110
+ }}
111
+ >
112
+ {icon ?? (
113
+ <span
114
+ style={{
115
+ width: 6,
116
+ height: 6,
117
+ borderRadius: '50%',
118
+ background: TONE_DOT[tone],
119
+ }}
120
+ />
121
+ )}
122
+ </div>
123
+ <div style={{ minWidth: 0, flex: 1 }}>
124
+ <div style={{ display: 'flex', gap: 6, alignItems: 'baseline', flexWrap: 'wrap' }}>
125
+ <span style={{ color: 'hsl(var(--ink, 228 14% 11%))', wordBreak: 'break-word' }}>
126
+ {title}
127
+ </span>
128
+ {detail != null && (
129
+ <span style={{ color: 'hsl(var(--ink-3, 228 6% 40%))', wordBreak: 'break-word' }}>
130
+ {detail}
131
+ </span>
132
+ )}
133
+ </div>
134
+ {children != null && <div style={{ marginTop: 4 }}>{children}</div>}
135
+ </div>
136
+ </div>
137
+ );
138
+ }
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Generic event timeline a biome can use to render a stream of its
3
+ * own events inside a custom surface — e.g. a "Deploys" panel that
4
+ * lists deploy attempts the same way the session console lists tool
5
+ * calls. Biomes keep ownership of the data model; this primitive
6
+ * supplies the scroll behaviour, auto-stick-to-bottom, and consistent
7
+ * spacing.
8
+ *
9
+ * The primitive does NOT subscribe to the biome registry or any SSE
10
+ * stream — callers pass in an items array. Auto-scroll-to-latest
11
+ * fires only when the user is already pinned to the bottom; if they
12
+ * scrolled up to read history we stay parked so live events don't
13
+ * yank context away.
14
+ */
15
+ import {
16
+ type CSSProperties,
17
+ type ReactElement,
18
+ type ReactNode,
19
+ useEffect,
20
+ useLayoutEffect,
21
+ useRef,
22
+ useState,
23
+ } from 'react';
24
+
25
+ export interface SessionEventTimelineProps<TItem> {
26
+ readonly items: readonly TItem[];
27
+ readonly getKey: (item: TItem) => string;
28
+ readonly renderItem: (item: TItem) => ReactNode;
29
+ /** Banner above the list (e.g. "stream recovering…"). */
30
+ readonly banner?: ReactNode;
31
+ /** Empty state when `items.length === 0`. */
32
+ readonly empty?: ReactNode;
33
+ /** Pixel threshold for "pinned to bottom" detection. Default 32. */
34
+ readonly stickThreshold?: number;
35
+ readonly style?: CSSProperties;
36
+ readonly className?: string;
37
+ }
38
+
39
+ export function SessionEventTimeline<TItem>({
40
+ items,
41
+ getKey,
42
+ renderItem,
43
+ banner,
44
+ empty,
45
+ stickThreshold = 32,
46
+ style,
47
+ className,
48
+ }: SessionEventTimelineProps<TItem>): ReactElement {
49
+ const scrollRef = useRef<HTMLDivElement>(null);
50
+ const [stuckToBottom, setStuckToBottom] = useState(true);
51
+
52
+ useEffect(() => {
53
+ const node = scrollRef.current;
54
+ if (!node) return;
55
+ const handler = () => {
56
+ const distanceFromBottom =
57
+ node.scrollHeight - node.scrollTop - node.clientHeight;
58
+ setStuckToBottom(distanceFromBottom < stickThreshold);
59
+ };
60
+ node.addEventListener('scroll', handler, { passive: true });
61
+ return () => node.removeEventListener('scroll', handler);
62
+ }, [stickThreshold]);
63
+
64
+ useLayoutEffect(() => {
65
+ if (!stuckToBottom) return;
66
+ const node = scrollRef.current;
67
+ if (!node) return;
68
+ node.scrollTop = node.scrollHeight;
69
+ }, [items, stuckToBottom]);
70
+
71
+ return (
72
+ <div
73
+ ref={scrollRef}
74
+ className={className}
75
+ style={{
76
+ height: '100%',
77
+ overflowY: 'auto',
78
+ padding: '8px 4px',
79
+ ...style,
80
+ }}
81
+ >
82
+ {banner}
83
+ {items.length === 0 && empty}
84
+ {items.map((item) => (
85
+ <div key={getKey(item)}>{renderItem(item)}</div>
86
+ ))}
87
+ </div>
88
+ );
89
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Generic sticky strip a biome can use as a session-level status row
3
+ * (linked Jira ticket, AWS deploy state, git branch, …). Wraps the
4
+ * biome's content in the host's editorial chrome — rule border,
5
+ * paper-elev background, consistent padding — so bars contributed by
6
+ * different biomes look like one product surface even when authored
7
+ * independently.
8
+ *
9
+ * The primitive is intentionally style-agnostic at the JS layer: it
10
+ * inlines CSS-variable references so it works against any host whose
11
+ * design system publishes `--paper-elev` / `--rule` / `--ink` on
12
+ * `:root`. Tailwind classes are NOT used because biomes must work
13
+ * across hosts whose CSS pipelines differ.
14
+ */
15
+ import { type CSSProperties, type ReactNode, type ReactElement } from 'react';
16
+
17
+ export type SessionMutationBarTone = 'default' | 'accent' | 'warning' | 'destructive';
18
+
19
+ const TONE_STYLES: Record<SessionMutationBarTone, CSSProperties> = {
20
+ default: {
21
+ background: 'hsl(var(--paper-elev, 0 0% 100%))',
22
+ borderBottom: '1px solid hsl(var(--rule, 40 14% 86%))',
23
+ },
24
+ accent: {
25
+ background: 'hsl(var(--accent-tint, 230 50% 96%))',
26
+ borderBottom: '1px solid hsl(var(--rule, 40 14% 86%))',
27
+ color: 'hsl(var(--accent-ink, 230 50% 30%))',
28
+ },
29
+ warning: {
30
+ background: 'hsl(var(--warning, 32 80% 50%) / 0.10)',
31
+ borderBottom: '1px solid hsl(var(--warning, 32 80% 50%) / 0.30)',
32
+ color: 'hsl(var(--ink, 228 14% 11%))',
33
+ },
34
+ destructive: {
35
+ background: 'hsl(var(--destructive, 8 70% 50%) / 0.10)',
36
+ borderBottom: '1px solid hsl(var(--destructive, 8 70% 50%) / 0.30)',
37
+ color: 'hsl(var(--ink, 228 14% 11%))',
38
+ },
39
+ };
40
+
41
+ export interface SessionMutationBarProps {
42
+ readonly tone?: SessionMutationBarTone;
43
+ readonly children: ReactNode;
44
+ /**
45
+ * Extra inline styles merged on top of the tone styles. Use for one-off
46
+ * sizing tweaks; do not override `background` or `borderBottom` here
47
+ * because that defeats the visual-consistency point of the primitive.
48
+ */
49
+ readonly style?: CSSProperties;
50
+ /** Optional className passthrough for hosts that DO use Tailwind. */
51
+ readonly className?: string;
52
+ }
53
+
54
+ export function SessionMutationBar({
55
+ tone = 'default',
56
+ children,
57
+ style,
58
+ className,
59
+ }: SessionMutationBarProps): ReactElement {
60
+ return (
61
+ <div
62
+ className={className}
63
+ style={{
64
+ ...TONE_STYLES[tone],
65
+ padding: '6px 12px',
66
+ fontSize: 13,
67
+ display: 'flex',
68
+ alignItems: 'center',
69
+ gap: 8,
70
+ ...style,
71
+ }}
72
+ >
73
+ {children}
74
+ </div>
75
+ );
76
+ }
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Generic tabbed drawer primitive a biome can use to build its own
3
+ * inspector surface — same shape as the host's session secondary
4
+ * drawer (tab strip across the top, switch-bodies below). Biome
5
+ * authors compose this when their biome owns a side surface that
6
+ * isn't part of the canonical session drawer.
7
+ *
8
+ * Headless on purpose: this primitive does NOT own a Dialog wrapper.
9
+ * Biomes decide whether to mount it inside their own dialog, a
10
+ * resizable panel, or inline — the only behaviour the primitive
11
+ * guarantees is "render exactly one tab body at a time, with a
12
+ * shared tab strip and keyboard navigation".
13
+ */
14
+ import {
15
+ type CSSProperties,
16
+ type ReactElement,
17
+ type ReactNode,
18
+ useEffect,
19
+ useMemo,
20
+ useState,
21
+ } from 'react';
22
+
23
+ export interface SessionTabbedDrawerTab {
24
+ readonly id: string;
25
+ readonly label: ReactNode;
26
+ readonly icon?: ReactNode;
27
+ readonly badge?: ReactNode;
28
+ readonly render: () => ReactNode;
29
+ }
30
+
31
+ export interface SessionTabbedDrawerProps {
32
+ readonly tabs: readonly SessionTabbedDrawerTab[];
33
+ readonly initialTabId?: string;
34
+ readonly activeTabId?: string;
35
+ readonly onActiveTabChange?: (id: string) => void;
36
+ /**
37
+ * When true, ⌘1..⌘N / Ctrl+1..N selects the corresponding tab while
38
+ * the drawer is mounted. Defaults to true.
39
+ */
40
+ readonly enableKeyboardShortcuts?: boolean;
41
+ readonly style?: CSSProperties;
42
+ readonly className?: string;
43
+ }
44
+
45
+ export function SessionTabbedDrawer({
46
+ tabs,
47
+ initialTabId,
48
+ activeTabId,
49
+ onActiveTabChange,
50
+ enableKeyboardShortcuts = true,
51
+ style,
52
+ className,
53
+ }: SessionTabbedDrawerProps): ReactElement {
54
+ const fallbackTabId = initialTabId ?? tabs[0]?.id ?? '';
55
+ const [internalActive, setInternalActive] = useState<string>(fallbackTabId);
56
+ const effectiveActive = activeTabId ?? internalActive;
57
+
58
+ const select = useMemo(() => {
59
+ return (id: string) => {
60
+ if (activeTabId === undefined) setInternalActive(id);
61
+ onActiveTabChange?.(id);
62
+ };
63
+ }, [activeTabId, onActiveTabChange]);
64
+
65
+ useEffect(() => {
66
+ if (!enableKeyboardShortcuts) return;
67
+ const handler = (event: KeyboardEvent) => {
68
+ if (!(event.metaKey || event.ctrlKey)) return;
69
+ const idx = Number.parseInt(event.key, 10);
70
+ if (Number.isNaN(idx) || idx < 1 || idx > tabs.length) return;
71
+ const target = tabs[idx - 1];
72
+ if (!target) return;
73
+ event.preventDefault();
74
+ select(target.id);
75
+ };
76
+ window.addEventListener('keydown', handler);
77
+ return () => window.removeEventListener('keydown', handler);
78
+ }, [enableKeyboardShortcuts, tabs, select]);
79
+
80
+ const active = tabs.find((tab) => tab.id === effectiveActive) ?? tabs[0];
81
+
82
+ return (
83
+ <div
84
+ className={className}
85
+ style={{
86
+ display: 'flex',
87
+ flexDirection: 'column',
88
+ height: '100%',
89
+ minHeight: 0,
90
+ ...style,
91
+ }}
92
+ >
93
+ <div
94
+ role="tablist"
95
+ style={{
96
+ display: 'flex',
97
+ alignItems: 'center',
98
+ gap: 4,
99
+ padding: '8px 16px 0',
100
+ borderBottom: '1px solid hsl(var(--rule, 40 14% 86%))',
101
+ overflowX: 'auto',
102
+ }}
103
+ >
104
+ {tabs.map((tab, idx) => {
105
+ const isActive = tab.id === active?.id;
106
+ return (
107
+ <button
108
+ key={tab.id}
109
+ type="button"
110
+ role="tab"
111
+ aria-selected={isActive}
112
+ onClick={() => select(tab.id)}
113
+ title={`${typeof tab.label === 'string' ? tab.label : 'Tab'} (⌘${idx + 1})`}
114
+ style={{
115
+ position: 'relative',
116
+ display: 'inline-flex',
117
+ alignItems: 'center',
118
+ gap: 6,
119
+ padding: '8px 12px',
120
+ fontSize: 13,
121
+ background: 'transparent',
122
+ border: 'none',
123
+ cursor: 'pointer',
124
+ color: isActive
125
+ ? 'hsl(var(--ink, 228 14% 11%))'
126
+ : 'hsl(var(--ink-3, 228 6% 40%))',
127
+ whiteSpace: 'nowrap',
128
+ }}
129
+ >
130
+ {tab.icon}
131
+ {tab.label}
132
+ {tab.badge}
133
+ {isActive && (
134
+ <span
135
+ aria-hidden
136
+ style={{
137
+ position: 'absolute',
138
+ inset: '0 4px -1px',
139
+ top: 'auto',
140
+ height: 2,
141
+ background: 'hsl(var(--primary, 230 50% 45%))',
142
+ borderRadius: 1,
143
+ }}
144
+ />
145
+ )}
146
+ </button>
147
+ );
148
+ })}
149
+ </div>
150
+ <div style={{ flex: 1, minHeight: 0, overflow: 'auto' }}>
151
+ {active?.render()}
152
+ </div>
153
+ </div>
154
+ );
155
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Reusable session-shell primitives exported from the SDK so biome
3
+ * authors can compose the same UI vocabulary the host shell uses —
4
+ * mutation bars, event cards, event timelines, tabbed drawers —
5
+ * without forking the host or rebuilding the editorial chrome from
6
+ * scratch.
7
+ *
8
+ * Every primitive in this directory:
9
+ * - Is style-portable (inline styles + CSS-variable tokens; no
10
+ * Tailwind dependency).
11
+ * - Has zero registry subscriptions (biomes pass data in).
12
+ * - Composes with the host's session shell as well as with a
13
+ * biome's own bespoke surfaces.
14
+ */
15
+ export * from './SessionEventCard';
16
+ export * from './SessionEventTimeline';
17
+ export * from './SessionMutationBar';
18
+ export * from './SessionTabbedDrawer';
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Single helper hook the host's session shell calls once per render to
3
+ * build the `SessionContext` it passes into every contribution selector.
4
+ *
5
+ * Inputs are the loose, host-shaped session fields (any DTO with these
6
+ * keys); the helper resolves the profile descriptor through the biome
7
+ * registry, frozes a capabilities set, and returns a stable
8
+ * `SessionContext`. Memoised by the underlying selectors — callers can
9
+ * pass the result as a dep without worrying about identity churn.
10
+ *
11
+ * Keeping this helper in the SDK (rather than the host) is what lets
12
+ * biomes also build a context — e.g. from inside a slash command
13
+ * handler that wants to gate behaviour against capabilities.
14
+ */
15
+ import { useMemo } from 'react';
16
+
17
+ import {
18
+ type SessionContext,
19
+ useSessionProfileDescriptor,
20
+ } from '../../index';
21
+
22
+ export interface BuildSessionContextInput {
23
+ readonly sessionId: string;
24
+ readonly orgId: string;
25
+ readonly projectId: string;
26
+ readonly biomeId?: string;
27
+ readonly profileKey?: string;
28
+ readonly status: string;
29
+ readonly isActive: boolean;
30
+ }
31
+
32
+ const TERMINAL_STATUSES = new Set([
33
+ 'paused',
34
+ 'completed',
35
+ 'cancelled',
36
+ 'failed',
37
+ 'terminated',
38
+ ]);
39
+
40
+ export function isStatusActive(status: string): boolean {
41
+ return !TERMINAL_STATUSES.has(status);
42
+ }
43
+
44
+ export function useSessionContext(input: BuildSessionContextInput): SessionContext {
45
+ const descriptor = useSessionProfileDescriptor(input.biomeId, input.profileKey);
46
+ return useMemo<SessionContext>(
47
+ () => ({
48
+ sessionId: input.sessionId,
49
+ orgId: input.orgId,
50
+ projectId: input.projectId,
51
+ biomeId: input.biomeId ?? descriptor.biomeId,
52
+ profileKey: input.profileKey ?? descriptor.key,
53
+ status: input.status,
54
+ capabilities: Object.freeze(new Set(descriptor.capabilities)),
55
+ isActive: input.isActive,
56
+ }),
57
+ [
58
+ input.sessionId,
59
+ input.orgId,
60
+ input.projectId,
61
+ input.biomeId,
62
+ input.profileKey,
63
+ input.status,
64
+ input.isActive,
65
+ descriptor,
66
+ ],
67
+ );
68
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * React context that publishes the current `SessionContext` to every
3
+ * descendant. The host's session shell mounts the provider once around
4
+ * the entire session page; biome-rendered slot panels and host
5
+ * primitives both read the context via `useCurrentSessionContext()`
6
+ * (throws fail-fast if no provider is mounted, since reading the
7
+ * context outside a session view is a wiring bug).
8
+ *
9
+ * Keeping this in the SDK rather than the host gives biome authors a
10
+ * stable, importable hook — `import { useCurrentSessionContext } from
11
+ * '@xemahq/ui-kernel/registry'`.
12
+ */
13
+ import { type ReactNode, type ReactElement, createContext, useContext } from 'react';
14
+
15
+ import type { SessionContext } from '../../index';
16
+
17
+ const Ctx = createContext<SessionContext | null>(null);
18
+ Ctx.displayName = 'SessionContext';
19
+
20
+ export interface SessionContextProviderProps {
21
+ readonly value: SessionContext;
22
+ readonly children: ReactNode;
23
+ }
24
+
25
+ export function SessionContextProvider({
26
+ value,
27
+ children,
28
+ }: SessionContextProviderProps): ReactElement {
29
+ return <Ctx.Provider value={value}>{children}</Ctx.Provider>;
30
+ }
31
+
32
+ export function useCurrentSessionContext(): SessionContext {
33
+ const ctx = useContext(Ctx);
34
+ if (!ctx) {
35
+ throw new Error(
36
+ '[biome-registry-web] useCurrentSessionContext() called outside <SessionContextProvider>. ' +
37
+ 'The host shell must wrap session UI with the provider before any biome reads it.',
38
+ );
39
+ }
40
+ return ctx;
41
+ }
42
+
43
+ /**
44
+ * Non-throwing variant for components that may render outside a session
45
+ * context (e.g. shared primitives reused on the design-system-builder page).
46
+ * Returns `null` instead of throwing.
47
+ */
48
+ export function useOptionalSessionContext(): SessionContext | null {
49
+ return useContext(Ctx);
50
+ }