Skip to content

Commit 10e42b5

Browse files
authored
Merge branch 'v2' into v2
2 parents 4f25b62 + ef3279e commit 10e42b5

53 files changed

Lines changed: 5276 additions & 5066 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/assets/css/main.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ img[alt="MemOS Banner"] {
5454
display: none;
5555
}
5656

57+
.mdc-live p {
58+
margin: 6px !important;
59+
line-height: 1.5;
60+
}
61+
.mdc-live code {
62+
word-break: break-word;
63+
}
64+
5765
html {
5866
-ms-overflow-style: none; /* IE and Edge */
5967
scrollbar-width: none; /* Firefox */

app/components/AppFooter.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const socialData: SocialLink[] = [
1616
},
1717
{
1818
icon: 'ri:twitter-x-fill',
19-
link: 'https://x.com/MemOS_MemTensor'
19+
link: 'https://x.com/MemOS_dev'
2020
},
2121
{
2222
icon: 'ri:discord-fill',

app/components/Assistant/Collapse.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<script setup lang="ts">
22
const { toggleOpen } = useAssistant()
3+
const { trackEvent } = useArms()
4+
5+
function onToggleOpen() {
6+
trackEvent('点击Ask AI', '按钮点击')
7+
toggleOpen()
8+
}
39
</script>
410

511
<template>
@@ -11,7 +17,7 @@ const { toggleOpen } = useAssistant()
1117
base: 'rounded-lg cursor-pointer',
1218
leadingIcon: 'size-4'
1319
}"
14-
@click="toggleOpen"
20+
@click="onToggleOpen"
1521
>
1622
Ask AI
1723
</UButton>

app/components/Assistant/index.vue

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const {
99
sendMessage,
1010
stopStreaming
1111
} = useAssistant()
12+
const { trackEvent } = useArms()
1213
1314
const onEnter = (e: KeyboardEvent) => {
1415
if (e.isComposing) {
@@ -18,6 +19,7 @@ const onEnter = (e: KeyboardEvent) => {
1819
}
1920
2021
const handleFormSubmit = async () => {
22+
trackEvent('发起对话', '按钮点击')
2123
try {
2224
await sendMessage(userInput.value)
2325
} catch (error) {
@@ -33,22 +35,40 @@ watch([suggestions, status], async () => {
3335
suggestionsRef.value?.scrollIntoView({ behavior: 'smooth', block: 'end' })
3436
}
3537
})
38+
39+
function onClose() {
40+
trackEvent('关闭助手面板', '按钮点击')
41+
toggleOpen()
42+
}
43+
44+
function onSuggestionClick(item: string) {
45+
trackEvent('参考问题', '按钮点击')
46+
sendMessage(item)
47+
}
48+
49+
function onStopStreaming() {
50+
trackEvent('停止对话', '按钮点击')
51+
stopStreaming()
52+
}
3653
</script>
3754

3855
<template>
3956
<Transition name="slide">
4057
<div
4158
v-if="isOpen"
42-
class="h-full shrink-0 overflow-hidden"
59+
class="h-screen sticky top-0 shrink-0 overflow-hidden"
4360
>
4461
<UDashboardSidebar
4562
id="assistant"
4663
class="overflow-y-auto h-full border-l border-default -ml-px"
4764
side="right"
4865
resizable
49-
:default-size="368"
50-
:min-size="368"
66+
:default-size="400"
67+
:min-size="400"
5168
:max-size="576"
69+
:ui="{
70+
body: 'pb-4'
71+
}"
5272
>
5373
<div class="flex items-center justify-between">
5474
<div class="flex items-center gap-1.5">
@@ -61,7 +81,7 @@ watch([suggestions, status], async () => {
6181
<div class="flex items-center gap-2">
6282
<button
6383
class="group flex items-center hover:bg-gray-100 dark:hover:bg-white/10 p-1.5 rounded-lg cursor-pointer"
64-
@click="toggleOpen"
84+
@click="onClose"
6585
>
6686
<UIcon
6787
name="i-lucide:x"
@@ -73,7 +93,7 @@ watch([suggestions, status], async () => {
7393

7494
<UChatPalette
7595
:ui="{
76-
content: 'scrollbar-hide'
96+
content: 'scrollbar-hide pr-px'
7797
}"
7898
>
7999
<UChatMessage
@@ -90,12 +110,12 @@ watch([suggestions, status], async () => {
90110
:status="status"
91111
should-auto-scroll
92112
:ui="{
93-
root: 'px-0'
113+
root: 'px-0 [&>article]:last-of-type:min-h-auto'
94114
}"
95115
>
96116
<template #content="{ message }">
97117
<AssistantMDC
98-
v-if="message.role === 'assistant'"
118+
v-if="message.role === 'assistant' && message.content"
99119
:value="message.content"
100120
class="text-sm"
101121
/>
@@ -120,7 +140,7 @@ watch([suggestions, status], async () => {
120140
v-for="(item, index) in suggestions"
121141
:key="index"
122142
class="hover:text-primary/80 cursor-pointer"
123-
@click="sendMessage(item)"
143+
@click="onSuggestionClick(item)"
124144
>
125145
{{ item }}
126146
</li>
@@ -140,8 +160,10 @@ watch([suggestions, status], async () => {
140160
>
141161
<UChatPromptSubmit
142162
size="sm"
163+
submitted-icon="i-lucide-circle"
164+
streaming-icon="i-lucide-circle"
143165
:status="status"
144-
@stop="stopStreaming"
166+
@stop="onStopStreaming"
145167
/>
146168
</UChatPrompt>
147169
</template>

app/composables/useAssistant.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,6 @@ export const useAssistant = () => {
121121
setUserInput('')
122122
}
123123

124-
const assistantId = (Date.now() + 1).toString()
125-
addMessage({
126-
id: assistantId,
127-
role: 'assistant',
128-
content: '',
129-
createAt: new Date()
130-
})
131-
132124
status.value = 'submitted'
133125

134126
try {
@@ -147,6 +139,13 @@ export const useAssistant = () => {
147139
for await (const chunk of stream) {
148140
if (status.value !== 'streaming') {
149141
status.value = 'streaming'
142+
const assistantId = (Date.now() + 1).toString()
143+
addMessage({
144+
id: assistantId,
145+
role: 'assistant',
146+
content: '',
147+
createAt: new Date()
148+
})
150149
}
151150
if (chunk.type === 'text' && chunk.data) {
152151
assistantContent += chunk.data

app/layouts/default.vue

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,58 @@
1+
<script setup lang="ts">
2+
const route = useRoute()
3+
const nuxtApp = useNuxtApp()
4+
5+
// Handle scroll reset on page navigation finish
6+
nuxtApp.hook('page:finish', () => {
7+
nextTick(() => {
8+
// Check if there is a hash
9+
if (route.hash) {
10+
const el = document.querySelector(route.hash)
11+
if (el) {
12+
el.scrollIntoView({ behavior: 'smooth' })
13+
}
14+
} else {
15+
// Reset scroll to top if no hash
16+
const el = document.getElementById('dashboard-panel-main')
17+
if (el) {
18+
el.scrollTop = 0
19+
}
20+
}
21+
})
22+
})
23+
24+
watch(() => route.hash, (hash) => {
25+
if (hash) {
26+
nextTick(() => {
27+
const el = document.querySelector(hash)
28+
if (el) {
29+
el.scrollIntoView({ behavior: 'smooth' })
30+
}
31+
})
32+
}
33+
})
34+
35+
onMounted(() => {
36+
if (route.hash) {
37+
nextTick(() => {
38+
const el = document.querySelector(route.hash)
39+
if (el) {
40+
el.scrollIntoView({ behavior: 'smooth' })
41+
}
42+
})
43+
}
44+
})
45+
</script>
46+
147
<template>
248
<UDashboardGroup
349
:persistent="false"
450
unit="px"
51+
class="h-screen overflow-hidden"
552
>
653
<UDashboardPanel
754
id="main"
8-
class="overflow-y-auto scrollbar-hide"
55+
class="h-full overflow-y-auto scrollbar-hide "
956
>
1057
<slot />
1158
</UDashboardPanel>

app/utils/oas.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@ function generateSampleFromSchema(schema: SchemaObject, api: OASDocument): unkno
225225
Object.entries(schema.properties).forEach(([key, propSchema]) => {
226226
obj[key] = generateSampleFromSchema(propSchema as SchemaObject, api)
227227
})
228+
} else if ('items' in schema) {
229+
return generateSampleFromSchema((schema as any).items as SchemaObject, api)
228230
}
231+
229232
return obj
230233
}
231234

0 commit comments

Comments
 (0)