@tangle-network/sandbox-ui 0.113.0 → 0.113.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1860,7 +1860,7 @@ function SandboxWorkbench({
1860
1860
  children: transcript
1861
1861
  }
1862
1862
  );
1863
- const artifactPanel = artifacts.length > 0 ? /* @__PURE__ */ jsxs9("section", { className: "flex h-full min-h-0 flex-col bg-surface-container", children: [
1863
+ const artifactPanel = artifacts.length > 0 || emptyArtifactState ? /* @__PURE__ */ jsxs9("section", { className: "flex h-full min-h-0 flex-col bg-surface-container", children: [
1864
1864
  /* @__PURE__ */ jsx10(
1865
1865
  ArtifactTabs,
1866
1866
  {
@@ -1880,7 +1880,7 @@ function SandboxWorkbench({
1880
1880
  ) }) })
1881
1881
  ] }) : null;
1882
1882
  const directoryPlacement = layout?.directoryPlacement ?? (directory ? "left" : "hidden");
1883
- const artifactPlacement = layout?.artifactPlacement ?? (artifacts.length > 0 ? "right" : "hidden");
1883
+ const artifactPlacement = layout?.artifactPlacement ?? (artifactPanel ? "right" : "hidden");
1884
1884
  const runtimePlacement = layout?.runtimePlacement ?? (runtime ? "bottom" : "hidden");
1885
1885
  const regionSections = {
1886
1886
  left: [],
@@ -7242,7 +7242,7 @@ function CodeView({
7242
7242
 
7243
7243
  // src/workbench/diff-view.tsx
7244
7244
  import * as React7 from "react";
7245
- import { PatchDiff } from "@pierre/diffs/react";
7245
+ import { FileDiff, getSingularPatch } from "@pierre/diffs";
7246
7246
 
7247
7247
  // src/workbench/diff-utils.ts
7248
7248
  import { createTwoFilesPatch, diffLines } from "diff";
@@ -7280,19 +7280,40 @@ var DIFF_OPTIONS = {
7280
7280
  themeType: "dark",
7281
7281
  stickyHeader: true
7282
7282
  };
7283
+ var DIFF_CONTAINER_TAG = "diffs-container";
7283
7284
  function DiffView({ filename, baseline, current, showFileHeader = true, className }) {
7284
7285
  const patch = React7.useMemo(
7285
7286
  () => buildUnifiedPatch(filename, baseline, current),
7286
7287
  [filename, baseline, current]
7287
7288
  );
7288
- const options = React7.useMemo(
7289
- () => showFileHeader ? DIFF_OPTIONS : { ...DIFF_OPTIONS, disableFileHeader: true },
7290
- [showFileHeader]
7291
- );
7289
+ const hostRef = React7.useRef(null);
7290
+ React7.useLayoutEffect(() => {
7291
+ const host = hostRef.current;
7292
+ if (host == null || !patch) return;
7293
+ const container = document.createElement(DIFF_CONTAINER_TAG);
7294
+ host.appendChild(container);
7295
+ const instance = new FileDiff(
7296
+ showFileHeader ? DIFF_OPTIONS : { ...DIFF_OPTIONS, disableFileHeader: true },
7297
+ void 0,
7298
+ false
7299
+ );
7300
+ instance.hydrate({ fileDiff: getSingularPatch(patch), fileContainer: container });
7301
+ return () => {
7302
+ instance.cleanUp();
7303
+ container.remove();
7304
+ };
7305
+ }, [patch, showFileHeader]);
7292
7306
  if (!patch) {
7293
7307
  return /* @__PURE__ */ jsx7("div", { className: cn("flex h-full items-center justify-center bg-surface-container", className), children: /* @__PURE__ */ jsx7("p", { className: "text-sm text-muted-foreground", children: "No changes \u2014 baseline and working copy are identical." }) });
7294
7308
  }
7295
- return /* @__PURE__ */ jsx7("div", { className: cn("h-full min-h-0 overflow-auto bg-surface-container text-[13px]", className), children: /* @__PURE__ */ jsx7(PatchDiff, { patch, options }) });
7309
+ return /* @__PURE__ */ jsx7(
7310
+ "div",
7311
+ {
7312
+ ref: hostRef,
7313
+ "data-testid": "diff-view",
7314
+ className: cn("h-full min-h-0 overflow-auto bg-surface-container text-[13px]", className)
7315
+ }
7316
+ );
7296
7317
  }
7297
7318
 
7298
7319
  // src/workbench/preview-view.tsx
@@ -7775,7 +7796,7 @@ function ChangesPane({
7775
7796
  showFileHeader: false,
7776
7797
  className: "flex-1"
7777
7798
  }
7778
- ) : /* @__PURE__ */ jsx10("p", { className: "px-3 py-3 text-xs text-muted-foreground", role: "status", children: "Loading diff\u2026" })
7799
+ ) : selected.loadError ? /* @__PURE__ */ jsx10("p", { className: "px-3 py-3 text-xs text-destructive", role: "alert", children: selected.loadError }) : /* @__PURE__ */ jsx10("p", { className: "px-3 py-3 text-xs text-muted-foreground", role: "status", children: "Loading diff\u2026" })
7779
7800
  ] }) : showList && /* @__PURE__ */ jsx10("p", { className: "px-3 py-3 text-xs text-muted-foreground", children: "Select a file to read its diff." }) }),
