@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.
- package/dist/ui/chrome/page-shell.d.ts +1 -1
- package/dist/ui/chrome/page-shell.d.ts.map +1 -1
- package/dist/ui/chrome/page-shell.js +9 -4
- package/dist/ui/chrome/page-shell.js.map +1 -1
- package/package.json +6 -4
- package/src/index.ts +0 -17
- package/src/lib/biome-host/agent-validation.ts +0 -239
- package/src/lib/biome-host/biome-builders.ts +0 -112
- package/src/lib/biome-host/biome-mode.ts +0 -6
- package/src/lib/biome-host/biome-navigation.ts +0 -37
- package/src/lib/biome-host/biome-registry.ts +0 -299
- package/src/lib/biome-host/biome-scope-hooks.ts +0 -41
- package/src/lib/biome-host/biome-scope.tsx +0 -52
- package/src/lib/biome-host/biome-scoped-query.ts +0 -134
- package/src/lib/biome-host/create-biome-orval-config.ts +0 -82
- package/src/lib/biome-host/define-web-biome.spec.ts +0 -221
- package/src/lib/biome-host/define-web-biome.ts +0 -222
- package/src/lib/biome-host/errors.ts +0 -220
- package/src/lib/biome-host/frontend-biome.ts +0 -256
- package/src/lib/biome-host/host-bridge.ts +0 -281
- package/src/lib/biome-host/host-sources.ts +0 -54
- package/src/lib/biome-host/i18n-hooks.ts +0 -51
- package/src/lib/biome-host/i18n-port.test.ts +0 -50
- package/src/lib/biome-host/i18n-port.ts +0 -96
- package/src/lib/biome-host/index.ts +0 -35
- package/src/lib/biome-host/realtime-hooks.ts +0 -75
- package/src/lib/biome-host/realtime-port.ts +0 -115
- package/src/lib/biome-host/session-contributions.ts +0 -296
- package/src/lib/biome-host/use-mutation-with-error-toast.ts +0 -90
- package/src/lib/biome-host/use-page-state.ts +0 -248
- package/src/lib/capabilities/capability-context.ts +0 -25
- package/src/lib/capabilities/capability-provider.tsx +0 -73
- package/src/lib/capabilities/index.ts +0 -17
- package/src/lib/capabilities/types.ts +0 -69
- package/src/lib/capabilities/use-capability.ts +0 -79
- package/src/lib/contribution-registry/contribution-registry.spec.ts +0 -141
- package/src/lib/contribution-registry/contribution-registry.ts +0 -204
- package/src/lib/contribution-registry/index.ts +0 -9
- package/src/lib/contribution-registry/renderable-registry.ts +0 -142
- package/src/lib/system-bus/capability-invoke.ts +0 -92
- package/src/lib/system-bus/deeplink.ts +0 -210
- package/src/lib/system-bus/enums.ts +0 -86
- package/src/lib/system-bus/host-ports.ts +0 -93
- package/src/lib/system-bus/index.ts +0 -16
- package/src/lib/system-bus/intent-registry.ts +0 -109
- package/src/lib/system-bus/intents.ts +0 -113
- package/src/lib/system-bus/palette.ts +0 -78
- package/src/lib/system-bus/system-bus-builder.ts +0 -159
- package/src/lib/system-bus/system-bus.ts +0 -37
- package/src/lib/system-bus/windows.ts +0 -51
- package/src/offline/id.ts +0 -16
- package/src/offline/index.ts +0 -54
- package/src/offline/mutation.ts +0 -75
- package/src/offline/offline-status-badge.tsx +0 -51
- package/src/offline/online-controller.ts +0 -105
- package/src/offline/outbox.test.ts +0 -172
- package/src/offline/outbox.ts +0 -348
- package/src/offline/react-hooks.ts +0 -40
- package/src/offline/react.tsx +0 -32
- package/src/offline/storage.ts +0 -112
- package/src/offline/types.ts +0 -77
- package/src/org-db/components/DbResultTable.tsx +0 -176
- package/src/org-db/index.ts +0 -1
- package/src/pdf/index.ts +0 -11
- package/src/registry/index.ts +0 -9
- package/src/registry/lib/agent-validation-host.ts +0 -36
- package/src/registry/lib/biome-slot.tsx +0 -50
- package/src/registry/lib/biomes-enabled-context.ts +0 -20
- package/src/registry/lib/extension-points.ts +0 -134
- package/src/registry/lib/primitives/SessionEventCard.tsx +0 -164
- package/src/registry/lib/primitives/SessionEventTimeline.tsx +0 -95
- package/src/registry/lib/primitives/SessionMutationBar.tsx +0 -76
- package/src/registry/lib/primitives/SessionTabbedDrawer.tsx +0 -165
- package/src/registry/lib/primitives/index.ts +0 -18
- package/src/registry/lib/session-context-builder.ts +0 -84
- package/src/registry/lib/session-context-provider.tsx +0 -33
- package/src/registry/lib/session-context.ts +0 -21
- package/src/registry/lib/session-selectors.ts +0 -272
- package/src/session/comments/CommentRail.tsx +0 -164
- package/src/session/index.ts +0 -3
- package/src/session/lib/cn.ts +0 -11
- package/src/session/shell/SessionWorkspaceShell.tsx +0 -147
- package/src/session-kit/approvals/ApprovalButton.tsx +0 -89
- package/src/session-kit/approvals/ApprovalCard.tsx +0 -341
- package/src/session-kit/approvals/ApprovalsCenter.tsx +0 -336
- package/src/session-kit/approvals/CapabilityApprovalStickyBar.tsx +0 -118
- package/src/session-kit/approvals/Obligation.tsx +0 -111
- package/src/session-kit/approvals/ScopedBody.tsx +0 -392
- package/src/session-kit/approvals/approval-icons.ts +0 -31
- package/src/session-kit/approvals/approval-model.ts +0 -204
- package/src/session-kit/approvals/index.ts +0 -22
- package/src/session-kit/approvals/obligation-display.ts +0 -100
- package/src/session-kit/approvals/risk-accent.ts +0 -47
- package/src/session-kit/approvals/scope-icons.ts +0 -19
- package/src/session-kit/combobox/Combobox.tsx +0 -358
- package/src/session-kit/combobox/use-click-outside.ts +0 -21
- package/src/session-kit/display/ContextHeader.tsx +0 -148
- package/src/session-kit/display/FileDiffCard.tsx +0 -140
- package/src/session-kit/display/MD.tsx +0 -162
- package/src/session-kit/display/MessageTurn.tsx +0 -157
- package/src/session-kit/display/ThinkingPanel.tsx +0 -81
- package/src/session-kit/display/TodoChecklist.tsx +0 -120
- package/src/session-kit/display/TokenMeter.tsx +0 -89
- package/src/session-kit/display/ToolStrip.tsx +0 -278
- package/src/session-kit/display/TypingDots.tsx +0 -24
- package/src/session-kit/index.ts +0 -44
- package/src/session-kit/lib/enums.ts +0 -66
- package/src/session-kit/lib/portal-accent.ts +0 -30
- package/src/session-kit/lib/status-dot.ts +0 -68
- package/src/session-kit/primitives/Avatar.tsx +0 -44
- package/src/session-kit/primitives/PortalGlyph.tsx +0 -51
- package/src/session-kit/primitives/RiskPill.tsx +0 -95
- package/src/session-kit/primitives/ScopeDot.tsx +0 -47
- package/src/session-kit/primitives/Segmented.tsx +0 -71
- package/src/ui/branding/app-branding-context.ts +0 -20
- package/src/ui/branding/app-branding-provider.tsx +0 -123
- package/src/ui/branding/sanitize.ts +0 -89
- package/src/ui/breakpoints.ts +0 -14
- package/src/ui/capture/document-preview.tsx +0 -166
- package/src/ui/capture/field-spec-to-zod.test.ts +0 -81
- package/src/ui/capture/field-spec-to-zod.ts +0 -174
- package/src/ui/capture/field-spec-validate.ts +0 -236
- package/src/ui/capture/field-spec.test.ts +0 -49
- package/src/ui/capture/field-spec.ts +0 -274
- package/src/ui/capture/index.ts +0 -51
- package/src/ui/capture/schema-field-input.tsx +0 -620
- package/src/ui/capture/schema-form.tsx +0 -149
- package/src/ui/capture/submit-values.test.ts +0 -70
- package/src/ui/capture/submit-values.ts +0 -63
- package/src/ui/capture/use-prefill.ts +0 -186
- package/src/ui/capture/use-schema-validation.ts +0 -145
- package/src/ui/capture/use-wizard.ts +0 -180
- package/src/ui/capture/value-format.ts +0 -32
- package/src/ui/capture/wizard.tsx +0 -105
- package/src/ui/charts/bar-chart.tsx +0 -139
- package/src/ui/charts/chart-frame.tsx +0 -125
- package/src/ui/charts/chart-types.ts +0 -52
- package/src/ui/charts/chart-utils.ts +0 -190
- package/src/ui/charts/charts.test.tsx +0 -204
- package/src/ui/charts/donut-chart.tsx +0 -129
- package/src/ui/charts/index.ts +0 -27
- package/src/ui/charts/line-chart.tsx +0 -202
- package/src/ui/charts/sparkline.tsx +0 -109
- package/src/ui/chrome/AsyncBoundary.tsx +0 -74
- package/src/ui/chrome/EmptyState.tsx +0 -257
- package/src/ui/chrome/ErrorCard.tsx +0 -63
- package/src/ui/chrome/LoadingState.tsx +0 -61
- package/src/ui/chrome/PageHeader.tsx +0 -137
- package/src/ui/chrome/RecordCardList.tsx +0 -98
- package/src/ui/chrome/StateCard.tsx +0 -150
- package/src/ui/chrome/confirm-delete-dialog.tsx +0 -59
- package/src/ui/chrome/page-shell.tsx +0 -189
- package/src/ui/chrome/scope-badge.tsx +0 -40
- package/src/ui/chrome/status-badge.tsx +0 -79
- package/src/ui/cn.ts +0 -32
- package/src/ui/design-tokens.ts +0 -372
- package/src/ui/hooks/use-debounced-value.ts +0 -16
- package/src/ui/hooks/use-is-mobile.ts +0 -28
- package/src/ui/index.ts +0 -110
- package/src/ui/pdf/pdf-preview.tsx +0 -122
- package/src/ui/primitives/alert-dialog.tsx +0 -104
- package/src/ui/primitives/async-combobox.tsx +0 -182
- package/src/ui/primitives/badge-variants.ts +0 -21
- package/src/ui/primitives/badge.tsx +0 -25
- package/src/ui/primitives/button-variants.ts +0 -31
- package/src/ui/primitives/button.tsx +0 -29
- package/src/ui/primitives/card.tsx +0 -43
- package/src/ui/primitives/checkbox.tsx +0 -26
- package/src/ui/primitives/collapsible.tsx +0 -9
- package/src/ui/primitives/dialog.tsx +0 -103
- package/src/ui/primitives/dropdown-menu.tsx +0 -179
- package/src/ui/primitives/form-stepper.tsx +0 -94
- package/src/ui/primitives/form-stepper.types.ts +0 -15
- package/src/ui/primitives/input.tsx +0 -22
- package/src/ui/primitives/label.tsx +0 -17
- package/src/ui/primitives/overflow-tabs.tsx +0 -331
- package/src/ui/primitives/popover.tsx +0 -33
- package/src/ui/primitives/preview-device-frame.tsx +0 -213
- package/src/ui/primitives/radio-group.tsx +0 -36
- package/src/ui/primitives/resizable.tsx +0 -67
- package/src/ui/primitives/scroll-area.tsx +0 -38
- package/src/ui/primitives/select.tsx +0 -143
- package/src/ui/primitives/separator.tsx +0 -20
- package/src/ui/primitives/sheet.tsx +0 -107
- package/src/ui/primitives/skeleton.tsx +0 -99
- package/src/ui/primitives/switch.tsx +0 -27
- package/src/ui/primitives/table.tsx +0 -72
- package/src/ui/primitives/tabs.tsx +0 -53
- package/src/ui/primitives/tag-multi-select.tsx +0 -261
- package/src/ui/primitives/textarea.tsx +0 -21
- package/src/ui/primitives/tooltip.tsx +0 -30
- package/src/ui/primitives/url-preview-chrome.tsx +0 -103
- package/src/vista/GenericCatalogueSurface.tsx +0 -179
- package/src/vista/SurfaceFallbackCard.tsx +0 -109
- package/src/vista/VistaPanel.tsx +0 -163
- package/src/vista/form-payload.spec.ts +0 -139
- package/src/vista/html/CustomUiFrame.spec.tsx +0 -127
- package/src/vista/html/CustomUiFrame.tsx +0 -206
- package/src/vista/html/custom-ui-frame-bridge.spec.ts +0 -191
- package/src/vista/html/custom-ui-frame-bridge.ts +0 -98
- package/src/vista/html/custom-ui-frame-contract.ts +0 -88
- package/src/vista/html/custom-ui-intents.spec.ts +0 -135
- package/src/vista/html/custom-ui-intents.ts +0 -155
- package/src/vista/html/custom-ui-srcdoc.spec.ts +0 -151
- package/src/vista/html/custom-ui-srcdoc.ts +0 -193
- package/src/vista/html/index.ts +0 -13
- package/src/vista/index.ts +0 -52
- package/src/vista/surface-catalogue.spec.ts +0 -140
- package/src/vista/surface-catalogue.ts +0 -90
- package/src/vista/surface-icons.ts +0 -57
- package/src/vista/surface-registry.ts +0 -56
- package/src/vista/surfaces/ChartSurface.tsx +0 -34
- package/src/vista/surfaces/FilesSurface.tsx +0 -202
- package/src/vista/surfaces/FormSurface.tsx +0 -380
- package/src/vista/surfaces/HtmlSurface.tsx +0 -43
- package/src/vista/surfaces/TableSurface.tsx +0 -100
- package/src/vista/surfaces/UrlSurface.tsx +0 -40
- package/src/vista/surfaces/blob-surfaces.tsx +0 -139
- package/src/vista/surfaces/elicitation-transport.spec.ts +0 -369
- package/src/vista/surfaces/elicitation-transport.ts +0 -367
- package/src/vista/surfaces/file-surface-utils.ts +0 -69
- package/src/vista/surfaces/index.ts +0 -24
- package/src/vista/surfaces/register-surfaces.tsx +0 -139
- package/src/vista/surfaces/text-surfaces.tsx +0 -132
- package/src/vista/use-vista-tabs.ts +0 -196
- package/src/vista/vista-code-renderer-context.ts +0 -16
- package/src/vista/vista-code-renderer.tsx +0 -35
- package/src/vista/vista-file-context.ts +0 -14
- package/src/vista/vista-file-source.tsx +0 -141
- package/src/vista/vista-form-context.ts +0 -20
- package/src/vista/vista-form-host.tsx +0 -48
- package/src/vista/vista-model.ts +0 -137
- package/src/vista/vista-open-context.tsx +0 -27
- package/src/vista/vista-open-state.ts +0 -11
- package/src/vista/vista-payloads.ts +0 -635
- package/src/vista/vista-tabs-manifest.ts +0 -138
- package/src/vista/vista-tools.ts +0 -232
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The text-bodied first-party surfaces: `code`, `json`, `diff`.
|
|
3
|
-
*
|
|
4
|
-
* Each accepts an inline `content` or a workspace `path` resolved through the
|
|
5
|
-
* host {@link VistaFileSource}, so a panel can open a file lazily without the
|
|
6
|
-
* kernel knowing anything about the host's file endpoints.
|
|
7
|
-
*
|
|
8
|
-
* `code` is a mono pane — it is also where a plain-text file lands (the legacy
|
|
9
|
-
* `plain` tab kind was collapsed into it; one kind, one renderer, no alias).
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { useVistaCodeRenderer } from '../vista-code-renderer-context';
|
|
13
|
-
import { VistaFileText } from '../vista-file-source';
|
|
14
|
-
|
|
15
|
-
import type { VistaTextPayload } from '../vista-payloads';
|
|
16
|
-
import type { ReactElement, ReactNode } from 'react';
|
|
17
|
-
|
|
18
|
-
const PANE_STYLE = {
|
|
19
|
-
height: '100%',
|
|
20
|
-
width: '100%',
|
|
21
|
-
margin: 0,
|
|
22
|
-
overflow: 'auto',
|
|
23
|
-
padding: '14px 16px',
|
|
24
|
-
fontSize: 12,
|
|
25
|
-
lineHeight: 1.6,
|
|
26
|
-
color: 'hsl(var(--ink-2))',
|
|
27
|
-
whiteSpace: 'pre-wrap' as const,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/** Render inline content, or fetch the path first — one seam for all three. */
|
|
31
|
-
function TextBody({
|
|
32
|
-
payload,
|
|
33
|
-
render,
|
|
34
|
-
}: Readonly<{
|
|
35
|
-
payload: VistaTextPayload;
|
|
36
|
-
render: (content: string) => ReactNode;
|
|
37
|
-
}>): ReactElement {
|
|
38
|
-
if (payload.content !== undefined) {
|
|
39
|
-
return <>{render(payload.content)}</>;
|
|
40
|
-
}
|
|
41
|
-
// `validateTextPayload` guarantees exactly one of content/path.
|
|
42
|
-
return <VistaFileText path={payload.path as string} render={render} />;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function CodeSurface(payload: VistaTextPayload): ReactElement {
|
|
46
|
-
// A host that ships a code editor provides it through
|
|
47
|
-
// `VistaCodeRendererProvider`; with none the mono pane below IS the intended
|
|
48
|
-
// rendering (see `vista-code-renderer.tsx`).
|
|
49
|
-
const hostRenderer = useVistaCodeRenderer();
|
|
50
|
-
return (
|
|
51
|
-
<TextBody
|
|
52
|
-
payload={payload}
|
|
53
|
-
render={(content) =>
|
|
54
|
-
hostRenderer === null ? (
|
|
55
|
-
<pre className="mono" style={PANE_STYLE}>
|
|
56
|
-
{content}
|
|
57
|
-
</pre>
|
|
58
|
-
) : (
|
|
59
|
-
hostRenderer({
|
|
60
|
-
content,
|
|
61
|
-
...(payload.path === undefined ? {} : { path: payload.path }),
|
|
62
|
-
...(payload.language === undefined
|
|
63
|
-
? {}
|
|
64
|
-
: { language: payload.language }),
|
|
65
|
-
})
|
|
66
|
-
)
|
|
67
|
-
}
|
|
68
|
-
/>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* `json` — pretty-printed and inspectable. An inline payload carries parsed
|
|
74
|
-
* `data`; a path-backed one carries the raw text, which is re-serialised when it
|
|
75
|
-
* parses and shown VERBATIM when it does not (a malformed JSON file is shown as
|
|
76
|
-
* it is, never swallowed).
|
|
77
|
-
*/
|
|
78
|
-
export function JsonSurface({
|
|
79
|
-
data,
|
|
80
|
-
}: Readonly<{ data: unknown }>): ReactElement {
|
|
81
|
-
let text: string;
|
|
82
|
-
try {
|
|
83
|
-
const serialized: unknown = JSON.stringify(data, null, 2);
|
|
84
|
-
text = typeof serialized === 'string' ? serialized : String(data);
|
|
85
|
-
} catch {
|
|
86
|
-
text = String(data);
|
|
87
|
-
}
|
|
88
|
-
return (
|
|
89
|
-
<pre className="mono" style={PANE_STYLE}>
|
|
90
|
-
{text}
|
|
91
|
-
</pre>
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** Colour a unified-diff line by its leading marker. */
|
|
96
|
-
function diffLineColor(line: string): string | undefined {
|
|
97
|
-
if (line.startsWith('+++') || line.startsWith('---')) {
|
|
98
|
-
return 'hsl(var(--ink-3))';
|
|
99
|
-
}
|
|
100
|
-
if (line.startsWith('@@')) {
|
|
101
|
-
return 'hsl(var(--info))';
|
|
102
|
-
}
|
|
103
|
-
if (line.startsWith('+')) {
|
|
104
|
-
return 'hsl(var(--success))';
|
|
105
|
-
}
|
|
106
|
-
if (line.startsWith('-')) {
|
|
107
|
-
return 'hsl(var(--destructive, var(--danger)))';
|
|
108
|
-
}
|
|
109
|
-
return undefined;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function DiffSurface(payload: VistaTextPayload): ReactElement {
|
|
113
|
-
return (
|
|
114
|
-
<TextBody
|
|
115
|
-
payload={payload}
|
|
116
|
-
render={(content) => (
|
|
117
|
-
<pre className="mono" style={PANE_STYLE}>
|
|
118
|
-
{content.split('\n').map((line, index) => (
|
|
119
|
-
<div
|
|
120
|
-
// A diff has no stable per-line identity other than its position.
|
|
121
|
-
|
|
122
|
-
key={index}
|
|
123
|
-
style={{ color: diffLineColor(line) }}
|
|
124
|
-
>
|
|
125
|
-
{line === '' ? ' ' : line}
|
|
126
|
-
</div>
|
|
127
|
-
))}
|
|
128
|
-
</pre>
|
|
129
|
-
)}
|
|
130
|
-
/>
|
|
131
|
-
);
|
|
132
|
-
}
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `useVistaTabs` — the ONE tab-state machine behind every Vista panel.
|
|
3
|
-
*
|
|
4
|
-
* Lifted from `SessionWorkspaceThin`'s (already host-agnostic) chrome and
|
|
5
|
-
* generalised to {@link VistaSurface} envelopes, so the thin session workspace,
|
|
6
|
-
* the Design-System-Builder preview, and the agent-driven `vista_*` tools all
|
|
7
|
-
* drive the SAME state. Behaviours carried over verbatim:
|
|
8
|
-
*
|
|
9
|
-
* • PINNED FIRST TAB. A surface with `pinned: true` sorts first and can never
|
|
10
|
-
* be closed (`close()` returns `false`).
|
|
11
|
-
* • HOST TABS vs. OPENED TABS. `hostTabs` are host-driven (a live workspace
|
|
12
|
-
* scan, an artifact list) and reconcile every render; `open()` tabs are
|
|
13
|
-
* user/agent-driven and persist until closed.
|
|
14
|
-
* • CLOSED-HOST-TAB MEMORY. Closing a host tab records its id so the next
|
|
15
|
-
* scan does NOT resurrect a tab the user dismissed. The record is pruned
|
|
16
|
-
* when the host stops offering that id, so a genuinely new occurrence shows
|
|
17
|
-
* again — no stale suppression.
|
|
18
|
-
* • ACTIVE RECONCILIATION. If the active tab disappears, the first remaining
|
|
19
|
-
* tab becomes active (never a dangling id, never a blank pane).
|
|
20
|
-
*/
|
|
21
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
22
|
-
|
|
23
|
-
import type { VistaTab } from './vista-model';
|
|
24
|
-
|
|
25
|
-
/** A partial update applied to an open tab (`vista_update`). */
|
|
26
|
-
export interface VistaSurfacePatch {
|
|
27
|
-
readonly kind?: string;
|
|
28
|
-
readonly version?: number;
|
|
29
|
-
readonly title?: string;
|
|
30
|
-
readonly payload?: unknown;
|
|
31
|
-
readonly pinned?: boolean;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** A tab summary — what `vista_list()` returns to the agent. */
|
|
35
|
-
export interface VistaTabSummary {
|
|
36
|
-
readonly tabId: string;
|
|
37
|
-
readonly kind: string;
|
|
38
|
-
readonly title: string;
|
|
39
|
-
readonly pinned: boolean;
|
|
40
|
-
readonly active: boolean;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** The tab-state surface a panel (and the `vista_*` dispatcher) drives. */
|
|
44
|
-
export interface VistaTabsController {
|
|
45
|
-
/** Host tabs (reconciled) followed by opened tabs, pinned ones first. */
|
|
46
|
-
readonly tabs: readonly VistaTab[];
|
|
47
|
-
readonly activeTabId: string | null;
|
|
48
|
-
/** Activate a tab. No-op for an id that is not open. */
|
|
49
|
-
activate(tabId: string): void;
|
|
50
|
-
/** Open (or REPLACE, when `tabId` is already open) a surface, and focus it. */
|
|
51
|
-
open(surface: VistaTab): string;
|
|
52
|
-
/** Patch an open tab. `false` when the tab is not open. */
|
|
53
|
-
update(tabId: string, patch: VistaSurfacePatch): boolean;
|
|
54
|
-
/** Close a tab. `false` when it is not open or is pinned. */
|
|
55
|
-
close(tabId: string): boolean;
|
|
56
|
-
/** Snapshot of every open tab. */
|
|
57
|
-
list(): readonly VistaTabSummary[];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface UseVistaTabsOptions {
|
|
61
|
-
/**
|
|
62
|
-
* Host-driven tabs, reconciled live (a workspace scan, an artifact set). A
|
|
63
|
-
* pinned entry here is the panel's permanent first tab.
|
|
64
|
-
*/
|
|
65
|
-
readonly hostTabs?: readonly VistaTab[];
|
|
66
|
-
/** Tab active on first render. Falls back to the first tab. */
|
|
67
|
-
readonly initialActiveTabId?: string;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const NO_HOST_TABS: readonly VistaTab[] = [];
|
|
71
|
-
|
|
72
|
-
/** Pinned tabs first, otherwise insertion order (stable). */
|
|
73
|
-
function sortPinnedFirst(tabs: readonly VistaTab[]): VistaTab[] {
|
|
74
|
-
const pinned = tabs.filter((t) => t.pinned === true);
|
|
75
|
-
const rest = tabs.filter((t) => t.pinned !== true);
|
|
76
|
-
return [...pinned, ...rest];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function useVistaTabs({
|
|
80
|
-
hostTabs = NO_HOST_TABS,
|
|
81
|
-
initialActiveTabId,
|
|
82
|
-
}: UseVistaTabsOptions = {}): VistaTabsController {
|
|
83
|
-
const [openedTabs, setOpenedTabs] = useState<readonly VistaTab[]>([]);
|
|
84
|
-
const [closedHostTabIds, setClosedHostTabIds] = useState<readonly string[]>(
|
|
85
|
-
[],
|
|
86
|
-
);
|
|
87
|
-
const [activeTabId, setActiveTabId] = useState<string | null>(
|
|
88
|
-
initialActiveTabId ?? null,
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
const tabs = useMemo(
|
|
92
|
-
() =>
|
|
93
|
-
sortPinnedFirst([
|
|
94
|
-
...hostTabs.filter((t) => !closedHostTabIds.includes(t.tabId)),
|
|
95
|
-
...openedTabs,
|
|
96
|
-
]),
|
|
97
|
-
[hostTabs, closedHostTabIds, openedTabs],
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
// Prune `closedHostTabIds` entries the host no longer offers, so if the same
|
|
101
|
-
// id reappears later it shows again (no stale suppression).
|
|
102
|
-
useEffect(() => {
|
|
103
|
-
setClosedHostTabIds((prev) => {
|
|
104
|
-
const next = prev.filter((id) => hostTabs.some((t) => t.tabId === id));
|
|
105
|
-
return next.length === prev.length ? prev : next;
|
|
106
|
-
});
|
|
107
|
-
}, [hostTabs]);
|
|
108
|
-
|
|
109
|
-
// Keep the active tab valid as host/opened tabs change. If it disappears (or
|
|
110
|
-
// was never set), fall back to the first available tab.
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
setActiveTabId((current) => {
|
|
113
|
-
if (current !== null && tabs.some((t) => t.tabId === current)) {
|
|
114
|
-
return current;
|
|
115
|
-
}
|
|
116
|
-
return tabs[0]?.tabId ?? null;
|
|
117
|
-
});
|
|
118
|
-
}, [tabs]);
|
|
119
|
-
|
|
120
|
-
// A stable snapshot for `list()` — the controller identity must not change on
|
|
121
|
-
// every render, so the callbacks read through a ref instead of closing over
|
|
122
|
-
// `tabs`.
|
|
123
|
-
const tabsRef = useRef(tabs);
|
|
124
|
-
tabsRef.current = tabs;
|
|
125
|
-
const openedTabsRef = useRef(openedTabs);
|
|
126
|
-
openedTabsRef.current = openedTabs;
|
|
127
|
-
const activeRef = useRef(activeTabId);
|
|
128
|
-
activeRef.current = activeTabId;
|
|
129
|
-
|
|
130
|
-
const activate = useCallback((tabId: string): void => {
|
|
131
|
-
if (!tabsRef.current.some((t) => t.tabId === tabId)) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
setActiveTabId(tabId);
|
|
135
|
-
}, []);
|
|
136
|
-
|
|
137
|
-
const open = useCallback((surface: VistaTab): string => {
|
|
138
|
-
setOpenedTabs((prev) => {
|
|
139
|
-
const index = prev.findIndex((t) => t.tabId === surface.tabId);
|
|
140
|
-
if (index === -1) {
|
|
141
|
-
return [...prev, surface];
|
|
142
|
-
}
|
|
143
|
-
// Re-opening the same tabId REPLACES it (the `VistaSurface` contract).
|
|
144
|
-
const next = [...prev];
|
|
145
|
-
next[index] = surface;
|
|
146
|
-
return next;
|
|
147
|
-
});
|
|
148
|
-
// Re-opening a host tab the user had dismissed un-dismisses it.
|
|
149
|
-
setClosedHostTabIds((prev) => prev.filter((id) => id !== surface.tabId));
|
|
150
|
-
setActiveTabId(surface.tabId);
|
|
151
|
-
return surface.tabId;
|
|
152
|
-
}, []);
|
|
153
|
-
|
|
154
|
-
const update = useCallback(
|
|
155
|
-
(tabId: string, patch: VistaSurfacePatch): boolean => {
|
|
156
|
-
// A HOST tab is owned by the host's data flow — a patch here would be
|
|
157
|
-
// overwritten on the next reconcile, so it is REFUSED rather than
|
|
158
|
-
// silently lost. Ownership is decided synchronously from the ref, not
|
|
159
|
-
// inside the state updater (which React may invoke twice).
|
|
160
|
-
if (!openedTabsRef.current.some((t) => t.tabId === tabId)) {
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
setOpenedTabs((prev) =>
|
|
164
|
-
prev.map((tab) => (tab.tabId === tabId ? { ...tab, ...patch } : tab)),
|
|
165
|
-
);
|
|
166
|
-
return true;
|
|
167
|
-
},
|
|
168
|
-
[],
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
const close = useCallback((tabId: string): boolean => {
|
|
172
|
-
const tab = tabsRef.current.find((t) => t.tabId === tabId);
|
|
173
|
-
if (tab === undefined || tab.pinned === true) {
|
|
174
|
-
return false;
|
|
175
|
-
}
|
|
176
|
-
setOpenedTabs((prev) => prev.filter((t) => t.tabId !== tabId));
|
|
177
|
-
setClosedHostTabIds((prev) =>
|
|
178
|
-
prev.includes(tabId) ? prev : [...prev, tabId],
|
|
179
|
-
);
|
|
180
|
-
return true;
|
|
181
|
-
}, []);
|
|
182
|
-
|
|
183
|
-
const list = useCallback(
|
|
184
|
-
(): readonly VistaTabSummary[] =>
|
|
185
|
-
tabsRef.current.map((tab) => ({
|
|
186
|
-
tabId: tab.tabId,
|
|
187
|
-
kind: tab.kind,
|
|
188
|
-
title: tab.title,
|
|
189
|
-
pinned: tab.pinned === true,
|
|
190
|
-
active: tab.tabId === activeRef.current,
|
|
191
|
-
})),
|
|
192
|
-
[],
|
|
193
|
-
);
|
|
194
|
-
|
|
195
|
-
return { tabs, activeTabId, activate, open, update, close, list };
|
|
196
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from 'react';
|
|
2
|
-
|
|
3
|
-
import type { ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
export type VistaCodeRenderer = (args: {
|
|
6
|
-
readonly content: string;
|
|
7
|
-
readonly path?: string;
|
|
8
|
-
readonly language?: string;
|
|
9
|
-
}) => ReactNode;
|
|
10
|
-
|
|
11
|
-
export const VistaCodeRendererContext =
|
|
12
|
-
createContext<VistaCodeRenderer | null>(null);
|
|
13
|
-
|
|
14
|
-
export function useVistaCodeRenderer(): VistaCodeRenderer | null {
|
|
15
|
-
return useContext(VistaCodeRendererContext);
|
|
16
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `VistaCodeRenderer` — the seam through which a host swaps in a real code
|
|
3
|
-
* editor for the `code` surface.
|
|
4
|
-
*
|
|
5
|
-
* The kernel ships NO syntax-highlighting engine (a Monaco/Prism dependency in
|
|
6
|
-
* a host-framework-agnostic package would be imposed on every consumer), so
|
|
7
|
-
* {@link CodeSurface}'s built-in body is a mono `<pre>`. That is a COMPLETE
|
|
8
|
-
* rendering of a file's bytes, not a degraded one — but a host that already
|
|
9
|
-
* ships an editor (host-web ships Monaco) provides it here and every `code`
|
|
10
|
-
* tab picks it up.
|
|
11
|
-
*
|
|
12
|
-
* This is an extension point, not a fallback chain: with no provider the mono
|
|
13
|
-
* pane is the intended rendering, and with a provider the host's renderer is
|
|
14
|
-
* the intended rendering. Neither is an error path.
|
|
15
|
-
*/
|
|
16
|
-
import { type ReactElement, type ReactNode } from 'react';
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
VistaCodeRendererContext,
|
|
20
|
-
type VistaCodeRenderer,
|
|
21
|
-
} from './vista-code-renderer-context';
|
|
22
|
-
|
|
23
|
-
export function VistaCodeRendererProvider({
|
|
24
|
-
renderer,
|
|
25
|
-
children,
|
|
26
|
-
}: Readonly<{
|
|
27
|
-
renderer: VistaCodeRenderer;
|
|
28
|
-
children: ReactNode;
|
|
29
|
-
}>): ReactElement {
|
|
30
|
-
return (
|
|
31
|
-
<VistaCodeRendererContext.Provider value={renderer}>
|
|
32
|
-
{children}
|
|
33
|
-
</VistaCodeRendererContext.Provider>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from 'react';
|
|
2
|
-
|
|
3
|
-
export interface VistaFileSource {
|
|
4
|
-
readText(path: string): Promise<string>;
|
|
5
|
-
resolveUrl(path: string): Promise<string>;
|
|
6
|
-
readonly revision?: string | number;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const VistaFileSourceContext =
|
|
10
|
-
createContext<VistaFileSource | null>(null);
|
|
11
|
-
|
|
12
|
-
export function useVistaFileSource(): VistaFileSource | null {
|
|
13
|
-
return useContext(VistaFileSourceContext);
|
|
14
|
-
}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `VistaFileSource` — the ONE seam through which a file-backed surface reads
|
|
3
|
-
* bytes.
|
|
4
|
-
*
|
|
5
|
-
* `@xemahq/ui-kernel` is host-framework-agnostic and carries no API client, so
|
|
6
|
-
* a `code`/`markdown`/`pdf`/`image` surface addressed by a workspace `path`
|
|
7
|
-
* cannot fetch on its own. The host provides a source (bound to its own
|
|
8
|
-
* session-file / artifact endpoints) exactly once, at the panel boundary; every
|
|
9
|
-
* first-party renderer reads through it.
|
|
10
|
-
*
|
|
11
|
-
* There is deliberately NO default: a path-backed surface mounted without a
|
|
12
|
-
* provider renders a visible error, never a blank pane and never a silent
|
|
13
|
-
* "content unavailable".
|
|
14
|
-
*/
|
|
15
|
-
import { useEffect, useState, type ReactElement, type ReactNode } from 'react';
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
VistaFileSourceContext,
|
|
19
|
-
useVistaFileSource,
|
|
20
|
-
type VistaFileSource,
|
|
21
|
-
} from './vista-file-context';
|
|
22
|
-
|
|
23
|
-
export function VistaFileSourceProvider({
|
|
24
|
-
source,
|
|
25
|
-
children,
|
|
26
|
-
}: Readonly<{ source: VistaFileSource; children: ReactNode }>): ReactElement {
|
|
27
|
-
return (
|
|
28
|
-
<VistaFileSourceContext.Provider value={source}>
|
|
29
|
-
{children}
|
|
30
|
-
</VistaFileSourceContext.Provider>
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** Async load state for a path-backed surface. */
|
|
35
|
-
type LoadState =
|
|
36
|
-
| { readonly status: 'loading' }
|
|
37
|
-
| { readonly status: 'ready'; readonly value: string }
|
|
38
|
-
| { readonly status: 'error'; readonly message: string };
|
|
39
|
-
|
|
40
|
-
const LOADING: LoadState = { status: 'loading' };
|
|
41
|
-
|
|
42
|
-
function useResolvedFile(path: string, mode: 'text' | 'url'): LoadState {
|
|
43
|
-
const source = useVistaFileSource();
|
|
44
|
-
const revision = source?.revision;
|
|
45
|
-
const [state, setState] = useState<LoadState>(LOADING);
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
if (source === null) {
|
|
49
|
-
setState({
|
|
50
|
-
status: 'error',
|
|
51
|
-
message:
|
|
52
|
-
'No file source is mounted for this panel, so path-backed content cannot be read.',
|
|
53
|
-
});
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
let cancelled = false;
|
|
57
|
-
setState(LOADING);
|
|
58
|
-
const promise =
|
|
59
|
-
mode === 'text' ? source.readText(path) : source.resolveUrl(path);
|
|
60
|
-
promise.then(
|
|
61
|
-
(value) => {
|
|
62
|
-
if (!cancelled) {
|
|
63
|
-
setState({ status: 'ready', value });
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
(error: unknown) => {
|
|
67
|
-
if (cancelled) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
setState({
|
|
71
|
-
status: 'error',
|
|
72
|
-
message: error instanceof Error ? error.message : String(error),
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
|
-
);
|
|
76
|
-
return () => {
|
|
77
|
-
cancelled = true;
|
|
78
|
-
};
|
|
79
|
-
}, [source, path, mode, revision]);
|
|
80
|
-
|
|
81
|
-
return state;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function LoadNotice({
|
|
85
|
-
state,
|
|
86
|
-
}: Readonly<{ state: Exclude<LoadState, { status: 'ready' }> }>): ReactElement {
|
|
87
|
-
return (
|
|
88
|
-
<div
|
|
89
|
-
role={state.status === 'error' ? 'alert' : undefined}
|
|
90
|
-
style={{
|
|
91
|
-
display: 'flex',
|
|
92
|
-
height: '100%',
|
|
93
|
-
alignItems: 'center',
|
|
94
|
-
justifyContent: 'center',
|
|
95
|
-
padding: 24,
|
|
96
|
-
fontSize: 12.5,
|
|
97
|
-
textAlign: 'center',
|
|
98
|
-
color:
|
|
99
|
-
state.status === 'error'
|
|
100
|
-
? 'hsl(var(--destructive))'
|
|
101
|
-
: 'hsl(var(--ink-4))',
|
|
102
|
-
}}
|
|
103
|
-
>
|
|
104
|
-
{state.status === 'loading' ? 'Loading…' : state.message}
|
|
105
|
-
</div>
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Render a path-backed surface body from its TEXT content. The load/error
|
|
111
|
-
* states are explicit and visible — a failed read never renders as empty
|
|
112
|
-
* content.
|
|
113
|
-
*/
|
|
114
|
-
export function VistaFileText({
|
|
115
|
-
path,
|
|
116
|
-
render,
|
|
117
|
-
}: Readonly<{
|
|
118
|
-
path: string;
|
|
119
|
-
render: (content: string) => ReactNode;
|
|
120
|
-
}>): ReactElement {
|
|
121
|
-
const state = useResolvedFile(path, 'text');
|
|
122
|
-
if (state.status !== 'ready') {
|
|
123
|
-
return <LoadNotice state={state} />;
|
|
124
|
-
}
|
|
125
|
-
return <>{render(state.value)}</>;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/** Render a path-backed surface body from a resolved fetchable URL. */
|
|
129
|
-
export function VistaFileUrl({
|
|
130
|
-
path,
|
|
131
|
-
render,
|
|
132
|
-
}: Readonly<{
|
|
133
|
-
path: string;
|
|
134
|
-
render: (url: string) => ReactNode;
|
|
135
|
-
}>): ReactElement {
|
|
136
|
-
const state = useResolvedFile(path, 'url');
|
|
137
|
-
if (state.status !== 'ready') {
|
|
138
|
-
return <LoadNotice state={state} />;
|
|
139
|
-
}
|
|
140
|
-
return <>{render(state.value)}</>;
|
|
141
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from 'react';
|
|
2
|
-
|
|
3
|
-
export interface VistaFormOutcome {
|
|
4
|
-
readonly submitted: true;
|
|
5
|
-
readonly ref: string;
|
|
6
|
-
readonly connectionId: string | null;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface VistaFormHost {
|
|
10
|
-
readonly elicitationApiBaseUrl: string;
|
|
11
|
-
getAccessToken(): Promise<string>;
|
|
12
|
-
onOutcome(outcome: VistaFormOutcome): void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const VistaFormHostContext =
|
|
16
|
-
createContext<VistaFormHost | null>(null);
|
|
17
|
-
|
|
18
|
-
export function useVistaFormHost(): VistaFormHost | null {
|
|
19
|
-
return useContext(VistaFormHostContext);
|
|
20
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `VistaFormHost` — the ONE seam through which a `SurfaceKind.Form` surface
|
|
3
|
-
* gets the SUBJECT's bearer token and reports completion.
|
|
4
|
-
*
|
|
5
|
-
* ── Why this exists, and why the shapes are what they are ───────────────────
|
|
6
|
-
* The `form` surface is the secure-elicitation surface: an agent asks for a
|
|
7
|
-
* credential it must never see. The value therefore travels
|
|
8
|
-
* BROWSER → OWNING SERVICE, signed with the user's own JWT, and the agent
|
|
9
|
-
* learns only that the elicitation settled.
|
|
10
|
-
*
|
|
11
|
-
* That is enforced STRUCTURALLY, not by convention:
|
|
12
|
-
*
|
|
13
|
-
* 1. {@link VistaFormOutcome} is the ONLY thing the surface can report. It is
|
|
14
|
-
* a closed interface with three scalar members and NO `unknown`, no index
|
|
15
|
-
* signature, and no payload/values member. There is no shape a field value
|
|
16
|
-
* could be assigned to. Widening it is the one change that would break the
|
|
17
|
-
* guarantee — do not add a member that can hold arbitrary data.
|
|
18
|
-
* 2. `getAccessToken` returns the SUBJECT's token. The host binds it to the
|
|
19
|
-
* logged-in user's session; it is never a service token and never the
|
|
20
|
-
* agent's token, so the service authorizes the human, not the model.
|
|
21
|
-
* 3. `elicitationApiBaseUrl` is supplied by trusted host configuration, never
|
|
22
|
-
* by the agent-controlled payload. The kernel validates its scheme and
|
|
23
|
-
* canonical authority/path before deriving the status/submit endpoints.
|
|
24
|
-
*
|
|
25
|
-
* There is deliberately NO default host: a `form` surface mounted without a
|
|
26
|
-
* provider renders a visible refusal and cannot submit. Fail-closed — a form
|
|
27
|
-
* that silently posts nowhere would be worse than one that says it cannot.
|
|
28
|
-
*/
|
|
29
|
-
import { type ReactElement, type ReactNode } from 'react';
|
|
30
|
-
|
|
31
|
-
import { VistaFormHostContext, type VistaFormHost } from './vista-form-context';
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Everything a settled elicitation reports. Closed, scalar-only, and
|
|
35
|
-
* value-identical to the service's `{ submitted, ref, connectionId }` — the
|
|
36
|
-
* persistence layer behind it has no column able to hold a field value, and
|
|
37
|
-
* neither does this type.
|
|
38
|
-
*/
|
|
39
|
-
export function VistaFormHostProvider({
|
|
40
|
-
host,
|
|
41
|
-
children,
|
|
42
|
-
}: Readonly<{ host: VistaFormHost; children: ReactNode }>): ReactElement {
|
|
43
|
-
return (
|
|
44
|
-
<VistaFormHostContext.Provider value={host}>
|
|
45
|
-
{children}
|
|
46
|
-
</VistaFormHostContext.Provider>
|
|
47
|
-
);
|
|
48
|
-
}
|