@opengeni/react 0.6.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +17 -6
  2. package/dist/{chunk-DEW2ZNF2.js → chunk-5C7RGAWA.js} +70 -37
  3. package/dist/chunk-5C7RGAWA.js.map +1 -0
  4. package/dist/index.d.ts +45 -9
  5. package/dist/index.js +1385 -732
  6. package/dist/index.js.map +1 -1
  7. package/dist/{machines-BD6h9P_s.d.ts → machines-BeZ3bD3t.d.ts} +2 -2
  8. package/dist/machines.d.ts +1 -1
  9. package/dist/machines.js +1 -1
  10. package/package.json +2 -2
  11. package/src/client.ts +1 -0
  12. package/src/components/chat-composer.tsx +127 -60
  13. package/src/components/code-editor.tsx +15 -15
  14. package/src/components/desktop-viewer.tsx +40 -36
  15. package/src/components/diff-view.tsx +22 -22
  16. package/src/components/enrollment-consent.tsx +13 -13
  17. package/src/components/file-browser.tsx +74 -67
  18. package/src/components/fleet-tile.tsx +3 -3
  19. package/src/components/machine-card.tsx +6 -6
  20. package/src/components/machine-status-pill.tsx +3 -3
  21. package/src/components/machines-dashboard.tsx +28 -14
  22. package/src/components/markdown.tsx +6 -6
  23. package/src/components/message-timeline.tsx +207 -12
  24. package/src/components/pierre-diff.tsx +9 -10
  25. package/src/components/pierre-file.tsx +8 -8
  26. package/src/components/sandbox-files.tsx +37 -40
  27. package/src/components/sandbox-terminal.tsx +9 -11
  28. package/src/components/session-status.tsx +2 -2
  29. package/src/components/workspace-dock.tsx +153 -49
  30. package/src/hooks/use-file-attachments.ts +45 -15
  31. package/src/hooks/use-session-events.ts +283 -8
  32. package/src/index.ts +2 -2
  33. package/src/lib/format.ts +32 -0
  34. package/src/lib/xterm-theme.ts +8 -11
  35. package/src/timeline/activity-rail.tsx +5 -2
  36. package/src/timeline/entrance.tsx +30 -0
  37. package/src/timeline/parsers.ts +104 -0
  38. package/src/timeline/projection.ts +22 -5
  39. package/src/timeline/screenshot-lightbox.tsx +1 -1
  40. package/src/timeline/shared.tsx +4 -1
  41. package/src/timeline/tool-diff.tsx +1 -1
  42. package/src/timeline/tool-renderers.tsx +46 -7
  43. package/src/timeline/turn-summary.tsx +24 -4
  44. package/styles/tokens.css +8 -0
  45. package/dist/chunk-DEW2ZNF2.js.map +0 -1
@@ -136,7 +136,7 @@ function LightboxRoot({ children }: { children: ReactNode }) {
136
136
  {state.caption}
137
137
  </figcaption>
138
138
  ) : (
139
- <figcaption className="font-og-mono text-[10px] uppercase tracking-[0.1em] text-white/35">
139
+ <figcaption className="font-og-mono text-og-xs uppercase tracking-[0.1em] text-white/35">
140
140
  Esc or click outside to close
141
141
  </figcaption>
142
142
  )}
