@workerdeck/ui 1.0.0 → 1.2.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.
@@ -1,4 +1,4 @@
1
- import { S as toolInputPreview, _ as formatRateLimitWindowLong, a as meterTintClass, d as formatAgoPrecise, f as formatBytes, h as formatDuration, m as formatCountdown, p as formatCost, r as meterColorClass, v as formatRelativeTime, x as rateLimitWindowSeconds, y as formatTokens } from "./status-C0HSLZas.mjs";
1
+ import { C as toolInputPreview, S as rateLimitWindowSeconds, a as meterTintClass, b as formatTokens, d as COMPACTION_TEXT, f as formatAgoPrecise, g as formatDuration, h as formatCountdown, m as formatCost, p as formatBytes, r as meterColorClass, v as formatRateLimitWindowLong, y as formatRelativeTime } from "./status-BW2xj79g.mjs";
2
2
  import { Fragment, createContext, forwardRef, memo, useCallback, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
3
3
  import { cva } from "class-variance-authority";
4
4
  import { clsx } from "clsx";
@@ -1497,7 +1497,7 @@ function unwrapBlockElement(parent, block) {
1497
1497
  */
1498
1498
  function normalizeEditorDOM(editor) {
1499
1499
  let changed = false;
1500
- const blockTags = new Set([
1500
+ const blockTags = /* @__PURE__ */ new Set([
1501
1501
  "DIV",
1502
1502
  "P",
1503
1503
  "SECTION",
@@ -2377,12 +2377,15 @@ function usePromptAreaEvents(deps) {
2377
2377
  e.preventDefault();
2378
2378
  const editor = editorRef.current;
2379
2379
  if (!editor) return;
2380
- const imageFile = Array.from(e.clipboardData.files).find((f) => f.type.startsWith("image/")) ?? Array.from(e.clipboardData.items).find((i) => i.type.startsWith("image/"))?.getAsFile() ?? null;
2380
+ const imageFile = Array.from(e.clipboardData.files).find((f) => f.type.startsWith("image/")) ?? (() => {
2381
+ return Array.from(e.clipboardData.items).find((i) => i.type.startsWith("image/"))?.getAsFile() ?? null;
2382
+ })();
2381
2383
  if (imageFile) {
2382
2384
  onImagePaste?.(imageFile);
2383
2385
  return;
2384
2386
  }
2385
- pushUndo(readSegmentsFromDOM());
2387
+ const currentSegments = readSegmentsFromDOM();
2388
+ pushUndo(currentSegments);
2386
2389
  const segmentJson = e.clipboardData.getData("text/prompt-area-segments");
2387
2390
  if (segmentJson) {
2388
2391
  const parsed = parseSegmentsFromClipboard(segmentJson);
@@ -2478,11 +2481,13 @@ function usePromptAreaEvents(deps) {
2478
2481
  handleCopy(e);
2479
2482
  const range = getSelectionRange();
2480
2483
  if (!range) return;
2481
- pushUndo(readSegmentsFromDOM());
2484
+ const currentSegments = readSegmentsFromDOM();
2485
+ pushUndo(currentSegments);
2482
2486
  range.deleteContents();
2483
2487
  const editor = editorRef.current;
2484
2488
  if (editor) normalizeEditorDOM(editor);
2485
- onChange(readSegmentsFromDOM());
2489
+ const newSegments = readSegmentsFromDOM();
2490
+ onChange(newSegments);
2486
2491
  runTriggerDetection();
2487
2492
  }, [
2488
2493
  handleCopy,
@@ -2818,8 +2823,9 @@ function usePromptAreaKeydown({ editorRef, triggers, markdownEnabled, submitOnEn
2818
2823
  if (!offsets) return;
2819
2824
  const currentSegments = readSegmentsFromDOM();
2820
2825
  pushUndo(currentSegments);
2826
+ const newSegments = replaceTextRange(currentSegments, offsets.start, offsets.end, "\n");
2821
2827
  applyEditResult(editor, {
2822
- segments: replaceTextRange(currentSegments, offsets.start, offsets.end, "\n"),
2828
+ segments: newSegments,
2823
2829
  cursorOffset: offsets.start + 1
2824
2830
  });
2825
2831
  };
@@ -2950,9 +2956,10 @@ function useChipEditing({ editorRef, triggers, disabled, onChange, renderSegment
2950
2956
  const wasOpenForThisChip = suppressReopenChip.current === node;
2951
2957
  suppressReopenChip.current = null;
2952
2958
  if (!disabled && !wasOpenForThisChip && config?.reopenOnChipClick && config.mode === "dropdown" && config.onSearch) {
2959
+ const childIdx = indexOfChildNode(editor, node);
2953
2960
  editingChip.current = {
2954
2961
  chip,
2955
- segIndex: domChildIndexToSegmentIndex(editor, indexOfChildNode(editor, node))
2962
+ segIndex: domChildIndexToSegmentIndex(editor, childIdx)
2956
2963
  };
2957
2964
  openChipNode.current = node;
2958
2965
  setActiveTrigger({
@@ -3429,12 +3436,14 @@ function usePromptArea({ value, onChange, triggers = NO_TRIGGERS, disabled = fal
3429
3436
  }
3430
3437
  undoTimer.current = null;
3431
3438
  }, UNDO_DEBOUNCE_MS);
3432
- if (editor) if (renumberedCursor !== null) {
3433
- renderSegmentsToDOM(nextSegments);
3434
- setCursorAtOffset(editor, renumberedCursor);
3435
- } else {
3436
- decorateEditor(editor, markdownEnabled);
3437
- if (savedCursorOffset !== null) setCursorAtOffset(editor, savedCursorOffset);
3439
+ if (editor) {
3440
+ if (renumberedCursor !== null) {
3441
+ renderSegmentsToDOM(nextSegments);
3442
+ setCursorAtOffset(editor, renumberedCursor);
3443
+ } else {
3444
+ decorateEditor(editor, markdownEnabled);
3445
+ if (savedCursorOffset !== null) setCursorAtOffset(editor, savedCursorOffset);
3446
+ }
3438
3447
  }
3439
3448
  runTriggerDetection();
3440
3449
  }, [
@@ -3925,9 +3934,9 @@ const FILE_ICONS = {
3925
3934
  /** Format bytes into a human-readable string. */
3926
3935
  function formatFileSize(bytes) {
3927
3936
  if (bytes < 1024) return `${bytes} B`;
3928
- if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
3929
- if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
3930
- return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
3937
+ if (bytes < 1048576) return `${(bytes / 1024).toFixed(1)} KB`;
3938
+ if (bytes < 1073741824) return `${(bytes / 1048576).toFixed(1)} MB`;
3939
+ return `${(bytes / 1073741824).toFixed(1)} GB`;
3931
3940
  }
3932
3941
  /** Extract a short extension label from a filename (e.g., "PDF", "CSV"). */
3933
3942
  function getExtensionLabel(name) {
@@ -5015,7 +5024,7 @@ function useToolResultImageSrc(ref) {
5015
5024
  ]);
5016
5025
  return state;
5017
5026
  }
5018
- const CACHE_BUDGET_BYTES = 64 * 1024 * 1024;
5027
+ const CACHE_BUDGET_BYTES = 67108864;
5019
5028
  function useToolResultImages(client, sessionId) {
5020
5029
  const cache = useRef(/* @__PURE__ */ new Map());
5021
5030
  useEffect(() => () => {
@@ -5432,6 +5441,19 @@ function TurnResultRow$1({ item }) {
5432
5441
  children: message
5433
5442
  }, index))] });
5434
5443
  }
5444
+ /**
5445
+ * One row, deliberately. A rule with a centred label reads better and costs the height book a
5446
+ * second measurement for a row that carries no content — and the point here is only that the
5447
+ * boundary is *visible*, so the ring dropping 90% → 15% stops reading as a bug.
5448
+ */
5449
+ function CompactionRow$1() {
5450
+ return /* @__PURE__ */ jsx(Row, {
5451
+ glyph: "≡",
5452
+ glyphTone: "yellow",
5453
+ tone: "faint",
5454
+ children: COMPACTION_TEXT
5455
+ });
5456
+ }
5435
5457
  function NoticeRow$1({ item }) {
5436
5458
  const error = item.level === "error";
5437
5459
  return /* @__PURE__ */ jsx(Row, {
@@ -5864,8 +5886,9 @@ function GlyphButton({ tone, label, disabled, onClick, gutter, className, childr
5864
5886
  });
5865
5887
  }
5866
5888
  function AttachmentStrip({ attachments }) {
5889
+ const terminal = useTranscriptVariant() === "terminal";
5867
5890
  return /* @__PURE__ */ jsx("div", {
5868
- className: cn("flex gap-2 overflow-x-auto", useTranscriptVariant() === "terminal" ? "term-attachments" : "border-b border-border px-2 py-2"),
5891
+ className: cn("flex gap-2 overflow-x-auto", terminal ? "term-attachments" : "border-b border-border px-2 py-2"),
5869
5892
  children: attachments.items.map((item) => /* @__PURE__ */ jsx(AttachmentChip, {
5870
5893
  item,
5871
5894
  onRetry: () => attachments.retry(item.key),
@@ -6226,13 +6249,14 @@ function McpDialog({ client, sessionId, open, onOpenChange, canManageServers = t
6226
6249
  };
6227
6250
  const server = servers?.find((s) => s.name === selectedServer);
6228
6251
  const tool = server?.tools?.find((t) => t.name === selectedTool);
6252
+ const title = tool?.name ?? server?.name ?? "MCP servers";
6229
6253
  return /* @__PURE__ */ jsx(Dialog$1, {
6230
6254
  open,
6231
6255
  onOpenChange,
6232
6256
  children: /* @__PURE__ */ jsxs(DialogContent, {
6233
6257
  className,
6234
6258
  children: [/* @__PURE__ */ jsx(DialogHeader, {
6235
- title: tool?.name ?? server?.name ?? "MCP servers",
6259
+ title,
6236
6260
  description: tool ? `${server?.name} tool` : server ? server.serverInfo?.name : void 0,
6237
6261
  actions: selectedServer ? /* @__PURE__ */ jsxs(Button, {
6238
6262
  variant: "ghost",
@@ -6272,9 +6296,10 @@ function ServerList({ servers, loading, onSelect }) {
6272
6296
  className: "py-6 text-center text-body-sm text-fg-4",
6273
6297
  children: "No MCP servers configured for this session."
6274
6298
  });
6299
+ const scopes = [...new Set(servers.map((s) => s.scope ?? "other"))];
6275
6300
  return /* @__PURE__ */ jsx("div", {
6276
6301
  className: "flex flex-col gap-4",
6277
- children: [...new Set(servers.map((s) => s.scope ?? "other"))].map((scope) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
6302
+ children: scopes.map((scope) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
6278
6303
  className: "text-label font-medium text-fg-3 capitalize",
6279
6304
  children: scope
6280
6305
  }), /* @__PURE__ */ jsx("ul", {
@@ -6483,9 +6508,10 @@ function SkillList({ skills, onSelect }) {
6483
6508
  className: "py-6 text-center text-body-sm text-fg-4",
6484
6509
  children: "This session found no skills."
6485
6510
  });
6511
+ const scopes = [...new Set(skills.map((s) => s.scope ?? "other"))];
6486
6512
  return /* @__PURE__ */ jsx("div", {
6487
6513
  className: "flex flex-col gap-4",
6488
- children: [...new Set(skills.map((s) => s.scope ?? "other"))].map((scope) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
6514
+ children: scopes.map((scope) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
6489
6515
  className: "text-label font-medium text-fg-3",
6490
6516
  children: SCOPE_LABEL[scope] ?? scope
6491
6517
  }), /* @__PURE__ */ jsx("ul", {
@@ -8267,7 +8293,7 @@ function clusterCells(cluster) {
8267
8293
  };
8268
8294
  }
8269
8295
  const TAB_SIZE = 2;
8270
- const BREAK_AFTER = new Set([
8296
+ const BREAK_AFTER = /* @__PURE__ */ new Set([
8271
8297
  "-",
8272
8298
  "–",
8273
8299
  "—",
@@ -8662,12 +8688,10 @@ function markdownHeight(md, m, extraPx = 0) {
8662
8688
  exact: true
8663
8689
  });
8664
8690
  break;
8665
- case "hr":
8666
- acc = add(acc, {
8667
- px: m.line,
8668
- exact: true
8669
- });
8670
- break;
8691
+ case "hr": acc = add(acc, {
8692
+ px: m.line,
8693
+ exact: true
8694
+ });
8671
8695
  }
8672
8696
  }
8673
8697
  return {
@@ -8784,6 +8808,7 @@ function itemHeight(item, m) {
8784
8808
  return acc;
8785
8809
  }
8786
8810
  case "notice": return rowH(item.text, m, { extraPx });
8811
+ case "compaction": return rowH(COMPACTION_TEXT, m, { extraPx });
8787
8812
  case "file_delivered": return rowH(`${item.path} · ${formatBytes(item.bytes)}` + (item.description ? ` · ${item.description}` : ""), m, { extraPx });
8788
8813
  default: return {
8789
8814
  px: 0,
@@ -9719,6 +9744,7 @@ function TerminalItemView({ item, fileUrl }) {
9719
9744
  case "tool_call": return /* @__PURE__ */ jsx(ToolRow, { item });
9720
9745
  case "turn_result": return /* @__PURE__ */ jsx(TurnResultRow$1, { item });
9721
9746
  case "notice": return /* @__PURE__ */ jsx(NoticeRow$1, { item });
9747
+ case "compaction": return /* @__PURE__ */ jsx(CompactionRow$1, {});
9722
9748
  case "file_delivered": return /* @__PURE__ */ jsx(FileRow, {
9723
9749
  item,
9724
9750
  href: fileUrl?.(item.path)
@@ -9939,7 +9965,7 @@ function Reasoning({ children, isStreaming = false, defaultOpen, className }) {
9939
9965
  //#endregion
9940
9966
  //#region src/components/agent/ToolCallCard.tsx
9941
9967
  const RESULT_PREVIEW_CHARS = 2e3;
9942
- const IMAGE_TOOLS = new Set(["CodexImageGeneration", "CodexImageView"]);
9968
+ const IMAGE_TOOLS = /* @__PURE__ */ new Set(["CodexImageGeneration", "CodexImageView"]);
9943
9969
  function imagePathOf(item) {
9944
9970
  if (!IMAGE_TOOLS.has(item.name)) return;
9945
9971
  const input = item.input;
@@ -10020,7 +10046,8 @@ function resultLanguage(item) {
10020
10046
  const input = item.input;
10021
10047
  const path = input?.file_path ?? input?.path;
10022
10048
  if (typeof path !== "string") return;
10023
- return EXTENSION_LANGUAGE[path.slice(path.lastIndexOf(".") + 1).toLowerCase()];
10049
+ const extension = path.slice(path.lastIndexOf(".") + 1).toLowerCase();
10050
+ return EXTENSION_LANGUAGE[extension];
10024
10051
  }
10025
10052
  function ToolCallCard({ item, hostImage, className }) {
10026
10053
  const [open, setOpen] = useState(false);
@@ -10248,6 +10275,7 @@ function TranscriptItemView({ item, fileUrl, attachmentUrl, hostImage, terminal
10248
10275
  });
10249
10276
  case "turn_result": return /* @__PURE__ */ jsx(TurnResultRow, { item });
10250
10277
  case "notice": return /* @__PURE__ */ jsx(NoticeRow, { item });
10278
+ case "compaction": return /* @__PURE__ */ jsx(CompactionRow, {});
10251
10279
  case "file_delivered": return /* @__PURE__ */ jsx(FileCard, {
10252
10280
  item,
10253
10281
  href: fileUrl?.(item.path)
@@ -10255,6 +10283,25 @@ function TranscriptItemView({ item, fileUrl, attachmentUrl, hostImage, terminal
10255
10283
  default: return null;
10256
10284
  }
10257
10285
  }
10286
+ /**
10287
+ * The cards spelling of a compaction boundary — a rule with the label through it, the same shape
10288
+ * `RecapRow` uses below, because both are boundaries rather than messages. The terminal spelling is
10289
+ * `terminal/items.tsx`'s `CompactionRow`, one grid row, and the two share `COMPACTION_TEXT`.
10290
+ */
10291
+ function CompactionRow() {
10292
+ return /* @__PURE__ */ jsxs("div", {
10293
+ "data-slot": "compaction",
10294
+ className: "flex items-center gap-2 py-1",
10295
+ children: [
10296
+ /* @__PURE__ */ jsx("div", { className: "h-px flex-1 bg-border" }),
10297
+ /* @__PURE__ */ jsxs("span", {
10298
+ className: "font-mono text-label text-fg-3",
10299
+ children: ["≡ ", COMPACTION_TEXT]
10300
+ }),
10301
+ /* @__PURE__ */ jsx("div", { className: "h-px flex-1 bg-border" })
10302
+ ]
10303
+ });
10304
+ }
10258
10305
  function RecapRow({ line, since, terminal }) {
10259
10306
  const away = since === void 0 ? void 0 : formatRelativeTime(since);
10260
10307
  const text = away ? `${line} · last here ${away}` : line;
@@ -11371,7 +11418,8 @@ function useHostImage(client, sessionId, producedFiles) {
11371
11418
  return url;
11372
11419
  }).catch(() => void 0) : client.readHostFile(path).then((file) => {
11373
11420
  if (file.encoding !== "base64") return;
11374
- const mediaType = IMAGE_MEDIA_TYPES[path.slice(path.lastIndexOf(".") + 1).toLowerCase()];
11421
+ const extension = path.slice(path.lastIndexOf(".") + 1).toLowerCase();
11422
+ const mediaType = IMAGE_MEDIA_TYPES[extension];
11375
11423
  return mediaType ? `data:${mediaType};base64,${file.content}` : void 0;
11376
11424
  }).catch(() => void 0);
11377
11425
  cache.current.set(key, pending);
@@ -11415,4 +11463,4 @@ function Notice({ level, onDismiss, children }) {
11415
11463
  //#endregion
11416
11464
  export { isMutatingTool as $, PERMISSION_MODES as A, MenuItem as At, Composer as B, Input as Bt, TerminalPermissionPrompt as C, DialogClose as Ct, SubagentStrip as D, DialogTrigger as Dt, parseUserQuestions as E, DialogRow as Et, SkillsDialog as F, SelectItem as Ft, previewPatch as G, cn as Gt, TerminalSurface as H, badgeVariants as Ht, McpDialog as I, SelectItemText as It, Ink as J, Band as K, HostFilesDialog as L, SelectTrigger as Lt, permissionModeChoices as M, MenuTrigger as Mt, permissionModeMeta as N, Select$1 as Nt, PermissionPrompt as O, Menu$1 as Ot, ModelSelect as P, SelectContent as Pt, useAffordances as Q, EntryIcon as R, SelectValue as Rt, TerminalQuestionPrompt as S, DialogBody as St, QuestionPrompt as T, DialogHeader as Tt, TerminalMarkdown as U, Button as Ut, skillPrompt as V, Badge as Vt, TerminalDiff as W, buttonVariants as Wt, CopyAction as X, Row as Y, WithActions as Z, ConversationContent as _, copyText as _t, Transcript as a, commandTrigger as at, STATUS_META as b, TooltipProvider as bt, PromptTokenText as c, usePromptAreaState as ct, FileCard as d, segmentsToPlainText as dt, toolIcon as et, TerminalItemView as f, ProgressRing as ft, Conversation as g, CopyButton as gt, Loader as h, Spinner as ht, useMinuteClock as i, useTranscriptVariant as it, PermissionModeSelect as j, MenuSeparator as jt, Response as k, MenuContent as kt, Message as l, PromptArea as lt, SessionEmptyState as m, CodeBlock as mt, UsageDialog as n, TranscriptVariantProvider as nt, ToolCallCard as o, hashtagTrigger as ot, TerminalTranscript as p, Splitter as pt, Blank as q, UsageMeters as r, useTranscriptDensity as rt, Reasoning as s, mentionTrigger as st, SessionPanel as t, TranscriptDensityProvider as tt, MessageContent as u, plainTextToSegments as ut, ConversationScrollButton as v, Tip as vt, QUESTION_BEHAVIORS as w, DialogContent as wt, SessionInfoDialog as x, Dialog$1 as xt, StatusBar as y, TooltipContent as yt, ContextDialog as z, PortalScope as zt };
11417
11465
 
11418
- //# sourceMappingURL=SessionPanel-DDgBkHsi.mjs.map
11466
+ //# sourceMappingURL=SessionPanel-DVhnUwXw.mjs.map