-
Notifications
You must be signed in to change notification settings - Fork 263
perf(nuxi): optimise chat composables, caching and navigation #2305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
HugoRCD
wants to merge
13
commits into
main
Choose a base branch
from
fix/chat-persistence
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c121c7b
fix: improve chat persistence
HugoRCD e0e6732
fix: improve chat persistence
HugoRCD fdaee15
perf(nuxi): optimise chat navigation and caching
HugoRCD 9284933
fix(nuxi): address review feedback and dashboard chat fixes
HugoRCD a8e1624
fix(nuxi): clear chat sidebar list on logout
HugoRCD f23fc63
Merge remote-tracking branch 'origin/main' into fix/chat-persistence
HugoRCD 8985ec6
fix(nuxi): prevent empty useAsyncData key on anonymous chat navigation
HugoRCD 1b99339
refactor(nuxi): merge AgentChatPage back into chat [id] page
HugoRCD 4d6c15f
fix(nuxi): fix anonymous chat navigation during view transition
HugoRCD 329c3e1
Merge branch 'main' into fix/chat-persistence
HugoRCD 54b6558
refactor(nuxi): merge chat composables into useNuxiChat and useChatDe…
HugoRCD 2133946
Merge remote-tracking branch 'origin/main' into fix/chat-persistence
HugoRCD 54d5d1d
address code rabbit issue
HugoRCD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| <script setup lang="ts"> | ||
| import type { UIMessage } from 'ai' | ||
| import type { AgentChatHandle } from '../../composables/eve/types' | ||
|
|
||
| const input = defineModel<string>('input', { required: true }) | ||
|
|
||
| const props = withDefaults(defineProps<{ | ||
| chat: AgentChatHandle | ||
| chatId: string | ||
| prompt: { pasteAttachments: TextPasteAttachment[], canSubmit: boolean } | ||
| usage?: { used: number, remaining: number, limit: number } | ||
| rateLimitReached?: boolean | ||
| compact?: boolean | ||
| showFaqEmpty?: boolean | ||
| faqQuestions?: FaqCategory[] | ||
| showActions?: boolean | ||
| showUserTimestamps?: boolean | ||
| spacingOffset?: number | ||
| getVote: (messageId: string) => boolean | null | ||
| variant?: 'subtle' | 'naked' | ||
| size?: 'sm' | 'md' | ||
| promptClass?: string | ||
| promptUi?: Record<string, string> | ||
| submitDisabled?: boolean | ||
| rateLimitVariant?: 'sticky' | 'footer' | ||
| loginHintBar?: boolean | ||
| }>(), { | ||
| compact: false, | ||
| showFaqEmpty: false, | ||
| faqQuestions: () => [], | ||
| showActions: true, | ||
| showUserTimestamps: false, | ||
| spacingOffset: 0, | ||
| variant: 'subtle', | ||
| rateLimitVariant: 'sticky', | ||
| loginHintBar: false | ||
| }) | ||
|
|
||
| const emit = defineEmits<{ | ||
| submit: [] | ||
| paste: [event: ClipboardEvent] | ||
| removeAttachment: [index: number] | ||
| restoreAttachment: [index: number] | ||
| vote: [message: UIMessage, isUpvoted: boolean] | ||
| askQuestion: [question: string] | ||
| }>() | ||
|
|
||
| const { loggedIn } = useUserSession() | ||
| const showLoginHint = computed(() => props.loginHintBar || !loggedIn.value) | ||
|
|
||
| const promptRef = useTemplateRef('promptRef') | ||
| defineExpose({ | ||
| focus: () => promptRef.value?.focus() | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <AgentChatMessages | ||
| :chat="chat" | ||
| :chat-id="chatId" | ||
| :compact="compact" | ||
| :show-faq-empty="showFaqEmpty" | ||
| :faq-questions="faqQuestions" | ||
| :show-actions="showActions" | ||
| :show-user-timestamps="showUserTimestamps" | ||
| :spacing-offset="spacingOffset" | ||
| :get-vote="getVote" | ||
| :class="compact ? 'flex flex-col gap-4' : 'flex-1 pt-4 pb-4 sm:pb-6'" | ||
| @ask-question="emit('askQuestion', $event)" | ||
| @vote="(message, isUpvoted) => emit('vote', message, isUpvoted)" | ||
| /> | ||
|
|
||
| <AgentRateLimitBanner v-if="rateLimitReached" :variant="rateLimitVariant" /> | ||
|
|
||
| <div | ||
| v-else | ||
| class="flex flex-col gap-1.5" | ||
| :class="rateLimitVariant === 'sticky' ? 'sticky bottom-0 z-10 bg-default' : ''" | ||
| > | ||
| <slot name="before-prompt" /> | ||
|
|
||
| <AgentLoginHint v-if="showLoginHint" :bar="loginHintBar" /> | ||
|
|
||
| <AgentChatPrompt | ||
| ref="promptRef" | ||
| v-model="input" | ||
| v-bind="prompt" | ||
| :chat="chat" | ||
| :usage="usage" | ||
| :variant="variant" | ||
| :size="size" | ||
| :submit-disabled="submitDisabled" | ||
| :class="promptClass" | ||
| :ui="promptUi" | ||
| @submit="emit('submit')" | ||
| @paste="emit('paste', $event)" | ||
| @remove-attachment="emit('removeAttachment', $event)" | ||
| @restore-attachment="emit('restoreAttachment', $event)" | ||
| > | ||
| <template v-if="$slots['prompt-footer-left']" #footer-left> | ||
| <slot name="prompt-footer-left" /> | ||
| </template> | ||
| </AgentChatPrompt> | ||
| </div> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.