Skip to content

Commit e1579bd

Browse files
committed
fix(types): refresh vendored tui plugin shim
1 parent 689fbb0 commit e1579bd

1 file changed

Lines changed: 31 additions & 15 deletions

File tree

tui/types/opencode-plugin-tui.d.ts

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ declare module "@opencode-ai/plugin/tui" {
1717

1818
import type { CliRenderer, ParsedKey, RGBA } from "@opentui/core"
1919
import type { JSX, SolidPlugin } from "@opentui/solid"
20-
import type { Plugin as ServerPlugin } from "@opencode-ai/plugin"
2120

2221
// PluginOptions = Record<string, unknown> — not yet exported by installed @opencode-ai/plugin
2322
type PluginOptions = Record<string, unknown>
@@ -113,6 +112,8 @@ declare module "@opencode-ai/plugin/tui" {
113112
description?: () => JSX.Element
114113
placeholder?: string
115114
value?: string
115+
busy?: boolean
116+
busyText?: string
116117
onConfirm?: (value: string) => void
117118
onCancel?: () => void
118119
}
@@ -139,6 +140,19 @@ declare module "@opencode-ai/plugin/tui" {
139140
current?: Value
140141
}
141142

143+
export type TuiPromptProps = {
144+
workspaceID?: string
145+
visible?: boolean
146+
disabled?: boolean
147+
onSubmit?: () => void
148+
hint?: JSX.Element
149+
showPlaceholder?: boolean
150+
placeholders?: {
151+
normal?: string[]
152+
shell?: string[]
153+
}
154+
}
155+
142156
export type TuiToast = {
143157
variant?: "info" | "success" | "warning" | "error"
144158
title?: string
@@ -247,14 +261,13 @@ declare module "@opencode-ai/plugin/tui" {
247261
mcp: () => ReadonlyArray<TuiSidebarMcpItem>
248262
}
249263

250-
// Upstream: Pick<PluginConfig, "$schema" | "theme" | "keybinds" | "plugin"> & NonNullable<PluginConfig["tui"]> & { plugin_enabled?: Record<string, boolean> }
251-
// PluginConfig (opencode.json schema) is not re-exported by @opencode-ai/plugin at installed version.
252-
// Approximation using known TUI-native config keys:
264+
// Current upstream shape is based on the host TUI config plus plugin tuples.
265+
// PluginConfig is not re-exported by the installed @opencode-ai/plugin version.
253266
type TuiConfigView = {
254267
$schema?: string
255268
theme?: string
256269
keybinds?: Record<string, string>
257-
plugin?: Record<string, unknown>
270+
plugin?: Array<string | [string, PluginOptions]>
258271
plugin_enabled?: Record<string, boolean>
259272
[key: string]: unknown
260273
}
@@ -290,6 +303,9 @@ declare module "@opencode-ai/plugin/tui" {
290303
export type TuiSlotMap = {
291304
app: {}
292305
home_logo: {}
306+
home_prompt: {
307+
workspace_id?: string
308+
}
293309
home_bottom: {}
294310
sidebar_title: {
295311
session_id: string
@@ -381,10 +397,8 @@ declare module "@opencode-ai/plugin/tui" {
381397
set: (workspaceID?: string) => void
382398
}
383399

384-
// Flat TuiPluginApi matching upstream spec from PR #19347.
385-
// Previous local shim split this into TuiApi -> TuiHostPluginApi -> TuiPluginApi;
386-
// the upstream API is a single flat type.
387-
export type TuiPluginApi<Renderer = CliRenderer> = {
400+
// Flat TuiPluginApi matching the current upstream TUI plugin API.
401+
export type TuiPluginApi = {
388402
app: TuiApp
389403
command: {
390404
register: (cb: () => TuiCommand[]) => () => void
@@ -401,6 +415,7 @@ declare module "@opencode-ai/plugin/tui" {
401415
DialogConfirm: (props: TuiDialogConfirmProps) => JSX.Element
402416
DialogPrompt: (props: TuiDialogPromptProps) => JSX.Element
403417
DialogSelect: <Value = unknown>(props: TuiDialogSelectProps<Value>) => JSX.Element
418+
Prompt: (props: TuiPromptProps) => JSX.Element
404419
toast: (input: TuiToast) => void
405420
dialog: TuiDialogStack
406421
}
@@ -417,7 +432,7 @@ declare module "@opencode-ai/plugin/tui" {
417432
scopedClient: (workspaceID?: string) => ReturnType<typeof createOpencodeClientV2>
418433
workspace: TuiWorkspace
419434
event: TuiEventBus
420-
renderer: Renderer
435+
renderer: CliRenderer
421436
slots: TuiSlots
422437
plugins: {
423438
list: () => ReadonlyArray<TuiPluginStatus>
@@ -432,14 +447,15 @@ declare module "@opencode-ai/plugin/tui" {
432447
lifecycle: TuiLifecycle
433448
}
434449

435-
export type TuiPlugin<Renderer = CliRenderer> = (
436-
api: TuiPluginApi<Renderer>,
450+
export type TuiPlugin = (
451+
api: TuiPluginApi,
437452
options: PluginOptions | undefined,
438453
meta: TuiPluginMeta,
439454
) => Promise<void>
440455

441-
export type TuiPluginModule<Renderer = CliRenderer> = {
442-
server?: ServerPlugin
443-
tui?: TuiPlugin<Renderer>
456+
export type TuiPluginModule = {
457+
id?: string
458+
tui: TuiPlugin
459+
server?: never
444460
}
445461
}

0 commit comments

Comments
 (0)