serenadeai / serenade

Apache License 2.0
317 stars 57 forks source link

Custom App Icon from Plugin #1

Closed charlespascoe closed 2 years ago

charlespascoe commented 2 years ago

Context

This is mainly something to make the interface a bit prettier, particularly as more people create plugins for Serenade.

Goals

I'd like to be able to pass a custom app icon from a plugin, so that as new plugins for new editors/terminals/browsers/etc. are created, the plugin author can provide an icon rather than it defaulting to a generic icon.

Proposed Solution

A few potentially helpful implementation details that I've figured out from exploring the source code:

I may have missed some other edge cases (e.g. what to do when the plugin disconnects, though that may already be handled by the current logic - I'm still reading the code), so please provide any additional guidance if necessary.

I'd be happy to implement this if the above sounds reasonable - it would give me the opportunity to set up my dev environment for Serenade and start contributing to the project.

Alternatives

The alternative is that you have to keep updating Serenade with an ever-growing list of icons ;)

tmacwill commented 2 years ago

thanks for the suggestion! I like this idea a lot, and agree with your implementation. this also adds minimal complexity to the application, which is great.

a few things you might want to consider:

will add the approved tag to this issue, and feel free to assign to yourself if you're interested in implementing! fwiw, since this is a client-only change, you won't have to worry about setting up all the dependencies for the speech engine, code engine, etc.

charlespascoe commented 2 years ago

Great! I'll start working on it, though I can't seem to assign this issue to myself.

The size of the icons should be fairly small compared to any limits the Electron IPC should impose, but I'll double check before submitting a pull request. It's also worth noting the icon wouldn't be sent frequently, only when the application is focused or the plugin changes the icon (which is a cool idea that I hadn't thought of).

I agree there should be some size limit; I created a 48x48 icon (which larger than what is displayed) that was 1.6KB raw or 2.2KB when encoded as a data: URL string, so maybe a 8KB or 16KB limit on the length of the icon string should limit any performance issues.

I'll also update the relevant documentation; it seems web/src/components/docs/protocol/messages-reference.tsx would be the right place to document this new field, but is there anywhere else I should update?

tmacwill commented 2 years ago

sounds great! just assigned to you. that's the right place to update in the documentation as well.