sourcegraph / cody

AI that knows your entire codebase
https://cody.dev
Apache License 2.0
2.25k stars 215 forks source link

Cody Web: fix cody web UI flashes problem #4757

Closed vovakulikov closed 1 day ago

vovakulikov commented 2 days ago

Based on https://github.com/sourcegraph/cody/pull/4756 Closes SRCH-632

After this change we will be able to publish Cody Web package from main again.

This PR fixes UI-flash problems when we switch chats or set the initial chat transcript. Previously, the CodyWebChat component didn't wait for any restoring event and render all available transcripts right away, this caused problems when you opened the chat and could see how we render empty chat only then render actual transcript UI.

This PR makes CodyWebChat wait for the actual current chat restoration and fixes the problem with flashing.

Tech note: I'm not happy with the current approach with refs and panel and chat ids states but for now it seems as a reasonable fix. Later I will refactor the provider state in a way that cody web chat component wouldn't subscribe in vscode API

Test plan

github-actions[bot] commented 1 day ago

‼️ Hey @sourcegraph/cody-security, please review this PR carefully as it introduces the usage of an unsafe_ function or abuses PromptString.