@workerdeck/ui 1.0.0 → 1.1.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 { 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-Dm9INVTt.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(() => () => {
@@ -5864,8 +5873,9 @@ function GlyphButton({ tone, label, disabled, onClick, gutter, className, childr
5864
5873
  });
5865
5874
  }
5866
5875
  function AttachmentStrip({ attachments }) {
5876
+ const terminal = useTranscriptVariant() === "terminal";
5867
5877
  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"),
5878
+ className: cn("flex gap-2 overflow-x-auto", terminal ? "term-attachments" : "border-b border-border px-2 py-2"),
5869
5879
  children: attachments.items.map((item) => /* @__PURE__ */ jsx(AttachmentChip, {
5870
5880
  item,
5871
5881
  onRetry: () => attachments.retry(item.key),
@@ -6226,13 +6236,14 @@ function McpDialog({ client, sessionId, open, onOpenChange, canManageServers = t
6226
6236
  };
6227
6237
  const server = servers?.find((s) => s.name === selectedServer);
6228
6238
  const tool = server?.tools?.find((t) => t.name === selectedTool);
6239
+ const title = tool?.name ?? server?.name ?? "MCP servers";
6229
6240
  return /* @__PURE__ */ jsx(Dialog$1, {
6230
6241
  open,
6231
6242
  onOpenChange,
6232
6243
  children: /* @__PURE__ */ jsxs(DialogContent, {
6233
6244
  className,
6234
6245
  children: [/* @__PURE__ */ jsx(DialogHeader, {
6235
- title: tool?.name ?? server?.name ?? "MCP servers",
6246
+ title,
6236
6247
  description: tool ? `${server?.name} tool` : server ? server.serverInfo?.name : void 0,
6237
6248
  actions: selectedServer ? /* @__PURE__ */ jsxs(Button, {
6238
6249
  variant: "ghost",
@@ -6272,9 +6283,10 @@ function ServerList({ servers, loading, onSelect }) {
6272
6283
  className: "py-6 text-center text-body-sm text-fg-4",
6273
6284
  children: "No MCP servers configured for this session."
6274
6285
  });
6286
+ const scopes = [...new Set(servers.map((s) => s.scope ?? "other"))];
6275
6287
  return /* @__PURE__ */ jsx("div", {
6276
6288
  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", {
6289
+ children: scopes.map((scope) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
6278
6290
  className: "text-label font-medium text-fg-3 capitalize",
6279
6291
  children: scope
6280
6292
  }), /* @__PURE__ */ jsx("ul", {
@@ -6483,9 +6495,10 @@ function SkillList({ skills, onSelect }) {
6483
6495
  className: "py-6 text-center text-body-sm text-fg-4",
6484
6496
  children: "This session found no skills."
6485
6497
  });
6498
+ const scopes = [...new Set(skills.map((s) => s.scope ?? "other"))];
6486
6499
  return /* @__PURE__ */ jsx("div", {
6487
6500
  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", {
6501
+ children: scopes.map((scope) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
6489
6502
  className: "text-label font-medium text-fg-3",
6490
6503
  children: SCOPE_LABEL[scope] ?? scope
6491
6504
  }), /* @__PURE__ */ jsx("ul", {
@@ -8267,7 +8280,7 @@ function clusterCells(cluster) {
8267
8280
  };
8268
8281
  }
8269
8282
  const TAB_SIZE = 2;
8270
- const BREAK_AFTER = new Set([
8283
+ const BREAK_AFTER = /* @__PURE__ */ new Set([
8271
8284
  "-",
8272
8285
  "–",
8273
8286
  "—",
@@ -8662,12 +8675,10 @@ function markdownHeight(md, m, extraPx = 0) {
8662
8675
  exact: true
8663
8676
  });
8664
8677
  break;
8665
- case "hr":
8666
- acc = add(acc, {
8667
- px: m.line,
8668
- exact: true
8669
- });
8670
- break;
8678
+ case "hr": acc = add(acc, {
8679
+ px: m.line,
8680
+ exact: true
8681
+ });
8671
8682
  }
8672
8683
  }
8673
8684
  return {
@@ -9939,7 +9950,7 @@ function Reasoning({ children, isStreaming = false, defaultOpen, className }) {
9939
9950
  //#endregion
9940
9951
  //#region src/components/agent/ToolCallCard.tsx
9941
9952
  const RESULT_PREVIEW_CHARS = 2e3;
9942
- const IMAGE_TOOLS = new Set(["CodexImageGeneration", "CodexImageView"]);
9953
+ const IMAGE_TOOLS = /* @__PURE__ */ new Set(["CodexImageGeneration", "CodexImageView"]);
9943
9954
  function imagePathOf(item) {
9944
9955
  if (!IMAGE_TOOLS.has(item.name)) return;
9945
9956
  const input = item.input;
@@ -10020,7 +10031,8 @@ function resultLanguage(item) {
10020
10031
  const input = item.input;
10021
10032
  const path = input?.file_path ?? input?.path;
10022
10033
  if (typeof path !== "string") return;
10023
- return EXTENSION_LANGUAGE[path.slice(path.lastIndexOf(".") + 1).toLowerCase()];
10034
+ const extension = path.slice(path.lastIndexOf(".") + 1).toLowerCase();
10035
+ return EXTENSION_LANGUAGE[extension];
10024
10036
  }
10025
10037
  function ToolCallCard({ item, hostImage, className }) {
10026
10038
  const [open, setOpen] = useState(false);
@@ -11371,7 +11383,8 @@ function useHostImage(client, sessionId, producedFiles) {
11371
11383
  return url;
11372
11384
  }).catch(() => void 0) : client.readHostFile(path).then((file) => {
11373
11385
  if (file.encoding !== "base64") return;
11374
- const mediaType = IMAGE_MEDIA_TYPES[path.slice(path.lastIndexOf(".") + 1).toLowerCase()];
11386
+ const extension = path.slice(path.lastIndexOf(".") + 1).toLowerCase();
11387
+ const mediaType = IMAGE_MEDIA_TYPES[extension];
11375
11388
  return mediaType ? `data:${mediaType};base64,${file.content}` : void 0;
11376
11389
  }).catch(() => void 0);
11377
11390
  cache.current.set(key, pending);
@@ -11415,4 +11428,4 @@ function Notice({ level, onDismiss, children }) {
11415
11428
  //#endregion
11416
11429
  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
11430
 
11418
- //# sourceMappingURL=SessionPanel-DDgBkHsi.mjs.map
11431
+ //# sourceMappingURL=SessionPanel-I5QSLLb0.mjs.map