Skip to content

Commit ed0c078

Browse files
committed
perf(event_manager): Ignore server.heartbeat events
These events were triggering event flush every 40ms Even if there was no streaming events. This should avoid refreshing the output pane periodically when trying to keep the scrolling in sync
1 parent 2546ca5 commit ed0c078

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

lua/opencode/event_manager.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ local log = require('opencode.log')
183183
--- @field state_cwd_listener function|nil Listener for state.current_cwd updates
184184
--- @field is_started boolean Whether the event manager is started
185185
--- @field captured_events table[] List of captured events for debugging
186+
--- @field ignored_events string[] List of event types to ignore when capturing
186187
--- @field throttling_emitter ThrottlingEmitter Throttle instance for batching events
187188
local EventManager = {}
188189
EventManager.__index = EventManager
@@ -197,6 +198,7 @@ function EventManager.new()
197198
state_cwd_listener = nil,
198199
is_started = false,
199200
captured_events = {},
201+
ignored_events = { 'server.heartbeat' },
200202
_parts_by_id = {},
201203
}, EventManager)
202204

@@ -553,6 +555,14 @@ function EventManager:_subscribe_to_server_events(server)
553555
local api_client = state.api_client
554556

555557
local emitter = function(event)
558+
if not event or not event.type then
559+
log.warn('Received malformed event from server: %s', vim.inspect(event))
560+
return
561+
end
562+
if self.ignored_events and vim.tbl_contains(self.ignored_events, event.type) then
563+
log.debug('Ignoring event of type %s', event.type)
564+
return
565+
end
556566
self.throttling_emitter:enqueue(event)
557567
end
558568

0 commit comments

Comments
 (0)