Skip to content

Commit 34edf5d

Browse files
Danilo Verde RibeiroDanilo Verde Ribeiro
authored andcommitted
Merge branch 'style-assistant-name-is-agent-name'
2 parents 3e7a8a8 + 55cc0db commit 34edf5d

2 files changed

Lines changed: 18 additions & 20 deletions

File tree

lua/opencode/types.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,7 @@
293293
---@field providerID string Provider identifier
294294
---@field role 'user'|'assistant'|'system' Role of the message sender
295295
---@field system_role string|nil Role defined in system messages
296-
---@field mode string|nil Agent/mode used to create this message (from CLI)
297-
---@field assistant_mode string|nil Assistant mode active when message was created (deprecated)
296+
---@field mode string|nil Agent or mode identifier
298297
---@field error table
299298

300299
---@class RestorePoint

lua/opencode/ui/session_formatter.lua

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ end
116116
---@param messages Message[] All messages in the session
117117
---@param revert_index number Index of the message where revert occurred
118118
---@param revert_info SessionRevertInfo Revert information
119-
---@return {messages: number, tool_calls: number, files: table<string, {additions: number, deletions: number}>}
119+
---@return {messages: number, tool_calls: number, files: {additions: number, deletions: number}}
120120
function M._calculate_revert_stats(messages, revert_index, revert_info)
121121
local stats = {
122122
messages = 0,
@@ -192,10 +192,10 @@ function M._format_revert_message(stats)
192192
end
193193
if #file_diff > 0 then
194194
local line_str = string.format(icons.get('file') .. '%s: %s', file, table.concat(file_diff, ' '))
195-
local line_idx = M.output:add_line(line_str) ---@type number
196-
local col = #(' ' .. file .. ': ') ---@type number
195+
local line_idx = M.output:add_line(line_str)
196+
local col = #(' ' .. file .. ': ')
197197
for _, diff in ipairs(file_diff) do
198-
local hl_group = diff:sub(1, 1) == '+' and 'OpencodeDiffAddText' or 'OpencodeDiffDeleteText' ---@type string
198+
local hl_group = diff:sub(1, 1) == '+' and 'OpencodeDiffAddText' or 'OpencodeDiffDeleteText'
199199
M.output:add_extmark(line_idx, {
200200
virt_text = { { diff, hl_group } },
201201
virt_text_pos = 'inline',
@@ -251,7 +251,7 @@ function M._format_patch(part)
251251
util.time_ago(restore_point.created_at)
252252
)
253253
)
254-
local restore_line = M.output:get_line_count() ---@type number
254+
local restore_line = M.output:get_line_count()
255255
M.output:add_action({
256256
text = 'Restore [A]ll',
257257
type = 'diff_restore_snapshot_all',
@@ -293,10 +293,9 @@ function M._format_message_header(message, msg_idx)
293293
M.output:add_empty_line()
294294
M.output:add_metadata({ msg_idx = msg_idx, part_idx = 1, role = role, type = 'header' })
295295

296-
-- Use the mode field from the message (stable label from CLI)
297296
local display_name
298297
if role == 'assistant' then
299-
local mode = message.mode or message.assistant_mode
298+
local mode = message.mode
300299
if mode and mode ~= '' then
301300
display_name = mode:upper()
302301
else
@@ -334,7 +333,10 @@ end
334333
---@param title? string Optional title for the callout
335334
function M._format_callout(callout, text, title)
336335
title = title and title .. ' ' or ''
337-
local win_width = (state.windows and state.windows.output_win and vim.api.nvim_win_is_valid(state.windows.output_win)) and vim.api.nvim_win_get_width(state.windows.output_win) or config.ui.window_width or 80
336+
local win_width = (state.windows and state.windows.output_win and vim.api.nvim_win_is_valid(state.windows.output_win))
337+
and vim.api.nvim_win_get_width(state.windows.output_win)
338+
or config.ui.window_width
339+
or 80
338340
if #text > win_width - 4 then
339341
local ok, substituted = pcall(vim.fn.substitute, text, '\v(.{' .. (win_width - 8) .. '})', '\1\n', 'g')
340342
text = ok and substituted or text
@@ -360,7 +362,7 @@ function M._format_user_message(text, message)
360362
context = context_module.extract_from_opencode_message(message)
361363
end
362364

363-
local start_line = M.output:get_line_count() - 1 ---@type number
365+
local start_line = M.output:get_line_count() - 1
364366

365367
M.output:add_empty_line()
366368
M.output:add_lines(vim.split(context.prompt, '\n'))
@@ -378,7 +380,7 @@ function M._format_user_message(text, message)
378380
M.output:add_line(string.format('[%s](%s)', path, context.current_file))
379381
end
380382

381-
local end_line = M.output:get_line_count() ---@type number
383+
local end_line = M.output:get_line_count()
382384

383385
M._add_vertical_border(start_line, end_line, 'OpencodeMessageRoleUser', -3)
384386
end
@@ -519,12 +521,9 @@ function M._format_tool(part)
519521
end
520522

521523
local start_line = M.output:get_line_count() + 1
522-
---@type TaskToolInput|BashToolInput|FileToolInput|TodoToolInput|GlobToolInput|GrepToolInput|WebFetchToolInput|ListToolInput
523-
local input = (part.state and part.state.input) or {}
524-
---@type ToolMetadataBase|TaskToolMetadata|WebFetchToolMetadata|BashToolMetadata|FileToolMetadata|GlobToolMetadata|GrepToolMetadata|ListToolMetadata
525-
local metadata = (part.state and part.state.metadata) or {}
526-
---@type string
527-
local output = (part.state and part.state.output) or ''
524+
local input = (part.state and part.state.input) or {}
525+
local metadata = (part.state and part.state.metadata) or {}
526+
local output = (part.state and part.state.output) or ''
528527

529528
if tool == 'bash' then
530529
M._format_bash_tool(input --[[@as BashToolInput]], metadata --[[@as BashToolMetadata]])
@@ -552,7 +551,7 @@ function M._format_tool(part)
552551

553552
M.output:add_empty_line()
554553

555-
local end_line = M.output:get_line_count() ---@type number
554+
local end_line = M.output:get_line_count()
556555
if end_line - start_line > 1 then
557556
M._add_vertical_border(start_line, end_line - 1, 'OpencodeToolBorder', -1)
558557
end
@@ -581,7 +580,7 @@ function M._format_task_tool(input, metadata, output)
581580
end
582581
end
583582

584-
local end_line = M.output:get_line_count() ---@type number
583+
local end_line = M.output:get_line_count()
585584
M.output:add_action({
586585
text = '[S]elect Child Session',
587586
type = 'select_child_session',

0 commit comments

Comments
 (0)