Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: AppMap AI: Explain #859

Merged
merged 17 commits into from
Jan 15, 2024
Merged

feat: AppMap AI: Explain #859

merged 17 commits into from
Jan 15, 2024

Conversation

kgilpin
Copy link
Contributor

@kgilpin kgilpin commented Jan 10, 2024

Dependencies

Commands

  • AppMap: AI Explain top-level command

Running this command opens the Explain UI page.

Screen Shot 2024-01-10 at 7 31 44 PM
  • Explain with AppMap AI quick search command from an open editor.

When the user selects some code in a supported language, the "light bulb" appears. This is known in VSCode as "Quick Search", it opens the AppMap Explain AI page with the question pre-populated with the user's selection.

Screen Shot 2024-01-10 at 7 32 15 PM

Considerations

AppMap state

AppMap state (basically, the filter popup), can be saved, applied, and transferred to and from the clipboard. This functionality should work for the AppMaps shown in the Explain UI as well.

AppMap RPC server

The appmap index command should be launched with options --port 0. With this option, the index process will run a JSON-RPC service on an OS-assigned port. JSON-RPC was chosen for the transport because it's also used by the Language Server Protocol.

The port is printed to stdout by the index command, so the Plugin should scan stdout to determine this port.

When an Explain UI page is launched, it should be provided with this port number via the appmapRpcPort property.

API key

The AppMap RPC server makes HTTP calls to the AppMap API services, including a hosted completion AI. Therefore, the user must have an AppMap API key to run the RPC server. The API key is provided to the appmap index command using the environment variable APPMAP_API_KEY.

Not shown in this PR - the AppMap API key is also provided to the Help chat and Explain chat directly as a property, so that the chat UI can send user feedback to the AppMap API services (thumbs up / thumbs down).

@kgilpin kgilpin self-assigned this Jan 10, 2024
@kgilpin kgilpin added the enhancement New feature or request label Jan 10, 2024
img-src ${webview.cspSource} data:;
script-src ${webview.cspSource} 'unsafe-eval';
style-src ${webview.cspSource} 'unsafe-inline';
">
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't remove the CSP; if we want the UI to be able to connect to the server (which I don't think it should be able to do directly) then we need to set it as small as possible, cf. #845 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know how to update the CSP to something that will work. If you can contribute a working snippet I'd be happy to apply it. Decoupling the frontend from the RPC is not something we will take on at this time; since it's already an abstraction over the CLI and the AI backend, I'm not sure why another layer on top of that would be needed or what it would contirbute?

Copy link
Contributor

@dividedmind dividedmind Jan 13, 2024

Choose a reason for hiding this comment

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

I added the CSP back in 006ad8b — what was needed was fetch-src http://localhost:${rpcPort}.

@kgilpin kgilpin merged commit 8a6d17e into develop Jan 15, 2024
2 checks passed
@kgilpin kgilpin deleted the feat/explain branch January 15, 2024 15:48
@appland-release
Copy link
Contributor

🎉 This PR is included in version 0.107.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants