Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 47 additions & 11 deletions packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { BoxRenderable, TextareaRenderable, MouseEvent, PasteEvent, t, dim, fg } from "@opentui/core"
import { createEffect, createMemo, type JSX, onMount, createSignal, onCleanup, Show, Switch, Match } from "solid-js"
import {
createEffect,
createMemo,
type JSX,
onMount,
createSignal,
onCleanup,
Show,
Switch,
Match,
For,
} from "solid-js"
import "opentui-spinner/solid"
import { useLocal } from "@tui/context/local"
import { useTheme } from "@tui/context/theme"
Expand All @@ -19,7 +30,7 @@ import { useRenderer } from "@opentui/solid"
import { Editor } from "@tui/util/editor"
import { useExit } from "../../context/exit"
import { Clipboard } from "../../util/clipboard"
import type { FilePart } from "@opencode-ai/sdk/v2"
import type { FilePart, KeybindsConfig } from "@opencode-ai/sdk/v2"
import { TuiEvent } from "../../event"
import { iife } from "@/util/iife"
import { Locale } from "@/util/locale"
Expand Down Expand Up @@ -1063,15 +1074,40 @@ export function Prompt(props: PromptProps) {
<box gap={2} flexDirection="row">
<Switch>
<Match when={store.mode === "normal"}>
<text fg={theme.text}>
{keybind.print("variant_cycle")} <span style={{ fg: theme.textMuted }}>variants</span>
</text>
<text fg={theme.text}>
{keybind.print("agent_cycle")} <span style={{ fg: theme.textMuted }}>agents</span>
</text>
<text fg={theme.text}>
{keybind.print("command_list")} <span style={{ fg: theme.textMuted }}>commands</span>
</text>
{(() => {
const tuiConfig = sync.data.config.tui
const config = tuiConfig?.status_hints
const enabled = config?.enabled !== false
if (!enabled) return null

// Default hints configuration
const defaultHints = [
{ keybind: "variant_cycle", label: "variants", when: "hasVariants" },
{ keybind: "agent_cycle", label: "agents" },
{ keybind: "command_list", label: "commands" },
]

const hints = config?.items ?? defaultHints

return (
<For each={hints}>
{(hint) => {
// Check conditional display
if (hint.when === "hasVariants") {
const hasVariants = local.model.variant.list().length > 0
if (!hasVariants) return null
}

return (
<text fg={theme.text}>
{keybind.print(hint.keybind as keyof KeybindsConfig)}{" "}
<span style={{ fg: theme.textMuted }}>{hint.label}</span>
</text>
)
}}
</For>
)
})()}
</Match>
<Match when={store.mode === "shell"}>
<text fg={theme.text}>
Expand Down
16 changes: 16 additions & 0 deletions packages/opencode/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,22 @@ export namespace Config {
.enum(["auto", "stacked"])
.optional()
.describe("Control diff rendering style: 'auto' adapts to terminal width, 'stacked' always shows single column"),
status_hints: z
.object({
enabled: z.boolean().optional().default(true).describe("Enable status line hints"),
items: z
.array(
z.object({
keybind: z.string().describe("Keybind identifier (e.g., 'agent_cycle', 'variant_cycle')"),
label: z.string().describe("Display label for the hint"),
when: z.string().optional().describe("Condition to show hint (e.g., 'hasVariants')"),
}),
)
.optional()
.describe("List of hints to display in status line"),
})
.optional()
.describe("Configure status line hints shown at the bottom of the TUI"),
})

export const Server = z
Expand Down
26 changes: 26 additions & 0 deletions packages/sdk/js/src/v2/gen/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,32 @@ export type Config = {
* Control diff rendering style: 'auto' adapts to terminal width, 'stacked' always shows single column
*/
diff_style?: "auto" | "stacked"
/**
* Configure status line hints shown at the bottom of the TUI
*/
status_hints?: {
/**
* Enable status line hints
*/
enabled?: boolean
/**
* List of hints to display in status line
*/
items?: Array<{
/**
* Keybind identifier (e.g., 'agent_cycle', 'variant_cycle')
*/
keybind: string
/**
* Display label for the hint
*/
label: string
/**
* Condition to show hint (e.g., 'hasVariants')
*/
when?: string
}>
}
}
server?: ServerConfig
/**
Expand Down
33 changes: 33 additions & 0 deletions packages/sdk/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -9119,6 +9119,39 @@
"description": "Control diff rendering style: 'auto' adapts to terminal width, 'stacked' always shows single column",
"type": "string",
"enum": ["auto", "stacked"]
},
"status_hints": {
"description": "Configure status line hints shown at the bottom of the TUI",
"type": "object",
"properties": {
"enabled": {
"description": "Enable status line hints",
"default": true,
"type": "boolean"
},
"items": {
"description": "List of hints to display in status line",
"type": "array",
"items": {
"type": "object",
"properties": {
"keybind": {
"description": "Keybind identifier (e.g., 'agent_cycle', 'variant_cycle')",
"type": "string"
},
"label": {
"description": "Display label for the hint",
"type": "string"
},
"when": {
"description": "Condition to show hint (e.g., 'hasVariants')",
"type": "string"
}
},
"required": ["keybind", "label"]
}
}
}
}
}
},
Expand Down