From 42b4a8a2fb40e40ca1c9b3898f2c29178a2615d0 Mon Sep 17 00:00:00 2001 From: phanium <91544758+phanen@users.noreply.github.com> Date: Sat, 11 Jul 2026 22:50:15 +0800 Subject: [PATCH 1/5] refactor(renderer): remove dead pinned-overlay scroll short-circuit --- lua/opencode/ui/renderer/flush.lua | 44 +----------------------------- 1 file changed, 1 insertion(+), 43 deletions(-) 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 From 45e8a581872050a80e1e4af7cc47f7f0ec7699ba Mon Sep 17 00:00:00 2001 From: phanium <91544758+phanen@users.noreply.github.com> Date: Sat, 11 Jul 2026 22:56:41 +0800 Subject: [PATCH 2/5] fix: another case --- lua/opencode/ui/permission_window.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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', From bfbbca3c4964e1ffb04daa96200419e15c41adfb Mon Sep 17 00:00:00 2001 From: phanium <91544758+phanen@users.noreply.github.com> Date: Sun, 12 Jul 2026 16:29:57 +0800 Subject: [PATCH 3/5] chore: simplify --- lua/opencode/ui/render_state.lua | 5 +---- lua/opencode/ui/renderer/events.lua | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) 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..a5b2d5d7 100644 --- a/lua/opencode/ui/renderer/events.lua +++ b/lua/opencode/ui/renderer/events.lua @@ -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] From 4528fbc88aa90ce7a6721333e5704552bfa80673 Mon Sep 17 00:00:00 2001 From: phanium <91544758+phanen@users.noreply.github.com> Date: Sun, 12 Jul 2026 16:29:57 +0800 Subject: [PATCH 4/5] chore: dead code --- lua/opencode/ui/renderer/events.lua | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/lua/opencode/ui/renderer/events.lua b/lua/opencode/ui/renderer/events.lua index a5b2d5d7..15748417 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 @@ -412,23 +412,9 @@ 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 + local index = existing_part_index or (is_new_part and (#message.parts + 1) or nil) + if index then + message.parts[index] = part end if part.type == 'step-start' or part.type == 'step-finish' then From ffadf1724a3086e37f659ba5470f9eb4933a0fce Mon Sep 17 00:00:00 2001 From: phanium <91544758+phanen@users.noreply.github.com> Date: Sun, 12 Jul 2026 16:30:09 +0800 Subject: [PATCH 5/5] chore: is_new_part seems not needed here --- lua/opencode/ui/renderer/events.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lua/opencode/ui/renderer/events.lua b/lua/opencode/ui/renderer/events.lua index 15748417..058584af 100644 --- a/lua/opencode/ui/renderer/events.lua +++ b/lua/opencode/ui/renderer/events.lua @@ -412,10 +412,7 @@ function M.on_part_updated(properties, revert_index) end -- Update the part reference in the message - local index = existing_part_index or (is_new_part and (#message.parts + 1) or nil) - if index then - message.parts[index] = part - 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