Skip to content

Commit 2c17e3a

Browse files
chore: generate
1 parent 98f5e6e commit 2c17e3a

9 files changed

Lines changed: 54 additions & 39 deletions

File tree

packages/opencode/src/cli/cmd/tui/component/dialog-provider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ function AutoMethod(props: AutoMethodProps) {
244244
{
245245
key: "c",
246246
cmd: () => {
247-
const code = props.authorization.instructions.match(/[A-Z0-9]{4}-[A-Z0-9]{4,5}/)?.[0] ?? props.authorization.url
247+
const code =
248+
props.authorization.instructions.match(/[A-Z0-9]{4}-[A-Z0-9]{4,5}/)?.[0] ?? props.authorization.url
248249
Clipboard.copy(code)
249250
.then(() => toast.show({ message: "Copied to clipboard", variant: "info" }))
250251
.catch(toast.error)

packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,7 @@ import { useArgs } from "@tui/context/args"
6060
import { Flag } from "@opencode-ai/core/flag/flag"
6161
import { type WorkspaceStatus } from "../workspace-label"
6262
import { useCommandPalette } from "../../context/command-palette"
63-
import {
64-
useBindings,
65-
useCommandShortcut,
66-
useLeaderActive,
67-
useOpencodeKeymap,
68-
} from "../../keymap"
63+
import { useBindings, useCommandShortcut, useLeaderActive, useOpencodeKeymap } from "../../keymap"
6964
import { useTuiConfig } from "../../context/tui-config"
7065

7166
export type PromptProps = {
@@ -890,7 +885,13 @@ export function Prompt(props: PromptProps) {
890885
target: inputTarget,
891886
enabled: (() => {
892887
cursorVersion()
893-
return inputTarget() !== undefined && !props.disabled && store.mode === "normal" && !auto()?.visible && input?.visualCursor.offset === 0
888+
return (
889+
inputTarget() !== undefined &&
890+
!props.disabled &&
891+
store.mode === "normal" &&
892+
!auto()?.visible &&
893+
input?.visualCursor.offset === 0
894+
)
894895
})(),
895896
bindings: [
896897
{

packages/opencode/src/cli/cmd/tui/config/legacy-keymap-transform.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ const inputCommands = {
4646
input_select_all: "input.select.all",
4747
} as const satisfies Partial<Record<keyof LegacyKeybinds, string>>
4848

49-
function add(config: SectionsConfig, section: KeymapSection, command: string, binding: BindingValue<Renderable, KeyEvent> | undefined) {
49+
function add(
50+
config: SectionsConfig,
51+
section: KeymapSection,
52+
command: string,
53+
binding: BindingValue<Renderable, KeyEvent> | undefined,
54+
) {
5055
if (binding === undefined) return
5156
config[section] ??= {}
5257
config[section][command] = binding
@@ -154,7 +159,12 @@ export function create(keybinds: LegacyKeybinds): KeymapConfigInput {
154159
add(config, "dialog_select", "dialog.select.submit", keybinds["dialog.select.submit"])
155160
add(config, "dialog_actions", "dialog.action.delete", combineBindings(keybinds.stash_delete, keybinds.session_delete))
156161
add(config, "dialog_actions", "dialog.action.rename", keybinds.session_rename)
157-
add(config, "dialog_actions", "dialog.action.toggle", combineBindings(keybinds["dialog.mcp.toggle"], keybinds["plugins.toggle"]))
162+
add(
163+
config,
164+
"dialog_actions",
165+
"dialog.action.toggle",
166+
combineBindings(keybinds["dialog.mcp.toggle"], keybinds["plugins.toggle"]),
167+
)
158168
add(config, "model", "model.dialog.provider", keybinds.model_provider_list)
159169
add(config, "model", "model.dialog.favorite", keybinds.model_favorite_toggle)
160170

packages/opencode/src/cli/cmd/tui/config/tui-schema.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,12 @@ export function keymapBindingDefaults(input: { section: string; binding: Readonl
293293
export const KeymapConfig = z
294294
.object({
295295
leader: z.string().prefault("ctrl+x"),
296-
leader_timeout: z.number().int().positive().prefault(KeymapLeaderTimeoutDefault).describe("Leader key timeout in milliseconds"),
296+
leader_timeout: z
297+
.number()
298+
.int()
299+
.positive()
300+
.prefault(KeymapLeaderTimeoutDefault)
301+
.describe("Leader key timeout in milliseconds"),
297302
sections: KeymapSections,
298303
})
299304
.strict()

packages/opencode/src/cli/cmd/tui/config/tui.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@ import * as Log from "@opencode-ai/core/util/log"
2323
import { ConfigVariable } from "@/config/variable"
2424
import { Npm } from "@opencode-ai/core/npm"
2525
import { LegacyKeymapTransform } from "./legacy-keymap-transform"
26-
import {
27-
KeymapSectionNames,
28-
keymapBindingDefaults,
29-
type KeymapInfo,
30-
type KeymapSection,
31-
} from "./tui-schema"
26+
import { KeymapSectionNames, keymapBindingDefaults, type KeymapInfo, type KeymapSection } from "./tui-schema"
3227

3328
const log = Log.create({ service: "tui.config" })
3429

packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,8 +1101,7 @@ export function Session() {
11011101
>
11021102
<text fg={theme.textMuted}>{revert()!.reverted.length} message reverted</text>
11031103
<text fg={theme.textMuted}>
1104-
<span style={{ fg: theme.text }}>{redoShortcut()}</span> or /redo to
1105-
restore
1104+
<span style={{ fg: theme.text }}>{redoShortcut()}</span> or /redo to restore
11061105
</text>
11071106
<Show when={revert()!.diffFiles?.length}>
11081107
<box marginTop={1}>

packages/opencode/src/cli/cmd/tui/routes/session/question.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,7 @@ export function QuestionPrompt(props: { request: QuestionRequest }) {
220220
},
221221
},
222222
...(confirm()
223-
? [
224-
{ key: "return", cmd: () => submit() },
225-
{ key: "escape", cmd: () => reject() },
226-
...sections.question,
227-
]
223+
? [{ key: "return", cmd: () => submit() }, { key: "escape", cmd: () => reject() }, ...sections.question]
228224
: [
229225
...Array.from({ length: max }, (_, index) => ({
230226
key: String(index + 1),

packages/opencode/test/config/tui.test.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -428,16 +428,20 @@ test("resolves semantic keymap sections", async () => {
428428
expect(config.keymap.sections.global.find((binding) => binding.cmd === "command.palette.show")?.key).toBe("alt+p")
429429
expect(config.keymap.sections.global.find((binding) => binding.cmd === "session.new")?.key).toBe("<leader>n")
430430
expect(config.keymap.sections.prompt.find((binding) => binding.cmd === "prompt.editor")?.key).toBe("ctrl+e")
431-
expect(config.keymap.sections.autocomplete.find((binding) => binding.cmd === "prompt.autocomplete.next")?.key).toBe("ctrl+j")
432-
expect(config.keymap.sections.dialog_actions.find((binding) => binding.cmd === "dialog.action.toggle")?.key).toBe("ctrl+t")
431+
expect(config.keymap.sections.autocomplete.find((binding) => binding.cmd === "prompt.autocomplete.next")?.key).toBe(
432+
"ctrl+j",
433+
)
434+
expect(config.keymap.sections.dialog_actions.find((binding) => binding.cmd === "dialog.action.toggle")?.key).toBe(
435+
"ctrl+t",
436+
)
433437
expect(config.keymap.sections.model.find((binding) => binding.cmd === "model.dialog.favorite")?.key).toBe("ctrl+f")
434438
expect(config.keymap.sections.plugins.find((binding) => binding.cmd === "plugin.dialog.install")?.key).toBe("shift+i")
435439
expect(config.keymap.pick("plugins", ["plugin.dialog.install"]).map((binding) => binding.cmd)).toEqual([
436440
"plugin.dialog.install",
437441
])
438-
expect(
439-
(config.keymap.pick("plugins", ["plugin.dialog.install"])[0] as { group?: unknown } | undefined)?.group,
440-
).toBe("Plugins")
442+
expect((config.keymap.pick("plugins", ["plugin.dialog.install"])[0] as { group?: unknown } | undefined)?.group).toBe(
443+
"Plugins",
444+
)
441445
expect(config.keymap.omit("plugins", ["plugin.dialog.install"]).map((binding) => binding.cmd)).toEqual([])
442446
})
443447

@@ -477,18 +481,22 @@ test("legacy keybinds transform into semantic keymap sections", async () => {
477481
])
478482
expect(config.keymap.sections.global.find((binding) => binding.cmd === "command.palette.show")?.key).toBe("alt+p")
479483
expect(config.keymap.sections.prompt.find((binding) => binding.cmd === "prompt.editor")?.key).toBe("ctrl+e")
480-
expect(config.keymap.sections.autocomplete.find((binding) => binding.cmd === "prompt.autocomplete.next")?.key).toBe("ctrl+j")
481-
expect(config.keymap.sections.dialog_actions.find((binding) => binding.cmd === "dialog.action.toggle")?.key).toBe("ctrl+t")
484+
expect(config.keymap.sections.autocomplete.find((binding) => binding.cmd === "prompt.autocomplete.next")?.key).toBe(
485+
"ctrl+j",
486+
)
487+
expect(config.keymap.sections.dialog_actions.find((binding) => binding.cmd === "dialog.action.toggle")?.key).toBe(
488+
"ctrl+t",
489+
)
482490
expect(config.keymap.sections.model.find((binding) => binding.cmd === "model.dialog.provider")?.key).toBe("ctrl+a")
483491
expect(config.keymap.sections.model.find((binding) => binding.cmd === "model.dialog.favorite")?.key).toBe("ctrl+f")
484492
expect(config.keymap.sections.plugins.find((binding) => binding.cmd === "plugin.dialog.install")?.key).toBe("shift+i")
485493
expect(config.keymap.sections.plugins.find((binding) => binding.cmd === "plugins.list")?.key).toBe("ctrl+shift+p")
486494
expect(config.keymap.pick("plugins", ["plugin.dialog.install"]).map((binding) => binding.cmd)).toEqual([
487495
"plugin.dialog.install",
488496
])
489-
expect(
490-
(config.keymap.omit("plugins", ["plugin.dialog.install"])[0] as { group?: unknown } | undefined)?.group,
491-
).toBe("Plugins")
497+
expect((config.keymap.omit("plugins", ["plugin.dialog.install"])[0] as { group?: unknown } | undefined)?.group).toBe(
498+
"Plugins",
499+
)
492500
expect(config.keymap.omit("plugins", ["plugin.dialog.install"]).map((binding) => binding.cmd)).toEqual([
493501
"plugins.list",
494502
])

packages/web/src/content/docs/keybinds.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ You do not need to use a leader key, but we recommend doing so.
5555

5656
`keymap.sections` is grouped by semantic area. Each section contains command names and the key sequence that triggers them.
5757

58-
| Field | Description |
59-
| ----- | ----------- |
60-
| `leader` | The key used by `<leader>` sequences. Defaults to `ctrl+x`. |
58+
| Field | Description |
59+
| ---------------- | --------------------------------------------------------------------------------------------------- |
60+
| `leader` | The key used by `<leader>` sequences. Defaults to `ctrl+x`. |
6161
| `leader_timeout` | How long OpenCode waits for the next key after the leader key, in milliseconds. Defaults to `2000`. |
62-
| `sections` | A map of TUI areas to command bindings. |
62+
| `sections` | A map of TUI areas to command bindings. |
6363

6464
---
6565

@@ -310,7 +310,7 @@ On native Windows, the defaults for undo and terminal suspend are different for
310310

311311
- `input.undo` defaults to `ctrl+z,ctrl+-,super+z` when it is not explicitly configured (the `ctrl+z` binding is added because Windows terminals do not support POSIX suspend).
312312
- `terminal.suspend` is disabled because native Windows terminals do not support POSIX suspend.
313-
:::
313+
:::
314314

315315
---
316316

0 commit comments

Comments
 (0)