7780
7801
  (onCommit || onPush) && /* @__PURE__ */ jsxs7("div", { className: cn("shrink-0 space-y-2 border-t bg-surface-container-low p-3", BORDER), children: [
7781
7802
  onCommit && /* @__PURE__ */ jsx10(
package/dist/index.js CHANGED
@@ -133,7 +133,7 @@ import {
133
133
  formatRelativeAge,
134
134
  shellShouldRevalidate,
135
135
  useOptimisticSessionItems
136
- } from "./chunk-2Q3KDQX7.js";
136
+ } from "./chunk-OUHP3YN4.js";
137
137
  import {
138
138
  BRAND_PRISM_THEME,
139
139
  ChangesPane,
@@ -150,7 +150,7 @@ import {
150
150
  buildUnifiedPatch,
151
151
  computeDiffStats,
152
152
  resolveLanguage
153
- } from "./chunk-ISTJTUHJ.js";
153
+ } from "./chunk-RDUYWQQ7.js";
154
154
  import {
155
155
  FileArtifactPane,
156
156
  FilePreview,
@@ -87,6 +87,11 @@ interface ChangedFile {
87
87
  /** Present once the consumer has resolved contents for the selected file. */
88
88
  baseline?: string;
89
89
  current?: string;
90
+ /**
91
+ * Why the sides could not be resolved. Shown under the file's header in
92
+ * place of the loading line, so a failed read never looks like a slow one.
93
+ */
94
+ loadError?: string;
90
95
  }
91
96
  interface ChangesPaneProps {
92
97
  /** Current branch; `null` when the tree has no commits yet or is not a repository. */
@@ -252,9 +257,18 @@ interface DiffViewProps {
252
257
  className?: string;
253
258
  }
254
259
  /**
255
- * Word-level unified diff via `@pierre/diffs`' `PatchDiff`. The patch is built
256
- * with jsdiff's `createTwoFilesPatch` (baseline → current); the renderer owns
257
- * hunking, intra-line word diffing, gutters, and syntax highlighting.
260
+ * Word-level unified diff via `@pierre/diffs`' core `FileDiff` renderer. The
261
+ * patch is built with jsdiff's `createTwoFilesPatch` (baseline → current); the
262
+ * renderer owns hunking, intra-line word diffing, gutters, and highlighting.
263
+ *
264
+ * The renderer is driven from an effect on a host element this component
265
+ * creates for every mount, not through the library's React wrapper. The
266
+ * wrapper hydrates the element React hands it and treats an existing shadow
267
+ * `<pre>` as prerendered content; React StrictMode attaches, detaches, and
268
+ * re-attaches that element on mount, so the second hydrate finds the first
269
+ * mount's `<pre>` and renders nothing. A fresh element per effect run has no
270
+ * such history, and the cleanup removes it (the instance is not
271
+ * container-managed).
258
272
  */
259
273
  declare function DiffView({ filename, baseline, current, showFileHeader, className }: DiffViewProps): React.JSX.Element;
260
274
 
package/dist/workbench.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  buildUnifiedPatch,
15
15
  computeDiffStats,
16
16
  resolveLanguage
17
- } from "./chunk-ISTJTUHJ.js";
17
+ } from "./chunk-RDUYWQQ7.js";
18
18
  import "./chunk-PZVUIUUW.js";
19
19
  import "./chunk-K4Q4E7D7.js";
20
20
  import "./chunk-OMUIPJQZ.js";
@@ -573,6 +573,10 @@ interface SandboxWorkbenchProps {
573
573
  onArtifactClose?: (artifactId: string) => void;
574
574
  runtime?: RuntimePaneProps;
575
575
  layout?: SandboxWorkbenchLayoutOptions;
576
+ /**
577
+ * Shown in the artifact region while no artifact is selected. When given,
578
+ * the region renders before the first artifact exists.
579
+ */
576
580
  emptyArtifactState?: ReactNode;
577
581
  className?: string;
578
582
  }
package/dist/workspace.js CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  formatRelativeAge,
22
22
  shellShouldRevalidate,
23
23
  useOptimisticSessionItems
24
- } from "./chunk-2Q3KDQX7.js";
24
+ } from "./chunk-OUHP3YN4.js";
25
25
  import "./chunk-BGVEHENC.js";
26
26
  import "./chunk-EI44GEQ5.js";
27
27
  import "./chunk-CZ7CSFO4.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/sandbox-ui",
3
- "version": "0.113.0",
3
+ "version": "0.113.2",
4
4
  "description": "Unified UI component library for Tangle Sandbox — primitives, chat, dashboard, terminal, editor, and workspace components",
5
5
  "repository": {
6
6
  "type": "git",