-
Notifications
You must be signed in to change notification settings - Fork 2.6k
support chat draft #5307
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
support chat draft #5307
Conversation
daniel-lxs
left a comment
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.
Hey @qdaxb, Thank you for your contribution!
I left some suggestions that are worth taking a look at, let me know if you have any questions!
|
I did some research on using Roo Code doesn't use Curious to hear what you think! |
I think this makes the implementation a bit more complex, but considering future maintenance costs, it’s acceptable. |
daniel-lxs
left a comment
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.
Hey @qdaxb, I left a couple of suggestions that are worth taking a look at. Let me know if you have any questions!
| const handleDraftValue = (event: MessageEvent) => { | ||
| const msg = event.data | ||
| if (msg && msg.type === "chatTextDraftValue") { | ||
| if (typeof msg.text === "string" && msg.text && !inputValue) { |
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.
Is there a potential race condition here? The draft is only restored if !inputValue, but what happens if the component receives an initial value before the message handler is set up? Could we miss restoring a valid draft in that case?
| debounceTimerRef.current = setTimeout(() => { | ||
| try { | ||
| // Fast pre-check: if character count is much greater than max bytes, skip encoding | ||
| if (inputValue.length > MAX_DRAFT_BYTES * 2) { |
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.
The pre-check using inputValue.length > MAX_DRAFT_BYTES * 2 might be too conservative. For strings with many multi-byte characters (like emojis or non-Latin scripts), this could reject valid drafts prematurely. Would it make sense to adjust this heuristic or document why 2x was chosen?
Related GitHub Issue
Closes: #5306
Description
Save the content to localStorage regularly to avoid permanent loss of the text being entered
Test Procedure
Pre-Submission Checklist
Screenshots / Videos
Documentation Updates
Additional Notes
Get in Touch
Important
Adds chat draft persistence using
localStoragewith a newuseChatTextDrafthook inChatTextArea.tsx.localStorageinChatTextArea.tsx.useChatTextDrafthook to auto-save drafts every 5 seconds, restore on mount, and clear on send.onSendwithhandleSendAndClearDraftto clear drafts after sending.useChatTextDraft: Manages draft lifecycle withlocalStorage.handleSendAndClearDraft: Clears draft and callsonSend.useChatTextDraftinChatTextArea.tsx.This description was created by
for c307066c1a00412f8209162e6f674186e6b4cf7a. You can customize this summary. It will automatically update as commits are pushed.