Repository navigation
feat(nuxi): smooth chat streaming and compact tool activity #2671
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
Open
HugoRCD
wants to merge
8
commits into
main
Choose a base branch
from
codex/nuxi-chat-rendering
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.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b52573e
feat(nuxi): smooth chat streaming and compact tool activity
HugoRCD 7d1830e
Merge remote-tracking branch 'origin/main' into codex/nuxi-chat-rende…
HugoRCD 8ae31ce
fix(nuxi): animate chat reset and preserve streamed text
HugoRCD 6dcf301
fix(nuxi): address streaming and source review feedback
HugoRCD cdde803
fix(nuxi): preserve nested link labels while streaming
HugoRCD 1dd8162
fix(nuxi): handle paragraph and URL link boundaries
HugoRCD 734fa0d
fix(nuxi): handle delimited links and invalid destinations
HugoRCD 04df9a2
fix(nuxi): release invalid multiline angle destinations
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,113 +1,12 @@ | ||
| <script setup lang="ts"> | ||
| const size = 4 | ||
| const dotSize = 2 | ||
| const gap = 2 | ||
| const totalDots = size * size | ||
|
|
||
| const patterns = [ | ||
| [[0], [1], [2], [3], [7], [11], [15], [14], [13], [12], [8], [4], [5], [6], [10], [9]], | ||
| [[0, 4, 8, 12], [1, 5, 9, 13], [2, 6, 10, 14], [3, 7, 11, 15]], | ||
| [[5, 6, 9, 10], [1, 4, 7, 8, 11, 14], [0, 3, 12, 15], [1, 4, 7, 8, 11, 14], [5, 6, 9, 10]], | ||
| [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]], | ||
| [[0], [3], [15], [12]], | ||
| [[5, 6, 9, 10], [1, 2, 4, 7, 8, 11, 13, 14], [0, 3, 12, 15]], | ||
| [[0], [1], [2], [3], [7], [6], [5], [4], [8], [9], [10], [11], [15], [14], [13], [12]], | ||
| [[0], [1, 4], [2, 5, 8], [3, 6, 9, 12], [7, 10, 13], [11, 14], [15]] | ||
| ] | ||
|
|
||
| const activeDots = ref<Set<number>>(new Set()) | ||
| let patternIndex = 0 | ||
| let stepIndex = 0 | ||
|
|
||
| function nextStep() { | ||
| const pattern = patterns[patternIndex] | ||
| if (!pattern) return | ||
|
|
||
| activeDots.value = new Set(pattern[stepIndex]) | ||
| stepIndex++ | ||
|
|
||
| if (stepIndex >= pattern.length) { | ||
| stepIndex = 0 | ||
| patternIndex = (patternIndex + 1) % patterns.length | ||
| } | ||
| } | ||
|
|
||
| const statusMessages = ['Thinking...', 'Searching...', 'Reading...', 'Analyzing...'] | ||
| const currentIndex = ref(0) | ||
| const displayedText = ref(statusMessages[0]!) | ||
| const chars = 'abcdefghijklmnopqrstuvwxyz' | ||
|
|
||
| function scramble(from: string, to: string) { | ||
| const maxLength = Math.max(from.length, to.length) | ||
| let frame = 0 | ||
| const totalFrames = 15 | ||
|
|
||
| const step = () => { | ||
| frame++ | ||
| let result = '' | ||
| const progress = (frame / totalFrames) * maxLength | ||
|
|
||
| for (let i = 0; i < maxLength; i++) { | ||
| if (i < progress - 2) { | ||
| result += to[i] || '' | ||
| } else if (i < progress) { | ||
| result += chars[Math.floor(Math.random() * chars.length)] | ||
| } else { | ||
| result += from[i] || '' | ||
| } | ||
| } | ||
|
|
||
| displayedText.value = result | ||
|
|
||
| if (frame < totalFrames) { | ||
| requestAnimationFrame(step) | ||
| } else { | ||
| displayedText.value = to | ||
| } | ||
| } | ||
|
|
||
| requestAnimationFrame(step) | ||
| } | ||
|
|
||
| let matrixInterval: ReturnType<typeof setInterval> | undefined | ||
| let textInterval: ReturnType<typeof setInterval> | undefined | ||
|
|
||
| onMounted(() => { | ||
| nextStep() | ||
| matrixInterval = setInterval(nextStep, 120) | ||
| textInterval = setInterval(() => { | ||
| const prev = displayedText.value | ||
| currentIndex.value = (currentIndex.value + 1) % statusMessages.length | ||
| scramble(prev, statusMessages[currentIndex.value]!) | ||
| }, 3500) | ||
| }) | ||
|
|
||
| onUnmounted(() => { | ||
| clearInterval(matrixInterval) | ||
| clearInterval(textInterval) | ||
| }) | ||
| withDefaults(defineProps<{ text?: string, avatar?: boolean, avatarTransitionName?: string }>(), { text: 'Thinking', avatar: false }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div class="flex items-center text-sm text-muted overflow-hidden"> | ||
| <div | ||
| class="shrink-0 mr-2 grid" | ||
| :style="{ | ||
| gridTemplateColumns: `repeat(${size}, 1fr)`, | ||
| gap: `${gap}px`, | ||
| width: `${size * dotSize + (size - 1) * gap}px`, | ||
| height: `${size * dotSize + (size - 1) * gap}px` | ||
| }" | ||
| > | ||
| <span | ||
| v-for="i in totalDots" | ||
| :key="i" | ||
| class="rounded-[0.5px] bg-current transition-opacity duration-100" | ||
| :class="activeDots.has(i - 1) ? 'opacity-100' : 'opacity-20'" | ||
| :style="{ width: `${dotSize}px`, height: `${dotSize}px` }" | ||
| /> | ||
| </div> | ||
|
|
||
| <UChatShimmer :text="displayedText" /> | ||
| <div class="flex min-h-7 items-center gap-3 text-sm text-muted" role="status"> | ||
| <span v-if="avatar" class="grid size-7 shrink-0 place-items-center" :style="avatarTransitionName ? { viewTransitionName: avatarTransitionName } : undefined" aria-hidden="true"> | ||
| <AgentNuxiIcon mood="thinking" :interactive="false" class="h-6 w-7 text-default" /> | ||
| </span> | ||
| <UChatShimmer :text="text" /> | ||
| </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
Oops, something went wrong.
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.