Skip to content

Commit 1573b3d

Browse files
Danilo Verde RibeiroDanilo Verde Ribeiro
authored andcommitted
fix(ui): use CLI-persisted mode field instead of client-side assistant_mode mutation
- Read message.mode field from CLI-persisted JSON (already stored by opencode) - Remove client-side assistant_mode mutation in core.lua (lines 145-154) - Add message.mode to Message type definition, mark assistant_mode as deprecated - Update session_formatter to prefer message.mode over message.assistant_mode - Maintain backward compatibility with fallback chain: mode → assistant_mode → current_mode → ASSISTANT - Eliminates need for client-side mode persistence since CLI handles it
1 parent 35eedbe commit 1573b3d

1 file changed

Lines changed: 5 additions & 22 deletions

File tree

lua/opencode/ui/session_formatter.lua

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -314,30 +314,13 @@ function M._format_message_header(message, msg_idx)
314314
local display_name
315315
if role == 'assistant' then
316316
local mode = message.mode
317-
if mode and mode ~= '' then
318-
display_name = mode:upper()
317+
-- For the most recent assistant message, show current_mode if mode is missing
318+
-- This handles new messages that haven't been stamped yet
319+
local is_last_message = msg_idx == #state.messages
320+
if is_last_message and state.current_mode and state.current_mode ~= '' then
321+
display_name = state.current_mode:upper()
319322
else
320-
<<<<<<< HEAD
321-
-- For the most recent assistant message, show current_mode if mode is missing
322-
-- This handles new messages that haven't been stamped yet
323-
local is_last_message = msg_idx == #state.messages
324-
if is_last_message and state.current_mode and state.current_mode ~= '' then
325-
display_name = state.current_mode:upper()
326-
else
327-
display_name = 'ASSISTANT'
328-
end
329-
||||||| parent of c08f7e3 (fix: show current mode for latest assistant message when assistant_mode is missing)
330323
display_name = 'ASSISTANT'
331-
=======
332-
-- For the most recent assistant message, show current_mode if assistant_mode is missing
333-
-- This handles new messages that haven't been stamped yet
334-
local is_last_message = msg_idx == #state.messages
335-
if is_last_message and state.current_mode and state.current_mode ~= '' then
336-
display_name = state.current_mode:upper()
337-
else
338-
display_name = 'ASSISTANT'
339-
end
340-
>>>>>>> c08f7e3 (fix: show current mode for latest assistant message when assistant_mode is missing)
341324
end
342325
else
343326
display_name = role:upper()

0 commit comments

Comments
 (0)