diff --git a/packages/tui/src/component/prompt/index.tsx b/packages/tui/src/component/prompt/index.tsx
index 7560d496536..80c5bef7249 100644
--- a/packages/tui/src/component/prompt/index.tsx
+++ b/packages/tui/src/component/prompt/index.tsx
@@ -68,6 +68,7 @@ import { useDirectoryRecents } from "../../prompt/directory-recents"
import { directoryRecentValue } from "../../prompt/directory-completion"
import { useWorkingDirectoryActions } from "../../ui/working-directory-actions"
import { truncateFilePath } from "../../ui/file-path"
+import { PromptMetadataRow } from "./metadata"
export type PromptProps = {
sessionID?: string
@@ -104,10 +105,6 @@ function randomIndex(count: number) {
return Math.floor(Math.random() * count)
}
-function fadeColor(color: RGBA, alpha: number) {
- return RGBA.fromValues(color.r, color.g, color.b, color.a * alpha)
-}
-
export function PromptInterruptStatus(props: {
armed: boolean
animations?: boolean
@@ -1838,52 +1835,19 @@ export function Prompt(props: PromptProps) {
syntaxStyle={syntax()}
/>
-
- }>
- {(label) => (
- <>
- {label()}
- = 44}
- >
- auto
-
- = 28}>
-
- ·
-
- {promptDisplay().modelLabel}
-
- = 50}>
-
- {promptDisplay().providerLabel}
-
-
- = 70}>
- ·
-
-
- {promptDisplay().variant}
-
-
-
-
-
- >
- )}
-
-
+
{props.right}
diff --git a/packages/tui/src/component/prompt/metadata.tsx b/packages/tui/src/component/prompt/metadata.tsx
new file mode 100644
index 00000000000..9d468b86da6
--- /dev/null
+++ b/packages/tui/src/component/prompt/metadata.tsx
@@ -0,0 +1,146 @@
+import { RGBA, TextAttributes } from "@opentui/core"
+import { useTerminalDimensions } from "@opentui/solid"
+import { createMemo, Show } from "solid-js"
+import { useTheme } from "../../context/theme"
+import { Locale } from "../../util/locale"
+import { stringWidth } from "../../util/string-width"
+
+export function PromptMetadataRow(props: {
+ mode: "normal" | "shell"
+ agent?: string
+ auto: boolean
+ model: string
+ provider: string
+ variant?: string
+ muted: boolean
+ highlight: RGBA
+ agentAlpha: number
+ modelAlpha: number
+ variantAlpha: number
+}) {
+ const theme = useTheme()
+ const dimensions = useTerminalDimensions()
+ const layout = createMemo(() => {
+ if (props.mode === "shell") return { agent: props.agent ?? "Shell", model: "" }
+ return promptMetadataLayout({
+ width: Math.max(0, dimensions().width - (dimensions().width < 44 ? 9 : 13)),
+ terminalWidth: dimensions().width,
+ agent: props.agent ?? "",
+ auto: props.auto,
+ model: props.model,
+ provider: props.provider,
+ variant: props.variant,
+ })
+ })
+
+ return (
+
+ }
+ >
+
+ {(agent) => {agent()}}
+
+
+ auto
+
+
+
+
+ ·
+
+
+ {layout().model}
+
+
+ {(provider) => (
+
+ {provider()}
+
+ )}
+
+
+ {(variant) => (
+ <>
+ ·
+
+ {variant()}
+
+ >
+ )}
+
+
+
+
+
+ )
+}
+
+function fade(color: RGBA, alpha: number) {
+ return RGBA.fromValues(color.r, color.g, color.b, color.a * alpha)
+}
+
+type Layout = {
+ agent?: string
+ auto?: boolean
+ model: string
+ provider?: string
+ variant?: string
+}
+
+function promptMetadataLayout(input: {
+ width: number
+ terminalWidth: number
+ agent: string
+ auto?: boolean
+ model: string
+ provider: string
+ variant?: string
+}) {
+ const agent = input.terminalWidth < 44 ? undefined : input.agent
+ const provider = input.terminalWidth < 44 ? "" : input.provider
+ const candidates: Layout[] = [
+ { agent, auto: input.auto, model: input.model, provider, variant: input.variant },
+ { agent, model: input.model, provider, variant: input.variant },
+ {
+ agent,
+ model: input.model,
+ provider: provider.split(" / ").at(-1) ?? provider,
+ variant: input.variant,
+ },
+ { agent, model: input.model, variant: input.variant },
+ ]
+ const fit = candidates.find((candidate) => stringWidth(text(candidate)) <= input.width)
+ if (fit) return fit
+
+ const prefix = agent ? `${agent} · ` : ""
+ const suffix = input.variant ? ` · ${input.variant}` : ""
+ return {
+ agent,
+ model: Locale.truncateWidth(
+ input.model,
+ Math.max(9, input.width - stringWidth(prefix) - stringWidth(suffix)),
+ ).replace(/\s+…$/, "…"),
+ variant: input.variant,
+ }
+}
+
+function text(input: Layout) {
+ return [
+ ...(input.agent ? [input.agent] : []),
+ ...(input.auto ? ["auto"] : []),
+ ...(input.model ? [...(input.agent ? ["·"] : []), input.model] : []),
+ ...(input.provider ? [input.provider] : []),
+ ...(input.variant ? ["·", input.variant] : []),
+ ].join(" ")
+}
diff --git a/packages/tui/src/feature-plugins/prompt/footer.tsx b/packages/tui/src/feature-plugins/prompt/footer.tsx
index 8f397d84ecd..c25e861d6a1 100644
--- a/packages/tui/src/feature-plugins/prompt/footer.tsx
+++ b/packages/tui/src/feature-plugins/prompt/footer.tsx
@@ -2,6 +2,7 @@ import { Plugin } from "@opencode-ai/plugin/tui"
import { createMemo, createSignal, Match, Show, Switch } from "solid-js"
import { contextUsage, formatContextUsage } from "../../util/session"
import { useTerminalDimensions } from "@opentui/solid"
+import { stringWidth } from "../../util/string-width"
const money = new Intl.NumberFormat("en-US", {
style: "currency",
@@ -47,13 +48,22 @@ export function PromptFooter(props: {
})
const live = createMemo(() => Boolean(subagents() || shells()))
const shortcut = (id: string) => props.context.keymap.shortcuts(id)[0]
+ const layout = createMemo(() => {
+ const command = shortcut("command.palette.show")
+ if (status().length === 0) return { usage: false, shortcuts: dimensions().width >= 44 }
+ return promptFooterLayout({
+ width: Math.max(0, dimensions().width - 8),
+ usage: status(),
+ shortcuts: command ? [`${command} commands`] : [],
+ })
+ })
return (
0}>
-
+
- 0}>
-
+ 0}>
+
·
{status().join(" · ")}
- = 44}>
+
{shortcut("agent.cycle")} agents
-
+
{shortcut("command.palette.show")} commands
@@ -112,13 +122,20 @@ export default Plugin.define({
context.ui.slot({
append: "prompt.footer",
render: (props) => (
-
+
),
})
},
})
+
+function promptFooterLayout(input: { width: number; usage: string[]; shortcuts: string[] }) {
+ const usage = input.usage.join(" · ")
+ const shortcuts = input.shortcuts.join(" · ")
+ const available = Math.max(0, input.width - Math.min(28, Math.floor(input.width / 2)))
+ if (usage && shortcuts && stringWidth(`${usage} · ${shortcuts}`) <= available) {
+ return { usage: true, shortcuts: true }
+ }
+ if (usage && stringWidth(usage) <= available) return { usage: true, shortcuts: false }
+ if (!usage && shortcuts && stringWidth(shortcuts) <= available) return { usage: false, shortcuts: true }
+ return { usage: false, shortcuts: false }
+}