const { setupArtifacts, connectArtifactPanel } = window.apartePlugins.artifacts;
const split = document.querySelector('aparte-split');
const panel = document.querySelector('aparte-artifact-panel');
setupArtifacts();
// A card's Open button shows its document in the panel and opens the pane; Close folds it.
connectArtifactPanel({ chat: document.querySelector('aparte-chat'), panel, split });
// Two replies that wrote the same document: the second call passed the first one's id back.
const wrote = (id, content) => ({
id, type: 'tool_call', status: 'resolved', result: 'Artifact created.',
toolCall: { id, name: 'create_artifact', input: {} },
structuredResult: { documentId: 'doc_4f2a91c0', mimeType: 'text/markdown', title: 'Launch note', content },
});
document.querySelector('aparte-chat-viewport').setMessages([
{ id: 'u1', role: 'user', content: 'Write the launch note.', timestamp: 1 },
{ id: 'a1', role: 'assistant', content: '', timestamp: 2, segments: [
wrote('s1', '# Launch note\n\nDocuments now open beside the chat.'),
] },
{ id: 'u2', role: 'user', content: 'Say what a version is.', timestamp: 3 },
{ id: 'a2', role: 'assistant', content: '', timestamp: 4, segments: [
wrote('s2', '# Launch note\n\nDocuments now open beside the chat.\n\n## Versions\n\nEach time the model rewrites a document, the panel keeps the one before. The arrows walk them.'),
] },
]);
// What a press on the last card's Open button does.
panel.show('doc_4f2a91c0');
split.single = false;