Repository navigation
✍️ fix: Keep an Unsent Draft in the Composer When a Run It Did Not Send Starts - #18472
Draft
danny-avila wants to merge 1 commit into
Draft
danny-avila wants to merge 1 commit into
danny-avila wants to merge 1 commit into
Conversation
Collaborator
Author
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This was referenced Nov 18, 2026
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Words written in the composer and not sent are lost when a run starts that the composer did not send. Type a draft, then click Regenerate on the last reply: the composer empties at once, and when the rerun ends the draft is gone for good. The same happens when a run started somewhere else reaches the conversation on screen (a second tab sending in it, for one): the tab holding the draft empties its composer as it attaches.
The composer saves its text under the conversation while idle and under a pending key while a run is under way. When a run starts,
useAutoSavewrites the field to the conversation's record and then restores the pending record over the field. For a send that is right: the send has already emptied the field. For any other run the field still holds the reader's words, the pending record is empty, and the restore blanks them. The end of the run then clears the conversation's record, which by then is their only copy. Staged files were already carried across this switch; text was not.With this change, words still in the composer when a run starts stay there, as staged files do. They are saved under the pending key for the run's duration and become the conversation's draft again when it ends. A composer drawn for the first time with words already in it, and no record to restore, keeps them too; that is what lets a composer mounted by something other than the route start from text it was handed.
How it works
sameComposerPhaseis the existing branch that saves the live composer under the new key instead of restoring that key's record over it. It now also holds at the start of a run when the field has text. The end of a run is left as it was: the pending record is moved to the conversation and restored, which is the path the tests for typing as a run finishes cover.A send is unaffected because
submitMessageresets the form in the same event that starts the run, so the field is empty by the time this effect sees the switch.Type of change
Testing
Reproduced in a real browser on the mock e2e lane, one tab: send a message, type
a draft I have not sent, click Regenerate. Before the change the composer read""half a second later, the text sat under the conversation's draft key for the length of the run, and after the run both the field and storage were empty. After the change the field keeps the words through the run and after it, and a reload restores them as the conversation's draft.The two-tab case (a draft in one tab, a slow reply started in the same conversation from another) was reproduced before the change and not re-run after it; it goes through the same switch.
The new unit tests fail with the change removed (2 of 63), and the new scenario fails against a build without it (
Expected: "still writing this one",Received: "").Tested environments/configuration:
Automated tests:
client: new cases insrc/hooks/Input/useAutoSave.spec.ts(a draft held when a run starts stays, is kept under the pending key, and is the conversation's draft when the run ends; an empty composer still restores the pending record; a composer drawn with words and no record keeps them).npx jest src/hooks/Input src/components/Chat/Input: 52 suites, 1200 tests pass.@scenario:composer-draft-survives-a-regenerateine2e/specs/mock/scenarios/composer-draft-survives-run.spec.ts.