sourcegraph / cody

Type less, code more: Cody is an AI code assistant that uses advanced search and codebase context to help you write and fix code.
https://cody.dev
Apache License 2.0
2.27k stars 214 forks source link

openctx: set preloadDelay to 5 seconds #4603

Closed keegancsmith closed 2 weeks ago

keegancsmith commented 2 weeks ago

OpenCtx will now fetch and require all providers after 5 seconds. This removes the initial delay which can be noticed when you open up cody chat for the first time and ask for a mention quickly. Instead we do that work after the Cody extension has been activated.

Note that by default Cody only has bundled providers which do not require fetching, making the preload not useful. However, if you configure remote providers this makes a noticeable difference.

5 seconds is a conservative number to prevent this optimization conflicting with other parts of Cody needing the network at startup. We can be more aggressive if we find we need to be.

I also intend a way to show "still loading" if a user does manage to startup a Cody chat mention before preload has run. This will be done in another PR.

Test Plan: Have my usual many remote providers. Add a provider which 404s. I then start up vscode wait 10s then start a new chat. The 404 provider shows an error straight away (but not before starting chat). mention menu is instantly loaded.

Parent https://github.com/sourcegraph/cody/pull/4600

Fixes https://linear.app/sourcegraph/issue/CODY-1898/preload-openctx-providers-for-faster-user-typing