fix(chat): guard agent-sessions reveal against transient tree-map desync (#309891)#310831
Open
maruthang wants to merge 2 commits intomicrosoft:mainfrom
Open
fix(chat): guard agent-sessions reveal against transient tree-map desync (#309891)#310831maruthang wants to merge 2 commits intomicrosoft:mainfrom
maruthang wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Member
|
I would prefer a change on the underlying base widget as it seems wrong every user of the API has to account for this. cc @benibenj |
microsoft#309891) Per @bpasero's review on microsoft#310831 — moving the guard from the agentSessionsControl call site into the underlying base widget so all AsyncDataTree consumers benefit. During an async refresh there is a microtask gap where AsyncDataTree.nodes (consulted by hasNode) and the underlying tree model's node map can be out of sync, so getDataNode or tree.getRelativeTop can throw TreeError even though hasNode returned true. Treat that transient TreeError as "not currently visible" by returning null — consistent with the existing semantic that null means the element is in the data source but not in view, so callers fall back to reveal() which is safe to call across the gap. Reverts the call-site try/catch in agentSessionsControl now that the base widget handles it.
Contributor
Author
|
Thanks @bpasero — agreed. Moved the guard into |
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @joaomorenoMatched files:
@benibenjMatched files:
|
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.
What —
AsyncDataTree.getRelativeTop()no longer throwsTreeError [...] Tree element not foundduring transient async-refresh races; it now returnsnull(the existing "not currently visible" semantic), so all consumers automatically get safe behavior.Why — Originally guarded only at the
AgentSessionsControlcall site. Per @bpasero's review feedback, the fix belongs in the underlying base widget — every consumer ofAsyncDataTree.getRelativeTop()would otherwise have to repeat the same try/catch when paired withhasNode().AsyncDataTree.hasNode()consultsthis.nodes(the JS-side map).AsyncDataTree.getRelativeTop()callsthis.getDataNode()and then the underlying tree model'sgetRelativeTop(), which consults a different map (compressedObjectTreeModel'snodes). DuringrefreshAndRenderNode()there is a microtask gap where one map is updated and the other isn't, sohasNode()can returntruewhile the deeper call throwsTreeError [...] Tree element not found(#309891, 51 hits / 28 users).How —
AsyncDataTree.getRelativeTop()now wraps the underlying call in try/catch. OnTreeErrorit returnsnull(matching the existing semantic for "not visible"); other errors continue to propagate. Reverted the call-sitetryGetRelativeTopworkaround inagentSessionsControl.ts— the call site is back to its upstream baseline.Test plan — Manual: trigger the race by switching active editors while the agent-sessions list is mid-refresh. Pre-fix this reliably throws the
TreeErrorwhen hit; post-fix the error is absorbed and the existingreveal(…, 0.5)fallback runs. No unit test added — reproducing the race deterministically requires drivingAsyncDataTree.refreshAndRenderNode()across its await boundary, which would need a substantial harness.Fixes #309891