Skip to content

Commit a6df8a2

Browse files
committed
feat(context-bar): move prompt-guard icon to the context bar
1 parent 8585f5e commit a6df8a2

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

lua/opencode/ui/context_bar.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ local M = {}
33
local context = require('opencode.context')
44
local icons = require('opencode.ui.icons')
55
local state = require('opencode.state')
6+
local prompt_guard_indicator = require('opencode.ui.prompt_guard_indicator')
67

78
local function get_current_file_info(ctx)
89
local current_file = ctx.current_file
@@ -139,7 +140,9 @@ local function format_winbar_text(segments)
139140
end
140141
end
141142

142-
return right_align .. table.concat(parts, '')
143+
local show_guard_indicator = prompt_guard_indicator.is_denied()
144+
local left = show_guard_indicator and prompt_guard_indicator.get_formatted() or ''
145+
return left .. right_align .. table.concat(parts, '')
143146
end
144147

145148
local function update_winbar_highlights(win_id)

lua/opencode/ui/icons.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ local presets = {
2828
-- statuses
2929
status_on = '',
3030
status_off = '',
31-
guard_on = '',
31+
guard_on = ' ',
3232
-- borders and misc
3333
border = '',
3434
-- context bar

lua/opencode/ui/topbar.lua

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ local M = {}
44

55
local state = require('opencode.state')
66
local config_file = require('opencode.config_file')
7-
local prompt_guard_indicator = require('opencode.ui.prompt_guard_indicator')
87

98
local LABELS = {
109
NEW_SESSION_TITLE = 'New session',
@@ -43,14 +42,10 @@ local function get_mode_highlight()
4342
end
4443
end
4544

46-
local function create_winbar_text(description, model_info, mode_info, show_guard_indicator, win_width)
45+
local function create_winbar_text(description, model_info, mode_info, win_width)
4746
local left_content = ''
4847
local right_content = ''
4948

50-
if show_guard_indicator then
51-
left_content = left_content .. prompt_guard_indicator.get_formatted() .. ' '
52-
end
53-
5449
right_content = model_info .. ' ' .. get_mode_highlight() .. mode_info .. '%*'
5550

5651
local desc_width = win_width - util.strdisplaywidth(left_content) - util.strdisplaywidth(right_content)
@@ -110,14 +105,8 @@ function M.render()
110105
-- topbar needs to at least have a value to make sure footer is positioned correctly
111106
vim.wo[win].winbar = ' '
112107

113-
local show_guard_indicator = prompt_guard_indicator.is_denied()
114-
vim.wo[win].winbar = create_winbar_text(
115-
get_session_desc(),
116-
format_model_info(),
117-
format_mode_info(),
118-
show_guard_indicator,
119-
vim.api.nvim_win_get_width(win)
120-
)
108+
vim.wo[win].winbar =
109+
create_winbar_text(get_session_desc(), format_model_info(), format_mode_info(), vim.api.nvim_win_get_width(win))
121110

122111
update_winbar_highlights(win)
123112
end)

0 commit comments

Comments
 (0)