Skip to content

feat(acp): fire CodeCompanionACPSessionPre event before session establishment#2938

Merged
olimorris merged 1 commit into
olimorris:mainfrom
georgeharker:acp-extension-hook
Mar 26, 2026
Merged

feat(acp): fire CodeCompanionACPSessionPre event before session establishment#2938
olimorris merged 1 commit into
olimorris:mainfrom
georgeharker:acp-extension-hook

Conversation

@georgeharker

Copy link
Copy Markdown
Contributor

Description

Fire the User event 'ACPSessionPre' (which Neovim broadcasts as 'CodeCompanionACPSessionPre') after connect_and_authenticate() succeeds but before _establish_session() runs in both:

  • Connection:connect_and_initialize() - initial connection path
  • Connection:ensure_session() - reconnection path

This gives consumers a synchronous hook to inspect _agent_info (populated after INITIALIZE RPC) and modify adapter_modified.defaults (e.g. mcpServers) before the session/new request is sent.

The event data includes { connection = self } so handlers have full access to the connection object.

AI Usage

Ai for documentation updates, adding tests.

Related Issue(s)

#2932

Screenshots

n/a

Checklist

  • I've read the contributing guidelines and have adhered to them in this PR
  • I confirm that this PR has been majority created by me, and not AI (unless stated in the "AI Usage" section above)
  • I've run make all to ensure docs are generated, tests pass and StyLua has formatted the code
  • (optional) I've added test coverage for this fix/feature
  • (optional) I've updated the README and/or relevant docs pages

Comment thread doc/usage/events.md Outdated
Comment thread tests/acp/test_acp.lua Outdated

@olimorris olimorris left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good to me. We can just streamline the docs and the test

@georgeharker

Copy link
Copy Markdown
Contributor Author

Sure! Want a more single-line doc entry? And for tests?

…lishment

Fire the User event 'ACPSessionPre' (which Neovim broadcasts as
'CodeCompanionACPSessionPre') after connect_and_authenticate() succeeds
but before _establish_session() runs in both:

- Connection:connect_and_initialize() - initial connection path
- Connection:ensure_session() - reconnection path

This gives consumers a synchronous hook to inspect _agent_info
(populated after INITIALIZE RPC) and modify adapter_modified.defaults
(e.g. mcpServers) before the session/new request is sent.

The event data includes { connection = self } so handlers have full
access to the connection object.

@georgeharker georgeharker left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved the comments.

@olimorris olimorris merged commit 754979b into olimorris:main Mar 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants