WorkspaceShell.vue 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896
  1. <script setup lang="ts">
  2. import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
  3. import { useRoute, useRouter } from 'vue-router'
  4. import type { Profile } from '@shared/types'
  5. import AgentAvatar from '@/components/common/AgentAvatar.vue'
  6. import AccountInitialAvatar from '@/components/common/AccountInitialAvatar.vue'
  7. import type { ProfileIdentityInput } from '@/api/profiles'
  8. import AppIcon from '@/components/common/AppIcon.vue'
  9. import BrandMark from '@/components/common/BrandMark.vue'
  10. import SettingsCenterDialog from '@/components/app/SettingsCenterDialog.vue'
  11. import { rememberInterfacePath } from '@/utils/interfaceMode'
  12. import YaoYaoSidebarIcon from '@/components/common/YaoYaoSidebarIcon.vue'
  13. type NavItem = {
  14. key: 'chat' | 'groups' | 'kanban' | 'files'
  15. label: string
  16. path: string
  17. icon: 'chat' | 'groups' | 'board' | 'files'
  18. }
  19. type SettingsPage =
  20. | 'agent-identity'
  21. | 'agent-models'
  22. | 'account-security'
  23. | 'account-mobile'
  24. | 'appearance'
  25. | 'system-overview'
  26. | 'system-users'
  27. | 'system-connection'
  28. | 'system-push'
  29. | 'system-nodes'
  30. | 'system-voice'
  31. | 'system-update'
  32. const SIDEBAR_COLLAPSED_KEY = 'hermes-yaoyao:sidebar-collapsed'
  33. const SIDEBAR_SEARCH_EVENT = 'hermes-yaoyao:sidebar-search'
  34. const SIDEBAR_SEARCH_CLOSE_EVENT = 'hermes-yaoyao:sidebar-search-close'
  35. const props = withDefaults(defineProps<{
  36. userName?: string
  37. pairingUserName?: string
  38. activeProfile?: Profile
  39. profiles?: Profile[]
  40. theme?: 'light' | 'dark'
  41. themePreference?: 'light' | 'dark' | 'system'
  42. insecureTransport?: boolean
  43. sidebarTitle?: string
  44. sidebarSubtitle?: string
  45. sidebarContextTitle?: string
  46. sidebarFocusMode?: boolean
  47. inspectorOpen?: boolean
  48. inspectorCloseLabel?: string
  49. isAdmin?: boolean
  50. upstreamReady?: boolean
  51. upstreamError?: string
  52. identityBusy?: boolean
  53. identityError?: string
  54. identityResetVersion?: number
  55. }>(), {
  56. userName: '',
  57. pairingUserName: '',
  58. activeProfile: undefined,
  59. profiles: () => [],
  60. theme: 'light',
  61. themePreference: 'system',
  62. insecureTransport: false,
  63. sidebarTitle: '',
  64. sidebarSubtitle: '',
  65. sidebarContextTitle: '',
  66. sidebarFocusMode: false,
  67. inspectorOpen: false,
  68. inspectorCloseLabel: '关闭预览',
  69. isAdmin: false,
  70. upstreamReady: false,
  71. upstreamError: '',
  72. identityBusy: false,
  73. identityError: '',
  74. identityResetVersion: 0,
  75. })
  76. const emit = defineEmits<{
  77. logout: []
  78. toggleTheme: []
  79. setTheme: [theme: 'light' | 'dark' | 'system']
  80. selectProfile: [profile: string]
  81. saveIdentity: [input: ProfileIdentityInput]
  82. closeInspector: []
  83. createAgent: []
  84. createGroup: []
  85. }>()
  86. const route = useRoute()
  87. const router = useRouter()
  88. const mobileDrawerOpen = ref(false)
  89. const profileMenuOpen = ref(false)
  90. const settingsOpen = ref(false)
  91. const settingsPage = ref<SettingsPage>('agent-identity')
  92. const settingsReturnFocus = ref<HTMLButtonElement>()
  93. const mobileNavigationTrigger = ref<HTMLButtonElement>()
  94. const mobileDrawerClose = ref<HTMLButtonElement>()
  95. const profileMenuTrigger = ref<HTMLButtonElement>()
  96. const sidebarCollapsed = ref(false)
  97. const sidebarSearchOpen = ref(false)
  98. const createMenuOpen = ref(false)
  99. const createMenu = ref<HTMLElement | null>(null)
  100. let createTrigger: HTMLElement | null = null
  101. const createPosition = ref({ left: '8px', top: '58px' })
  102. const settingsMenuOpen = ref(false)
  103. const settingsMenu = ref<HTMLElement | null>(null)
  104. let settingsTrigger: HTMLButtonElement | null = null
  105. const settingsMenuPosition = ref({ left: '8px', top: '8px' })
  106. const desktopSidebarContext = ref<HTMLElement | null>(null)
  107. const mobileSidebarContext = ref<HTMLElement | null>(null)
  108. function profileTitle(profile?: Profile): string {
  109. return profile?.agentName || profile?.displayName || profile?.name || '未选择 Agent'
  110. }
  111. const navItems: NavItem[] = [
  112. { key: 'chat', label: '原生对话', path: '/chat', icon: 'chat' },
  113. { key: 'groups', label: '聊天', path: '/conversations', icon: 'groups' },
  114. { key: 'kanban', label: '看板', path: '/kanban', icon: 'board' },
  115. { key: 'files', label: '文件库', path: '/files', icon: 'files' },
  116. ]
  117. // The active workspace is already represented by its main canvas and sidebar
  118. // context. Keep this strip focused on destinations the user can switch to.
  119. const featureNavItems = computed(() => navItems.filter(item => item.key !== 'groups' && item.key !== activeNav.value.key
  120. ))
  121. const applicationWorkspace = computed(() => route.path.startsWith('/conversations'))
  122. const activeNav = computed(() => {
  123. const item = navItems.find(entry => route.path.startsWith(entry.path))
  124. return item ?? navItems[0]
  125. })
  126. const contextHeading = computed(() => ({
  127. chat: '历史记录',
  128. groups: '聊天列表',
  129. kanban: '看板列表',
  130. files: '历史记录',
  131. })[activeNav.value.key])
  132. const hasPrimaryAction = computed(() => ['chat', 'groups', 'kanban', 'files'].includes(activeNav.value.key))
  133. async function navigate(path: string) {
  134. mobileDrawerOpen.value = false
  135. rememberInterfacePath(path)
  136. await router.push(path)
  137. }
  138. function openMobileDrawer() {
  139. mobileDrawerOpen.value = true
  140. void nextTick(() => mobileDrawerClose.value?.focus())
  141. }
  142. function closeMobileDrawer() {
  143. mobileDrawerOpen.value = false
  144. void nextTick(() => mobileNavigationTrigger.value?.focus())
  145. }
  146. function closeMenus(event: MouseEvent) {
  147. const target = event.target as HTMLElement
  148. if (!target.closest('.sidebar-account-switcher')) profileMenuOpen.value = false
  149. if (!target.closest('.workspace-create-menu, .sidebar-create-trigger')) createMenuOpen.value = false
  150. if (!target.closest('.workspace-settings-menu, .sidebar-settings-trigger')) settingsMenuOpen.value = false
  151. }
  152. function closeCreateMenu() {
  153. createMenuOpen.value = false
  154. void nextTick(() => { if (createTrigger?.isConnected) createTrigger.focus() })
  155. }
  156. async function openCreateMenu(event: Event) {
  157. if (createMenuOpen.value) { closeCreateMenu(); return }
  158. createTrigger = event.currentTarget as HTMLElement
  159. const rect = createTrigger.getBoundingClientRect()
  160. createPosition.value = { left: `${Math.max(8, Math.min(rect.left, window.innerWidth - 192))}px`, top: `${Math.max(8, Math.min(rect.bottom + 6, window.innerHeight - 96))}px` }
  161. profileMenuOpen.value = false
  162. createMenuOpen.value = true
  163. await nextTick()
  164. createMenu.value?.querySelector<HTMLButtonElement>('[role="menuitem"]')?.focus()
  165. }
  166. function chooseCreate(kind: 'agent' | 'group') {
  167. closeCreateMenu()
  168. mobileDrawerOpen.value = false
  169. if (kind === 'agent') emit('createAgent')
  170. else emit('createGroup')
  171. }
  172. function actionMenuKeydown(event: KeyboardEvent) {
  173. if (!['ArrowUp', 'ArrowDown', 'Home', 'End'].includes(event.key)) return
  174. event.preventDefault()
  175. const buttons = [...(event.currentTarget as HTMLElement).querySelectorAll<HTMLButtonElement>('[role="menuitem"]')]
  176. const index = buttons.indexOf(document.activeElement as HTMLButtonElement)
  177. buttons[event.key === 'Home' ? 0 : event.key === 'End' ? buttons.length - 1 : (index + (event.key === 'ArrowUp' ? -1 : 1) + buttons.length) % buttons.length]?.focus()
  178. }
  179. function closeSettingsMenu() {
  180. settingsMenuOpen.value = false
  181. void nextTick(() => { if (settingsTrigger?.isConnected) settingsTrigger.focus() })
  182. }
  183. async function openSettingsMenu(event: MouseEvent) {
  184. if (settingsMenuOpen.value) { closeSettingsMenu(); return }
  185. settingsTrigger = event.currentTarget as HTMLButtonElement
  186. const rect = settingsTrigger.getBoundingClientRect()
  187. settingsMenuPosition.value = { left: `${Math.max(8, Math.min(rect.right - 180, window.innerWidth - 188))}px`, top: `${Math.max(8, rect.top - 92)}px` }
  188. profileMenuOpen.value = false
  189. createMenuOpen.value = false
  190. settingsMenuOpen.value = true
  191. await nextTick()
  192. settingsMenu.value?.querySelector<HTMLButtonElement>('[role="menuitem"]')?.focus()
  193. }
  194. function chooseSettingsAction(action: 'settings' | 'bots') {
  195. settingsMenuOpen.value = false
  196. if (action === 'bots') { switchInterfaceMode(); return }
  197. settingsReturnFocus.value = settingsTrigger?.closest('.mobile-drawer')
  198. ? mobileNavigationTrigger.value : settingsTrigger ?? undefined
  199. openSettings(applicationWorkspace.value ? 'account-security' : 'agent-identity')
  200. }
  201. function switchInterfaceMode() {
  202. settingsOpen.value = false
  203. void navigate(applicationWorkspace.value ? '/chat' : '/conversations')
  204. }
  205. function workspaceKeydown(event: KeyboardEvent) {
  206. if (!applicationWorkspace.value || !(event.metaKey || event.ctrlKey) || event.key.toLowerCase() !== 'k' || settingsOpen.value || document.querySelector('dialog[open]')) return
  207. event.preventDefault()
  208. if (sidebarSearchOpen.value) document.dispatchEvent(new CustomEvent(SIDEBAR_SEARCH_CLOSE_EVENT))
  209. else void openSidebarSearch(null)
  210. }
  211. function toggleProfileMenu(event: MouseEvent) {
  212. const trigger = event.currentTarget
  213. if (trigger instanceof HTMLButtonElement) profileMenuTrigger.value = trigger
  214. profileMenuOpen.value = !profileMenuOpen.value
  215. if (!profileMenuOpen.value) return
  216. void nextTick(() => {
  217. trigger instanceof HTMLElement
  218. && trigger.closest('.sidebar-account-switcher')?.querySelector<HTMLButtonElement>('.profile-menu [role="option"][aria-selected="true"]')?.focus()
  219. })
  220. }
  221. function chooseProfile(name: string) {
  222. emit('selectProfile', name)
  223. profileMenuOpen.value = false
  224. void nextTick(() => profileMenuTrigger.value?.focus())
  225. }
  226. function handleProfileMenuKeydown(event: KeyboardEvent) {
  227. const options = [...(event.currentTarget as HTMLElement).querySelectorAll<HTMLButtonElement>('[role="option"]')]
  228. if (!options.length) return
  229. const current = Math.max(0, options.indexOf(document.activeElement as HTMLButtonElement))
  230. let next: number | undefined
  231. if (event.key === 'ArrowDown') next = (current + 1) % options.length
  232. else if (event.key === 'ArrowUp') next = (current - 1 + options.length) % options.length
  233. else if (event.key === 'Home') next = 0
  234. else if (event.key === 'End') next = options.length - 1
  235. else if (event.key === 'Escape') {
  236. event.preventDefault()
  237. profileMenuOpen.value = false
  238. void nextTick(() => profileMenuTrigger.value?.focus())
  239. return
  240. }
  241. if (next === undefined) return
  242. event.preventDefault()
  243. options[next]?.focus()
  244. }
  245. function openSettings(page: SettingsPage = 'agent-identity', event?: MouseEvent) {
  246. const trigger = event?.currentTarget
  247. if (trigger instanceof HTMLButtonElement) {
  248. settingsReturnFocus.value = trigger.closest('.mobile-drawer')
  249. ? mobileNavigationTrigger.value
  250. : trigger
  251. }
  252. profileMenuOpen.value = false
  253. mobileDrawerOpen.value = false
  254. settingsPage.value = page
  255. settingsOpen.value = true
  256. }
  257. function closeSettings() {
  258. settingsOpen.value = false
  259. void nextTick(() => settingsReturnFocus.value?.focus())
  260. }
  261. function toggleSidebar() {
  262. createMenuOpen.value = false
  263. settingsMenuOpen.value = false
  264. sidebarCollapsed.value = !sidebarCollapsed.value
  265. try { localStorage.setItem(SIDEBAR_COLLAPSED_KEY, sidebarCollapsed.value ? '1' : '0') } catch { /* optional persistence */ }
  266. }
  267. function navIcon(key: NavItem['key']): 'chat' | 'folder' | 'people' | 'board' {
  268. return key === 'groups' ? 'people' : key === 'kanban' ? 'board' : key === 'files' ? 'folder' : 'chat'
  269. }
  270. async function openSidebarSearch(host: HTMLElement | null) {
  271. if (applicationWorkspace.value) {
  272. createMenuOpen.value = false
  273. sidebarSearchOpen.value = true
  274. document.dispatchEvent(new CustomEvent(SIDEBAR_SEARCH_EVENT, { detail: { section: 'groups' } }))
  275. return
  276. }
  277. if (sidebarCollapsed.value) {
  278. sidebarCollapsed.value = false
  279. try { localStorage.setItem(SIDEBAR_COLLAPSED_KEY, '0') } catch { /* optional persistence */ }
  280. await nextTick()
  281. }
  282. sidebarSearchOpen.value = true
  283. document.dispatchEvent(new CustomEvent(SIDEBAR_SEARCH_EVENT, { detail: { section: activeNav.value.key } }))
  284. await nextTick()
  285. host?.querySelector<HTMLInputElement>('input[type="search"]')?.focus()
  286. }
  287. async function closeSidebarSearch(host: HTMLElement | null, clear = false, restoreFocus = false) {
  288. const input = host?.querySelector<HTMLInputElement>('input[type="search"]')
  289. if (clear && input?.value) {
  290. input.value = ''
  291. input.dispatchEvent(new Event('input', { bubbles: true }))
  292. }
  293. sidebarSearchOpen.value = false
  294. document.dispatchEvent(new CustomEvent(SIDEBAR_SEARCH_CLOSE_EVENT))
  295. input?.blur()
  296. if (restoreFocus) {
  297. await nextTick()
  298. host?.closest('aside')?.querySelector<HTMLButtonElement>('.sidebar-search-trigger')?.focus()
  299. }
  300. }
  301. function handleSidebarInput(event: Event) {
  302. const input = event.target as HTMLInputElement
  303. if (input.matches('input[type="search"]') && !input.value) void closeSidebarSearch(input.closest('.sidebar-context'))
  304. }
  305. function handleSidebarFocusout(event: FocusEvent) {
  306. const input = event.target as HTMLInputElement
  307. if (input.matches('input[type="search"]') && !input.value) void closeSidebarSearch(input.closest('.sidebar-context'))
  308. }
  309. function handleSidebarSearchClosed() { sidebarSearchOpen.value = false }
  310. watch(() => route.fullPath, () => { mobileDrawerOpen.value = false; createMenuOpen.value = false; settingsMenuOpen.value = false })
  311. watch(() => activeNav.value.key, () => {
  312. sidebarSearchOpen.value = false
  313. profileMenuOpen.value = false
  314. })
  315. onMounted(() => {
  316. try { sidebarCollapsed.value = localStorage.getItem(SIDEBAR_COLLAPSED_KEY) === '1' } catch { /* optional persistence */ }
  317. document.addEventListener('mousedown', closeMenus)
  318. document.addEventListener(SIDEBAR_SEARCH_CLOSE_EVENT, handleSidebarSearchClosed)
  319. document.addEventListener('keydown', workspaceKeydown)
  320. })
  321. onBeforeUnmount(() => {
  322. document.removeEventListener('mousedown', closeMenus)
  323. document.removeEventListener(SIDEBAR_SEARCH_CLOSE_EVENT, handleSidebarSearchClosed)
  324. document.removeEventListener('keydown', workspaceKeydown)
  325. })
  326. </script>
  327. <template>
  328. <div class="workspace-shell" :class="{ 'workspace-shell--collapsed': sidebarCollapsed && !applicationWorkspace, 'workspace-shell--sidebar-focused': sidebarFocusMode, 'workspace-shell--conversations': applicationWorkspace, 'workspace-shell--conversation-open': applicationWorkspace && !!route.params.id }" :inert="settingsOpen || (applicationWorkspace && sidebarSearchOpen)">
  329. <header class="mobile-header" :inert="mobileDrawerOpen">
  330. <button ref="mobileNavigationTrigger" class="icon-button" type="button" aria-label="打开导航" @click="openMobileDrawer">
  331. <AppIcon name="menu" :size="20" />
  332. </button>
  333. <button class="mobile-brand" type="button" aria-label="返回聊天" @click="navigate(applicationWorkspace ? '/conversations' : '/chat')">
  334. <BrandMark :size="28" compact />
  335. </button>
  336. <button class="icon-button" type="button" :aria-label="theme === 'dark' ? '切换浅色主题' : '切换深色主题'" @click="emit('toggleTheme')">
  337. <AppIcon :name="theme === 'dark' ? 'sun' : 'moon'" />
  338. </button>
  339. </header>
  340. <aside
  341. class="desktop-sidebar rail"
  342. :class="{ 'desktop-sidebar--collapsed': sidebarCollapsed && !applicationWorkspace }"
  343. aria-label="主导航"
  344. :inert="mobileDrawerOpen"
  345. >
  346. <div v-if="applicationWorkspace" class="bot-list-header">
  347. <button class="bot-logo-trigger sidebar-brand" type="button" aria-label="返回 Bot 列表" title="夭夭 Web" @click="navigate('/conversations')"><BrandMark :size="32" :label="false" compact bare /></button>
  348. <span class="bot-list-header__spacer" />
  349. <button class="bot-list-toolbar-button sidebar-search-trigger" type="button" aria-label="搜索" :aria-expanded="sidebarSearchOpen" @click="openSidebarSearch(desktopSidebarContext)"><AppIcon name="search" :size="21" /></button>
  350. <button class="bot-list-toolbar-button sidebar-create-trigger" type="button" aria-label="新建" aria-haspopup="menu" :aria-expanded="createMenuOpen" @click="openCreateMenu"><AppIcon name="plus" :size="23" /></button>
  351. </div>
  352. <div v-else class="sidebar-brand-row">
  353. <button class="rail__brand sidebar-brand" type="button" aria-label="返回聊天" title="夭夭 Web" @click="navigate(applicationWorkspace ? '/conversations' : '/chat')">
  354. <BrandMark :size="sidebarCollapsed ? 26 : 32" :label="false" compact bare />
  355. </button>
  356. </div>
  357. <button
  358. v-if="!applicationWorkspace"
  359. class="sidebar-collapse"
  360. :class="{ 'sidebar-collapse--collapsed': sidebarCollapsed }"
  361. type="button"
  362. :aria-label="sidebarCollapsed ? '展开侧边栏' : '折叠侧边栏'"
  363. :title="sidebarCollapsed ? '展开侧边栏' : '折叠侧边栏'"
  364. @click="toggleSidebar"
  365. >
  366. <AppIcon name="chevron-left" :size="18" />
  367. </button>
  368. <button
  369. v-if="!applicationWorkspace && !['files', 'kanban'].includes(activeNav.key)"
  370. class="sidebar-search-trigger"
  371. :class="{ 'sidebar-search-trigger--searching': sidebarSearchOpen && !applicationWorkspace }"
  372. type="button"
  373. aria-label="搜索"
  374. title="搜索"
  375. :aria-expanded="sidebarSearchOpen"
  376. :aria-hidden="sidebarSearchOpen && !applicationWorkspace ? 'true' : undefined"
  377. :tabindex="sidebarSearchOpen && !applicationWorkspace ? -1 : 0"
  378. @click="openSidebarSearch(desktopSidebarContext)"
  379. >
  380. <YaoYaoSidebarIcon name="search" />
  381. <span>搜索</span>
  382. </button>
  383. <div v-if="hasPrimaryAction && !applicationWorkspace" class="sidebar-primary-action">
  384. <slot name="sidebar-action" />
  385. </div>
  386. <nav v-if="!applicationWorkspace" class="sidebar-feature-nav" aria-label="功能入口">
  387. <button
  388. v-for="item in featureNavItems"
  389. :key="item.key"
  390. type="button"
  391. :class="{ active: activeNav.key === item.key }"
  392. :aria-current="activeNav.key === item.key ? 'page' : undefined"
  393. :title="item.label"
  394. @click="navigate(item.path)"
  395. >
  396. <YaoYaoSidebarIcon :name="navIcon(item.key)" />
  397. <span>{{ item.label }}</span>
  398. </button>
  399. </nav>
  400. <section
  401. ref="desktopSidebarContext"
  402. class="sidebar-context"
  403. :class="{ 'sidebar-context--searching': sidebarSearchOpen }"
  404. @keydown.esc.capture="closeSidebarSearch(desktopSidebarContext, true, true)"
  405. @input.capture="handleSidebarInput"
  406. @focusout.capture="handleSidebarFocusout"
  407. >
  408. <slot name="sidebar-before-heading" />
  409. <header v-if="!applicationWorkspace" class="sidebar-context__heading">
  410. <strong>{{ sidebarContextTitle || contextHeading }}</strong>
  411. <span v-if="sidebarSubtitle">{{ sidebarSubtitle }}</span>
  412. </header>
  413. <div class="sidebar-context__body">
  414. <slot name="sidebar" />
  415. </div>
  416. </section>
  417. <div class="sidebar-footer">
  418. <div class="sidebar-account-switcher">
  419. <button class="sidebar-account-switcher__main" type="button" :title="applicationWorkspace ? '当前账号' : `切换 Agent:${profileTitle(activeProfile)}`" :aria-haspopup="applicationWorkspace ? undefined : 'listbox'" :aria-expanded="applicationWorkspace ? undefined : profileMenuOpen" @click="applicationWorkspace ? openSettings('account-security', $event) : toggleProfileMenu($event)">
  420. <AccountInitialAvatar v-if="applicationWorkspace" :name="userName" :size="30" />
  421. <AgentAvatar v-else :name="profileTitle(activeProfile)" :avatar="activeProfile?.agentAvatar || ''" :size="30" />
  422. <span class="account-copy">
  423. <strong>{{ applicationWorkspace ? userName : profileTitle(activeProfile) }}</strong>
  424. <span>{{ applicationWorkspace ? '当前账号' : activeProfile?.name || userName || '未选择 Agent' }}</span>
  425. </span>
  426. <AppIcon v-if="!applicationWorkspace" class="sidebar-account-switcher__chevron" name="chevron-down" :size="14" />
  427. </button>
  428. <button class="sidebar-settings-trigger" type="button" title="设置与模式" aria-label="设置与模式" aria-haspopup="menu" :aria-expanded="settingsMenuOpen" @click="openSettingsMenu">
  429. <AppIcon name="settings" :size="17" />
  430. </button>
  431. <Transition name="menu-fade">
  432. <div v-if="profileMenuOpen" class="profile-menu" role="listbox" aria-label="切换 Agent" @keydown="handleProfileMenuKeydown">
  433. <strong class="profile-menu__heading">切换 Agent</strong>
  434. <button
  435. v-for="profile in profiles"
  436. :key="profile.name"
  437. type="button"
  438. role="option"
  439. :class="{ active: profile.name === activeProfile?.name }"
  440. :aria-selected="profile.name === activeProfile?.name"
  441. @click="chooseProfile(profile.name)"
  442. >
  443. <AgentAvatar :name="profileTitle(profile)" :avatar="profile.agentAvatar || ''" :size="24" />
  444. <strong>{{ profileTitle(profile) }}</strong>
  445. <AppIcon v-if="profile.name === activeProfile?.name" name="check" :size="15" />
  446. </button>
  447. </div>
  448. </Transition>
  449. </div>
  450. </div>
  451. </aside>
  452. <Transition name="drawer-fade">
  453. <button v-if="mobileDrawerOpen" class="drawer-scrim" type="button" aria-label="关闭导航" @click="closeMobileDrawer" />
  454. </Transition>
  455. <aside
  456. class="mobile-drawer"
  457. :class="{ 'mobile-drawer--open': mobileDrawerOpen, 'mobile-drawer--focused': sidebarFocusMode }"
  458. aria-label="移动导航"
  459. :aria-hidden="!mobileDrawerOpen"
  460. :inert="!mobileDrawerOpen"
  461. >
  462. <div class="mobile-drawer__header">
  463. <button class="sidebar-brand" type="button" aria-label="返回聊天" @click="navigate(applicationWorkspace ? '/conversations' : '/chat')">
  464. <BrandMark :size="32" compact />
  465. </button>
  466. <div class="mobile-drawer__actions"><button ref="mobileDrawerClose" class="icon-button" type="button" aria-label="关闭导航" @click="closeMobileDrawer">
  467. <AppIcon name="close" />
  468. </button><button v-if="applicationWorkspace" class="sidebar-create-trigger" type="button" aria-label="新建" title="新建" aria-haspopup="menu" :aria-expanded="createMenuOpen" @click="openCreateMenu"><AppIcon name="plus" :size="19" /></button></div>
  469. </div>
  470. <button
  471. v-if="!applicationWorkspace && !['files', 'kanban'].includes(activeNav.key)"
  472. class="sidebar-search-trigger"
  473. :class="{ 'sidebar-search-trigger--searching': sidebarSearchOpen && !applicationWorkspace }"
  474. type="button"
  475. aria-label="搜索"
  476. title="搜索"
  477. :aria-expanded="sidebarSearchOpen"
  478. :aria-hidden="sidebarSearchOpen && !applicationWorkspace ? 'true' : undefined"
  479. :tabindex="sidebarSearchOpen && !applicationWorkspace ? -1 : 0"
  480. @click="openSidebarSearch(mobileSidebarContext)"
  481. >
  482. <AppIcon name="search" :size="18" />
  483. <span>搜索</span>
  484. </button>
  485. <div v-if="hasPrimaryAction && !applicationWorkspace" class="sidebar-primary-action">
  486. <slot name="sidebar-action" />
  487. </div>
  488. <nav v-if="!applicationWorkspace" class="sidebar-feature-nav" aria-label="功能入口">
  489. <button
  490. v-for="item in featureNavItems"
  491. :key="item.key"
  492. type="button"
  493. :class="{ active: activeNav.key === item.key }"
  494. :aria-current="activeNav.key === item.key ? 'page' : undefined"
  495. @click="navigate(item.path)"
  496. >
  497. <AppIcon :name="item.icon" :size="18" />
  498. <span>{{ item.label }}</span>
  499. </button>
  500. </nav>
  501. <section
  502. ref="mobileSidebarContext"
  503. class="sidebar-context mobile-drawer__context"
  504. :class="{ 'sidebar-context--searching': sidebarSearchOpen }"
  505. @keydown.esc.capture="closeSidebarSearch(mobileSidebarContext, true, true)"
  506. @input.capture="handleSidebarInput"
  507. @focusout.capture="handleSidebarFocusout"
  508. >
  509. <slot name="sidebar-before-heading" />
  510. <header v-if="!applicationWorkspace" class="sidebar-context__heading">
  511. <strong>{{ sidebarContextTitle || contextHeading }}</strong>
  512. <span v-if="sidebarSubtitle">{{ sidebarSubtitle }}</span>
  513. </header>
  514. <div class="sidebar-context__body">
  515. <slot name="mobile-sidebar" />
  516. </div>
  517. </section>
  518. <div class="sidebar-footer mobile-drawer__footer">
  519. <div class="sidebar-account-switcher">
  520. <button class="sidebar-account-switcher__main" type="button" :title="applicationWorkspace ? '当前账号' : `切换 Agent:${profileTitle(activeProfile)}`" :aria-haspopup="applicationWorkspace ? undefined : 'listbox'" :aria-expanded="applicationWorkspace ? undefined : profileMenuOpen" @click="applicationWorkspace ? openSettings('account-security', $event) : toggleProfileMenu($event)">
  521. <AccountInitialAvatar v-if="applicationWorkspace" :name="userName" :size="30" />
  522. <AgentAvatar v-else :name="profileTitle(activeProfile)" :avatar="activeProfile?.agentAvatar || ''" :size="30" />
  523. <span class="account-copy">
  524. <strong>{{ applicationWorkspace ? userName : profileTitle(activeProfile) }}</strong>
  525. <span>{{ applicationWorkspace ? '当前账号' : activeProfile?.name || userName || '未选择 Agent' }}</span>
  526. </span>
  527. <AppIcon v-if="!applicationWorkspace" class="sidebar-account-switcher__chevron" name="chevron-down" :size="14" />
  528. </button>
  529. <button class="sidebar-settings-trigger" type="button" title="设置与模式" aria-label="设置与模式" aria-haspopup="menu" :aria-expanded="settingsMenuOpen" @click="openSettingsMenu">
  530. <AppIcon name="settings" :size="17" />
  531. </button>
  532. <Transition name="menu-fade">
  533. <div v-if="profileMenuOpen" class="profile-menu" role="listbox" aria-label="切换 Agent" @keydown="handleProfileMenuKeydown">
  534. <strong class="profile-menu__heading">切换 Agent</strong>
  535. <button
  536. v-for="profile in profiles"
  537. :key="profile.name"
  538. type="button"
  539. role="option"
  540. :class="{ active: profile.name === activeProfile?.name }"
  541. :aria-selected="profile.name === activeProfile?.name"
  542. @click="chooseProfile(profile.name)"
  543. >
  544. <AgentAvatar :name="profileTitle(profile)" :avatar="profile.agentAvatar || ''" :size="24" />
  545. <strong>{{ profileTitle(profile) }}</strong>
  546. <AppIcon v-if="profile.name === activeProfile?.name" name="check" :size="15" />
  547. </button>
  548. </div>
  549. </Transition>
  550. </div>
  551. </div>
  552. </aside>
  553. <main class="workspace-main" :inert="mobileDrawerOpen">
  554. <slot />
  555. </main>
  556. <Transition name="inspector-slide">
  557. <aside v-if="inspectorOpen" class="workspace-inspector">
  558. <div class="workspace-inspector__close">
  559. <button class="icon-button" type="button" :aria-label="inspectorCloseLabel" :title="inspectorCloseLabel" @click="emit('closeInspector')">
  560. <AppIcon name="close" />
  561. </button>
  562. </div>
  563. <slot name="inspector" />
  564. </aside>
  565. </Transition>
  566. <SettingsCenterDialog
  567. :open="settingsOpen"
  568. :bot-mode="applicationWorkspace"
  569. @switch-mode="switchInterfaceMode"
  570. :initial-page="settingsPage"
  571. :user-name="userName"
  572. :pairing-user-name="pairingUserName"
  573. :active-profile="activeProfile"
  574. :profiles="profiles"
  575. :theme="theme"
  576. :theme-preference="themePreference"
  577. :insecure-transport="insecureTransport"
  578. :is-admin="isAdmin"
  579. :upstream-ready="upstreamReady"
  580. :upstream-error="upstreamError"
  581. :identity-busy="identityBusy"
  582. :identity-error="identityError"
  583. :identity-reset-version="identityResetVersion"
  584. @close="closeSettings"
  585. @logout="emit('logout')"
  586. @select-profile="emit('selectProfile', $event)"
  587. @save-identity="emit('saveIdentity', $event)"
  588. @set-theme="emit('setTheme', $event)"
  589. />
  590. <Teleport to="body">
  591. <div v-if="settingsMenuOpen" class="workspace-create-dismiss" @pointerdown.self="closeSettingsMenu" @keydown.esc.prevent.stop="closeSettingsMenu">
  592. <div ref="settingsMenu" class="workspace-create-menu workspace-settings-menu" :style="settingsMenuPosition" role="menu" aria-label="设置与模式" @keydown="actionMenuKeydown">
  593. <button type="button" role="menuitem" @click="chooseSettingsAction('settings')"><AppIcon name="settings" :size="17" />进入设置</button>
  594. <button type="button" role="menuitem" @click="chooseSettingsAction('bots')"><AppIcon :name="applicationWorkspace ? 'chat' : 'users'" :size="17" />{{ applicationWorkspace ? '进入聊天模式' : '进入 Bot 模式' }}</button>
  595. </div>
  596. </div>
  597. <div v-if="createMenuOpen" class="workspace-create-dismiss" @pointerdown.self="closeCreateMenu" @keydown.esc.prevent.stop="closeCreateMenu">
  598. <div ref="createMenu" class="workspace-create-menu" :style="createPosition" role="menu" aria-label="新建聊天" @keydown="actionMenuKeydown">
  599. <button type="button" role="menuitem" @click="chooseCreate('agent')"><AppIcon name="users" :size="17" />新建 Bot</button>
  600. <button type="button" role="menuitem" @click="chooseCreate('group')"><AppIcon name="groups" :size="17" />新建群聊</button>
  601. </div>
  602. </div>
  603. </Teleport>
  604. </div>
  605. </template>
  606. <style scoped>
  607. .workspace-shell {
  608. display: grid;
  609. grid-template-columns: 264px minmax(0, 1fr) auto;
  610. width: 100%;
  611. height: 100%;
  612. min-width: 0;
  613. overflow: hidden;
  614. background: var(--canvas);
  615. transition: grid-template-columns 180ms var(--ease-out);
  616. }
  617. .workspace-shell--conversations { grid-template-columns: 360px minmax(0, 1fr) auto; }
  618. .workspace-shell--collapsed { grid-template-columns: 68px minmax(0, 1fr) auto; }
  619. .mobile-header, .mobile-drawer, .drawer-scrim { display: none; }
  620. .desktop-sidebar {
  621. --sidebar-search-top: 58px;
  622. position: relative;
  623. z-index: 20;
  624. display: flex;
  625. min-width: 0;
  626. min-height: 0;
  627. flex-direction: column;
  628. overflow: hidden;
  629. border-right: 1px solid var(--line);
  630. background: var(--surface);
  631. color: var(--text-primary);
  632. }
  633. .sidebar-brand-row { display: flex; min-height: 58px; align-items: center; padding: 9px 20px 7px; }
  634. .sidebar-brand { display: flex; min-width: 0; align-items: center; padding: 0; border: 0; border-radius: 10px; background: transparent; cursor: pointer; }
  635. .sidebar-brand:hover { background: transparent; }
  636. .sidebar-collapse {
  637. display: grid;
  638. width: 34px;
  639. height: 34px;
  640. flex: 0 0 34px;
  641. place-items: center;
  642. padding: 0;
  643. border: 0;
  644. border-radius: 9px;
  645. background: transparent;
  646. color: var(--text-muted);
  647. cursor: pointer;
  648. }
  649. .sidebar-collapse:hover { background: var(--surface-hover); color: var(--text-primary); }
  650. .sidebar-collapse { position: absolute; top: 12px; right: 11px; transition: transform 180ms var(--ease-out), color 140ms ease, background-color 140ms ease; }
  651. .sidebar-collapse--collapsed { transform: rotate(180deg); }
  652. .sidebar-search-trigger,
  653. .sidebar-feature-nav button {
  654. display: flex;
  655. width: calc(100% - 20px);
  656. min-height: 36px;
  657. align-items: center;
  658. gap: 11px;
  659. margin-inline: 10px;
  660. padding: 0 11px;
  661. border: 0;
  662. border-radius: 10px;
  663. background: transparent;
  664. color: var(--text-primary);
  665. cursor: pointer;
  666. text-align: left;
  667. font-size: 14px;
  668. font-weight: 650;
  669. }
  670. .sidebar-search-trigger:hover,
  671. .sidebar-search-trigger[aria-expanded="true"],
  672. .sidebar-feature-nav button:hover,
  673. .sidebar-feature-nav button.active { background: var(--surface-soft); }
  674. .sidebar-search-trigger[aria-expanded="true"] { box-shadow: 0 0 0 3px var(--focus-ring); }
  675. .sidebar-search-trigger--searching { visibility: hidden; pointer-events: none; }
  676. .desktop-sidebar .sidebar-context--searching :deep(.sidebar-search),
  677. .desktop-sidebar .sidebar-context--searching :deep(.library-search),
  678. .mobile-drawer .sidebar-context--searching :deep(.sidebar-search),
  679. .mobile-drawer .sidebar-context--searching :deep(.library-search) {
  680. position: absolute;
  681. z-index: 40;
  682. top: var(--sidebar-search-top);
  683. left: 10px;
  684. width: calc(100% - 20px);
  685. min-height: 36px;
  686. margin: 0;
  687. background: var(--surface);
  688. }
  689. .sidebar-primary-action { margin: 3px 10px; }
  690. .sidebar-primary-action :deep(button) {
  691. display: flex;
  692. width: 100%;
  693. min-height: 36px;
  694. align-items: center;
  695. justify-content: flex-start;
  696. gap: 11px;
  697. padding: 0 11px;
  698. border: 0;
  699. border-radius: 10px;
  700. background: transparent;
  701. color: var(--text-primary);
  702. cursor: pointer;
  703. font-size: 14px;
  704. font-weight: 650;
  705. }
  706. .sidebar-primary-action :deep(button:hover),
  707. .sidebar-primary-action :deep(button:focus-visible) { background: var(--surface-soft); }
  708. .sidebar-primary-action :deep(button:focus-visible) { outline: 0; box-shadow: inset 0 0 0 1px var(--line-strong); }
  709. .sidebar-primary-action :deep(button:active) { background: var(--surface-hover); }
  710. .sidebar-primary-action :deep(button > span) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  711. .sidebar-feature-nav { display: flex; flex-direction: column; gap: 1px; padding: 0 0 9px; }
  712. .sidebar-feature-nav button { margin-block: 0; font-weight: 680; }
  713. .sidebar-feature-nav button.active { font-weight: 740; }
  714. .sidebar-context { display: flex; min-height: 0; flex: 1; flex-direction: column; overflow: hidden; }
  715. .sidebar-context__heading { display: flex; min-height: 35px; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 20px 5px 21px; }
  716. .sidebar-context__heading strong { font-size: 13px; font-weight: 680; }
  717. .sidebar-context__heading span { overflow: hidden; color: var(--text-muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
  718. .sidebar-context__body { min-height: 0; flex: 1; overflow: hidden; }
  719. .sidebar-context:not(.sidebar-context--searching) :deep(.library-search) { display: none; }
  720. .sidebar-context__body :deep(.library-search) { margin-bottom: 10px; }
  721. .sidebar-context__body :deep(.sidebar-list) { padding-inline: 10px; }
  722. .sidebar-context__body :deep(.sidebar-item) { min-height: 42px; padding: 5px 9px; }
  723. .sidebar-context__body :deep(.sidebar-item.sidebar-item--single-line) { min-height: 31px; padding: 1px 7px; }
  724. .sidebar-context__body :deep(.sidebar-item--single-line .sidebar-item__row strong) { font-size: 14px; font-weight: 400; }
  725. .sidebar-context__body :deep(.sidebar-item__icon) { width: 25px; height: 25px; flex-basis: 25px; border: 0; border-radius: 7px; background: transparent; }
  726. .sidebar-context__body :deep(.sidebar-item__icon--avatar) { background: transparent; color: var(--text-secondary); }
  727. .sidebar-context__body :deep(.sidebar-item__row strong) { font-size: 13px; }
  728. .sidebar-context__body :deep(.sidebar-item.sidebar-item--topic .sidebar-item__row strong) { font-size: 14px; font-weight: 450; }
  729. .sidebar-context__body :deep(.library-sidebar) { padding-top: 1px; }
  730. .sidebar-context__body :deep(.library-sidebar section) { margin-top: 2px; }
  731. .workspace-shell--sidebar-focused .desktop-sidebar .sidebar-search-trigger,
  732. .workspace-shell--sidebar-focused .desktop-sidebar > .sidebar-primary-action,
  733. .workspace-shell--sidebar-focused .desktop-sidebar .sidebar-feature-nav,
  734. .workspace-shell--sidebar-focused .desktop-sidebar .sidebar-footer { display: none; }
  735. .workspace-shell--sidebar-focused { grid-template-columns: 264px minmax(0, 1fr) auto; }
  736. .workspace-shell--sidebar-focused .desktop-sidebar .sidebar-context,
  737. .workspace-shell--sidebar-focused .desktop-sidebar--collapsed .sidebar-context { display: flex; flex: 1; }
  738. .sidebar-footer { flex: 0 0 auto; padding: 7px 10px 10px; background: var(--surface); }
  739. .sidebar-account-switcher { position: relative; z-index: 30; display: flex; min-height: 46px; align-items: center; gap: 6px; padding: 4px 2px; border-top: 1px solid var(--line); }
  740. .sidebar-account-switcher__main { display: flex; min-width: 0; min-height: 38px; flex: 1; align-items: center; gap: 9px; padding: 4px 1px; border: 0; border-radius: 8px; background: transparent; color: var(--text-primary); cursor: pointer; text-align: left; }
  741. .sidebar-account-switcher__main:hover { background: var(--surface-soft); }
  742. .sidebar-settings-trigger { display: grid; width: 38px; min-width: 38px; height: 38px; flex: 0 0 38px; place-items: center; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--text-muted); cursor: pointer; }
  743. .sidebar-settings-trigger:hover { background: var(--surface-soft); color: var(--text-primary); }
  744. .sidebar-settings-trigger:focus-visible { outline: 0; box-shadow: inset 0 0 0 1px var(--line-strong), 0 0 0 3px var(--focus-ring); }
  745. .sidebar-account__avatar { display: grid; width: 30px; height: 30px; flex: 0 0 30px; place-items: center; border-radius: 50%; background: transparent; color: var(--text-secondary); font-size: 13px; font-weight: 700; }
  746. .sidebar-account-switcher__chevron { flex: 0 0 auto; color: var(--text-muted); }
  747. .profile-menu { position: absolute; right: 0; bottom: calc(100% + 6px); left: 0; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-raised); box-shadow: var(--shadow-float); }
  748. .profile-menu__heading { display: block; padding: 8px 8px 5px; color: var(--text-muted); font-size: 11px; font-weight: 650; }
  749. .profile-menu button { display: flex; width: 100%; min-height: 38px; align-items: center; gap: 9px; padding: 5px 8px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; text-align: left; }
  750. .profile-menu button:hover, .profile-menu button.active { background: var(--surface-hover); }
  751. .profile-menu button > span:not(.agent-avatar) { display: grid; width: 25px; height: 25px; place-items: center; border-radius: 8px; background: var(--surface-soft); color: var(--text-secondary); font-size: 11px; }
  752. .profile-menu button strong { flex: 1; overflow: hidden; font-size: 13px; text-overflow: ellipsis; }
  753. .account-copy { display: flex; min-width: 0; flex: 1; flex-direction: column; }
  754. .account-copy strong, .account-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  755. .account-copy strong { font-size: 13px; font-weight: 650; }
  756. .account-copy span { color: var(--text-muted); font-size: 11px; }
  757. .desktop-sidebar--collapsed .sidebar-brand-row { padding-inline: 21px; }
  758. .desktop-sidebar--collapsed .sidebar-brand { width: 26px; flex: 0 0 26px; overflow: hidden; }
  759. .desktop-sidebar--collapsed .sidebar-collapse { position: static; width: 28px; height: 28px; flex: 0 0 28px; order: 1; align-self: center; margin-top: auto; margin-bottom: 5px; }
  760. .desktop-sidebar--collapsed .sidebar-context { display: none; }
  761. .desktop-sidebar--collapsed .sidebar-search-trigger { width: 42px; justify-content: center; margin-inline: auto; padding: 0; }
  762. .desktop-sidebar--collapsed .sidebar-search-trigger span { display: none; }
  763. .desktop-sidebar--collapsed .sidebar-primary-action { width: 42px; margin-inline: auto; }
  764. .desktop-sidebar--collapsed .sidebar-primary-action :deep(button) { width: 42px; justify-content: center; padding: 0; }
  765. .desktop-sidebar--collapsed .sidebar-primary-action :deep(button > span) { display: none; }
  766. .desktop-sidebar--collapsed .sidebar-feature-nav { align-items: center; padding: 8px 0; }
  767. .desktop-sidebar--collapsed .sidebar-feature-nav button { width: 42px; justify-content: center; margin-inline: 0; padding: 0; }
  768. .desktop-sidebar--collapsed .sidebar-feature-nav button span,
  769. .desktop-sidebar--collapsed .sidebar-account-switcher__chevron,
  770. .desktop-sidebar--collapsed .account-copy { display: none; }
  771. .desktop-sidebar--collapsed .sidebar-footer { display: flex; order: 2; margin-top: 0; flex-direction: column; align-items: center; padding: 0 8px 8px; }
  772. .desktop-sidebar--collapsed .sidebar-account-switcher { width: 42px; flex-direction: column; gap: 3px; padding: 0; border-top: 0; }
  773. .desktop-sidebar--collapsed .sidebar-account-switcher__main { width: 42px; min-height: 42px; flex: 0 0 42px; justify-content: center; padding: 0; }
  774. .desktop-sidebar--collapsed .sidebar-settings-trigger { width: 42px; min-width: 42px; height: 42px; padding: 0; }
  775. .desktop-sidebar--collapsed .profile-menu { right: auto; bottom: 0; left: calc(100% + 8px); width: 220px; }
  776. .workspace-main { position: relative; display: flex; min-width: 0; min-height: 0; flex-direction: column; overflow: hidden; background: var(--canvas); }
  777. .workspace-inspector { position: relative; width: min(390px, 34vw); min-width: 310px; min-height: 0; overflow: hidden; border-left: 1px solid var(--line); background: var(--surface); }
  778. .workspace-inspector__close { position: absolute; z-index: 5; top: 10px; right: 10px; }
  779. .menu-fade-enter-active, .menu-fade-leave-active { transition: opacity 120ms ease, transform 120ms var(--ease-out); }
  780. .menu-fade-enter-from, .menu-fade-leave-to { opacity: 0; transform: translateY(4px); }
  781. .inspector-slide-enter-active, .inspector-slide-leave-active { overflow: hidden; transition: width 180ms var(--ease-out), opacity 150ms ease; }
  782. .inspector-slide-enter-from, .inspector-slide-leave-to { width: 0; min-width: 0; opacity: 0; }
  783. @media (max-width: 900px) {
  784. .workspace-shell, .workspace-shell--collapsed { grid-template-columns: minmax(0, 1fr); grid-template-rows: 52px minmax(0, 1fr); }
  785. .mobile-header { display: flex; z-index: 24; grid-row: 1; align-items: center; justify-content: space-between; padding: max(5px, env(safe-area-inset-top)) 10px 5px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(18px); }
  786. .mobile-brand { padding: 0; border: 0; background: transparent; cursor: pointer; }
  787. .desktop-sidebar { display: none; }
  788. .workspace-main { grid-row: 2; }
  789. .drawer-scrim { display: block; position: fixed; z-index: 50; inset: 0; padding: 0; border: 0; background: var(--scrim); backdrop-filter: blur(2px); }
  790. .mobile-drawer { --sidebar-search-top: calc(max(9px, env(safe-area-inset-top)) + 49px); display: flex; position: fixed; z-index: 51; inset: 0 auto 0 0; width: min(304px, 88vw); min-height: 0; flex-direction: column; overflow: hidden; padding: max(9px, env(safe-area-inset-top)) 0 max(9px, env(safe-area-inset-bottom)); background: var(--surface); box-shadow: var(--shadow-float); transform: translateX(-102%); transition: transform 190ms var(--ease-out); }
  791. .mobile-drawer--open { transform: translateX(0); }
  792. .mobile-drawer__header { display: flex; min-height: 49px; align-items: center; justify-content: space-between; padding: 0 14px 5px 12px; }
  793. .mobile-drawer__context { margin-top: 2px; }
  794. .mobile-drawer--focused { padding-block: max(9px, env(safe-area-inset-top)) max(9px, env(safe-area-inset-bottom)); }
  795. .mobile-drawer--focused > .sidebar-search-trigger,
  796. .mobile-drawer--focused > .sidebar-primary-action,
  797. .mobile-drawer--focused > .sidebar-feature-nav,
  798. .mobile-drawer--focused > .sidebar-footer { display: none; }
  799. .mobile-drawer--focused .mobile-drawer__context { margin-top: 0; flex: 1; }
  800. .mobile-drawer__context .sidebar-context__body :deep(.resource-sidebar) { min-height: 0; flex: 1; }
  801. .mobile-drawer__footer { padding-inline: 10px; }
  802. .workspace-inspector { position: fixed; z-index: 45; inset: 52px 0 0 auto; width: min(440px, 100vw); min-width: 0; box-shadow: var(--shadow-float); }
  803. .inspector-slide-enter-from, .inspector-slide-leave-to { width: min(440px, 100vw); transform: translateX(100%); }
  804. }
  805. .drawer-fade-enter-active, .drawer-fade-leave-active { transition: opacity 160ms ease; }
  806. .drawer-fade-enter-from, .drawer-fade-leave-to { opacity: 0; }
  807. .sidebar-create-trigger{display:grid;width:34px;height:34px;flex:0 0 34px;place-items:center;padding:0;border:0;border-radius:9px;background:transparent;color:var(--text-muted);cursor:pointer}
  808. .sidebar-create-trigger:hover,.sidebar-create-trigger[aria-expanded="true"]{background:var(--surface-hover);color:var(--text-primary)}
  809. .workspace-shell--conversations .desktop-sidebar:not(.desktop-sidebar--collapsed) .sidebar-collapse{right:49px}
  810. .desktop-sidebar > .sidebar-create-trigger{position:absolute;top:12px;right:11px}
  811. .desktop-sidebar--collapsed > .sidebar-create-trigger{position:static;width:42px;height:36px;flex-basis:36px;align-self:center;margin:0 auto 4px}
  812. .mobile-drawer__actions{display:flex;align-items:center;gap:4px}
  813. .workspace-create-dismiss{position:fixed;inset:0;z-index:80}
  814. .workspace-create-menu{position:absolute;width:180px;padding:5px;border:1px solid var(--line);border-radius:11px;background:var(--surface-raised);box-shadow:var(--shadow-float)}
  815. .workspace-create-menu button{display:flex;width:100%;min-height:36px;align-items:center;gap:9px;padding:7px 10px;border:0;border-radius:7px;background:transparent;color:var(--text-primary);font:13px var(--font-ui);text-align:left;cursor:pointer}
  816. .workspace-create-menu button:hover,.workspace-create-menu button:focus-visible{outline:0;background:var(--surface-hover)}
  817. .bot-list-header{display:flex;align-items:center;gap:10px;padding:20px 20px 12px;min-height:74px}
  818. .bot-list-header__spacer{flex:1}
  819. .bot-logo-trigger{display:grid;place-items:center;padding:0;border:0;background:transparent;cursor:pointer;border-radius:50%}
  820. .bot-list-header .bot-list-toolbar-button{position:static;display:grid;place-items:center;width:42px;height:42px;min-height:42px;flex:0 0 42px;margin:0;padding:0;border:1px solid var(--line);border-radius:50%;background:var(--surface);color:var(--text-primary)}
  821. .workspace-shell--conversations .sidebar-context{margin-top:0}
  822. @media(max-width:900px){
  823. .workspace-shell--conversations{grid-template-rows:minmax(0,1fr);grid-template-columns:minmax(0,1fr)}
  824. .workspace-shell--conversations>.mobile-header,.workspace-shell--conversations>.mobile-drawer{display:none}
  825. .workspace-shell--conversations>.desktop-sidebar{display:flex;grid-row:1;border:0;padding-top:env(safe-area-inset-top)}
  826. .workspace-shell--conversations>.workspace-main{display:none;grid-row:1}
  827. .workspace-shell--conversation-open>.desktop-sidebar{display:none}
  828. .workspace-shell--conversation-open>.workspace-main{display:flex}
  829. }
  830. </style>