Skip to content

Commit

Permalink
fix why not shown
Browse files Browse the repository at this point in the history
  • Loading branch information
zAlweNy26 committed Mar 29, 2024
1 parent a45ff73 commit 0c5b1d7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/components/MessageBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,12 @@ const fileUrl = computed(() => {
</div>
</div>
</div>
<div v-if="why" class="divider divider-horizontal m-0 w-px before:bg-base-200 after:bg-base-200" />
<button v-if="why" class="btn btn-circle btn-xs mx-2 border-0 bg-neutral/20 text-neutral" @click="whyPanel?.togglePanel()">
<p class="text-base">?</p>
</button>
<template v-if="why">
<div class="divider divider-horizontal m-0 w-px before:bg-base-200 after:bg-base-200" />
<button class="btn btn-circle btn-xs mx-2 border-0 bg-neutral/20 text-neutral" @click="whyPanel?.togglePanel()">
<p class="text-base">?</p>
</button>
</template>
</div>
<div v-if="sender === 'bot'" class="chat-footer mt-1 flex gap-1">
<div class="tooltip tooltip-bottom" data-tip="Copy">
Expand Down
2 changes: 1 addition & 1 deletion src/models/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface MessageBase {
*/
export interface BotMessage extends MessageBase {
readonly sender: 'bot'
readonly why: any
why: any
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/stores/useMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const useMessages = defineStore('messages', () => {
if (currentState.generating) {
const index = currentState.messages.findIndex(m => m.id === currentState.generating)
currentState.messages[index].text = content
if (currentState.messages[index].sender === 'bot') currentState.messages[index].why = why

Check failure on line 90 in src/stores/useMessages.ts

View workflow job for this annotation

GitHub Actions / build

Property 'why' does not exist on type '{ readonly sender: "bot"; why: any; readonly id: string; readonly when: { toString: () => string; toDateString: () => string; toTimeString: () => string; toLocaleString: { (): string; (locales?: string | string[] | undefined, options?: DateTimeFormatOptions | undefined): string; (locales?: LocalesArgument, options?:...'.

Check failure on line 90 in src/stores/useMessages.ts

View workflow job for this annotation

GitHub Actions / build

Property 'why' does not exist on type '{ readonly sender: "bot"; why: any; readonly id: string; readonly when: { toString: () => string; toDateString: () => string; toTimeString: () => string; toLocaleString: { (): string; (locales?: string | string[] | undefined, options?: DateTimeFormatOptions | undefined): string; (locales?: LocalesArgument, options?:...'.
currentState.generating = undefined
} else {
addMessage({
Expand Down Expand Up @@ -173,6 +174,7 @@ export const useMessages = defineStore('messages', () => {

return {
currentState,
history,
addMessage,
selectRandomDefaultMessages,
dispatchMessage,
Expand Down
5 changes: 4 additions & 1 deletion src/views/HomeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ const generatePlaceholder = (isLoading: boolean, isRecording: boolean, error?: s
const wipeHistory = async () => {
const res = await wipeConversation()
if (res) messagesState.value.messages = []
if (res) {
messagesState.value.messages = []
messagesStore.history = []
}
}
const scrollToBottom = () => {
Expand Down

0 comments on commit 0c5b1d7

Please sign in to comment.