Skip to content

Commit bb00bdc

Browse files
committed
first/last
1 parent cc846d8 commit bb00bdc

2 files changed

Lines changed: 24 additions & 5 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ const sessionGlobalBindingCommands = [
156156
"session.half.page.down",
157157
] as const
158158

159+
const sessionGlobalUnfocusedBindingCommands = ["session.first", "session.last"] as const
160+
159161
const context = createContext<{
160162
width: number
161163
sessionID: string
@@ -1068,6 +1070,11 @@ export function Session() {
10681070
bindings: tuiConfig.keybinds.gather("session.global", sessionGlobalBindingCommands),
10691071
}))
10701072

1073+
useBindings(() => ({
1074+
enabled: () => renderer.currentFocusedEditor === null,
1075+
bindings: tuiConfig.keybinds.gather("session.global.unfocused", sessionGlobalUnfocusedBindingCommands),
1076+
}))
1077+
10711078
useBindings(() => ({
10721079
mode: OPENCODE_BASE_MODE,
10731080
bindings: tuiConfig.keybinds.gather("session", sessionBindingCommands),

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,14 @@ test("mode-less bindings stay active when opencode mode changes", async () => {
7171
{ name: "session.list", run() {} },
7272
{ name: "session.new", run() {} },
7373
{ name: "session.page.up", run() {} },
74+
{ name: "session.first", run() {} },
7475
],
75-
bindings: config.keybinds.gather("test.global", ["session.list", "session.new", "session.page.up"]),
76+
bindings: config.keybinds.gather("test.global", [
77+
"session.list",
78+
"session.new",
79+
"session.page.up",
80+
"session.first",
81+
]),
7682
})
7783
const offBase = keymap.registerLayer({
7884
mode: OPENCODE_BASE_MODE,
@@ -84,7 +90,7 @@ test("mode-less bindings stay active when opencode mode changes", async () => {
8490
Array.from(
8591
keymap.getCommandBindings({
8692
visibility: "active",
87-
commands: ["session.list", "session.new", "session.page.up", "model.list"],
93+
commands: ["session.list", "session.new", "session.page.up", "session.first", "model.list"],
8894
}),
8995
([command, bindings]) => [command, bindings.length],
9096
),
@@ -114,9 +120,15 @@ test("mode-less bindings stay active when opencode mode changes", async () => {
114120
const app = await testRender(() => <Harness />)
115121
try {
116122
expect(counts).toEqual({
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 },
123+
base: { "session.list": 1, "session.new": 1, "session.page.up": 2, "session.first": 2, "model.list": 1 },
124+
question: { "session.list": 1, "session.new": 1, "session.page.up": 2, "session.first": 2, "model.list": 0 },
125+
autocomplete: {
126+
"session.list": 1,
127+
"session.new": 1,
128+
"session.page.up": 2,
129+
"session.first": 2,
130+
"model.list": 0,
131+
},
120132
})
121133
} finally {
122134
app.renderer.destroy()

0 commit comments

Comments
 (0)