MessageTimeline.vue 32 KB

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