dreamboard 0.1.21 → 0.1.23

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.
Files changed (186) hide show
  1. package/dist/{chunk-EYYWGWTO.js → chunk-2RCUHMGL.js} +343 -1911
  2. package/dist/chunk-2RCUHMGL.js.map +1 -0
  3. package/dist/{chunk-MOVHYB6E.js → chunk-GN7232BY.js} +1025 -695
  4. package/dist/chunk-GN7232BY.js.map +1 -0
  5. package/dist/{chunk-BMYC6772.js → chunk-H3O43F5P.js} +9765 -3068
  6. package/dist/chunk-H3O43F5P.js.map +1 -0
  7. package/dist/dev-host/dev-api-proxy-plugin.ts +330 -0
  8. package/dist/dev-host/dev-diagnostics.ts +62 -0
  9. package/dist/dev-host/dev-fallback-stylesheet.ts +50 -0
  10. package/dist/dev-host/dev-host-controller.ts +686 -0
  11. package/dist/dev-host/dev-host-player-query.ts +17 -0
  12. package/dist/dev-host/dev-host-session-transport.ts +52 -0
  13. package/dist/dev-host/dev-host-storage.ts +56 -0
  14. package/dist/dev-host/dev-log-relay-plugin.ts +469 -0
  15. package/dist/dev-host/dev-runtime-config.ts +14 -0
  16. package/dist/dev-host/dev-runtime-platform.ts +419 -0
  17. package/dist/dev-host/dev-virtual-modules-plugin.ts +63 -0
  18. package/dist/dev-host/host-main.css +182 -0
  19. package/dist/dev-host/host-main.tsx +754 -0
  20. package/dist/dev-host/index.html +56 -0
  21. package/dist/dev-host/plugin-main.ts +55 -0
  22. package/dist/dev-host/plugin.html +24 -0
  23. package/dist/dev-host/start-dev-server.ts +138 -0
  24. package/dist/dev-host/virtual-modules.d.ts +27 -0
  25. package/dist/dist-FEPN3BDN.js +16543 -0
  26. package/dist/dist-FEPN3BDN.js.map +1 -0
  27. package/dist/{dist-WJRJNFLI.js → dist-FRURQI7Q.js} +4 -2
  28. package/dist/index.js +3 -3
  29. package/dist/internal.js +159 -124
  30. package/dist/internal.js.map +1 -1
  31. package/dist/runtime-packages/tailwind-config/shared-styles.css +146 -0
  32. package/dist/runtime-packages/ui/src/components/.gitkeep +0 -0
  33. package/dist/runtime-packages/ui/src/components/accordion.tsx +66 -0
  34. package/dist/runtime-packages/ui/src/components/ai-elements/actions.tsx +65 -0
  35. package/dist/runtime-packages/ui/src/components/ai-elements/artifact.tsx +147 -0
  36. package/dist/runtime-packages/ui/src/components/ai-elements/branch.tsx +215 -0
  37. package/dist/runtime-packages/ui/src/components/ai-elements/canvas.tsx +22 -0
  38. package/dist/runtime-packages/ui/src/components/ai-elements/chain-of-thought.tsx +228 -0
  39. package/dist/runtime-packages/ui/src/components/ai-elements/code-block.tsx +179 -0
  40. package/dist/runtime-packages/ui/src/components/ai-elements/confirmation.tsx +158 -0
  41. package/dist/runtime-packages/ui/src/components/ai-elements/connection.tsx +28 -0
  42. package/dist/runtime-packages/ui/src/components/ai-elements/context.tsx +408 -0
  43. package/dist/runtime-packages/ui/src/components/ai-elements/controls.tsx +18 -0
  44. package/dist/runtime-packages/ui/src/components/ai-elements/conversation.tsx +97 -0
  45. package/dist/runtime-packages/ui/src/components/ai-elements/edge.tsx +140 -0
  46. package/dist/runtime-packages/ui/src/components/ai-elements/image.tsx +24 -0
  47. package/dist/runtime-packages/ui/src/components/ai-elements/inline-citation.tsx +287 -0
  48. package/dist/runtime-packages/ui/src/components/ai-elements/loader.tsx +96 -0
  49. package/dist/runtime-packages/ui/src/components/ai-elements/message.tsx +463 -0
  50. package/dist/runtime-packages/ui/src/components/ai-elements/node.tsx +71 -0
  51. package/dist/runtime-packages/ui/src/components/ai-elements/open-in-chat.tsx +365 -0
  52. package/dist/runtime-packages/ui/src/components/ai-elements/panel.tsx +15 -0
  53. package/dist/runtime-packages/ui/src/components/ai-elements/plan.tsx +142 -0
  54. package/dist/runtime-packages/ui/src/components/ai-elements/prompt-input.tsx +1380 -0
  55. package/dist/runtime-packages/ui/src/components/ai-elements/queue.tsx +274 -0
  56. package/dist/runtime-packages/ui/src/components/ai-elements/reasoning.tsx +182 -0
  57. package/dist/runtime-packages/ui/src/components/ai-elements/response.tsx +22 -0
  58. package/dist/runtime-packages/ui/src/components/ai-elements/shimmer.tsx +64 -0
  59. package/dist/runtime-packages/ui/src/components/ai-elements/sources.tsx +77 -0
  60. package/dist/runtime-packages/ui/src/components/ai-elements/suggestion.tsx +53 -0
  61. package/dist/runtime-packages/ui/src/components/ai-elements/task.tsx +87 -0
  62. package/dist/runtime-packages/ui/src/components/ai-elements/tool.tsx +165 -0
  63. package/dist/runtime-packages/ui/src/components/ai-elements/toolbar.tsx +16 -0
  64. package/dist/runtime-packages/ui/src/components/ai-elements/web-preview.tsx +263 -0
  65. package/dist/runtime-packages/ui/src/components/alert-dialog.tsx +157 -0
  66. package/dist/runtime-packages/ui/src/components/alert.tsx +66 -0
  67. package/dist/runtime-packages/ui/src/components/avatar.tsx +53 -0
  68. package/dist/runtime-packages/ui/src/components/badge.tsx +46 -0
  69. package/dist/runtime-packages/ui/src/components/button-group.tsx +83 -0
  70. package/dist/runtime-packages/ui/src/components/button.tsx +65 -0
  71. package/dist/runtime-packages/ui/src/components/card.tsx +92 -0
  72. package/dist/runtime-packages/ui/src/components/carousel.tsx +241 -0
  73. package/dist/runtime-packages/ui/src/components/collapsible.tsx +33 -0
  74. package/dist/runtime-packages/ui/src/components/command.tsx +184 -0
  75. package/dist/runtime-packages/ui/src/components/context-menu.tsx +252 -0
  76. package/dist/runtime-packages/ui/src/components/counter.tsx +11 -0
  77. package/dist/runtime-packages/ui/src/components/dialog.tsx +146 -0
  78. package/dist/runtime-packages/ui/src/components/drawer.tsx +132 -0
  79. package/dist/runtime-packages/ui/src/components/dropdown-menu.tsx +257 -0
  80. package/dist/runtime-packages/ui/src/components/form.tsx +168 -0
  81. package/dist/runtime-packages/ui/src/components/header.tsx +13 -0
  82. package/dist/runtime-packages/ui/src/components/hover-card.tsx +44 -0
  83. package/dist/runtime-packages/ui/src/components/input-group.tsx +178 -0
  84. package/dist/runtime-packages/ui/src/components/input.tsx +21 -0
  85. package/dist/runtime-packages/ui/src/components/item.tsx +193 -0
  86. package/dist/runtime-packages/ui/src/components/label.tsx +24 -0
  87. package/dist/runtime-packages/ui/src/components/navigation-menu.tsx +168 -0
  88. package/dist/runtime-packages/ui/src/components/popover.tsx +55 -0
  89. package/dist/runtime-packages/ui/src/components/progress.tsx +31 -0
  90. package/dist/runtime-packages/ui/src/components/radio-group.tsx +45 -0
  91. package/dist/runtime-packages/ui/src/components/resizable.tsx +56 -0
  92. package/dist/runtime-packages/ui/src/components/scroll-area.tsx +58 -0
  93. package/dist/runtime-packages/ui/src/components/select.tsx +187 -0
  94. package/dist/runtime-packages/ui/src/components/separator.tsx +28 -0
  95. package/dist/runtime-packages/ui/src/components/skeleton.tsx +13 -0
  96. package/dist/runtime-packages/ui/src/components/sonner.tsx +25 -0
  97. package/dist/runtime-packages/ui/src/components/spinner.tsx +16 -0
  98. package/dist/runtime-packages/ui/src/components/switch.tsx +31 -0
  99. package/dist/runtime-packages/ui/src/components/table.tsx +137 -0
  100. package/dist/runtime-packages/ui/src/components/tabs.tsx +74 -0
  101. package/dist/runtime-packages/ui/src/components/textarea.tsx +23 -0
  102. package/dist/runtime-packages/ui/src/components/theme-provider.tsx +73 -0
  103. package/dist/runtime-packages/ui/src/components/tooltip.tsx +61 -0
  104. package/dist/runtime-packages/ui/src/components/ui/file-upload.tsx +195 -0
  105. package/dist/runtime-packages/ui/src/hooks/.gitkeep +0 -0
  106. package/dist/runtime-packages/ui/src/index.ts +68 -0
  107. package/dist/runtime-packages/ui/src/lib/utils.ts +6 -0
  108. package/dist/runtime-packages/ui-host-runtime/src/actor-principal.ts +68 -0
  109. package/dist/runtime-packages/ui-host-runtime/src/components/host-controls.tsx +359 -0
  110. package/dist/runtime-packages/ui-host-runtime/src/components/host-feedback-toaster.tsx +274 -0
  111. package/dist/runtime-packages/ui-host-runtime/src/components/host-feedback.tsx +214 -0
  112. package/dist/runtime-packages/ui-host-runtime/src/components/host-session-metadata.tsx +135 -0
  113. package/dist/runtime-packages/ui-host-runtime/src/components/index.ts +5 -0
  114. package/dist/runtime-packages/ui-host-runtime/src/components/perf-overlay.tsx +194 -0
  115. package/dist/runtime-packages/ui-host-runtime/src/host-controls.tsx +1 -0
  116. package/dist/runtime-packages/ui-host-runtime/src/host-feedback.tsx +1 -0
  117. package/dist/runtime-packages/ui-host-runtime/src/host-session-transport.ts +162 -0
  118. package/dist/runtime-packages/ui-host-runtime/src/index.ts +2 -0
  119. package/dist/runtime-packages/ui-host-runtime/src/logger.ts +11 -0
  120. package/dist/runtime-packages/ui-host-runtime/src/perf.ts +253 -0
  121. package/dist/runtime-packages/ui-host-runtime/src/plugin-bridge.ts +195 -0
  122. package/dist/runtime-packages/ui-host-runtime/src/plugin-health-check.ts +138 -0
  123. package/dist/runtime-packages/ui-host-runtime/src/plugin-messages.ts +159 -0
  124. package/dist/runtime-packages/ui-host-runtime/src/plugin-session-gateway.ts +524 -0
  125. package/dist/runtime-packages/ui-host-runtime/src/runtime/index.ts +12 -0
  126. package/dist/runtime-packages/ui-host-runtime/src/screenshot/projection-to-snapshot.ts +122 -0
  127. package/dist/runtime-packages/ui-host-runtime/src/screenshot/static-store-api.ts +26 -0
  128. package/dist/runtime-packages/ui-host-runtime/src/session-ingress-controller.ts +477 -0
  129. package/dist/runtime-packages/ui-host-runtime/src/session-ingress.ts +209 -0
  130. package/dist/runtime-packages/ui-host-runtime/src/session-live-runtime.ts +112 -0
  131. package/dist/runtime-packages/ui-host-runtime/src/session-model.ts +318 -0
  132. package/dist/runtime-packages/ui-host-runtime/src/session-projection.ts +211 -0
  133. package/dist/runtime-packages/ui-host-runtime/src/session-state-reducer.ts +814 -0
  134. package/dist/runtime-packages/ui-host-runtime/src/sse-manager.ts +334 -0
  135. package/dist/runtime-packages/ui-host-runtime/src/unified-session-store.ts +180 -0
  136. package/dist/scaffold/assets/static/app/tsconfig.framework.json +3 -1
  137. package/dist/scaffold/assets/static/ui/tsconfig.framework.json +7 -19
  138. package/package.json +52 -17
  139. package/skills/dreamboard/SKILL.md +41 -75
  140. package/LICENSE +0 -89
  141. package/NOTICE +0 -1
  142. package/dist/chunk-BMYC6772.js.map +0 -1
  143. package/dist/chunk-EYYWGWTO.js.map +0 -1
  144. package/dist/chunk-MOVHYB6E.js.map +0 -1
  145. package/dist/scaffold/assets/static/ui/App.tsx +0 -22
  146. package/dist/src-CUL7EGGG.js +0 -634
  147. package/dist/src-CUL7EGGG.js.map +0 -1
  148. package/skills/dreamboard/references/authoring-lifecycle.md +0 -102
  149. package/skills/dreamboard/references/board-surfaces.md +0 -36
  150. package/skills/dreamboard/references/board-topology.md +0 -443
  151. package/skills/dreamboard/references/boards-and-topology.md +0 -100
  152. package/skills/dreamboard/references/card-actions.md +0 -107
  153. package/skills/dreamboard/references/cli.md +0 -120
  154. package/skills/dreamboard/references/core-concepts.md +0 -514
  155. package/skills/dreamboard/references/custom-renderers.md +0 -26
  156. package/skills/dreamboard/references/derived-values.md +0 -55
  157. package/skills/dreamboard/references/effects.md +0 -111
  158. package/skills/dreamboard/references/game-contract.md +0 -89
  159. package/skills/dreamboard/references/game-definition.md +0 -89
  160. package/skills/dreamboard/references/game-shell.md +0 -80
  161. package/skills/dreamboard/references/hand-surfaces.md +0 -33
  162. package/skills/dreamboard/references/index.md +0 -112
  163. package/skills/dreamboard/references/inputs-and-targets.md +0 -160
  164. package/skills/dreamboard/references/interactions.md +0 -158
  165. package/skills/dreamboard/references/manifest-fields.md +0 -137
  166. package/skills/dreamboard/references/manifest.md +0 -81
  167. package/skills/dreamboard/references/package-surfaces.md +0 -69
  168. package/skills/dreamboard/references/phases.md +0 -145
  169. package/skills/dreamboard/references/prompts-and-choices.md +0 -55
  170. package/skills/dreamboard/references/quickstart.md +0 -71
  171. package/skills/dreamboard/references/rule-authoring.md +0 -144
  172. package/skills/dreamboard/references/setup-bootstrap.md +0 -78
  173. package/skills/dreamboard/references/stages-and-zones.md +0 -59
  174. package/skills/dreamboard/references/static-views.md +0 -67
  175. package/skills/dreamboard/references/table-queries-and-ops.md +0 -103
  176. package/skills/dreamboard/references/testing-bases.md +0 -147
  177. package/skills/dreamboard/references/testing-generated-contracts.md +0 -142
  178. package/skills/dreamboard/references/testing-runtime-assertions.md +0 -124
  179. package/skills/dreamboard/references/testing-scenarios.md +0 -148
  180. package/skills/dreamboard/references/testing-ui-tests.md +0 -174
  181. package/skills/dreamboard/references/testing.md +0 -161
  182. package/skills/dreamboard/references/ui-architecture.md +0 -137
  183. package/skills/dreamboard/references/ui-components.md +0 -34
  184. package/skills/dreamboard/references/views.md +0 -72
  185. package/skills/dreamboard/references/workspace-layout.md +0 -136
  186. /package/dist/{dist-WJRJNFLI.js.map → dist-FRURQI7Q.js.map} +0 -0
