File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed
Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -189,6 +189,8 @@ M.defaults = {
189189 hooks = {
190190 on_file_edited = nil ,
191191 on_session_loaded = nil ,
192+ on_done_thinking = nil ,
193+ on_permission_requested = nil ,
192194 },
193195}
194196
Original file line number Diff line number Diff line change @@ -366,8 +366,24 @@ function M.initialize_current_model()
366366 return state .current_model
367367end
368368
369+ local function on_job_count_change (_ , new , old )
370+ local done_thinking = new == 0 and old > 0
371+ if config .hooks and config .hooks .on_done_thinking and done_thinking then
372+ pcall (config .hooks .on_done_thinking )
373+ end
374+ end
375+
376+ local function on_current_permission_change (_ , new , old )
377+ local permission_requested = old == nil and new ~= nil
378+ if config .hooks and config .hooks .on_permission_requested and permission_requested then
379+ pcall (config .hooks .on_permission_requested )
380+ end
381+ end
382+
369383function M .setup ()
370384 state .subscribe (' opencode_server' , on_opencode_server )
385+ state .subscribe (' user_message_count' , on_job_count_change )
386+ state .subscribe (' current_permission' , on_current_permission_change )
371387
372388 vim .schedule (function ()
373389 M .opencode_ok ()
Original file line number Diff line number Diff line change 139139--- @class OpencodeHooks
140140--- @field on_file_edited ? fun ( file : string ): nil
141141--- @field on_session_loaded ? fun ( session : Session ): nil
142+ --- @field on_done_thinking ? fun (): nil
143+ --- @field on_permission_requested ? fun (): nil
142144
143145--- @class OpencodeProviders
144146--- @field [ string] string[]
You can’t perform that action at this time.
0 commit comments