@@ -155,6 +155,9 @@ export function ActivityDisclosure({
155
155
  const rowClass = cn(
156
156
  "group/disclosure flex w-full min-w-0 items-center gap-2 rounded-og-sm px-1.5 py-1.5 text-left text-og-base",
157
157
  "text-og-fg-muted transition-colors duration-150",
158
+ // A tool row is a touch target on coarse pointers: grow its padding so the
159
+ // hit area clears the 40px minimum without loosening the dense desktop rail.
160
+ "pointer-coarse:py-2.5",
158
161
  );
159
162
  // The chevron rotates to point down when open; it tracks `data-state` on this
160
163
  // same row (the Trigger), so the affordance never freezes.
@@ -295,7 +298,7 @@ export function TermBlock({
295
298
  const showHeader = command != null || workdir != null;
296
299
 
297
300
  return (
298
- <div className="overflow-hidden rounded-og-sm border border-og-border bg-og-bg/70">
301
+ <div className="min-w-0 overflow-hidden rounded-og-sm border border-og-border bg-og-bg/70">
299
302
  {showHeader ? (
300
303
  <div className="flex items-center gap-2 border-b border-og-border/70 px-2.5 py-1.5">
301
304
  <span className="select-none text-og-status-idle">$</span>
@@ -49,7 +49,7 @@ function LayoutToggle({ layout, onChange }: { layout: "unified" | "split"; onCha
49
49
  type="button"
50
50
  onClick={() => onChange(value)}
51
51
  className={cn(
52
- "rounded-[5px] px-2 py-[3px] text-[11px] font-medium capitalize transition-colors",
52
+ "rounded-og-xs px-2 py-[3px] text-og-xs font-medium capitalize transition-colors",
53
53
  layout === value ? "bg-og-surface-2 text-og-fg" : "text-og-fg-subtle hover:text-og-fg-muted",
54
54
  )}
55
55
  >
@@ -15,7 +15,7 @@ import {
15
15
  WrenchIcon,
16
16
  } from "lucide-react";
17
17
  import type { ReactNode } from "react";
18
- import { stringifyPayload } from "../lib/format";
18
+ import { stringifyPayload, tryParseJson } from "../lib/format";
19
19
  import {
20
20
  applyPatchOps,
21
21
  controlCaret,
@@ -30,6 +30,7 @@ import {
30
30
  tailPeek,
31
31
  unwrapMcpOutput,
32
32
  v4aToGitFileDiff,
33
+ screenshotDataUrl,
33
34
  type ApplyPatchOperation,
34
35
  } from "./parsers";
35
36
  import { createToolRegistry, type ToolRegistry, type ToolRegistryEntry, type ToolRendererProps } from "./registry";
@@ -477,20 +478,49 @@ function computerVerb(action: ComputerAction | undefined): string {
477
478
  }
478
479
  }
479
480
 
481
+
482
+ /** Coerce a function-tool arguments payload into the ComputerAction fields. */
483
+ function asComputerArgs(args: unknown): Partial<ComputerAction> {
484
+ if (!args) {
485
+ return {};
486
+ }
487
+ const parsed = typeof args === "string" ? tryParseJson(args) : args;
488
+ if (!parsed || typeof parsed !== "object") {
489
+ return {};
490
+ }
491
+ const record = parsed as Record<string, unknown>;
492
+ return {
493
+ ...(typeof record.x === "number" ? { x: record.x } : {}),
494
+ ...(typeof record.y === "number" ? { y: record.y } : {}),
495
+ ...(typeof record.text === "string" ? { text: record.text } : {}),
496
+ ...(Array.isArray(record.keys) ? { keys: record.keys as string[] } : {}),
497
+ ...(typeof record.button === "string" ? { button: record.button } : {}),
498
+ };
499
+ }
500
+
480
501
  function ComputerCallRenderer({ item }: ToolRendererProps) {
481
502
  const raw = (item.raw ?? {}) as {
482
503
  action?: ComputerAction;
483
504
  actions?: ComputerAction[];
484
505
  providerData?: { approvalStatus?: string };
485
506
  };
486
- const action = raw.action;
507
+ // Function-mode computer tools (computer_screenshot / computer_click / …,
508
+ // used on codex + chat-wire providers since the explicit tool-transport
509
+ // change) carry the action in the tool NAME + arguments instead of raw.action.
510
+ // Normalize them into the same ComputerAction shape so one renderer serves
511
+ // every transport.
512
+ const functionAction: ComputerAction | undefined =
513
+ !raw.action && item.name.startsWith("computer_") && item.name !== "computer_call"
514
+ ? { type: item.name.slice("computer_".length), ...(asComputerArgs(item.arguments)) }
515
+ : undefined;
516
+ const action = raw.action ?? functionAction;
487
517
  const actions = raw.actions ?? (action ? [action] : []);
488
518
  const verb = computerVerb(action);
489
519
  const out = item.output;
490
520
  const running = item.status === "running";
491
521
  const rejected = raw.providerData?.approvalStatus === "rejected";
492
522
  const readOnly = typeof out === "string" && out.includes("read-only");
493
- const isImage = typeof out === "string" && out.startsWith("data:image");
523
+ const shotUrl = screenshotDataUrl(out);
494
524
  const empty = out === "" || out == null;
495
525
  const batched = actions.length > 1 ? actions.map((a) => computerVerb(a)).join(" · ") : null;
496
526
  // Fold the batched-action count into the title (one media affordance per row),
@@ -542,8 +572,8 @@ function ComputerCallRenderer({ item }: ToolRendererProps) {
542
572
  const isFailed = item.status === "failed";
543
573
  const isCancelled = item.status === "cancelled";
544
574
 
545
- if (isImage && typeof out === "string") {
546
- const caption = `computer_call · ${verb}${actions.length > 1 ? ` (+${actions.length - 1} more)` : ""}`;
575
+ if (shotUrl) {
576
+ const caption = `${verb}${actions.length > 1 ? ` (+${actions.length - 1} more)` : ""}`;
547
577
  return (
548
578
  <ActivityDisclosure
549
579
  icon={isShot ? <CameraIcon className={ICON_SIZE} /> : <MousePointer2Icon className={ICON_SIZE} />}
@@ -551,9 +581,9 @@ function ComputerCallRenderer({ item }: ToolRendererProps) {
551
581
  title={`${verb}${countSuffix}`}
552
582
  failed={isFailed}
553
583
  cancelled={isCancelled}
554
- media={<Thumbnail src={out} caption={caption} />}
584
+ media={<Thumbnail src={shotUrl} caption={caption} />}
555
585
  >
556
- <ScreenshotFigure src={out} caption={caption} />
586
+ <ScreenshotFigure src={shotUrl} caption={caption} />
557
587
  {batched ? <BodyNote>batched: {batched}</BodyNote> : null}
558
588
  </ActivityDisclosure>
559
589
  );
@@ -866,6 +896,15 @@ const BASE_ENTRIES: ToolRegistryEntry[] = [
866
896
  { match: "name", name: "write_stdin", render: WriteStdinRenderer },
867
897
  { match: "name", name: "apply_patch_call", render: ApplyPatchRenderer },
868
898
  { match: "name", name: "computer_call", render: ComputerCallRenderer },
899
+ // Function-mode computer tools (codex / chat-wire transports).
900
+ { match: "name", name: "computer_screenshot", render: ComputerCallRenderer },
901
+ { match: "name", name: "computer_click", render: ComputerCallRenderer },
902
+ { match: "name", name: "computer_double_click", render: ComputerCallRenderer },
903
+ { match: "name", name: "computer_move", render: ComputerCallRenderer },
904
+ { match: "name", name: "computer_scroll", render: ComputerCallRenderer },
905
+ { match: "name", name: "computer_type", render: ComputerCallRenderer },
906
+ { match: "name", name: "computer_keypress", render: ComputerCallRenderer },
907
+ { match: "name", name: "computer_drag", render: ComputerCallRenderer },
869
908
  { match: "name", name: "web_search_call", render: WebSearchRenderer },
870
909
  { match: "name", name: "view_image", render: ViewImageRenderer },
871
910
  { match: "name", name: "environment_set_variable", render: SecretSetRenderer },
@@ -3,7 +3,8 @@ import { useState } from "react";
3
3
  import { Collapsible } from "radix-ui";
4
4
  import { cn } from "../lib/cn";
5
5
  import { useForcedDefaultOpen } from "./disclosure-context";
6
- import { applyPatchOps, isApplyPatch } from "./parsers";
6
+ import { useEntranceAnimation } from "./entrance";
7
+ import { applyPatchOps, isApplyPatch, screenshotDataUrl } from "./parsers";
7
8
  import { rawTypeOf } from "./registry";
8
9
  import type { ActivityItem, TurnOutcome } from "./types";
9
10
  export type { TurnOutcome } from "./types";
@@ -39,13 +40,17 @@ export function TurnSummary({ items, outcome, failureText, durationMs, defaultOp
39
40
  // (screenshot instrumentation); otherwise the turn starts folded.
40
41
  const forcedDefaultOpen = useForcedDefaultOpen();
41
42
  const [open, setOpen] = useState(defaultOpen ?? forcedDefaultOpen ?? false);
43
+ const enter = useEntranceAnimation();
42
44
  const facets = summarizeTurn(items, durationMs);
43
45
 
44
46
  return (
45
- <Collapsible.Root open={open} onOpenChange={setOpen} className="animate-og-enter">
47
+ <Collapsible.Root open={open} onOpenChange={setOpen} className={enter ? "animate-og-enter" : undefined}>
46
48
  <Collapsible.Trigger
47
49
  className={cn(
48
50
  "group flex w-full items-center gap-2.5 rounded-og-md border px-3 py-2 text-left text-og-base transition-colors",
51
+ // A folded turn is a touch target on coarse pointers: grow the row so
52
+ // it clears the 40px minimum without disturbing the calm desktop rhythm.
53
+ "pointer-coarse:py-2.5",
49
54
  // Only a failed turn earns the one filled/tinted card in the timeline;
50
55
  // complete and cancelled stay flat and calm.
51
56
  outcome === "failed"
@@ -84,6 +89,21 @@ export function TurnSummary({ items, outcome, failureText, durationMs, defaultOp
84
89
  ) : null}
85
90
  {outcome === "cancelled" ? <span className="text-og-fg-subtle"> · interrupted</span> : null}
86
91
  </span>
92
+ {/* The disclosure hint. Calm at rest on fine pointers (revealed on hover
93
+ and keyboard focus), but always present on coarse pointers where there
94
+ is no hover to lean on — so the fold never reads as a static status
95
+ line. Purely visual: the trigger's aria-expanded already conveys state
96
+ to assistive tech, so the hint is hidden from the accessible name. */}
97
+ <span
98
+ aria-hidden
99
+ className={cn(
100
+ "ml-auto shrink-0 pl-2 text-og-xs text-og-fg-subtle transition-opacity duration-150",
101
+ "opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100",
102
+ "pointer-coarse:opacity-100",
103
+ )}
104
+ >
105
+ {open ? "hide steps" : "show steps"}
106
+ </span>
87
107
  </Collapsible.Trigger>
88
108
  <Collapsible.Content className="overflow-hidden data-[state=closed]:animate-og-collapse data-[state=open]:animate-og-expand">
89
109
  <div className="pt-2">{children}</div>
@@ -106,8 +126,8 @@ function summarizeTurn(items: ActivityItem[], durationMs?: number): string {
106
126
  files += applyPatchOps(item.raw).length;
107
127
  } else if (item.name === "exec_command") {
108
128
  commands += 1;
109
- } else if (rawTypeOf(item) === "computer_call" || item.name === "computer_call") {
110
- if (typeof item.output === "string" && item.output.startsWith("data:image")) {
129
+ } else if (rawTypeOf(item) === "computer_call" || item.name === "computer_call" || item.name === "computer_screenshot") {
130
+ if (screenshotDataUrl(item.output) !== null) {
111
131
  screenshots += 1;
112
132
  }
113
133
  }
package/styles/tokens.css CHANGED
@@ -17,6 +17,8 @@
17
17
  --og-font-sans: "Inter Variable", "Inter", ui-sans-serif, system-ui, sans-serif;
18
18
  --og-font-mono: "JetBrains Mono Variable", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
19
19
  --og-font-features: "cv11", "ss01", "ss03";
20
+ --og-code-font-size: 12px;
21
+ --og-code-line-height: 18px;
20
22
 
21
23
  /* Radius ----------------------------------------------------------------- */
22
24
  --og-radius-xs: 4px;
@@ -48,6 +50,7 @@
48
50
  /* Accent — one brand hue, used sparingly ----------------------------------- */
49
51
  --og-color-accent: oklch(0.72 0.15 255);
50
52
  --og-color-accent-strong: oklch(0.78 0.14 255);
53
+ --og-color-accent-deep: oklch(0.62 0.18 255);
51
54
  --og-color-accent-fg: oklch(0.985 0.005 260);
52
55
  --og-color-accent-soft: color-mix(in oklch, var(--og-color-accent) 16%, transparent);
53
56
 
@@ -59,6 +62,8 @@
59
62
  --og-color-status-failed: oklch(0.7 0.16 22);
60
63
  --og-color-status-cancelled: oklch(0.6 0.035 260);
61
64
  --og-color-danger: oklch(0.66 0.18 22);
65
+ --og-color-diff-add-bg: color-mix(in oklch, var(--og-color-status-idle) 14%, transparent);
66
+ --og-color-diff-del-bg: color-mix(in oklch, var(--og-color-status-failed) 14%, transparent);
62
67
 
63
68
  /* Elevation ----------------------------------------------------------------
64
69
  Dark surfaces barely cast shadows; elevation reads mostly from the
@@ -91,6 +96,7 @@
91
96
 
92
97
  --og-color-accent: oklch(0.55 0.18 255);
93
98
  --og-color-accent-strong: oklch(0.48 0.19 255);
99
+ --og-color-accent-deep: oklch(0.44 0.19 255);
94
100
  --og-color-accent-fg: oklch(0.985 0.005 260);
95
101
  --og-color-accent-soft: color-mix(in oklch, var(--og-color-accent) 11%, transparent);
96
102
 
@@ -101,6 +107,8 @@
101
107
  --og-color-status-failed: oklch(0.55 0.19 22);
102
108
  --og-color-status-cancelled: oklch(0.55 0.025 260);
103
109
  --og-color-danger: oklch(0.55 0.2 22);
110
+ --og-color-diff-add-bg: color-mix(in oklch, var(--og-color-status-idle) 12%, transparent);
111
+ --og-color-diff-del-bg: color-mix(in oklch, var(--og-color-status-failed) 12%, transparent);
104
112
 
105
113
  --og-shadow-sm: 0 1px 2px oklch(0.2 0.02 260 / 0.07);
106
114
  --og-shadow-md: 0 2px 8px oklch(0.2 0.02 260 / 0.09), 0 1px 2px oklch(0.2 0.02 260 / 0.06);
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types/machines.ts","../src/lib/cn.ts","../src/components/machine-status-pill.tsx","../src/lib/format.ts","../src/components/machine-metrics.tsx","../src/components/machine-card.tsx","../src/components/machines-dashboard.tsx","../src/components/machine-dock-bar.tsx","../src/components/enrollment-device-flow.tsx","../src/components/enrollment-consent.tsx","../src/hooks/use-machines.ts","../src/provider.tsx","../src/hooks/internal.ts"],"sourcesContent":["// ----------------------------------------------------------------------------\n// Bring-your-own-compute — Machines view-model.\n//\n// The data-contract types (MachineView / MetricSample / MachinesResponse /\n// MachineMetricsSeriesResponse / MachineKind / MachineState) are the\n// orchestrator-owned SHARED DATA CONTRACT that M10 ships in `@opengeni/sdk`\n// (hand-written mirrors of `@opengeni/contracts`, pinned by contract-parity).\n// M9 RE-EXPORTS them here so the dashboard UI imports a single, stable name and\n// never drifts from the API — exactly as the contract intends.\n//\n// (During concurrent M9/M10 development this module briefly carried a local\n// view-model with the same field names; once M10 landed the SDK types we\n// reconciled to re-export them — the field names were identical by design.)\n//\n// Endpoints these model (M10 owns the SDK client methods):\n// GET /v1/workspaces/:ws/machines -> MachinesResponse\n// GET /v1/workspaces/:ws/machines/:enrollmentId/metrics/series?window=1h\n// -> { samples: MetricSample[] }\n// ----------------------------------------------------------------------------\nimport type {\n MachineKind,\n MachineMetricsSeriesResponse,\n MachinesResponse,\n MachineState,\n MachineView,\n MetricSample,\n} from \"@opengeni/sdk\";\n\nexport type {\n MachineKind,\n MachineMetricsSeriesResponse,\n MachinesResponse,\n MachineState,\n MachineView,\n MetricSample,\n};\n\n// --- connection-status grouping (a PURE UI projection — not a contract type) --\n\n/**\n * The three connection-status pill values the UI surfaces across the dashboard,\n * the dock, and the timeline. `consent_required` / `display_unavailable` /\n * `enrolling` are NOT connection states — they map onto a connection state for\n * the pill and carry their own badge separately.\n */\nexport type ConnectionStatus = \"online\" | \"reconnecting\" | \"offline\";\n\n/** Project a machine `state` onto its connection-status pill value. */\nexport function connectionStatusForState(state: MachineState): ConnectionStatus {\n switch (state) {\n case \"online\":\n case \"consent_required\":\n case \"display_unavailable\":\n // The control plane is reachable; the limitation is consent / no display.\n return \"online\";\n case \"reconnecting\":\n case \"enrolling\":\n return \"reconnecting\";\n case \"offline\":\n return \"offline\";\n default: {\n // Exhaustiveness guard — a new state must be classified explicitly.\n const _never: never = state;\n return _never;\n }\n }\n}\n","import { clsx, type ClassValue } from \"clsx\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\n/* ----------------------------------------------------------------------------\n tailwind-merge, taught our design tokens.\n\n Our type scale and color ramp share the `og-` prefix: `text-og-base` is a\n FONT SIZE, `text-og-fg-muted` is a COLOR. Stock tailwind-merge can't tell\n them apart — it lumps every `text-og-*` into one `font-size` group and, when\n two land in the same class list, drops the earlier one. That silently ate the\n size off rows like `text-og-base text-og-fg-muted`, leaving titles at the\n browser-default 16px. Register the custom font-size scale so the size and the\n color live in different conflict groups and both survive a merge.\n -------------------------------------------------------------------------- */\nconst twMerge = extendTailwindMerge({\n extend: {\n classGroups: {\n \"font-size\": [{ text: [\"og-xs\", \"og-sm\", \"og-base\", \"og-md\"] }],\n },\n },\n});\n\n/** Merge class names with Tailwind-aware conflict resolution. */\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(inputs));\n}\n","import { cn } from \"../lib/cn\";\nimport {\n type ConnectionStatus,\n connectionStatusForState,\n type MachineState,\n} from \"../types/machines\";\n\nexport type ConnectionStatusMeta = {\n label: string;\n dotClassName: string;\n badgeClassName: string;\n /** Live/transient states breathe; settled states hold still. */\n pulse: boolean;\n};\n\n/** Token-backed meta for the three connection-status pill values. */\nexport const CONNECTION_STATUS_META: Record<ConnectionStatus, ConnectionStatusMeta> = {\n online: {\n label: \"Online\",\n dotClassName: \"bg-og-status-running\",\n badgeClassName: \"text-og-status-running border-og-status-running/30 bg-og-status-running/10\",\n pulse: false,\n },\n reconnecting: {\n label: \"Reconnecting\",\n dotClassName: \"bg-og-status-waiting\",\n badgeClassName: \"text-og-status-waiting border-og-status-waiting/35 bg-og-status-waiting/10\",\n pulse: true,\n },\n offline: {\n label: \"Offline\",\n dotClassName: \"bg-og-status-failed\",\n badgeClassName: \"text-og-fg-subtle border-og-border bg-og-status-failed/10\",\n pulse: false,\n },\n};\n\nexport type MachineStateBadgeMeta = {\n label: string;\n badgeClassName: string;\n};\n\n/**\n * The non-connection state badges that ride ALONGSIDE the connection pill —\n * `consent_required` / `display_unavailable` / `enrolling` describe a capability\n * limitation, not reachability, so they render as their own tinted chip.\n */\nexport const MACHINE_STATE_BADGE_META: Partial<Record<MachineState, MachineStateBadgeMeta>> = {\n consent_required: {\n label: \"Consent required\",\n badgeClassName: \"text-og-status-waiting border-og-status-waiting/35 bg-og-status-waiting/10\",\n },\n display_unavailable: {\n label: \"No display\",\n badgeClassName: \"text-og-fg-muted border-og-border bg-og-surface-2\",\n },\n enrolling: {\n label: \"Enrolling\",\n badgeClassName: \"text-og-accent border-og-accent/30 bg-og-accent-soft\",\n },\n};\n\nexport type ConnectionStatusPillProps = {\n status: ConnectionStatus;\n /** Override the label (\"Online\" -> \"Connected\", ...). */\n label?: string | undefined;\n size?: \"sm\" | \"md\" | undefined;\n className?: string | undefined;\n};\n\n/**\n * The connection-status pill (online / reconnecting / offline) surfaced across\n * the Machines dashboard, the dock header, and the session timeline. Reconnecting\n * breathes (the resiliency-as-headline blip), online/offline hold still.\n */\nexport function ConnectionStatusPill({ status, label, size = \"md\", className }: ConnectionStatusPillProps) {\n const meta = CONNECTION_STATUS_META[status];\n return (\n <span\n data-connection-status={status}\n className={cn(\n \"og-root inline-flex shrink-0 items-center rounded-full border font-medium\",\n size === \"sm\" ? \"gap-1 px-1.5 py-px text-[10px]\" : \"gap-1.5 px-2 py-0.5 text-xs\",\n meta.badgeClassName,\n className,\n )}\n >\n <ConnectionDot status={status} className={size === \"sm\" ? \"size-1\" : \"size-1.5\"} />\n {label ?? meta.label}\n </span>\n );\n}\n\nexport type ConnectionDotProps = {\n status: ConnectionStatus;\n className?: string | undefined;\n};\n\n/** Just the dot — for dense rows, the dock header, and timeline notices. */\nexport function ConnectionDot({ status, className }: ConnectionDotProps) {\n const meta = CONNECTION_STATUS_META[status];\n return (\n <span className={cn(\"relative inline-flex size-1.5 shrink-0 rounded-full\", meta.dotClassName, className)}>\n {meta.pulse ? <span className={cn(\"absolute inset-0 animate-og-pulse rounded-full\", meta.dotClassName)} /> : null}\n </span>\n );\n}\n\nexport type MachineStatusPillProps = {\n /** The machine's full state — drives the connection pill + any state badge. */\n state: MachineState;\n /** How many live sessions share this lease (renders a \"Shared\" chip when >1). */\n sharedSessionCount?: number | undefined;\n size?: \"sm\" | \"md\" | undefined;\n className?: string | undefined;\n};\n\n/**\n * The composite machine status surface: the connection pill PLUS any\n * consent/display/enrolling badge PLUS a shared-in-use chip. One component the\n * dashboard row, the dock header, and the timeline all reuse so the status\n * language is identical everywhere.\n */\nexport function MachineStatusPill({ state, sharedSessionCount, size = \"md\", className }: MachineStatusPillProps) {\n const stateBadge = MACHINE_STATE_BADGE_META[state];\n const shared = (sharedSessionCount ?? 0) > 1;\n return (\n <span className={cn(\"og-root inline-flex flex-wrap items-center gap-1\", className)} data-machine-state={state}>\n <ConnectionStatusPill status={connectionStatusForState(state)} size={size} />\n {stateBadge ? (\n <span\n data-state-badge={state}\n className={cn(\n \"inline-flex shrink-0 items-center rounded-full border font-medium\",\n size === \"sm\" ? \"px-1.5 py-px text-[10px]\" : \"px-2 py-0.5 text-xs\",\n stateBadge.badgeClassName,\n )}\n >\n {stateBadge.label}\n </span>\n ) : null}\n {shared ? (\n <span\n data-shared-chip\n className={cn(\n \"inline-flex shrink-0 items-center gap-1 rounded-full border font-medium\",\n \"text-og-accent border-og-accent/30 bg-og-accent-soft\",\n size === \"sm\" ? \"px-1.5 py-px text-[10px]\" : \"px-2 py-0.5 text-xs\",\n )}\n title={`${sharedSessionCount} sessions are on this machine`}\n >\n Shared · {sharedSessionCount}\n </span>\n ) : null}\n </span>\n );\n}\n","/** Compact relative time: \"now\", \"42s\", \"7m\", \"3h\", \"2d\", then a date. */\nexport function formatRelativeTime(iso: string, now: Date = new Date()): string {\n const then = new Date(iso).getTime();\n if (Number.isNaN(then)) {\n return \"\";\n }\n const seconds = Math.max(0, Math.floor((now.getTime() - then) / 1000));\n if (seconds < 10) {\n return \"now\";\n }\n if (seconds < 60) {\n return `${seconds}s`;\n }\n const minutes = Math.floor(seconds / 60);\n if (minutes < 60) {\n return `${minutes}m`;\n }\n const hours = Math.floor(minutes / 60);\n if (hours < 24) {\n return `${hours}h`;\n }\n const days = Math.floor(hours / 24);\n if (days < 14) {\n return `${days}d`;\n }\n return new Date(iso).toLocaleDateString();\n}\n\n/** Human-readable byte size: \"512 B\", \"8.0 KB\", \"1.4 MB\", \"3 GB\". */\nexport function formatBytes(bytes: number): string {\n if (bytes < 1024) {\n return `${bytes} B`;\n }\n const units = [\"KB\", \"MB\", \"GB\"] as const;\n let value = bytes / 1024;\n for (const unit of units) {\n if (value < 1024 || unit === \"GB\") {\n return `${value.toFixed(value < 10 ? 1 : 0)} ${unit}`;\n }\n value /= 1024;\n }\n return `${bytes} B`;\n}\n\n/** Single-line preview of arbitrary text, for tiles and collapsed rows. */\nexport function truncate(text: string, maxLength: number): string {\n const collapsed = text.replace(/\\s+/g, \" \").trim();\n if (collapsed.length <= maxLength) {\n return collapsed;\n }\n return `${collapsed.slice(0, Math.max(0, maxLength - 1)).trimEnd()}…`;\n}\n\n/** Render an unknown payload as readable text (pretty JSON when possible). */\nexport function stringifyPayload(value: unknown): string {\n if (value === null || value === undefined) {\n return \"\";\n }\n if (typeof value === \"string\") {\n const parsed = tryParseJson(value);\n if (parsed !== undefined && typeof parsed === \"object\") {\n return stringifyPayload(parsed);\n }\n return value;\n }\n try {\n return JSON.stringify(value, null, 2) ?? String(value);\n } catch {\n return String(value);\n }\n}\n\n/** JSON.parse that returns `undefined` instead of throwing. */\nexport function tryParseJson(text: string): unknown {\n const trimmed = text.trim();\n if (!trimmed.startsWith(\"{\") && !trimmed.startsWith(\"[\") && !trimmed.startsWith('\"')) {\n return undefined;\n }\n try {\n return JSON.parse(trimmed) as unknown;\n } catch {\n return undefined;\n }\n}\n","import { cn } from \"../lib/cn\";\nimport { formatBytes } from \"../lib/format\";\nimport type { MetricSample } from \"../types/machines\";\n\nexport type MachineMetricsProps = {\n /** The latest metric sample, or null when the machine hasn't reported yet. */\n metrics: MetricSample | null;\n /** Compact (dashboard row) vs full (the dock detail). */\n density?: \"compact\" | \"full\" | undefined;\n className?: string | undefined;\n};\n\n/** Clamp a 0..100-ish percent into the bar range. */\nfunction pct(value: number): number {\n if (!Number.isFinite(value)) return 0;\n return Math.max(0, Math.min(100, value));\n}\n\n/** A label/value pair with a token-tinted utilisation bar. */\nfunction Meter({\n label,\n value,\n fillPct,\n tone,\n}: {\n label: string;\n value: string;\n fillPct: number;\n tone: \"ok\" | \"warn\" | \"hot\";\n}) {\n const fillClass =\n tone === \"hot\" ? \"bg-og-status-failed\" : tone === \"warn\" ? \"bg-og-status-waiting\" : \"bg-og-status-running\";\n return (\n <div className=\"flex min-w-0 flex-col gap-1\" data-metric={label.toLowerCase()}>\n <div className=\"flex items-baseline justify-between gap-2\">\n <span className=\"text-[10px] font-medium uppercase tracking-wide text-og-fg-subtle\">{label}</span>\n <span className=\"font-og-mono text-[11px] tabular-nums text-og-fg-muted\">{value}</span>\n </div>\n <div className=\"h-1 w-full overflow-hidden rounded-full bg-og-surface-2\">\n <div\n className={cn(\"h-full rounded-full transition-[width] duration-500\", fillClass)}\n style={{ width: `${pct(fillPct)}%` }}\n />\n </div>\n </div>\n );\n}\n\n/** Map a percent to a calm/warn/hot tone (no color invented — token classes). */\nfunction toneFor(p: number): \"ok\" | \"warn\" | \"hot\" {\n if (p >= 90) return \"hot\";\n if (p >= 70) return \"warn\";\n return \"ok\";\n}\n\n/** The token text color for a tone (matches the `Meter` fill ramp). */\nfunction toneTextClass(tone: \"ok\" | \"warn\" | \"hot\"): string {\n return tone === \"hot\" ? \"text-og-status-failed\" : tone === \"warn\" ? \"text-og-status-waiting\" : \"text-og-status-running\";\n}\n\n/**\n * Load average as three labeled mini-stats (1m / 5m / 15m) — an honest triple of\n * numbers, NOT a fake gauge. The whole triple is tinted by `load1`'s tone (load\n * isn't a 0..100 ratio, so we tone it but never draw a bar). Run queue rides\n * alongside as a quiet chip when there's pending work.\n */\nfunction StatTriple({\n load1,\n load5,\n load15,\n runQueue,\n}: {\n load1: number;\n load5: number;\n load15: number;\n runQueue: number;\n}) {\n // Load isn't a percent — tone by load1 against a nominal single-core ceiling\n // (≥0.9/core ≈ saturated). Used only to tint the labels/values, never a bar.\n const tone = toneFor(load1 * 100);\n const stats: Array<{ label: string; value: number }> = [\n { label: \"1m\", value: load1 },\n { label: \"5m\", value: load5 },\n { label: \"15m\", value: load15 },\n ];\n return (\n <div className=\"flex items-center justify-between gap-3\" data-metric=\"load\">\n <div className=\"flex min-w-0 flex-col gap-1\">\n <span className=\"text-[10px] font-medium uppercase tracking-wide text-og-fg-subtle\">Load</span>\n <div className=\"flex items-baseline gap-3\">\n {stats.map((s) => (\n <div key={s.label} className=\"flex items-baseline gap-1\">\n <span className={cn(\"text-[10px] font-medium uppercase tracking-wide\", toneTextClass(tone))}>\n {s.label}\n </span>\n <span className={cn(\"font-og-mono text-[12px] tabular-nums\", toneTextClass(tone))}>\n {s.value.toFixed(2)}\n </span>\n </div>\n ))}\n </div>\n </div>\n {runQueue > 0 ? (\n <div\n className=\"flex shrink-0 items-baseline gap-1.5 rounded-og-sm bg-og-surface-2 px-2 py-1 text-[11px] text-og-fg-subtle\"\n data-metric=\"runqueue\"\n >\n <span className=\"font-medium uppercase tracking-wide\">Queue</span>\n <span className=\"font-og-mono tabular-nums text-og-fg-muted\">{runQueue}</span>\n </div>\n ) : null}\n </div>\n );\n}\n\n/**\n * Per-machine resource meters: CPU%, load average, memory, disk, and GPU when\n * present. Renders the M2 `machine_metrics_latest` sample. When `metrics` is\n * null the panel shows a quiet \"no samples yet\" placeholder (offline / just\n * enrolled). GPU rows only render when `gpuUtilPct` is non-null.\n */\nexport function MachineMetrics({ metrics, density = \"compact\", className }: MachineMetricsProps) {\n if (!metrics) {\n return (\n <div className={cn(\"text-[11px] text-og-fg-subtle\", className)} data-metrics-empty>\n No metrics yet\n </div>\n );\n }\n\n const memPct = metrics.memTotalBytes > 0 ? (metrics.memUsedBytes / metrics.memTotalBytes) * 100 : 0;\n const diskPct = metrics.diskTotalBytes > 0 ? (metrics.diskUsedBytes / metrics.diskTotalBytes) * 100 : 0;\n const hasGpu = metrics.gpuUtilPct !== null;\n const gpuMemLabel = metrics.gpuMemBytes !== null ? formatBytes(metrics.gpuMemBytes) : null;\n // Memory & disk are honest used/total ratios → full-width meters; stack them in\n // the dock detail, two-up in the dashboard row.\n const ratioGridClass = density === \"full\" ? \"grid-cols-1\" : \"grid-cols-1 sm:grid-cols-2\";\n\n return (\n <div className={cn(\"flex flex-col gap-3\", className)} data-machine-metrics>\n {/* Resources — used/total ratios with real 0..100% bars. */}\n <div className={cn(\"grid gap-x-4 gap-y-2.5\", ratioGridClass)}>\n <Meter\n label=\"Memory\"\n value={`${formatBytes(metrics.memUsedBytes)} / ${formatBytes(metrics.memTotalBytes)}`}\n fillPct={memPct}\n tone={toneFor(memPct)}\n />\n <Meter\n label=\"Disk\"\n value={`${formatBytes(metrics.diskUsedBytes)} / ${formatBytes(metrics.diskTotalBytes)}`}\n fillPct={diskPct}\n tone={toneFor(diskPct)}\n />\n </div>\n\n {/* Utilization — CPU% (and GPU% when present) as honest percent gauges. */}\n <div className=\"grid grid-cols-2 gap-x-4 gap-y-2.5\">\n <Meter\n label=\"CPU\"\n value={`${metrics.cpuPct.toFixed(0)}%`}\n fillPct={metrics.cpuPct}\n tone={toneFor(metrics.cpuPct)}\n />\n {hasGpu ? (\n <Meter\n label=\"GPU\"\n value={gpuMemLabel ? `${metrics.gpuUtilPct!.toFixed(0)}% · ${gpuMemLabel}` : `${metrics.gpuUtilPct!.toFixed(0)}%`}\n fillPct={metrics.gpuUtilPct!}\n tone={toneFor(metrics.gpuUtilPct!)}\n />\n ) : null}\n </div>\n\n {/* Activity — load average as labeled mini-stats (no fake bar) + run queue. */}\n <StatTriple\n load1={metrics.load1}\n load5={metrics.load5}\n load15={metrics.load15}\n runQueue={metrics.runQueue}\n />\n </div>\n );\n}\n","import {\n CpuIcon,\n LaptopIcon,\n MonitorIcon,\n MonitorOffIcon,\n ServerIcon,\n UsersIcon,\n} from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { formatRelativeTime } from \"../lib/format\";\nimport type { MachineView } from \"../types/machines\";\nimport { MachineMetrics } from \"./machine-metrics\";\nimport { MachineStatusPill } from \"./machine-status-pill\";\n\nexport type MachineCardProps = {\n machine: MachineView;\n /** Attach/swap the session's active sandbox to this machine. */\n onAttach?: ((machine: MachineView) => void) | undefined;\n /** Whether an attach/swap is currently in flight (disables the affordance). */\n attaching?: boolean | undefined;\n className?: string | undefined;\n};\n\nfunction KindIcon({ machine }: { machine: MachineView }) {\n if (machine.isSessionGroup) return <ServerIcon className=\"size-4 text-og-fg-subtle\" aria-hidden />;\n if (machine.kind === \"modal\") return <CpuIcon className=\"size-4 text-og-fg-subtle\" aria-hidden />;\n return <LaptopIcon className=\"size-4 text-og-fg-subtle\" aria-hidden />;\n}\n\n/**\n * One machine in the Machines dashboard: name + kind + OS/arch, the composite\n * connection/state/shared status, latest resource meters, last-seen recency, and\n * an attach/swap affordance. The session's currently-active sandbox carries an\n * accent edge + an \"Active\" marker (never an attach button — it's already active).\n */\nexport function MachineCard({ machine, onAttach, attaching, className }: MachineCardProps) {\n const offline = machine.state === \"offline\";\n const attachable = !machine.active && !offline && Boolean(onAttach);\n const shared = machine.sharedSessionCount > 1;\n\n return (\n <div\n data-machine-card={machine.sandboxId}\n data-active={machine.active ? \"true\" : \"false\"}\n className={cn(\n \"og-root relative flex flex-col gap-3 overflow-hidden rounded-og-lg border border-og-border\",\n \"bg-og-surface-1 p-4 shadow-og-sm\",\n machine.active && \"border-og-accent/40\",\n className,\n )}\n >\n {machine.active ? (\n <span aria-hidden className=\"absolute inset-y-0 left-0 w-0.5 bg-og-accent\" />\n ) : null}\n\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"flex min-w-0 items-start gap-2.5\">\n <span className=\"mt-0.5 shrink-0\">\n <KindIcon machine={machine} />\n </span>\n <div className=\"min-w-0\">\n <div className=\"flex items-center gap-2\">\n <span className=\"truncate text-sm font-medium text-og-fg\">{machine.name}</span>\n {machine.active ? (\n <span\n data-active-marker\n className=\"shrink-0 rounded-full border border-og-accent/30 bg-og-accent-soft px-1.5 py-px text-[10px] font-medium text-og-accent\"\n >\n Active\n </span>\n ) : null}\n </div>\n <div className=\"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-og-fg-subtle\">\n <span className=\"capitalize\">{machine.isSessionGroup ? \"session sandbox\" : machine.kind}</span>\n <span aria-hidden>·</span>\n <span className=\"font-og-mono\">\n {machine.os}/{machine.arch}\n </span>\n <span aria-hidden>·</span>\n <span className=\"inline-flex items-center gap-1\">\n {machine.hasDisplay ? (\n <MonitorIcon className=\"size-3\" aria-hidden />\n ) : (\n <MonitorOffIcon className=\"size-3\" aria-hidden />\n )}\n {machine.hasDisplay ? \"display\" : \"headless\"}\n </span>\n </div>\n </div>\n </div>\n <MachineStatusPill state={machine.state} sharedSessionCount={machine.sharedSessionCount} size=\"sm\" className=\"shrink-0\" />\n </div>\n\n {shared ? (\n <p\n data-shared-disclosure\n className=\"flex items-center gap-1.5 rounded-og-md border border-og-accent/25 bg-og-accent-soft px-2.5 py-1.5 text-[11px] text-og-fg-muted\"\n >\n <UsersIcon className=\"size-3.5 shrink-0 text-og-accent\" aria-hidden />\n Shared — {machine.sharedSessionCount} sessions are on this machine.\n </p>\n ) : null}\n\n <MachineMetrics metrics={machine.metrics} />\n\n <div className=\"mt-1 flex items-center justify-between gap-3 text-[11px] text-og-fg-subtle\">\n <span>\n {machine.lastSeenAt ? <>Last seen {formatRelativeTime(machine.lastSeenAt)}</> : \"Never connected\"}\n </span>\n {machine.active ? (\n <span className=\"text-og-accent\">Routing here</span>\n ) : attachable ? (\n <button\n type=\"button\"\n data-attach\n disabled={attaching}\n onClick={() => onAttach?.(machine)}\n className={cn(\n \"rounded-og-sm border border-og-border px-2.5 py-1 text-[11px] font-medium text-og-fg-muted transition-colors\",\n \"hover:border-og-border-strong hover:text-og-fg disabled:cursor-not-allowed disabled:opacity-50\",\n )}\n >\n {attaching ? \"Switching…\" : \"Attach\"}\n </button>\n ) : (\n <span className=\"text-og-fg-subtle/70\">{offline ? \"Unavailable\" : \"—\"}</span>\n )}\n </div>\n </div>\n );\n}\n","import { type ReactNode } from \"react\";\nimport { LaptopIcon, PlusIcon, RefreshCwIcon } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport type { MachineView } from \"../types/machines\";\nimport { MachineCard } from \"./machine-card\";\n\nexport type MachinesDashboardProps = {\n machines: MachineView[];\n /** The session's active sandbox id (drives the per-card \"Active\" marker). */\n activeSandboxId?: string | null | undefined;\n loading?: boolean | undefined;\n error?: Error | null | undefined;\n /** Attach/swap the session's active sandbox to a machine. */\n onAttach?: ((machine: MachineView) => void) | undefined;\n /** The sandbox id currently being attached/swapped to (disables that card). */\n attachingSandboxId?: string | null | undefined;\n /** Open the enrollment flow (the \"Enroll a machine\" CTA). */\n onEnroll?: (() => void) | undefined;\n onRefresh?: (() => void) | undefined;\n className?: string | undefined;\n};\n\nfunction EmptyState({ onEnroll }: { onEnroll?: (() => void) | undefined }) {\n return (\n <div\n data-machines-empty\n className=\"flex flex-col items-center justify-center gap-3 rounded-og-lg border border-dashed border-og-border bg-og-surface-1 px-6 py-12 text-center\"\n >\n <span className=\"flex size-10 items-center justify-center rounded-full bg-og-surface-2 text-og-fg-subtle\">\n <LaptopIcon className=\"size-5\" aria-hidden />\n </span>\n <div className=\"space-y-1\">\n <p className=\"text-sm font-medium text-og-fg\">No machines yet</p>\n <p className=\"max-w-xs text-[12px] text-og-fg-muted\">\n Enroll your own computer to run the agent on it — your files, your terminal, your desktop.\n </p>\n </div>\n {onEnroll ? (\n <button\n type=\"button\"\n data-enroll-cta\n onClick={onEnroll}\n className=\"inline-flex items-center gap-1.5 rounded-og-sm bg-og-accent px-3 py-1.5 text-xs font-medium text-og-accent-fg transition-colors hover:bg-og-accent-strong\"\n >\n <PlusIcon className=\"size-3.5\" aria-hidden />\n Enroll a machine\n </button>\n ) : null}\n </div>\n );\n}\n\nfunction Header({\n count,\n onEnroll,\n onRefresh,\n}: {\n count: number;\n onEnroll?: (() => void) | undefined;\n onRefresh?: (() => void) | undefined;\n}): ReactNode {\n return (\n <div className=\"flex items-center justify-between gap-3\">\n <div className=\"flex items-baseline gap-2\">\n <h2 className=\"text-sm font-semibold text-og-fg\">Machines</h2>\n <span className=\"font-og-mono text-[11px] text-og-fg-subtle\">{count}</span>\n </div>\n <div className=\"flex items-center gap-1.5\">\n {onRefresh ? (\n <button\n type=\"button\"\n data-refresh\n onClick={onRefresh}\n title=\"Refresh\"\n className=\"rounded-og-sm p-1.5 text-og-fg-subtle transition-colors hover:bg-og-surface-2 hover:text-og-fg\"\n >\n <RefreshCwIcon className=\"size-3.5\" aria-hidden />\n </button>\n ) : null}\n {onEnroll ? (\n <button\n type=\"button\"\n data-enroll-cta\n onClick={onEnroll}\n className=\"inline-flex items-center gap-1.5 rounded-og-sm border border-og-border px-2.5 py-1 text-xs font-medium text-og-fg-muted transition-colors hover:border-og-border-strong hover:text-og-fg\"\n >\n <PlusIcon className=\"size-3.5\" aria-hidden />\n Enroll\n </button>\n ) : null}\n </div>\n </div>\n );\n}\n\n/**\n * The workspace Machines dashboard: the fleet of selfhosted enrollments + the\n * session's Modal sandbox, each with its connection-status pill, state badges,\n * latest metrics, and an attach/swap affordance. Renders the empty state (no\n * machines → enroll CTA), a load error, and the populated grid. The component\n * is purely presentational — feed it `MachinesResponse` data via `useMachines`.\n */\nexport function MachinesDashboard({\n machines,\n activeSandboxId,\n loading,\n error,\n onAttach,\n attachingSandboxId,\n onEnroll,\n onRefresh,\n className,\n}: MachinesDashboardProps) {\n const isEmpty = !loading && !error && machines.length === 0;\n\n return (\n <section data-machines-dashboard className={cn(\"og-root flex flex-col gap-3\", className)}>\n <Header count={machines.length} onEnroll={onEnroll} onRefresh={onRefresh} />\n\n {error ? (\n <p\n data-machines-error\n className=\"rounded-og-md border border-og-status-failed/30 bg-og-status-failed/10 px-3 py-2 text-[12px] text-og-status-failed\"\n >\n Could not load machines: {error.message}\n </p>\n ) : null}\n\n {loading && machines.length === 0 ? (\n <div data-machines-loading className=\"grid gap-3 sm:grid-cols-2\">\n {[0, 1].map((i) => (\n <div key={i} className=\"h-36 animate-og-pulse rounded-og-lg border border-og-border bg-og-surface-1\" />\n ))}\n </div>\n ) : isEmpty ? (\n <EmptyState onEnroll={onEnroll} />\n ) : (\n <div className=\"grid gap-3 sm:grid-cols-2 xl:grid-cols-3\" data-machines-grid>\n {machines.map((machine) => (\n <MachineCard\n key={machine.sandboxId}\n machine={{ ...machine, active: machine.active || machine.sandboxId === activeSandboxId }}\n onAttach={onAttach}\n attaching={attachingSandboxId === machine.sandboxId}\n />\n ))}\n </div>\n )}\n </section>\n );\n}\n","import { LaptopIcon, CpuIcon, UsersIcon } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport type { MachineKind, MachineState } from \"../types/machines\";\nimport { ConnectionStatusPill, MACHINE_STATE_BADGE_META } from \"./machine-status-pill\";\nimport { connectionStatusForState } from \"../types/machines\";\n\nexport type MachineDockBarProps = {\n /** The active machine's display name. */\n name: string;\n kind: MachineKind;\n state: MachineState;\n /** Live sessions sharing this whole-machine lease (>1 ⇒ shared disclosure). */\n sharedSessionCount?: number | undefined;\n className?: string | undefined;\n};\n\n/**\n * A slim bar that surfaces WHICH machine the dock surfaces (Files/Terminal/\n * Desktop) are bound to + its connection status. Mounted above the dock tabs so\n * the user always knows whether they are looking at the Modal box or their own\n * machine, and whether it is online / reconnecting / offline. The surfaces below\n * render IDENTICALLY regardless of backend — this bar is the only backend-aware\n * chrome (the dock-parity contract: selfhosted == Modal for the surfaces).\n */\nexport function MachineDockBar({ name, kind, state, sharedSessionCount, className }: MachineDockBarProps) {\n const Icon = kind === \"selfhosted\" ? LaptopIcon : CpuIcon;\n const stateBadge = MACHINE_STATE_BADGE_META[state];\n const shared = (sharedSessionCount ?? 0) > 1;\n return (\n <div\n data-machine-dock-bar\n className={cn(\n \"flex shrink-0 items-center justify-between gap-2 border-b border-og-border bg-og-surface-1 px-2.5 py-1\",\n className,\n )}\n >\n <div className=\"flex min-w-0 items-center gap-1.5\">\n <Icon className=\"size-3.5 shrink-0 text-og-fg-subtle\" aria-hidden />\n <span className=\"truncate text-[11px] font-medium text-og-fg\">{name}</span>\n {stateBadge ? (\n <span\n data-state-badge={state}\n className={cn(\"shrink-0 rounded-full border px-1.5 py-px text-[10px] font-medium\", stateBadge.badgeClassName)}\n >\n {stateBadge.label}\n </span>\n ) : null}\n </div>\n <ConnectionStatusPill status={connectionStatusForState(state)} size=\"sm\" className=\"shrink-0\" />\n </div>\n );\n}\n\nexport type SharedMachineDisclosureProps = {\n sharedSessionCount: number;\n /** Compact (inline strip) vs full (a notice block). */\n density?: \"compact\" | \"full\" | undefined;\n className?: string | undefined;\n};\n\n/**\n * The \"shared — another session is on this machine\" disclosure. Surfaced in the\n * dock (and reused on the desktop take-control gate) so the user knows others are\n * driving the same whole-machine lease. Render when `sharedSessionCount > 1`.\n */\nexport function SharedMachineDisclosure({ sharedSessionCount, density = \"compact\", className }: SharedMachineDisclosureProps) {\n const others = Math.max(0, sharedSessionCount - 1);\n return (\n <div\n data-shared-disclosure\n className={cn(\n \"flex items-center gap-1.5 border-og-accent/25 bg-og-accent-soft text-og-fg-muted\",\n density === \"full\" ? \"rounded-og-md border px-3 py-2 text-[12px]\" : \"border-b px-2.5 py-1 text-[11px]\",\n className,\n )}\n >\n <UsersIcon className=\"size-3.5 shrink-0 text-og-accent\" aria-hidden />\n <span>\n Shared — {others === 1 ? \"another session is\" : `${others} other sessions are`} on this machine. They see the same\n terminal, files, and desktop.\n </span>\n </div>\n );\n}\n","import { type ReactNode } from \"react\";\nimport { CopyIcon, ExternalLinkIcon, LaptopIcon, TerminalIcon } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport type { MachineState } from \"../types/machines\";\nimport { ConnectionStatusPill } from \"./machine-status-pill\";\n\n/** The poll state of an in-flight device-flow enrollment. */\nexport type DeviceFlowPhase = \"pending\" | \"authorized\" | \"denied\" | \"expired\" | \"disabled\";\n\nexport type EnrollmentDeviceFlowProps = {\n /** The short user code the agent printed (shown big for the human to confirm). */\n userCode: string;\n /** Where the user approves — the same-origin device page. */\n verificationUri: string;\n /** The complete URI (code pre-filled) for a one-click / QR open. */\n verificationUriComplete?: string | undefined;\n /** The install one-liner the user ran (echoed for context). Optional. */\n installCommand?: string | undefined;\n phase?: DeviceFlowPhase | undefined;\n /** Seconds remaining before the code expires (drives a quiet countdown). */\n expiresInSeconds?: number | undefined;\n onCopyCode?: (() => void) | undefined;\n onCopyInstall?: (() => void) | undefined;\n onOpenVerification?: (() => void) | undefined;\n className?: string | undefined;\n};\n\nconst PHASE_TO_STATE: Record<DeviceFlowPhase, MachineState> = {\n pending: \"enrolling\",\n authorized: \"online\",\n denied: \"offline\",\n expired: \"offline\",\n disabled: \"offline\",\n};\n\nfunction PhaseLabel({ phase }: { phase: DeviceFlowPhase }): ReactNode {\n const text: Record<DeviceFlowPhase, string> = {\n pending: \"Waiting for approval\",\n authorized: \"Connected\",\n denied: \"Denied\",\n expired: \"Code expired\",\n disabled: \"Enrollment disabled\",\n };\n return <span>{text[phase]}</span>;\n}\n\n/**\n * The IN-SESSION device-flow panel: the agent (after the install one-liner) prints\n * a short `userCode` + a `verificationUri`; this surfaces them so the user can open\n * the approve page and confirm the code. Polls in the caller; this renders the\n * pending → authorized/denied/expired progression with a connection pill. This is\n * the FIRST step of the IA flow (device-flow → Machines list → attach/swap).\n */\nexport function EnrollmentDeviceFlow({\n userCode,\n verificationUri,\n verificationUriComplete,\n installCommand,\n phase = \"pending\",\n expiresInSeconds,\n onCopyCode,\n onCopyInstall,\n onOpenVerification,\n className,\n}: EnrollmentDeviceFlowProps) {\n const href = verificationUriComplete ?? verificationUri;\n // Before the one-liner runs the caller passes a placeholder (dashes) for the\n // code — surface that as an explicit waiting state rather than dashes that look\n // like a real code to type.\n const codeIsPlaceholder = !/[A-Za-z0-9]/.test(userCode);\n const awaitingCode = phase === \"pending\" && codeIsPlaceholder;\n return (\n <div\n data-enrollment-device-flow\n className={cn(\n \"og-root flex w-full max-w-md flex-col gap-4 rounded-og-lg border border-og-border bg-og-surface-1 p-5 shadow-og-sm\",\n className,\n )}\n >\n <div className=\"flex items-center justify-between gap-3\">\n <div className=\"flex items-center gap-2\">\n <span className=\"flex size-7 items-center justify-center rounded-full bg-og-surface-2 text-og-fg-muted\">\n <LaptopIcon className=\"size-4\" aria-hidden />\n </span>\n <h2 className=\"text-sm font-semibold text-og-fg\">Connect a machine</h2>\n </div>\n <ConnectionStatusPill\n status={\n PHASE_TO_STATE[phase] === \"online\"\n ? \"online\"\n : PHASE_TO_STATE[phase] === \"offline\"\n ? \"offline\"\n : \"reconnecting\"\n }\n label={(<PhaseLabel phase={phase} />) as unknown as string}\n size=\"sm\"\n />\n </div>\n\n {installCommand ? (\n <div className=\"flex flex-col gap-1.5\">\n <span className=\"text-[11px] font-medium uppercase tracking-wide text-og-fg-subtle\">1 · Run on the machine</span>\n <div className=\"flex items-center justify-between gap-2 overflow-hidden rounded-og-md border border-og-border bg-og-bg px-2.5 py-1.5\">\n <code className=\"flex min-w-0 items-center gap-2 overflow-x-auto font-og-mono text-[12px] text-og-fg\">\n <TerminalIcon className=\"size-3.5 shrink-0 text-og-fg-subtle\" aria-hidden />\n {installCommand}\n </code>\n <button\n type=\"button\"\n data-copy-install\n onClick={onCopyInstall}\n title=\"Copy command\"\n className=\"shrink-0 rounded-og-sm p-1.5 text-og-fg-subtle transition-colors hover:bg-og-surface-2 hover:text-og-fg\"\n >\n <CopyIcon className=\"size-4\" aria-hidden />\n </button>\n </div>\n </div>\n ) : null}\n\n <div className=\"flex flex-col gap-1.5\">\n <span className=\"text-[11px] font-medium uppercase tracking-wide text-og-fg-subtle\">\n {installCommand ? \"2 · Approve the machine\" : \"Approve the machine\"}\n </span>\n <div className=\"flex items-center justify-between gap-3 rounded-og-md border border-og-border bg-og-bg px-3 py-2.5\">\n {awaitingCode ? (\n <span data-user-code className=\"font-og-mono text-[13px] text-og-fg-subtle\">\n Run the command above — your code appears here\n </span>\n ) : (\n <span\n data-user-code\n className=\"select-all font-og-mono text-2xl font-semibold tracking-[0.25em] text-og-fg\"\n >\n {userCode}\n </span>\n )}\n <button\n type=\"button\"\n data-copy-code\n onClick={onCopyCode}\n disabled={awaitingCode}\n title=\"Copy code\"\n className=\"shrink-0 rounded-og-sm p-1.5 text-og-fg-subtle transition-colors hover:bg-og-surface-2 hover:text-og-fg disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-og-fg-subtle\"\n >\n <CopyIcon className=\"size-4\" aria-hidden />\n </button>\n </div>\n </div>\n\n <a\n href={href}\n data-open-verification\n target=\"_blank\"\n rel=\"noreferrer\"\n onClick={onOpenVerification}\n className=\"inline-flex items-center justify-center gap-1.5 rounded-og-sm bg-og-accent px-3 py-2 text-sm font-medium text-og-accent-fg transition-colors hover:bg-og-accent-strong\"\n >\n Open approval page\n <ExternalLinkIcon className=\"size-3.5\" aria-hidden />\n </a>\n\n <p className=\"text-center text-[11px] text-og-fg-subtle\">\n {awaitingCode ? (\n <>\n The one-liner prints a short code. Open{\" \"}\n <span className=\"font-og-mono text-og-fg-muted\">{verificationUri}</span> and confirm the code shown there\n matches.\n </>\n ) : (\n <>\n Confirm code <span className=\"font-og-mono text-og-fg-muted\">{userCode}</span> — the one printed by the\n one-liner — at <span className=\"font-og-mono text-og-fg-muted\">{verificationUri}</span>.\n {typeof expiresInSeconds === \"number\" ? (\n <> Expires in {Math.max(0, Math.round(expiresInSeconds / 60))} min.</>\n ) : null}\n </>\n )}\n </p>\n </div>\n );\n}\n","import { type ReactNode, useState } from \"react\";\nimport {\n CircleAlertIcon,\n LaptopIcon,\n MonitorIcon,\n ScreenShareIcon,\n ShieldAlertIcon,\n TerminalIcon,\n UsersIcon,\n} from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\n\n/** The machine identity surfaced to the approver, from the device-flow start. */\nexport type EnrollmentConsentMachine = {\n /** Human-friendly name (hostname by default). */\n machineName: string;\n os: string;\n arch: string;\n /** The agent can offer a display (a real screen / Xvfb is available). */\n canOfferDisplay: boolean;\n /** The agent requests screen control (computer-use). */\n requestsScreenControl: boolean;\n};\n\n/** The phase of the approve page (drives the rendered panel). */\nexport type EnrollmentConsentPhase = \"review\" | \"approving\" | \"approved\" | \"denied\" | \"error\";\n\nexport type EnrollmentConsentProps = {\n /** The short code the user typed / scanned (echoed back for confirmation). */\n userCode: string;\n machine: EnrollmentConsentMachine;\n phase?: EnrollmentConsentPhase | undefined;\n /** Approve with the chosen screen-control consent. */\n onApprove?: ((allowScreenControl: boolean) => void) | undefined;\n onDeny?: (() => void) | undefined;\n /** Error message when phase === \"error\". */\n errorMessage?: string | undefined;\n className?: string | undefined;\n};\n\nfunction Capability({ icon, title, body }: { icon: ReactNode; title: string; body: string }) {\n return (\n <li className=\"flex items-start gap-2.5\">\n <span className=\"mt-0.5 shrink-0 text-og-status-failed\">{icon}</span>\n <span className=\"min-w-0\">\n <span className=\"block text-[13px] font-medium text-og-fg\">{title}</span>\n <span className=\"block text-[12px] text-og-fg-muted\">{body}</span>\n </span>\n </li>\n );\n}\n\n/**\n * The user-facing APPROVE page for the device-flow enrollment: a LOUD,\n * un-minimised whole-machine consent. Approving grants the agent FULL access to\n * this machine — exec, files, terminal — and (when toggled) live screen control.\n * The danger framing is deliberate (§18 hardening: whole-machine = loud consent),\n * never buried. Renders review / approving / approved / denied / error phases.\n */\nexport function EnrollmentConsent({\n userCode,\n machine,\n phase = \"review\",\n onApprove,\n onDeny,\n errorMessage,\n className,\n}: EnrollmentConsentProps) {\n const [allowScreenControl, setAllowScreenControl] = useState(machine.requestsScreenControl);\n const busy = phase === \"approving\";\n\n if (phase === \"approved\") {\n return (\n <ConsentResult\n className={className}\n tone=\"ok\"\n title=\"Machine connected\"\n body={`${machine.machineName} is now enrolled in this workspace. You can close this page — it will appear in your Machines dashboard.`}\n />\n );\n }\n if (phase === \"denied\") {\n return (\n <ConsentResult\n className={className}\n tone=\"muted\"\n title=\"Enrollment denied\"\n body={`You declined to connect ${machine.machineName}. The agent has no access to this machine. You can re-run the install one-liner to try again.`}\n />\n );\n }\n if (phase === \"error\") {\n return (\n <ConsentResult\n className={className}\n tone=\"danger\"\n title=\"Could not complete enrollment\"\n body={errorMessage ?? \"The code may have expired. Re-run the install one-liner on the machine for a fresh code.\"}\n />\n );\n }\n\n return (\n <div\n data-enrollment-consent\n className={cn(\n \"og-root mx-auto flex w-full max-w-md flex-col gap-5 rounded-og-lg border border-og-status-failed/30 bg-og-surface-1 p-6 shadow-og-md\",\n className,\n )}\n >\n <div className=\"flex items-start gap-3\">\n <span className=\"flex size-9 shrink-0 items-center justify-center rounded-full bg-og-status-failed/15 text-og-status-failed\">\n <ShieldAlertIcon className=\"size-5\" aria-hidden />\n </span>\n <div className=\"min-w-0\">\n <h1 className=\"text-base font-semibold text-og-fg\">Give the agent your whole machine?</h1>\n <p className=\"mt-1 text-[13px] text-og-fg-muted\">\n Approving lets the OpenGeni agent run on <span className=\"font-medium text-og-fg\">{machine.machineName}</span> with\n full access. This is your real computer — not a sandbox.\n </p>\n </div>\n </div>\n\n <div className=\"flex flex-wrap items-center gap-2 rounded-og-md border border-og-border bg-og-surface-2 px-3 py-2 text-[12px]\">\n <LaptopIcon className=\"size-4 text-og-fg-subtle\" aria-hidden />\n <span className=\"font-medium text-og-fg\">{machine.machineName}</span>\n <span className=\"font-og-mono text-og-fg-subtle\">\n {machine.os}/{machine.arch}\n </span>\n <span aria-hidden className=\"text-og-fg-subtle\">·</span>\n <span className=\"text-og-fg-subtle\">\n code <span className=\"font-og-mono font-medium text-og-fg\">{userCode}</span>\n </span>\n </div>\n\n <ul className=\"flex flex-col gap-3\">\n <Capability\n icon={<TerminalIcon className=\"size-4\" aria-hidden />}\n title=\"Read, write & run anything\"\n body=\"The agent can read and modify any file, run any command, and use your git credentials — as if it were you at the keyboard.\"\n />\n {machine.canOfferDisplay ? (\n <Capability\n icon={<MonitorIcon className=\"size-4\" aria-hidden />}\n title=\"See your screen\"\n body=\"The agent can capture this machine's display to watch what it is doing.\"\n />\n ) : null}\n <Capability\n icon={<UsersIcon className=\"size-4\" aria-hidden />}\n title=\"Shared while connected\"\n body=\"Any session in this workspace can use this machine while it is online. Disconnect the agent to revoke access instantly.\"\n />\n </ul>\n\n {machine.canOfferDisplay ? (\n <label\n data-screen-control-toggle\n className=\"flex cursor-pointer items-start gap-3 rounded-og-md border border-og-border bg-og-bg px-3 py-2.5\"\n >\n <input\n type=\"checkbox\"\n checked={allowScreenControl}\n disabled={busy}\n onChange={(e) => setAllowScreenControl(e.target.checked)}\n className=\"mt-0.5 size-4 accent-[var(--og-color-accent)]\"\n />\n <span className=\"min-w-0\">\n <span className=\"flex items-center gap-1.5 text-[13px] font-medium text-og-fg\">\n <ScreenShareIcon className=\"size-3.5 text-og-fg-muted\" aria-hidden />\n Also let the agent control my mouse & keyboard\n </span>\n <span className=\"mt-0.5 block text-[12px] text-og-fg-muted\">\n Optional. Enables computer-use — the agent can move the pointer, type, and click on this machine's desktop. Leave\n off to let it only watch.\n </span>\n </span>\n </label>\n ) : (\n <p className=\"flex items-start gap-2 rounded-og-md border border-og-border bg-og-bg px-3 py-2 text-[12px] text-og-fg-muted\">\n <CircleAlertIcon className=\"mt-px size-3.5 shrink-0 text-og-fg-subtle\" aria-hidden />\n This machine has no display, so screen control isn't available — files, terminal, and git only.\n </p>\n )}\n\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n data-deny\n disabled={busy}\n onClick={() => onDeny?.()}\n className=\"flex-1 rounded-og-sm border border-og-border px-3 py-2 text-sm font-medium text-og-fg-muted transition-colors hover:border-og-border-strong hover:text-og-fg disabled:opacity-50\"\n >\n Cancel\n </button>\n <button\n type=\"button\"\n data-approve\n disabled={busy}\n onClick={() => onApprove?.(allowScreenControl)}\n className=\"flex-1 rounded-og-sm bg-og-status-failed px-3 py-2 text-sm font-semibold text-white transition-colors hover:opacity-90 disabled:opacity-50\"\n >\n {busy ? \"Connecting…\" : \"Grant full access\"}\n </button>\n </div>\n </div>\n );\n}\n\nfunction ConsentResult({\n tone,\n title,\n body,\n className,\n}: {\n tone: \"ok\" | \"muted\" | \"danger\";\n title: string;\n body: string;\n className?: string | undefined;\n}) {\n const ring =\n tone === \"ok\"\n ? \"border-og-status-running/30\"\n : tone === \"danger\"\n ? \"border-og-status-failed/30\"\n : \"border-og-border\";\n const iconClass =\n tone === \"ok\" ? \"text-og-status-running\" : tone === \"danger\" ? \"text-og-status-failed\" : \"text-og-fg-subtle\";\n return (\n <div\n data-enrollment-result={tone}\n className={cn(\n \"og-root mx-auto flex w-full max-w-md flex-col items-center gap-3 rounded-og-lg border bg-og-surface-1 p-6 text-center shadow-og-md\",\n ring,\n className,\n )}\n >\n <span className={cn(\"flex size-10 items-center justify-center rounded-full bg-og-surface-2\", iconClass)}>\n <LaptopIcon className=\"size-5\" aria-hidden />\n </span>\n <h1 className=\"text-base font-semibold text-og-fg\">{title}</h1>\n <p className=\"max-w-sm text-[13px] text-og-fg-muted\">{body}</p>\n </div>\n );\n}\n","import { useCallback, useState } from \"react\";\nimport { useOpenGeni, type ClientOverride } from \"../provider\";\nimport { useMutationRunner, usePolledValue } from \"./internal\";\nimport type { MachinesResponse, MachineView, MetricSample } from \"../types/machines\";\n\n/**\n * The slice of the SDK client the Machines surface needs. The method NAMES +\n * SIGNATURES match M10's `OpenGeniClient` (`listMachines`, `machineMetricsSeries`)\n * so the real SDK client satisfies this surface DIRECTLY for the read paths — no\n * adapter needed. It is declared structurally (not a hard `OpenGeniClient` Pick)\n * so a test/demo/Geni-frontend client can stand in, keeping the hook dual-consumer\n * safe (works in apps/web AND the separate Geni frontend).\n *\n * The active-sandbox SWAP is now a typed SDK call (`swapActiveSandbox`, the M7\n * user-authenticated REST equivalent of the `sandbox_swap` MCP tool). The real\n * SDK client satisfies it structurally, so the default attach path is wired\n * WHENEVER a sessionId is in scope (the swap is session-scoped). `attachMachine`\n * stays an OPTIONAL escape hatch for a host that wants to supply its own swap\n * adapter; when neither it nor a sessionId is present, attach is a no-op and the\n * card hides the button.\n */\nexport type MachinesClientLike = {\n /** GET /v1/workspaces/:ws/machines — the dashboard list + active pointer. */\n listMachines: (workspaceId: string, options?: { sessionId?: string }) => Promise<MachinesResponse>;\n /** GET .../machines/:enrollmentId/metrics/series — the downsampled history. */\n machineMetricsSeries?: (\n workspaceId: string,\n enrollmentId: string,\n options?: { window?: \"15m\" | \"1h\" | \"6h\" | \"24h\" },\n ) => Promise<MetricSample[]>;\n /**\n * POST .../sessions/:sessionId/active-sandbox — swap the session's active\n * sandbox to a machine. The default swap path; the real SDK client provides it.\n */\n swapActiveSandbox?: (\n workspaceId: string,\n sessionId: string,\n request: { target: string },\n ) => Promise<unknown>;\n /**\n * Host-supplied swap adapter (an escape hatch). When present it wins over the\n * default `swapActiveSandbox` path. Session-scoped, like the swap it backs.\n */\n attachMachine?: (workspaceId: string, sessionId: string, sandboxId: string) => Promise<unknown>;\n};\n\nexport type UseMachinesOptions = ClientOverride & {\n pollIntervalMs?: number | undefined;\n enabled?: boolean | undefined;\n /** Scope the list to a session (adds the synthetic Modal group box + pointer). */\n sessionId?: string | undefined;\n /**\n * Override the client with one implementing `MachinesClientLike`. Defaults to\n * the provider client cast to the surface (the real SDK client satisfies the\n * read paths). An app supplies an adapter to wire `attachMachine` (the swap).\n */\n machinesClient?: MachinesClientLike | undefined;\n};\n\nexport type UseMachinesResult = {\n machines: MachineView[];\n activeSandboxId: string | null;\n activeEpoch: number;\n loading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n /** Attach/swap the session's active sandbox to a machine (returns the new pointer). */\n attach: (sandboxId: string) => Promise<boolean>;\n /** Whether the host wired an attach/swap path (drives the card affordance). */\n canAttach: boolean;\n /** Fetch a downsampled metric series for one enrolled machine. */\n fetchSeries: (enrollmentId: string, window?: \"15m\" | \"1h\" | \"6h\" | \"24h\") => Promise<MetricSample[]>;\n attaching: boolean;\n /** The sandbox id of the in-flight attach (for per-card spinner gating). */\n attachingSandboxId: string | null;\n mutationError: Error | null;\n clearMutationError: () => void;\n};\n\nconst EMPTY: MachinesResponse = { activeSandboxId: null, activeEpoch: 0, machines: [] };\n\n/**\n * The workspace Machines fleet: the selfhosted enrollments + the session's Modal\n * box, each with latest metrics + state, plus the active-sandbox pointer. Polls\n * the M10 `GET /machines` endpoint and exposes attach/swap + a metric-series\n * fetch. Renders via `<MachinesDashboard>`. Dual-consumer safe: it reads only the\n * structural `MachinesClientLike` surface, so it works in apps/web AND the Geni\n * frontend (each provides its own client/adapter).\n */\nexport function useMachines(options: UseMachinesOptions = {}): UseMachinesResult {\n const { client, workspaceId } = useOpenGeni(options);\n const machinesClient = (options.machinesClient ?? (client as unknown as MachinesClientLike)) satisfies MachinesClientLike;\n const sessionId = options.sessionId;\n\n const load = useCallback(async () => {\n return await machinesClient.listMachines(workspaceId, sessionId ? { sessionId } : undefined);\n }, [machinesClient, workspaceId, sessionId]);\n\n const state = usePolledValue(load, { pollIntervalMs: options.pollIntervalMs, enabled: options.enabled });\n const mutation = useMutationRunner();\n // The sandbox id of the in-flight attach (drives the per-card spinner).\n const [attachingSandboxId, setAttachingSandboxId] = useState<string | null>(null);\n\n const data = state.data ?? EMPTY;\n // The swap is session-scoped: a host adapter (`attachMachine`) wins; otherwise\n // the default `swapActiveSandbox` path is wired whenever a sessionId is in\n // scope. Either way attach needs a sessionId to point at.\n const canAttach =\n sessionId !== undefined &&\n (typeof machinesClient.attachMachine === \"function\" ||\n typeof machinesClient.swapActiveSandbox === \"function\");\n\n const attach = useCallback(\n async (sandboxId: string): Promise<boolean> => {\n if (sessionId === undefined) return false;\n const runSwap = machinesClient.attachMachine\n ? () => machinesClient.attachMachine!(workspaceId, sessionId, sandboxId)\n : machinesClient.swapActiveSandbox\n ? () => machinesClient.swapActiveSandbox!(workspaceId, sessionId, { target: sandboxId })\n : null;\n if (!runSwap) return false;\n setAttachingSandboxId(sandboxId);\n const result = await mutation.run(async () => {\n await runSwap();\n return true;\n });\n setAttachingSandboxId(null);\n if (result) await state.refresh();\n return result === true;\n },\n [machinesClient, workspaceId, sessionId, mutation.run, state.refresh],\n );\n\n const fetchSeries = useCallback(\n async (enrollmentId: string, window: \"15m\" | \"1h\" | \"6h\" | \"24h\" = \"1h\"): Promise<MetricSample[]> => {\n if (!machinesClient.machineMetricsSeries) return [];\n return await machinesClient.machineMetricsSeries(workspaceId, enrollmentId, { window });\n },\n [machinesClient, workspaceId],\n );\n\n return {\n machines: data.machines,\n activeSandboxId: data.activeSandboxId,\n activeEpoch: data.activeEpoch,\n loading: state.loading,\n error: state.error,\n refresh: state.refresh,\n attach,\n canAttach,\n fetchSeries,\n attaching: mutation.mutating,\n attachingSandboxId,\n mutationError: mutation.mutationError,\n clearMutationError: mutation.clearMutationError,\n };\n}\n","import { createContext, useContext, useMemo, type ReactNode } from \"react\";\nimport type { SessionClientLike } from \"./client\";\n\nexport type OpenGeniContextValue = {\n client: SessionClientLike;\n workspaceId: string;\n};\n\nconst OpenGeniContext = createContext<OpenGeniContextValue | null>(null);\n\nexport type OpenGeniProviderProps = {\n client: SessionClientLike;\n workspaceId: string;\n children?: ReactNode;\n};\n\n/**\n * Supplies the OpenGeni client + workspace to all hooks below it. Hooks also\n * accept `{ client, workspaceId }` overrides per call for multi-workspace UIs.\n */\nexport function OpenGeniProvider({ client, workspaceId, children }: OpenGeniProviderProps) {\n const value = useMemo(() => ({ client, workspaceId }), [client, workspaceId]);\n return <OpenGeniContext.Provider value={value}>{children}</OpenGeniContext.Provider>;\n}\n\nexport type ClientOverride = {\n client?: SessionClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\n/** Resolve client + workspace from explicit overrides or the provider. */\nexport function useOpenGeni(override: ClientOverride = {}): OpenGeniContextValue {\n const context = useContext(OpenGeniContext);\n const client = override.client ?? context?.client;\n const workspaceId = override.workspaceId ?? context?.workspaceId;\n if (!client || !workspaceId) {\n throw new Error(\n \"@opengeni/react: no OpenGeni client/workspace available. Wrap the tree in <OpenGeniProvider> or pass { client, workspaceId } to the hook.\",\n );\n }\n return { client, workspaceId };\n}\n\n/**\n * Resolve the client only — for hooks that are not workspace-scoped\n * (`useWorkspaces`, `useBillingUsage`).\n */\nexport function useOpenGeniClient(override: Pick<ClientOverride, \"client\"> = {}): SessionClientLike {\n const context = useContext(OpenGeniContext);\n const client = override.client ?? context?.client;\n if (!client) {\n throw new Error(\n \"@opengeni/react: no OpenGeni client available. Wrap the tree in <OpenGeniProvider> or pass { client } to the hook.\",\n );\n }\n return client;\n}\n","import type { SessionEvent } from \"@opengeni/sdk\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { SessionClientLike } from \"../client\";\n\nexport type AsyncListState<T> = {\n data: T | null;\n loading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n};\n\n/**\n * Shared fetch + optional polling loop for the list/read hooks. Stale\n * responses (superseded by a newer load or an unmount) are dropped.\n */\nexport function usePolledValue<T>(load: () => Promise<T>, options: { pollIntervalMs?: number | undefined; enabled?: boolean | undefined } = {}): AsyncListState<T> {\n const enabled = options.enabled ?? true;\n const pollIntervalMs = options.pollIntervalMs;\n const [data, setData] = useState<T | null>(null);\n const [loading, setLoading] = useState(enabled);\n const [error, setError] = useState<Error | null>(null);\n const generation = useRef(0);\n const loadRef = useRef(load);\n\n // A new loader identity means a new query (different session/workspace/...):\n // drop the previous result instead of showing it as the new query's data.\n useEffect(() => {\n if (loadRef.current !== load) {\n loadRef.current = load;\n setData(null);\n setError(null);\n }\n }, [load]);\n\n const run = useCallback(async () => {\n const ticket = ++generation.current;\n try {\n const result = await load();\n if (ticket === generation.current) {\n setData(result);\n setError(null);\n setLoading(false);\n }\n } catch (cause) {\n if (ticket === generation.current) {\n setError(cause instanceof Error ? cause : new Error(String(cause)));\n setLoading(false);\n }\n }\n }, [load]);\n\n useEffect(() => {\n if (!enabled) {\n setLoading(false);\n return;\n }\n setLoading(true);\n void run();\n if (pollIntervalMs === undefined || pollIntervalMs <= 0) {\n return () => {\n generation.current += 1;\n };\n }\n const timer = setInterval(() => void run(), pollIntervalMs);\n return () => {\n clearInterval(timer);\n generation.current += 1;\n };\n }, [run, enabled, pollIntervalMs]);\n\n return { data, loading, error, refresh: run };\n}\n\nexport type MutationState = {\n mutating: boolean;\n mutationError: Error | null;\n clearMutationError: () => void;\n};\n\n/**\n * Shared async mutation runner for the write hooks. `run` resolves with the\n * operation's value, or `null` after capturing the error in `mutationError`\n * (callers then roll back optimistic state).\n */\nexport function useMutationRunner(): MutationState & {\n run: <T>(operation: () => Promise<T>) => Promise<T | null>;\n} {\n const [mutating, setMutating] = useState(false);\n const [mutationError, setMutationError] = useState<Error | null>(null);\n const inFlight = useRef(0);\n const mounted = useRef(true);\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n const run = useCallback(async <T,>(operation: () => Promise<T>): Promise<T | null> => {\n inFlight.current += 1;\n if (mounted.current) {\n setMutating(true);\n setMutationError(null);\n }\n try {\n return await operation();\n } catch (cause) {\n if (mounted.current) {\n setMutationError(cause instanceof Error ? cause : new Error(String(cause)));\n }\n return null;\n } finally {\n inFlight.current -= 1;\n if (mounted.current && inFlight.current === 0) {\n setMutating(false);\n }\n }\n }, []);\n return {\n mutating,\n mutationError,\n clearMutationError: useCallback(() => setMutationError(null), []),\n run,\n };\n}\n\nexport type SessionEventFeedOptions = {\n /**\n * Share an existing event log (from `useSessionEvents`) instead of opening\n * a second stream. When omitted the hook tails the session's event stream\n * itself, starting at the current `lastSequence`.\n */\n events?: SessionEvent[] | undefined;\n enabled?: boolean | undefined;\n};\n\n/**\n * Invoke `onEvent` for every session event matching `match` — the live-update\n * primitive behind `useTurnQueue` and `useGoal`. Either watches a shared\n * `events` log or tails the stream directly (reconnect handled by the SDK).\n */\nexport function useSessionEventTrigger(\n client: SessionClientLike,\n workspaceId: string,\n sessionId: string | null | undefined,\n match: (event: SessionEvent) => boolean,\n onEvent: (event: SessionEvent) => void,\n options: SessionEventFeedOptions = {},\n): void {\n const enabled = options.enabled ?? true;\n const events = options.events;\n const sharedFeed = events !== undefined;\n const matchRef = useRef(match);\n matchRef.current = match;\n const onEventRef = useRef(onEvent);\n onEventRef.current = onEvent;\n const consumedRef = useRef(0);\n const feedKeyRef = useRef<string | null>(null);\n\n // Shared-log mode: scan only the unseen tail on every append.\n useEffect(() => {\n if (!sharedFeed || !enabled || !sessionId) {\n return;\n }\n const feedKey = `${workspaceId}\\u0000${sessionId}`;\n const firstSequence = events[0]?.sequence ?? 0;\n // A new session target or a log reset (sequence restarted below the\n // cursor) restarts consumption from the top of the shared log.\n if (feedKeyRef.current !== feedKey || firstSequence > consumedRef.current + 1) {\n feedKeyRef.current = feedKey;\n consumedRef.current = 0;\n }\n for (const event of events) {\n if (event.sequence <= consumedRef.current) {\n continue;\n }\n consumedRef.current = event.sequence;\n if (matchRef.current(event)) {\n onEventRef.current(event);\n }\n }\n }, [sharedFeed, enabled, events, workspaceId, sessionId]);\n\n // Self-stream mode: tail from the session's current lastSequence.\n useEffect(() => {\n if (sharedFeed || !enabled || !sessionId) {\n return;\n }\n const controller = new AbortController();\n void (async () => {\n try {\n const session = await client.getSession(workspaceId, sessionId);\n if (controller.signal.aborted) {\n return;\n }\n const stream = client.streamEvents(workspaceId, sessionId, {\n after: session.lastSequence,\n signal: controller.signal,\n });\n for await (const event of stream) {\n if (matchRef.current(event)) {\n onEventRef.current(event);\n }\n }\n } catch {\n // Live updates are best-effort: the read hooks still expose refresh()\n // and the initial load already populated state.\n }\n })();\n return () => {\n controller.abort();\n };\n }, [sharedFeed, enabled, client, workspaceId, sessionId]);\n}\n\n/** Debounce rapid event bursts into one trailing call (default 150ms). */\nexport function useDebouncedCallback(callback: () => void, delayMs = 150): () => void {\n const callbackRef = useRef(callback);\n callbackRef.current = callback;\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(() => {\n return () => {\n if (timerRef.current !== null) {\n clearTimeout(timerRef.current);\n }\n };\n }, []);\n return useCallback(() => {\n if (timerRef.current !== null) {\n clearTimeout(timerRef.current);\n }\n timerRef.current = setTimeout(() => {\n timerRef.current = null;\n callbackRef.current();\n }, delayMs);\n }, [delayMs]);\n}\n"],"mappings":";AAgDO,SAAS,yBAAyB,OAAuC;AAC9E,UAAQ,OAAO;AAAA,IACb,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAEH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,SAAS;AAEP,YAAM,SAAgB;AACtB,aAAO;AAAA,IACT;AAAA,EACF;AACF;;;AClEA,SAAS,YAA6B;AACtC,SAAS,2BAA2B;AAapC,IAAM,UAAU,oBAAo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ACpB;AAAA,IACA,eAAe,SAAS;AAAA,IACxB,oBAAoB,SAAS;AAAA,EAC/B;AACF;","names":["jsx","jsxs","jsx","jsxs","LaptopIcon","jsx","jsxs","LaptopIcon","LaptopIcon","CpuIcon","UsersIcon","jsx","jsxs","LaptopIcon","CpuIcon","UsersIcon","LaptopIcon","Fragment","jsx","jsxs","LaptopIcon","LaptopIcon","MonitorIcon","TerminalIcon","UsersIcon","jsx","jsxs","LaptopIcon","TerminalIcon","MonitorIcon","UsersIcon","useCallback","useState","jsx","useState","useCallback","useState"]}