Skip to content

Commit d220112

Browse files
authored
Issue #299: Fix for "New" button redirect on assistant chat (#302)
* redirect with router on assistant chat start * put redirect in a function returned by AssistantContainer
1 parent 16c5b3e commit d220112

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

components/Assistant.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export default defineComponent({
1515
type: String,
1616
},
1717
},
18-
setup(props) {
18+
emits: ['send'],
19+
setup(props, { emit }) {
1920
const { id } = useId()
2021
const { isDesktop, modKey } = useDevice()
2122
const chatId = computed(() => props.chatId || id())
@@ -218,6 +219,8 @@ export default defineComponent({
218219
}
219220
220221
isWaiting.value = false
222+
223+
emit('send')
221224
}
222225
223226
const examplePrompts = ref([

components/AssistantContainer.vue

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,22 @@ export default defineComponent({
88
const { isMounted } = useVue()
99
const chatIdFromRoute = computed(() => router.currentRoute.value.params.id as string)
1010
const chatId = computed(() => chatIdFromRoute.value || id())
11-
const { chat } = useChat(chatId)
12-
const { pushRoute } = useSoftNavigation()
1311
14-
watch(chat, () => {
15-
if (chat.value && !chatIdFromRoute.value) {
16-
pushRoute({
17-
path: `/assistant/conversations/${chatId.value}`,
18-
})
19-
}
20-
})
12+
const redirect = () => {
13+
router.push({ path: `/assistant/conversations/${chatId.value}` })
14+
}
2115
2216
return {
2317
chatId,
2418
isMounted,
19+
redirect,
2520
}
2621
},
2722
})
2823
</script>
2924

3025
<template>
3126
<article class="flex flex-col flex-grow">
32-
<Assistant v-if="isMounted" :chat-id="chatId" />
27+
<Assistant v-if="isMounted" :chat-id="chatId" @send="redirect" />
3328
</article>
3429
</template>

0 commit comments

Comments
 (0)