Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions lua/opencode/ui/renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -839,8 +839,31 @@ function M.on_session_updated(properties)
if not properties or not properties.info or not state.active_session then
return
end
if not vim.deep_equal(state.active_session.revert, properties.info.revert) then
state.active_session.revert = properties.info.revert

local updated_session = properties.info
if not updated_session.id or updated_session.id ~= state.active_session.id then
return
end

local current_session = state.active_session
local revert_changed = not vim.deep_equal(current_session.revert, updated_session.revert)
local previous_title = current_session.title

local merged_session = vim.tbl_deep_extend('force', vim.deepcopy(current_session), updated_session)

if not vim.deep_equal(current_session, merged_session) then
-- mutate existing `state.active_session` table in place
-- reassigning would cause UI flickering on frequent `session.updated` events since it triggers a full rerender
for key, value in pairs(merged_session) do
current_session[key] = value
end

if updated_session.title and updated_session.title ~= previous_title then
require('opencode.ui.topbar').render()
end
end

if revert_changed then
M._render_full_session_data(state.messages)
end
end
Expand Down
Loading