diff --git a/lua/opencode/ui/permission_window.lua b/lua/opencode/ui/permission_window.lua index 70f2f2bb..e5995a9f 100644 --- a/lua/opencode/ui/permission_window.lua +++ b/lua/opencode/ui/permission_window.lua @@ -244,7 +244,7 @@ function M.format_display(output) title = icons.get('warning') .. ' Permission Required' .. progress, title_hl = 'OpencodePermissionTitle', border_hl = 'OpencodePermissionBorder', - content = render_content and nil or content, + content = content, render_content = render_content, options = options, unfocused_message = 'Focus Opencode window to respond to permission', diff --git a/lua/opencode/ui/render_state.lua b/lua/opencode/ui/render_state.lua index cacb8478..f222928a 100644 --- a/lua/opencode/ui/render_state.lua +++ b/lua/opencode/ui/render_state.lua @@ -212,12 +212,9 @@ end ---@param message_id string ---@return RenderedMessage? function RenderState:get_previous_message(messages, message_id) - for i = #messages, 1, -1 do + for i = #messages, 2, -1 do local message = messages[i] if message and message.info and message.info.id == message_id then - if i <= 1 then - return nil - end local previous_message = messages[i - 1] return previous_message and previous_message.info and self._messages[previous_message.info.id] or nil end diff --git a/lua/opencode/ui/renderer/events.lua b/lua/opencode/ui/renderer/events.lua index 2c901368..058584af 100644 --- a/lua/opencode/ui/renderer/events.lua +++ b/lua/opencode/ui/renderer/events.lua @@ -385,7 +385,7 @@ function M.on_part_updated(properties, revert_index) local is_new_part = not part_data local prev_last_part_id = get_last_part_for_message(message) - local existing_part_index = nil + local existing_part_index = nil ---@type integer? for i = #message.parts, 1, -1 do if message.parts[i].id == part.id then existing_part_index = i @@ -396,7 +396,7 @@ function M.on_part_updated(properties, revert_index) -- Preserve state.input when the update omits it. MCP tool completion -- events sometimes arrive with an empty input table, clobbering the -- call arguments from the earlier running event. - if part.state and part.state.input and type(part.state.input) == 'table' and next(part.state.input) == nil then + if part.state and type(part.state.input) == 'table' and next(part.state.input) == nil then local old_input = nil if existing_part_index then old_input = message.parts[existing_part_index] @@ -412,24 +412,7 @@ function M.on_part_updated(properties, revert_index) end -- Update the part reference in the message - if is_new_part then - if existing_part_index then - message.parts[existing_part_index] = part - else - table.insert(message.parts, part) - end - else - if existing_part_index then - message.parts[existing_part_index] = part - else - for i = #message.parts, 1, -1 do - if message.parts[i].id == part.id then - message.parts[i] = part - break - end - end - end - end + message.parts[existing_part_index or #message.parts + 1] = part if part.type == 'step-start' or part.type == 'step-finish' then if part.type == 'step-finish' and part.tokens then diff --git a/lua/opencode/ui/renderer/flush.lua b/lua/opencode/ui/renderer/flush.lua index f5fb2bfc..1fa54ce5 100644 --- a/lua/opencode/ui/renderer/flush.lua +++ b/lua/opencode/ui/renderer/flush.lua @@ -12,16 +12,6 @@ local append = require('opencode.ui.renderer.append') local M = {} local warned_part_render_error = false -local pinned_overlay_part_ids = { - ['permission-display-part'] = true, - ['question-display-part'] = true, -} - -local pinned_overlay_message_ids = { - ['permission-display-message'] = true, - ['question-display-message'] = true, -} - ---@param part_id string ---@param message_id string|nil ---@param err any @@ -418,39 +408,7 @@ local function apply_pending(pending, render_context) return false end - local only_pinned_overlay_updates = true - for _, part_id in ipairs(pending.removed_part_order) do - if pending.removed_parts[part_id] and not pinned_overlay_part_ids[part_id] then - only_pinned_overlay_updates = false - break - end - end - if only_pinned_overlay_updates then - for _, message_id in ipairs(pending.removed_message_order) do - if pending.removed_messages[message_id] and not pinned_overlay_message_ids[message_id] then - only_pinned_overlay_updates = false - break - end - end - end - if only_pinned_overlay_updates then - for _, message_id in ipairs(pending.dirty_message_order) do - if pending.dirty_messages[message_id] and not pinned_overlay_message_ids[message_id] then - only_pinned_overlay_updates = false - break - end - end - end - if only_pinned_overlay_updates then - for _, part_id in ipairs(pending.dirty_part_order) do - if pending.dirty_parts[part_id] and not pinned_overlay_part_ids[part_id] then - only_pinned_overlay_updates = false - break - end - end - end - - local scroll_snapshot = only_pinned_overlay_updates and nil or scroll.pre_flush(buf) + local scroll_snapshot = scroll.pre_flush(buf) with_suppressed_output_autocmds(function() for _, part_id in ipairs(pending.removed_part_order) do if pending.removed_parts[part_id] then