@@ -0,0 +1,66 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { ChevronDownIcon } from "lucide-react";
5
+ import { Accordion as AccordionPrimitive } from "radix-ui";
6
+
7
+ import { cn } from "@dreamboard/ui/lib/utils";
8
+
9
+ function Accordion({
10
+ ...props
11
+ }: React.ComponentProps<typeof AccordionPrimitive.Root>) {
12
+ return <AccordionPrimitive.Root data-slot="accordion" {...props} />;
13
+ }
14
+
15
+ function AccordionItem({
16
+ className,
17
+ ...props
18
+ }: React.ComponentProps<typeof AccordionPrimitive.Item>) {
19
+ return (
20
+ <AccordionPrimitive.Item
21
+ data-slot="accordion-item"
22
+ className={cn("border-b last:border-b-0", className)}
23
+ {...props}
24
+ />
25
+ );
26
+ }
27
+
28
+ function AccordionTrigger({
29
+ className,
30
+ children,
31
+ ...props
32
+ }: React.ComponentProps<typeof AccordionPrimitive.Trigger>) {
33
+ return (
34
+ <AccordionPrimitive.Header className="flex">
35
+ <AccordionPrimitive.Trigger
36
+ data-slot="accordion-trigger"
37
+ className={cn(
38
+ "focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",
39
+ className,
40
+ )}
41
+ {...props}
42
+ >
43
+ {children}
44
+ <ChevronDownIcon className="text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200" />
45
+ </AccordionPrimitive.Trigger>
46
+ </AccordionPrimitive.Header>
47
+ );
48
+ }
49
+
50
+ function AccordionContent({
51
+ className,
52
+ children,
53
+ ...props
54
+ }: React.ComponentProps<typeof AccordionPrimitive.Content>) {
55
+ return (
56
+ <AccordionPrimitive.Content
57
+ data-slot="accordion-content"
58
+ className="data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"
59
+ {...props}
60
+ >
61
+ <div className={cn("pt-0 pb-4", className)}>{children}</div>
62
+ </AccordionPrimitive.Content>
63
+ );
64
+ }
65
+
66
+ export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
@@ -0,0 +1,65 @@
1
+ "use client";
2
+
3
+ import { Button } from "@dreamboard/ui/components/button";
4
+ import {
5
+ Tooltip,
6
+ TooltipContent,
7
+ TooltipProvider,
8
+ TooltipTrigger,
9
+ } from "@dreamboard/ui/components/tooltip";
10
+ import { cn } from "@dreamboard/ui/lib/utils";
11
+ import type { ComponentProps } from "react";
12
+
13
+ export type ActionsProps = ComponentProps<"div">;
14
+
15
+ export const Actions = ({ className, children, ...props }: ActionsProps) => (
16
+ <div className={cn("flex items-center gap-1", className)} {...props}>
17
+ {children}
18
+ </div>
19
+ );
20
+
21
+ export type ActionProps = ComponentProps<typeof Button> & {
22
+ tooltip?: string;
23
+ label?: string;
24
+ };
25
+
26
+ export const Action = ({
27
+ tooltip,
28
+ children,
29
+ label,
30
+ className,
31
+ variant = "ghost",
32
+ size = "sm",
33
+ ...props
34
+ }: ActionProps) => {
35
+ const button = (
36
+ <Button
37
+ className={cn(
38
+ "relative size-9 p-1.5 text-muted-foreground hover:text-foreground",
39
+ className,
40
+ )}
41
+ size={size}
42
+ type="button"
43
+ variant={variant}
44
+ {...props}
45
+ >
46
+ {children}
47
+ <span className="sr-only">{label || tooltip}</span>
48
+ </Button>
49
+ );
50
+
51
+ if (tooltip) {
52
+ return (
53
+ <TooltipProvider>
54
+ <Tooltip>
55
+ <TooltipTrigger asChild>{button}</TooltipTrigger>
56
+ <TooltipContent>
57
+ <p>{tooltip}</p>
58
+ </TooltipContent>
59
+ </Tooltip>
60
+ </TooltipProvider>
61
+ );
62
+ }
63
+
64
+ return button;
65
+ };
@@ -0,0 +1,147 @@
1
+ "use client";
2
+
3
+ import { Button } from "@dreamboard/ui/components/button";
4
+ import {
5
+ Tooltip,
6
+ TooltipContent,
7
+ TooltipProvider,
8
+ TooltipTrigger,
9
+ } from "@dreamboard/ui/components/tooltip";
10
+ import { cn } from "@dreamboard/ui/lib/utils";
11
+ import { type LucideIcon, XIcon } from "lucide-react";
12
+ import type { ComponentProps, HTMLAttributes } from "react";
13
+
14
+ export type ArtifactProps = HTMLAttributes<HTMLDivElement>;
15
+
16
+ export const Artifact = ({ className, ...props }: ArtifactProps) => (
17
+ <div
18
+ className={cn(
19
+ "flex flex-col overflow-hidden rounded-lg border bg-background shadow-sm",
20
+ className,
21
+ )}
22
+ {...props}
23
+ />
24
+ );
25
+
26
+ export type ArtifactHeaderProps = HTMLAttributes<HTMLDivElement>;
27
+
28
+ export const ArtifactHeader = ({
29
+ className,
30
+ ...props
31
+ }: ArtifactHeaderProps) => (
32
+ <div
33
+ className={cn(
34
+ "flex items-center justify-between border-b bg-muted/50 px-4 py-3",
35
+ className,
36
+ )}
37
+ {...props}
38
+ />
39
+ );
40
+
41
+ export type ArtifactCloseProps = ComponentProps<typeof Button>;
42
+
43
+ export const ArtifactClose = ({
44
+ className,
45
+ children,
46
+ size = "sm",
47
+ variant = "ghost",
48
+ ...props
49
+ }: ArtifactCloseProps) => (
50
+ <Button
51
+ className={cn(
52
+ "size-8 p-0 text-muted-foreground hover:text-foreground",
53
+ className,
54
+ )}
55
+ size={size}
56
+ type="button"
57
+ variant={variant}
58
+ {...props}
59
+ >
60
+ {children ?? <XIcon className="size-4" />}
61
+ <span className="sr-only">Close</span>
62
+ </Button>
63
+ );
64
+
65
+ export type ArtifactTitleProps = HTMLAttributes<HTMLParagraphElement>;
66
+
67
+ export const ArtifactTitle = ({ className, ...props }: ArtifactTitleProps) => (
68
+ <p
69
+ className={cn("font-medium text-foreground text-sm", className)}
70
+ {...props}
71
+ />
72
+ );
73
+
74
+ export type ArtifactDescriptionProps = HTMLAttributes<HTMLParagraphElement>;
75
+
76
+ export const ArtifactDescription = ({
77
+ className,
78
+ ...props
79
+ }: ArtifactDescriptionProps) => (
80
+ <p className={cn("text-muted-foreground text-sm", className)} {...props} />
81
+ );
82
+
83
+ export type ArtifactActionsProps = HTMLAttributes<HTMLDivElement>;
84
+
85
+ export const ArtifactActions = ({
86
+ className,
87
+ ...props
88
+ }: ArtifactActionsProps) => (
89
+ <div className={cn("flex items-center gap-1", className)} {...props} />
90
+ );
91
+
92
+ export type ArtifactActionProps = ComponentProps<typeof Button> & {
93
+ tooltip?: string;
94
+ label?: string;
95
+ icon?: LucideIcon;
96
+ };
97
+
98
+ export const ArtifactAction = ({
99
+ tooltip,
100
+ label,
101
+ icon: Icon,
102
+ children,
103
+ className,
104
+ size = "sm",
105
+ variant = "ghost",
106
+ ...props
107
+ }: ArtifactActionProps) => {
108
+ const button = (
109
+ <Button
110
+ className={cn(
111
+ "size-8 p-0 text-muted-foreground hover:text-foreground",
112
+ className,
113
+ )}
114
+ size={size}
115
+ type="button"
116
+ variant={variant}
117
+ {...props}
118
+ >
119
+ {Icon ? <Icon className="size-4" /> : children}
120
+ <span className="sr-only">{label || tooltip}</span>
121
+ </Button>
122
+ );
123
+
124
+ if (tooltip) {
125
+ return (
126
+ <TooltipProvider>
127
+ <Tooltip>
128
+ <TooltipTrigger asChild>{button}</TooltipTrigger>
129
+ <TooltipContent>
130
+ <p>{tooltip}</p>
131
+ </TooltipContent>
132
+ </Tooltip>
133
+ </TooltipProvider>
134
+ );
135
+ }
136
+
137
+ return button;
138
+ };
139
+
140
+ export type ArtifactContentProps = HTMLAttributes<HTMLDivElement>;
141
+
142
+ export const ArtifactContent = ({
143
+ className,
144
+ ...props
145
+ }: ArtifactContentProps) => (
146
+ <div className={cn("flex-1 overflow-auto p-4", className)} {...props} />
147
+ );
@@ -0,0 +1,215 @@
1
+ "use client";
2
+
3
+ import { Button } from "@dreamboard/ui/components/button";
4
+ import { cn } from "@dreamboard/ui/lib/utils";
5
+ import type { UIMessage } from "ai";
6
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
7
+ import type { ComponentProps, HTMLAttributes, ReactElement } from "react";
8
+ import { createContext, useContext, useEffect, useMemo, useState } from "react";
9
+
10
+ interface BranchContextType {
11
+ currentBranch: number;
12
+ totalBranches: number;
13
+ goToPrevious: () => void;
14
+ goToNext: () => void;
15
+ branches: ReactElement[];
16
+ setBranches: (branches: ReactElement[]) => void;
17
+ }
18
+
19
+ const BranchContext = createContext<BranchContextType | null>(null);
20
+
21
+ const useBranch = () => {
22
+ const context = useContext(BranchContext);
23
+
24
+ if (!context) {
25
+ throw new Error("Branch components must be used within Branch");
26
+ }
27
+
28
+ return context;
29
+ };
30
+
31
+ export type BranchProps = HTMLAttributes<HTMLDivElement> & {
32
+ defaultBranch?: number;
33
+ onBranchChange?: (branchIndex: number) => void;
34
+ };
35
+
36
+ export const Branch = ({
37
+ defaultBranch = 0,
38
+ onBranchChange,
39
+ className,
40
+ ...props
41
+ }: BranchProps) => {
42
+ const [currentBranch, setCurrentBranch] = useState(defaultBranch);
43
+ const [branches, setBranches] = useState<ReactElement[]>([]);
44
+
45
+ const handleBranchChange = (newBranch: number) => {
46
+ setCurrentBranch(newBranch);
47
+ onBranchChange?.(newBranch);
48
+ };
49
+
50
+ const goToPrevious = () => {
51
+ const newBranch =
52
+ currentBranch > 0 ? currentBranch - 1 : branches.length - 1;
53
+ handleBranchChange(newBranch);
54
+ };
55
+
56
+ const goToNext = () => {
57
+ const newBranch =
58
+ currentBranch < branches.length - 1 ? currentBranch + 1 : 0;
59
+ handleBranchChange(newBranch);
60
+ };
61
+
62
+ const contextValue: BranchContextType = {
63
+ currentBranch,
64
+ totalBranches: branches.length,
65
+ goToPrevious,
66
+ goToNext,
67
+ branches,
68
+ setBranches,
69
+ };
70
+
71
+ return (
72
+ <BranchContext.Provider value={contextValue}>
73
+ <div
74
+ className={cn("grid w-full gap-2 [&>div]:pb-0", className)}
75
+ {...props}
76
+ />
77
+ </BranchContext.Provider>
78
+ );
79
+ };
80
+
81
+ export type BranchMessagesProps = HTMLAttributes<HTMLDivElement>;
82
+
83
+ export const BranchMessages = ({ children, ...props }: BranchMessagesProps) => {
84
+ const { currentBranch, setBranches, branches } = useBranch();
85
+ const childrenArray = useMemo(
86
+ () => (Array.isArray(children) ? children : [children]),
87
+ [children],
88
+ );
89
+
90
+ // Use useEffect to update branches when they change
91
+ useEffect(() => {
92
+ if (branches.length !== childrenArray.length) {
93
+ setBranches(childrenArray);
94
+ }
95
+ }, [childrenArray, branches, setBranches]);
96
+
97
+ return childrenArray.map((branch, index) => (
98
+ <div
99
+ className={cn(
100
+ "grid gap-2 overflow-hidden [&>div]:pb-0",
101
+ index === currentBranch ? "block" : "hidden",
102
+ )}
103
+ key={branch.key}
104
+ {...props}
105
+ >
106
+ {branch}
107
+ </div>
108
+ ));
109
+ };
110
+
111
+ export type BranchSelectorProps = HTMLAttributes<HTMLDivElement> & {
112
+ from: UIMessage["role"];
113
+ };
114
+
115
+ export const BranchSelector = ({
116
+ className,
117
+ from,
118
+ ...props
119
+ }: BranchSelectorProps) => {
120
+ const { totalBranches } = useBranch();
121
+
122
+ // Don't render if there's only one branch
123
+ if (totalBranches <= 1) {
124
+ return null;
125
+ }
126
+
127
+ return (
128
+ <div
129
+ className={cn(
130
+ "flex items-center gap-2 self-end px-10",
131
+ from === "assistant" ? "justify-start" : "justify-end",
132
+ className,
133
+ )}
134
+ {...props}
135
+ />
136
+ );
137
+ };
138
+
139
+ export type BranchPreviousProps = ComponentProps<typeof Button>;
140
+
141
+ export const BranchPrevious = ({
142
+ className,
143
+ children,
144
+ ...props
145
+ }: BranchPreviousProps) => {
146
+ const { goToPrevious, totalBranches } = useBranch();
147
+
148
+ return (
149
+ <Button
150
+ aria-label="Previous branch"
151
+ className={cn(
152
+ "size-7 shrink-0 rounded-full text-muted-foreground transition-colors",
153
+ "hover:bg-accent hover:text-foreground",
154
+ "disabled:pointer-events-none disabled:opacity-50",
155
+ className,
156
+ )}
157
+ disabled={totalBranches <= 1}
158
+ onClick={goToPrevious}
159
+ size="icon"
160
+ type="button"
161
+ variant="ghost"
162
+ {...props}
163
+ >
164
+ {children ?? <ChevronLeftIcon size={14} />}
165
+ </Button>
166
+ );
167
+ };
168
+
169
+ export type BranchNextProps = ComponentProps<typeof Button>;
170
+
171
+ export const BranchNext = ({
172
+ className,
173
+ children,
174
+ ...props
175
+ }: BranchNextProps) => {
176
+ const { goToNext, totalBranches } = useBranch();
177
+
178
+ return (
179
+ <Button
180
+ aria-label="Next branch"
181
+ className={cn(
182
+ "size-7 shrink-0 rounded-full text-muted-foreground transition-colors",
183
+ "hover:bg-accent hover:text-foreground",
184
+ "disabled:pointer-events-none disabled:opacity-50",
185
+ className,
186
+ )}
187
+ disabled={totalBranches <= 1}
188
+ onClick={goToNext}
189
+ size="icon"
190
+ type="button"
191
+ variant="ghost"
192
+ {...props}
193
+ >
194
+ {children ?? <ChevronRightIcon size={14} />}
195
+ </Button>
196
+ );
197
+ };
198
+
199
+ export type BranchPageProps = HTMLAttributes<HTMLSpanElement>;
200
+
201
+ export const BranchPage = ({ className, ...props }: BranchPageProps) => {
202
+ const { currentBranch, totalBranches } = useBranch();
203
+
204
+ return (
205
+ <span
206
+ className={cn(
207
+ "font-medium text-muted-foreground text-xs tabular-nums",
208
+ className,
209
+ )}
210
+ {...props}
211
+ >
212
+ {currentBranch + 1} of {totalBranches}
213
+ </span>
214
+ );
215
+ };
@@ -0,0 +1,22 @@
1
+ import { Background, ReactFlow, type ReactFlowProps } from "@xyflow/react";
2
+ import type { ReactNode } from "react";
3
+ import "@xyflow/react/dist/style.css";
4
+
5
+ type CanvasProps = ReactFlowProps & {
6
+ children?: ReactNode;
7
+ };
8
+
9
+ export const Canvas = ({ children, ...props }: CanvasProps) => (
10
+ <ReactFlow
11
+ deleteKeyCode={["Backspace", "Delete"]}
12
+ fitView
13
+ panOnDrag={false}
14
+ panOnScroll
15
+ selectionOnDrag={true}
16
+ zoomOnDoubleClick={false}
17
+ {...props}
18
+ >
19
+ <Background bgColor="var(--sidebar)" />
20
+ {children}
21
+ </ReactFlow>
22
+ );