Ceara/aitt fix new thread behavior #67866
Merged
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.
This is a fix for a bug @MollyPeredo noted where you couldn't create a new thread using the "New thread" button if you are still in a thread started with the new thread button.
This is because we previously set the key for the chat component as 0 for a new thread and the thread id for old threads. We set the key when switching threads to re-set the State of the chat component to clear the message history and reset it from params. On a new thread with key == 0, we don't reset the key to the newly created threadID because we want to keep the messagehistory and view as-is. The key remained until switching threads from the sidebar, which cause problems when trying to create a new thread from a previous new thread, because both keys are 0.
This change just alternates 0 and -1 as keys for new threads. -1 is used so it won't accidentally clash with a real thread ID.
Video:
Screen.Recording.2025-08-20.at.7.13.33.PM.mov
Links
slack thread about bug: https://codedotorg.slack.com/archives/C050HE4QDHR/p1755200424919449?thread_ts=1755196263.126769&cid=C050HE4QDHR
Included in jira ticket: https://codedotorg.atlassian.net/browse/AITT-1115
Testing story
Previous non-thread tests are passing