File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ trim_trailing_whitespace = false
1515
1616[* .lua ]
1717indent_size = 4
18+ insert_final_newline = true
1819
1920[Makefile ]
20- indent_style = tab
21+ indent_style = tab
Original file line number Diff line number Diff line change @@ -839,6 +839,21 @@ integrating with other plugins.
839839 --- @type agentic.PartialUserConfig
840840 opts = {
841841 hooks = {
842+ -- Called when a new ACP session is created (or fails to create)
843+ on_create_session_response = function (data )
844+ -- data.session_id: string|nil - The ACP session ID (nil if err is set)
845+ -- data.tab_page_id: number - The Neovim tabpage ID
846+ -- data.response: table|nil - The ACP session creation response (nil if err is set)
847+ -- data.err: table|nil - Error details if session creation failed
848+ if data .response then
849+ vim .notify (" New session: " .. data .response .sessionId )
850+ end
851+
852+ if vim .api .nvim_tabpage_is_valid (data .tab_page_id ) then
853+ vim .t [data .tab_page_id ].agentic_usage = nil
854+ end
855+ end ,
856+
842857 -- Called when the user submits a prompt
843858 on_prompt_submit = function (data )
844859 -- data.prompt: string - The user's prompt text
Original file line number Diff line number Diff line change @@ -601,6 +601,12 @@ Event hooks ~
601601 --- @type agentic.PartialUserConfig
602602 opts = {
603603 hooks = {
604+ on_create_session_response = function(data)
605+ -- data.response: table|nil - The ACP session creation response (nil if err is set)
606+ -- data.err: table|nil - Error details if session creation failed
607+ -- data.session_id: string
608+ -- data.tab_page_id: number
609+ end,
604610 on_prompt_submit = function(data)
605611 -- data.prompt: string
606612 -- data.session_id: string
@@ -934,4 +940,4 @@ Persistent ACP message log:
934940 `~/.cache/nvim/agentic_debug.log `
935941
936942==============================================================================
937- vim:tw=78:ts=8:ft=help:norl:
943+ vim:tw=78:ts=8:ft=help:norl:
Original file line number Diff line number Diff line change 2323---
2424--- @alias agentic.UserConfig.Headers table<agentic.ui.ChatWidget.PanelNames , agentic.ui.ChatWidget.HeaderParts | agentic.UserConfig.HeaderRenderFn | nil>
2525
26+ --- Data passed to the on_create_session_response hook
27+ --- @class agentic.UserConfig.CreateSessionResponseData
28+ --- @field session_id string | nil
29+ --- @field tab_page_id number
30+ --- @field response agentic.acp.SessionCreationResponse | nil
31+ --- @field err ? agentic.acp.ACPError
32+
2633--- Data passed to the on_prompt_submit hook
2734--- @class agentic.UserConfig.PromptSubmitData
2835--- @field prompt string The user ' s prompt text
164171--- @field tool_calls agentic.UserConfig.Folding.ToolCalls
165172
166173--- @class agentic.UserConfig.Hooks
174+ --- @field on_create_session_response ? fun ( data : agentic.UserConfig.CreateSessionResponseData ): nil
167175--- @field on_prompt_submit ? fun ( data : agentic.UserConfig.PromptSubmitData ): nil
168176--- @field on_response_complete ? fun ( data : agentic.UserConfig.ResponseCompleteData ): nil
169177--- @field on_session_update ? fun ( data : agentic.UserConfig.SessionUpdateData ): nil
@@ -470,6 +478,7 @@ local ConfigDefault = {
470478 },
471479
472480 hooks = {
481+ on_create_session_response = nil ,
473482 on_prompt_submit = nil ,
474483 on_response_complete = nil ,
475484 on_session_update = nil ,
Original file line number Diff line number Diff line change @@ -27,8 +27,8 @@ local FILE_MUTATING_KINDS = {
2727}
2828
2929--- Safely invoke a user-configured hook
30- --- @param hook_name " on_prompt_submit" | " on_response_complete" | " on_session_update" | " on_file_edit"
31- --- @param data agentic.UserConfig.PromptSubmitData | agentic.UserConfig.ResponseCompleteData | agentic.UserConfig.SessionUpdateData | agentic.UserConfig.FileEditData
30+ --- @param hook_name " on_create_session_response " | " on_prompt_submit" | " on_response_complete" | " on_session_update" | " on_file_edit"
31+ --- @param data agentic.UserConfig.CreateSessionResponseData | agentic.UserConfig. PromptSubmitData | agentic.UserConfig.ResponseCompleteData | agentic.UserConfig.SessionUpdateData | agentic.UserConfig.FileEditData
3232function P .invoke_hook (hook_name , data )
3333 local hook = Config .hooks and Config .hooks [hook_name ]
3434
@@ -953,6 +953,16 @@ function SessionManager:new_session(opts)
953953 self .agent :create_session (handlers , function (response , err )
954954 self .status_animation :stop ()
955955
956+ --- @type agentic.UserConfig.CreateSessionResponseData
957+ local hook_data = {
958+ session_id = response and response .sessionId ,
959+ tab_page_id = self .tab_page_id ,
960+ response = response ,
961+ err = err ,
962+ }
963+
964+ P .invoke_hook (" on_create_session_response" , hook_data )
965+
956966 if err or not response then
957967 -- no log here, already logged in create_session
958968 self .session_id = nil
You can’t perform that action at this time.
0 commit comments