@tangle-network/ui 11.11.8 → 11.13.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.
- package/CHANGELOG.md +24 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/auth/auth.d.ts +53 -0
- package/dist/{auth-DOETfnd9.js → auth/auth.js} +7 -37
- package/dist/auth/login-layout.d.ts +20 -0
- package/dist/auth/login-layout.js +36 -0
- package/dist/auth.d.ts +2 -1
- package/dist/auth.js +2 -1
- package/dist/chat/agent-timeline.d.ts +83 -0
- package/dist/chat/agent-timeline.js +236 -0
- package/dist/chat/chat-container.d.ts +51 -0
- package/dist/chat/chat-container.js +309 -0
- package/dist/chat/chat-message.d.ts +22 -0
- package/dist/chat/chat-message.js +38 -0
- package/dist/chat/message-list.d.ts +32 -0
- package/dist/chat/message-list.js +37 -0
- package/dist/chat/thinking-indicator.d.ts +6 -0
- package/dist/chat/thinking-indicator.js +38 -0
- package/dist/chat/user-message.d.ts +21 -0
- package/dist/chat/user-message.js +42 -0
- package/dist/chat.d.ts +6 -1
- package/dist/chat.js +6 -1
- package/dist/editor/document-editor-pane.d.ts +37 -0
- package/dist/editor/document-editor-pane.js +199 -0
- package/dist/editor/editor-lazy.js +37 -0
- package/dist/editor/editor-loading.js +21 -0
- package/dist/editor/editor-peers.d.ts +6 -0
- package/dist/editor/editor-peers.js +155 -0
- package/dist/{document-editor-pane-DHM8DDhb.d.ts → editor/editor-provider.d.ts} +10 -47
- package/dist/editor/editor-provider.js +253 -0
- package/dist/editor/editor-toolbar.d.ts +11 -0
- package/dist/editor/editor-toolbar.js +106 -0
- package/dist/editor/markdown-conversion.js +23 -0
- package/dist/editor/markdown-document-editor.js +103 -0
- package/dist/editor/tiptap-editor.d.ts +45 -0
- package/dist/editor/tiptap-editor.js +271 -0
- package/dist/editor/use-editor.d.ts +67 -0
- package/dist/editor/use-editor.js +158 -0
- package/dist/editor.d.ts +6 -119
- package/dist/editor.js +5 -1
- package/dist/files/file-artifact-pane.d.ts +47 -0
- package/dist/files/file-artifact-pane.js +114 -0
- package/dist/files/file-format.d.ts +51 -0
- package/dist/{file-format-BgXbr-Ib.js → files/file-format.js} +1 -1
- package/dist/files/file-preview.d.ts +27 -0
- package/dist/files/file-preview.js +359 -0
- package/dist/files/file-tabs.d.ts +19 -0
- package/dist/files/file-tabs.js +48 -0
- package/dist/files/file-tree.d.ts +31 -0
- package/dist/files/file-tree.js +135 -0
- package/dist/files/rich-file-tree.d.ts +62 -0
- package/dist/files/rich-file-tree.js +122 -0
- package/dist/files.d.ts +6 -1
- package/dist/files.js +6 -2
- package/dist/hooks/use-auth.d.ts +40 -0
- package/dist/hooks/use-auth.js +91 -0
- package/dist/hooks/use-auto-scroll.d.ts +11 -0
- package/dist/hooks/use-auto-scroll.js +48 -0
- package/dist/hooks/use-dropdown-menu.d.ts +12 -0
- package/dist/hooks/use-dropdown-menu.js +31 -0
- package/dist/hooks/use-live-time.d.ts +7 -0
- package/dist/hooks/use-live-time.js +22 -0
- package/dist/hooks/use-realtime-session.d.ts +32 -0
- package/dist/hooks/use-realtime-session.js +235 -0
- package/dist/hooks/use-run-collapse-state.d.ts +13 -0
- package/dist/hooks/use-run-collapse-state.js +24 -0
- package/dist/hooks/use-run-groups.d.ts +11 -0
- package/dist/hooks/use-run-groups.js +85 -0
- package/dist/hooks/use-sdk-session.d.ts +59 -0
- package/dist/hooks/use-sdk-session.js +322 -0
- package/dist/hooks/use-sse-stream.d.ts +124 -0
- package/dist/hooks/use-sse-stream.js +229 -0
- package/dist/hooks/use-tool-call-stream.d.ts +23 -0
- package/dist/hooks/use-tool-call-stream.js +75 -0
- package/dist/hooks.d.ts +11 -49
- package/dist/hooks.js +10 -110
- package/dist/index.d.ts +99 -25
- package/dist/index.js +86 -36
- package/dist/lib/focus.d.ts +55 -0
- package/dist/{focus-BcE_SHqz.js → lib/focus.js} +1 -1
- package/dist/lib/utils.d.ts +4 -0
- package/dist/{utils-C_uf36nf.js → lib/utils.js} +1 -1
- package/dist/{code-block-B9miUPht.d.ts → markdown/code-block.d.ts} +5 -6
- package/dist/{code-block-B36KVUSN.js → markdown/code-block.js} +22 -47
- package/dist/{markdown-C0atSabr.d.ts → markdown/markdown.d.ts} +4 -5
- package/dist/{markdown-Db08KAYF.js → markdown/markdown.js} +3 -3
- package/dist/markdown.d.ts +2 -2
- package/dist/markdown.js +2 -2
- package/dist/{openui-artifact-renderer-fkBQaoLO.d.ts → openui/openui-artifact-renderer.d.ts} +20 -21
- package/dist/{openui-artifact-renderer-DG_i2lOR.js → openui/openui-artifact-renderer.js} +9 -7
- package/dist/{schema-BpW9rSSG.js → openui/schema-compiled.js} +2 -354
- package/dist/{schema-DAstk-J4.d.ts → openui/schema-data.d.ts} +3 -24
- package/dist/openui/schema-data.js +206 -0
- package/dist/openui-schema.d.ts +22 -3
- package/dist/openui-schema.js +138 -1
- package/dist/openui.d.ts +3 -2
- package/dist/openui.js +3 -2
- package/dist/{artifact-pane-BL_DFWNl.d.ts → primitives/artifact-pane.d.ts} +3 -4
- package/dist/{artifact-pane-DMXT9a8U.js → primitives/artifact-pane.js} +2 -2
- package/dist/primitives/avatar.d.ts +8 -0
- package/dist/primitives/avatar.js +25 -0
- package/dist/primitives/badge.d.ts +22 -0
- package/dist/primitives/badge.js +47 -0
- package/dist/{button-yoIv77e2.d.ts → primitives/button.d.ts} +2 -2
- package/dist/primitives/button.js +113 -0
- package/dist/primitives/card.d.ts +18 -0
- package/dist/primitives/card.js +52 -0
- package/dist/primitives/code-block.d.ts +6 -0
- package/dist/primitives/code-block.js +13 -0
- package/dist/primitives/dialog.d.ts +23 -0
- package/dist/primitives/dialog.js +59 -0
- package/dist/primitives/drop-zone.d.ts +23 -0
- package/dist/primitives/drop-zone.js +104 -0
- package/dist/primitives/dropdown-menu.d.ts +29 -0
- package/dist/{dropdown-menu-BpcLa5vF.js → primitives/dropdown-menu.js} +2 -23
- package/dist/primitives/empty-state.d.ts +11 -0
- package/dist/primitives/empty-state.js +32 -0
- package/dist/primitives/heading.d.ts +23 -0
- package/dist/primitives/heading.js +38 -0
- package/dist/primitives/input.d.ts +23 -0
- package/dist/primitives/input.js +110 -0
- package/dist/primitives/label.d.ts +6 -0
- package/dist/primitives/label.js +16 -0
- package/dist/primitives/metric-strip.d.ts +48 -0
- package/dist/primitives/metric-strip.js +52 -0
- package/dist/primitives/page-header.d.ts +25 -0
- package/dist/primitives/page-header.js +47 -0
- package/dist/primitives/page-shell.d.ts +14 -0
- package/dist/primitives/page-shell.js +17 -0
- package/dist/primitives/progress.d.ts +9 -0
- package/dist/primitives/progress.js +29 -0
- package/dist/primitives/segmented-control.d.ts +40 -0
- package/dist/primitives/segmented-control.js +57 -0
- package/dist/primitives/select.d.ts +15 -0
- package/dist/primitives/select.js +74 -0
- package/dist/primitives/sidebar-drop-zone.d.ts +21 -0
- package/dist/primitives/sidebar-drop-zone.js +88 -0
- package/dist/primitives/skeleton.d.ts +10 -0
- package/dist/primitives/skeleton.js +50 -0
- package/dist/primitives/stat-card.d.ts +16 -0
- package/dist/primitives/stat-card.js +60 -0
- package/dist/primitives/status-pill.d.ts +44 -0
- package/dist/primitives/status-pill.js +119 -0
- package/dist/primitives/switch.d.ts +6 -0
- package/dist/primitives/switch.js +16 -0
- package/dist/primitives/table.d.ts +22 -0
- package/dist/primitives/table.js +63 -0
- package/dist/primitives/tabs.d.ts +13 -0
- package/dist/{tabs-BVHR6NkO.js → primitives/tabs.js} +3 -3
- package/dist/primitives/terminal-display.d.ts +25 -0
- package/dist/primitives/terminal-display.js +109 -0
- package/dist/primitives/text-shimmer.d.ts +16 -0
- package/dist/{text-shimmer-BUUo6I-g.js → primitives/text-shimmer.js} +2 -2
- package/dist/primitives/theme-toggle.d.ts +11 -0
- package/dist/primitives/theme-toggle.js +154 -0
- package/dist/primitives/toast.d.ts +29 -0
- package/dist/primitives/toast.js +142 -0
- package/dist/primitives/toolbar.d.ts +55 -0
- package/dist/primitives/toolbar.js +37 -0
- package/dist/primitives/upload-progress.d.ts +23 -0
- package/dist/primitives/upload-progress.js +72 -0
- package/dist/primitives.d.ts +35 -5
- package/dist/primitives.js +35 -9
- package/dist/{index-COgqsFAQ.d.ts → redaction/redacted-document.d.ts} +6 -7
- package/dist/{redaction-CGGB2ENG.js → redaction/redacted-document.js} +2 -2
- package/dist/redaction.d.ts +1 -1
- package/dist/redaction.js +1 -1
- package/dist/run/expandable-content.js +41 -0
- package/dist/run/expanded-tool-detail.d.ts +12 -0
- package/dist/run/expanded-tool-detail.js +163 -0
- package/dist/run/inline-thinking-item.d.ts +11 -0
- package/dist/run/inline-thinking-item.js +60 -0
- package/dist/run/inline-tool-item.d.ts +25 -0
- package/dist/run/inline-tool-item.js +63 -0
- package/dist/run/run-group.d.ts +26 -0
- package/dist/{run-group-BWGeesgs.js → run/run-group.js} +9 -60
- package/dist/run/run-item-primitives.d.ts +5 -0
- package/dist/{run-ZsIKPA6J.js → run/run-item-primitives.js} +2 -2
- package/dist/run/run-row-shell.d.ts +53 -0
- package/dist/run/run-row-shell.js +114 -0
- package/dist/{tool-call-feed-BeB1_4pX.d.ts → run/tool-call-feed.d.ts} +7 -12
- package/dist/{tool-call-feed-BpmMLpPX.js → run/tool-call-feed.js} +4 -4
- package/dist/run/tool-call-step.d.ts +5 -0
- package/dist/run/tool-call-step.js +82 -0
- package/dist/run.d.ts +8 -2
- package/dist/run.js +7 -4
- package/dist/sdk-hooks.d.ts +8 -1
- package/dist/sdk-hooks.js +8 -2
- package/dist/stores/active-sessions-store.d.ts +83 -0
- package/dist/{active-sessions-store-Gt1R0rFG.js → stores/active-sessions-store.js} +1 -1
- package/dist/stores/chat-store.d.ts +14 -0
- package/dist/stores/chat-store.js +33 -0
- package/dist/stores.d.ts +3 -16
- package/dist/stores.js +2 -33
- package/dist/tool-previews/command-preview.d.ts +11 -0
- package/dist/tool-previews/command-preview.js +91 -0
- package/dist/tool-previews/diff-preview.d.ts +7 -0
- package/dist/tool-previews/diff-preview.js +76 -0
- package/dist/tool-previews/glob-results-preview.d.ts +7 -0
- package/dist/tool-previews/glob-results-preview.js +53 -0
- package/dist/tool-previews/grep-results-preview.d.ts +7 -0
- package/dist/tool-previews/grep-results-preview.js +99 -0
- package/dist/tool-previews/preview-primitives.js +58 -0
- package/dist/tool-previews/question-preview.d.ts +7 -0
- package/dist/tool-previews/question-preview.js +63 -0
- package/dist/tool-previews/web-search-preview.d.ts +7 -0
- package/dist/tool-previews/web-search-preview.js +78 -0
- package/dist/tool-previews/write-file-preview.d.ts +11 -0
- package/dist/tool-previews/write-file-preview.js +52 -0
- package/dist/tool-previews.d.ts +7 -1
- package/dist/tool-previews.js +7 -1
- package/dist/{branding-26d5ARIr.d.ts → types/branding.d.ts} +2 -3
- package/dist/{message-vhUI0c5G.d.ts → types/message.d.ts} +2 -3
- package/dist/{parts-5mhy9yJ3.d.ts → types/parts.d.ts} +8 -9
- package/dist/{run-OyWmIDqu.d.ts → types/run.d.ts} +9 -10
- package/dist/{tool-display-DgmL5rIU.d.ts → types/tool-display.d.ts} +5 -6
- package/dist/types.d.ts +5 -5
- package/dist/utils/copy-text.d.ts +7 -0
- package/dist/{utils-Bl_CZ0Qp.js → utils/copy-text.js} +1 -11
- package/dist/utils/format.d.ts +22 -0
- package/dist/{format-DfcLWqMa.js → utils/format.js} +1 -1
- package/dist/utils/time-ago.d.ts +3 -0
- package/dist/utils/time-ago.js +11 -0
- package/dist/utils/tool-display.d.ts +16 -0
- package/dist/{tool-display-BAuAVa43.js → utils/tool-display.js} +1 -1
- package/dist/utils.d.ts +6 -1
- package/dist/utils.js +6 -5
- package/package.json +2 -2
- package/src/editor/document-editor-pane.tsx +4 -1
- package/src/files/file-artifact-pane.test.tsx +23 -0
- package/src/files/file-artifact-pane.tsx +3 -0
- package/src/files/rich-file-tree.stories.tsx +1 -1
- package/src/files/rich-file-tree.tsx +12 -9
- package/src/markdown/code-block.test.tsx +46 -2
- package/src/markdown/code-block.tsx +23 -60
- package/src/markdown/markdown.test.tsx +3 -2
- package/src/primitives/button.stories.tsx +37 -1
- package/src/primitives/button.test.tsx +230 -0
- package/src/primitives/button.tsx +62 -14
- package/src/primitives/card-anatomy.stories.tsx +51 -0
- package/src/primitives/card.test.tsx +71 -0
- package/src/primitives/card.tsx +25 -13
- package/src/primitives/heading.stories.tsx +35 -0
- package/src/primitives/heading.test.tsx +56 -0
- package/src/primitives/heading.tsx +76 -0
- package/src/primitives/index.ts +8 -0
- package/src/primitives/input.stories.tsx +28 -0
- package/src/primitives/input.test.tsx +161 -0
- package/src/primitives/input.tsx +34 -28
- package/src/primitives/page-header.stories.tsx +51 -0
- package/src/primitives/page-header.test.tsx +48 -0
- package/src/primitives/page-header.tsx +35 -35
- package/src/primitives/page-shell.stories.tsx +89 -0
- package/src/primitives/page-shell.test.tsx +24 -0
- package/src/primitives/page-shell.tsx +26 -0
- package/src/primitives/table-wrapper.stories.tsx +54 -0
- package/src/primitives/table.test.tsx +72 -0
- package/src/primitives/table.tsx +33 -12
- package/src/primitives/theme-toggle.test.tsx +167 -0
- package/src/primitives/theme-toggle.tsx +111 -39
- package/dist/active-sessions-store-nl70ZnMC.d.ts +0 -84
- package/dist/button-C87nEe2R.js +0 -78
- package/dist/chat-DDvF2oGQ.js +0 -672
- package/dist/diff-preview-BcK3nRXb.js +0 -533
- package/dist/document-editor-pane-CsFbH2qo.js +0 -1279
- package/dist/files--Unn___t.js +0 -752
- package/dist/index-2UntyjBb.d.ts +0 -52
- package/dist/index-BgUHilZm.d.ts +0 -108
- package/dist/index-CPDET_s1.d.ts +0 -549
- package/dist/index-Cg6gYAqh.d.ts +0 -73
- package/dist/index-Cs7j8V7l.d.ts +0 -203
- package/dist/index-CyGSLGVF.d.ts +0 -234
- package/dist/index-DjKxO357.d.ts +0 -128
- package/dist/primitives-Bx59fT-U.js +0 -1239
- package/dist/table-Bss73DhB.js +0 -146
- package/dist/tool-call-step-DNebqhmX.js +0 -434
- package/dist/use-auto-scroll-C5Pjeqon.js +0 -153
- package/dist/use-sse-stream-DjqRuDft.js +0 -884
- package/dist/use-sse-stream-Dm6R5YWz.d.ts +0 -282
|
@@ -1,533 +0,0 @@
|
|
|
1
|
-
import { i as focusRing } from "./focus-BcE_SHqz.js";
|
|
2
|
-
import { t as cn } from "./utils-C_uf36nf.js";
|
|
3
|
-
import { n as CopyButton, t as CodeBlock } from "./code-block-B36KVUSN.js";
|
|
4
|
-
import { a as getSyntaxLanguage } from "./file-format-BgXbr-Ib.js";
|
|
5
|
-
import { memo, useMemo, useState } from "react";
|
|
6
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { ChevronDown, ChevronRight, FileEdit, FileText, FolderOpen, GitCompareArrows, Globe, Loader2, MessageSquareQuote, Search, Terminal } from "lucide-react";
|
|
8
|
-
//#region src/tool-previews/preview-primitives.tsx
|
|
9
|
-
function PreviewCard({ icon, title, description, meta, children, className }) {
|
|
10
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
11
|
-
className: cn("overflow-hidden rounded-[var(--radius-lg)] border border-border bg-card shadow-[var(--shadow-card)]", className),
|
|
12
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
13
|
-
className: "flex items-center gap-2.5 border-b border-border bg-card px-[var(--tool-card-px)] py-[var(--tool-card-py)]",
|
|
14
|
-
children: [
|
|
15
|
-
/* @__PURE__ */ jsx("div", {
|
|
16
|
-
className: "flex h-[var(--tool-icon-size)] w-[var(--tool-icon-size)] shrink-0 items-center justify-center rounded-[var(--radius-sm)] border border-[var(--border-accent)] bg-muted text-primary",
|
|
17
|
-
children: icon
|
|
18
|
-
}),
|
|
19
|
-
/* @__PURE__ */ jsx("div", {
|
|
20
|
-
className: "min-w-0 flex-1",
|
|
21
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
22
|
-
className: "flex items-center gap-2",
|
|
23
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
24
|
-
className: "text-xs font-semibold text-foreground",
|
|
25
|
-
children: title
|
|
26
|
-
}), description ? /* @__PURE__ */ jsx("span", {
|
|
27
|
-
className: "truncate text-xs font-mono text-muted-foreground",
|
|
28
|
-
children: description
|
|
29
|
-
}) : null]
|
|
30
|
-
})
|
|
31
|
-
}),
|
|
32
|
-
meta ? /* @__PURE__ */ jsx("div", {
|
|
33
|
-
className: "shrink-0 text-xs text-muted-foreground",
|
|
34
|
-
children: meta
|
|
35
|
-
}) : null
|
|
36
|
-
]
|
|
37
|
-
}), children ? /* @__PURE__ */ jsx("div", {
|
|
38
|
-
className: "space-y-2 px-[var(--tool-card-px)] py-[var(--tool-card-py)]",
|
|
39
|
-
children
|
|
40
|
-
}) : null]
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
function PreviewEmpty({ label, className }) {
|
|
44
|
-
return /* @__PURE__ */ jsx("div", {
|
|
45
|
-
className: cn("rounded-[var(--radius-md)] border border-dashed border-border bg-muted px-3 py-2.5 text-xs text-muted-foreground", className),
|
|
46
|
-
children: label
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
function PreviewError({ error }) {
|
|
50
|
-
return /* @__PURE__ */ jsx("div", {
|
|
51
|
-
className: "rounded-[var(--radius-md)] border border-[var(--surface-danger-border)] bg-[var(--surface-danger-bg)] px-3 py-3 text-sm text-[var(--surface-danger-text)]",
|
|
52
|
-
children: error
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
function PreviewLoading({ label = "Running…" }) {
|
|
56
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
57
|
-
className: "flex items-center gap-2 rounded-[var(--radius-md)] border border-border bg-muted px-3 py-2 text-xs text-muted-foreground",
|
|
58
|
-
children: [/* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin text-primary" }), /* @__PURE__ */ jsx("span", { children: label })]
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region src/tool-previews/command-preview.tsx
|
|
63
|
-
/** Extract stdout/stderr/exitCode from tool output. */
|
|
64
|
-
function extractCommandOutput(output) {
|
|
65
|
-
if (!output) return {
|
|
66
|
-
stdout: "",
|
|
67
|
-
stderr: "",
|
|
68
|
-
exitCode: 0
|
|
69
|
-
};
|
|
70
|
-
if (typeof output === "string") return {
|
|
71
|
-
stdout: output,
|
|
72
|
-
stderr: "",
|
|
73
|
-
exitCode: 0
|
|
74
|
-
};
|
|
75
|
-
if (typeof output === "object" && output !== null) {
|
|
76
|
-
const obj = output;
|
|
77
|
-
return {
|
|
78
|
-
stdout: String(obj.stdout ?? obj.output ?? ""),
|
|
79
|
-
stderr: String(obj.stderr ?? ""),
|
|
80
|
-
exitCode: Number(obj.exitCode ?? obj.exit_code ?? obj.code ?? 0)
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
stdout: String(output),
|
|
85
|
-
stderr: "",
|
|
86
|
-
exitCode: 0
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Terminal-style command output preview.
|
|
91
|
-
* Shows the command, exit code, and stdout/stderr with expand/collapse.
|
|
92
|
-
*/
|
|
93
|
-
const CommandPreview = memo(({ part }) => {
|
|
94
|
-
const [expanded, setExpanded] = useState(true);
|
|
95
|
-
const input = part.state.input;
|
|
96
|
-
const command = typeof input?.command === "string" ? input.command : String(input ?? "");
|
|
97
|
-
const output = part.state.status === "completed" ? extractCommandOutput(part.state.output) : null;
|
|
98
|
-
const isError = output ? output.exitCode !== 0 : part.state.status === "error";
|
|
99
|
-
const errorText = part.state.error;
|
|
100
|
-
const lineCount = output?.stdout ? output.stdout.split("\n").length : 0;
|
|
101
|
-
return /* @__PURE__ */ jsxs(PreviewCard, {
|
|
102
|
-
icon: /* @__PURE__ */ jsx(Terminal, { className: "h-4 w-4" }),
|
|
103
|
-
title: "Command",
|
|
104
|
-
description: command,
|
|
105
|
-
meta: output ? /* @__PURE__ */ jsxs("span", {
|
|
106
|
-
className: cn("inline-flex items-center rounded-full border px-2 py-0.5 font-mono", isError ? "border-[var(--surface-danger-border)] bg-[var(--surface-danger-bg)] text-[var(--surface-danger-text)]" : "border-[var(--surface-success-border)] bg-[var(--surface-success-bg)] text-[var(--surface-success-text)]"),
|
|
107
|
-
children: ["exit ", output.exitCode]
|
|
108
|
-
}) : null,
|
|
109
|
-
children: [
|
|
110
|
-
/* @__PURE__ */ jsxs("button", {
|
|
111
|
-
onClick: () => setExpanded((value) => !value),
|
|
112
|
-
className: cn("flex w-full items-center gap-2 rounded-[var(--radius-md)] border border-border bg-muted px-3 py-2 text-left transition-colors hover:border-[var(--border-strong)] hover:bg-accent/45", focusRing),
|
|
113
|
-
children: [
|
|
114
|
-
/* @__PURE__ */ jsx("code", {
|
|
115
|
-
className: "min-w-0 flex-1 truncate text-xs font-mono text-foreground",
|
|
116
|
-
children: command
|
|
117
|
-
}),
|
|
118
|
-
lineCount > 0 ? /* @__PURE__ */ jsxs("span", {
|
|
119
|
-
className: "shrink-0 text-xs text-muted-foreground",
|
|
120
|
-
children: [
|
|
121
|
-
lineCount,
|
|
122
|
-
" line",
|
|
123
|
-
lineCount === 1 ? "" : "s"
|
|
124
|
-
]
|
|
125
|
-
}) : null,
|
|
126
|
-
expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3.5 w-3.5 text-muted-foreground" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3.5 w-3.5 text-muted-foreground" })
|
|
127
|
-
]
|
|
128
|
-
}),
|
|
129
|
-
part.state.status === "running" ? /* @__PURE__ */ jsx(PreviewLoading, {}) : null,
|
|
130
|
-
errorText ? /* @__PURE__ */ jsx(PreviewError, { error: errorText }) : null,
|
|
131
|
-
expanded && output ? /* @__PURE__ */ jsxs("div", {
|
|
132
|
-
className: "overflow-hidden rounded-[var(--radius-md)] border border-border bg-muted",
|
|
133
|
-
children: [output.stdout ? /* @__PURE__ */ jsx("pre", {
|
|
134
|
-
className: "max-h-80 overflow-auto px-3 py-3 text-xs font-mono whitespace-pre-wrap break-all text-foreground",
|
|
135
|
-
children: output.stdout
|
|
136
|
-
}) : null, output.stderr ? /* @__PURE__ */ jsx("pre", {
|
|
137
|
-
className: "max-h-80 overflow-auto border-t border-border px-3 py-3 text-xs font-mono whitespace-pre-wrap break-all text-red-200",
|
|
138
|
-
children: output.stderr
|
|
139
|
-
}) : null]
|
|
140
|
-
}) : null
|
|
141
|
-
]
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
CommandPreview.displayName = "CommandPreview";
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region src/tool-previews/write-file-preview.tsx
|
|
147
|
-
function extractWriteContent(input) {
|
|
148
|
-
if (!input || typeof input !== "object") return null;
|
|
149
|
-
const obj = input;
|
|
150
|
-
return {
|
|
151
|
-
path: String(obj.file_path ?? obj.path ?? obj.filePath ?? "unknown"),
|
|
152
|
-
content: String(obj.content ?? obj.contents ?? obj.data ?? "")
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Preview for file write/create operations.
|
|
157
|
-
* Shows file path, line count, and the written content.
|
|
158
|
-
*/
|
|
159
|
-
const WriteFilePreview = memo(({ part }) => {
|
|
160
|
-
const write = extractWriteContent(part.state.input);
|
|
161
|
-
if (!write) return null;
|
|
162
|
-
const lineCount = write.content.split("\n").length;
|
|
163
|
-
const language = getSyntaxLanguage(write.path);
|
|
164
|
-
return /* @__PURE__ */ jsxs(PreviewCard, {
|
|
165
|
-
icon: /* @__PURE__ */ jsx(FileEdit, { className: "h-4 w-4" }),
|
|
166
|
-
title: "Write file",
|
|
167
|
-
description: write.path,
|
|
168
|
-
meta: /* @__PURE__ */ jsxs("span", {
|
|
169
|
-
className: "text-xs text-muted-foreground",
|
|
170
|
-
children: [
|
|
171
|
-
"+",
|
|
172
|
-
lineCount,
|
|
173
|
-
" line",
|
|
174
|
-
lineCount !== 1 ? "s" : ""
|
|
175
|
-
]
|
|
176
|
-
}),
|
|
177
|
-
children: [
|
|
178
|
-
part.state.status === "running" ? /* @__PURE__ */ jsx(PreviewLoading, { label: "Writing file…" }) : null,
|
|
179
|
-
part.state.error ? /* @__PURE__ */ jsx(PreviewError, { error: part.state.error }) : null,
|
|
180
|
-
/* @__PURE__ */ jsx(CodeBlock, {
|
|
181
|
-
code: write.content,
|
|
182
|
-
language,
|
|
183
|
-
className: "rounded-[var(--radius-md)]",
|
|
184
|
-
children: /* @__PURE__ */ jsx(CopyButton, { text: write.content })
|
|
185
|
-
})
|
|
186
|
-
]
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
WriteFilePreview.displayName = "WriteFilePreview";
|
|
190
|
-
//#endregion
|
|
191
|
-
//#region src/tool-previews/grep-results-preview.tsx
|
|
192
|
-
function coerceString$2(value) {
|
|
193
|
-
return typeof value === "string" && value.trim() ? value : void 0;
|
|
194
|
-
}
|
|
195
|
-
function parseMatch(value) {
|
|
196
|
-
if (typeof value === "string") {
|
|
197
|
-
const [path, maybeLine, ...rest] = value.split(":");
|
|
198
|
-
const line = Number(maybeLine);
|
|
199
|
-
if (rest.length > 0 && Number.isFinite(line)) return {
|
|
200
|
-
path,
|
|
201
|
-
line,
|
|
202
|
-
text: rest.join(":").trim()
|
|
203
|
-
};
|
|
204
|
-
return {
|
|
205
|
-
path: "match",
|
|
206
|
-
text: value
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
if (!value || typeof value !== "object") return null;
|
|
210
|
-
const record = value;
|
|
211
|
-
const path = coerceString$2(record.path) ?? coerceString$2(record.file) ?? coerceString$2(record.filePath) ?? "match";
|
|
212
|
-
const lineValue = record.line ?? record.lineNumber ?? record.line_number;
|
|
213
|
-
const line = typeof lineValue === "number" ? lineValue : Number(lineValue);
|
|
214
|
-
const text = coerceString$2(record.text) ?? coerceString$2(record.content) ?? coerceString$2(record.lineText) ?? coerceString$2(record.preview);
|
|
215
|
-
if (!text) return null;
|
|
216
|
-
return {
|
|
217
|
-
path,
|
|
218
|
-
line: Number.isFinite(line) ? line : void 0,
|
|
219
|
-
text
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
function extractPattern$1(input) {
|
|
223
|
-
if (!input || typeof input !== "object") return;
|
|
224
|
-
const record = input;
|
|
225
|
-
return coerceString$2(record.pattern) ?? coerceString$2(record.query);
|
|
226
|
-
}
|
|
227
|
-
function extractMatches(output) {
|
|
228
|
-
if (Array.isArray(output)) return output.map(parseMatch).filter((value) => value !== null);
|
|
229
|
-
if (output && typeof output === "object") {
|
|
230
|
-
const record = output;
|
|
231
|
-
const candidates = [
|
|
232
|
-
record.matches,
|
|
233
|
-
record.results,
|
|
234
|
-
record.output
|
|
235
|
-
];
|
|
236
|
-
for (const candidate of candidates) if (Array.isArray(candidate)) return candidate.map(parseMatch).filter((value) => value !== null);
|
|
237
|
-
}
|
|
238
|
-
if (typeof output === "string") return output.split("\n").map((line) => line.trim()).filter(Boolean).map(parseMatch).filter((value) => value !== null);
|
|
239
|
-
return [];
|
|
240
|
-
}
|
|
241
|
-
const GrepResultsPreview = memo(({ part }) => {
|
|
242
|
-
const pattern = extractPattern$1(part.state.input);
|
|
243
|
-
const matches = useMemo(() => extractMatches(part.state.output), [part.state.output]);
|
|
244
|
-
const groupedMatches = useMemo(() => {
|
|
245
|
-
const groups = /* @__PURE__ */ new Map();
|
|
246
|
-
for (const match of matches) {
|
|
247
|
-
const list = groups.get(match.path) ?? [];
|
|
248
|
-
list.push(match);
|
|
249
|
-
groups.set(match.path, list);
|
|
250
|
-
}
|
|
251
|
-
return [...groups.entries()];
|
|
252
|
-
}, [matches]);
|
|
253
|
-
return /* @__PURE__ */ jsxs(PreviewCard, {
|
|
254
|
-
icon: /* @__PURE__ */ jsx(Search, { className: "h-4 w-4" }),
|
|
255
|
-
title: pattern ? `Search results for "${pattern}"` : "Search results",
|
|
256
|
-
description: matches.length > 0 ? `${matches.length} match${matches.length === 1 ? "" : "es"}` : void 0,
|
|
257
|
-
children: [
|
|
258
|
-
part.state.status === "running" ? /* @__PURE__ */ jsx(PreviewLoading, { label: "Searching files…" }) : null,
|
|
259
|
-
part.state.error ? /* @__PURE__ */ jsx(PreviewError, { error: part.state.error }) : null,
|
|
260
|
-
part.state.status === "completed" && matches.length === 0 ? /* @__PURE__ */ jsx(PreviewEmpty, { label: "No matching files or lines were returned." }) : null,
|
|
261
|
-
groupedMatches.map(([path, pathMatches]) => /* @__PURE__ */ jsxs("div", {
|
|
262
|
-
className: "rounded-[var(--radius-md)] border border-border bg-muted/55",
|
|
263
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
264
|
-
className: "border-b border-border px-3 py-2 text-xs font-medium text-foreground",
|
|
265
|
-
children: path
|
|
266
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
267
|
-
className: "divide-y divide-border",
|
|
268
|
-
children: pathMatches.map((match, index) => /* @__PURE__ */ jsxs("div", {
|
|
269
|
-
className: "grid grid-cols-[auto_minmax(0,1fr)] gap-3 px-3 py-2",
|
|
270
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
271
|
-
className: "pt-0.5 text-xs font-mono text-muted-foreground",
|
|
272
|
-
children: match.line ?? "·"
|
|
273
|
-
}), /* @__PURE__ */ jsx("pre", {
|
|
274
|
-
className: "overflow-x-auto whitespace-pre-wrap break-words text-xs font-mono text-foreground",
|
|
275
|
-
children: match.text
|
|
276
|
-
})]
|
|
277
|
-
}, `${path}-${match.line ?? index}-${index}`))
|
|
278
|
-
})]
|
|
279
|
-
}, path))
|
|
280
|
-
]
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
GrepResultsPreview.displayName = "GrepResultsPreview";
|
|
284
|
-
//#endregion
|
|
285
|
-
//#region src/tool-previews/glob-results-preview.tsx
|
|
286
|
-
function coerceString$1(value) {
|
|
287
|
-
return typeof value === "string" && value.trim() ? value : void 0;
|
|
288
|
-
}
|
|
289
|
-
function extractPattern(input) {
|
|
290
|
-
if (!input || typeof input !== "object") return;
|
|
291
|
-
const record = input;
|
|
292
|
-
return coerceString$1(record.pattern) ?? coerceString$1(record.path);
|
|
293
|
-
}
|
|
294
|
-
function extractFiles(output) {
|
|
295
|
-
if (Array.isArray(output)) return output.map((item) => String(item)).filter(Boolean);
|
|
296
|
-
if (output && typeof output === "object") {
|
|
297
|
-
const record = output;
|
|
298
|
-
const candidate = record.files ?? record.matches ?? record.paths ?? record.results;
|
|
299
|
-
if (Array.isArray(candidate)) return candidate.map((item) => typeof item === "string" ? item : item && typeof item === "object" ? String(item.path ?? item.file ?? "") : "").filter(Boolean);
|
|
300
|
-
}
|
|
301
|
-
if (typeof output === "string") return output.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
302
|
-
return [];
|
|
303
|
-
}
|
|
304
|
-
const GlobResultsPreview = memo(({ part }) => {
|
|
305
|
-
const pattern = extractPattern(part.state.input);
|
|
306
|
-
const files = useMemo(() => extractFiles(part.state.output), [part.state.output]);
|
|
307
|
-
return /* @__PURE__ */ jsxs(PreviewCard, {
|
|
308
|
-
icon: /* @__PURE__ */ jsx(FolderOpen, { className: "h-4 w-4" }),
|
|
309
|
-
title: pattern ? `Files for ${pattern}` : "File results",
|
|
310
|
-
description: files.length > 0 ? `${files.length} path${files.length === 1 ? "" : "s"}` : void 0,
|
|
311
|
-
children: [
|
|
312
|
-
part.state.status === "running" ? /* @__PURE__ */ jsx(PreviewLoading, { label: "Collecting files…" }) : null,
|
|
313
|
-
part.state.error ? /* @__PURE__ */ jsx(PreviewError, { error: part.state.error }) : null,
|
|
314
|
-
part.state.status === "completed" && files.length === 0 ? /* @__PURE__ */ jsx(PreviewEmpty, { label: "No matching files were returned." }) : null,
|
|
315
|
-
files.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
316
|
-
className: "grid gap-2 sm:grid-cols-2",
|
|
317
|
-
children: files.map((file) => {
|
|
318
|
-
const Icon = file.endsWith("/") ? FolderOpen : FileText;
|
|
319
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
320
|
-
className: "flex items-center gap-2 rounded-[var(--radius-md)] border border-border bg-muted/55 px-3 py-2",
|
|
321
|
-
children: [/* @__PURE__ */ jsx(Icon, { className: "h-4 w-4 shrink-0 text-primary" }), /* @__PURE__ */ jsx("span", {
|
|
322
|
-
className: "min-w-0 truncate text-xs font-mono text-foreground",
|
|
323
|
-
children: file
|
|
324
|
-
})]
|
|
325
|
-
}, file);
|
|
326
|
-
})
|
|
327
|
-
}) : null
|
|
328
|
-
]
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
GlobResultsPreview.displayName = "GlobResultsPreview";
|
|
332
|
-
//#endregion
|
|
333
|
-
//#region src/tool-previews/web-search-preview.tsx
|
|
334
|
-
function coerceString(value) {
|
|
335
|
-
return typeof value === "string" && value.trim() ? value : void 0;
|
|
336
|
-
}
|
|
337
|
-
function extractQuery(input, output) {
|
|
338
|
-
if (input && typeof input === "object") {
|
|
339
|
-
const record = input;
|
|
340
|
-
const query = coerceString(record.query) ?? coerceString(record.url);
|
|
341
|
-
if (query) return query;
|
|
342
|
-
}
|
|
343
|
-
if (output && typeof output === "object") return coerceString(output.query);
|
|
344
|
-
}
|
|
345
|
-
function parseResult(value) {
|
|
346
|
-
if (!value || typeof value !== "object") return null;
|
|
347
|
-
const record = value;
|
|
348
|
-
const title = coerceString(record.title) ?? coerceString(record.name) ?? "Untitled result";
|
|
349
|
-
const url = coerceString(record.url) ?? coerceString(record.link);
|
|
350
|
-
if (!url) return null;
|
|
351
|
-
return {
|
|
352
|
-
title,
|
|
353
|
-
url,
|
|
354
|
-
snippet: coerceString(record.snippet) ?? coerceString(record.description) ?? coerceString(record.text)
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
function extractResults(output) {
|
|
358
|
-
if (output && typeof output === "object") {
|
|
359
|
-
const record = output;
|
|
360
|
-
const candidate = record.results ?? record.items ?? record.output;
|
|
361
|
-
if (Array.isArray(candidate)) return candidate.map(parseResult).filter((value) => value !== null);
|
|
362
|
-
}
|
|
363
|
-
if (Array.isArray(output)) return output.map(parseResult).filter((value) => value !== null);
|
|
364
|
-
return [];
|
|
365
|
-
}
|
|
366
|
-
const WebSearchPreview = memo(({ part }) => {
|
|
367
|
-
const query = extractQuery(part.state.input, part.state.output);
|
|
368
|
-
const results = useMemo(() => extractResults(part.state.output), [part.state.output]);
|
|
369
|
-
return /* @__PURE__ */ jsxs(PreviewCard, {
|
|
370
|
-
icon: /* @__PURE__ */ jsx(Globe, { className: "h-4 w-4" }),
|
|
371
|
-
title: query ? `Web results for ${query}` : "Web results",
|
|
372
|
-
description: results.length > 0 ? `${results.length} result${results.length === 1 ? "" : "s"}` : void 0,
|
|
373
|
-
children: [
|
|
374
|
-
part.state.status === "running" ? /* @__PURE__ */ jsx(PreviewLoading, { label: "Searching the web…" }) : null,
|
|
375
|
-
part.state.error ? /* @__PURE__ */ jsx(PreviewError, { error: part.state.error }) : null,
|
|
376
|
-
part.state.status === "completed" && results.length === 0 ? /* @__PURE__ */ jsx(PreviewEmpty, { label: "No web results were returned." }) : null,
|
|
377
|
-
/* @__PURE__ */ jsx("div", {
|
|
378
|
-
className: "space-y-2",
|
|
379
|
-
children: results.map((result) => /* @__PURE__ */ jsxs("a", {
|
|
380
|
-
href: result.url,
|
|
381
|
-
target: "_blank",
|
|
382
|
-
rel: "noreferrer",
|
|
383
|
-
className: `block rounded-[var(--radius-md)] border border-border bg-muted/55 px-3 py-3 transition-colors hover:border-[var(--border-strong)] hover:bg-accent/50 ${focusRing}`,
|
|
384
|
-
children: [
|
|
385
|
-
/* @__PURE__ */ jsx("div", {
|
|
386
|
-
className: "text-sm font-medium text-foreground",
|
|
387
|
-
children: result.title
|
|
388
|
-
}),
|
|
389
|
-
/* @__PURE__ */ jsx("div", {
|
|
390
|
-
className: "mt-1 truncate text-xs text-primary",
|
|
391
|
-
children: result.url
|
|
392
|
-
}),
|
|
393
|
-
result.snippet ? /* @__PURE__ */ jsx("p", {
|
|
394
|
-
className: "mt-2 text-sm leading-relaxed text-muted-foreground",
|
|
395
|
-
children: result.snippet
|
|
396
|
-
}) : null
|
|
397
|
-
]
|
|
398
|
-
}, result.url))
|
|
399
|
-
})
|
|
400
|
-
]
|
|
401
|
-
});
|
|
402
|
-
});
|
|
403
|
-
WebSearchPreview.displayName = "WebSearchPreview";
|
|
404
|
-
//#endregion
|
|
405
|
-
//#region src/tool-previews/question-preview.tsx
|
|
406
|
-
function toQuestionList(input) {
|
|
407
|
-
if (!input) return [];
|
|
408
|
-
if (typeof input === "string") return [input];
|
|
409
|
-
if (Array.isArray(input)) return input.map((item) => String(item)).filter(Boolean);
|
|
410
|
-
if (typeof input === "object") {
|
|
411
|
-
const record = input;
|
|
412
|
-
const value = record.questions ?? record.question ?? record.prompt;
|
|
413
|
-
if (Array.isArray(value)) return value.map((item) => String(item)).filter(Boolean);
|
|
414
|
-
if (typeof value === "string") return [value];
|
|
415
|
-
}
|
|
416
|
-
return [];
|
|
417
|
-
}
|
|
418
|
-
function toAnswerList(output) {
|
|
419
|
-
if (!output) return [];
|
|
420
|
-
if (typeof output === "string") return [output];
|
|
421
|
-
if (Array.isArray(output)) return output.map((item) => String(item)).filter(Boolean);
|
|
422
|
-
if (typeof output === "object") {
|
|
423
|
-
const record = output;
|
|
424
|
-
const value = record.answers ?? record.answer ?? record.response;
|
|
425
|
-
if (Array.isArray(value)) return value.map((item) => String(item)).filter(Boolean);
|
|
426
|
-
if (typeof value === "string") return [value];
|
|
427
|
-
}
|
|
428
|
-
return [];
|
|
429
|
-
}
|
|
430
|
-
const QuestionPreview = memo(({ part }) => {
|
|
431
|
-
const questions = useMemo(() => toQuestionList(part.state.input), [part.state.input]);
|
|
432
|
-
const answers = useMemo(() => toAnswerList(part.state.output), [part.state.output]);
|
|
433
|
-
return /* @__PURE__ */ jsxs(PreviewCard, {
|
|
434
|
-
icon: /* @__PURE__ */ jsx(MessageSquareQuote, { className: "h-4 w-4" }),
|
|
435
|
-
title: "Agent question",
|
|
436
|
-
description: questions.length > 1 ? `${questions.length} questions require attention` : void 0,
|
|
437
|
-
children: [
|
|
438
|
-
part.state.status === "running" ? /* @__PURE__ */ jsx(PreviewLoading, { label: "Waiting for an answer…" }) : null,
|
|
439
|
-
part.state.error ? /* @__PURE__ */ jsx(PreviewError, { error: part.state.error }) : null,
|
|
440
|
-
questions.length === 0 ? /* @__PURE__ */ jsx(PreviewEmpty, { label: "No question text was provided." }) : null,
|
|
441
|
-
questions.map((question, index) => /* @__PURE__ */ jsxs("div", {
|
|
442
|
-
className: "rounded-[var(--radius-md)] border border-border bg-muted px-3 py-3",
|
|
443
|
-
children: [
|
|
444
|
-
/* @__PURE__ */ jsxs("div", {
|
|
445
|
-
className: "text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground",
|
|
446
|
-
children: ["Question ", index + 1]
|
|
447
|
-
}),
|
|
448
|
-
/* @__PURE__ */ jsx("div", {
|
|
449
|
-
className: "mt-2 text-sm leading-relaxed text-foreground",
|
|
450
|
-
children: question
|
|
451
|
-
}),
|
|
452
|
-
/* @__PURE__ */ jsx("div", {
|
|
453
|
-
className: "mt-3 rounded-[var(--radius-sm)] border border-border bg-card px-3 py-2 text-sm text-foreground",
|
|
454
|
-
children: answers[index] ?? (part.state.status === "completed" ? "No answer recorded." : "Awaiting answer")
|
|
455
|
-
})
|
|
456
|
-
]
|
|
457
|
-
}, `${question}-${index}`))
|
|
458
|
-
]
|
|
459
|
-
});
|
|
460
|
-
});
|
|
461
|
-
QuestionPreview.displayName = "QuestionPreview";
|
|
462
|
-
//#endregion
|
|
463
|
-
//#region src/tool-previews/diff-preview.tsx
|
|
464
|
-
function extractString(record, ...keys) {
|
|
465
|
-
for (const key of keys) {
|
|
466
|
-
const value = record[key];
|
|
467
|
-
if (typeof value === "string" && value.length > 0) return value;
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
function extractDiffPayload(part) {
|
|
471
|
-
const sources = [
|
|
472
|
-
part.state.input,
|
|
473
|
-
part.state.output,
|
|
474
|
-
part.state.metadata
|
|
475
|
-
];
|
|
476
|
-
for (const source of sources) {
|
|
477
|
-
if (!source || typeof source !== "object") continue;
|
|
478
|
-
const record = source;
|
|
479
|
-
const diff = extractString(record, "diff", "patch", "unifiedDiff", "unified_diff");
|
|
480
|
-
const before = extractString(record, "oldString", "old_string", "before", "previous");
|
|
481
|
-
const after = extractString(record, "newString", "new_string", "after", "updated");
|
|
482
|
-
const path = extractString(record, "file_path", "filePath", "path");
|
|
483
|
-
if (diff || before || after) return {
|
|
484
|
-
path,
|
|
485
|
-
diff,
|
|
486
|
-
before,
|
|
487
|
-
after
|
|
488
|
-
};
|
|
489
|
-
}
|
|
490
|
-
return {};
|
|
491
|
-
}
|
|
492
|
-
const DiffPreview = memo(({ part }) => {
|
|
493
|
-
const payload = extractDiffPayload(part);
|
|
494
|
-
return /* @__PURE__ */ jsxs(PreviewCard, {
|
|
495
|
-
icon: /* @__PURE__ */ jsx(GitCompareArrows, { className: "h-4 w-4" }),
|
|
496
|
-
title: payload.path ? `Changes for ${payload.path}` : "File changes",
|
|
497
|
-
children: [
|
|
498
|
-
part.state.status === "running" ? /* @__PURE__ */ jsx(PreviewLoading, { label: "Computing changes…" }) : null,
|
|
499
|
-
part.state.error ? /* @__PURE__ */ jsx(PreviewError, { error: part.state.error }) : null,
|
|
500
|
-
!payload.diff && !payload.before && !payload.after ? /* @__PURE__ */ jsx(PreviewEmpty, { label: "No structured diff payload was provided." }) : null,
|
|
501
|
-
payload.diff ? /* @__PURE__ */ jsx(CodeBlock, {
|
|
502
|
-
code: payload.diff,
|
|
503
|
-
language: "diff",
|
|
504
|
-
className: "rounded-[var(--radius-md)]"
|
|
505
|
-
}) : null,
|
|
506
|
-
!payload.diff && payload.before ? /* @__PURE__ */ jsxs("div", {
|
|
507
|
-
className: "space-y-2",
|
|
508
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
509
|
-
className: "text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground",
|
|
510
|
-
children: "Before"
|
|
511
|
-
}), /* @__PURE__ */ jsx(CodeBlock, {
|
|
512
|
-
code: payload.before,
|
|
513
|
-
language: "text",
|
|
514
|
-
className: "rounded-[var(--radius-md)]"
|
|
515
|
-
})]
|
|
516
|
-
}) : null,
|
|
517
|
-
!payload.diff && payload.after ? /* @__PURE__ */ jsxs("div", {
|
|
518
|
-
className: "space-y-2",
|
|
519
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
520
|
-
className: "text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground",
|
|
521
|
-
children: "After"
|
|
522
|
-
}), /* @__PURE__ */ jsx(CodeBlock, {
|
|
523
|
-
code: payload.after,
|
|
524
|
-
language: "text",
|
|
525
|
-
className: "rounded-[var(--radius-md)]"
|
|
526
|
-
})]
|
|
527
|
-
}) : null
|
|
528
|
-
]
|
|
529
|
-
});
|
|
530
|
-
});
|
|
531
|
-
DiffPreview.displayName = "DiffPreview";
|
|
532
|
-
//#endregion
|
|
533
|
-
export { GrepResultsPreview as a, GlobResultsPreview as i, QuestionPreview as n, WriteFilePreview as o, WebSearchPreview as r, CommandPreview as s, DiffPreview as t };
|