59bb7fbc12
This is once again a huge commit, but its mostly performance improvements along with some bug fixes and refactoring. It also includes changes to the theming systems. I'm still not 100% happy with the theming system, but its better than before. Model fetching has been dramatically improved! Nearly all the important computation and pre-processing has been moved to the server. This has also somehow fixed the way model details are loaded, which was causing many models to be missing their details despite models.dev having them. The markdown renderer has once again been changed, but I'm mostly certain that this is the last time major changes will be made to it. The renderer is not spamming components, bloating memory usage, and its not using a bug prone custom written chunking system. There's also a lot more that I haven't mentioned and honestly forgot. I need to get better commit hygiene tbh.
76 lines
2.5 KiB
Vue
76 lines
2.5 KiB
Vue
<script lang="ts" setup>
|
|
import type { Entity } from '@triplit/client';
|
|
import type schema from '#triplit/schema';
|
|
|
|
const props = defineProps<{
|
|
part: Readonly<Entity<typeof schema, 'message_parts'>>;
|
|
}>();
|
|
|
|
const reasoningOpen = ref(!props.part.finished);
|
|
|
|
watch(
|
|
() => props.part.finished,
|
|
() => {
|
|
reasoningOpen.value = !props.part.finished;
|
|
},
|
|
);
|
|
|
|
const containerRef: Ref<HTMLDivElement | null> = ref(null);
|
|
const scrollState = ref('middle');
|
|
|
|
const { scrollToBottom } = useAutoScroll(containerRef);
|
|
|
|
const handleScroll = () => {
|
|
if (!containerRef.value) return;
|
|
|
|
const container = containerRef.value;
|
|
const scrollTop = container.scrollTop;
|
|
const scrollHeight = container.scrollHeight;
|
|
const clientHeight = container.clientHeight;
|
|
|
|
const topThreshold = 0.02 * clientHeight;
|
|
|
|
if (scrollTop <= topThreshold) {
|
|
scrollState.value = 'top';
|
|
} else if (scrollTop + 100 >= scrollHeight - clientHeight) {
|
|
scrollState.value = 'bottom';
|
|
} else {
|
|
scrollState.value = 'middle';
|
|
}
|
|
};
|
|
|
|
const toggleReasoning = async () => {
|
|
if (!props.part.finished) return;
|
|
|
|
reasoningOpen.value = !reasoningOpen.value;
|
|
if (!reasoningOpen.value) return;
|
|
await nextTick();
|
|
scrollToBottom('instant');
|
|
handleScroll();
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<div class="text-[--text-tertiary]">
|
|
<button @click="toggleReasoning" :class="[
|
|
'w-full hover:bg-[var(--color-hover)] rounded-lg p-1 flex justify-between items-center transition-colors duration-200 ease-[cubic-bezier(0.5,_1,_0.89,_1)]',
|
|
part.finished ? '' : 'cursor-default'
|
|
]">
|
|
<div class="flex items-center gap-1">
|
|
<div
|
|
class="w-[24px] h-[24px] flex-shrink-0 rounded-lg overflow-hidden bg-[var(--bg-surface)] flex items-center justify-center">
|
|
<Icon name="mynaui:atom" class="w-3 h-3 text-[var(--reasoning-accent)]" />
|
|
</div>
|
|
Deep Thinking
|
|
</div>
|
|
<Icon name="mynaui:chevron-down" :class="['w-4 h-4', reasoningOpen ? '' : '-rotate-90']" />
|
|
</button>
|
|
<div v-if="reasoningOpen" ref="containerRef" @scroll="handleScroll"
|
|
:class="['reasoning-contaizner max-h-[min(40vh,320px)] overflow-y-auto [scrollbar-width:thin] [scrollbar-color:#888_transparent] [scrollbar-gutter:stable]', scrollState]">
|
|
<div class="p-2">
|
|
<MarkdownRenderer :finished="part.finished" :id="part.id" :content="part.content" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|