-
Notifications
You must be signed in to change notification settings - Fork 117
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
Refactor InputBar with Tip Tap Library #2992
Conversation
|
||
const SUGGESTION_DISPLAY_LIMIT = 7; | ||
|
||
export function makeGetAssistantSuggestions(suggestions: EditorSuggestion[]) { |
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.
Typpy has limited coverage for TypeScript types, so I've used any as a temporary solution (see the PR description for details).
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.
Code looks great! Incredible improvement.
From testing:
-
Blocking for merge IMHO:
- Placeholder should disapear on focus
-
Non blocking for merge (which you mention in the description)
- The suggestion moving below the cursor when there's only one element left
As you mention this component is quite critical. I would suggest getting a +1 from everyone before deploy based on testing on front-edge.
Assume you have my +1 as soon as the placeholder thing is resolved 👍
Oh and as per IRL let's move everything in an input_bar folder 🙏 |
ea46008
to
4e6f6f0
Compare
@@ -1,994 +0,0 @@ | |||
import { |
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.
This file has been moved to input_bar
. No changes.
Awesome work 🔥 As per slack, 2 small issues identified:
|
(but other than that you have my +1 as well) |
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.
Just caught a little setTimeout() not being cleaned-up while debugging the missing file bug.
useEffect(() => { | ||
if (animate && !isAnimating) { | ||
setIsAnimating(true); | ||
setTimeout(() => setIsAnimating(false), 1500); |
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.
are we not missing a timeout clean up here in the return of useEffect()?
Keen to see it shipped ! 👍 for me too |
@lasryaric done in 5e1f3bd :) |
// for operations that cannot rely on the normal asynchronous nature of setState. | ||
// This is not an ideal solution and should be addressed with a more robust state management strategy | ||
// as a follow-up action to minimize unnecessary re-renders and improve component performance. | ||
function useSyncedState<T>(initialValue: T | undefined) { |
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.
It's far from ideal, but this requires some more refactoring that falls out of scope of this already pretty big PR. The issue lies in dependencies that are not stable which leads to re-rendering.
Also from the react documentation:
The set function only updates the state variable for the next render. If you read the state variable after calling the set function, you will still get the old value that was on the screen before your call.
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.
Truly amazing job! Thanks.
Description
This PR overhauls the fundamental workings of the input bar (distinct from the code definition, which includes the generation animation and additional logic). Specifically, this update replaces the complex, legacy code in the
InputBar
file, which previously managed a content-editable interface, with a new implementation powered by TipTap.Enhancements introduced in this update include:
🔈 Additional changes were made during the overhaul:
Pending issues to address include:
Implementing file type filtering during uploads to ensure only supported files can be selected (was already broken).🔮 Long-term enhancements on the horizon:
any
) for positioning the dropdown when typing@
will need revisiting for potential dependency removal.Undertaking such a refactoring carries the inherent risk of regressions. The input bar is a pivotal component, serving as the initial interface for users interacting with Dust. However, this modernization significantly reduces complexity, boosting our development velocity and simplifying maintenance. It also opens the door to effortlessly integrating text formatting features like bold, italics, and code blocks (which could be leverage to influence the models).
Tests
Design
The design does not change from the former implementation.
On mobile:
Action items before merging:
input_bar
folder