|
|
@@ -8,6 +8,7 @@ import type { AssistantMessage, Session } from "@opencode-ai/sdk/v2"
|
|
|
import { useCommandDialog } from "@tui/component/dialog-command"
|
|
|
import { useKeybind } from "../../context/keybind"
|
|
|
import { Installation } from "@/installation"
|
|
|
+import { useTerminalDimensions } from "@opentui/solid"
|
|
|
|
|
|
const Title = (props: { session: Accessor<Session> }) => {
|
|
|
const { theme } = useTheme()
|
|
|
@@ -63,6 +64,8 @@ export function Header() {
|
|
|
const keybind = useKeybind()
|
|
|
const command = useCommandDialog()
|
|
|
const [hover, setHover] = createSignal<"parent" | "prev" | "next" | null>(null)
|
|
|
+ const dimensions = useTerminalDimensions()
|
|
|
+ const narrow = createMemo(() => dimensions().width < 80)
|
|
|
|
|
|
return (
|
|
|
<box flexShrink={0}>
|
|
|
@@ -79,49 +82,52 @@ export function Header() {
|
|
|
>
|
|
|
<Switch>
|
|
|
<Match when={session()?.parentID}>
|
|
|
- <box flexDirection="row" gap={2}>
|
|
|
- <text fg={theme.text}>
|
|
|
- <b>Subagent session</b>
|
|
|
- </text>
|
|
|
- <box
|
|
|
- onMouseOver={() => setHover("parent")}
|
|
|
- onMouseOut={() => setHover(null)}
|
|
|
- onMouseUp={() => command.trigger("session.parent")}
|
|
|
- backgroundColor={hover() === "parent" ? theme.backgroundElement : theme.backgroundPanel}
|
|
|
- >
|
|
|
+ <box flexDirection="column" gap={1}>
|
|
|
+ <box flexDirection={narrow() ? "column" : "row"} justifyContent="space-between" gap={narrow() ? 1 : 0}>
|
|
|
<text fg={theme.text}>
|
|
|
- Parent <span style={{ fg: theme.textMuted }}>{keybind.print("session_parent")}</span>
|
|
|
+ <b>Subagent session</b>
|
|
|
</text>
|
|
|
+ <box flexDirection="row" gap={1} flexShrink={0}>
|
|
|
+ <ContextInfo context={context} cost={cost} />
|
|
|
+ <text fg={theme.textMuted}>v{Installation.VERSION}</text>
|
|
|
+ </box>
|
|
|
</box>
|
|
|
- <box
|
|
|
- onMouseOver={() => setHover("prev")}
|
|
|
- onMouseOut={() => setHover(null)}
|
|
|
- onMouseUp={() => command.trigger("session.child.previous")}
|
|
|
- backgroundColor={hover() === "prev" ? theme.backgroundElement : theme.backgroundPanel}
|
|
|
- >
|
|
|
- <text fg={theme.text}>
|
|
|
- Prev <span style={{ fg: theme.textMuted }}>{keybind.print("session_child_cycle_reverse")}</span>
|
|
|
- </text>
|
|
|
- </box>
|
|
|
- <box
|
|
|
- onMouseOver={() => setHover("next")}
|
|
|
- onMouseOut={() => setHover(null)}
|
|
|
- onMouseUp={() => command.trigger("session.child.next")}
|
|
|
- backgroundColor={hover() === "next" ? theme.backgroundElement : theme.backgroundPanel}
|
|
|
- >
|
|
|
- <text fg={theme.text}>
|
|
|
- Next <span style={{ fg: theme.textMuted }}>{keybind.print("session_child_cycle")}</span>
|
|
|
- </text>
|
|
|
- </box>
|
|
|
- <box flexGrow={1} flexShrink={1} />
|
|
|
- <box flexDirection="row" gap={1} flexShrink={0}>
|
|
|
- <ContextInfo context={context} cost={cost} />
|
|
|
- <text fg={theme.textMuted}>v{Installation.VERSION}</text>
|
|
|
+ <box flexDirection="row" gap={2}>
|
|
|
+ <box
|
|
|
+ onMouseOver={() => setHover("parent")}
|
|
|
+ onMouseOut={() => setHover(null)}
|
|
|
+ onMouseUp={() => command.trigger("session.parent")}
|
|
|
+ backgroundColor={hover() === "parent" ? theme.backgroundElement : theme.backgroundPanel}
|
|
|
+ >
|
|
|
+ <text fg={theme.text}>
|
|
|
+ Parent <span style={{ fg: theme.textMuted }}>{keybind.print("session_parent")}</span>
|
|
|
+ </text>
|
|
|
+ </box>
|
|
|
+ <box
|
|
|
+ onMouseOver={() => setHover("prev")}
|
|
|
+ onMouseOut={() => setHover(null)}
|
|
|
+ onMouseUp={() => command.trigger("session.child.previous")}
|
|
|
+ backgroundColor={hover() === "prev" ? theme.backgroundElement : theme.backgroundPanel}
|
|
|
+ >
|
|
|
+ <text fg={theme.text}>
|
|
|
+ Prev <span style={{ fg: theme.textMuted }}>{keybind.print("session_child_cycle_reverse")}</span>
|
|
|
+ </text>
|
|
|
+ </box>
|
|
|
+ <box
|
|
|
+ onMouseOver={() => setHover("next")}
|
|
|
+ onMouseOut={() => setHover(null)}
|
|
|
+ onMouseUp={() => command.trigger("session.child.next")}
|
|
|
+ backgroundColor={hover() === "next" ? theme.backgroundElement : theme.backgroundPanel}
|
|
|
+ >
|
|
|
+ <text fg={theme.text}>
|
|
|
+ Next <span style={{ fg: theme.textMuted }}>{keybind.print("session_child_cycle")}</span>
|
|
|
+ </text>
|
|
|
+ </box>
|
|
|
</box>
|
|
|
</box>
|
|
|
</Match>
|
|
|
<Match when={true}>
|
|
|
- <box flexDirection="row" justifyContent="space-between" gap={1}>
|
|
|
+ <box flexDirection={narrow() ? "column" : "row"} justifyContent="space-between" gap={1}>
|
|
|
<Title session={session} />
|
|
|
<box flexDirection="row" gap={1} flexShrink={0}>
|
|
|
<ContextInfo context={context} cost={cost} />
|