GroupsView.vue 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  1. <script setup lang="ts">
  2. import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
  3. import { useRoute, useRouter } from 'vue-router'
  4. import { SUPPORTED_GROUP_PROTOCOL_VERSION_LABEL } from '@shared/types'
  5. import type { GroupAgent, GroupRoomSummary, GroupTopicSummary, ModelOption } from '@shared/types'
  6. import AppIcon from '@/components/common/AppIcon.vue'
  7. import AgentAvatar from '@/components/common/AgentAvatar.vue'
  8. import YaoYaoSidebarIcon from '@/components/common/YaoYaoSidebarIcon.vue'
  9. import EmptyState from '@/components/common/EmptyState.vue'
  10. import ComposerShell from '@/components/composer/ComposerShell.vue'
  11. import type { ComposerOption, ComposerReference, ComposerSubmit } from '@/components/composer/types'
  12. import CreateGroupDialog from '@/components/groups/CreateGroupDialog.vue'
  13. import GroupManager from '@/components/groups/GroupManager.vue'
  14. import type { GroupProfileOption } from '@/components/groups/types'
  15. import PreviewModal from '@/components/library/PreviewModal.vue'
  16. import ImagePreviewLightbox from '@/components/library/ImagePreviewLightbox.vue'
  17. import type { PreviewMedia } from '@/components/library/ImagePreviewLightbox.vue'
  18. import type { UiLibraryItem } from '@/components/library/types'
  19. import { mediaItemsFromMessages, mediaUrlIdentity, previewItemFromUrl } from '@/components/library/mediaSequence'
  20. import MessageTimeline from '@/components/messages/MessageTimeline.vue'
  21. import type { UiMessage } from '@/components/messages/types'
  22. import ResourceSidebar from '@/components/app/ResourceSidebar.vue'
  23. import FloatingResourceSearch from '@/components/app/FloatingResourceSearch.vue'
  24. import type { SidebarItem } from '@/components/app/types'
  25. import WorkspaceView from '@/components/workspace/WorkspaceView.vue'
  26. import { loadComposerFile } from '@/components/workspace/pendingComposer'
  27. import { readAgentShowThinking, writeAgentShowThinking } from '@/utils/sessionPreferences'
  28. import { agentToUi, groupInteraction, groupMessageToUi, roomSidebarItem, roomToUi } from '@/components/workspace/viewModels'
  29. import { getModels } from '@/api/profiles'
  30. import { useAuthStore } from '@/stores/auth'
  31. import { useGroupsStore } from '@/stores/groups'
  32. const auth = useAuthStore()
  33. const groups = useGroupsStore()
  34. const route = useRoute()
  35. const router = useRouter()
  36. const createOpen = ref(false)
  37. const managerOpen = ref(false)
  38. const showThinking = ref(true)
  39. const quoted = ref<UiMessage | null>(null)
  40. const preview = ref<UiLibraryItem | null>(null)
  41. const mediaPreviewIndex = ref<number | null>(null)
  42. const composer = ref<InstanceType<typeof ComposerShell> | null>(null)
  43. const modelOptionsByProfile = ref<Record<string, ModelOption[]>>({})
  44. const modelOptionsLoading = ref<Record<string, boolean>>({})
  45. const modelOptionsError = ref<Record<string, string>>({})
  46. const agentUpdateBusy = ref<Record<string, boolean>>({})
  47. const agentUpdateError = ref<Record<string, string>>({})
  48. const managerError = ref('')
  49. const createError = ref('')
  50. const creatingRoom = ref(false)
  51. const roomActionMenu = ref<{ roomId: string; topicId?: string; x: number; y: number } | null>(null)
  52. const topicActionRenaming = ref(false)
  53. const topicActionRenameValue = ref('')
  54. const topicListRoomId = ref<string | null>(null)
  55. const archivedOverlayOpen = ref(false)
  56. const archivedRoomList = ref<GroupRoomSummary[]>([])
  57. const archivedTopicList = ref<GroupTopicSummary[]>([])
  58. const activeRooms = computed(() => groups.rooms.filter(room => !room.archived))
  59. const roomSidebarItems = computed(() => activeRooms.value.map(room => {
  60. const currentMembers = room.id === groups.selectedRoomId && displayAgents.value.length
  61. ? displayAgents.value.slice(0, 4).map(agent => ({
  62. profile: agent.profile,
  63. nodeId: agent.nodeId,
  64. displayName: agent.displayName,
  65. }))
  66. : room.avatarMembers
  67. return roomSidebarItem({ ...room, avatarMembers: currentMembers }, agentAvatars.value, agentAvatarsByName.value)
  68. }))
  69. const pinnedTopics = computed(() => groups.pinnedTopics.filter(topic => !topic.archived).sort((a, b) => b.updatedAt - a.updatedAt || b.id.localeCompare(a.id)))
  70. const topicListRoom = computed(() => topicListRoomId.value ? activeRooms.value.find(room => room.id === topicListRoomId.value) : undefined)
  71. const sidebarSubtitle = computed(() => topicListRoom.value
  72. ? `${topicListRoom.value.agentCount} 个 Agent`
  73. : groups.availability === 'available' ? `${activeRooms.value.length} 个活跃团队` : `9119 团队 ${SUPPORTED_GROUP_PROTOCOL_VERSION_LABEL}`)
  74. const GROUP_LIST_BACK_ID = 'group-list'
  75. const NEW_TOPIC_ID = 'new-topic'
  76. function topicSidebarItemId(roomId: string, topicId: string): string { return `topic:${roomId}:${topicId}` }
  77. function topicFromSidebarItemId(id: string): { roomId: string; topicId: string } | undefined {
  78. const match = /^topic:([^:]+):([^:]+)$/.exec(id)
  79. return match ? { roomId: match[1]!, topicId: match[2]! } : undefined
  80. }
  81. function topicTimeSection(updatedAt: number): string {
  82. const timestamp = updatedAt < 10_000_000_000 ? updatedAt * 1000 : updatedAt
  83. const today = new Date()
  84. today.setHours(0, 0, 0, 0)
  85. const yesterday = new Date(today)
  86. yesterday.setDate(yesterday.getDate() - 1)
  87. if (timestamp >= today.getTime()) return '今天'
  88. if (timestamp >= yesterday.getTime()) return '昨天'
  89. return '更早'
  90. }
  91. const sidebarItems = computed<SidebarItem[]>(() => {
  92. const room = topicListRoom.value
  93. if (!room) return roomSidebarItems.value.map(item => ({ ...item, section: undefined }))
  94. const items: SidebarItem[] = [{
  95. id: GROUP_LIST_BACK_ID,
  96. title: '返回团队列表',
  97. icon: 'chevron-left',
  98. showMore: false,
  99. }, {
  100. id: NEW_TOPIC_ID,
  101. title: '新建话题',
  102. icon: 'plus',
  103. showMore: false,
  104. }]
  105. const roomTopics = groups.topicsForRoom(room.id)
  106. items.push(...roomTopics.filter(topic => topic.pinned).map(topic => ({
  107. id: topicSidebarItemId(room.id, topic.id),
  108. title: topic.title,
  109. subtitle: topic.preview || `${topic.messageCount} 条消息`,
  110. meta: topic.unreadCount ? `${topic.unreadCount} 未读` : `${topic.messageCount} 条`,
  111. unread: topic.unreadCount,
  112. pinned: true,
  113. section: '话题置顶',
  114. icon: 'topic' as const,
  115. topic: true,
  116. showMore: false,
  117. active: topic.id === groups.selectedTopicId,
  118. })))
  119. items.push(...roomTopics.filter(topic => !topic.pinned).map(topic => ({
  120. id: topicSidebarItemId(room.id, topic.id),
  121. title: topic.title,
  122. subtitle: topic.preview || `${topic.messageCount} 条消息`,
  123. meta: topic.unreadCount ? `${topic.unreadCount} 未读` : `${topic.messageCount} 条`,
  124. unread: topic.unreadCount,
  125. section: topicTimeSection(topic.updatedAt),
  126. icon: 'topic' as const,
  127. topic: true,
  128. showMore: false,
  129. active: topic.id === groups.selectedTopicId,
  130. })))
  131. if (room.id === groups.selectedRoomId && groups.selectedTopicId && !groups.selectedTopic) {
  132. items.push({
  133. id: topicSidebarItemId(room.id, groups.selectedTopicId),
  134. title: '新话题',
  135. subtitle: '发送第一条消息以创建',
  136. section: '今天',
  137. icon: 'topic',
  138. topic: true,
  139. showMore: false,
  140. active: true,
  141. })
  142. }
  143. return items
  144. })
  145. const localAgentIdentities = computed(() => new Map(auth.profiles.map(profile => [profile.name, {
  146. name: profile.agentName || profile.displayName || profile.name,
  147. }])))
  148. const displayAgents = computed(() => groups.agents.map(agent => {
  149. const identity = agent.nodeId === 'local' ? localAgentIdentities.value.get(agent.profile) : undefined
  150. return identity ? { ...agent, displayName: identity.name } : agent
  151. }))
  152. const messages = computed(() => groups.messages.map(message => groupMessageToUi(message, displayAgents.value)))
  153. const conversationMediaItems = computed(() => mediaItemsFromMessages(messages.value))
  154. const lightboxMedia = computed(() => conversationMediaItems.value.map(item => ({ url: item.previewUrl || item.downloadUrl || '', name: item.name, type: item.kind as 'image' | 'video' })).filter(item => item.url))
  155. const agents = computed(() => displayAgents.value.map(agentToUi))
  156. const agentAvatars = computed(() => Object.fromEntries([
  157. ...auth.profiles.flatMap(profile =>
  158. profile.agentAvatar ? [[profile.name, profile.agentAvatar] as const] : []),
  159. ...groups.nodes.flatMap(node => node.profiles.flatMap(profile =>
  160. profile.avatar ? [[`node:${node.nodeId}:${profile.name}`, profile.avatar] as const] : [])),
  161. ]))
  162. const agentAvatarsByName = computed(() => Object.fromEntries([
  163. ...auth.profiles.flatMap(profile =>
  164. profile.agentAvatar ? [[profile.agentName || profile.displayName || profile.name, profile.agentAvatar] as const] : []),
  165. ...groups.nodes.flatMap(node => node.profiles.flatMap(profile =>
  166. profile.avatar ? [[profile.displayName || profile.name, profile.avatar] as const] : [])),
  167. ]))
  168. function serverAddress(value: string): string {
  169. try { return new URL(value).host }
  170. catch { return value.replace(/^https?:\/\//i, '').replace(/\/.*$/, '') }
  171. }
  172. const remoteServerAddresses = computed(() => Object.fromEntries(groups.nodes
  173. .filter(node => node.nodeId && node.serverUrl)
  174. .map(node => [node.nodeId, serverAddress(node.serverUrl)])))
  175. const hostAgent = computed(() => groups.hostProtocol ? displayAgents.value.find(agent => agent.isHost) : undefined)
  176. const connected = computed(() => ['connected', 'ready'].includes(groups.connectionState))
  177. const synced = computed(() => groups.connectionState === 'ready' && !groups.isLoading)
  178. const activeInteraction = computed(() => groupInteraction(groups.pendingInteractions[0]))
  179. const room = computed(() => groups.selectedRoom ? roomToUi(groups.selectedRoom) : null)
  180. const profiles = computed<GroupProfileOption[]>(() => [
  181. ...auth.profiles.map(profile => ({
  182. id: `local|${profile.name}`,
  183. profile: profile.name,
  184. displayName: profile.agentName || profile.displayName || profile.name,
  185. nodeId: 'local',
  186. nodeLabel: '当前 Hermes',
  187. avatar: profile.agentAvatar,
  188. })),
  189. ...groups.nodes.flatMap(node => node.profiles.map(profile => ({
  190. id: `${node.nodeId}|${profile.name}`,
  191. profile: profile.name,
  192. displayName: profile.displayName || profile.name,
  193. nodeId: node.nodeId,
  194. nodeLabel: node.name,
  195. avatar: profile.avatar,
  196. }))),
  197. ])
  198. const availableProfiles = computed(() => profiles.value.filter(profile => !groups.agents.some(agent =>
  199. agent.profile === profile.profile && agent.nodeId === profile.nodeId)))
  200. const uploadsEnabled = computed(() => auth.groupUploadsEnabled)
  201. const managerBusy = computed(() => groups.isLoading || Object.values(agentUpdateBusy.value).some(Boolean))
  202. const reference = computed<ComposerReference | null>(() => quoted.value ? { id: quoted.value.id, author: quoted.value.author, content: quoted.value.content } : null)
  203. const mentionNames = computed(() => ['所有人', ...displayAgents.value.map(agent => agent.displayName || agent.profile)])
  204. const mentionOptions = computed<ComposerOption[]>(() => [
  205. { id: 'all', label: '所有人', detail: '通知团队内全部 Agent' },
  206. ...displayAgents.value.map(agent => ({
  207. id: agent.id,
  208. label: agent.displayName || agent.profile,
  209. detail: groups.hostProtocol && agent.isHost ? `管理员 · ${agent.profile}` : agent.profile,
  210. disabled: !agent.enabled,
  211. })),
  212. ])
  213. const roomSubtitle = computed(() => {
  214. if (!groups.selectedRoom) return '选择或新建一个团队'
  215. const host = hostAgent.value ? `管理员 ${hostAgent.value.displayName || hostAgent.value.profile} · ` : ''
  216. const mode = groups.selectedRoom.orchestrationMode === 'host' ? '管理员协调 · ' : ''
  217. return `${groups.selectedRoom.name} · ${mode}${host}${groups.agents.length} 个 Agent · 最多 ${groups.selectedRoom.maxReplyRounds} 轮回复`
  218. })
  219. const activeAgentIds = computed(() => {
  220. if (!groups.topicProtocol) {
  221. return new Set(groups.agents.filter(agent => ['queued', 'running'].includes(agent.status)).map(agent => agent.id))
  222. }
  223. return new Set((groups.selectedRoom?.runs ?? [])
  224. .filter(run => run.topicId === groups.selectedTopicId && ['queued', 'running'].includes(run.status))
  225. .map(run => run.agentId))
  226. })
  227. const typingAgentIds = computed(() => {
  228. if (!groups.topicProtocol) return new Set(groups.agents.filter(agent => agent.status === 'running').map(agent => agent.id))
  229. return new Set((groups.selectedRoom?.runs ?? [])
  230. .filter(run => run.topicId === groups.selectedTopicId && run.status === 'running')
  231. .map(run => run.agentId))
  232. })
  233. const typingAgentNames = computed(() => [...new Set(groups.agents
  234. .filter(agent => typingAgentIds.value.has(agent.id))
  235. .map(agent => displayAgents.value.find(candidate => candidate.id === agent.id)?.displayName || agent.profile))])
  236. const typingActivity = computed(() => {
  237. if (!connected.value) return ''
  238. const names = typingAgentNames.value
  239. if (!names.length) return ''
  240. if (names.length <= 3) return `${names.join('、')}正在输入…`
  241. return `${names.slice(0, 2).join('、')}等 ${names.length} 个 Agent 正在输入…`
  242. })
  243. function groupRoute(roomId = groups.selectedRoomId, topicId = groups.selectedTopicId): string {
  244. if (!roomId) return '/groups'
  245. const roomPath = `/groups/${encodeURIComponent(roomId)}`
  246. return groups.topicProtocol && topicId ? `${roomPath}/${encodeURIComponent(topicId)}` : roomPath
  247. }
  248. const roomActionMenuStyle = computed(() => roomActionMenu.value
  249. ? { left: `${roomActionMenu.value.x}px`, top: `${roomActionMenu.value.y}px` }
  250. : {})
  251. const actionTopic = computed(() => {
  252. const action = roomActionMenu.value
  253. if (!action?.topicId) return undefined
  254. return groups.topicsForRoom(action.roomId).find(item => item.id === action.topicId)
  255. || groups.pinnedTopics.find(item => item.id === action.topicId)
  256. })
  257. function restoreShowThinking(profile = auth.activeProfile?.name || 'default') {
  258. showThinking.value = readAgentShowThinking(auth.user?.id ?? 'local', profile)
  259. }
  260. function toggleShowThinking() {
  261. showThinking.value = !showThinking.value
  262. writeAgentShowThinking(auth.user?.id ?? 'local', auth.activeProfile?.name || 'default', showThinking.value)
  263. }
  264. function stopActiveTopic() {
  265. for (const agentId of activeAgentIds.value) void groups.interruptAgent(agentId).catch(() => undefined)
  266. }
  267. async function selectRoom(id: string) {
  268. try { await groups.selectRoom(id) }
  269. catch { return }
  270. topicListRoomId.value = id
  271. await router.push(groupRoute())
  272. quoted.value = null
  273. }
  274. async function selectTopic(id: string) {
  275. if (!id || id === groups.selectedTopicId) return
  276. try { await groups.selectTopic(id) }
  277. catch { return }
  278. await router.push(groupRoute())
  279. quoted.value = null
  280. }
  281. async function selectSidebarItem(id: string) {
  282. if (id === GROUP_LIST_BACK_ID) {
  283. topicListRoomId.value = null
  284. return
  285. }
  286. if (id === NEW_TOPIC_ID && topicListRoom.value) {
  287. await startTopic(topicListRoom.value.id)
  288. return
  289. }
  290. const topic = topicFromSidebarItemId(id)
  291. if (topic) {
  292. if (topic.roomId !== groups.selectedRoomId) {
  293. try { await groups.selectRoom(topic.roomId, topic.topicId) }
  294. catch { return }
  295. topicListRoomId.value = topic.roomId
  296. await router.push(groupRoute())
  297. quoted.value = null
  298. return
  299. }
  300. await selectTopic(topic.topicId)
  301. return
  302. }
  303. await selectRoom(id)
  304. }
  305. async function openRoomManager(id: string) {
  306. if (topicFromSidebarItemId(id)) return
  307. await selectRoom(id)
  308. managerOpen.value = true
  309. try { await groups.refreshNodes() }
  310. catch { /* Keep the current node list when refreshing is unavailable. */ }
  311. }
  312. async function openSelectedRoomManager() {
  313. managerOpen.value = true
  314. try { await groups.refreshNodes() }
  315. catch { /* Keep the current node list when refreshing is unavailable. */ }
  316. }
  317. async function openCreateGroup() {
  318. try { await groups.refreshNodes() }
  319. catch { /* A node refresh must not prevent creating a local-only group. */ }
  320. createError.value = ''
  321. createOpen.value = true
  322. }
  323. function openRoomActions(roomId: string, event: MouseEvent) {
  324. const topic = topicFromSidebarItemId(roomId)
  325. const width = 174
  326. const height = topic ? 80 : 80
  327. const inset = 8
  328. if (topic) {
  329. topicActionRenaming.value = false
  330. topicActionRenameValue.value = groups.topicsForRoom(topic.roomId).find(item => item.id === topic.topicId)?.title
  331. || groups.pinnedTopics.find(item => item.id === topic.topicId)?.title
  332. || ''
  333. roomActionMenu.value = {
  334. roomId: topic.roomId,
  335. topicId: topic.topicId,
  336. x: Math.max(inset, Math.min(event.clientX, window.innerWidth - width - inset)),
  337. y: Math.max(inset, Math.min(event.clientY, window.innerHeight - height - inset)),
  338. }
  339. return
  340. }
  341. if (!groups.topicProtocol || !activeRooms.value.some(room => room.id === roomId)) return
  342. roomActionMenu.value = {
  343. roomId,
  344. x: Math.max(inset, Math.min(event.clientX, window.innerWidth - width - inset)),
  345. y: Math.max(inset, Math.min(event.clientY, window.innerHeight - height - inset)),
  346. }
  347. }
  348. function openTopicActions(roomId: string, topicId: string, event: MouseEvent) {
  349. openRoomActions(topicSidebarItemId(roomId, topicId), event)
  350. }
  351. function closeRoomActions() {
  352. roomActionMenu.value = null
  353. topicActionRenaming.value = false
  354. topicActionRenameValue.value = ''
  355. }
  356. function handleRoomActionPointer(event: PointerEvent) {
  357. if (!roomActionMenu.value || (event.target as HTMLElement).closest('.group-room-actions')) return
  358. closeRoomActions()
  359. }
  360. function handleRoomActionKey(event: KeyboardEvent) {
  361. if (event.key === 'Escape' && roomActionMenu.value) closeRoomActions()
  362. }
  363. async function startTopicFromRoomAction() {
  364. const roomId = roomActionMenu.value?.roomId
  365. if (roomActionMenu.value?.topicId) return
  366. closeRoomActions()
  367. if (!roomId) return
  368. await startTopic(roomId)
  369. }
  370. async function startTopic(roomId: string) {
  371. try {
  372. await groups.selectRoom(roomId)
  373. topicListRoomId.value = roomId
  374. const topicId = await groups.startNewTopic()
  375. if (!topicId) return
  376. await router.push(groupRoute(roomId, topicId))
  377. quoted.value = null
  378. await nextTick()
  379. composer.value?.focus()
  380. } catch { /* store publishes the error */ }
  381. }
  382. async function createRoom(payload: { name: string; avatar?: string; members: Array<GroupProfileOption & { description?: string }>; autoReply: boolean; replyRounds: number; instructions?: string; hostProfile?: string; orchestrationMode?: 'free' | 'host' }) {
  383. const hostProfile = payload.hostProfile || payload.members[0]?.id
  384. createError.value = ''
  385. creatingRoom.value = true
  386. try {
  387. const detail = await groups.createRoom({
  388. name: payload.name,
  389. ...(groups.roomAvatarProtocol ? { avatar: payload.avatar ?? '' } : {}),
  390. ...(groups.roomInstructionsProtocol ? { instructions: payload.instructions ?? '' } : {}),
  391. agents: payload.members.map(member => ({
  392. profile: member.profile,
  393. nodeId: member.nodeId,
  394. nodeLabel: member.nodeLabel,
  395. displayName: member.displayName,
  396. description: member.description,
  397. replyWithoutMention: payload.autoReply,
  398. ...(groups.hostProtocol ? { isHost: member.id === hostProfile } : {}),
  399. })),
  400. maxReplyRounds: payload.replyRounds,
  401. ...(groups.hostFlowProtocol ? { orchestrationMode: payload.orchestrationMode ?? 'free' } : {}),
  402. })
  403. createOpen.value = false
  404. await router.push(groupRoute(detail.id, groups.selectedTopicId))
  405. } catch (cause) {
  406. createError.value = cause instanceof Error ? cause.message : '创建团队失败'
  407. } finally {
  408. creatingRoom.value = false
  409. }
  410. }
  411. async function send(payload: ComposerSubmit) {
  412. const prefix = quoted.value ? `> ${quoted.value.content.replace(/\n/g, '\n> ')}\n\n` : ''
  413. try {
  414. await groups.sendMessage(`${prefix}${payload.text}`, payload.mentionIds, payload.files)
  415. quoted.value = null
  416. composer.value?.clearAfterSend()
  417. } catch { /* store publishes the error */ }
  418. }
  419. async function updateRoom(patch: { name?: string; instructions?: string; avatar?: string; replyRounds?: number; orchestrationMode?: 'free' | 'host' }) {
  420. if (!groups.selectedRoom) return
  421. await groups.updateRoom(groups.selectedRoom.id, {
  422. name: patch.name,
  423. ...(groups.roomInstructionsProtocol ? { instructions: patch.instructions } : {}),
  424. ...(groups.roomAvatarProtocol ? { avatar: patch.avatar } : {}),
  425. maxReplyRounds: patch.replyRounds,
  426. ...(groups.hostFlowProtocol ? { orchestrationMode: patch.orchestrationMode } : {}),
  427. })
  428. }
  429. async function addAgent(profileID: string) {
  430. if (!groups.selectedRoom) return
  431. const member = profiles.value.find(profile => profile.id === profileID)
  432. if (!member) return
  433. await groups.addAgent(groups.selectedRoom.id, {
  434. profile: member.profile,
  435. nodeId: member.nodeId,
  436. nodeLabel: member.nodeLabel,
  437. displayName: member.displayName,
  438. replyWithoutMention: true,
  439. ...(groups.hostProtocol ? { isHost: false } : {}),
  440. })
  441. }
  442. type AgentSettingsPatch = Partial<Pick<GroupAgent,
  443. 'displayName' | 'description' | 'enabled' | 'replyWithoutMention' | 'isHost' | 'model' | 'provider' | 'reasoningEffort' | 'fastMode'>>
  444. async function loadAgentModels(profile: string) {
  445. if (modelOptionsLoading.value[profile] || Object.prototype.hasOwnProperty.call(modelOptionsByProfile.value, profile)) return
  446. modelOptionsLoading.value = { ...modelOptionsLoading.value, [profile]: true }
  447. modelOptionsError.value = { ...modelOptionsError.value, [profile]: '' }
  448. try {
  449. modelOptionsByProfile.value = { ...modelOptionsByProfile.value, [profile]: await getModels(profile) }
  450. } catch (cause) {
  451. modelOptionsError.value = { ...modelOptionsError.value, [profile]: cause instanceof Error ? cause.message : '模型选项加载失败' }
  452. } finally {
  453. modelOptionsLoading.value = { ...modelOptionsLoading.value, [profile]: false }
  454. }
  455. }
  456. async function updateAgent(id: string, patch: AgentSettingsPatch) {
  457. if (!groups.selectedRoom) return
  458. managerError.value = ''
  459. agentUpdateBusy.value = { ...agentUpdateBusy.value, [id]: true }
  460. agentUpdateError.value = { ...agentUpdateError.value, [id]: '' }
  461. try { await groups.updateAgent(groups.selectedRoom.id, id, patch) }
  462. catch (cause) {
  463. const message = cause instanceof Error ? cause.message : 'Agent 设置保存失败'
  464. agentUpdateError.value = { ...agentUpdateError.value, [id]: message }
  465. managerError.value = message
  466. }
  467. finally { agentUpdateBusy.value = { ...agentUpdateBusy.value, [id]: false } }
  468. }
  469. async function removeAgent(id: string) {
  470. if (!groups.selectedRoom) return
  471. managerError.value = ''
  472. agentUpdateBusy.value = { ...agentUpdateBusy.value, [id]: true }
  473. try { await groups.removeAgent(groups.selectedRoom.id, id) }
  474. catch (cause) { managerError.value = cause instanceof Error ? cause.message : '移除 Agent 失败' }
  475. finally { agentUpdateBusy.value = { ...agentUpdateBusy.value, [id]: false } }
  476. }
  477. function clearAgentError(id: string) {
  478. if (!agentUpdateError.value[id]) return
  479. agentUpdateError.value = { ...agentUpdateError.value, [id]: '' }
  480. managerError.value = ''
  481. }
  482. async function archiveRoom() {
  483. if (!groups.selectedRoom) return
  484. await groups.archiveRoom(groups.selectedRoom.id)
  485. managerOpen.value = false
  486. await router.replace(groupRoute())
  487. }
  488. async function openArchivedOverlay() {
  489. archivedOverlayOpen.value = true
  490. archivedRoomList.value = await groups.archivedRooms()
  491. archivedTopicList.value = groups.selectedRoomId
  492. ? await groups.archivedTopics(groups.selectedRoomId)
  493. : []
  494. }
  495. async function restoreArchivedRoom(roomId: string) {
  496. await groups.restoreRoom(roomId)
  497. archivedRoomList.value = await groups.archivedRooms()
  498. }
  499. async function archiveTopicFromAction() {
  500. const action = roomActionMenu.value
  501. closeRoomActions()
  502. if (!action?.topicId) return
  503. await groups.archiveTopic(action.roomId, action.topicId)
  504. }
  505. async function toggleTopicPinnedFromAction() {
  506. const action = roomActionMenu.value
  507. const topic = actionTopic.value
  508. closeRoomActions()
  509. if (!action?.topicId) return
  510. await groups.setTopicPinned(action.roomId, action.topicId, !topic?.pinned)
  511. }
  512. async function renameTopicFromAction() {
  513. const action = roomActionMenu.value
  514. const title = topicActionRenameValue.value.trim()
  515. if (!action?.topicId || !title) return
  516. await groups.renameTopic(action.roomId, action.topicId, title)
  517. closeRoomActions()
  518. }
  519. async function archiveRoomFromAction() {
  520. const action = roomActionMenu.value
  521. closeRoomActions()
  522. if (!action || action.topicId) return
  523. await groups.archiveRoom(action.roomId)
  524. if (route.params.roomId === action.roomId) await router.replace(groupRoute())
  525. }
  526. async function restoreArchivedTopic(topicId: string) {
  527. const roomId = groups.selectedRoomId
  528. if (!roomId) return
  529. await groups.restoreTopic(roomId, topicId)
  530. archivedTopicList.value = await groups.archivedTopics(roomId)
  531. }
  532. function openLocalFile({ name, url }: { name: string; url: string }) {
  533. const item = previewItemFromUrl(name, url)
  534. if (item.kind === 'image' || item.kind === 'video') openMedia(item)
  535. else preview.value = item
  536. }
  537. function openMedia(item: UiLibraryItem) {
  538. const target = mediaUrlIdentity(item.previewUrl || item.downloadUrl || '')
  539. const index = lightboxMedia.value.findIndex(media => mediaUrlIdentity(media.url) === target)
  540. mediaPreviewIndex.value = index >= 0 ? index : null
  541. }
  542. function openAttachment(attachment: NonNullable<UiMessage['attachments']>[number]) {
  543. const item = previewItemFromUrl(attachment.name, attachment.url || '', attachment.id, attachment.kind)
  544. item.size = attachment.size
  545. if (item.kind === 'image' || item.kind === 'video') openMedia(item)
  546. else preview.value = item
  547. }
  548. async function addPreviewToComposer(item: UiLibraryItem) {
  549. if (!uploadsEnabled.value) return
  550. const file = await loadComposerFile(item)
  551. if (!file || !composer.value) return
  552. composer.value.attachFiles([file])
  553. preview.value = null
  554. mediaPreviewIndex.value = null
  555. await nextTick()
  556. composer.value?.focus()
  557. }
  558. async function addMediaToComposer(media: PreviewMedia) {
  559. await addPreviewToComposer(previewItemFromUrl(media.name, media.url, `preview:${media.url}`, media.type))
  560. }
  561. onMounted(async () => {
  562. document.addEventListener('pointerdown', handleRoomActionPointer)
  563. document.addEventListener('keydown', handleRoomActionKey)
  564. restoreShowThinking()
  565. try {
  566. await groups.start()
  567. const requested = typeof route.params.roomId === 'string' ? route.params.roomId : ''
  568. const requestedTopic = typeof route.params.topicId === 'string' ? route.params.topicId : undefined
  569. if (requested) {
  570. try {
  571. await groups.selectRoom(requested, requestedTopic)
  572. topicListRoomId.value = requested
  573. }
  574. catch {
  575. if (groups.selectedRoomId) await router.replace(groupRoute())
  576. return
  577. }
  578. }
  579. if (groups.selectedRoomId) {
  580. if (route.fullPath !== groupRoute()) await router.replace(groupRoute())
  581. }
  582. } catch { /* availability state renders the error */ }
  583. })
  584. onBeforeUnmount(() => {
  585. document.removeEventListener('pointerdown', handleRoomActionPointer)
  586. document.removeEventListener('keydown', handleRoomActionKey)
  587. groups.stop()
  588. })
  589. watch(() => [route.params.roomId, route.params.topicId] as const, async ([roomValue, topicValue]) => {
  590. const roomId = typeof roomValue === 'string' ? roomValue : ''
  591. const topicId = typeof topicValue === 'string' ? topicValue : undefined
  592. if (!roomId) {
  593. topicListRoomId.value = null
  594. return
  595. }
  596. if (roomId && (roomId !== groups.selectedRoomId || (groups.topicProtocol && topicId && topicId !== groups.selectedTopicId))) {
  597. try {
  598. await groups.selectRoom(roomId, topicId)
  599. topicListRoomId.value = roomId
  600. }
  601. catch { if (groups.selectedRoomId && route.fullPath !== groupRoute()) await router.replace(groupRoute()) }
  602. }
  603. })
  604. watch(() => groups.selectedRoomId, () => {
  605. managerError.value = ''
  606. agentUpdateError.value = {}
  607. })
  608. watch(() => auth.activeProfile?.name, profile => { if (profile) restoreShowThinking(profile) })
  609. </script>
  610. <template>
  611. <WorkspaceView sidebar-title="团队" :sidebar-context-title="topicListRoom?.name" :sidebar-subtitle="sidebarSubtitle" :sidebar-focus-mode="!!topicListRoom" :inspector-open="managerOpen && !!room" inspector-close-label="关闭团队管理" @close-inspector="managerOpen = false">
  612. <template #sidebar-action>
  613. <button class="sidebar-primary-action" type="button" :disabled="groups.availability !== 'available'" title="新建团队" aria-label="新建团队" @click="openCreateGroup">
  614. <YaoYaoSidebarIcon name="add" />
  615. <span>新建团队</span>
  616. </button>
  617. <button class="sidebar-primary-action" type="button" :disabled="groups.availability !== 'available'" @click="openArchivedOverlay">
  618. <AppIcon name="archive" :size="15" />
  619. <span>已归档</span>
  620. </button>
  621. </template>
  622. <template #sidebar-before-heading>
  623. <section v-if="pinnedTopics.length && !topicListRoom" class="pinned-topic-list" aria-label="话题置顶">
  624. <header class="pinned-topic-list__heading"><strong>话题置顶</strong><span>{{ pinnedTopics.length }} 个置顶话题</span></header>
  625. <button v-for="topic in pinnedTopics" :key="topic.id" class="pinned-topic-list__item" type="button" :class="{ active: topic.id === groups.selectedTopicId }" @click="selectSidebarItem(topicSidebarItemId(topic.roomId, topic.id))" @contextmenu.prevent.stop="openTopicActions(topic.roomId, topic.id, $event)">
  626. <AppIcon name="topic" :size="14" />
  627. <span>{{ topic.title }}</span>
  628. <small>{{ activeRooms.find(room => room.id === topic.roomId)?.name || topic.preview }}</small>
  629. </button>
  630. </section>
  631. </template>
  632. <template #sidebar>
  633. <ResourceSidebar
  634. :class="{ 'group-topic-focus-sidebar': !!topicListRoom }"
  635. :items="sidebarItems"
  636. :active-id="groups.selectedRoomId"
  637. :loading="groups.isLoading"
  638. external-search
  639. search-placeholder="搜索团队"
  640. empty-title="还没有团队"
  641. empty-description="新建团队,邀请 1–8 个 Agent 一起协作。"
  642. @select="selectSidebarItem"
  643. @more="openRoomManager"
  644. @context-menu="openRoomActions"
  645. />
  646. </template>
  647. <div v-if="groups.availability === 'unsupported' || groups.availability === 'unavailable'" class="groups-unavailable">
  648. <EmptyState icon="alert" :title="groups.availability === 'unsupported' ? '团队协议版本不兼容' : '团队服务暂不可用'" :description="groups.error || `请确认 9119 已安装 YaoYao 团队协议 ${SUPPORTED_GROUP_PROTOCOL_VERSION_LABEL} 插件。`" action-label="重新检查" @action="groups.refresh" />
  649. </div>
  650. <div v-else class="groups-workspace">
  651. <MessageTimeline
  652. :messages="messages"
  653. :title="groups.topicProtocol ? (groups.selectedTopic?.title || '新话题') : (groups.selectedRoom?.name || '团队')"
  654. :subtitle="roomSubtitle"
  655. :loading="groups.isLoading"
  656. :has-older="groups.hasMoreBefore"
  657. :connected="connected"
  658. :synced="synced"
  659. :show-tools="showThinking"
  660. :interaction="activeInteraction"
  661. :mention-names="mentionNames"
  662. :agent-avatars="agentAvatars"
  663. :empty-title="groups.topicProtocol ? '开始一个新话题' : '让多个 Agent 一起工作'"
  664. :empty-description="groups.topicProtocol ? '第一条消息会创建独立话题,各话题分别保留 Agent 上下文。' : '使用 @ 提及指定 Agent,或直接发送消息触发已启用自动回复的成员。'"
  665. @load-older="groups.loadOlder"
  666. @quote="quoted = $event"
  667. @preview="openAttachment"
  668. @preview-file="openLocalFile"
  669. @approve="activeInteraction && groups.approveInteraction(activeInteraction.id, $event ? 'once' : 'deny')"
  670. @clarify="activeInteraction && groups.clarifyInteraction(activeInteraction.id, $event)"
  671. >
  672. <template #header-actions>
  673. <div class="group-header-actions">
  674. <span v-if="hostAgent" class="group-host-chip" :title="`用户未明确 @ 时由管理员 ${hostAgent.displayName || hostAgent.profile} 负责回应`">管理员 {{ hostAgent.displayName || hostAgent.profile }}</span>
  675. <div class="group-avatars" aria-label="团队成员"><AgentAvatar v-for="agent in agents.slice(0, 4)" :key="agent.id" :name="agent.name" :avatar="agentAvatars[agent.nodeId === 'local' ? agent.profile || '' : `node:${agent.nodeId}:${agent.profile}`] || ''" :size="24" :title="agent.isHost ? `${agent.name} · 管理员` : agent.name" /><em v-if="agents.length > 4">+{{ agents.length - 4 }}</em></div>
  676. <button class="icon-button" type="button" title="管理团队" aria-label="管理团队" :disabled="!groups.selectedRoom" @click="openSelectedRoomManager"><AppIcon name="dots" /></button>
  677. </div>
  678. </template>
  679. </MessageTimeline>
  680. <p v-if="groups.error" class="group-error" role="alert"><AppIcon name="alert" :size="13" />{{ groups.error }}</p>
  681. <ComposerShell
  682. ref="composer"
  683. mode="group"
  684. :draft-key="`${auth.user?.id || 'local'}:${groups.selectedRoomId || 'new'}:${groups.selectedTopicId || 'legacy'}`"
  685. :disabled="!groups.selectedRoom || groups.availability !== 'available'"
  686. :streaming="activeAgentIds.size > 0"
  687. :sending="groups.isSending"
  688. :activity-text="typingActivity"
  689. :tool-trace-visible="showThinking"
  690. :reference="reference"
  691. :mention-options="mentionOptions"
  692. :attachments-enabled="uploadsEnabled"
  693. placeholder="发消息给团队,输入 @ 提及 Agent"
  694. @send="send"
  695. @stop="stopActiveTopic"
  696. @tool-trace-toggle="toggleShowThinking"
  697. @clear-reference="quoted = null"
  698. />
  699. </div>
  700. <template #inspector>
  701. <GroupManager
  702. v-if="room && groups.selectedRoom"
  703. :room="room"
  704. :agents="displayAgents"
  705. :host-enabled="groups.hostProtocol"
  706. :host-flow-enabled="groups.hostFlowProtocol"
  707. :room-instructions-enabled="groups.roomInstructionsProtocol"
  708. :avatar-enabled="groups.roomAvatarProtocol"
  709. :available-profiles="availableProfiles"
  710. :busy="managerBusy"
  711. :model-options-by-profile="modelOptionsByProfile"
  712. :model-options-loading="modelOptionsLoading"
  713. :model-options-error="modelOptionsError"
  714. :remote-server-addresses="remoteServerAddresses"
  715. :agent-update-error="agentUpdateError"
  716. :agent-avatars="agentAvatars"
  717. :manager-error="managerError"
  718. @update-room="updateRoom"
  719. @add-agent="addAgent"
  720. @load-models="loadAgentModels"
  721. @clear-agent-error="clearAgentError"
  722. @update-agent="updateAgent"
  723. @remove-agent="removeAgent"
  724. @interrupt-agent="groups.interruptAgent($event, groups.selectedRoom.id)"
  725. @archive-room="archiveRoom"
  726. />
  727. </template>
  728. </WorkspaceView>
  729. <FloatingResourceSearch section="groups" label="搜索团队" :items="roomSidebarItems" @select="selectRoom" />
  730. <CreateGroupDialog :open="createOpen" :profiles="profiles" :avatar-enabled="groups.roomAvatarProtocol" :host-enabled="groups.hostProtocol" :host-flow-enabled="groups.hostFlowProtocol" :room-instructions-enabled="groups.roomInstructionsProtocol" :error="createError" :busy="groups.isLoading || creatingRoom" @close="createOpen = false" @create="createRoom" />
  731. <PreviewModal v-if="preview" :item="preview" :items="conversationMediaItems" @close="preview = null" @add-to-composer="addPreviewToComposer" @source="preview = null" />
  732. <ImagePreviewLightbox v-model="mediaPreviewIndex" :images="lightboxMedia" :can-add="uploadsEnabled" @add="addMediaToComposer" />
  733. <Teleport to="body">
  734. <Transition name="group-menu">
  735. <section v-if="roomActionMenu" class="group-room-actions" :style="roomActionMenuStyle" role="menu" aria-label="团队操作" @contextmenu.prevent>
  736. <template v-if="roomActionMenu.topicId">
  737. <template v-if="topicActionRenaming">
  738. <label class="group-topic-rename">话题名称<input v-model="topicActionRenameValue" maxlength="120" autofocus @keydown.enter="renameTopicFromAction" /></label>
  739. <div class="group-topic-rename__actions"><button class="quiet-button" type="button" @click="topicActionRenaming = false">取消</button><button class="solid-button" type="button" @click="renameTopicFromAction">保存</button></div>
  740. </template>
  741. <template v-else>
  742. <button class="group-action-row" role="menuitem" type="button" @click="toggleTopicPinnedFromAction"><AppIcon :name="actionTopic?.pinned ? 'pin-off' : 'pin'" :size="14" />{{ actionTopic?.pinned ? '取消置顶' : '置顶话题' }}</button>
  743. <button class="group-action-row" role="menuitem" type="button" @click="topicActionRenaming = true"><AppIcon name="edit" :size="14" />重命名</button>
  744. <button class="group-action-row danger" role="menuitem" type="button" @click="archiveTopicFromAction"><AppIcon name="archive" :size="14" />归档话题</button>
  745. </template>
  746. </template>
  747. <template v-else>
  748. <button class="group-action-row" role="menuitem" type="button" @click="startTopicFromRoomAction"><AppIcon name="plus" :size="14" />新建话题</button>
  749. <button class="group-action-row danger" role="menuitem" type="button" @click="archiveRoomFromAction"><AppIcon name="archive" :size="14" />归档团队</button>
  750. </template>
  751. </section>
  752. </Transition>
  753. </Teleport>
  754. <Teleport to="body">
  755. <Transition name="group-menu">
  756. <div v-if="archivedOverlayOpen" class="archived-overlay-backdrop" role="presentation" @click.self="archivedOverlayOpen = false">
  757. <section class="archived-overlay" role="dialog" aria-modal="true" aria-label="已归档团队和话题">
  758. <header><div><small>团队归档</small><strong>已归档内容</strong></div><button type="button" aria-label="关闭" @click="archivedOverlayOpen = false"><AppIcon name="close" :size="16" /></button></header>
  759. <section class="archived-section"><h3>团队</h3><p v-if="!archivedRoomList.length">没有已归档团队</p><article v-for="archived in archivedRoomList" :key="archived.id"><span>{{ archived.name }}</span><button type="button" @click="restoreArchivedRoom(archived.id)">恢复</button></article></section>
  760. <section class="archived-section"><h3>当前团队的话题</h3><p v-if="!groups.selectedRoom">请先打开一个团队查看其已归档话题</p><p v-else-if="!archivedTopicList.length">没有已归档话题</p><article v-for="topic in archivedTopicList" :key="topic.id"><span>{{ topic.title }}</span><button type="button" @click="restoreArchivedTopic(topic.id)">恢复</button></article></section>
  761. </section>
  762. </div>
  763. </Transition>
  764. </Teleport>
  765. </template>
  766. <style scoped>
  767. .groups-workspace, .groups-unavailable { display: flex; min-width: 0; min-height: 0; flex: 1; flex-direction: column; background: var(--conversation-canvas); }.groups-unavailable { overflow: auto; }
  768. .group-room-actions { position: fixed; z-index: 205; width: 174px; box-sizing: border-box; padding: 6px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-raised); box-shadow: 0 12px 34px rgba(0,0,0,.16); }
  769. .group-action-row { display: flex; width: 100%; min-height: 34px; align-items: center; gap: 8px; padding: 0 9px; border: 0; border-radius: 7px; background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 11px; text-align: left; }.group-action-row:hover, .group-action-row:focus-visible { outline: 0; background: var(--surface-soft); color: var(--text-primary); }
  770. .group-action-row.danger:hover, .group-action-row.danger:focus-visible { color: var(--danger); }
  771. .group-topic-rename { display: grid; gap: 6px; padding: 6px 8px; color: var(--text-secondary); font-size: 10px; }.group-topic-rename input { width: 100%; min-height: 30px; box-sizing: border-box; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: var(--surface-soft); color: var(--text-primary); font: inherit; }.group-topic-rename input:focus { border-color: var(--line-strong); box-shadow: 0 0 0 3px var(--focus-ring); }.group-topic-rename__actions { display: flex; justify-content: flex-end; gap: 6px; padding: 2px 8px 5px; }.group-topic-rename__actions button { min-height: 28px; padding: 0 8px; font-size: 10px; }
  772. .group-menu-enter-active, .group-menu-leave-active { transition: opacity 100ms ease, transform 120ms var(--ease-out); transform-origin: top right; }.group-menu-enter-from, .group-menu-leave-to { opacity: 0; transform: translateY(-3px) scale(.98); }
  773. .sidebar-primary-action { display: flex; width: 100%; min-height: 40px; align-items: center; gap: 10px; padding: 0 11px; border: 0; border-radius: 9px; background: transparent; color: var(--text-primary); cursor: pointer; font-size: 12px; font-weight: 610; text-align: left; transition: background-color 120ms ease; }
  774. .sidebar-primary-action:hover, .sidebar-primary-action:focus-visible { background: var(--surface-hover); outline: 0; }
  775. .sidebar-primary-action:focus-visible { box-shadow: inset 0 0 0 1px var(--line-strong); }
  776. .sidebar-primary-action:disabled { cursor: not-allowed; opacity: .35; }
  777. .pinned-topic-list { max-height: 154px; overflow: auto; padding: 0 10px 4px; border-bottom: 1px solid var(--line); }
  778. .pinned-topic-list__heading { display: flex; min-height: 35px; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 11px 5px; }
  779. .pinned-topic-list__heading strong { font-size: 12px; font-weight: 680; }.pinned-topic-list__heading span { overflow: hidden; color: var(--text-muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
  780. .pinned-topic-list__item { display: flex; width: 100%; min-height: 32px; align-items: center; gap: 7px; padding: 1px 9px; border: 0; border-radius: 8px; background: transparent; color: var(--text-primary); cursor: pointer; text-align: left; }.pinned-topic-list__item:hover, .pinned-topic-list__item.active { background: var(--surface-hover); }.pinned-topic-list__item :deep(.app-icon) { flex: 0 0 auto; color: var(--text-muted); }.pinned-topic-list__item > span { min-width: 0; overflow: hidden; font-size: 10.5px; font-weight: 450; text-overflow: ellipsis; white-space: nowrap; }.pinned-topic-list__item small { margin-left: auto; overflow: hidden; color: var(--text-muted); font-size: 8.5px; text-overflow: ellipsis; white-space: nowrap; }
  781. .group-topic-focus-sidebar :deep(.sidebar-list) { padding: 0 0 14px; }
  782. .group-topic-focus-sidebar :deep(.sidebar-section-label) { margin-inline: 10px; }
  783. .group-topic-focus-sidebar :deep(.sidebar-item:not([data-sidebar-id="group-list"])) { width: calc(100% - 20px); margin-inline: 10px; }
  784. .group-topic-focus-sidebar :deep([data-sidebar-id="group-list"]) { position: sticky; z-index: 3; top: 0; min-height: 58px; padding-inline: 17px; border-bottom: 1px solid var(--line); border-radius: 0; background: var(--surface); }
  785. .group-topic-focus-sidebar :deep([data-sidebar-id="group-list"]:hover), .group-topic-focus-sidebar :deep([data-sidebar-id="group-list"]:focus-visible) { background: var(--surface-hover); }
  786. .archived-overlay-backdrop { position: fixed; z-index: 220; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.36); }.archived-overlay { width: min(460px, 100%); max-height: min(620px, calc(100vh - 40px)); overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-raised); box-shadow: 0 24px 70px rgba(0,0,0,.28); }.archived-overlay header { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }.archived-overlay header small { display: block; color: var(--text-secondary); font-size: 10px; }.archived-overlay header strong { font-size: 15px; }.archived-overlay header button { display: grid; width: 30px; height: 30px; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); cursor: pointer; }.archived-section { display: grid; gap: 8px; padding: 16px 18px; }.archived-section + .archived-section { border-top: 1px solid var(--line); }.archived-section h3 { margin: 0; font-size: 12px; }.archived-section p { margin: 0; color: var(--text-secondary); font-size: 12px; }.archived-section article { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; }.archived-section article span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.archived-section article button { border: 0; border-radius: 7px; background: var(--surface-hover); color: var(--text-primary); cursor: pointer; padding: 5px 9px; }
  787. .group-header-actions { display: flex; align-items: center; gap: 8px; }.group-host-chip { max-width: 150px; overflow: hidden; padding: 4px 7px; border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--line)); border-radius: 999px; background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--accent); font-size: 9px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }.group-avatars { display: flex; align-items: center; }.group-avatars span, .group-avatars em { display: grid; width: 24px; height: 24px; margin-left: -5px; place-items: center; border: 2px solid var(--canvas); border-radius: 8px; font-size: 8px; font-style: normal; font-weight: 650; }.group-avatars span { background: transparent; color: var(--text-secondary); }.group-avatars span:first-child { margin-left: 0; }.group-avatars em { background: var(--surface-hover); color: var(--text-secondary); }
  788. .group-error { display: flex; width: min(760px, calc(100% - 32px)); margin: 0 auto 4px; align-items: center; gap: 6px; color: var(--danger); font-size: 9px; }
  789. @media (max-width: 480px) { .group-avatars, .group-host-chip { display: none; } }
  790. @media (prefers-reduced-motion: reduce) { .sidebar-primary-action, .group-menu-enter-active, .group-menu-leave-active { transition: none; } }
  791. </style>