diff --git a/frontend/src/chat.js b/frontend/src/chat.js index 2f7e831..196ae04 100644 --- a/frontend/src/chat.js +++ b/frontend/src/chat.js @@ -788,6 +788,7 @@ export class ChatSession { type: 'thread-header', threadId: fork.id, active: false, + isFork: true, messageCount: fork.messageCount, time: firstMessage?.time, @@ -796,7 +797,7 @@ export class ChatSession { }); } } - const addThreadHeader = (thread) => { + const addThreadHeader = (thread, isRoot) => { let isActive = this.activeThreadIds.includes(thread.id); let referenceMessage; @@ -837,11 +838,11 @@ export class ChatSession { if (!referenceMessage) return; headers.push({ - // claim just before id id: 't.' + thread.id, type: 'thread-header', threadId: thread.id, active: isActive, + isFork: !isRoot, messageCount: isActive ? 0 : thread.messageCount, time: referenceMessage.time, @@ -851,7 +852,9 @@ export class ChatSession { }); } - this.threads.forEach(addThreadHeader); + for (let root of this.threads) { + addThreadHeader(root, true); + } // Headers must be ordered by their attach id headers.sort((a, b) => parseInt(a.attach.id) - parseInt(b.attach.id)); diff --git a/frontend/src/components/Message.vue b/frontend/src/components/Message.vue index a14df50..1ad2236 100644 --- a/frontend/src/components/Message.vue +++ b/frontend/src/components/Message.vue @@ -16,6 +16,7 @@ marked.use({ } }); +const emit = defineEmits(['open-thread', 'open-menu', 'toggle-log', 'cancel']) const props = defineProps({ message: { type: Object, @@ -39,7 +40,12 @@ function chatEntryClass(msg) { } else if (msg.type == 'resource') { return ['resource', 'resource-' + (msg.subkind || 'generic')]; } else if (msg.type == 'log') { - return ['message', 'log']; + return ['log']; + } else if (msg.type == 'thread-header') { + let cls = ['thread']; + if (!msg.active) cls.push('thread-open') + if (msg.isFork) cls.push('thread-fork'); + return cls; } else { return ['info']; } @@ -50,6 +56,14 @@ function resourceLabel(msg) { return msg.subkind || 'Resource'; } +function handleClick(msg) { + if (msg.type == 'thread-header' || msg.type == 'fork-header') { + if (!msg.active && msg.threadId != null) { + emit('open-thread', msg.threadId) + } + } +} + const format = ref(null); const content = ref(""); @@ -94,7 +108,7 @@ watch(() => [props.message.format, props.message.content], ([newFormat, newConte diff --git a/frontend/src/views/Chat.vue b/frontend/src/views/Chat.vue index a7337ab..810b063 100644 --- a/frontend/src/views/Chat.vue +++ b/frontend/src/views/Chat.vue @@ -196,19 +196,20 @@
- + + :cancellable="messageRunMap[msg.id]" + @cancel="session.cancelMessageRun(msg.id)" + /> +
@@ -261,8 +262,12 @@ flex-direction: column; } - .messages-container > div { - margin-bottom: 10px; + .message-container { + width: 100%; + max-width: 80em; + margin: 0 auto 0.6em; + display: flex; + flex-direction: column; } .input-container {