titlebar.tsx 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. import { createEffect, createMemo, createResource, createSignal, Match, onMount, Show, Switch, untrack } from "solid-js"
  2. import { createStore } from "solid-js/store"
  3. import { useLocation, useNavigate, useParams } from "@solidjs/router"
  4. import { IconButton } from "@opencode-ai/ui/icon-button"
  5. import { Icon } from "@opencode-ai/ui/icon"
  6. import { Button } from "@opencode-ai/ui/button"
  7. import { Tooltip, TooltipKeybind } from "@opencode-ai/ui/tooltip"
  8. import { IconButtonV2 } from "@opencode-ai/ui/v2/icon-button-v2"
  9. import { Icon as IconV2 } from "@opencode-ai/ui/v2/icon"
  10. import { KeybindV2 } from "@opencode-ai/ui/v2/keybind-v2"
  11. import { TooltipV2 } from "@opencode-ai/ui/v2/tooltip-v2"
  12. import { LayoutRoute, useLayout } from "@/context/layout"
  13. import { usePlatform } from "@/context/platform"
  14. import { useCommand } from "@/context/command"
  15. import { useLanguage } from "@/context/language"
  16. import { useSettings } from "@/context/settings"
  17. import { WindowsAppMenu } from "./windows-app-menu"
  18. import { applyPath, backPath, forwardPath } from "./titlebar-history"
  19. import { TitlebarTabStrip } from "@/components/titlebar-tab-strip"
  20. import { makeEventListener } from "@solid-primitives/event-listener"
  21. import { createMediaQuery } from "@solid-primitives/media"
  22. import { readSessionTabsRemovedDetail, SESSION_TABS_REMOVED_EVENT } from "@/components/titlebar-session-events"
  23. import { useGlobal } from "@/context/global"
  24. import { ServerConnection, useServer } from "@/context/server"
  25. import { tabKey, useTabs } from "@/context/tabs"
  26. import type { PromptSession } from "@/context/prompt"
  27. import "./titlebar.css"
  28. import { newTabTooltipKeybind } from "./command-tooltip-keybind"
  29. import { normalizeSessionInfo } from "@/utils/session"
  30. const legacyTitlebarHeight = 40
  31. const v2TitlebarHeight = 36
  32. const minTitlebarZoom = 0.25
  33. const windowsControlsBaseWidth = 138 // 3 native Windows caption buttons at 46px each.
  34. const macTrafficLightsBaseWidth = 84
  35. export type TitlebarUpdate = {
  36. version: () => string | undefined
  37. installing: () => boolean
  38. install: () => void
  39. }
  40. export function useTitlebarRightMount() {
  41. const [mount, setMount] = createSignal<HTMLElement | null>(null)
  42. onMount(() => setMount(document.getElementById("opencode-titlebar-right")))
  43. return mount
  44. }
  45. export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visible: boolean; toggle: () => void } }) {
  46. const layout = useLayout()
  47. const platform = usePlatform()
  48. const command = useCommand()
  49. const language = useLanguage()
  50. const settings = useSettings()
  51. const server = useServer()
  52. const navigate = useNavigate()
  53. const location = useLocation()
  54. const params = useParams()
  55. const useV2Titlebar = createMemo(() => settings.general.newLayoutDesigns())
  56. const mobile = createMediaQuery("(max-width: 767px)")
  57. const bottom = createMemo(() => useV2Titlebar() && mobile() && settings.general.mobileTitlebarPosition() === "bottom")
  58. const mac = createMemo(() => platform.platform === "desktop" && platform.os === "macos")
  59. const windows = createMemo(() => platform.platform === "desktop" && platform.os === "windows")
  60. const linux = createMemo(() => platform.platform === "desktop" && platform.os === "linux")
  61. const web = createMemo(() => platform.platform === "web")
  62. const macTrafficLights = createMemo(() => mac() && !platform.windowFullscreen?.())
  63. const zoom = () => platform.webviewZoom?.() ?? 1
  64. const titlebarZoom = () => (windows() ? Math.max(zoom(), minTitlebarZoom) : zoom())
  65. const counterZoom = () => (windows() && titlebarZoom() < 1 ? 1 / titlebarZoom() : 1)
  66. const minHeight = () => {
  67. const height = useV2Titlebar() ? v2TitlebarHeight : legacyTitlebarHeight
  68. if (mac()) return `${height / zoom()}px`
  69. if (windows()) return `${height / Math.min(titlebarZoom(), 1)}px`
  70. return undefined
  71. }
  72. const windowsControlsWidth = () => `${windowsControlsBaseWidth / Math.max(titlebarZoom(), 1)}px`
  73. const [history, setHistory] = createStore({
  74. stack: [] as string[],
  75. index: 0,
  76. action: undefined as "back" | "forward" | undefined,
  77. })
  78. const path = () => `${location.pathname}${location.search}${location.hash}`
  79. const creating = createMemo(() => {
  80. const route = layout.route()
  81. if (route.type === "draft" || route.type === "dir-new-sesssion") return true
  82. if (!params.dir) return false
  83. if (params.id) return false
  84. const parts = location.pathname.replace(/\/+$/, "").split("/")
  85. return parts.at(-1) === "session"
  86. })
  87. createEffect(() => {
  88. const current = path()
  89. untrack(() => {
  90. const next = applyPath(history, current)
  91. if (next === history) return
  92. setHistory(next)
  93. })
  94. })
  95. const canBack = createMemo(() => history.index > 0)
  96. const canForward = createMemo(() => history.index < history.stack.length - 1)
  97. const hasProjects = createMemo(() => layout.projects.list().length > 0)
  98. const nav = createMemo(() => (useV2Titlebar() ? settings.general.showNavigation() : true))
  99. const updateState = createMemo<TitlebarUpdatePillState>(() => {
  100. const installing = props.update?.installing() ?? false
  101. const version = props.update?.version()
  102. return {
  103. visible: version !== undefined || installing,
  104. installing,
  105. label: "Update",
  106. ariaLabel: language.t("toast.update.action.installRestart"),
  107. title: version ? `Update ${version}` : undefined,
  108. onInstall: () => props.update?.install(),
  109. }
  110. })
  111. const v2RightState = createMemo<TitlebarV2RightState>(() => ({
  112. update: updateState(),
  113. }))
  114. const back = () => {
  115. const next = backPath(history)
  116. if (!next) return
  117. setHistory(next.state)
  118. navigate(next.to)
  119. }
  120. const forward = () => {
  121. const next = forwardPath(history)
  122. if (!next) return
  123. setHistory(next.state)
  124. navigate(next.to)
  125. }
  126. command.register(() => [
  127. {
  128. id: "common.goBack",
  129. title: language.t("common.goBack"),
  130. category: language.t("command.category.view"),
  131. keybind: "mod+[",
  132. onSelect: back,
  133. },
  134. {
  135. id: "common.goForward",
  136. title: language.t("common.goForward"),
  137. category: language.t("command.category.view"),
  138. keybind: "mod+]",
  139. onSelect: forward,
  140. },
  141. ])
  142. return (
  143. <header
  144. data-slot={useV2Titlebar() ? "titlebar-v2" : undefined}
  145. classList={{
  146. "shrink-0 relative flex flex-row": true,
  147. "h-9 bg-v2-background-bg-deep overflow-visible": useV2Titlebar(),
  148. "h-10 bg-background-base overflow-hidden": !useV2Titlebar(),
  149. "order-last": bottom(),
  150. }}
  151. style={{
  152. "min-height": minHeight(),
  153. // Keep native macOS traffic lights clear even when the desktop window is narrow.
  154. "padding-left": macTrafficLights() ? `${macTrafficLightsBaseWidth / zoom()}px` : 0,
  155. width: windows() ? `env(titlebar-area-width, calc(100vw - ${windowsControlsWidth()}))` : undefined,
  156. "max-width": windows() ? `env(titlebar-area-width, calc(100vw - ${windowsControlsWidth()}))` : undefined,
  157. "align-self": windows() ? "flex-start" : undefined,
  158. }}
  159. data-tauri-drag-region
  160. >
  161. <Switch>
  162. <Match when={useV2Titlebar()}>
  163. {(_) => {
  164. const layout = useLayout()
  165. const global = useGlobal()
  166. const tabs = useTabs()
  167. const tabsStore = tabs.store
  168. const tabsStoreActions = tabs
  169. const [session] = createResource(
  170. () => {
  171. const route = layout.route()
  172. if (route.type !== "session") return undefined
  173. const conn = global.servers
  174. .list()
  175. .find((item) => ServerConnection.key(item) === (route.server ?? server.key))
  176. return conn ? { route, sdk: global.ensureServerCtx(conn).sdk } : undefined
  177. },
  178. ({ route, sdk }) =>
  179. sdk.api.session
  180. .get({ sessionID: route.sessionId })
  181. .then(normalizeSessionInfo)
  182. .catch(() => {}),
  183. )
  184. const matchRoute = (route: LayoutRoute) => {
  185. if (route.type === "home") return
  186. if (route.type === "draft") {
  187. return tabsStore.find((item) => item.type === "draft" && item.draftID === route.draftID)
  188. }
  189. if (route.type === "session") {
  190. const main = tabsStore.find(
  191. (item) =>
  192. item.type === "session" && item.server === route.server && item.sessionId === route.sessionId,
  193. )
  194. if (main) return main
  195. const s = session()
  196. if (s?.parentID) {
  197. const parentID = s.parentID
  198. const parent = tabsStore.find(
  199. (item) => item.type === "session" && item.server === route.server && item.sessionId === parentID,
  200. )
  201. if (parent) return parent
  202. }
  203. }
  204. }
  205. const currentTab = () => matchRoute(layout.route())
  206. createEffect(() => {
  207. const route = layout.route()
  208. if (!tabs.ready()) return
  209. const tab = currentTab()
  210. if (tab) {
  211. tabs.remember(tab)
  212. return
  213. }
  214. if (route.type === "session") {
  215. const s = session()
  216. if (!s) return
  217. const sessionId = s.parentID ?? s.id
  218. const next = { server: route.server ?? server.key, sessionId }
  219. tabsStoreActions.addSessionTab(next)
  220. }
  221. })
  222. makeEventListener(window, SESSION_TABS_REMOVED_EVENT, (event) => {
  223. const detail = readSessionTabsRemovedDetail(event)
  224. if (!detail) return
  225. tabsStoreActions.removeSessions(detail)
  226. })
  227. const openNewTab = () => {
  228. const route = layout.route()
  229. const activeSession = session()
  230. if (route.type === "session" && activeSession) {
  231. const sessionTab = {
  232. type: "session" as const,
  233. server: route.server ?? server.key,
  234. sessionId: activeSession.id,
  235. }
  236. const model = tabs.stateValue<PromptSession>(sessionTab, "prompt")?.model.current()
  237. tabs.newDraft({ server: sessionTab.server, directory: activeSession.directory }, "", model)
  238. return
  239. }
  240. const activeTab = currentTab()
  241. if (activeTab?.type === "draft") {
  242. const model = tabs.stateValue<PromptSession>(activeTab, "prompt")?.model.current()
  243. tabs.newDraft({ server: activeTab.server, directory: activeTab.directory }, "", model)
  244. return
  245. }
  246. if (route.type === "home") {
  247. const selection = layout.home.selection()
  248. const conn = global.servers.list().find((item) => ServerConnection.key(item) === selection.server)
  249. const project = conn
  250. ? global
  251. .ensureServerCtx(conn)
  252. .projects.list()
  253. .find((item) => item.worktree === selection.directory)
  254. : undefined
  255. if (conn && project) {
  256. tabs.newDraft({ server: ServerConnection.key(conn), directory: project.worktree }, "")
  257. return
  258. }
  259. }
  260. const current = layout.projects.list()[0]
  261. if (current) {
  262. tabs.newDraft({ server: server.key, directory: current.worktree }, "")
  263. return
  264. }
  265. const fallback = global.servers.list().flatMap((conn) => {
  266. const project = global.ensureServerCtx(conn).projects.list()[0]
  267. return project ? [{ server: ServerConnection.key(conn), project }] : []
  268. })[0]
  269. if (!fallback) return
  270. tabs.newDraft({ server: fallback.server, directory: fallback.project.worktree }, "")
  271. }
  272. const toggleHome = () => tabs.toggleHome({ home: layout.route().type === "home", current: currentTab() })
  273. command.register("titlebar-home", () => [
  274. {
  275. id: "home.toggle",
  276. title: language.t("home.title"),
  277. category: language.t("command.category.view"),
  278. keybind: "mod+b",
  279. hidden: true,
  280. onSelect: toggleHome,
  281. },
  282. ])
  283. command.register("tabs", () => {
  284. const current = currentTab()
  285. return [
  286. {
  287. id: "tab.new",
  288. category: "tab",
  289. title: language.t("command.session.new"),
  290. keybind: "mod+t,mod+n",
  291. hidden: true,
  292. onSelect: openNewTab,
  293. },
  294. current && {
  295. id: "tab.close",
  296. category: "tab",
  297. title: language.t("command.tab.close"),
  298. keybind: "mod+w",
  299. hidden: true,
  300. onSelect: () => {
  301. tabsStoreActions.closeTab(tabsStore.findIndex((tab) => current === tab))
  302. },
  303. },
  304. {
  305. id: "tab.reopenClosed",
  306. category: language.t("command.category.file"),
  307. title: language.t("command.tab.reopenClosed"),
  308. keybind: "mod+shift+t",
  309. onSelect: () => tabsStoreActions.reopenClosedTab(),
  310. },
  311. ].filter((v) => v !== undefined)
  312. })
  313. const [tabsAreOverflowing, setTabsAreOverflowing] = createSignal(false)
  314. return (
  315. <div
  316. data-slot="titlebar-toolbar"
  317. class="h-full flex-1 overflow-hidden flex flex-row items-center gap-1.5 px-2 md:pr-3"
  318. classList={{
  319. "pt-2": !bottom(),
  320. "pb-2": bottom(),
  321. "md:pl-2": macTrafficLights(),
  322. "md:pl-4": !macTrafficLights(),
  323. }}
  324. >
  325. <ChannelIndicator debugTools={props.debugTools} />
  326. <Show when={windows() || linux()}>
  327. <WindowsAppMenu command={command} platform={platform} variant="v2" />
  328. </Show>
  329. <TooltipV2
  330. placement="bottom"
  331. value={
  332. <>
  333. {language.t("home.title")}
  334. <KeybindV2 keys={command.keybindParts("home.toggle")} variant="neutral" />
  335. </>
  336. }
  337. class="shrink-0"
  338. >
  339. <IconButtonV2
  340. type="button"
  341. variant="ghost-muted"
  342. size="large"
  343. class="!w-9 shrink-0"
  344. icon={<IconV2 name="grid-plus" />}
  345. state={layout.route().type === "home" ? "pressed" : undefined}
  346. onClick={toggleHome}
  347. aria-label={language.t("home.title")}
  348. aria-pressed={layout.route().type === "home"}
  349. />
  350. </TooltipV2>
  351. <TitlebarTabStrip
  352. tabs={tabsStore}
  353. currentTab={currentTab}
  354. forceTruncate={tabsAreOverflowing()}
  355. onOverflowChange={setTabsAreOverflowing}
  356. onNavigate={(tab, el) => {
  357. tabs.select(tab)
  358. el?.scrollIntoView({ behavior: "instant" })
  359. }}
  360. onClose={(tab) => {
  361. const index = tabsStore.findIndex((item) => tabKey(item) === tabKey(tab))
  362. if (index !== -1) tabsStoreActions.closeTab(index)
  363. }}
  364. onReorder={(keys) => tabsStoreActions.reorder(keys)}
  365. />
  366. <TooltipV2
  367. placement="bottom"
  368. value={
  369. <>
  370. {language.t("command.session.new")}
  371. <KeybindV2 keys={newTabTooltipKeybind(command)} variant="neutral" />
  372. </>
  373. }
  374. >
  375. <IconButtonV2
  376. type="button"
  377. variant="ghost-muted"
  378. size="large"
  379. class="shrink-0"
  380. icon={<IconV2 name="plus" />}
  381. onClick={openNewTab}
  382. aria-label={language.t("command.session.new")}
  383. />
  384. </TooltipV2>
  385. <div class="flex-1" />
  386. <TitlebarV2Right state={v2RightState()} />
  387. </div>
  388. )
  389. }}
  390. </Match>
  391. <Match when>
  392. <div
  393. class="grid h-full min-h-full w-full grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center"
  394. style={{ zoom: counterZoom() }}
  395. >
  396. <div
  397. classList={{
  398. "flex items-center min-w-0": true,
  399. "pl-2": !macTrafficLights(),
  400. }}
  401. >
  402. <Show when={windows() || linux()}>
  403. <WindowsAppMenu command={command} platform={platform} />
  404. </Show>
  405. <Show when={mac()}>
  406. <div class="xl:hidden w-10 shrink-0 flex items-center justify-center">
  407. <IconButton
  408. icon="menu"
  409. variant="ghost"
  410. class="titlebar-icon rounded-md"
  411. onClick={layout.mobileSidebar.toggle}
  412. aria-label={language.t("sidebar.menu.toggle")}
  413. aria-expanded={layout.mobileSidebar.opened()}
  414. />
  415. </div>
  416. </Show>
  417. <Show when={!mac()}>
  418. <div class="xl:hidden w-[48px] shrink-0 flex items-center justify-center">
  419. <IconButton
  420. icon="menu"
  421. variant="ghost"
  422. class="titlebar-icon rounded-md"
  423. onClick={layout.mobileSidebar.toggle}
  424. aria-label={language.t("sidebar.menu.toggle")}
  425. aria-expanded={layout.mobileSidebar.opened()}
  426. />
  427. </div>
  428. </Show>
  429. <div class="flex items-center gap-1 shrink-0">
  430. <TooltipKeybind
  431. class={web() ? "hidden xl:flex shrink-0 ml-14" : "hidden xl:flex shrink-0 ml-2"}
  432. placement="bottom"
  433. title={language.t("command.sidebar.toggle")}
  434. keybind={command.keybind("sidebar.toggle")}
  435. >
  436. <Button
  437. variant="ghost"
  438. class="group/sidebar-toggle titlebar-icon w-8 h-6 p-0 box-border"
  439. onClick={layout.sidebar.toggle}
  440. aria-label={language.t("command.sidebar.toggle")}
  441. aria-expanded={layout.sidebar.opened()}
  442. >
  443. <Icon size="small" name={layout.sidebar.opened() ? "sidebar-active" : "sidebar"} />
  444. </Button>
  445. </TooltipKeybind>
  446. <div class="hidden xl:flex items-center shrink-0">
  447. <Show when={params.dir}>
  448. <div
  449. class="flex items-center shrink-0 w-8 mr-1"
  450. aria-hidden={layout.sidebar.opened() ? "true" : undefined}
  451. >
  452. <div
  453. class="transition-opacity"
  454. classList={{
  455. "opacity-100 duration-120 ease-out": !layout.sidebar.opened(),
  456. "opacity-0 duration-120 ease-in delay-0 pointer-events-none": layout.sidebar.opened(),
  457. }}
  458. >
  459. <TooltipKeybind
  460. placement="bottom"
  461. title={language.t("command.session.new")}
  462. keybind={command.keybind("session.new")}
  463. openDelay={800}
  464. >
  465. <Button
  466. variant="ghost"
  467. class="titlebar-icon w-8 h-6 p-0 box-border"
  468. disabled={layout.sidebar.opened()}
  469. tabIndex={layout.sidebar.opened() ? -1 : undefined}
  470. onClick={() => {
  471. if (!params.dir) return
  472. navigate(`/${params.dir}/session`)
  473. }}
  474. aria-label={language.t("command.session.new")}
  475. aria-current={creating() ? "page" : undefined}
  476. >
  477. <IconV2 name="edit" size="small" />
  478. </Button>
  479. </TooltipKeybind>
  480. </div>
  481. </div>
  482. </Show>
  483. <div
  484. class="flex items-center shrink-0"
  485. classList={{
  486. "-translate-x-[36px]": layout.sidebar.opened() && !!params.dir,
  487. "duration-180 ease-out": !layout.sidebar.opened(),
  488. "duration-180 ease-in": layout.sidebar.opened(),
  489. }}
  490. >
  491. <Show when={hasProjects() && nav()}>
  492. <div class="flex items-center gap-0 transition-transform">
  493. <Tooltip placement="bottom" value={language.t("common.goBack")} openDelay={800}>
  494. <Button
  495. variant="ghost"
  496. icon="chevron-left"
  497. class="titlebar-icon w-6 h-6 p-0 box-border"
  498. disabled={!canBack()}
  499. onClick={back}
  500. aria-label={language.t("common.goBack")}
  501. />
  502. </Tooltip>
  503. <Tooltip placement="bottom" value={language.t("common.goForward")} openDelay={800}>
  504. <Button
  505. variant="ghost"
  506. icon="chevron-right"
  507. class="titlebar-icon w-6 h-6 p-0 box-border"
  508. disabled={!canForward()}
  509. onClick={forward}
  510. aria-label={language.t("common.goForward")}
  511. />
  512. </Tooltip>
  513. </div>
  514. </Show>
  515. <div id="opencode-titlebar-left" class="flex items-center gap-3 min-w-0 px-2" />
  516. </div>
  517. </div>
  518. <ChannelIndicator debugTools={props.debugTools} />
  519. </div>
  520. </div>
  521. <div class="min-w-0 flex items-center justify-center pointer-events-none">
  522. <div
  523. id="opencode-titlebar-center"
  524. class="pointer-events-auto min-w-0 flex justify-center w-fit max-w-full"
  525. />
  526. </div>
  527. <div
  528. classList={{
  529. "flex items-center min-w-0 justify-end": true,
  530. "pr-2": !windows(),
  531. }}
  532. data-tauri-drag-region
  533. >
  534. <div id="opencode-titlebar-right" class="flex items-center gap-1 shrink-0 justify-end" />
  535. <Show when={windows()}>
  536. <div class="shrink-0" style={{ width: windowsControlsWidth() }} />
  537. </Show>
  538. </div>
  539. </div>
  540. </Match>
  541. </Switch>
  542. </header>
  543. )
  544. }
  545. type TitlebarUpdatePillState = {
  546. visible: boolean
  547. installing: boolean
  548. label: string
  549. ariaLabel: string
  550. title?: string
  551. onInstall: () => void
  552. }
  553. type TitlebarV2RightState = {
  554. update: TitlebarUpdatePillState
  555. }
  556. function TitlebarV2Right(props: { state: TitlebarV2RightState }) {
  557. return (
  558. <div class="relative z-20 flex shrink-0 items-center justify-end gap-0 overflow-visible">
  559. <Show when={props.state.update.visible}>
  560. <TitlebarUpdateIconButton state={props.state.update} />
  561. </Show>
  562. <div id="opencode-titlebar-right" class="flex shrink-0 items-center justify-end gap-0" />
  563. </div>
  564. )
  565. }
  566. function TitlebarUpdateIconButton(props: { state: TitlebarUpdatePillState }) {
  567. return (
  568. <div class="group relative mr-3 h-5 w-5 shrink-0 rounded-full bg-v2-background-bg-deep transition-[width] duration-150 ease-out hover:z-30 hover:w-[68px] focus-within:z-30 focus-within:w-[68px] motion-reduce:transition-none">
  569. <button
  570. type="button"
  571. class="absolute right-0 top-0 z-10 flex h-5 w-5 items-center justify-end overflow-hidden rounded-full bg-v2-icon-icon-accent/20 text-v2-icon-icon-accent transition-[width,background-color] duration-150 ease-out group-hover:w-[68px] group-hover:bg-[color-mix(in_srgb,var(--v2-icon-icon-accent)_20%,var(--v2-background-bg-deep))] group-focus-within:w-[68px] group-focus-within:bg-[color-mix(in_srgb,var(--v2-icon-icon-accent)_20%,var(--v2-background-bg-deep))] focus-visible:outline-none disabled:opacity-60 motion-reduce:transition-none"
  572. onClick={props.state.onInstall}
  573. disabled={props.state.installing}
  574. aria-busy={props.state.installing}
  575. aria-label={props.state.ariaLabel}
  576. >
  577. <span class="shrink-0 ml-[8px] mr-px text-[11px] text-v2-text-text-accent [font-weight:530] opacity-0 translate-x-2 motion-safe:transition-all duration-150 ease-out group-hover:opacity-100 group-hover:translate-x-0 group-focus-within:opacity-100 group-focus-within:translate-x-0 motion-reduce:translate-x-0">
  578. Update
  579. </span>
  580. <span class="flex size-5 shrink-0 items-center justify-center">
  581. <Show
  582. when={!props.state.installing}
  583. fallback={<span data-slot="titlebar-update-loader" aria-hidden="true" />}
  584. >
  585. <svg width="14" height="14" viewBox="0 0 14 14" fill="none" aria-hidden="true">
  586. <path d="M7 11V3M3.5 7.63128L7 11L10.5 7.63128" stroke="currentColor" />
  587. </svg>
  588. </Show>
  589. </span>
  590. </button>
  591. </div>
  592. )
  593. }
  594. function ChannelIndicator(props: { debugTools?: { visible: boolean; toggle: () => void } }) {
  595. const channel = import.meta.env.VITE_OPENCODE_CHANNEL
  596. if (channel === "dev" && props.debugTools) {
  597. return (
  598. <button
  599. type="button"
  600. data-component="build-channel"
  601. class="bg-icon-interactive-base text-[#FFF] font-medium px-2 rounded-sm uppercase font-mono cursor-pointer"
  602. onClick={props.debugTools.toggle}
  603. aria-label="Toggle debug tools"
  604. aria-pressed={props.debugTools.visible}
  605. >
  606. DEV
  607. </button>
  608. )
  609. }
  610. return (
  611. <>
  612. {["beta", "dev"].includes(channel) && (
  613. <div
  614. data-component="build-channel"
  615. class="bg-icon-interactive-base text-[#FFF] font-medium px-2 rounded-sm uppercase font-mono"
  616. >
  617. {channel.toUpperCase()}
  618. </div>
  619. )}
  620. </>
  621. )
  622. }