added artifact bundling for custom long artifacts like uploading folder
Browse files
app/components/chat/Artifact.tsx
CHANGED
|
@@ -59,6 +59,14 @@ export const Artifact = memo(({ messageId }: ArtifactProps) => {
|
|
| 59 |
workbenchStore.showWorkbench.set(!showWorkbench);
|
| 60 |
}}
|
| 61 |
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
<div className="px-5 p-3.5 w-full text-left">
|
| 63 |
<div className="w-full text-bolt-elements-textPrimary font-medium leading-5 text-sm">{artifact?.title}</div>
|
| 64 |
<div className="w-full w-full text-bolt-elements-textSecondary text-xs mt-0.5">Click to open Workbench</div>
|
|
@@ -66,7 +74,7 @@ export const Artifact = memo(({ messageId }: ArtifactProps) => {
|
|
| 66 |
</button>
|
| 67 |
<div className="bg-bolt-elements-artifacts-borderColor w-[1px]" />
|
| 68 |
<AnimatePresence>
|
| 69 |
-
{actions.length && (
|
| 70 |
<motion.button
|
| 71 |
initial={{ width: 0 }}
|
| 72 |
animate={{ width: 'auto' }}
|
|
@@ -83,7 +91,7 @@ export const Artifact = memo(({ messageId }: ArtifactProps) => {
|
|
| 83 |
</AnimatePresence>
|
| 84 |
</div>
|
| 85 |
<AnimatePresence>
|
| 86 |
-
{showActions && actions.length > 0 && (
|
| 87 |
<motion.div
|
| 88 |
className="actions"
|
| 89 |
initial={{ height: 0 }}
|
|
@@ -92,6 +100,7 @@ export const Artifact = memo(({ messageId }: ArtifactProps) => {
|
|
| 92 |
transition={{ duration: 0.15 }}
|
| 93 |
>
|
| 94 |
<div className="bg-bolt-elements-artifacts-borderColor h-[1px]" />
|
|
|
|
| 95 |
<div className="p-5 text-left bg-bolt-elements-actions-background">
|
| 96 |
<ActionList actions={actions} />
|
| 97 |
</div>
|
|
|
|
| 59 |
workbenchStore.showWorkbench.set(!showWorkbench);
|
| 60 |
}}
|
| 61 |
>
|
| 62 |
+
{artifact.type == 'bundled' && (
|
| 63 |
+
<>
|
| 64 |
+
<div className="p-4">
|
| 65 |
+
<div className={'i-ph:files-light'} style={{ fontSize: '2rem' }}></div>
|
| 66 |
+
</div>
|
| 67 |
+
<div className="bg-bolt-elements-artifacts-borderColor w-[1px]" />
|
| 68 |
+
</>
|
| 69 |
+
)}
|
| 70 |
<div className="px-5 p-3.5 w-full text-left">
|
| 71 |
<div className="w-full text-bolt-elements-textPrimary font-medium leading-5 text-sm">{artifact?.title}</div>
|
| 72 |
<div className="w-full w-full text-bolt-elements-textSecondary text-xs mt-0.5">Click to open Workbench</div>
|
|
|
|
| 74 |
</button>
|
| 75 |
<div className="bg-bolt-elements-artifacts-borderColor w-[1px]" />
|
| 76 |
<AnimatePresence>
|
| 77 |
+
{actions.length && artifact.type !== 'bundled' && (
|
| 78 |
<motion.button
|
| 79 |
initial={{ width: 0 }}
|
| 80 |
animate={{ width: 'auto' }}
|
|
|
|
| 91 |
</AnimatePresence>
|
| 92 |
</div>
|
| 93 |
<AnimatePresence>
|
| 94 |
+
{artifact.type !== 'bundled' && showActions && actions.length > 0 && (
|
| 95 |
<motion.div
|
| 96 |
className="actions"
|
| 97 |
initial={{ height: 0 }}
|
|
|
|
| 100 |
transition={{ duration: 0.15 }}
|
| 101 |
>
|
| 102 |
<div className="bg-bolt-elements-artifacts-borderColor h-[1px]" />
|
| 103 |
+
|
| 104 |
<div className="p-5 text-left bg-bolt-elements-actions-background">
|
| 105 |
<ActionList actions={actions} />
|
| 106 |
</div>
|
app/components/chat/ImportFolderButton.tsx
CHANGED
|
@@ -79,7 +79,7 @@ ${content}
|
|
| 79 |
role: 'assistant',
|
| 80 |
content: `I'll help you set up these files.${binaryFilesMessage}
|
| 81 |
|
| 82 |
-
<boltArtifact id="imported-files" title="Imported Files">
|
| 83 |
${fileArtifacts.join('\n\n')}
|
| 84 |
</boltArtifact>`,
|
| 85 |
id: generateId(),
|
|
|
|
| 79 |
role: 'assistant',
|
| 80 |
content: `I'll help you set up these files.${binaryFilesMessage}
|
| 81 |
|
| 82 |
+
<boltArtifact id="imported-files" title="Imported Files" type="bundled">
|
| 83 |
${fileArtifacts.join('\n\n')}
|
| 84 |
</boltArtifact>`,
|
| 85 |
id: generateId(),
|
app/lib/runtime/message-parser.ts
CHANGED
|
@@ -192,6 +192,7 @@ export class StreamingMessageParser {
|
|
| 192 |
const artifactTag = input.slice(i, openTagEnd + 1);
|
| 193 |
|
| 194 |
const artifactTitle = this.#extractAttribute(artifactTag, 'title') as string;
|
|
|
|
| 195 |
const artifactId = this.#extractAttribute(artifactTag, 'id') as string;
|
| 196 |
|
| 197 |
if (!artifactTitle) {
|
|
@@ -207,6 +208,7 @@ export class StreamingMessageParser {
|
|
| 207 |
const currentArtifact = {
|
| 208 |
id: artifactId,
|
| 209 |
title: artifactTitle,
|
|
|
|
| 210 |
} satisfies BoltArtifactData;
|
| 211 |
|
| 212 |
state.currentArtifact = currentArtifact;
|
|
|
|
| 192 |
const artifactTag = input.slice(i, openTagEnd + 1);
|
| 193 |
|
| 194 |
const artifactTitle = this.#extractAttribute(artifactTag, 'title') as string;
|
| 195 |
+
const type = this.#extractAttribute(artifactTag, 'type') as string;
|
| 196 |
const artifactId = this.#extractAttribute(artifactTag, 'id') as string;
|
| 197 |
|
| 198 |
if (!artifactTitle) {
|
|
|
|
| 208 |
const currentArtifact = {
|
| 209 |
id: artifactId,
|
| 210 |
title: artifactTitle,
|
| 211 |
+
type,
|
| 212 |
} satisfies BoltArtifactData;
|
| 213 |
|
| 214 |
state.currentArtifact = currentArtifact;
|
app/lib/stores/workbench.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { extractRelativePath } from '~/utils/diff';
|
|
| 18 |
export interface ArtifactState {
|
| 19 |
id: string;
|
| 20 |
title: string;
|
|
|
|
| 21 |
closed: boolean;
|
| 22 |
runner: ActionRunner;
|
| 23 |
}
|
|
@@ -229,7 +230,7 @@ export class WorkbenchStore {
|
|
| 229 |
// TODO: what do we wanna do and how do we wanna recover from this?
|
| 230 |
}
|
| 231 |
|
| 232 |
-
addArtifact({ messageId, title, id }: ArtifactCallbackData) {
|
| 233 |
const artifact = this.#getArtifact(messageId);
|
| 234 |
|
| 235 |
if (artifact) {
|
|
@@ -244,6 +245,7 @@ export class WorkbenchStore {
|
|
| 244 |
id,
|
| 245 |
title,
|
| 246 |
closed: false,
|
|
|
|
| 247 |
runner: new ActionRunner(webcontainer, () => this.boltTerminal),
|
| 248 |
});
|
| 249 |
}
|
|
|
|
| 18 |
export interface ArtifactState {
|
| 19 |
id: string;
|
| 20 |
title: string;
|
| 21 |
+
type?: string;
|
| 22 |
closed: boolean;
|
| 23 |
runner: ActionRunner;
|
| 24 |
}
|
|
|
|
| 230 |
// TODO: what do we wanna do and how do we wanna recover from this?
|
| 231 |
}
|
| 232 |
|
| 233 |
+
addArtifact({ messageId, title, id,type }: ArtifactCallbackData) {
|
| 234 |
const artifact = this.#getArtifact(messageId);
|
| 235 |
|
| 236 |
if (artifact) {
|
|
|
|
| 245 |
id,
|
| 246 |
title,
|
| 247 |
closed: false,
|
| 248 |
+
type,
|
| 249 |
runner: new ActionRunner(webcontainer, () => this.boltTerminal),
|
| 250 |
});
|
| 251 |
}
|
app/types/artifact.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
export interface BoltArtifactData {
|
| 2 |
id: string;
|
| 3 |
title: string;
|
|
|
|
| 4 |
}
|
|
|
|
| 1 |
export interface BoltArtifactData {
|
| 2 |
id: string;
|
| 3 |
title: string;
|
| 4 |
+
type?: string;
|
| 5 |
}
|