-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Make it possible to dogfood new prompt editor (#7094)
Closes https://linear.app/sourcegraph/issue/SRCH-1667/no-results-returned-when-enabling-feature-for-queries This PR fixes an issue with the prompt input being cleared out when a query is submitted and the new input is enabled. ## Root cause The root cause for this issue is twofold: 1. Evaluating feature flags is always asynchronous. The first time `HumanMessageEditor` is rendered we will render the old editor. 1. In the same component, `useImperativeHandle` is only run once when the component is mounted. This means we never update the ref with the ref from the new editor once the feature flag updates. The consequence of this is that everywhere else where `editorRef` is used we have a reference to the _old_ editor API, which has been destroyed since. Reading the value from it will of course be empty, which in turn causes the input value of the rendered editor to be overwritten. ## Solution It seems obvious to remove the empty dependency list from the `useImperativeHandle` call to make that the ref is always updated. We do this in other places too (`Transcript.tsx`). However, Vova pointed out that there can still be race conditions between accessing `humanEditoRef` and the feature flag loading and suggested that we should retrieve the feature flag value before we render any UI. I've extended the object returned by `getConfigForWebview` but I'm not sure whether that's the right place to put it. I've also heard that we want to make as few network requests as possible during initialization, which is understandable. > [!IMPORTANT] > I'd like some guidance from the cody team on where put this setting to ensure avoid the aforementioned problem. ## Test plan 1. Enabled the feature flag for myself on S2. 1. Ran the standalone web demo (`cd client/web; pnpm dev`) 1. Verified that the new input used (typing `@...` looks slightly different) 1. Submitting a query does not clear the input and generates an appropriate response.
- Loading branch information
Showing
5 changed files
with
16 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters