ChatView.vue
1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<template>
<div class="workbench">
<div class="col left">
<TestControlCenter @send="sendAndSelect" />
</div>
<div class="col main">
<LiveDiagnosticsFeed :active-assistant-id="activeAssistantId" @select="onSelectAssistant" @send="sendAndSelect" />
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
import TestControlCenter from "../components/workbench/TestControlCenter.vue";
import LiveDiagnosticsFeed from "../components/workbench/LiveDiagnosticsFeed.vue";
import { useChatStore } from "../stores/chat";
const chat = useChatStore();
const activeAssistantId = ref("");
async function sendAndSelect(text: string): Promise<void> {
const before = chat.messages.length;
await chat.send(text);
const after = chat.messages.length;
if (after > before) {
for (let i = after - 1; i >= 0; i -= 1) {
const m = chat.messages[i];
if (m.role === "assistant") {
activeAssistantId.value = m.id;
break;
}
}
}
}
function onSelectAssistant(id: string): void {
activeAssistantId.value = id;
}
</script>
<style scoped>
.workbench {
height: 100%;
display: grid;
grid-template-columns: 320px 1fr;
gap: 0;
width: 100%;
}
.col {
min-width: 0;
}
.left {
height: 100%;
overflow-y: auto;
padding: 18px 14px 18px 18px;
scrollbar-width: thin;
}
.left::-webkit-scrollbar {
width: 8px;
}
.left::-webkit-scrollbar-thumb {
background: rgba(15, 23, 42, 0.16);
border-radius: 999px;
border: 2px solid rgba(250, 250, 250, 1);
background-clip: content-box;
}
.left::-webkit-scrollbar-track {
background: transparent;
}
.main {
height: 100%;
overflow: hidden;
padding: 18px 24px 18px 18px;
}
</style>