Skip to content

Commit e95905b

Browse files
committed
chore: misc tweak and fixes
1 parent 800c4f8 commit e95905b

5 files changed

Lines changed: 17 additions & 21 deletions

File tree

lua/opencode/api.lua

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ local function build_toggle_open_context(restore_hidden)
8989
}
9090
end
9191

92-
local focus = config.ui.input.auto_hide and 'input'
93-
or state.last_focused_opencode_window
94-
or 'input'
92+
local focus = config.ui.input.auto_hide and 'input' or state.last_focused_opencode_window or 'input'
9593

9694
return {
9795
focus = focus,
@@ -100,21 +98,20 @@ local function build_toggle_open_context(restore_hidden)
10098
end
10199

102100
M.toggle = Promise.async(function(new_session)
103-
local decision = state.resolve_toggle_decision(
104-
config.ui.persist_state,
105-
state.display_route ~= nil
106-
)
101+
local decision = state.resolve_toggle_decision(config.ui.persist_state, state.display_route ~= nil)
107102
local action = decision.action
108103
local is_new_session = new_session == true
109104

110105
local function open_windows(restore_hidden)
111106
local ctx = build_toggle_open_context(restore_hidden == true)
112-
return core.open({
113-
new_session = is_new_session,
114-
focus = ctx.focus,
115-
start_insert = false,
116-
open_action = ctx.open_action,
117-
}):await()
107+
return core
108+
.open({
109+
new_session = is_new_session,
110+
focus = ctx.focus,
111+
start_insert = false,
112+
open_action = ctx.open_action,
113+
})
114+
:await()
118115
end
119116

120117
local function open_fresh_windows()
@@ -535,7 +532,7 @@ M.switch_mode = Promise.async(function()
535532
end)
536533

537534
function M.with_header(lines, show_welcome)
538-
show_welcome = show_welcome or show_welcome
535+
show_welcome = show_welcome or false
539536
state.display_route = '/header'
540537

541538
local msg = {
@@ -582,7 +579,7 @@ function M.help()
582579
return
583580
end
584581

585-
local max_desc_length = math.min(90, vim.api.nvim_win_get_width(state.windows.output_win) - 30)
582+
local max_desc_length = math.min(90, vim.api.nvim_win_get_width(state.windows.output_win) - 35)
586583

587584
local sorted_commands = vim.tbl_keys(M.commands)
588585
table.sort(sorted_commands)
@@ -889,7 +886,7 @@ end)
889886
-- Returns the ID of the next user message after the current undo point
890887
-- This is a port of the opencode tui logic
891888
-- https://github.com/sst/opencode/blob/dev/packages/tui/internal/components/chat/messages.go#L1199
892-
function find_next_message_for_redo()
889+
local function find_next_message_for_redo()
893890
if not state.active_session then
894891
return nil
895892
end
@@ -1163,7 +1160,7 @@ M.commands = {
11631160
},
11641161

11651162
review = {
1166-
desc = 'Review changes [commit|branch|pr], defaults to uncommitted changes',
1163+
desc = 'Review changes (commit/branch/pr), defaults to uncommitted changes',
11671164
fn = function(args)
11681165
M.review(args)
11691166
end,

lua/opencode/core.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
-- This file was written by an automated tool.
21
local state = require('opencode.state')
32
local context = require('opencode.context')
43
local session = require('opencode.session')

lua/opencode/ui/output_window.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ function M.focus_output(should_stop_insert)
241241
end
242242

243243
function M.close()
244-
if M.mounted() then
244+
if not M.mounted() then
245245
return
246246
end
247247
---@cast state.windows { output_win: integer, output_buf: integer }

lua/opencode/ui/renderer.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function M.reset()
4848
state.tokens_count = 0
4949

5050
local permissions = state.pending_permissions or {}
51-
if #permissions and state.api_client then
51+
if #permissions > 0 and state.api_client then
5252
for _, permission in ipairs(permissions) do
5353
require('opencode.api').permission_deny(permission)
5454
end

lua/opencode/util.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ function M.check_prompt_allowed(guard_callback, mentioned_files)
480480
return true, nil -- No guard = always allowed
481481
end
482482

483-
if not type(guard_callback) == 'function' then
483+
if type(guard_callback) ~= 'function' then
484484
return false, 'prompt_guard must be a function'
485485
end
486486

0 commit comments

Comments
 (0)