Skip to content

feat(utility): create an utility for the ai assistant COMPASS-11269 - #8636

Merged
esvm merged 20 commits into
mainfrom
COMPASS-11269-utility
Nov 3, 2026
Merged

esvm merged 20 commits into
mainfrom
COMPASS-11269-utility

Conversation

@esvm

@esvm esvm commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Keeping up the work for using electron utilities, I'm creating an utility for the AI Assistant. There's a stacked PR actually making use of this utility.

I had some issues with the size of the bundled app. That's because of some imports which duplicate some code, so I tried to optimize the bundle as much as I could

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • If this change could impact the load on the MongoDB cluster, please describe the expected and worst case impact
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@esvm esvm self-assigned this Oct 28, 2026
Copilot AI balanced review requested due to automatic review settings October 28, 2026 18:32
@github-actions github-actions Bot added the feat label Oct 28, 2026
@esvm esvm changed the title feat: ai assistant utility feat: ai assistant utility COMPASS-11269 Oct 28, 2026
@esvm
esvm added this pull request to stack #8638 October 28, 2026 18:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The extracted runner calls an unsupported createServer() method that prevents MCP startup, while overlapping tool calls can invoke or disconnect the wrong provider through shared connection state.

4 open issues
What changed in this PR

Adds utility-process infrastructure for Compass’s AI assistant database tools, separating tool execution from renderer-side communication.

Changes:

  • Introduces a tools host, request/response messaging, cancellation, and BSON-aware connection parameter transfer.
  • Registers the assistant utility and adjusts utility bundling to share dependencies.
  • Adds tests for messaging, tool hosting, serialization, and port lifecycle behavior.
File Description
packages/​compass/​webpack.config.js Shares utility dependencies and disables utility coverage instrumentation.
packages/​compass/​src/​utilities/​ai-assistant/​index.spec.mts Tests utility logging, requests, and port closure.
packages/​compass/​src/​utilities/​ai-assistant/​index.mts Creates a tools host for each renderer port.
packages/​compass/​src/​main/​application.ts Registers the AI assistant utility.
packages/​compass-utils/​src/​utility-process.ts Starts renderer-side utility ports.
packages/​compass-utils/​src/​utility-process.spec.ts Tests port transfer and startup.
packages/​compass-generative-ai/​src/​tools/​infrastructure/​tools-host.ts Hosts database tools and manages connections.
packages/​compass-generative-ai/​src/​tools/​infrastructure/​tools-host.spec.ts Tests tool listing, configuration, failures, and shutdown.
packages/​compass-generative-ai/​src/​tools/​infrastructure/​server.ts Dispatches requests and propagates cancellation.
packages/​compass-generative-ai/​src/​tools/​infrastructure/​rpc-client.ts Tracks requests, responses, and cancellation.
packages/​compass-generative-ai/​src/​tools/​infrastructure/​rpc-client.spec.ts Tests messaging and lifecycle behavior.
packages/​compass-generative-ai/​src/​tools/​infrastructure/​noop-metrics.ts Provides a no-op metrics implementation.
packages/​compass-generative-ai/​src/​tools/​infrastructure/​messages.ts Defines the tools messaging protocol.
packages/​compass-generative-ai/​src/​tools/​infrastructure/​in-memory-runner.ts Adds an in-memory MCP server runner.
packages/​compass-generative-ai/​src/​tools/​infrastructure/​connect-params.ts Restores BSON prototypes after port transfer.
packages/​compass-generative-ai/​src/​tools/​infrastructure/​connect-params.spec.ts Tests connection parameter serialization.
packages/​compass-generative-ai/​package.json Exports the utility host and makes BSON a runtime dependency.
package-lock.json Reflects the BSON dependency classification.

Review effort: Balanced

@esvm
esvm force-pushed the COMPASS-11269-utility branch from 386dbdd to 313b59b Compare October 29, 2026 12:28
@esvm
esvm marked this pull request as ready for review October 29, 2026 13:50
@esvm
esvm requested a review from a team as a code owner October 29, 2026 13:50
@esvm
esvm requested review from ivandevp and nbbeeken October 29, 2026 13:50
@esvm
esvm removed this pull request from stack #8638 October 30, 2026 13:16
@esvm
esvm force-pushed the COMPASS-11269-utility branch from b037746 to 14b5c88 Compare November 2, 2026 09:39
@esvm esvm changed the title feat: ai assistant utility COMPASS-11269 feat(utility): create an utility for the ai assistant COMPASS-11269 Nov 2, 2026
* Renderer-side client. `port` is the end of the channel returned by
* `openUtilityPort`.
*/
export function createRuntimeClient(port: MessagePort): {

@nbbeeken nbbeeken Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just a note for anyone else looking here: Edjan and I discussed how we're going to need to repeat this pattern for the other services too, particularly data service, it should be easy when I work on data-service to make one sharable implementation that just extends this a bit for AbortSignal support etc. (actually just saw this does support signal so maybe it'll just be extraction to a shared package!)

for (const entryValue of Array.isArray(value)
? value
: Object.values(value)) {
collectBsonValues(entryValue, found, seen);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Another thing for us to move somewhere shared later, we have the same logic in the shell parsing package, fine to have here for now

@nbbeeken
nbbeeken removed the request for review from ivandevp November 2, 2026 14:18
@esvm
esvm merged commit d92ccfe into main Nov 3, 2026
54 of 56 checks passed
@esvm
esvm deleted the COMPASS-11269-utility branch November 3, 2026 11:42
Comment thread packages/compass-web/src/utilities.mts Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants