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
Cody standalone web app prototype and dev helper #4047
Conversation
|
bb21433
to
7d33601
Compare
396d581
to
ef4797d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments inline at your discretion.
This is pretty interesting as something heavier than Storybook but lighter than the extension.
How big is the burden for DOM and Node APIs, in the limit? Part of me is wondering if we could run Agent in-process in JetBrains in a JavaScript environment.
@sqs, have you tried building this package? It seems that the target output module is having a problem with web worker creation.
I've tried changing the target and formats for the build option but it had no effect. Also, I probably should compile/build this with lib mode or don't build this at all, because I'm not sure how the pre-build module will go with module resolution on the consumer side (I guess web-worker URI resolution won't work)
This would mean that consumers should override shims themselves, but maybe this is needed anyway because we won't have dynamic shims for file resolution, for example. |
Found |
@vovakulikov No, I haven't tried building this package. I haven't thought through the best way to allow the consumer to shim it, but since it's just 1 real consumer for now (sourcegraph), it's probably fine to have something that's not yet generalized. |
FYI, I'm going to rebase and merge this because there are some changes (to the chat message editor UI) that I'd like to make that would be a lot easier to iterate on with this. (But as the PR description states, |
This lets the agent run in web or node (instead of hard-coding the import of the node `activate`).
There is some static initialization (converting an emoji to SVG) that is now bypassed when running in the agent. The main motivation for this is Cody Web, where the tutorial is not needed and the emoji-to-SVG conversion would require polyfilling Buffer.
ef4797d
to
c1ed570
Compare
Interesting idea. If you're referring to the extra burden of running the agent in a Web Worker vs. just running it as a separate node process, I don't anticipate it would be much (either in terms of resource consumption or complexity). It might be trickier to do certain HTTP proxy things in the worker, though, which have been a pain in the past. |
Yeah, I don't worry about generalized API at the moment, but since we override native nodejs API with "vite replacements," it means that these noop API implementations with which we replaced NodeJs implementation are included in the bundle, and the consumer doesn't have any API to get access to them. We need this for instance to provide the right list of files for suggestions in the chat input UI ( So what I have in mind is either
// fs__promises.ts
import type { Dirent, Stats } from 'node:fs'
import { CodyContextStore } from './context-store'
export function readdir(): Promise<Dirent[]> {
return Promise.resolve(CodyContextStore.DIRECTORIES)
} // context-store.ts
export class CodyContextStore {
static DIRECTORIES = []
static setContextDirectories(dirs: Dirent) {
CodyContextStore.DIRECTORIES = dirs
}
...
} Then, the consumer, as we go to the blob UI page, will set |
@vovakulikov Yep, makes sense. Either of those seem like good approaches. And eventually we'll probably get to the ultimate state where |
The
web/
subdir implements a standalone web app for Cody for development purposes only. This is useful:web/
shim might be insufficient.The web app runs the Cody agent in a Web Worker, with some noop shims. Known issues:
It is OK to break
web/
in your other PRs; don't waste time trying to make it work (until further notice, anyone relying onweb/
is responsible for keeping it working).Try it out at https://noodle-cody-web-x847yqf4z.netlify.app/ and enter a Sourcegraph.com access token.
Test plan
Run
pnpm -C web dev
and visit http://localhost:5777. After entering a Sourcegraph.com access token, you should see the chat webview UI and be able to select models and chat.Nothing in the VS Code extension or agent should break or change behavior as a result of this change.