MessageTimeline.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <script setup lang="ts">
  2. import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
  3. import AppIcon from '@/components/common/AppIcon.vue'
  4. import AgentAvatar from '@/components/common/AgentAvatar.vue'
  5. import EmptyState from '@/components/common/EmptyState.vue'
  6. import InteractionCard from './InteractionCard.vue'
  7. import MarkdownContent from './MarkdownContent.vue'
  8. import ToolTrace from './ToolTrace.vue'
  9. import TurnTrace from './TurnTrace.vue'
  10. import type { UiInteraction, UiLocalFileLink, UiMessage } from './types'
  11. import { buildMessageTimelineRows } from '@/utils/turnTrace'
  12. import { displayContentForMessage } from '@/utils/messageDisplay'
  13. import { formatMessageTime } from '@/utils/messageTime'
  14. const props = withDefaults(defineProps<{
  15. messages: UiMessage[]
  16. title?: string
  17. subtitle?: string
  18. emptyTitle?: string
  19. emptyDescription?: string
  20. emptyLogo?: boolean
  21. transparentHeader?: boolean
  22. forkSourceTitle?: string
  23. loading?: boolean
  24. loadingOlder?: boolean
  25. hasOlder?: boolean
  26. connected?: boolean
  27. synced?: boolean
  28. showTools?: boolean
  29. showAssistantIdentity?: boolean
  30. interaction?: UiInteraction | null
  31. mentionNames?: string[]
  32. agentAvatars?: Record<string, string>
  33. thinking?: boolean
  34. }>(), {
  35. title: '',
  36. subtitle: '',
  37. emptyTitle: '开始一段新对话',
  38. emptyDescription: '从下方输入框发送消息,或选择左侧的历史会话。',
  39. emptyLogo: false,
  40. transparentHeader: false,
  41. forkSourceTitle: '',
  42. loading: false,
  43. loadingOlder: false,
  44. hasOlder: false,
  45. connected: false,
  46. synced: false,
  47. showTools: true,
  48. showAssistantIdentity: true,
  49. interaction: null,
  50. mentionNames: () => [],
  51. agentAvatars: () => ({}),
  52. thinking: false,
  53. })
  54. const emit = defineEmits<{
  55. loadOlder: []
  56. quote: [message: UiMessage]
  57. branch: [message: UiMessage]
  58. preview: [attachment: NonNullable<UiMessage['attachments']>[number]]
  59. previewFile: [file: UiLocalFileLink]
  60. approve: [approved: boolean]
  61. clarify: [text: string]
  62. }>()
  63. const scroller = ref<HTMLElement | null>(null)
  64. const pinnedToBottom = ref(true)
  65. const showJump = ref(false)
  66. const copiedMessageId = ref('')
  67. const thinkingElapsedMs = ref(0)
  68. const timelineRows = computed(() => buildMessageTimelineRows(props.messages))
  69. const showThinkingIndicator = computed(() => {
  70. if (!props.thinking) return false
  71. const current = [...props.messages].reverse().find(message => message.role === 'assistant' && message.status === 'streaming')
  72. // A tool trace is progress detail, not assistant prose. Keep the bottom
  73. // activity indicator visible while that tool-only stream segment is active.
  74. return !current?.content.trim() && !current?.reasoning?.trim()
  75. })
  76. let copyResetTimer: number | undefined
  77. let thinkingTimer: number | undefined
  78. let thinkingStartedAt = 0
  79. const formatTime = formatMessageTime
  80. function delegationSummary(metadata?: Record<string, unknown>): string {
  81. const total = Number(metadata?.task_count ?? 0)
  82. const completed = Number(metadata?.completed_count ?? 0)
  83. const failed = Number(metadata?.failed_count ?? 0)
  84. const seconds = Number(metadata?.duration_seconds ?? 0)
  85. const duration = seconds > 0 ? ` · ${seconds < 60 ? `${Math.round(seconds)} 秒` : `${Math.floor(seconds / 60)} 分 ${Math.round(seconds % 60)} 秒`}` : ''
  86. return `${total || completed + failed || 1} 个子任务 · ${completed} 已完成${failed ? ` · ${failed} 失败` : ''}${duration}`
  87. }
  88. function systemSummary(content: string): string {
  89. const model = content.match(/(?:changed to|切换为)\s*([^\s,。\]]+?)(?=\s+via\b|\s*$|\])/i)?.[1]
  90. if (model) return `模型已切换:${model}`
  91. return '系统信息'
  92. }
  93. function isCompactionEvent(message: UiMessage): boolean {
  94. return message.timelineMetadata?.eventKind === 'compaction'
  95. || message.content.trim().toLocaleLowerCase().startsWith('[context compaction')
  96. }
  97. function onScroll() {
  98. const el = scroller.value
  99. if (!el) return
  100. const distance = el.scrollHeight - el.scrollTop - el.clientHeight
  101. pinnedToBottom.value = distance < 100
  102. showJump.value = distance > 240
  103. }
  104. function scrollToBottom(behavior: ScrollBehavior = 'smooth') {
  105. const el = scroller.value
  106. if (!el) return
  107. el.scrollTo({ top: el.scrollHeight, behavior })
  108. }
  109. function scrollToMessage(id: string): boolean {
  110. const root = scroller.value
  111. if (!root) return false
  112. const message = root.querySelector<HTMLElement>(`[data-message-id="${CSS.escape(id)}"]`)
  113. if (!message) return false
  114. message.scrollIntoView({ block: 'center', behavior: 'smooth' })
  115. message.classList.remove('message--revealed')
  116. requestAnimationFrame(() => message.classList.add('message--revealed'))
  117. window.setTimeout(() => message.classList.remove('message--revealed'), 1800)
  118. return true
  119. }
  120. function scrollToAnchor(messageId: string, anchorId: string): boolean {
  121. const root = scroller.value
  122. if (!root) return false
  123. const message = root.querySelector<HTMLElement>(`[data-message-id="${CSS.escape(messageId)}"]`)
  124. if (!message) return false
  125. const target = anchorId ? message.querySelector<HTMLElement>(`#${CSS.escape(anchorId)}`) : null
  126. ;(target || message).scrollIntoView({ block: target ? 'start' : 'center', behavior: 'smooth' })
  127. message.classList.remove('message--revealed')
  128. requestAnimationFrame(() => message.classList.add('message--revealed'))
  129. window.setTimeout(() => message.classList.remove('message--revealed'), 1800)
  130. return true
  131. }
  132. async function copyMessage(message: UiMessage) {
  133. const text = displayContentForMessage(message.role, message.content)
  134. let copied = false
  135. try {
  136. if (navigator.clipboard?.writeText && window.isSecureContext) {
  137. await navigator.clipboard.writeText(text)
  138. copied = true
  139. }
  140. } catch { /* Fall through to the HTTP-compatible browser fallback. */ }
  141. if (!copied) {
  142. const textarea = document.createElement('textarea')
  143. textarea.value = text
  144. textarea.setAttribute('readonly', '')
  145. textarea.style.cssText = 'position:fixed;left:-9999px;top:0;opacity:0'
  146. document.body.appendChild(textarea)
  147. textarea.select()
  148. copied = document.execCommand('copy')
  149. textarea.remove()
  150. }
  151. if (!copied) throw new Error('浏览器拒绝访问剪贴板')
  152. copiedMessageId.value = message.id
  153. if (copyResetTimer !== undefined) window.clearTimeout(copyResetTimer)
  154. copyResetTimer = window.setTimeout(() => {
  155. copiedMessageId.value = ''
  156. copyResetTimer = undefined
  157. }, 1400)
  158. }
  159. function hasConversationActions(message: UiMessage): boolean {
  160. return message.role === 'user' || (message.role === 'assistant' && Boolean(message.content.trim()))
  161. }
  162. function deliveryLabel(status?: UiMessage['status']): string {
  163. return ({
  164. preparing: '正在准备附件',
  165. attached: '附件已就绪',
  166. pending: '正在发送',
  167. accepted: '已发送',
  168. failed: '发送失败',
  169. 'unknown-receipt': '回执未知,请检查后重试',
  170. } as Partial<Record<NonNullable<UiMessage['status']>, string>>)[status || 'settled'] || ''
  171. }
  172. function formatThinkingElapsed(value: number): string {
  173. const seconds = Math.max(0, Math.floor(value / 1000))
  174. return `${seconds} 秒`
  175. }
  176. watch(() => props.messages.length, async () => {
  177. if (!pinnedToBottom.value) return
  178. await nextTick()
  179. scrollToBottom('auto')
  180. })
  181. watch(() => props.messages.at(-1)?.content, async () => {
  182. if (!pinnedToBottom.value) return
  183. await nextTick()
  184. scrollToBottom('auto')
  185. })
  186. watch(showThinkingIndicator, visible => {
  187. if (thinkingTimer !== undefined) window.clearInterval(thinkingTimer)
  188. thinkingTimer = undefined
  189. if (!visible) {
  190. thinkingElapsedMs.value = 0
  191. return
  192. }
  193. thinkingStartedAt = Date.now()
  194. thinkingTimer = window.setInterval(() => { thinkingElapsedMs.value = Date.now() - thinkingStartedAt }, 250)
  195. }, { immediate: true })
  196. onMounted(() => nextTick(() => scrollToBottom('auto')))
  197. onBeforeUnmount(() => { if (thinkingTimer !== undefined) window.clearInterval(thinkingTimer) })
  198. defineExpose({ scrollToMessage, scrollToAnchor, scrollToBottom })
  199. </script>
  200. <template>
  201. <section class="timeline-frame" :class="{ 'timeline-frame--transparent': transparentHeader }">
  202. <header v-if="title || transparentHeader" class="timeline-header" :class="{ 'timeline-header--transparent': transparentHeader }">
  203. <div v-if="!transparentHeader"><h2>{{ title }}</h2><p v-if="subtitle">{{ subtitle }}</p></div>
  204. <div v-if="!transparentHeader" class="timeline-state" :title="connected ? (synced ? '实时连接与历史均已同步' : '实时连接已就绪,历史同步中') : '实时连接未就绪'">
  205. <span class="status-dot" :class="connected ? (synced ? 'status-dot--online' : 'status-dot--working') : ''" />
  206. {{ connected ? (synced ? '已同步' : '同步中') : '离线' }}
  207. </div>
  208. <slot name="header-actions" />
  209. </header>
  210. <div ref="scroller" class="timeline" @scroll.passive="onScroll">
  211. <div v-if="loading && !messages.length" class="message-skeletons" aria-label="正在加载消息">
  212. <div v-for="n in 4" :key="n" :class="{ user: n % 2 === 0 }"><i /><span /></div>
  213. </div>
  214. <div v-else-if="!messages.length && emptyLogo" class="new-chat-empty">
  215. <img class="new-chat-empty__logo" src="/brand/AppIcon-1024.png" alt="" aria-hidden="true" />
  216. <p>聊点什么</p>
  217. </div>
  218. <EmptyState v-else-if="!messages.length" icon="chat" :title="emptyTitle" :description="emptyDescription" />
  219. <div v-else class="message-stack">
  220. <div v-if="forkSourceTitle" class="fork-divider" role="separator">
  221. <span><AppIcon name="branch" :size="13" />FORK 来源 <strong>{{ forkSourceTitle }}</strong></span>
  222. </div>
  223. <button v-if="hasOlder" class="load-older" type="button" :disabled="loadingOlder" @click="emit('loadOlder')">
  224. {{ loadingOlder ? '正在加载…' : '加载更早消息' }}
  225. </button>
  226. <template v-for="row in timelineRows" :key="row.id">
  227. <TurnTrace v-if="row.kind === 'trace' && showTools" :group="row" />
  228. <template v-else-if="row.kind === 'message'">
  229. <article
  230. v-for="message in [row.message]"
  231. :key="message.id"
  232. :data-message-id="message.id"
  233. class="message"
  234. :class="[`message--${message.role}`, {
  235. 'message--failed': message.status === 'failed',
  236. 'message--tool-only': message.role === 'assistant' && !message.content && !message.reasoning && Boolean(message.tools?.length),
  237. 'message--assistant-internal': message.role === 'assistant' && !message.content.trim(),
  238. 'message--assistant-anonymous': message.role === 'assistant' && !showAssistantIdentity,
  239. }]"
  240. >
  241. <AgentAvatar v-if="message.role !== 'user' && (message.role !== 'assistant' || showAssistantIdentity)" class="message__avatar" :name="message.author || message.profile || (message.role === 'assistant' ? '夭' : '系')" :avatar="message.profile ? agentAvatars[message.profile] || '' : ''" :size="27" />
  242. <div class="message__body">
  243. <template v-if="message.timelineKind === 'delegation-complete'">
  244. <details class="delegation-event">
  245. <summary><AppIcon name="groups" :size="14" /><span><strong>子任务已完成</strong><small>{{ delegationSummary(message.timelineMetadata) }}</small></span></summary>
  246. <MarkdownContent v-if="message.content" :content="message.content" />
  247. </details>
  248. </template>
  249. <template v-else-if="message.timelineKind === 'system' && isCompactionEvent(message)">
  250. <details class="delegation-event compaction-event">
  251. <summary><AppIcon name="archive" :size="14" /><span><strong>上下文已压缩</strong><small>压缩摘要已归档 · 点击查看</small></span></summary>
  252. <MarkdownContent v-if="message.content" :content="message.content" />
  253. </details>
  254. </template>
  255. <template v-else-if="message.timelineKind === 'system'">
  256. <details class="system-event">
  257. <summary><AppIcon name="settings" :size="13" /><span>{{ systemSummary(message.content) }}</span></summary>
  258. <MarkdownContent v-if="message.content" :content="message.content" />
  259. </details>
  260. </template>
  261. <template v-else>
  262. <div v-if="message.role !== 'assistant' || showAssistantIdentity" class="message__meta">
  263. <strong><AppIcon v-if="message.isRemoteAgent" class="message__remote-agent" name="globe" :size="12" />{{ message.role === 'user' ? '你' : message.author || message.profile || (message.role === 'assistant' ? 'Agent' : '系统') }}</strong>
  264. <span v-if="message.metadata" class="message__execution">{{ message.metadata }}</span>
  265. <time>{{ formatTime(message.createdAt) }}</time>
  266. <span v-if="message.status && !['settled', 'streaming'].includes(message.status)">{{ { preparing: '准备中', attached: '附件已就绪', pending: '等待回执', accepted: '已接收', streaming: '生成中', settled: '已完成', failed: '发送失败', 'unknown-receipt': '回执未知' }[message.status] }}</span>
  267. </div>
  268. <details v-if="message.reasoning" class="message__reasoning">
  269. <summary><AppIcon name="brain" :size="13" />思考过程 · {{ message.reasoning.length }} 字</summary>
  270. <MarkdownContent :content="message.reasoning" />
  271. </details>
  272. <div v-if="message.role === 'user' && message.attachments?.length" class="message__attachments">
  273. <button v-for="attachment in message.attachments" :key="attachment.id" type="button" :class="{ 'message__attachment--image': attachment.kind === 'image' && attachment.url }" @click="emit('preview', attachment)">
  274. <img v-if="attachment.kind === 'image' && attachment.url" :src="attachment.url" :alt="attachment.name" />
  275. <span v-else><AppIcon :name="attachment.kind || 'file'" :size="17" /></span>
  276. <strong v-if="attachment.kind !== 'image' || !attachment.url">{{ attachment.name }}</strong>
  277. </button>
  278. </div>
  279. <div class="message__content">
  280. <MarkdownContent
  281. :content="displayContentForMessage(message.role, message.content)"
  282. :streaming="message.status === 'streaming'"
  283. :legacy-media="message.role === 'assistant'"
  284. :plain="message.role === 'user'"
  285. :mention-names="mentionNames"
  286. :outline-prefix="message.role === 'assistant' ? `outline-${message.id}` : ''"
  287. file-cards
  288. @file-link="(name, url) => emit('previewFile', { name, url })"
  289. />
  290. </div>
  291. <div
  292. v-if="message.role === 'user' && deliveryLabel(message.status)"
  293. class="message__delivery"
  294. :class="`message__delivery--${message.status}`"
  295. role="status"
  296. aria-live="polite"
  297. >
  298. <AppIcon :name="message.status === 'accepted' ? 'check' : message.status === 'failed' || message.status === 'unknown-receipt' ? 'alert' : 'dots'" :size="11" />
  299. {{ deliveryLabel(message.status) }}
  300. </div>
  301. <div v-if="message.role !== 'user' && message.attachments?.length" class="message__attachments">
  302. <button v-for="attachment in message.attachments" :key="attachment.id" type="button" @click="emit('preview', attachment)">
  303. <img v-if="attachment.kind === 'image' && attachment.url" :src="attachment.url" :alt="attachment.name" />
  304. <span v-else><AppIcon :name="attachment.kind || 'file'" :size="17" /></span>
  305. <strong>{{ attachment.name }}</strong>
  306. </button>
  307. </div>
  308. <div v-if="showTools && message.tools?.length" class="message__tools">
  309. <ToolTrace v-for="tool in message.tools" :key="tool.id" :tool="tool" />
  310. </div>
  311. <p v-if="message.error" class="message__error"><AppIcon name="alert" :size="13" />{{ message.error }}</p>
  312. <div v-if="hasConversationActions(message)" class="message__actions">
  313. <time v-if="message.role === 'assistant' && !showAssistantIdentity && message.createdAt" class="message__action-time">{{ formatTime(message.createdAt) }}</time>
  314. <button
  315. type="button"
  316. :class="{ 'message-action--copied': copiedMessageId === message.id }"
  317. :title="copiedMessageId === message.id ? '已复制' : '复制'"
  318. :aria-label="copiedMessageId === message.id ? '已复制' : '复制消息'"
  319. @click="copyMessage(message)"
  320. ><AppIcon :name="copiedMessageId === message.id ? 'check' : 'copy'" :size="13" /></button>
  321. <button type="button" title="引用" aria-label="引用消息" @click="emit('quote', message)"><AppIcon name="quote" :size="13" /></button>
  322. <button v-if="message.role === 'assistant'" type="button" title="从这里分支" aria-label="从这里分支" @click="emit('branch', message)"><AppIcon name="branch" :size="13" /></button>
  323. </div>
  324. </template>
  325. </div>
  326. </article>
  327. </template>
  328. </template>
  329. <div v-if="showThinkingIndicator" class="thinking-indicator" role="status" aria-live="polite" aria-label="正在思考">
  330. <span><strong>正在思考</strong><small>{{ formatThinkingElapsed(thinkingElapsedMs) }}</small></span>
  331. </div>
  332. <InteractionCard
  333. v-if="interaction"
  334. :interaction="interaction"
  335. @approve="emit('approve', $event)"
  336. @clarify="emit('clarify', $event)"
  337. />
  338. </div>
  339. </div>
  340. <Transition name="view-fade">
  341. <button v-if="showJump" class="jump-bottom" type="button" @click="scrollToBottom()">
  342. <AppIcon name="chevron-down" :size="15" />回到底部
  343. </button>
  344. </Transition>
  345. </section>
  346. </template>
  347. <style scoped>
  348. .timeline-frame { position: relative; display: flex; min-width: 0; min-height: 0; flex: 1; flex-direction: column; }
  349. .timeline-header { display: flex; z-index: 6; min-height: 62px; align-items: center; gap: 13px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--canvas) 92%, transparent); backdrop-filter: blur(16px); }
  350. .timeline-header--transparent { position: absolute; top: 0; right: 0; left: 0; min-height: 0; justify-content: flex-end; padding: 11px 14px; border: 0; background: transparent; backdrop-filter: none; pointer-events: none; }
  351. .timeline-header--transparent > * { pointer-events: auto; }
  352. .timeline-header > div:first-child { min-width: 0; flex: 1; }.timeline-header h2 { overflow: hidden; margin: 0; font-size: 14px; font-weight: 630; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }.timeline-header p { overflow: hidden; margin: 3px 0 0; color: var(--text-muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
  353. .timeline-state { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 9px; }
  354. .timeline { min-height: 0; flex: 1; overflow-y: auto; overscroll-behavior: contain; background: var(--conversation-canvas); }
  355. .message-stack { width: min(780px, 100%); min-height: 100%; margin: 0 auto; padding: 24px 24px 36px; }
  356. .timeline-frame--transparent .message-stack { padding-top: 58px; }
  357. .load-older { display: block; margin: 0 auto 18px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 9px; }.load-older:hover { background: var(--surface-soft); color: var(--text-secondary); }
  358. .message { position: relative; display: flex; max-width: 100%; gap: 10px; margin: 0 0 21px; }
  359. .message__avatar { display: grid; place-items: center; width: 27px; height: 27px; flex: 0 0 27px; border-radius: 9px; background: var(--accent); color: var(--text-on-solid); font-size: 10px; font-weight: 700; }
  360. .message__body { position: relative; min-width: 0; max-width: min(680px, calc(100% - 37px)); }
  361. .message__meta { display: flex; min-height: 20px; align-items: center; gap: 7px; color: var(--text-muted); font-size: 9px; }.message__meta strong { display: inline-flex; align-items: center; color: var(--text-primary); font-size: 11px; font-weight: 600; }.message__remote-agent { margin-right: 4px; color: var(--accent); }.message__meta span { color: var(--warning); }.message__meta .message__execution { overflow: hidden; max-width: 230px; color: var(--text-secondary); font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
  362. .message__content { color: var(--text-primary); }
  363. .message--user { justify-content: flex-end; margin-top: 27px; }
  364. .message--user .message__body { max-width: min(610px, 76%); padding: 11px 15px; border-radius: 20px 20px 6px 20px; background: #eceff3; }
  365. .dark .message--user .message__body { background: #2d323a; }
  366. .message--user .message__meta { display: none; }
  367. .message__delivery { display: flex; min-height: 18px; align-items: center; justify-content: flex-end; gap: 4px; margin: 5px 1px -4px; color: var(--text-muted); font-size: 9px; }.message__delivery--accepted { color: var(--success); }.message__delivery--failed, .message__delivery--unknown-receipt { color: var(--danger); }
  368. .thinking-indicator { display: flex; min-height: 34px; align-items: center; margin: 5px 0 20px; color: var(--text-muted); }.thinking-indicator > span { display: inline-flex; align-items: baseline; gap: 7px; }.thinking-indicator strong { color: var(--text-secondary); font-size: 11px; font-weight: 600; background: linear-gradient(90deg, var(--text-muted), var(--text-primary), var(--text-muted)); background-size: 200% 100%; background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; animation: thinking-shimmer 2.2s linear infinite; }.thinking-indicator small { font-size: 9px; font-variant-numeric: tabular-nums; }
  369. @keyframes thinking-shimmer { to { background-position: -200% 0; } }
  370. .message--system { justify-content: center; }.message--system .message__avatar, .message--system .message__meta { display: none; }.message--system .message__body { max-width: 82%; padding: 6px 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--text-muted); text-align: center; }
  371. .delegation-event { min-width: 230px; max-width: 460px; text-align: left; }.delegation-event summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; }.delegation-event summary::-webkit-details-marker { display: none; }.delegation-event summary > span { display: flex; min-width: 0; flex-direction: column; gap: 2px; }.delegation-event strong { color: var(--text-secondary); font-size: 11px; font-weight: 650; }.delegation-event small { color: var(--text-muted); font-size: 9px; }.delegation-event :deep(.markdown) { max-height: 260px; margin-top: 9px; overflow: auto; color: var(--text-secondary); font-size: 10px; }
  372. .system-event { max-width: 460px; text-align: left; }.system-event summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; color: var(--text-muted); font-size: 10px; }.system-event summary::-webkit-details-marker { display: none; }.system-event :deep(.markdown) { max-height: 220px; margin-top: 8px; overflow: auto; color: var(--text-secondary); font-size: 10px; }
  373. .message--tool-only { margin-block: 4px; }.message--tool-only .message__avatar, .message--tool-only .message__meta, .message--tool-only .message__actions { display: none; }.message--tool-only .message__body { max-width: 100%; }
  374. .message--assistant-internal { margin-bottom: 6px; }.message--assistant-internal .message__reasoning { margin-bottom: 4px; padding-bottom: 4px; }.message--assistant-internal .message__tools { margin-top: 4px; }
  375. .message--assistant-anonymous .message__body { max-width: min(680px, 100%); }
  376. .message__reasoning { max-width: 420px; margin: 3px 0 10px; padding: 0 0 8px; border: 0; border-bottom: 1px dashed var(--line-strong); color: var(--text-secondary); font-size: 11px; }.message__reasoning summary { display: flex; align-items: center; gap: 5px; list-style: none; color: var(--text-muted); cursor: pointer; font-size: 9px; }.message__reasoning summary::-webkit-details-marker { display: none; }.message__reasoning summary::before { content: '›'; color: var(--text-muted); font-size: 14px; line-height: 1; transition: transform 120ms ease; }.message__reasoning[open] summary::before { transform: rotate(90deg); }.message__reasoning :deep(.markdown) { margin-top: 8px; }
  377. .fork-divider { display: flex; align-items: center; gap: 12px; margin: 8px 0 28px; color: var(--text-muted); font-size: 10px; }.fork-divider::before, .fork-divider::after { height: 1px; flex: 1; background: var(--line); content: ''; }.fork-divider > span { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-raised); white-space: nowrap; }.fork-divider strong { max-width: 180px; overflow: hidden; color: var(--text-secondary); text-overflow: ellipsis; }
  378. .message__attachments { display: flex; margin-top: 8px; flex-wrap: wrap; gap: 7px; }.message__attachments button { display: flex; min-width: 90px; max-width: 210px; min-height: 42px; align-items: center; gap: 7px; padding: 5px 8px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text-secondary); cursor: pointer; }.message__attachments button:hover { border-color: var(--line-strong); }.message__attachments img { width: 48px; height: 48px; margin: -5px 0 -5px -8px; object-fit: cover; }.message__attachments button > span { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 7px; background: var(--surface-soft); }.message__attachments strong { min-width: 0; overflow: hidden; font-size: 10px; font-weight: 520; text-overflow: ellipsis; white-space: nowrap; }
  379. .message--user .message__attachments { margin: 0 0 9px; }.message--user .message__attachments button { width: 100%; max-width: none; min-height: 50px; padding: 7px 9px; border: 0; border-radius: 11px; background: rgba(255,255,255,.48); color: var(--text-primary); }.message--user .message__attachments button > span { width: 28px; height: 28px; background: rgba(255,255,255,.65); }.message--user .message__attachments strong { font-size: 11px; font-weight: 560; }.dark .message--user .message__attachments button { background: rgba(255,255,255,.08); }.message--user .message__attachments button.message__attachment--image { display: block; width: auto; min-width: 0; max-width: min(360px, 100%); min-height: 0; padding: 0; border: 0; border-radius: 8px; background: transparent; }.message--user .message__attachments button.message__attachment--image img { display: block; width: auto; height: auto; max-width: min(360px, 100%); max-height: 420px; margin: 0; border-radius: inherit; object-fit: contain; }
  380. .message__tools { margin-top: 9px; }.message__error { display: flex; align-items: center; gap: 5px; margin: 7px 0 0; color: var(--danger); font-size: 9px; }
  381. .message__actions { display: flex; position: absolute; left: -3px; top: 100%; gap: 2px; padding-top: 2px; opacity: 0; transition: opacity 120ms ease; }.message:hover .message__actions, .message:focus-within .message__actions { opacity: 1; }.message--user .message__actions { right: 0; left: auto; }.message__actions button { display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--text-muted); cursor: pointer; }.message__actions button:hover { background: var(--surface-soft); color: var(--text-primary); }.message__actions .message-action--copied { color: var(--success); }
  382. .message--assistant-anonymous .message__actions { align-items: center; }.message__action-time { min-width: 36px; padding: 0 4px 0 3px; color: var(--text-muted); font-size: 9px; font-variant-numeric: tabular-nums; }
  383. .message--failed .message__body { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
  384. .message--revealed .message__body { animation: reveal-message 1.8s ease; }
  385. @keyframes reveal-message { 0%, 28% { box-shadow: 0 0 0 5px var(--focus-ring); } 100% { box-shadow: 0 0 0 0 transparent; } }
  386. .jump-bottom { display: flex; position: absolute; z-index: 8; bottom: 8px; left: 50%; align-items: center; gap: 5px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-raised); color: var(--text-secondary); cursor: pointer; font-size: 9px; box-shadow: 0 6px 18px rgba(0,0,0,.1); transform: translateX(-50%); }
  387. .new-chat-empty { display: flex; min-height: 100%; align-items: center; justify-content: center; gap: 18px; padding: 12vh 24px; box-sizing: border-box; flex-direction: column; color: var(--text-muted); text-align: center; }
  388. .new-chat-empty__logo { display: block; width: min(180px, 34vw); height: auto; opacity: .18; filter: grayscale(1); }
  389. .new-chat-empty p { margin: 0; color: var(--text-secondary); font-size: 17px; font-weight: 520; letter-spacing: .02em; }
  390. .message-skeletons { width: min(760px, 100%); margin: 0 auto; padding: 35px 24px; }.message-skeletons div { display: flex; gap: 10px; margin: 0 0 25px; }.message-skeletons div.user { justify-content: flex-end; }.message-skeletons i { width: 27px; height: 27px; border-radius: 9px; background: var(--surface-hover); }.message-skeletons span { width: min(480px, 70%); height: 64px; border-radius: 12px; background: linear-gradient(90deg, var(--surface-soft), var(--surface-hover), var(--surface-soft)); background-size: 200% 100%; animation: shimmer 1.5s linear infinite; }.message-skeletons .user i { display: none; }.message-skeletons .user span { width: 44%; height: 46px; }
  391. @keyframes shimmer { to { background-position: -200% 0; } }
  392. @media (max-width: 768px) {
  393. .timeline-header { min-height: 54px; padding: 8px 12px; }.timeline-state { font-size: 0; }.timeline-state .status-dot { width: 7px; height: 7px; }
  394. .new-chat-empty { gap: 15px; padding-block: 9vh; }.new-chat-empty__logo { width: min(150px, 42vw); }.new-chat-empty p { font-size: 16px; }
  395. .message-stack { padding: 18px 14px 30px; }.message { margin-bottom: 18px; }.message__body { max-width: calc(100% - 37px); }.message--user .message__body { max-width: 88%; }.message__content :deep(.markdown) { font-size: 13px; }
  396. .message__actions { opacity: .65; }.message__meta time { display: none; }
  397. }
  398. @media (prefers-reduced-motion: reduce) { .thinking-indicator strong { animation: none; } }
  399. </style>