diff --git a/packages/app/src/components/titlebar.tsx b/packages/app/src/components/titlebar.tsx index 36c7e46b626a..86ff45140bbf 100644 --- a/packages/app/src/components/titlebar.tsx +++ b/packages/app/src/components/titlebar.tsx @@ -1,4 +1,16 @@ -import { createEffect, createMemo, createResource, For, Match, Show, startTransition, Switch, untrack } from "solid-js" +import { + createEffect, + createMemo, + createResource, + createSignal, + For, + Match, + onMount, + Show, + startTransition, + Switch, + untrack, +} from "solid-js" import { createStore } from "solid-js/store" import { useLocation, useMatch, useNavigate, useParams } from "@solidjs/router" import { IconButton } from "@opencode-ai/ui/icon-button" @@ -230,7 +242,7 @@ export function Titlebar(props: { update?: TitlebarUpdate }) { : undefined, "align-self": electronWindows() ? "flex-start" : undefined, }} - data-tauri-drag-region + // data-tauri-drag-region onMouseDown={drag} onDblClick={maximize} > @@ -393,9 +405,16 @@ export function Titlebar(props: { update?: TitlebarUpdate }) { ].filter((v) => v !== undefined) }) + const [tabsAreOverflowing, setTabsAreOverflowing] = createSignal(false) + let tabScrollRef!: HTMLDivElement + + function refreshTabsAreOverflowing() { + setTabsAreOverflowing(tabScrollRef.scrollWidth > tabScrollRef.clientWidth) + } + return (
} state={!!homeMatch() ? "pressed" : undefined} /> -
-
- - {(tab, i) => ( - <> - {i() !== 0 && ( -
- )} - navigateTab(tab)} - onClose={() => tabsStoreActions.removeTab(i())} - active={currentTab() === tab} - activeServer={tab.server === server.key} - /> - - )} +
+
+ + {(tab, i) => { + let ref!: HTMLDivElement + + onMount(() => { + refreshTabsAreOverflowing() + }) + + return ( + <> + {i() !== 0 && ( +
+ )} + { + navigateTab(tab) + + ref.scrollIntoView({ behavior: "instant" }) + }} + onClose={() => tabsStoreActions.removeTab(i())} + active={currentTab() === tab} + activeServer={tab.server === server.key} + forceTruncate={tabsAreOverflowing()} + /> + + ) + }} -
- } - as="a" - href={newSessionHref()} - aria-label={language.t("command.session.new")} - /> - } - > - { - const tab = tabsStore.at(-1) - if (tab) navigateTab(tab) - else navigate("/") + + {(_) => { + let ref!: HTMLDivElement + + onMount(() => { + ref.scrollIntoView({ behavior: "instant" }) + }) + + return ( + <> +
+ { + const tab = tabsStore.at(-1) + if (tab) navigateTab(tab) + else navigate("/") + }} + /> + + ) }} - /> - -
+ +
+ + } + as="a" + href={newSessionHref()} + aria-label={language.t("command.session.new")} + /> + +
@@ -615,7 +660,7 @@ export function Titlebar(props: { update?: TitlebarUpdate }) { "flex items-center min-w-0 justify-end": true, "pr-2": !windows(), }} - data-tauri-drag-region + // data-tauri-drag-region onMouseDown={drag} >
@@ -685,6 +730,7 @@ function TitlebarUpdateIconButton(props: { state: TitlebarUpdatePillState }) { } function TabNavItem(props: { + ref?: HTMLDivElement href: string server: ServerConnection.Key directory: string @@ -694,6 +740,7 @@ function TabNavItem(props: { onNavigate: () => void active?: boolean activeServer: boolean + forceTruncate?: boolean }) { const closeTab = (event: MouseEvent) => { event.preventDefault() @@ -710,6 +757,7 @@ function TabNavItem(props: { const [session] = createResource( () => { const ctx = dirSyncCtx() + console.log({ ctx, sessionId: props.sessionId }) if (!ctx || !props.sessionId) return return [props.sessionId, ctx] as const }, @@ -722,6 +770,7 @@ function TabNavItem(props: { return (
{ @@ -731,6 +780,7 @@ function TabNavItem(props: { > {(session) => { + console.log({ session: session() }) const project = createMemo(() => projectForSession(session(), serverCtx()?.projects.list() ?? [])) return ( @@ -756,7 +806,10 @@ function TabNavItem(props: { }} -
+
void }) { +function NewSessionTabItem(props: { ref?: HTMLDivElement; href: string; title: string; onClose: () => void }) { const closeTab = (event: MouseEvent) => { event.preventDefault() event.stopPropagation() @@ -804,7 +857,8 @@ function NewSessionTabItem(props: { href: string; title: string; onClose: () => } return (
{ if (event.button !== 1) return closeTab(event)