Reset the conversation Documents pane on New chat - #1300
Merged
Paul Lizer (paullizer) merged 1 commit intoAug 19, 2026
Conversation
Clicking New chat left the previous conversation's documents listed in the conversation side drawer, kept the header documents toggle and count badge visible, and prevented the drawer from closing. The Contents pane reset correctly, so the two modes behaved inconsistently. createNewConversation() fires chat:conversation-context-changed with a null conversation id before the new conversation exists, but refreshConversationDocuments() resolved a falsy id by falling back to getCurrentConversationId(). At that moment window.currentConversationId still pointed at the conversation being left, so the reset signal was executed as a refresh of the old conversation and its documents were re-rendered. refreshConversationDocuments() now accepts allowCurrentConversationFallback (default true), and the context-changed listener passes false so an empty id means reset rather than reload current. The existing empty-id branch already performed the full reset; it was simply unreachable. Conversation selection, the chat:conversation-documents-refresh path, and module init keep the fallback. Fixes microsoft#1298 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Paul Lizer (paullizer)
merged commit Aug 19, 2026
1610a55
into
microsoft:Development
11 of 12 checks passed
Paul Lizer (paullizer)
added a commit
that referenced
this pull request
Aug 19, 2026
PR #1300 landed on Development and claimed 0.260.004, so this branch moves to 0.260.005 and its release notes entries move into a new 0.260.005 section above the merged 0.260.004 entry. The fixes index keeps both new entries. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.
Fixes #1298
Problem
The chat conversation side drawer has two modes, Contents and Documents. Clicking New chat emptied Contents and closed the drawer, but Documents kept showing the documents from the conversation the user had just left — along with a still-visible header documents toggle, a stale count badge, and a drawer that would not close.
Switching between existing conversations worked correctly; only the New chat path was affected.
Root cause
createNewConversation()signals the reset before the new conversation exists, so the event carries a null id:The drawer listener forwarded that as
"", andrefreshConversationDocuments()resolved the id with an unconditional fallback:At that moment
window.currentConversationIdstill pointed at the previous conversation — it is only reassigned after the/api/create_conversationresponse. So the reset signal was executed as "refresh the conversation I'm already on": the old metadata was re-fetched and the old documents re-rendered.Because
documentEntriesnever became empty,updateDrawerTriggers()never reached its!hasContents && !hasDocuments -> closeDrawer(...)branch.Contents reset correctly only because it is driven by a different mechanism entirely: the
MutationObserveron#chatboxreacting tochatbox.innerHTML = "".Fix
application/single_app/static/js/chat/chat-conversation-contents.js:refreshConversationDocuments()acceptsallowCurrentConversationFallback(defaulttrue).chat:conversation-context-changedlistener passesfalse, so an empty id means reset rather than reload current.No new reset logic was needed — the existing
if (!conversationId)branch already cleareddocumentEntries, reset the usage-tracking flags, cleared the status line, showed the empty state, and calledupdateDrawerTriggers(). It was simply unreachable.Deliberately preserved:
reason: "select"always supplies an explicit id, so conversation switching is unchanged.chat:conversation-documents-refreshpath (streaming, retry, edit, collaboration) and the module's initial load keep the fallback.Validation
A jsdom harness exercised the real module against both the pre-fix and post-fix source, reproducing the reported symptom and confirming the fix:
Functional tests:
functional_tests/test_chat_new_conversation_documents_drawer_reset.py(new) — 7/7 passedfunctional_tests/test_chat_cited_source_tracking.py— passedfunctional_tests/test_chat_new_conversation_action_state_reset.py— passedNotes
Two pre-existing test failures were observed and verified to fail identically on the unmodified baseline, so they are out of scope here:
test_conversation_contents_drawer_settings.py— its AST-extracteduser_settingsroute namespace is missingAI_NOTICE_USER_SETTINGS_KEY, whichroute_backend_users.pynow references.test_chat_new_conversation_tag_reset.py— itsloadTagsForScopesource assertion has drifted fromchat-documents.js.Other changes
config.py:0.260.003→0.260.004docs/explanation/fixes/NEW_CHAT_CONVERSATION_DOCUMENTS_DRAWER_RESET_FIX.md(+ fixes index entry)v0.260.004release-notes entry