Skip to content

Commit 0f6c1e6

Browse files
authored
Merge pull request #2 from cwandev/feature/branch
feat: add branch component
2 parents 6c09f91 + 1e8c2c1 commit 0f6c1e6

File tree

26 files changed

+2091
-2184
lines changed

26 files changed

+2091
-2184
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ AI Elements Vue includes the following components:
8787
| `response` | ✅ 已完成 | Formatted AI response display |
8888
| `prompt-input` | ✅ 已完成 | Advanced input component with model selection |
8989
| `actions` | ✅ 已完成 | Interactive action buttons for AI responses |
90-
| `branch` | ❌ 未完成 | Branch visualization for conversation flows |
90+
| `branch` | ✅ 已完成 | Branch visualization for conversation flows |
9191
| `code-block` | ❌ 未完成 | Syntax-highlighted code display with copy functionality |
9292
| `image` | ❌ 未完成 | AI-generated image display component |
9393
| `inline-citation` | ❌ 未完成 | Inline source citations |

apps/registry/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"devDependencies": {
1010
"@vue/compiler-sfc": "^3.5.21",
1111
"h3": "^1.15.4",
12-
"nitropack": "^2.12.4",
12+
"nitropack": "^2.12.6",
1313
"ts-morph": "^27.0.0"
1414
}
1515
}

apps/test/app/examples/branch.vue

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<script setup lang="ts">
2+
import { Branch, BranchMessages, BranchNext, BranchPage, BranchPrevious, BranchSelector } from '@repo/elements/branch'
3+
import { Message, MessageAvatar, MessageContent } from '@repo/elements/message'
4+
import { nanoid } from 'nanoid'
5+
6+
interface SimpleMessage {
7+
id: string
8+
content: string
9+
}
10+
11+
const userMessages: SimpleMessage[] = [
12+
{ id: nanoid(), content: 'What are the key strategies for optimizing Vue performance?' },
13+
{ id: nanoid(), content: 'How can I improve the performance of my Vue application?' },
14+
{ id: nanoid(), content: 'What performance optimization techniques should I use in Vue?' },
15+
]
16+
17+
const assistantMessages: SimpleMessage[] = [
18+
{ id: nanoid(), content: 'Here\'s the first response to your question. This approach focuses on performance optimization.' },
19+
{ id: nanoid(), content: 'Here\'s an alternative response. This approach emphasizes code readability and maintainability over pure performance.' },
20+
{ id: nanoid(), content: 'And here\'s a third option. This balanced approach considers both performance and maintainability, making it suitable for most use cases.' },
21+
]
22+
23+
function handleBranchChange(branchIndex: number) {
24+
// eslint-disable-next-line no-console
25+
console.log('Branch changed to:', branchIndex)
26+
}
27+
</script>
28+
29+
<template>
30+
<div class="space-y-8">
31+
<Branch :default-branch="0" :on-branch-change="handleBranchChange">
32+
<BranchMessages>
33+
<Message v-for="message in userMessages" :key="message.id" from="user">
34+
<MessageContent>{{ message.content }}</MessageContent>
35+
<MessageAvatar name="Hayden Bleasel" src="https://github.com/haydenbleasel.png" />
36+
</Message>
37+
</BranchMessages>
38+
<BranchSelector from="user">
39+
<BranchPrevious />
40+
<BranchPage />
41+
<BranchNext />
42+
</BranchSelector>
43+
</Branch>
44+
45+
<Branch :default-branch="0" :on-branch-change="handleBranchChange">
46+
<BranchMessages>
47+
<Message v-for="message in assistantMessages" :key="message.id" from="assistant">
48+
<MessageContent>{{ message.content }}</MessageContent>
49+
<MessageAvatar name="AI" src="https://github.com/openai.png" />
50+
</Message>
51+
</BranchMessages>
52+
<BranchSelector from="assistant">
53+
<BranchPrevious />
54+
<BranchPage />
55+
<BranchNext />
56+
</BranchSelector>
57+
</Branch>
58+
</div>
59+
</template>

apps/test/app/pages/index.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { Card, CardContent, CardHeader, CardTitle } from '@repo/shadcn-vue/components/ui/card'
33
import ActionsHover from '~/examples/actions-hover.vue'
44
import Actions from '~/examples/actions.vue'
5+
import Branch from '~/examples/branch.vue'
56
import Conversation from '~/examples/conversation.vue'
67
import MessageMarkdown from '~/examples/message-markdown.vue'
78
import Message from '~/examples/message.vue'
@@ -11,6 +12,7 @@ import Response from '~/examples/response.vue'
1112
const components = [
1213
{ name: 'Message', Component: Message },
1314
{ name: 'Actions', Component: Actions },
15+
{ name: 'Branch', Component: Branch },
1416
{ name: 'ActionsHover', Component: ActionsHover },
1517
{ name: 'PromptInput', Component: PromptInput },
1618
{ name: 'Conversation', Component: Conversation },

apps/test/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313
"dependencies": {
1414
"@repo/elements": "workspace:*",
1515
"@repo/shadcn-vue": "workspace:*",
16-
"@tailwindcss/vite": "^4.1.12",
17-
"@vueuse/core": "^13.8.0",
18-
"ai": "^5.0.28",
16+
"@tailwindcss/vite": "^4.1.13",
17+
"@vueuse/core": "^13.9.0",
18+
"ai": "^5.0.51",
1919
"class-variance-authority": "^0.7.1",
2020
"clsx": "^2.1.1",
21-
"lucide-vue-next": "^0.542.0",
22-
"nanoid": "^5.1.5",
23-
"nuxt": "^4.0.3",
21+
"lucide-vue-next": "^0.544.0",
22+
"nanoid": "^5.1.6",
23+
"nuxt": "^4.1.2",
2424
"shadcn-nuxt": "2.2.0",
2525
"tailwind-merge": "^3.3.1",
26-
"tailwindcss": "^4.1.12",
27-
"tw-animate-css": "^1.3.7",
28-
"vue": "^3.5.20",
26+
"tailwindcss": "^4.1.13",
27+
"tw-animate-css": "^1.4.0",
28+
"vue": "^3.5.21",
2929
"vue-router": "^4.5.1"
3030
},
3131
"devDependencies": {

apps/www/content/1.overview/1.Introduction.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@ You can install it with:
2727
:::ComponentLoader{label="Actions" componentName="Actions"}
2828
:::
2929

30+
:::ComponentLoader{label="Branch" componentName="Branch"}
31+
:::
32+
3033
View the [source code](https://github.com/cwandev/ai-elements-vue) for all components on GitHub.

0 commit comments

Comments
 (0)