@useavalon/caelence-agent 0.2.2-canary.5 → 0.2.2-canary.7

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 (41) hide show
  1. package/desktop/src/App.tsx +226 -74
  2. package/desktop/src/BubbleClip.tsx +58 -0
  3. package/desktop/src/PipelineTrack.tsx +19 -0
  4. package/desktop/src/PlatformPane.tsx +98 -0
  5. package/desktop/src/ReplySources.tsx +267 -0
  6. package/desktop/src/ShimmerPhrase.tsx +71 -0
  7. package/desktop/src/SkillsPanel.tsx +0 -7
  8. package/desktop/src/api.ts +24 -1
  9. package/desktop/src/app.css +906 -47
  10. package/desktop/src/clip.test.ts +16 -0
  11. package/desktop/src/clip.ts +26 -0
  12. package/desktop/src/pipeline.test.ts +86 -0
  13. package/desktop/src/pipeline.ts +131 -0
  14. package/desktop/src/platform.test.ts +30 -0
  15. package/desktop/src/platform.ts +76 -0
  16. package/desktop/src/preview-render.test.ts +79 -0
  17. package/desktop/src/preview-render.ts +254 -0
  18. package/desktop/src/queue.test.ts +18 -1
  19. package/desktop/src/queue.ts +8 -0
  20. package/desktop/src/reply-sources.test.ts +73 -0
  21. package/desktop/src/reply-sources.ts +116 -0
  22. package/desktop/src/rich-text.test.ts +26 -0
  23. package/desktop/src/rich-text.ts +51 -2
  24. package/desktop/src/stream.test.ts +41 -2
  25. package/desktop/src/stream.ts +22 -3
  26. package/desktop/src/styles/primitives.css +6 -3
  27. package/desktop/src/thought.test.ts +65 -18
  28. package/desktop/src/thought.ts +41 -11
  29. package/desktop/src/tool-label.test.ts +12 -0
  30. package/desktop/src/tool-label.ts +28 -0
  31. package/package.json +2 -2
  32. package/src/cli/models.ts +3 -1
  33. package/src/cli/openrouter-live.test.ts +29 -0
  34. package/src/cli/openrouter-live.ts +9 -1
  35. package/src/core/events.ts +1 -0
  36. package/src/core/run-turn.ts +7 -0
  37. package/src/core/session.ts +3 -0
  38. package/src/desktop/bridge.test.ts +51 -0
  39. package/src/desktop/bridge.ts +84 -6
  40. package/src/desktop/preview-kind.test.ts +20 -0
  41. package/src/desktop/preview-kind.ts +29 -0
@@ -1,6 +1,8 @@
1
+ import { ArrowUDownLeftIcon } from "@phosphor-icons/react/dist/csr/ArrowUDownLeft";
1
2
  import { ArrowUpRightIcon } from "@phosphor-icons/react/dist/csr/ArrowUpRight";
2
3
  import { CaretDownIcon } from "@phosphor-icons/react/dist/csr/CaretDown";
3
4
  import { CheckIcon } from "@phosphor-icons/react/dist/csr/Check";
5
+ import { CircleIcon } from "@phosphor-icons/react/dist/csr/Circle";
4
6
  import { FileIcon } from "@phosphor-icons/react/dist/csr/File";
5
7
  import { FolderSimpleIcon } from "@phosphor-icons/react/dist/csr/FolderSimple";
6
8
  import { GearIcon } from "@phosphor-icons/react/dist/csr/Gear";
@@ -67,6 +69,7 @@ import {
67
69
  startTurn,
68
70
  transcribe,
69
71
  } from "./api";
72
+ import { BubbleClip } from "./BubbleClip";
70
73
  import { AttachmentThumbs } from "./ComposerAttach";
71
74
  import {
72
75
  type ComposerAttachment,
@@ -91,15 +94,22 @@ import { FloatNotice } from "./FloatNotice";
91
94
  import { integrationMatches } from "./integration-search";
92
95
  import { LogoMark } from "./LogoMark";
93
96
  import { McpPanel } from "./McpPanel";
97
+ import { PipelineTrack } from "./PipelineTrack";
98
+ import { PlatformPane } from "./PlatformPane";
94
99
  import { pickerKeyAction, pickerStartIndex, stepIndex } from "./picker-nav";
100
+ import { pipelineProgress } from "./pipeline";
101
+ import { formatPlatformOutput, isPlatformTool } from "./platform";
95
102
  import {
96
103
  enqueueMessage,
104
+ promoteQueued,
97
105
  type QueuedMessage,
98
106
  removeQueued,
99
107
  setQueuedText,
100
108
  updateQueued,
101
109
  } from "./queue";
102
- import { canvaViewUrl, splitRichText } from "./rich-text";
110
+ import { ReplySources } from "./ReplySources";
111
+ import { canvaViewUrl, looksLikeWebUrl, splitRichText, webHref } from "./rich-text";
112
+ import { ShimmerPhrase } from "./ShimmerPhrase";
103
113
  import { SkillsPanel } from "./SkillsPanel";
104
114
  import { clampMenuPosition } from "./session-menu";
105
115
  import {
@@ -113,6 +123,7 @@ import {
113
123
  import {
114
124
  type FoldEntry,
115
125
  groupTranscriptLines,
126
+ liveStatusPhrases,
116
127
  type ToolLine,
117
128
  thoughtSummary,
118
129
  thoughtTools,
@@ -460,8 +471,10 @@ export function App(): React.ReactElement {
460
471
  suffix?: string;
461
472
  } | null>(null);
462
473
  const [editingQueuedId, setEditingQueuedId] = useState<string | null>(null);
474
+ const [queueOpen, setQueueOpen] = useState(true);
463
475
  const [notice, setNotice] = useState<{ text: string; id: number } | null>(null);
464
476
  const [attachments, setAttachments] = useState<ComposerAttachment[]>([]);
477
+ const [integrations, setIntegrations] = useState<PublicIntegration[]>([]);
465
478
  const [fileDrag, setFileDrag] = useState(false);
466
479
  const transcriptRef = useRef<HTMLDivElement>(null);
467
480
  const inputRef = useRef<HTMLTextAreaElement>(null);
@@ -543,6 +556,21 @@ export function App(): React.ReactElement {
543
556
  };
544
557
  }, []);
545
558
 
559
+ useEffect(() => {
560
+ if (!bridge) return;
561
+ let cancelled = false;
562
+ void getIntegrations(bridge)
563
+ .then((result) => {
564
+ if (!cancelled) setIntegrations(result.items);
565
+ })
566
+ .catch(() => {
567
+ if (!cancelled) setIntegrations([]);
568
+ });
569
+ return () => {
570
+ cancelled = true;
571
+ };
572
+ }, [bridge]);
573
+
546
574
  useEffect(() => {
547
575
  const node = transcriptRef.current;
548
576
  if (node) node.scrollTop = node.scrollHeight;
@@ -917,6 +945,7 @@ export function App(): React.ReactElement {
917
945
  setView("chat");
918
946
  if (status === "running" || status === "approval" || sendingRef.current) {
919
947
  setQueueSync(enqueueMessage(queueRef.current, toSend, `q-${Date.now()}`, pendingFiles));
948
+ setQueueOpen(true);
920
949
  return;
921
950
  }
922
951
  await sendTurn(toSend, undefined, pendingFiles);
@@ -933,6 +962,20 @@ export function App(): React.ReactElement {
933
962
  takeAttachments,
934
963
  ]);
935
964
 
965
+ const sendQueuedNow = useCallback(
966
+ async (id: string) => {
967
+ const item = queueRef.current.find((row) => row.id === id);
968
+ if (!item || !bridge) return;
969
+ if (status === "running" || status === "approval" || sendingRef.current) {
970
+ setQueueSync(promoteQueued(queueRef.current, id));
971
+ return;
972
+ }
973
+ setQueueSync(removeQueued(queueRef.current, id));
974
+ await sendTurn(item.text, undefined, item.attachments ?? []);
975
+ },
976
+ [bridge, sendTurn, setQueueSync, status],
977
+ );
978
+
936
979
  const stop = useCallback(async () => {
937
980
  if (!bridge) return;
938
981
  await abortTurn(bridge);
@@ -1538,7 +1581,9 @@ export function App(): React.ReactElement {
1538
1581
  <TranscriptLine
1539
1582
  key={line.key}
1540
1583
  line={line}
1584
+ lines={lines}
1541
1585
  bridge={bridge}
1586
+ integrations={integrations}
1542
1587
  editing={
1543
1588
  line.type === "user" && editingUser?.index === line.userTurnIndex
1544
1589
  ? editingUser.text
@@ -1655,64 +1700,25 @@ export function App(): React.ReactElement {
1655
1700
  <footer className="desk-composer">
1656
1701
  {fileDrag ? <p className="desk-composer__drop">Drop files to attach</p> : null}
1657
1702
  {queue.length > 0 ? (
1658
- <ul className="desk-queue" aria-label="Queued messages">
1659
- {queue.map((item) => (
1660
- <li key={item.id} className="desk-queue-item">
1661
- {editingQueuedId === item.id ? (
1662
- <textarea
1663
- className="cel-input desk-compose-input"
1664
- rows={2}
1665
- value={item.text}
1666
- aria-label="Edit queued message"
1667
- onChange={(event) =>
1668
- setQueueSync(
1669
- setQueuedText(queueRef.current, item.id, event.target.value),
1670
- )
1671
- }
1672
- onKeyDown={(event) => {
1673
- if (event.key === "Enter" && !event.shiftKey) {
1674
- event.preventDefault();
1675
- setQueueSync(updateQueued(queueRef.current, item.id, item.text));
1676
- setEditingQueuedId(null);
1677
- }
1678
- if (event.key === "Escape") {
1679
- event.preventDefault();
1680
- setEditingQueuedId(null);
1681
- }
1682
- }}
1683
- onBlur={() => {
1684
- setQueueSync(updateQueued(queueRef.current, item.id, item.text));
1685
- setEditingQueuedId(null);
1686
- }}
1687
- />
1688
- ) : (
1689
- <div className="desk-queue-copy">
1690
- <AttachmentThumbs items={item.attachments ?? []} />
1691
- {item.text ? (
1692
- <button
1693
- type="button"
1694
- className="desk-queue-text"
1695
- onClick={() => setEditingQueuedId(item.id)}
1696
- >
1697
- {item.text}
1698
- </button>
1699
- ) : null}
1700
- </div>
1701
- )}
1702
- <button
1703
- type="button"
1704
- className="cel-btn cel-btn--quiet cel-btn--compact"
1705
- aria-label="Remove from queue"
1706
- onClick={() => {
1707
- if (editingQueuedId === item.id) setEditingQueuedId(null);
1708
- setQueueSync(removeQueued(queueRef.current, item.id));
1709
- }}
1710
- >
1711
- <XIcon size={16} weight="regular" />
1712
- </button>
1713
- </li>
1714
- ))}
1715
- </ul>
1703
+ <QueuePanel
1704
+ queue={queue}
1705
+ open={queueOpen}
1706
+ editingId={editingQueuedId}
1707
+ onToggle={() => setQueueOpen((current) => !current)}
1708
+ onEdit={setEditingQueuedId}
1709
+ onChangeText={(id, text) =>
1710
+ setQueueSync(setQueuedText(queueRef.current, id, text))
1711
+ }
1712
+ onCommitText={(id, text) => {
1713
+ setQueueSync(updateQueued(queueRef.current, id, text));
1714
+ setEditingQueuedId(null);
1715
+ }}
1716
+ onSendNow={(id) => void sendQueuedNow(id)}
1717
+ onRemove={(id) => {
1718
+ if (editingQueuedId === id) setEditingQueuedId(null);
1719
+ setQueueSync(removeQueued(queueRef.current, id));
1720
+ }}
1721
+ />
1716
1722
  ) : null}
1717
1723
  {mediaModels.length > 0 && mediaOpen ? (
1718
1724
  <section className="desk-composer__meta">
@@ -2357,6 +2363,121 @@ function SettingsPanel(
2357
2363
  );
2358
2364
  }
2359
2365
 
2366
+ function QueuePanel(
2367
+ props: Readonly<{
2368
+ queue: QueuedMessage[];
2369
+ open: boolean;
2370
+ editingId: string | null;
2371
+ onToggle: () => void;
2372
+ onEdit: (id: string | null) => void;
2373
+ onChangeText: (id: string, text: string) => void;
2374
+ onCommitText: (id: string, text: string) => void;
2375
+ onSendNow: (id: string) => void;
2376
+ onRemove: (id: string) => void;
2377
+ }>,
2378
+ ): React.ReactElement {
2379
+ const editRef = useRef<HTMLTextAreaElement>(null);
2380
+ const count = props.queue.length;
2381
+ const title = count === 1 ? "1 queued message" : `${count} queued messages`;
2382
+ useEffect(() => {
2383
+ if (props.editingId) editRef.current?.focus();
2384
+ }, [props.editingId]);
2385
+ return (
2386
+ <section className="desk-queue">
2387
+ <button
2388
+ type="button"
2389
+ className="desk-queue__head"
2390
+ aria-expanded={props.open}
2391
+ onClick={props.onToggle}
2392
+ >
2393
+ <CaretDownIcon className="desk-queue__caret" size={12} weight="bold" aria-hidden="true" />
2394
+ {title}
2395
+ </button>
2396
+ {props.open ? (
2397
+ <ul className="desk-queue__list">
2398
+ {props.queue.map((item) => {
2399
+ const editing = props.editingId === item.id;
2400
+ return (
2401
+ <li key={item.id} className={`desk-queue-item${editing ? " is-editing" : ""}`}>
2402
+ <button
2403
+ type="button"
2404
+ className="desk-queue__pick"
2405
+ aria-label="Send now"
2406
+ onClick={() => props.onSendNow(item.id)}
2407
+ >
2408
+ <CircleIcon size={16} weight="regular" aria-hidden="true" />
2409
+ </button>
2410
+ {editing ? (
2411
+ <textarea
2412
+ ref={editRef}
2413
+ className="cel-input desk-compose-input desk-queue__input"
2414
+ rows={2}
2415
+ value={item.text}
2416
+ aria-label="Edit queued message"
2417
+ onChange={(event) => props.onChangeText(item.id, event.target.value)}
2418
+ onKeyDown={(event) => {
2419
+ if (event.key === "Enter" && !event.shiftKey) {
2420
+ event.preventDefault();
2421
+ props.onCommitText(item.id, item.text);
2422
+ }
2423
+ if (event.key === "Escape") {
2424
+ event.preventDefault();
2425
+ props.onEdit(null);
2426
+ }
2427
+ }}
2428
+ onBlur={() => props.onCommitText(item.id, item.text)}
2429
+ />
2430
+ ) : (
2431
+ <div className="desk-queue-copy">
2432
+ <AttachmentThumbs items={item.attachments ?? []} />
2433
+ {item.text ? (
2434
+ <button
2435
+ type="button"
2436
+ className="desk-queue-text"
2437
+ onClick={() => props.onEdit(item.id)}
2438
+ >
2439
+ {item.text}
2440
+ </button>
2441
+ ) : null}
2442
+ </div>
2443
+ )}
2444
+ {editing ? null : (
2445
+ <div className="desk-queue__actions">
2446
+ <button
2447
+ type="button"
2448
+ className="desk-queue__act"
2449
+ onClick={() => props.onSendNow(item.id)}
2450
+ >
2451
+ Send now
2452
+ <ArrowUDownLeftIcon size={12} weight="bold" aria-hidden="true" />
2453
+ </button>
2454
+ <button
2455
+ type="button"
2456
+ className="desk-queue__icon"
2457
+ aria-label="Edit queued message"
2458
+ onClick={() => props.onEdit(item.id)}
2459
+ >
2460
+ <PencilSimpleIcon size={14} weight="regular" />
2461
+ </button>
2462
+ <button
2463
+ type="button"
2464
+ className="desk-queue__icon"
2465
+ aria-label="Remove from queue"
2466
+ onClick={() => props.onRemove(item.id)}
2467
+ >
2468
+ <TrashIcon size={14} weight="regular" />
2469
+ </button>
2470
+ </div>
2471
+ )}
2472
+ </li>
2473
+ );
2474
+ })}
2475
+ </ul>
2476
+ ) : null}
2477
+ </section>
2478
+ );
2479
+ }
2480
+
2360
2481
  function ThoughtFold(
2361
2482
  props: Readonly<{
2362
2483
  entries: FoldEntry[];
@@ -2364,32 +2485,33 @@ function ThoughtFold(
2364
2485
  warmupSeed?: number;
2365
2486
  }>,
2366
2487
  ): React.ReactElement {
2367
- const { entries, live, warmupSeed } = props;
2488
+ const { entries, live } = props;
2368
2489
  const tools = thoughtTools(entries);
2369
2490
  const summary = thoughtSummary(tools, live, {
2370
2491
  warmup: entries.length === 0,
2371
- seed: warmupSeed ?? 0,
2492
+ seed: props.warmupSeed ?? 0,
2372
2493
  });
2494
+ const phrases = live ? liveStatusPhrases(tools, entries.length === 0) : [summary.headline];
2495
+ const pipe = live ? pipelineProgress(tools) : undefined;
2373
2496
  const hasBody = entries.some((entry) =>
2374
2497
  entry.type === "note" ? entry.text.trim().length > 0 : true,
2375
2498
  );
2499
+ const headline = (
2500
+ <span className="desk-thought__copy">
2501
+ <span className="desk-thought__headline">
2502
+ <ShimmerPhrase phrases={phrases} live={live} tone={pipe ? "pipe" : undefined} />
2503
+ </span>
2504
+ {pipe ? <PipelineTrack steps={pipe.steps} /> : null}
2505
+ </span>
2506
+ );
2376
2507
  if (!hasBody) {
2377
2508
  return (
2378
- <p className="desk-thought desk-thought--plain">
2379
- <span className="desk-thought__headline">{summary.headline}</span>
2380
- </p>
2509
+ <p className={`desk-thought desk-thought--plain${pipe ? " is-pipe" : ""}`}>{headline}</p>
2381
2510
  );
2382
2511
  }
2383
2512
  return (
2384
- <details className="desk-thought">
2385
- <summary>
2386
- <span className="desk-thought__copy">
2387
- <span className="desk-thought__headline">{summary.headline}</span>
2388
- {live && summary.activity ? (
2389
- <span className="desk-thought__activity">{summary.activity}</span>
2390
- ) : null}
2391
- </span>
2392
- </summary>
2513
+ <details className={`desk-thought${pipe ? " is-pipe" : ""}`}>
2514
+ <summary>{headline}</summary>
2393
2515
  <div className="desk-thought__body">
2394
2516
  {entries.map((entry) => {
2395
2517
  if (entry.type === "note") {
@@ -2498,7 +2620,11 @@ function UserTranscriptLine(
2498
2620
  ) : (
2499
2621
  <>
2500
2622
  <AttachmentThumbs items={shown.attachments} variant="chat" />
2501
- {shown.text ? <p>{shown.text}</p> : null}
2623
+ {shown.text ? (
2624
+ <BubbleClip text={shown.text}>
2625
+ <p>{shown.text}</p>
2626
+ </BubbleClip>
2627
+ ) : null}
2502
2628
  </>
2503
2629
  )}
2504
2630
  </div>
@@ -2509,7 +2635,9 @@ function UserTranscriptLine(
2509
2635
  function TranscriptLine(
2510
2636
  props: Readonly<{
2511
2637
  line: StreamLine;
2638
+ lines: StreamLine[];
2512
2639
  bridge: BridgeClient | null;
2640
+ integrations: PublicIntegration[];
2513
2641
  editing?: string | null;
2514
2642
  onStartEdit?: () => void;
2515
2643
  onEditChange?: (text: string) => void;
@@ -2543,11 +2671,28 @@ function TranscriptLine(
2543
2671
  onOpenUrl={onOpenUrl}
2544
2672
  onOpenFile={onOpenFile}
2545
2673
  />
2674
+ <ReplySources
2675
+ lines={props.lines}
2676
+ assistantKey={line.key}
2677
+ bridge={bridge}
2678
+ onOpenUrl={onOpenUrl}
2679
+ onOpenFile={onOpenFile}
2680
+ />
2546
2681
  </div>
2547
2682
  </article>
2548
2683
  );
2549
2684
  }
2550
2685
  if (line.type === "tool") {
2686
+ if (isPlatformTool(line.name)) {
2687
+ const body = formatPlatformOutput(line.output ?? "");
2688
+ return (
2689
+ <PlatformPane line={line} integrations={props.integrations}>
2690
+ {body ? (
2691
+ <RichBody text={body} bridge={bridge} onOpenUrl={onOpenUrl} onOpenFile={onOpenFile} />
2692
+ ) : null}
2693
+ </PlatformPane>
2694
+ );
2695
+ }
2551
2696
  const count = eventCountSuffix(line.count);
2552
2697
  return (
2553
2698
  <article className={`desk-line desk-line--event is-${line.status}`}>
@@ -2623,6 +2768,7 @@ function RichBody(
2623
2768
  path={part.path}
2624
2769
  label={part.label}
2625
2770
  onOpenFile={props.onOpenFile}
2771
+ onOpenUrl={props.onOpenUrl}
2626
2772
  />
2627
2773
  );
2628
2774
  }
@@ -2662,8 +2808,14 @@ function FileLink(
2662
2808
  path: string;
2663
2809
  label: string;
2664
2810
  onOpenFile?: (path: string, reveal: boolean) => void;
2811
+ onOpenUrl?: (url: string) => void;
2665
2812
  }>,
2666
2813
  ): React.ReactElement {
2814
+ if (looksLikeWebUrl(props.path)) {
2815
+ return (
2816
+ <ExternalLink href={webHref(props.path)} label={props.label} onOpenUrl={props.onOpenUrl} />
2817
+ );
2818
+ }
2667
2819
  return (
2668
2820
  <span className="desk-file">
2669
2821
  <button
@@ -0,0 +1,58 @@
1
+ import { CaretDownIcon } from "@phosphor-icons/react/dist/csr/CaretDown";
2
+ import { type ReactElement, type ReactNode, useLayoutEffect, useRef, useState } from "react";
3
+ import { clipLineHeight, clipNeedsExpand, collapsedClipLimit } from "./clip.ts";
4
+
5
+ export function BubbleClip(
6
+ props: Readonly<{
7
+ text: string;
8
+ locked?: boolean;
9
+ children: ReactNode;
10
+ }>,
11
+ ): ReactElement {
12
+ const [open, setOpen] = useState(false);
13
+ const [overflows, setOverflows] = useState(false);
14
+ const bodyRef = useRef<HTMLDivElement>(null);
15
+ const innerRef = useRef<HTMLDivElement>(null);
16
+ const expanded = props.locked || open;
17
+
18
+ useLayoutEffect(() => {
19
+ setOpen(false);
20
+ }, [props.text]);
21
+
22
+ useLayoutEffect(() => {
23
+ const clip = bodyRef.current;
24
+ const inner = innerRef.current;
25
+ if (!clip || !inner || props.locked) {
26
+ if (props.locked) setOverflows(false);
27
+ return;
28
+ }
29
+ setOverflows(
30
+ clipNeedsExpand(inner.scrollHeight, collapsedClipLimit(clip), clipLineHeight(inner)),
31
+ );
32
+ }, [props.locked, props.text, props.children]);
33
+
34
+ return (
35
+ <div
36
+ ref={bodyRef}
37
+ className={`desk-line__clip${expanded ? " is-open" : ""}${overflows && !props.locked ? " has-more" : ""}`}
38
+ >
39
+ <div ref={innerRef} className="desk-line__clip-inner">
40
+ {props.children}
41
+ </div>
42
+ {overflows && !props.locked ? (
43
+ <>
44
+ {open ? null : <div className="desk-line__fog" aria-hidden="true" />}
45
+ <button
46
+ type="button"
47
+ className={`desk-line__more${open ? " is-open" : ""}`}
48
+ aria-expanded={open}
49
+ aria-label={open ? "Show less" : "Show more"}
50
+ onClick={() => setOpen((current) => !current)}
51
+ >
52
+ <CaretDownIcon size={14} weight="bold" aria-hidden="true" />
53
+ </button>
54
+ </>
55
+ ) : null}
56
+ </div>
57
+ );
58
+ }
@@ -0,0 +1,19 @@
1
+ import type { ReactElement } from "react";
2
+ import type { PipeStep } from "./pipeline";
3
+
4
+ export function PipelineTrack(
5
+ props: Readonly<{ steps: readonly PipeStep[] }>,
6
+ ): ReactElement | null {
7
+ if (props.steps.length === 0) return null;
8
+ const label = props.steps.map((step) => step.label).join(", ");
9
+ return (
10
+ <div className="desk-pipe" role="img" aria-label={label}>
11
+ {props.steps.map((step, index) => (
12
+ <span key={step.id} className={`desk-pipe__unit is-${step.status}`}>
13
+ {index > 0 ? <span className="desk-pipe__seg" aria-hidden="true" /> : null}
14
+ <span className="desk-pipe__dot" aria-hidden="true" />
15
+ </span>
16
+ ))}
17
+ </div>
18
+ );
19
+ }
@@ -0,0 +1,98 @@
1
+ import { ArrowsInIcon } from "@phosphor-icons/react/dist/csr/ArrowsIn";
2
+ import { ArrowsOutIcon } from "@phosphor-icons/react/dist/csr/ArrowsOut";
3
+ import { type ReactElement, type ReactNode, useEffect, useState } from "react";
4
+ import type { PublicIntegration } from "./api";
5
+ import { BubbleClip } from "./BubbleClip";
6
+ import { matchPlatform, platformTitle } from "./platform";
7
+ import type { ToolLine } from "./thought";
8
+
9
+ export function PlatformPane(
10
+ props: Readonly<{
11
+ line: ToolLine;
12
+ integrations: PublicIntegration[];
13
+ children?: ReactNode;
14
+ }>,
15
+ ): ReactElement {
16
+ const { line, integrations } = props;
17
+ const match = matchPlatform(line.name, integrations);
18
+ const title = platformTitle(line.name, integrations);
19
+ const [logoFailed, setLogoFailed] = useState(false);
20
+ const [full, setFull] = useState(false);
21
+ const clipKey = line.output ?? line.error ?? line.label;
22
+
23
+ useEffect(() => {
24
+ if (!full) return;
25
+ const onKey = (event: KeyboardEvent): void => {
26
+ if (event.key === "Escape") setFull(false);
27
+ };
28
+ window.addEventListener("keydown", onKey);
29
+ return () => window.removeEventListener("keydown", onKey);
30
+ }, [full]);
31
+
32
+ const pane = (
33
+ <article className={`desk-platform is-${line.status}${full ? " is-full" : ""}`}>
34
+ <header className="desk-platform__chrome">
35
+ <span className="desk-platform__brand">
36
+ {match?.logoUrl && !logoFailed ? (
37
+ <img
38
+ src={match.logoUrl}
39
+ alt=""
40
+ width={16}
41
+ height={16}
42
+ onError={() => setLogoFailed(true)}
43
+ />
44
+ ) : (
45
+ <span className="desk-platform__glyph">{match?.glyph ?? title.slice(0, 2)}</span>
46
+ )}
47
+ <span>{title}</span>
48
+ </span>
49
+ <span className="desk-platform__actions">
50
+ {line.status === "running" ? (
51
+ <span className="desk-platform__live">
52
+ <span className="desk-event__spin" aria-hidden="true" />
53
+ {line.label}
54
+ </span>
55
+ ) : null}
56
+ <button
57
+ type="button"
58
+ className="desk-platform__action"
59
+ aria-label={full ? "Exit full screen" : "Full screen"}
60
+ onClick={() => setFull((current) => !current)}
61
+ >
62
+ {full ? (
63
+ <ArrowsInIcon size={16} weight="regular" aria-hidden="true" />
64
+ ) : (
65
+ <ArrowsOutIcon size={16} weight="regular" aria-hidden="true" />
66
+ )}
67
+ </button>
68
+ </span>
69
+ </header>
70
+ <div className="desk-platform__body">
71
+ <BubbleClip text={clipKey} locked={full || line.status === "running"}>
72
+ {platformBody(line, props.children)}
73
+ </BubbleClip>
74
+ </div>
75
+ </article>
76
+ );
77
+
78
+ if (!full) return pane;
79
+ return (
80
+ <>
81
+ <button
82
+ type="button"
83
+ className="desk-platform-scrim"
84
+ aria-label="Exit full screen"
85
+ onClick={() => setFull(false)}
86
+ />
87
+ {pane}
88
+ </>
89
+ );
90
+ }
91
+
92
+ function platformBody(line: ToolLine, children: ReactNode): ReactNode {
93
+ if (line.status === "fail" && line.error) {
94
+ return <p className="desk-event__err">{line.error}</p>;
95
+ }
96
+ if (children) return children;
97
+ return <p className="desk-platform__empty">{line.label}</p>;
98
+ }