feat: group chat session lifecycle, typing recovery, mention highlighting (#186)

* feat: restore group chat system with Socket.IO and SQLite persistence

- GroupChatServer: Socket.IO server with room management, message history, typing indicators
- SQLite storage for rooms, messages, and agent configuration
- AgentClients: manages AI agent connections via socket.io-client, forwards @mentions to Hermes gateway
- REST API: room CRUD, agent management, invite codes
- Agent auto-restoration on server restart
- Tests for all REST endpoints

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: add context-engine design document for group chat compression

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: handle special-character session search

* fix: keep unicode dotted session search on quoted FTS path

* feat: add context engine and group chat frontend UI

- Context engine: three-zone compression (head/tail/summary) with LLM
  summarization, incremental updates, TTL cache, and graceful degradation
- Frontend: group chat page with Socket.IO client, room sidebar, message
  list, agent/member display, create/join-by-code modals
- Integration: wire context engine into agent-clients before /v1/runs
- Refactor ChatStorage to use global DB (getDb/ensureTable) with gc_ prefix
- Add i18n keys for group chat to all 8 locales
- Add sidebar nav entry and router for group chat page

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: remove leftover main branch code from merge conflict resolution

The `isNumericQuery`, `hasUnsafeChars`, and `runLikeContentSearch` functions
no longer exist — they were replaced by HEAD's `shouldUseLiteralContentSearch`
and `runLiteralContentSearch`. This dead code block caused a TypeScript
compile error after the merge.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: install missing socket.io dep and type ack params

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: enable WebSocket proxy and fix socket.io transport for group chat

- Add ws: true to Vite proxy config so WebSocket upgrade requests
  are forwarded to the backend
- Allow both polling and websocket transports on server and client
  (polling as fallback when WebSocket upgrade fails through proxy)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: separate socket.io path from REST routes for group chat

socket.io was mounted at /api/hermes/group-chat which intercepted all
REST requests to /api/hermes/group-chat/rooms etc, returning
"Transport unknown". Changed socket.io path to /api/hermes/group-chat/ws
to avoid conflicts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: improve group chat UI, agent management, and socket.io reliability

- Redesign GroupChatPanel with Naive UI, stacked agent avatars, and popover management
- Match GroupChatInput style with single chat input, add IME composition handling
- Add agent add/remove per room with profile selection and duplicate prevention
- Use @multiavatar for SVG avatar generation with caching
- Decouple joinRoom from socket.io, use REST API for data loading
- Switch socket.io to default path with /group-chat namespace to avoid proxy conflicts
- Restore agent connections after server is listening
- Add getRoomDetail REST endpoint and duplicate agent prevention (409)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: server-side @mention routing with context compression status and queue

- Move @mention detection from agent socket listeners to server-side processMentions()
- Add per-room processing lock to block mention dispatch during compression
- Queue mentions during processing, drain only the latest when ready
- Emit context_status events (compressing/replying/ready) to room via Socket.IO
- Frontend displays compression status indicator above input
- Token-based compression trigger (100k threshold) with CJK-aware estimation
- Fix compressor type errors (countTokens parameter type)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: improve group chat profile handling and session sync

Refine group chat room/session behavior with per-room compression controls, sidebar updates, and better stale session cleanup so multi-profile group chat state stays consistent.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: group chat improvements — session lifecycle, typing recovery, mention highlighting

- Fix cross-profile session deletion with deferred delete queue
- Move saveSessionProfile to after gateway response confirmation
- Replace all console.log with logger in group-chat modules
- Add server-side typing/context_status state tracking for room rejoin
- Fix @ mention popup position to follow cursor
- Add @ mention highlighting (blue) in chat message content
- Fix mention regex to match all occurrences after HTML tags
- Enable esbuild minify and treeShaking
- Move @multiavatar/multiavatar to devDependencies
- Add i18n keys for group chat features
- Update tests for new functionality

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore: bump version to 0.4.5 and move @multiavatar to devDependencies

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Zhicheng Han <zhicheng.han@mathematik.uni-goettingen.de>
This commit is contained in:
ekko
2026-04-24 20:41:14 +08:00
committed by GitHub
parent 82965ae6e2
commit ba72264542
47 changed files with 7590 additions and 141 deletions
@@ -6,7 +6,13 @@ import MarkdownIt from 'markdown-it'
import { handleCodeBlockCopyClick, renderHighlightedCodeBlock } from './highlight'
import { downloadFile } from '@/api/hermes/download'
const props = defineProps<{ content: string }>()
const props = withDefaults(defineProps<{
content: string
mentionNames?: string[]
}>(), {
mentionNames: () => [],
})
const { t } = useI18n()
const message = useMessage()
@@ -19,7 +25,15 @@ const md: MarkdownIt = new MarkdownIt({
},
})
const renderedHtml = computed(() => md.render(props.content))
const renderedHtml = computed(() => {
let html = md.render(props.content)
if (props.mentionNames && props.mentionNames.length > 0) {
const escaped = props.mentionNames.map(n => n.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
const re = new RegExp(`(?<=[\\s>]|^)@(${escaped.join('|')})(?=\\s|$)`, 'gi')
html = html.replace(re, '<span class="mention-highlight">@$1</span>')
}
return html
})
function handleMarkdownClick(event: MouseEvent): void {
void handleCodeBlockCopyClick(event)
@@ -0,0 +1,160 @@
<script setup lang="ts">
import { ref, nextTick } from 'vue'
import { useI18n } from 'vue-i18n'
import { NInput, NButton, NSpace, NInputNumber, NCollapse, NCollapseItem } from 'naive-ui'
type InputLikeInstance = {
focus: () => void
}
const { t } = useI18n()
const emit = defineEmits<{
submit: [name: string, inviteCode: string, userName: string, description: string, compression: { triggerTokens: number; maxHistoryTokens: number; tailMessageCount: number }]
cancel: []
}>()
const roomName = ref('')
const inviteCode = ref('')
const userName = ref('')
const description = ref('')
const roomInput = ref<InputLikeInstance | null>(null)
const compression = ref({
triggerTokens: 100000,
maxHistoryTokens: 32000,
tailMessageCount: 20,
})
function generateCode(): string {
const chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789'
let code = ''
for (let i = 0; i < 6; i++) {
code += chars[Math.floor(Math.random() * chars.length)]
}
return code
}
function handleCreate() {
const name = roomName.value.trim()
const code = inviteCode.value.trim() || generateCode()
const user = userName.value.trim()
if (!name || !user) return
emit('submit', name, code, user, description.value.trim(), { ...compression.value })
}
function focusRoomInput() {
nextTick(() => roomInput.value?.focus())
}
</script>
<template>
<div class="create-form">
<div class="form-group">
<label class="form-label">{{ t('groupChat.yourName') }}</label>
<NInput
v-model:value="userName"
:placeholder="t('groupChat.yourNamePlaceholder')"
@keyup.enter="focusRoomInput"
/>
</div>
<div class="form-group">
<label class="form-label">{{ t('groupChat.yourDescription') }}</label>
<NInput
v-model:value="description"
type="textarea"
:rows="2"
:placeholder="t('groupChat.yourDescriptionPlaceholder')"
/>
</div>
<div class="form-group">
<label class="form-label">{{ t('groupChat.roomName') }}</label>
<NInput
ref="roomInput"
v-model:value="roomName"
:placeholder="t('groupChat.roomNamePlaceholder')"
@keyup.enter="handleCreate"
/>
</div>
<div class="form-group">
<label class="form-label">{{ t('groupChat.inviteCode') }}</label>
<div class="code-row">
<NInput
v-model:value="inviteCode"
:placeholder="t('groupChat.autoGenerate')"
/>
<NButton size="small" @click="inviteCode = generateCode()">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<polyline points="23 4 23 10 17 10" /><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10" />
</svg>
</NButton>
</div>
</div>
<NCollapse class="compression-collapse">
<NCollapseItem :title="t('groupChat.compressionSettings')" name="compression">
<div class="compression-fields">
<div class="form-group">
<label class="form-label">{{ t('groupChat.triggerTokens') }}</label>
<NInputNumber v-model:value="compression.triggerTokens" :min="1000" :step="1000" style="width: 100%" />
<p class="form-hint">{{ t('groupChat.triggerTokensDesc') }}</p>
</div>
<div class="form-group">
<label class="form-label">{{ t('groupChat.maxHistoryTokens') }}</label>
<NInputNumber v-model:value="compression.maxHistoryTokens" :min="1000" :step="1000" style="width: 100%" />
<p class="form-hint">{{ t('groupChat.maxHistoryTokensDesc') }}</p>
</div>
<div class="form-group">
<label class="form-label">{{ t('groupChat.tailMessageCount') }}</label>
<NInputNumber v-model:value="compression.tailMessageCount" :min="1" :step="5" style="width: 100%" />
<p class="form-hint">{{ t('groupChat.tailMessageCountDesc') }}</p>
</div>
</div>
</NCollapseItem>
</NCollapse>
<div class="modal-actions">
<NSpace justify="end">
<NButton @click="emit('cancel')">{{ t('common.cancel') }}</NButton>
<NButton type="primary" :disabled="!roomName.trim() || !userName.trim()" @click="handleCreate">{{ t('common.create') }}</NButton>
</NSpace>
</div>
</div>
</template>
<style scoped lang="scss">
@use "@/styles/variables" as *;
.create-form {
.form-group {
margin-bottom: 16px;
}
}
.form-label {
display: block;
font-size: 13px;
font-weight: 500;
color: $text-secondary;
margin-bottom: 6px;
}
.form-hint {
font-size: 11px;
color: $text-muted;
margin: 4px 0 0;
}
.code-row {
display: flex;
gap: 8px;
align-items: center;
}
.compression-collapse {
margin-bottom: 16px;
}
.compression-fields {
padding-top: 8px;
}
</style>
@@ -0,0 +1,321 @@
<script setup lang="ts">
import { ref, computed, nextTick } from 'vue'
import { useI18n } from 'vue-i18n'
import { NButton, NDropdown } from 'naive-ui'
import { useGroupChatStore } from '@/stores/hermes/group-chat'
import type { DropdownOption } from 'naive-ui'
const { t } = useI18n()
const emit = defineEmits<{ send: [content: string] }>()
const store = useGroupChatStore()
const inputText = ref('')
const textareaRef = ref<HTMLTextAreaElement>()
const isComposing = ref(false)
// ─── Mention State ───────────────────────────────────────
const mentionActive = ref(false)
const mentionQuery = ref('')
const mentionStartIndex = ref(-1)
const dropdownX = ref(0)
const dropdownY = ref(0)
const activeIndex = ref(0)
const filteredAgents = computed(() => {
const query = mentionQuery.value.toLowerCase()
return store.agents.filter(a => a.name.toLowerCase().includes(query))
})
const dropdownOptions = computed<DropdownOption[]>(() => {
return filteredAgents.value.map((a, i) => ({
label: `${a.name} (${a.profile})`,
key: a.name,
index: i,
}))
})
const canSend = computed(() => !!inputText.value.trim())
// ─── Mention Logic ───────────────────────────────────────
function updateMentionState() {
const el = textareaRef.value
if (!el) { mentionActive.value = false; return }
const text = inputText.value
const cursorPos = el.selectionStart
// Find the last @ before the cursor
let atPos = -1
for (let i = cursorPos - 1; i >= 0; i--) {
if (text[i] === '@') { atPos = i; break }
if (text[i] === ' ' || text[i] === '\n') break
}
if (atPos === -1) {
mentionActive.value = false
return
}
// Make sure the @ is not part of a word (preceded by space or start of line)
if (atPos > 0 && text[atPos - 1] !== ' ' && text[atPos - 1] !== '\n') {
mentionActive.value = false
return
}
const query = text.slice(atPos + 1, cursorPos)
if (query.includes(' ')) {
mentionActive.value = false
return
}
mentionQuery.value = query
mentionStartIndex.value = atPos
activeIndex.value = 0
// Calculate dropdown position using mirror span
const mirror = document.createElement('span')
const style = getComputedStyle(el)
const props = ['fontFamily', 'fontSize', 'fontWeight', 'letterSpacing', 'textTransform', 'wordSpacing', 'textIndent', 'border', 'padding', 'boxSizing', 'lineHeight']
props.forEach(p => { (mirror.style as any)[p] = style[p as any] })
mirror.style.position = 'absolute'
mirror.style.visibility = 'hidden'
mirror.style.whiteSpace = 'nowrap'
mirror.textContent = text.slice(0, atPos + 1)
const rect = el.getBoundingClientRect()
document.body.appendChild(mirror)
const mirrorRect = mirror.getBoundingClientRect()
document.body.removeChild(mirror)
dropdownX.value = rect.left + mirrorRect.width - el.scrollLeft
// Estimate Y based on newlines before @ and line height
const linesBeforeAt = text.slice(0, atPos + 1).split('\n').length - 1
const lineHeight = parseFloat(style.lineHeight) || parseFloat(style.fontSize) * 1.2
dropdownY.value = rect.top + linesBeforeAt * lineHeight - el.scrollTop + lineHeight + 4
mentionActive.value = filteredAgents.value.length > 0
}
function selectMention(name: string) {
const el = textareaRef.value
if (!el || mentionStartIndex.value === -1) return
const before = inputText.value.slice(0, mentionStartIndex.value)
const after = inputText.value.slice(el.selectionStart)
inputText.value = `${before}@${name} ${after}`
mentionActive.value = false
nextTick(() => {
if (el) {
const newPos = before.length + name.length + 2
el.setSelectionRange(newPos, newPos)
el.focus()
el.style.height = 'auto'
el.style.height = Math.min(el.scrollHeight, 100) + 'px'
}
})
}
// ─── Event Handlers ──────────────────────────────────────
function handleKeydown(e: KeyboardEvent) {
// Mention navigation
if (mentionActive.value && filteredAgents.value.length > 0) {
if (e.key === 'ArrowDown') {
e.preventDefault()
activeIndex.value = (activeIndex.value + 1) % filteredAgents.value.length
return
}
if (e.key === 'ArrowUp') {
e.preventDefault()
activeIndex.value = (activeIndex.value - 1 + filteredAgents.value.length) % filteredAgents.value.length
return
}
if (e.key === 'Enter' || e.key === 'Tab') {
e.preventDefault()
selectMention(filteredAgents.value[activeIndex.value].name)
return
}
if (e.key === 'Escape') {
e.preventDefault()
mentionActive.value = false
return
}
}
if (e.key !== 'Enter' || e.shiftKey) return
if (isComposing.value || e.isComposing || e.keyCode === 229) return
e.preventDefault()
handleSend()
}
function handleSend() {
const content = inputText.value.trim()
if (!content) return
emit('send', content)
inputText.value = ''
mentionActive.value = false
nextTick(() => {
if (textareaRef.value) {
textareaRef.value.style.height = 'auto'
}
})
}
function handleInput(e: Event) {
store.emitTyping()
const el = e.target as HTMLTextAreaElement
el.style.height = 'auto'
el.style.height = Math.min(el.scrollHeight, 100) + 'px'
if (!isComposing.value) {
updateMentionState()
}
}
function handleDropdownSelect(key: string) {
selectMention(key)
}
function handleDropdownClickOutside() {
mentionActive.value = false
}
function handleCompositionStart() {
isComposing.value = true
}
function handleCompositionEnd() {
requestAnimationFrame(() => {
isComposing.value = false
updateMentionState()
})
}
</script>
<template>
<div class="chat-input-area">
<div class="input-wrapper">
<textarea
ref="textareaRef"
v-model="inputText"
class="input-textarea"
:placeholder="t('groupChat.inputPlaceholder')"
rows="1"
@keydown="handleKeydown"
@compositionstart="handleCompositionStart"
@compositionend="handleCompositionEnd"
@input="handleInput"
/>
<div class="input-actions">
<NButton
size="small"
type="primary"
:disabled="!canSend"
@click="handleSend"
>
<template #icon>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></svg>
</template>
{{ t('chat.send') }}
</NButton>
</div>
</div>
<NDropdown
placement="top-start"
trigger="manual"
:x="dropdownX"
:y="dropdownY"
:options="dropdownOptions"
:show="mentionActive"
:render-icon="() => null"
@select="handleDropdownSelect"
@clickoutside="handleDropdownClickOutside"
/>
</div>
</template>
<style scoped lang="scss">
@use "@/styles/variables" as *;
.chat-input-area {
padding: 20px 20px 16px;
border-top: 1px solid $border-color;
flex-shrink: 0;
}
.typing-dots {
display: inline-flex;
align-items: center;
gap: 2px;
span {
display: block;
width: 4px;
height: 4px;
border-radius: 50%;
background-color: $text-muted;
animation: typing-bounce 1.2s infinite;
&:nth-child(2) { animation-delay: 0.2s; }
&:nth-child(3) { animation-delay: 0.4s; }
}
}
@keyframes typing-bounce {
0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
30% { transform: translateY(-3px); opacity: 1; }
}
.input-wrapper {
display: flex;
align-items: center;
gap: 10px;
background-color: $bg-input;
border: 1px solid $border-color;
border-radius: $radius-md;
padding: 10px 12px;
transition: border-color $transition-fast, background-color $transition-fast;
&:focus-within {
border-color: $accent-primary;
}
.dark & {
background-color: #333333;
}
}
.input-textarea {
flex: 1;
background: none;
border: none;
outline: none;
color: $text-primary;
font-family: $font-ui;
font-size: 14px;
line-height: 1.5;
resize: none;
max-height: 100px;
min-height: 20px;
overflow-y: auto;
&::placeholder {
color: $text-muted;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
.input-actions {
display: flex;
gap: 6px;
flex-shrink: 0;
align-items: center;
}
</style>
@@ -0,0 +1,896 @@
<script setup lang="ts">
import { ref, computed, nextTick, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { useMessage, NInput, NButton, NSpace, NSelect, NPopover, NPopconfirm, NInputNumber } from 'naive-ui'
import multiavatar from '@multiavatar/multiavatar'
import { useGroupChatStore } from '@/stores/hermes/group-chat'
import { useProfilesStore } from '@/stores/hermes/profiles'
import { updateRoomConfig, forceCompress } from '@/api/hermes/group-chat'
import GroupMessageList from './GroupMessageList.vue'
import GroupChatInput from './GroupChatInput.vue'
const { t } = useI18n()
const message = useMessage()
const store = useGroupChatStore()
const profilesStore = useProfilesStore()
const showSidebar = ref(true)
const showCreateModal = ref(false)
const showAddAgentModal = ref(false)
const showCompressionModal = ref(false)
const compressionConfig = ref({ triggerTokens: 100000, maxHistoryTokens: 32000, tailMessageCount: 20 })
const isCompressing = ref(false)
const selectedProfile = ref<string | null>(null)
const agentName = ref('')
const agentDescription = ref('')
const profileOptions = computed(() =>
profilesStore.profiles.map(p => ({ label: p.name, value: p.name }))
)
const avatarCache = new Map<string, string>()
function agentAvatarUrl(name: string): string {
if (avatarCache.has(name)) return avatarCache.get(name)!
const uri = multiavatar(name)
avatarCache.set(name, uri)
return uri
}
const hasRoom = computed(() => !!store.currentRoomId)
function formatTokens(tokens: number): string {
if (tokens >= 1000) return `${(tokens / 1000).toFixed(1)}k tokens`
return `${tokens} tokens`
}
function toggleSidebar() {
showSidebar.value = !showSidebar.value
}
async function handleCreateRoom(name: string, inviteCode: string, userName: string, description: string, compression: { triggerTokens: number; maxHistoryTokens: number; tailMessageCount: number }) {
try {
store.setUserInfo(userName, description)
const res = await store.createNewRoom(name, inviteCode, undefined, compression)
showCreateModal.value = false
message.success(t('groupChat.roomCreated'))
await store.joinRoom(res.room.id)
} catch {
message.error(t('common.saveFailed'))
}
}
async function handleDeleteRoom(roomId: string) {
try {
await store.deleteRoom(roomId)
message.success(t('groupChat.roomDeleted'))
} catch {
message.error(t('common.saveFailed'))
}
}
async function handleSelectRoom(roomId: string) {
try {
await store.joinRoom(roomId)
} catch {
message.error(t('groupChat.joinFailed'))
}
}
async function handleSendMessage(content: string) {
try {
await store.sendMessage(content)
} catch (err: any) {
message.error(err.message)
}
}
async function handleAddAgent() {
await profilesStore.fetchProfiles()
showAddAgentModal.value = true
}
async function confirmAddAgent() {
if (!selectedProfile.value || !store.currentRoomId) return
try {
await store.addAgentToRoom(store.currentRoomId, {
profile: selectedProfile.value,
name: agentName.value.trim() || undefined,
description: agentDescription.value.trim() || undefined,
})
showAddAgentModal.value = false
selectedProfile.value = null
agentName.value = ''
agentDescription.value = ''
message.success(t('groupChat.agentAdded'))
} catch (err: any) {
if (err.message?.includes('already')) {
message.warning(t('groupChat.agentAlreadyInRoom'))
} else {
message.error(t('common.saveFailed'))
}
}
}
function handleOpenCompressionConfig() {
const room = store.rooms.find(r => r.id === store.currentRoomId)
if (room) {
compressionConfig.value = {
triggerTokens: room.triggerTokens ?? 100000,
maxHistoryTokens: room.maxHistoryTokens ?? 32000,
tailMessageCount: room.tailMessageCount ?? 20,
}
}
showCompressionModal.value = true
}
async function handleSaveCompressionConfig() {
if (!store.currentRoomId) return
try {
const res = await updateRoomConfig(store.currentRoomId, { ...compressionConfig.value })
const idx = store.rooms.findIndex(r => r.id === store.currentRoomId)
if (idx >= 0 && res.room) store.rooms[idx] = res.room
showCompressionModal.value = false
message.success(t('groupChat.compressionSaved'))
} catch {
message.error(t('common.saveFailed'))
}
}
async function handleForceCompress() {
if (!store.currentRoomId || isCompressing.value) return
if (store.contextStatuses.size > 0) {
message.warning(t('groupChat.compressingInProgress'))
return
}
isCompressing.value = true
try {
await forceCompress(store.currentRoomId)
message.success(t('groupChat.compressionSaved'))
} catch {
message.error(t('common.saveFailed'))
} finally {
isCompressing.value = false
}
}
async function handleRemoveAgent(agentId: string) {
if (!store.currentRoomId) return
try {
await store.removeAgentFromRoom(store.currentRoomId, agentId)
} catch {
message.error(t('common.deleteFailed'))
}
}
// Auto-scroll on new messages
const messageListRef = ref()
watch(() => store.sortedMessages.length, async () => {
await nextTick()
messageListRef.value?.scrollToBottom()
})
</script>
<template>
<div class="group-chat-panel">
<!-- Room sidebar -->
<div v-if="showSidebar" class="room-sidebar">
<div class="sidebar-header">
<span class="sidebar-title">{{ t('groupChat.title') }}</span>
<div class="sidebar-actions">
<button class="icon-btn" :title="t('groupChat.createRoom')" @click="showCreateModal = true">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<line x1="12" y1="5" x2="12" y2="19" /><line x1="5" y1="12" x2="19" y2="12" />
</svg>
</button>
</div>
</div>
<div class="room-list">
<div
v-for="room in store.rooms"
:key="room.id"
class="room-item"
:class="{ active: store.currentRoomId === room.id }"
@click="handleSelectRoom(room.id)"
>
<svg class="room-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
</svg>
<div class="room-info">
<span class="room-name">{{ room.name || room.id }}</span>
<span v-if="room.inviteCode" class="room-code">{{ room.inviteCode }}</span>
<span class="room-tokens">{{ formatTokens(room.totalTokens || 0) }}</span>
</div>
<NPopconfirm @positive-click="handleDeleteRoom(room.id)">
<template #trigger>
<button class="room-delete-btn" @click.stop>
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
</button>
</template>
{{ t('groupChat.deleteRoomConfirm') }}
</NPopconfirm>
</div>
<div v-if="store.rooms.length === 0" class="empty-rooms">
{{ t('groupChat.noRooms') }}
</div>
</div>
</div>
<!-- Main chat area -->
<div class="chat-main">
<div class="chat-header">
<button class="icon-btn" @click="toggleSidebar">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="18" height="18" rx="2" ry="2" /><line x1="9" y1="3" x2="9" y2="21" />
</svg>
</button>
<span class="room-title-text">{{ store.roomName || (store.currentRoomId || t('groupChat.title')) }}</span>
<div class="header-info">
<!-- Stacked avatars (user + agents) -->
<NPopover v-if="store.agents.length" trigger="click" placement="bottom-end" :width="220">
<template #trigger>
<div class="avatar-stack-inner">
<!-- User avatar first -->
<span class="avatar-stack-item" :style="{ zIndex: store.agents.length + 1 }">
<span class="agent-avatar" v-html="agentAvatarUrl(store.userName || store.userId)" />
</span>
<span
v-for="(agent, index) in store.agents.slice(-4)"
:key="agent.id"
class="avatar-stack-item"
:style="{ zIndex: store.agents.length - index }"
>
<span class="agent-avatar" v-html="agentAvatarUrl(agent.name)" />
</span>
<span v-if="store.agents.length > 4" class="avatar-stack-more">+{{ store.agents.length - 4 }}</span>
</div>
</template>
<div class="agent-popover">
<div class="agent-popover-item" style="margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--n-border-color, #efeff5);">
<span class="agent-avatar" v-html="agentAvatarUrl(store.userName || store.userId)" />
<div class="agent-popover-info">
<span class="agent-popover-name">{{ store.userName || 'You' }}</span>
<span class="agent-popover-profile">{{ t('groupChat.you') }}</span>
</div>
</div>
<div class="agent-popover-title">{{ t('groupChat.agents') }} ({{ store.agents.length }})</div>
<div v-for="agent in store.agents" :key="agent.id" class="agent-popover-item">
<span class="agent-avatar" v-html="agentAvatarUrl(agent.name)" />
<div class="agent-popover-info">
<span class="agent-popover-name">{{ agent.name }}</span>
<span class="agent-popover-profile">{{ agent.profile }}</span>
</div>
<button class="agent-popover-remove" @click="handleRemoveAgent(agent.id)">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
</button>
</div>
</div>
</NPopover>
<!-- Only user avatar, no agents -->
<div v-else-if="store.userName" class="avatar-stack-inner">
<span class="avatar-stack-item">
<span class="agent-avatar" v-html="agentAvatarUrl(store.userName || store.userId)" />
</span>
</div>
<button class="icon-btn" :title="t('groupChat.addAgent')" @click="handleAddAgent">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
</button>
<button class="icon-btn" :title="t('groupChat.compressionConfig')" @click="handleOpenCompressionConfig">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 4.6a1.65 1.65 0 0 0 1.51 1V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1.51 1z"/></svg>
</button>
<span v-if="store.members.length" class="member-count">
{{ store.members.length }} {{ t('groupChat.members') }}
</span>
<span class="connection-dot" :class="{ connected: store.connected, disconnected: !store.connected }"></span>
</div>
</div>
<template v-if="hasRoom">
<GroupMessageList ref="messageListRef" />
<div v-if="store.contextStatuses.size > 0 || (store.typingText && store.contextStatuses.size === 0)" class="status-bar">
<div v-if="store.contextStatuses.size > 0" class="context-status-list">
<div v-for="[name, status] in store.contextStatuses" :key="name" class="context-status">
<span class="typing-dots">
<span /><span /><span />
</span>
<span v-if="status.status === 'compressing'">
@{{ status.agentName }} {{ t('groupChat.agentCompressing') }}
</span>
<span v-else>
@{{ status.agentName }} {{ t('groupChat.agentReplying') }}
</span>
</div>
</div>
<div v-else-if="store.typingText" class="typing-indicator">
<span class="typing-dots">
<span /><span /><span />
</span>
{{ store.typingText }}
</div>
</div>
<GroupChatInput @send="handleSendMessage" />
</template>
<div v-else class="no-room">
<div class="no-room-icon">
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
</svg>
</div>
<p>{{ t('groupChat.selectOrCreate') }}</p>
</div>
</div>
<!-- Create room modal -->
<Teleport to="body">
<div v-if="showCreateModal" class="modal-backdrop" @click.self="showCreateModal = false">
<div class="modal">
<h3>{{ t('groupChat.createRoom') }}</h3>
<CreateRoomForm @submit="handleCreateRoom" @cancel="showCreateModal = false" />
</div>
</div>
</Teleport>
<Teleport to="body">
<div v-if="showAddAgentModal" class="modal-backdrop" @click.self="showAddAgentModal = false">
<div class="modal">
<h3>{{ t('groupChat.addAgent') }}</h3>
<div class="form-group">
<NSelect
v-model:value="selectedProfile"
:options="profileOptions"
:placeholder="t('groupChat.selectProfile')"
filterable
/>
</div>
<div class="form-group">
<label class="form-label">{{ t('groupChat.agentName') }}</label>
<NInput
v-model:value="agentName"
:placeholder="t('groupChat.agentNamePlaceholder')"
/>
</div>
<div class="form-group">
<label class="form-label">{{ t('groupChat.agentDesc') }}</label>
<NInput
v-model:value="agentDescription"
type="textarea"
:rows="2"
:placeholder="t('groupChat.agentDescPlaceholder')"
/>
</div>
<div class="modal-actions">
<NSpace justify="end">
<NButton @click="showAddAgentModal = false">{{ t('common.cancel') }}</NButton>
<NButton type="primary" :disabled="!selectedProfile" @click="confirmAddAgent">{{ t('common.add') }}</NButton>
</NSpace>
</div>
</div>
</div>
<div v-if="showCompressionModal" class="modal-backdrop" @click.self="showCompressionModal = false">
<div class="modal">
<h3>{{ t('groupChat.compressionConfig') }}</h3>
<div class="form-group">
<label class="form-label">{{ t('groupChat.triggerTokens') }}</label>
<NInputNumber v-model:value="compressionConfig.triggerTokens" :min="1000" :step="10000" style="width: 100%" />
<p class="form-hint">{{ t('groupChat.triggerTokensDesc') }}</p>
</div>
<div class="form-group">
<label class="form-label">{{ t('groupChat.maxHistoryTokens') }}</label>
<NInputNumber v-model:value="compressionConfig.maxHistoryTokens" :min="1000" :step="1000" style="width: 100%" />
<p class="form-hint">{{ t('groupChat.maxHistoryTokensDesc') }}</p>
</div>
<div class="form-group">
<label class="form-label">{{ t('groupChat.tailMessageCount') }}</label>
<NInputNumber v-model:value="compressionConfig.tailMessageCount" :min="1" :step="5" style="width: 100%" />
<p class="form-hint">{{ t('groupChat.tailMessageCountDesc') }}</p>
</div>
<div style="margin-top: 8px">
<NButton
block
:disabled="isCompressing || store.contextStatuses.size > 0"
:loading="isCompressing"
@click="handleForceCompress"
>
{{ isCompressing ? t('groupChat.compressingInProgress') : t('groupChat.compressNow') }}
</NButton>
</div>
<div class="modal-actions">
<NSpace justify="end">
<NButton @click="showCompressionModal = false">{{ t('common.cancel') }}</NButton>
<NButton type="primary" @click="handleSaveCompressionConfig">{{ t('common.save') }}</NButton>
</NSpace>
</div>
</div>
</div>
</Teleport>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import CreateRoomForm from './CreateRoomForm.vue'
export default defineComponent({ components: { CreateRoomForm } })
</script>
<style scoped lang="scss">
@use "@/styles/variables" as *;
.group-chat-panel {
display: flex;
height: 100%;
overflow: hidden;
}
// ─── Status Bar ──────────────────────────────────────────
.status-bar {
flex-shrink: 0;
padding: 6px 20px;
background: #ffffff;
overflow: hidden;
}
.context-status-list {
display: flex;
gap: 8px;
overflow-x: auto;
flex-wrap: nowrap;
&::-webkit-scrollbar {
height: 0;
}
}
.context-status {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 4px 10px;
font-size: 12px;
color: $text-secondary;
background-color: $bg-card-hover;
border-radius: $radius-sm;
.dark & {
background-color: rgba(255, 255, 255, 0.06);
}
}
.typing-indicator {
display: flex;
align-items: center;
gap: 6px;
font-size: 12px;
color: $text-muted;
}
.typing-dots {
display: inline-flex;
align-items: center;
gap: 2px;
span {
display: block;
width: 4px;
height: 4px;
border-radius: 50%;
background-color: $text-muted;
animation: typing-bounce 1.2s infinite;
&:nth-child(2) { animation-delay: 0.2s; }
&:nth-child(3) { animation-delay: 0.4s; }
}
}
@keyframes typing-bounce {
0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
30% { transform: translateY(-3px); opacity: 1; }
}
// ─── Room Sidebar ────────────────────────────────────────
.room-sidebar {
width: 220px;
flex-shrink: 0;
background-color: $bg-sidebar;
border-right: 1px solid $border-color;
display: flex;
flex-direction: column;
}
.sidebar-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px;
flex-shrink: 0;
.sidebar-title {
font-size: 15px;
font-weight: 600;
color: $text-primary;
}
.sidebar-actions {
display: flex;
gap: 4px;
}
}
.room-list {
flex: 1;
overflow-y: auto;
padding: 8px;
}
.room-item {
display: flex;
align-items: center;
gap: 10px;
padding: 10px;
border-radius: $radius-sm;
cursor: pointer;
transition: background-color $transition-fast;
&:hover {
background-color: rgba(var(--accent-primary-rgb), 0.06);
}
&.active {
background-color: rgba(var(--accent-primary-rgb), 0.12);
}
.room-icon {
color: $text-muted;
flex-shrink: 0;
}
.room-info {
display: flex;
flex-direction: column;
min-width: 0;
flex: 1;
}
.room-name {
font-size: 13px;
color: $text-primary;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.room-code {
font-size: 11px;
color: $text-muted;
font-family: $font-code;
}
.room-tokens {
font-size: 11px;
color: $text-muted;
}
.room-delete-btn {
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
border: none;
background: transparent;
color: $text-muted;
cursor: pointer;
border-radius: $radius-sm;
opacity: 0;
transition: opacity $transition-fast, color $transition-fast, background-color $transition-fast;
&:hover {
color: $error;
background-color: rgba(var(--error-rgb), 0.1);
}
}
&:hover .room-delete-btn {
opacity: 1;
}
}
.empty-rooms {
padding: 20px 12px;
text-align: center;
font-size: 13px;
color: $text-muted;
}
// ─── Chat Main ──────────────────────────────────────────
.chat-main {
flex: 1;
display: flex;
flex-direction: column;
min-width: 0;
}
.chat-header {
display: flex;
align-items: center;
gap: 12px;
padding: 21px 20px;
border-bottom: 1px solid $border-color;
.room-title-text {
font-size: 16px;
font-weight: 600;
color: $text-primary;
flex: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.header-info {
display: flex;
align-items: center;
gap: 8px;
flex-shrink: 0;
}
.member-count {
font-size: 12px;
color: $text-muted;
}
}
// ─── Header Avatar Stack ──────────────────────────────
.avatar-stack {
cursor: pointer;
}
.avatar-stack-inner {
display: flex;
align-items: center;
}
.avatar-stack-item {
width: 28px;
height: 28px;
border-radius: 50%;
border: 2px solid $bg-card;
margin-left: -12px;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
background-color: $bg-secondary;
transition: transform $transition-fast;
&:first-child {
margin-left: 0;
}
&:hover {
transform: translateY(-2px);
z-index: 100 !important;
}
}
.avatar-stack-more {
width: 28px;
height: 28px;
border-radius: 50%;
border: 2px solid $bg-card;
margin-left: -12px;
display: flex;
align-items: center;
justify-content: center;
background-color: $bg-secondary;
font-size: 11px;
font-weight: 600;
color: $text-secondary;
}
.agent-avatar {
width: 28px;
height: 28px;
display: flex;
align-items: center;
justify-content: center;
:deep(svg) {
width: 100%;
height: 100%;
}
}
// ─── Agent Popover ─────────────────────────────────────
.agent-popover {
max-height: 300px;
overflow-y: auto;
}
.agent-popover-title {
font-size: 12px;
font-weight: 600;
color: $text-muted;
padding: 0 0 8px;
border-bottom: 1px solid $border-color;
margin-bottom: 8px;
}
.agent-popover-item {
display: flex;
align-items: center;
gap: 8px;
padding: 6px 4px;
border-radius: $radius-sm;
transition: background-color $transition-fast;
&:hover {
background-color: rgba(var(--accent-primary-rgb), 0.06);
}
.agent-popover-info {
flex: 1;
min-width: 0;
}
.agent-popover-name {
display: block;
font-size: 13px;
color: $text-primary;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.agent-popover-profile {
display: block;
font-size: 11px;
color: $text-muted;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.agent-popover-remove {
display: flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
border: none;
background: none;
border-radius: $radius-sm;
color: $text-muted;
cursor: pointer;
flex-shrink: 0;
transition: all $transition-fast;
&:hover {
color: $error;
background-color: rgba(200, 50, 50, 0.08);
}
}
}
// ─── No Room State ────────────────────────────────────────
.no-room {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 16px;
color: $text-muted;
.no-room-icon {
opacity: 0.3;
}
p {
font-size: 14px;
}
}
// ─── Shared ──────────────────────────────────────────────
.icon-btn {
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border: none;
background: none;
border-radius: $radius-sm;
color: $text-secondary;
cursor: pointer;
transition: all $transition-fast;
&:hover {
background-color: rgba(var(--accent-primary-rgb), 0.08);
color: $text-primary;
}
}
.modal-backdrop {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.4);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
}
.modal {
background: $bg-card;
border-radius: $radius-lg;
padding: 24px;
width: 400px;
max-width: 90vw;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
h3 {
font-size: 16px;
font-weight: 600;
color: $text-primary;
margin: 0 0 20px;
}
}
.form-group {
margin-bottom: 16px;
}
.modal-actions {
margin-top: 12px;
display: flex;
justify-content: flex-end;
gap: 8px;
}
.form-hint {
font-size: 11px;
color: $text-muted;
margin: 4px 0 0;
}
// ─── Connection Dot ──────────────────────────────────────
.connection-dot {
width: 8px;
height: 8px;
border-radius: 50%;
flex-shrink: 0;
&.connected {
background-color: $success;
box-shadow: 0 0 6px rgba(var(--success-rgb), 0.5);
}
&.disconnected {
background-color: $error;
}
}
// ─── Mobile ──────────────────────────────────────────────
@media (max-width: $breakpoint-mobile) {
.room-sidebar {
position: absolute;
left: 0;
top: 0;
bottom: 0;
z-index: 100;
box-shadow: 4px 0 16px rgba(0, 0, 0, 0.1);
}
}
</style>
@@ -0,0 +1,149 @@
<script setup lang="ts">
import { computed } from 'vue'
import multiavatar from '@multiavatar/multiavatar'
import MarkdownRenderer from '../chat/MarkdownRenderer.vue'
import type { ChatMessage, RoomAgent } from '@/api/hermes/group-chat'
const props = defineProps<{
message: ChatMessage
agents: RoomAgent[]
currentUserId?: string
}>()
const isAgent = computed(() => {
return props.agents.some(a => a.agentId === props.message.senderId)
})
const isSelf = computed(() => {
return !!props.currentUserId && props.message.senderId === props.currentUserId
})
const agentInfo = computed(() => {
return props.agents.find(a => a.agentId === props.message.senderId)
})
const timeStr = computed(() => {
const d = new Date(props.message.timestamp)
return d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
})
const avatarSvg = computed(() => {
return multiavatar(props.message.senderName || props.message.senderId)
})
const mentionNames = computed(() => props.agents.map(a => a.name).filter(Boolean))
</script>
<template>
<div class="group-message" :class="{ agent: isAgent, self: isSelf }">
<!-- Avatar -->
<div class="avatar">
<span v-html="avatarSvg" />
</div>
<div class="msg-body">
<div class="msg-header">
<span class="sender-name">{{ message.senderName }}</span>
<span v-if="isAgent && agentInfo?.description" class="agent-desc">{{ agentInfo.description }}</span>
<span class="msg-time">{{ timeStr }}</span>
</div>
<div class="msg-content" :class="{ 'agent-content': isAgent }">
<MarkdownRenderer :content="message.content" :mention-names="mentionNames" />
</div>
</div>
</div>
</template>
<style scoped lang="scss">
@use "@/styles/variables" as *;
.group-message {
display: flex;
gap: 10px;
padding: 2px 0;
&.agent,
&.self {
flex-direction: row-reverse;
.msg-body {
align-items: flex-end;
}
.msg-header {
flex-direction: row-reverse;
}
}
&.agent .msg-content.agent-content {
background-color: rgba(var(--accent-primary-rgb), 0.06);
}
&.self .msg-content {
background-color: rgba(var(--accent-primary-rgb), 0.1);
}
}
.avatar {
width: 36px;
height: 36px;
flex-shrink: 0;
margin-top: 2px;
overflow: hidden;
border-radius: 8px;
:deep(svg) {
width: 36px;
height: 36px;
}
}
.msg-body {
display: flex;
flex-direction: column;
min-width: 0;
max-width: 70%;
}
.msg-header {
display: flex;
align-items: center;
gap: 8px;
padding-bottom: 2px;
.sender-name {
font-size: 13px;
font-weight: 600;
color: $text-primary;
}
.agent-desc {
font-size: 11px;
color: $text-muted;
font-style: italic;
}
.msg-time {
font-size: 11px;
color: $text-muted;
margin-left: auto;
}
}
.msg-content {
padding: 10px 14px;
font-size: 14px;
line-height: 1.65;
color: $text-primary;
border-radius: 10px;
background-color: $msg-user-bg;
word-break: break-word;
overflow-wrap: break-word;
:deep(.mention-highlight) {
color: #409eff;
font-weight: 600;
cursor: default;
}
}
</style>
@@ -0,0 +1,79 @@
<script setup lang="ts">
import { ref, watch, nextTick } from 'vue'
import { useGroupChatStore } from '@/stores/hermes/group-chat'
import GroupMessageItem from './GroupMessageItem.vue'
const store = useGroupChatStore()
const listRef = ref<HTMLDivElement>()
const isNearBottom = ref(true)
function checkNearBottom(): void {
if (!listRef.value) return
const { scrollTop, scrollHeight, clientHeight } = listRef.value
isNearBottom.value = scrollHeight - scrollTop - clientHeight < 200
}
function scrollToBottom(): void {
if (!listRef.value) return
listRef.value.scrollTop = listRef.value.scrollHeight
}
function handleScroll(): void {
checkNearBottom()
}
watch(() => store.messages.length, async () => {
await nextTick()
if (isNearBottom.value) {
scrollToBottom()
}
})
defineExpose({ scrollToBottom })
</script>
<template>
<div ref="listRef" class="message-list" @scroll="handleScroll">
<div v-if="store.sortedMessages.length === 0" class="empty-state">
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
</svg>
<p>No messages yet</p>
</div>
<GroupMessageItem
v-for="msg in store.sortedMessages"
:key="msg.id"
:message="msg"
:agents="store.agents"
:current-user-id="store.userId"
/>
</div>
</template>
<style scoped lang="scss">
@use "@/styles/variables" as *;
.message-list {
flex: 1;
overflow-y: auto;
padding: 16px 20px;
display: flex;
flex-direction: column;
gap: 12px;
}
.empty-state {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 12px;
color: $text-muted;
opacity: 0.4;
p {
font-size: 14px;
}
}
</style>
@@ -65,21 +65,39 @@ function openChangelog() {
</div>
<nav class="sidebar-nav">
<!-- Chat (standalone) -->
<button class="nav-item" :class="{ active: selectedKey === 'hermes.chat' }" @click="handleNav('hermes.chat')">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
</svg>
<span>{{ t("sidebar.chat") }}</span>
</button>
<button class="nav-item" @click="openSessionSearch">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<circle cx="11" cy="11" r="7" />
<path d="m20 20-3.5-3.5" />
</svg>
<span>{{ t("sidebar.search") }}</span>
</button>
<!-- Conversation -->
<div class="nav-group">
<div class="nav-group-label" @click="toggleGroup('conversation')">
<span>{{ t("sidebar.groupConversation") }}</span>
<svg class="nav-group-arrow" :class="{ collapsed: isGroupCollapsed('conversation') }" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="6 9 12 15 18 9" />
</svg>
</div>
<div v-show="!isGroupCollapsed('conversation')">
<button class="nav-item" :class="{ active: selectedKey === 'hermes.chat' }" @click="handleNav('hermes.chat')">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
</svg>
<span>{{ t("sidebar.chat") }}</span>
</button>
<button class="nav-item" :class="{ active: selectedKey === 'hermes.groupChat' }" @click="handleNav('hermes.groupChat')">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" />
<circle cx="9" cy="7" r="4" />
<path d="M23 21v-2a4 4 0 0 0-3-3.87" />
<path d="M16 3.13a4 4 0 0 1 0 7.75" />
</svg>
<span>{{ t("sidebar.groupChat") }}<span class="beta-tag">(beta)</span></span>
</button>
<button class="nav-item" @click="openSessionSearch">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<circle cx="11" cy="11" r="7" />
<path d="m20 20-3.5-3.5" />
</svg>
<span>{{ t("sidebar.search") }}</span>
</button>
</div>
</div>
<!-- Agent -->
<div class="nav-group">
@@ -430,6 +448,12 @@ function openChangelog() {
background-color: rgba(var(--accent-primary-rgb), 0.12);
color: $accent-primary;
}
.beta-tag {
font-size: 10px;
color: $text-muted;
margin-left: 2px;
}
}
.sidebar-footer {