Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/components/chat/Artifact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ if (import.meta.hot) {

interface ArtifactProps {
messageId: string;
artifactId: string;
}

export const Artifact = memo(({ messageId }: ArtifactProps) => {
export const Artifact = memo(({ artifactId }: ArtifactProps) => {
const userToggledActions = useRef(false);
const [showActions, setShowActions] = useState(false);
const [allActionFinished, setAllActionFinished] = useState(false);

const artifacts = useStore(workbenchStore.artifacts);
const artifact = artifacts[messageId];
const artifact = artifacts[artifactId];

const actions = useStore(
computed(artifact.runner.actions, (actions) => {
Expand Down
7 changes: 6 additions & 1 deletion app/components/chat/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@ export const Markdown = memo(

if (className?.includes('__boltArtifact__')) {
const messageId = node?.properties.dataMessageId as string;
const artifactId = node?.properties.dataArtifactId as string;

if (!messageId) {
logger.error(`Invalid message id ${messageId}`);
}

return <Artifact messageId={messageId} />;
if (!artifactId) {
logger.error(`Invalid artifact id ${artifactId}`);
}

return <Artifact messageId={messageId} artifactId={artifactId} />;
}

if (className?.includes('__boltSelectedElement__')) {
Expand Down
9 changes: 8 additions & 1 deletion app/lib/hooks/useMessageParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,21 @@ const messageParser = new EnhancedStreamingMessageParser({
onActionOpen: (data) => {
logger.trace('onActionOpen', data.action);

// we only add shell actions when when the close tag got parsed because only then we have the content
/*
* File actions are streamed, so we add them immediately to show progress
* Shell actions are complete when created by enhanced parser, so we wait for close
*/
if (data.action.type === 'file') {
workbenchStore.addAction(data);
}
},
onActionClose: (data) => {
logger.trace('onActionClose', data.action);

/*
* Add non-file actions (shell, build, start, etc.) when they close
* Enhanced parser creates complete shell actions, so they're ready to execute
*/
if (data.action.type !== 'file') {
workbenchStore.addAction(data);
}
Expand Down
66 changes: 42 additions & 24 deletions app/lib/runtime/__snapshots__/message-parser.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`StreamingMessageParser > valid artifacts with actions > should correctl
"type": "shell",
},
"actionId": "0",
"artifactId": "artifact_1",
"artifactId": "message_1-0",
"messageId": "message_1",
}
`;
Expand All @@ -19,14 +19,15 @@ exports[`StreamingMessageParser > valid artifacts with actions > should correctl
"type": "shell",
},
"actionId": "0",
"artifactId": "artifact_1",
"artifactId": "message_1-0",
"messageId": "message_1",
}
`;

exports[`StreamingMessageParser > valid artifacts with actions > should correctly parse chunks and strip out bolt artifacts (0) > onArtifactClose 1`] = `
{
"id": "artifact_1",
"artifactId": "message_1-0",
"id": "message_1-0",
"messageId": "message_1",
"title": "Some title",
"type": undefined,
Expand All @@ -35,7 +36,8 @@ exports[`StreamingMessageParser > valid artifacts with actions > should correctl

exports[`StreamingMessageParser > valid artifacts with actions > should correctly parse chunks and strip out bolt artifacts (0) > onArtifactOpen 1`] = `
{
"id": "artifact_1",
"artifactId": "message_1-0",
"id": "message_1-0",
"messageId": "message_1",
"title": "Some title",
"type": undefined,
Expand All @@ -49,7 +51,7 @@ exports[`StreamingMessageParser > valid artifacts with actions > should correctl
"type": "shell",
},
"actionId": "0",
"artifactId": "artifact_1",
"artifactId": "message_1-0",
"messageId": "message_1",
}
`;
Expand All @@ -63,7 +65,7 @@ exports[`StreamingMessageParser > valid artifacts with actions > should correctl
"type": "file",
},
"actionId": "1",
"artifactId": "artifact_1",
"artifactId": "message_1-0",
"messageId": "message_1",
}
`;
Expand All @@ -75,7 +77,7 @@ exports[`StreamingMessageParser > valid artifacts with actions > should correctl
"type": "shell",
},
"actionId": "0",
"artifactId": "artifact_1",
"artifactId": "message_1-0",
"messageId": "message_1",
}
`;
Expand All @@ -88,14 +90,15 @@ exports[`StreamingMessageParser > valid artifacts with actions > should correctl
"type": "file",
},
"actionId": "1",
"artifactId": "artifact_1",
"artifactId": "message_1-0",
"messageId": "message_1",
}
`;

exports[`StreamingMessageParser > valid artifacts with actions > should correctly parse chunks and strip out bolt artifacts (1) > onArtifactClose 1`] = `
{
"id": "artifact_1",
"artifactId": "message_1-0",
"id": "message_1-0",
"messageId": "message_1",
"title": "Some title",
"type": undefined,
Expand All @@ -104,7 +107,8 @@ exports[`StreamingMessageParser > valid artifacts with actions > should correctl

exports[`StreamingMessageParser > valid artifacts with actions > should correctly parse chunks and strip out bolt artifacts (1) > onArtifactOpen 1`] = `
{
"id": "artifact_1",
"artifactId": "message_1-0",
"id": "message_1-0",
"messageId": "message_1",
"title": "Some title",
"type": undefined,
Expand All @@ -113,7 +117,8 @@ exports[`StreamingMessageParser > valid artifacts with actions > should correctl

exports[`StreamingMessageParser > valid artifacts without actions > should correctly parse chunks and strip out bolt artifacts (0) > onArtifactClose 1`] = `
{
"id": "artifact_1",
"artifactId": "message_1-0",
"id": "message_1-0",
"messageId": "message_1",
"title": "Some title",
"type": undefined,
Expand All @@ -122,7 +127,8 @@ exports[`StreamingMessageParser > valid artifacts without actions > should corre

exports[`StreamingMessageParser > valid artifacts without actions > should correctly parse chunks and strip out bolt artifacts (0) > onArtifactOpen 1`] = `
{
"id": "artifact_1",
"artifactId": "message_1-0",
"id": "message_1-0",
"messageId": "message_1",
"title": "Some title",
"type": undefined,
Expand All @@ -131,7 +137,8 @@ exports[`StreamingMessageParser > valid artifacts without actions > should corre

exports[`StreamingMessageParser > valid artifacts without actions > should correctly parse chunks and strip out bolt artifacts (1) > onArtifactClose 1`] = `
{
"id": "artifact_1",
"artifactId": "message_1-0",
"id": "message_1-0",
"messageId": "message_1",
"title": "Some title",
"type": "bundled",
Expand All @@ -140,7 +147,8 @@ exports[`StreamingMessageParser > valid artifacts without actions > should corre

exports[`StreamingMessageParser > valid artifacts without actions > should correctly parse chunks and strip out bolt artifacts (1) > onArtifactOpen 1`] = `
{
"id": "artifact_1",
"artifactId": "message_1-0",
"id": "message_1-0",
"messageId": "message_1",
"title": "Some title",
"type": "bundled",
Expand All @@ -149,7 +157,8 @@ exports[`StreamingMessageParser > valid artifacts without actions > should corre

exports[`StreamingMessageParser > valid artifacts without actions > should correctly parse chunks and strip out bolt artifacts (2) > onArtifactClose 1`] = `
{
"id": "artifact_1",
"artifactId": "message_1-0",
"id": "message_1-0",
"messageId": "message_1",
"title": "Some title",
"type": undefined,
Expand All @@ -158,7 +167,8 @@ exports[`StreamingMessageParser > valid artifacts without actions > should corre

exports[`StreamingMessageParser > valid artifacts without actions > should correctly parse chunks and strip out bolt artifacts (2) > onArtifactOpen 1`] = `
{
"id": "artifact_1",
"artifactId": "message_1-0",
"id": "message_1-0",
"messageId": "message_1",
"title": "Some title",
"type": undefined,
Expand All @@ -167,7 +177,8 @@ exports[`StreamingMessageParser > valid artifacts without actions > should corre

exports[`StreamingMessageParser > valid artifacts without actions > should correctly parse chunks and strip out bolt artifacts (3) > onArtifactClose 1`] = `
{
"id": "artifact_1",
"artifactId": "message_1-0",
"id": "message_1-0",
"messageId": "message_1",
"title": "Some title",
"type": undefined,
Expand All @@ -176,7 +187,8 @@ exports[`StreamingMessageParser > valid artifacts without actions > should corre

exports[`StreamingMessageParser > valid artifacts without actions > should correctly parse chunks and strip out bolt artifacts (3) > onArtifactOpen 1`] = `
{
"id": "artifact_1",
"artifactId": "message_1-0",
"id": "message_1-0",
"messageId": "message_1",
"title": "Some title",
"type": undefined,
Expand All @@ -185,7 +197,8 @@ exports[`StreamingMessageParser > valid artifacts without actions > should corre

exports[`StreamingMessageParser > valid artifacts without actions > should correctly parse chunks and strip out bolt artifacts (4) > onArtifactClose 1`] = `
{
"id": "artifact_1",
"artifactId": "message_1-0",
"id": "message_1-0",
"messageId": "message_1",
"title": "Some title",
"type": undefined,
Expand All @@ -194,7 +207,8 @@ exports[`StreamingMessageParser > valid artifacts without actions > should corre

exports[`StreamingMessageParser > valid artifacts without actions > should correctly parse chunks and strip out bolt artifacts (4) > onArtifactOpen 1`] = `
{
"id": "artifact_1",
"artifactId": "message_1-0",
"id": "message_1-0",
"messageId": "message_1",
"title": "Some title",
"type": undefined,
Expand All @@ -203,7 +217,8 @@ exports[`StreamingMessageParser > valid artifacts without actions > should corre

exports[`StreamingMessageParser > valid artifacts without actions > should correctly parse chunks and strip out bolt artifacts (5) > onArtifactClose 1`] = `
{
"id": "artifact_1",
"artifactId": "message_1-0",
"id": "message_1-0",
"messageId": "message_1",
"title": "Some title",
"type": undefined,
Expand All @@ -212,7 +227,8 @@ exports[`StreamingMessageParser > valid artifacts without actions > should corre

exports[`StreamingMessageParser > valid artifacts without actions > should correctly parse chunks and strip out bolt artifacts (5) > onArtifactOpen 1`] = `
{
"id": "artifact_1",
"artifactId": "message_1-0",
"id": "message_1-0",
"messageId": "message_1",
"title": "Some title",
"type": undefined,
Expand All @@ -221,7 +237,8 @@ exports[`StreamingMessageParser > valid artifacts without actions > should corre

exports[`StreamingMessageParser > valid artifacts without actions > should correctly parse chunks and strip out bolt artifacts (6) > onArtifactClose 1`] = `
{
"id": "artifact_1",
"artifactId": "message_1-0",
"id": "message_1-0",
"messageId": "message_1",
"title": "Some title",
"type": undefined,
Expand All @@ -230,7 +247,8 @@ exports[`StreamingMessageParser > valid artifacts without actions > should corre

exports[`StreamingMessageParser > valid artifacts without actions > should correctly parse chunks and strip out bolt artifacts (6) > onArtifactOpen 1`] = `
{
"id": "artifact_1",
"artifactId": "message_1-0",
"id": "message_1-0",
"messageId": "message_1",
"title": "Some title",
"type": undefined,
Expand Down
Loading
Loading