blob: 4abf8fe373aa8df8921b24fe038448a33d774cea [file] [log] [blame]
bankseanbdc68892025-07-28 17:28:13 -07001import { DemoModule } from "./demo-framework/types";
2import { demoUtils } from "./demo-fixtures/index";
3import { SketchExternalMessage } from "../sketch-external-message";
4
5const demo: DemoModule = {
6 title: "Sketch External Message Demo",
7 description:
8 "Demonstration of external message components for various external message types",
9 imports: ["../sketch-external-message.ts"],
10
11 setup: async (container: HTMLElement) => {
12 const section = demoUtils.createDemoSection(
13 "External Message Components",
14 "Shows different external message components for various message types",
15 );
16
17 // external messages
18 const externalMessages = [
19 {
20 name: "github_workflow_run: completed, success",
21 message_type: "github_workflow_run",
22 body: {
23 workflow: {
24 name: "go_tests",
25 },
26 workflow_run: {
27 id: 123456789,
28 status: "completed",
29 conclusion: "success",
30 head_branch: "user/sketch/slug-name",
banksean051c3cd2025-07-30 13:23:03 -070031 head_sha: "abc123deadbeef1234567890abcdef",
bankseanbdc68892025-07-28 17:28:13 -070032 html_url: "https://github.com/orgs/your-org/actions/runs/123456789",
33 },
34 },
35 },
36 {
37 name: "github_workflow_run: completed, failed",
38 message_type: "github_workflow_run",
39 body: {
40 workflow: {
41 name: "go_tests",
42 },
43 workflow_run: {
44 id: 123456789,
45 status: "completed",
46 conclusion: "failure",
47 head_branch: "user/sketch/slug-name",
banksean051c3cd2025-07-30 13:23:03 -070048 head_sha: "abc123deadbeef1234567890abcdef",
bankseanbdc68892025-07-28 17:28:13 -070049 html_url: "https://github.com/orgs/your-org/actions/runs/123456789",
50 },
51 },
52 },
53 {
54 name: "github_workflow_run: queued",
55 message_type: "github_workflow_run",
56 body: {
57 workflow: {
58 name: "go_tests",
59 },
60 workflow_run: {
61 id: 123456789,
62 status: "queued",
63 head_branch: "user/sketch/slug-name",
banksean051c3cd2025-07-30 13:23:03 -070064 head_sha: "abc123deadbeef1234567890abcdef",
bankseanbdc68892025-07-28 17:28:13 -070065 html_url: "https://github.com/orgs/your-org/actions/runs/123456789",
66 },
67 },
68 },
69 {
70 name: "github_workflow_run: in_progress",
71 message_type: "github_workflow_run",
72 body: {
73 workflow: {
74 name: "go_tests",
75 },
76 workflow_run: {
77 id: 123456789,
78 status: "in_progress",
79 head_branch: "user/sketch/slug-name",
banksean051c3cd2025-07-30 13:23:03 -070080 head_sha: "abc123deadbeef1234567890abcdef",
bankseanbdc68892025-07-28 17:28:13 -070081 html_url: "https://github.com/orgs/your-org/actions/runs/123456789",
82 },
83 },
84 },
85 ];
86
87 // Create tool cards for each tool call
88 externalMessages.forEach((msg) => {
89 const msgSection = document.createElement("div");
90 msgSection.style.marginBottom = "2rem";
91 msgSection.style.border = "1px solid #eee";
92 msgSection.style.borderRadius = "8px";
93 msgSection.style.padding = "1rem";
94
95 const header = document.createElement("h3");
96 header.textContent = `Message: ${msg.name}`;
97 header.style.marginTop = "0";
98 header.style.marginBottom = "1rem";
99 header.style.color = "var(--demo-fixture-text-color)";
100 msgSection.appendChild(header);
101 const msgEl = document.createElement(
102 "sketch-external-message",
103 ) as SketchExternalMessage;
104
105 msgEl.message = {
106 message_type: msg.message_type,
107 body: msg.body,
108 text_content: `Workflow run ${msg.body.workflow_run.id} completed with status ${msg.body.workflow_run.status} and conclusion ${msg.body.workflow_run.conclusion}.`,
109 };
110 msgEl.open = true;
111
112 msgSection.appendChild(msgEl);
113 section.appendChild(msgSection);
114 });
115
116 container.appendChild(section);
117 },
118};
119
120export default demo;