Skip to content

Commit cc846d8

Browse files
committed
move more
1 parent f342d61 commit cc846d8

3 files changed

Lines changed: 29 additions & 15 deletions

File tree

packages/opencode/src/cli/cmd/tui/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ import { DialogVariant } from "./component/dialog-variant"
8181

8282
const appGlobalBindingCommands = [
8383
"session.list",
84+
"session.new",
8485
"session.quick_switch.1",
8586
"session.quick_switch.2",
8687
"session.quick_switch.3",
@@ -94,7 +95,6 @@ const appGlobalBindingCommands = [
9495

9596
const appBindingCommands = [
9697
"command.palette.show",
97-
"session.new",
9898
"model.list",
9999
"model.cycle_recent",
100100
"model.cycle_recent_reverse",

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,6 @@ const sessionBindingCommands = [
133133
"session.toggle.actions",
134134
"session.toggle.scrollbar",
135135
"session.toggle.generic_tool_output",
136-
"session.page.up",
137-
"session.page.down",
138-
"session.line.up",
139-
"session.line.down",
140-
"session.half.page.up",
141-
"session.half.page.down",
142136
"session.first",
143137
"session.last",
144138
"session.messages_last_user",
@@ -153,6 +147,15 @@ const sessionBindingCommands = [
153147
"session.child.previous",
154148
] as const
155149

150+
const sessionGlobalBindingCommands = [
151+
"session.page.up",
152+
"session.page.down",
153+
"session.line.up",
154+
"session.line.down",
155+
"session.half.page.up",
156+
"session.half.page.down",
157+
] as const
158+
156159
const context = createContext<{
157160
width: number
158161
sessionID: string
@@ -1061,6 +1064,10 @@ export function Session() {
10611064
commands: sessionCommands(),
10621065
}))
10631066

1067+
useBindings(() => ({
1068+
bindings: tuiConfig.keybinds.gather("session.global", sessionGlobalBindingCommands),
1069+
}))
1070+
10641071
useBindings(() => ({
10651072
mode: OPENCODE_BASE_MODE,
10661073
bindings: tuiConfig.keybinds.gather("session", sessionBindingCommands),

packages/opencode/test/cli/tui/keymap.test.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,25 @@ test("mode-less bindings stay active when opencode mode changes", async () => {
6767
const config = createTuiResolvedConfig()
6868
const offKeymap = registerOpencodeKeymap(keymap, renderer, config)
6969
const offGlobal = keymap.registerLayer({
70-
commands: [{ name: "session.list", run() {} }],
71-
bindings: config.keybinds.gather("test.global", ["session.list"]),
70+
commands: [
71+
{ name: "session.list", run() {} },
72+
{ name: "session.new", run() {} },
73+
{ name: "session.page.up", run() {} },
74+
],
75+
bindings: config.keybinds.gather("test.global", ["session.list", "session.new", "session.page.up"]),
7276
})
7377
const offBase = keymap.registerLayer({
7478
mode: OPENCODE_BASE_MODE,
75-
commands: [{ name: "session.new", run() {} }],
76-
bindings: config.keybinds.gather("test.base", ["session.new"]),
79+
commands: [{ name: "model.list", run() {} }],
80+
bindings: config.keybinds.gather("test.base", ["model.list"]),
7781
})
7882
const activeCounts = () =>
7983
Object.fromEntries(
8084
Array.from(
81-
keymap.getCommandBindings({ visibility: "active", commands: ["session.list", "session.new"] }),
85+
keymap.getCommandBindings({
86+
visibility: "active",
87+
commands: ["session.list", "session.new", "session.page.up", "model.list"],
88+
}),
8289
([command, bindings]) => [command, bindings.length],
8390
),
8491
)
@@ -107,9 +114,9 @@ test("mode-less bindings stay active when opencode mode changes", async () => {
107114
const app = await testRender(() => <Harness />)
108115
try {
109116
expect(counts).toEqual({
110-
base: { "session.list": 1, "session.new": 1 },
111-
question: { "session.list": 1, "session.new": 0 },
112-
autocomplete: { "session.list": 1, "session.new": 0 },
117+
base: { "session.list": 1, "session.new": 1, "session.page.up": 2, "model.list": 1 },
118+
question: { "session.list": 1, "session.new": 1, "session.page.up": 2, "model.list": 0 },
119+
autocomplete: { "session.list": 1, "session.new": 1, "session.page.up": 2, "model.list": 0 },
113120
})
114121
} finally {
115122
app.renderer.destroy()

0 commit comments

Comments
 (0)