@tangle-network/ui 1.0.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 +12 -0
- package/LICENSE +21 -0
- package/README.md +33 -0
- package/dist/active-sessions-store-CeOmXgv5.d.ts +85 -0
- package/dist/artifact-pane-DvJyPWV4.d.ts +24 -0
- package/dist/auth.d.ts +74 -0
- package/dist/auth.js +15 -0
- package/dist/button-CMQuQEW_.d.ts +17 -0
- package/dist/chat.d.ts +232 -0
- package/dist/chat.js +30 -0
- package/dist/chunk-2NFQRQOD.js +1009 -0
- package/dist/chunk-2VH6PUXD.js +186 -0
- package/dist/chunk-34A66VBG.js +214 -0
- package/dist/chunk-3OI2QKFD.js +0 -0
- package/dist/chunk-4CLN43XT.js +45 -0
- package/dist/chunk-54SQQMMM.js +156 -0
- package/dist/chunk-5Z5ZYMOJ.js +0 -0
- package/dist/chunk-66BNMOVT.js +167 -0
- package/dist/chunk-6BGQA4BQ.js +0 -0
- package/dist/chunk-7UO2ZMRQ.js +133 -0
- package/dist/chunk-BX6AQMUS.js +183 -0
- package/dist/chunk-CD53GZOM.js +59 -0
- package/dist/chunk-CSAIKY36.js +54 -0
- package/dist/chunk-EEE55AVS.js +1201 -0
- package/dist/chunk-GYPQXTJU.js +230 -0
- package/dist/chunk-HFL6R6IF.js +37 -0
- package/dist/chunk-HJKCSXCH.js +737 -0
- package/dist/chunk-LISXUB4D.js +1222 -0
- package/dist/chunk-LQS34IGP.js +0 -0
- package/dist/chunk-MKTSMWVD.js +109 -0
- package/dist/chunk-NKDZ7GZE.js +192 -0
- package/dist/chunk-OEX7NZE3.js +321 -0
- package/dist/chunk-Q56BYXQF.js +61 -0
- package/dist/chunk-Q7EIIWTC.js +0 -0
- package/dist/chunk-REJESC5U.js +117 -0
- package/dist/chunk-RQGKSCEZ.js +0 -0
- package/dist/chunk-RQHJBTEU.js +10 -0
- package/dist/chunk-TMFOPHHN.js +299 -0
- package/dist/chunk-XGKULLYE.js +40 -0
- package/dist/chunk-XIHMJ7ZQ.js +614 -0
- package/dist/chunk-YJ2G3XO5.js +1048 -0
- package/dist/chunk-YNN4O57I.js +754 -0
- package/dist/code-block-DjXf8eOG.d.ts +19 -0
- package/dist/document-editor-pane-A5LT5H4N.js +12 -0
- package/dist/document-editor-pane-DyDEX_Zm.d.ts +124 -0
- package/dist/editor.d.ts +120 -0
- package/dist/editor.js +34 -0
- package/dist/files.d.ts +175 -0
- package/dist/files.js +20 -0
- package/dist/hooks.d.ts +56 -0
- package/dist/hooks.js +41 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +446 -0
- package/dist/markdown.d.ts +15 -0
- package/dist/markdown.js +14 -0
- package/dist/message-BHWbxBtT.d.ts +15 -0
- package/dist/openui.d.ts +115 -0
- package/dist/openui.js +12 -0
- package/dist/parts-dj7AcUg0.d.ts +36 -0
- package/dist/primitives.d.ts +332 -0
- package/dist/primitives.js +191 -0
- package/dist/run-PfLmDAox.d.ts +41 -0
- package/dist/run.d.ts +69 -0
- package/dist/run.js +36 -0
- package/dist/sdk-hooks.d.ts +285 -0
- package/dist/sdk-hooks.js +31 -0
- package/dist/stores.d.ts +17 -0
- package/dist/stores.js +76 -0
- package/dist/tool-call-feed-Bs3MyQMT.d.ts +68 -0
- package/dist/tool-display-z4JcDmMQ.d.ts +32 -0
- package/dist/tool-previews.d.ts +48 -0
- package/dist/tool-previews.js +21 -0
- package/dist/types.d.ts +19 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +45 -0
- package/dist/utils.js +32 -0
- package/package.json +193 -0
- package/src/auth/auth.tsx +228 -0
- package/src/auth/index.ts +13 -0
- package/src/auth/login-layout.tsx +46 -0
- package/src/chat/agent-timeline.stories.tsx +429 -0
- package/src/chat/agent-timeline.tsx +360 -0
- package/src/chat/chat-container.tsx +486 -0
- package/src/chat/chat-input.stories.tsx +142 -0
- package/src/chat/chat-input.tsx +389 -0
- package/src/chat/chat-message.stories.tsx +237 -0
- package/src/chat/chat-message.tsx +129 -0
- package/src/chat/index.ts +18 -0
- package/src/chat/message-list.stories.tsx +336 -0
- package/src/chat/message-list.tsx +79 -0
- package/src/chat/thinking-indicator.stories.tsx +56 -0
- package/src/chat/thinking-indicator.tsx +30 -0
- package/src/chat/user-message.stories.tsx +92 -0
- package/src/chat/user-message.tsx +43 -0
- package/src/editor/document-editor-pane.tsx +351 -0
- package/src/editor/editor-provider.tsx +428 -0
- package/src/editor/editor-toolbar.tsx +130 -0
- package/src/editor/index.ts +31 -0
- package/src/editor/markdown-conversion.ts +21 -0
- package/src/editor/markdown-document-editor.tsx +137 -0
- package/src/editor/tiptap-editor.tsx +331 -0
- package/src/editor/use-editor.ts +221 -0
- package/src/files/file-artifact-pane.tsx +183 -0
- package/src/files/file-preview.tsx +342 -0
- package/src/files/file-tabs.tsx +71 -0
- package/src/files/file-tree.tsx +258 -0
- package/src/files/index.ts +17 -0
- package/src/files/rich-file-tree.stories.tsx +104 -0
- package/src/files/rich-file-tree.test.tsx +42 -0
- package/src/files/rich-file-tree.tsx +232 -0
- package/src/hooks/index.ts +10 -0
- package/src/hooks/use-auth.ts +153 -0
- package/src/hooks/use-auto-scroll.ts +59 -0
- package/src/hooks/use-dropdown-menu.ts +40 -0
- package/src/hooks/use-live-time.test.tsx +40 -0
- package/src/hooks/use-live-time.ts +27 -0
- package/src/hooks/use-realtime-session.ts +319 -0
- package/src/hooks/use-run-collapse-state.ts +25 -0
- package/src/hooks/use-run-groups.ts +111 -0
- package/src/hooks/use-sdk-session.ts +575 -0
- package/src/hooks/use-sse-stream.ts +475 -0
- package/src/hooks/use-tool-call-stream.ts +96 -0
- package/src/index.ts +14 -0
- package/src/lib/utils.ts +6 -0
- package/src/markdown/code-block.tsx +198 -0
- package/src/markdown/index.ts +2 -0
- package/src/markdown/markdown.stories.tsx +190 -0
- package/src/markdown/markdown.tsx +62 -0
- package/src/openui/index.ts +20 -0
- package/src/openui/openui-artifact-renderer.tsx +542 -0
- package/src/primitives/artifact-pane.tsx +91 -0
- package/src/primitives/avatar.stories.tsx +95 -0
- package/src/primitives/avatar.tsx +47 -0
- package/src/primitives/badge.stories.tsx +57 -0
- package/src/primitives/badge.tsx +97 -0
- package/src/primitives/button.stories.tsx +48 -0
- package/src/primitives/button.tsx +115 -0
- package/src/primitives/card.stories.tsx +53 -0
- package/src/primitives/card.tsx +98 -0
- package/src/primitives/code-block.stories.tsx +115 -0
- package/src/primitives/code-block.tsx +22 -0
- package/src/primitives/design-tokens.stories.tsx +162 -0
- package/src/primitives/dialog.stories.tsx +176 -0
- package/src/primitives/dialog.tsx +137 -0
- package/src/primitives/drop-zone.stories.tsx +123 -0
- package/src/primitives/drop-zone.tsx +131 -0
- package/src/primitives/dropdown-menu.stories.tsx +122 -0
- package/src/primitives/dropdown-menu.tsx +214 -0
- package/src/primitives/empty-state.stories.tsx +81 -0
- package/src/primitives/empty-state.tsx +40 -0
- package/src/primitives/index.ts +118 -0
- package/src/primitives/input.stories.tsx +113 -0
- package/src/primitives/input.tsx +136 -0
- package/src/primitives/label.stories.tsx +84 -0
- package/src/primitives/label.tsx +24 -0
- package/src/primitives/progress.stories.tsx +93 -0
- package/src/primitives/progress.tsx +50 -0
- package/src/primitives/segmented-control.test.tsx +328 -0
- package/src/primitives/segmented-control.tsx +154 -0
- package/src/primitives/select.stories.tsx +164 -0
- package/src/primitives/select.tsx +158 -0
- package/src/primitives/sidebar-drop-zone.stories.tsx +100 -0
- package/src/primitives/sidebar-drop-zone.tsx +149 -0
- package/src/primitives/skeleton.stories.tsx +79 -0
- package/src/primitives/skeleton.tsx +55 -0
- package/src/primitives/stat-card.stories.tsx +137 -0
- package/src/primitives/stat-card.tsx +97 -0
- package/src/primitives/switch.stories.tsx +85 -0
- package/src/primitives/switch.tsx +28 -0
- package/src/primitives/table.stories.tsx +170 -0
- package/src/primitives/table.tsx +116 -0
- package/src/primitives/tabs.stories.tsx +180 -0
- package/src/primitives/tabs.tsx +71 -0
- package/src/primitives/terminal-display.stories.tsx +191 -0
- package/src/primitives/terminal-display.tsx +189 -0
- package/src/primitives/theme-toggle.stories.tsx +32 -0
- package/src/primitives/theme-toggle.tsx +96 -0
- package/src/primitives/toast.stories.tsx +155 -0
- package/src/primitives/toast.tsx +190 -0
- package/src/primitives/upload-progress.stories.tsx +120 -0
- package/src/primitives/upload-progress.tsx +110 -0
- package/src/run/expanded-tool-detail.stories.tsx +182 -0
- package/src/run/expanded-tool-detail.tsx +186 -0
- package/src/run/index.ts +13 -0
- package/src/run/inline-thinking-item.stories.tsx +136 -0
- package/src/run/inline-thinking-item.tsx +120 -0
- package/src/run/inline-tool-item.stories.tsx +222 -0
- package/src/run/inline-tool-item.tsx +190 -0
- package/src/run/run-group.stories.tsx +322 -0
- package/src/run/run-group.tsx +569 -0
- package/src/run/run-item-primitives.tsx +17 -0
- package/src/run/tool-call-feed.stories.tsx +294 -0
- package/src/run/tool-call-feed.tsx +192 -0
- package/src/run/tool-call-step.stories.tsx +198 -0
- package/src/run/tool-call-step.tsx +240 -0
- package/src/sdk-hooks.ts +38 -0
- package/src/stores/active-sessions-store.ts +455 -0
- package/src/stores/chat-store.ts +43 -0
- package/src/stores/index.ts +2 -0
- package/src/tool-previews/command-preview.tsx +116 -0
- package/src/tool-previews/diff-preview.tsx +85 -0
- package/src/tool-previews/glob-results-preview.tsx +98 -0
- package/src/tool-previews/grep-results-preview.tsx +157 -0
- package/src/tool-previews/index.ts +22 -0
- package/src/tool-previews/preview-primitives.tsx +84 -0
- package/src/tool-previews/question-preview.tsx +101 -0
- package/src/tool-previews/web-search-preview.tsx +117 -0
- package/src/tool-previews/write-file-preview.tsx +80 -0
- package/src/types/branding.ts +11 -0
- package/src/types/index.ts +5 -0
- package/src/types/message.ts +13 -0
- package/src/types/parts.ts +51 -0
- package/src/types/run.ts +56 -0
- package/src/types/tool-display.ts +41 -0
- package/src/utils/copy-text.ts +30 -0
- package/src/utils/format.test.ts +43 -0
- package/src/utils/format.ts +56 -0
- package/src/utils/index.ts +10 -0
- package/src/utils/time-ago.ts +9 -0
- package/src/utils/tool-display.ts +238 -0
|
@@ -0,0 +1,614 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CodeBlock,
|
|
3
|
+
CopyButton
|
|
4
|
+
} from "./chunk-66BNMOVT.js";
|
|
5
|
+
import {
|
|
6
|
+
cn
|
|
7
|
+
} from "./chunk-RQHJBTEU.js";
|
|
8
|
+
|
|
9
|
+
// src/tool-previews/command-preview.tsx
|
|
10
|
+
import { memo, useState } from "react";
|
|
11
|
+
import {
|
|
12
|
+
Terminal,
|
|
13
|
+
ChevronDown,
|
|
14
|
+
ChevronRight
|
|
15
|
+
} from "lucide-react";
|
|
16
|
+
|
|
17
|
+
// src/tool-previews/preview-primitives.tsx
|
|
18
|
+
import { Loader2 } from "lucide-react";
|
|
19
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
+
function PreviewCard({
|
|
21
|
+
icon,
|
|
22
|
+
title,
|
|
23
|
+
description,
|
|
24
|
+
meta,
|
|
25
|
+
children,
|
|
26
|
+
className
|
|
27
|
+
}) {
|
|
28
|
+
return /* @__PURE__ */ jsxs(
|
|
29
|
+
"div",
|
|
30
|
+
{
|
|
31
|
+
className: cn(
|
|
32
|
+
"overflow-hidden rounded-[var(--radius-lg)] border border-border bg-card shadow-[var(--shadow-card)]",
|
|
33
|
+
className
|
|
34
|
+
),
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2.5 border-b border-border bg-card px-[var(--tool-card-px)] py-[var(--tool-card-py)]", children: [
|
|
37
|
+
/* @__PURE__ */ jsx("div", { 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", children: icon }),
|
|
38
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
39
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-semibold text-foreground", children: title }),
|
|
40
|
+
description ? /* @__PURE__ */ jsx("span", { className: "truncate text-xs font-mono text-muted-foreground", children: description }) : null
|
|
41
|
+
] }) }),
|
|
42
|
+
meta ? /* @__PURE__ */ jsx("div", { className: "shrink-0 text-xs text-muted-foreground", children: meta }) : null
|
|
43
|
+
] }),
|
|
44
|
+
children ? /* @__PURE__ */ jsx("div", { className: "space-y-2 px-[var(--tool-card-px)] py-[var(--tool-card-py)]", children }) : null
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
function PreviewEmpty({
|
|
50
|
+
label,
|
|
51
|
+
className
|
|
52
|
+
}) {
|
|
53
|
+
return /* @__PURE__ */ jsx(
|
|
54
|
+
"div",
|
|
55
|
+
{
|
|
56
|
+
className: cn(
|
|
57
|
+
"rounded-[var(--radius-md)] border border-dashed border-border bg-muted px-3 py-2.5 text-xs text-muted-foreground",
|
|
58
|
+
className
|
|
59
|
+
),
|
|
60
|
+
children: label
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
function PreviewError({ error }) {
|
|
65
|
+
return /* @__PURE__ */ jsx("div", { 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)]", children: error });
|
|
66
|
+
}
|
|
67
|
+
function PreviewLoading({ label = "Running\u2026" }) {
|
|
68
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-[var(--radius-md)] border border-border bg-muted px-3 py-2 text-xs text-muted-foreground", children: [
|
|
69
|
+
/* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin text-primary" }),
|
|
70
|
+
/* @__PURE__ */ jsx("span", { children: label })
|
|
71
|
+
] });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/tool-previews/command-preview.tsx
|
|
75
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
76
|
+
function extractCommandOutput(output) {
|
|
77
|
+
if (!output) return { stdout: "", stderr: "", exitCode: 0 };
|
|
78
|
+
if (typeof output === "string") return { stdout: output, stderr: "", exitCode: 0 };
|
|
79
|
+
if (typeof output === "object" && output !== null) {
|
|
80
|
+
const obj = output;
|
|
81
|
+
return {
|
|
82
|
+
stdout: String(obj.stdout ?? obj.output ?? ""),
|
|
83
|
+
stderr: String(obj.stderr ?? ""),
|
|
84
|
+
exitCode: Number(obj.exitCode ?? obj.exit_code ?? obj.code ?? 0)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return { stdout: String(output), stderr: "", exitCode: 0 };
|
|
88
|
+
}
|
|
89
|
+
var CommandPreview = memo(({ part }) => {
|
|
90
|
+
const [expanded, setExpanded] = useState(true);
|
|
91
|
+
const input = part.state.input;
|
|
92
|
+
const command = typeof input?.command === "string" ? input.command : String(input ?? "");
|
|
93
|
+
const output = part.state.status === "completed" ? extractCommandOutput(part.state.output) : null;
|
|
94
|
+
const isError = output ? output.exitCode !== 0 : part.state.status === "error";
|
|
95
|
+
const errorText = part.state.error;
|
|
96
|
+
const lineCount = output?.stdout ? output.stdout.split("\n").length : 0;
|
|
97
|
+
return /* @__PURE__ */ jsxs2(
|
|
98
|
+
PreviewCard,
|
|
99
|
+
{
|
|
100
|
+
icon: /* @__PURE__ */ jsx2(Terminal, { className: "h-4 w-4" }),
|
|
101
|
+
title: "Command",
|
|
102
|
+
description: command,
|
|
103
|
+
meta: output ? /* @__PURE__ */ jsxs2(
|
|
104
|
+
"span",
|
|
105
|
+
{
|
|
106
|
+
className: cn(
|
|
107
|
+
"inline-flex items-center rounded-full border px-2 py-0.5 font-mono",
|
|
108
|
+
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)]"
|
|
109
|
+
),
|
|
110
|
+
children: [
|
|
111
|
+
"exit ",
|
|
112
|
+
output.exitCode
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
) : null,
|
|
116
|
+
children: [
|
|
117
|
+
/* @__PURE__ */ jsxs2(
|
|
118
|
+
"button",
|
|
119
|
+
{
|
|
120
|
+
onClick: () => setExpanded((value) => !value),
|
|
121
|
+
className: "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-accent-hover)] hover:bg-accent/45",
|
|
122
|
+
children: [
|
|
123
|
+
/* @__PURE__ */ jsx2("code", { className: "min-w-0 flex-1 truncate text-xs font-mono text-foreground", children: command }),
|
|
124
|
+
lineCount > 0 ? /* @__PURE__ */ jsxs2("span", { className: "shrink-0 text-xs text-muted-foreground", children: [
|
|
125
|
+
lineCount,
|
|
126
|
+
" line",
|
|
127
|
+
lineCount === 1 ? "" : "s"
|
|
128
|
+
] }) : null,
|
|
129
|
+
expanded ? /* @__PURE__ */ jsx2(ChevronDown, { className: "h-3.5 w-3.5 text-muted-foreground" }) : /* @__PURE__ */ jsx2(ChevronRight, { className: "h-3.5 w-3.5 text-muted-foreground" })
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
part.state.status === "running" ? /* @__PURE__ */ jsx2(PreviewLoading, {}) : null,
|
|
134
|
+
errorText ? /* @__PURE__ */ jsx2(PreviewError, { error: errorText }) : null,
|
|
135
|
+
expanded && output ? /* @__PURE__ */ jsxs2("div", { className: "overflow-hidden rounded-[var(--radius-md)] border border-border bg-muted", children: [
|
|
136
|
+
output.stdout ? /* @__PURE__ */ jsx2("pre", { className: "max-h-80 overflow-auto px-3 py-3 text-xs font-mono whitespace-pre-wrap break-all text-foreground", children: output.stdout }) : null,
|
|
137
|
+
output.stderr ? /* @__PURE__ */ jsx2("pre", { 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", children: output.stderr }) : null
|
|
138
|
+
] }) : null
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
});
|
|
143
|
+
CommandPreview.displayName = "CommandPreview";
|
|
144
|
+
|
|
145
|
+
// src/tool-previews/write-file-preview.tsx
|
|
146
|
+
import { memo as memo2 } from "react";
|
|
147
|
+
import { FileEdit } from "lucide-react";
|
|
148
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
149
|
+
function extractWriteContent(input) {
|
|
150
|
+
if (!input || typeof input !== "object") return null;
|
|
151
|
+
const obj = input;
|
|
152
|
+
const path = String(obj.file_path ?? obj.path ?? obj.filePath ?? "unknown");
|
|
153
|
+
const content = String(obj.content ?? obj.contents ?? obj.data ?? "");
|
|
154
|
+
return { path, content };
|
|
155
|
+
}
|
|
156
|
+
function getLanguageFromPath(path) {
|
|
157
|
+
const ext = path.split(".").pop()?.toLowerCase();
|
|
158
|
+
const map = {
|
|
159
|
+
ts: "typescript",
|
|
160
|
+
tsx: "tsx",
|
|
161
|
+
js: "javascript",
|
|
162
|
+
jsx: "jsx",
|
|
163
|
+
rs: "rust",
|
|
164
|
+
py: "python",
|
|
165
|
+
go: "go",
|
|
166
|
+
rb: "ruby",
|
|
167
|
+
json: "json",
|
|
168
|
+
yaml: "yaml",
|
|
169
|
+
yml: "yaml",
|
|
170
|
+
toml: "toml",
|
|
171
|
+
md: "markdown",
|
|
172
|
+
css: "css",
|
|
173
|
+
scss: "scss",
|
|
174
|
+
html: "html",
|
|
175
|
+
sh: "bash",
|
|
176
|
+
bash: "bash",
|
|
177
|
+
zsh: "bash",
|
|
178
|
+
sql: "sql",
|
|
179
|
+
sol: "solidity",
|
|
180
|
+
proto: "protobuf"
|
|
181
|
+
};
|
|
182
|
+
return ext ? map[ext] : void 0;
|
|
183
|
+
}
|
|
184
|
+
var WriteFilePreview = memo2(({ part }) => {
|
|
185
|
+
const write = extractWriteContent(part.state.input);
|
|
186
|
+
if (!write) return null;
|
|
187
|
+
const lineCount = write.content.split("\n").length;
|
|
188
|
+
const language = getLanguageFromPath(write.path);
|
|
189
|
+
return /* @__PURE__ */ jsxs3(
|
|
190
|
+
PreviewCard,
|
|
191
|
+
{
|
|
192
|
+
icon: /* @__PURE__ */ jsx3(FileEdit, { className: "h-4 w-4" }),
|
|
193
|
+
title: "Write file",
|
|
194
|
+
description: write.path,
|
|
195
|
+
meta: /* @__PURE__ */ jsxs3("span", { className: "text-xs text-muted-foreground", children: [
|
|
196
|
+
"+",
|
|
197
|
+
lineCount,
|
|
198
|
+
" line",
|
|
199
|
+
lineCount !== 1 ? "s" : ""
|
|
200
|
+
] }),
|
|
201
|
+
children: [
|
|
202
|
+
part.state.status === "running" ? /* @__PURE__ */ jsx3(PreviewLoading, { label: "Writing file\u2026" }) : null,
|
|
203
|
+
part.state.error ? /* @__PURE__ */ jsx3(PreviewError, { error: part.state.error }) : null,
|
|
204
|
+
/* @__PURE__ */ jsx3(CodeBlock, { code: write.content, language, className: "rounded-[var(--radius-md)]", children: /* @__PURE__ */ jsx3(CopyButton, { text: write.content }) })
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
});
|
|
209
|
+
WriteFilePreview.displayName = "WriteFilePreview";
|
|
210
|
+
|
|
211
|
+
// src/tool-previews/grep-results-preview.tsx
|
|
212
|
+
import { memo as memo3, useMemo } from "react";
|
|
213
|
+
import { Search } from "lucide-react";
|
|
214
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
215
|
+
function coerceString(value) {
|
|
216
|
+
return typeof value === "string" && value.trim() ? value : void 0;
|
|
217
|
+
}
|
|
218
|
+
function parseMatch(value) {
|
|
219
|
+
if (typeof value === "string") {
|
|
220
|
+
const [path2, maybeLine, ...rest] = value.split(":");
|
|
221
|
+
const line2 = Number(maybeLine);
|
|
222
|
+
if (rest.length > 0 && Number.isFinite(line2)) {
|
|
223
|
+
return {
|
|
224
|
+
path: path2,
|
|
225
|
+
line: line2,
|
|
226
|
+
text: rest.join(":").trim()
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
path: "match",
|
|
231
|
+
text: value
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
if (!value || typeof value !== "object") {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
const record = value;
|
|
238
|
+
const path = coerceString(record.path) ?? coerceString(record.file) ?? coerceString(record.filePath) ?? "match";
|
|
239
|
+
const lineValue = record.line ?? record.lineNumber ?? record.line_number;
|
|
240
|
+
const line = typeof lineValue === "number" ? lineValue : Number(lineValue);
|
|
241
|
+
const text = coerceString(record.text) ?? coerceString(record.content) ?? coerceString(record.lineText) ?? coerceString(record.preview);
|
|
242
|
+
if (!text) {
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
path,
|
|
247
|
+
line: Number.isFinite(line) ? line : void 0,
|
|
248
|
+
text
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
function extractPattern(input) {
|
|
252
|
+
if (!input || typeof input !== "object") {
|
|
253
|
+
return void 0;
|
|
254
|
+
}
|
|
255
|
+
const record = input;
|
|
256
|
+
return coerceString(record.pattern) ?? coerceString(record.query);
|
|
257
|
+
}
|
|
258
|
+
function extractMatches(output) {
|
|
259
|
+
if (Array.isArray(output)) {
|
|
260
|
+
return output.map(parseMatch).filter((value) => value !== null);
|
|
261
|
+
}
|
|
262
|
+
if (output && typeof output === "object") {
|
|
263
|
+
const record = output;
|
|
264
|
+
const candidates = [record.matches, record.results, record.output];
|
|
265
|
+
for (const candidate of candidates) {
|
|
266
|
+
if (Array.isArray(candidate)) {
|
|
267
|
+
return candidate.map(parseMatch).filter((value) => value !== null);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (typeof output === "string") {
|
|
272
|
+
return output.split("\n").map((line) => line.trim()).filter(Boolean).map(parseMatch).filter((value) => value !== null);
|
|
273
|
+
}
|
|
274
|
+
return [];
|
|
275
|
+
}
|
|
276
|
+
var GrepResultsPreview = memo3(({ part }) => {
|
|
277
|
+
const pattern = extractPattern(part.state.input);
|
|
278
|
+
const matches = useMemo(() => extractMatches(part.state.output), [part.state.output]);
|
|
279
|
+
const groupedMatches = useMemo(() => {
|
|
280
|
+
const groups = /* @__PURE__ */ new Map();
|
|
281
|
+
for (const match of matches) {
|
|
282
|
+
const list = groups.get(match.path) ?? [];
|
|
283
|
+
list.push(match);
|
|
284
|
+
groups.set(match.path, list);
|
|
285
|
+
}
|
|
286
|
+
return [...groups.entries()];
|
|
287
|
+
}, [matches]);
|
|
288
|
+
return /* @__PURE__ */ jsxs4(
|
|
289
|
+
PreviewCard,
|
|
290
|
+
{
|
|
291
|
+
icon: /* @__PURE__ */ jsx4(Search, { className: "h-4 w-4" }),
|
|
292
|
+
title: pattern ? `Search results for "${pattern}"` : "Search results",
|
|
293
|
+
description: matches.length > 0 ? `${matches.length} match${matches.length === 1 ? "" : "es"}` : void 0,
|
|
294
|
+
children: [
|
|
295
|
+
part.state.status === "running" ? /* @__PURE__ */ jsx4(PreviewLoading, { label: "Searching files\u2026" }) : null,
|
|
296
|
+
part.state.error ? /* @__PURE__ */ jsx4(PreviewError, { error: part.state.error }) : null,
|
|
297
|
+
part.state.status === "completed" && matches.length === 0 ? /* @__PURE__ */ jsx4(PreviewEmpty, { label: "No matching files or lines were returned." }) : null,
|
|
298
|
+
groupedMatches.map(([path, pathMatches]) => /* @__PURE__ */ jsxs4(
|
|
299
|
+
"div",
|
|
300
|
+
{
|
|
301
|
+
className: "rounded-[var(--radius-md)] border border-border bg-muted/55",
|
|
302
|
+
children: [
|
|
303
|
+
/* @__PURE__ */ jsx4("div", { className: "border-b border-border px-3 py-2 text-xs font-medium text-foreground", children: path }),
|
|
304
|
+
/* @__PURE__ */ jsx4("div", { className: "divide-y divide-border", children: pathMatches.map((match, index) => /* @__PURE__ */ jsxs4("div", { className: "grid grid-cols-[auto_minmax(0,1fr)] gap-3 px-3 py-2", children: [
|
|
305
|
+
/* @__PURE__ */ jsx4("div", { className: "pt-0.5 text-xs font-mono text-muted-foreground", children: match.line ?? "\xB7" }),
|
|
306
|
+
/* @__PURE__ */ jsx4("pre", { className: "overflow-x-auto whitespace-pre-wrap break-words text-xs font-mono text-foreground", children: match.text })
|
|
307
|
+
] }, `${path}-${match.line ?? index}-${index}`)) })
|
|
308
|
+
]
|
|
309
|
+
},
|
|
310
|
+
path
|
|
311
|
+
))
|
|
312
|
+
]
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
});
|
|
316
|
+
GrepResultsPreview.displayName = "GrepResultsPreview";
|
|
317
|
+
|
|
318
|
+
// src/tool-previews/glob-results-preview.tsx
|
|
319
|
+
import { memo as memo4, useMemo as useMemo2 } from "react";
|
|
320
|
+
import { FileText, FolderOpen } from "lucide-react";
|
|
321
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
322
|
+
function coerceString2(value) {
|
|
323
|
+
return typeof value === "string" && value.trim() ? value : void 0;
|
|
324
|
+
}
|
|
325
|
+
function extractPattern2(input) {
|
|
326
|
+
if (!input || typeof input !== "object") {
|
|
327
|
+
return void 0;
|
|
328
|
+
}
|
|
329
|
+
const record = input;
|
|
330
|
+
return coerceString2(record.pattern) ?? coerceString2(record.path);
|
|
331
|
+
}
|
|
332
|
+
function extractFiles(output) {
|
|
333
|
+
if (Array.isArray(output)) {
|
|
334
|
+
return output.map((item) => String(item)).filter(Boolean);
|
|
335
|
+
}
|
|
336
|
+
if (output && typeof output === "object") {
|
|
337
|
+
const record = output;
|
|
338
|
+
const candidate = record.files ?? record.matches ?? record.paths ?? record.results;
|
|
339
|
+
if (Array.isArray(candidate)) {
|
|
340
|
+
return candidate.map(
|
|
341
|
+
(item) => typeof item === "string" ? item : item && typeof item === "object" ? String(
|
|
342
|
+
item.path ?? item.file ?? ""
|
|
343
|
+
) : ""
|
|
344
|
+
).filter(Boolean);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (typeof output === "string") {
|
|
348
|
+
return output.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
349
|
+
}
|
|
350
|
+
return [];
|
|
351
|
+
}
|
|
352
|
+
var GlobResultsPreview = memo4(({ part }) => {
|
|
353
|
+
const pattern = extractPattern2(part.state.input);
|
|
354
|
+
const files = useMemo2(() => extractFiles(part.state.output), [part.state.output]);
|
|
355
|
+
return /* @__PURE__ */ jsxs5(
|
|
356
|
+
PreviewCard,
|
|
357
|
+
{
|
|
358
|
+
icon: /* @__PURE__ */ jsx5(FolderOpen, { className: "h-4 w-4" }),
|
|
359
|
+
title: pattern ? `Files for ${pattern}` : "File results",
|
|
360
|
+
description: files.length > 0 ? `${files.length} path${files.length === 1 ? "" : "s"}` : void 0,
|
|
361
|
+
children: [
|
|
362
|
+
part.state.status === "running" ? /* @__PURE__ */ jsx5(PreviewLoading, { label: "Collecting files\u2026" }) : null,
|
|
363
|
+
part.state.error ? /* @__PURE__ */ jsx5(PreviewError, { error: part.state.error }) : null,
|
|
364
|
+
part.state.status === "completed" && files.length === 0 ? /* @__PURE__ */ jsx5(PreviewEmpty, { label: "No matching files were returned." }) : null,
|
|
365
|
+
files.length > 0 ? /* @__PURE__ */ jsx5("div", { className: "grid gap-2 sm:grid-cols-2", children: files.map((file) => {
|
|
366
|
+
const isDirectory = file.endsWith("/");
|
|
367
|
+
const Icon = isDirectory ? FolderOpen : FileText;
|
|
368
|
+
return /* @__PURE__ */ jsxs5(
|
|
369
|
+
"div",
|
|
370
|
+
{
|
|
371
|
+
className: "flex items-center gap-2 rounded-[var(--radius-md)] border border-border bg-muted/55 px-3 py-2",
|
|
372
|
+
children: [
|
|
373
|
+
/* @__PURE__ */ jsx5(Icon, { className: "h-4 w-4 shrink-0 text-primary" }),
|
|
374
|
+
/* @__PURE__ */ jsx5("span", { className: "min-w-0 truncate text-xs font-mono text-foreground", children: file })
|
|
375
|
+
]
|
|
376
|
+
},
|
|
377
|
+
file
|
|
378
|
+
);
|
|
379
|
+
}) }) : null
|
|
380
|
+
]
|
|
381
|
+
}
|
|
382
|
+
);
|
|
383
|
+
});
|
|
384
|
+
GlobResultsPreview.displayName = "GlobResultsPreview";
|
|
385
|
+
|
|
386
|
+
// src/tool-previews/web-search-preview.tsx
|
|
387
|
+
import { memo as memo5, useMemo as useMemo3 } from "react";
|
|
388
|
+
import { Globe } from "lucide-react";
|
|
389
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
390
|
+
function coerceString3(value) {
|
|
391
|
+
return typeof value === "string" && value.trim() ? value : void 0;
|
|
392
|
+
}
|
|
393
|
+
function extractQuery(input, output) {
|
|
394
|
+
if (input && typeof input === "object") {
|
|
395
|
+
const record = input;
|
|
396
|
+
const query = coerceString3(record.query) ?? coerceString3(record.url);
|
|
397
|
+
if (query) return query;
|
|
398
|
+
}
|
|
399
|
+
if (output && typeof output === "object") {
|
|
400
|
+
const record = output;
|
|
401
|
+
return coerceString3(record.query);
|
|
402
|
+
}
|
|
403
|
+
return void 0;
|
|
404
|
+
}
|
|
405
|
+
function parseResult(value) {
|
|
406
|
+
if (!value || typeof value !== "object") {
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
const record = value;
|
|
410
|
+
const title = coerceString3(record.title) ?? coerceString3(record.name) ?? "Untitled result";
|
|
411
|
+
const url = coerceString3(record.url) ?? coerceString3(record.link);
|
|
412
|
+
if (!url) {
|
|
413
|
+
return null;
|
|
414
|
+
}
|
|
415
|
+
return {
|
|
416
|
+
title,
|
|
417
|
+
url,
|
|
418
|
+
snippet: coerceString3(record.snippet) ?? coerceString3(record.description) ?? coerceString3(record.text)
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
function extractResults(output) {
|
|
422
|
+
if (output && typeof output === "object") {
|
|
423
|
+
const record = output;
|
|
424
|
+
const candidate = record.results ?? record.items ?? record.output;
|
|
425
|
+
if (Array.isArray(candidate)) {
|
|
426
|
+
return candidate.map(parseResult).filter((value) => value !== null);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
if (Array.isArray(output)) {
|
|
430
|
+
return output.map(parseResult).filter((value) => value !== null);
|
|
431
|
+
}
|
|
432
|
+
return [];
|
|
433
|
+
}
|
|
434
|
+
var WebSearchPreview = memo5(({ part }) => {
|
|
435
|
+
const query = extractQuery(part.state.input, part.state.output);
|
|
436
|
+
const results = useMemo3(() => extractResults(part.state.output), [part.state.output]);
|
|
437
|
+
return /* @__PURE__ */ jsxs6(
|
|
438
|
+
PreviewCard,
|
|
439
|
+
{
|
|
440
|
+
icon: /* @__PURE__ */ jsx6(Globe, { className: "h-4 w-4" }),
|
|
441
|
+
title: query ? `Web results for ${query}` : "Web results",
|
|
442
|
+
description: results.length > 0 ? `${results.length} result${results.length === 1 ? "" : "s"}` : void 0,
|
|
443
|
+
children: [
|
|
444
|
+
part.state.status === "running" ? /* @__PURE__ */ jsx6(PreviewLoading, { label: "Searching the web\u2026" }) : null,
|
|
445
|
+
part.state.error ? /* @__PURE__ */ jsx6(PreviewError, { error: part.state.error }) : null,
|
|
446
|
+
part.state.status === "completed" && results.length === 0 ? /* @__PURE__ */ jsx6(PreviewEmpty, { label: "No web results were returned." }) : null,
|
|
447
|
+
/* @__PURE__ */ jsx6("div", { className: "space-y-2", children: results.map((result) => /* @__PURE__ */ jsxs6(
|
|
448
|
+
"a",
|
|
449
|
+
{
|
|
450
|
+
href: result.url,
|
|
451
|
+
target: "_blank",
|
|
452
|
+
rel: "noreferrer",
|
|
453
|
+
className: "block rounded-[var(--radius-md)] border border-border bg-muted/55 px-3 py-3 transition-colors hover:border-[var(--border-accent-hover)] hover:bg-accent/50",
|
|
454
|
+
children: [
|
|
455
|
+
/* @__PURE__ */ jsx6("div", { className: "text-sm font-medium text-foreground", children: result.title }),
|
|
456
|
+
/* @__PURE__ */ jsx6("div", { className: "mt-1 truncate text-xs text-primary", children: result.url }),
|
|
457
|
+
result.snippet ? /* @__PURE__ */ jsx6("p", { className: "mt-2 text-sm leading-relaxed text-muted-foreground", children: result.snippet }) : null
|
|
458
|
+
]
|
|
459
|
+
},
|
|
460
|
+
result.url
|
|
461
|
+
)) })
|
|
462
|
+
]
|
|
463
|
+
}
|
|
464
|
+
);
|
|
465
|
+
});
|
|
466
|
+
WebSearchPreview.displayName = "WebSearchPreview";
|
|
467
|
+
|
|
468
|
+
// src/tool-previews/question-preview.tsx
|
|
469
|
+
import { memo as memo6, useMemo as useMemo4 } from "react";
|
|
470
|
+
import { MessageSquareQuote } from "lucide-react";
|
|
471
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
472
|
+
function toQuestionList(input) {
|
|
473
|
+
if (!input) {
|
|
474
|
+
return [];
|
|
475
|
+
}
|
|
476
|
+
if (typeof input === "string") {
|
|
477
|
+
return [input];
|
|
478
|
+
}
|
|
479
|
+
if (Array.isArray(input)) {
|
|
480
|
+
return input.map((item) => String(item)).filter(Boolean);
|
|
481
|
+
}
|
|
482
|
+
if (typeof input === "object") {
|
|
483
|
+
const record = input;
|
|
484
|
+
const value = record.questions ?? record.question ?? record.prompt;
|
|
485
|
+
if (Array.isArray(value)) {
|
|
486
|
+
return value.map((item) => String(item)).filter(Boolean);
|
|
487
|
+
}
|
|
488
|
+
if (typeof value === "string") {
|
|
489
|
+
return [value];
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
return [];
|
|
493
|
+
}
|
|
494
|
+
function toAnswerList(output) {
|
|
495
|
+
if (!output) {
|
|
496
|
+
return [];
|
|
497
|
+
}
|
|
498
|
+
if (typeof output === "string") {
|
|
499
|
+
return [output];
|
|
500
|
+
}
|
|
501
|
+
if (Array.isArray(output)) {
|
|
502
|
+
return output.map((item) => String(item)).filter(Boolean);
|
|
503
|
+
}
|
|
504
|
+
if (typeof output === "object") {
|
|
505
|
+
const record = output;
|
|
506
|
+
const value = record.answers ?? record.answer ?? record.response;
|
|
507
|
+
if (Array.isArray(value)) {
|
|
508
|
+
return value.map((item) => String(item)).filter(Boolean);
|
|
509
|
+
}
|
|
510
|
+
if (typeof value === "string") {
|
|
511
|
+
return [value];
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
return [];
|
|
515
|
+
}
|
|
516
|
+
var QuestionPreview = memo6(({ part }) => {
|
|
517
|
+
const questions = useMemo4(() => toQuestionList(part.state.input), [part.state.input]);
|
|
518
|
+
const answers = useMemo4(() => toAnswerList(part.state.output), [part.state.output]);
|
|
519
|
+
return /* @__PURE__ */ jsxs7(
|
|
520
|
+
PreviewCard,
|
|
521
|
+
{
|
|
522
|
+
icon: /* @__PURE__ */ jsx7(MessageSquareQuote, { className: "h-4 w-4" }),
|
|
523
|
+
title: "Agent question",
|
|
524
|
+
description: questions.length > 1 ? `${questions.length} questions require attention` : void 0,
|
|
525
|
+
children: [
|
|
526
|
+
part.state.status === "running" ? /* @__PURE__ */ jsx7(PreviewLoading, { label: "Waiting for an answer\u2026" }) : null,
|
|
527
|
+
part.state.error ? /* @__PURE__ */ jsx7(PreviewError, { error: part.state.error }) : null,
|
|
528
|
+
questions.length === 0 ? /* @__PURE__ */ jsx7(PreviewEmpty, { label: "No question text was provided." }) : null,
|
|
529
|
+
questions.map((question, index) => /* @__PURE__ */ jsxs7(
|
|
530
|
+
"div",
|
|
531
|
+
{
|
|
532
|
+
className: "rounded-[var(--radius-md)] border border-border bg-muted px-3 py-3",
|
|
533
|
+
children: [
|
|
534
|
+
/* @__PURE__ */ jsxs7("div", { className: "text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground", children: [
|
|
535
|
+
"Question ",
|
|
536
|
+
index + 1
|
|
537
|
+
] }),
|
|
538
|
+
/* @__PURE__ */ jsx7("div", { className: "mt-2 text-sm leading-relaxed text-foreground", children: question }),
|
|
539
|
+
/* @__PURE__ */ jsx7("div", { className: "mt-3 rounded-[var(--radius-sm)] border border-border bg-card px-3 py-2 text-sm text-foreground", children: answers[index] ?? (part.state.status === "completed" ? "No answer recorded." : "Awaiting answer") })
|
|
540
|
+
]
|
|
541
|
+
},
|
|
542
|
+
`${question}-${index}`
|
|
543
|
+
))
|
|
544
|
+
]
|
|
545
|
+
}
|
|
546
|
+
);
|
|
547
|
+
});
|
|
548
|
+
QuestionPreview.displayName = "QuestionPreview";
|
|
549
|
+
|
|
550
|
+
// src/tool-previews/diff-preview.tsx
|
|
551
|
+
import { memo as memo7 } from "react";
|
|
552
|
+
import { GitCompareArrows } from "lucide-react";
|
|
553
|
+
import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
554
|
+
function extractString(record, ...keys) {
|
|
555
|
+
for (const key of keys) {
|
|
556
|
+
const value = record[key];
|
|
557
|
+
if (typeof value === "string" && value.length > 0) {
|
|
558
|
+
return value;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
return void 0;
|
|
562
|
+
}
|
|
563
|
+
function extractDiffPayload(part) {
|
|
564
|
+
const sources = [part.state.input, part.state.output, part.state.metadata];
|
|
565
|
+
for (const source of sources) {
|
|
566
|
+
if (!source || typeof source !== "object") {
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
const record = source;
|
|
570
|
+
const diff = extractString(record, "diff", "patch", "unifiedDiff", "unified_diff");
|
|
571
|
+
const before = extractString(record, "oldString", "old_string", "before", "previous");
|
|
572
|
+
const after = extractString(record, "newString", "new_string", "after", "updated");
|
|
573
|
+
const path = extractString(record, "file_path", "filePath", "path");
|
|
574
|
+
if (diff || before || after) {
|
|
575
|
+
return { path, diff, before, after };
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
return {};
|
|
579
|
+
}
|
|
580
|
+
var DiffPreview = memo7(({ part }) => {
|
|
581
|
+
const payload = extractDiffPayload(part);
|
|
582
|
+
return /* @__PURE__ */ jsxs8(
|
|
583
|
+
PreviewCard,
|
|
584
|
+
{
|
|
585
|
+
icon: /* @__PURE__ */ jsx8(GitCompareArrows, { className: "h-4 w-4" }),
|
|
586
|
+
title: payload.path ? `Changes for ${payload.path}` : "File changes",
|
|
587
|
+
children: [
|
|
588
|
+
part.state.status === "running" ? /* @__PURE__ */ jsx8(PreviewLoading, { label: "Computing changes\u2026" }) : null,
|
|
589
|
+
part.state.error ? /* @__PURE__ */ jsx8(PreviewError, { error: part.state.error }) : null,
|
|
590
|
+
!payload.diff && !payload.before && !payload.after ? /* @__PURE__ */ jsx8(PreviewEmpty, { label: "No structured diff payload was provided." }) : null,
|
|
591
|
+
payload.diff ? /* @__PURE__ */ jsx8(CodeBlock, { code: payload.diff, language: "diff", className: "rounded-[var(--radius-md)]" }) : null,
|
|
592
|
+
!payload.diff && payload.before ? /* @__PURE__ */ jsxs8("div", { className: "space-y-2", children: [
|
|
593
|
+
/* @__PURE__ */ jsx8("div", { className: "text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground", children: "Before" }),
|
|
594
|
+
/* @__PURE__ */ jsx8(CodeBlock, { code: payload.before, language: "text", className: "rounded-[var(--radius-md)]" })
|
|
595
|
+
] }) : null,
|
|
596
|
+
!payload.diff && payload.after ? /* @__PURE__ */ jsxs8("div", { className: "space-y-2", children: [
|
|
597
|
+
/* @__PURE__ */ jsx8("div", { className: "text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground", children: "After" }),
|
|
598
|
+
/* @__PURE__ */ jsx8(CodeBlock, { code: payload.after, language: "text", className: "rounded-[var(--radius-md)]" })
|
|
599
|
+
] }) : null
|
|
600
|
+
]
|
|
601
|
+
}
|
|
602
|
+
);
|
|
603
|
+
});
|
|
604
|
+
DiffPreview.displayName = "DiffPreview";
|
|
605
|
+
|
|
606
|
+
export {
|
|
607
|
+
CommandPreview,
|
|
608
|
+
WriteFilePreview,
|
|
609
|
+
GrepResultsPreview,
|
|
610
|
+
GlobResultsPreview,
|
|
611
|
+
WebSearchPreview,
|
|
612
|
+
QuestionPreview,
|
|
613
|
+
DiffPreview
|
|
614
|
+
};
|