Skip to content

Fix TreeError in AgentSessionsView#314067

Merged
benibenj merged 1 commit into
mainfrom
benibenj/unemployed-shark
May 4, 2026
Merged

Fix TreeError in AgentSessionsView#314067
benibenj merged 1 commit into
mainfrom
benibenj/unemployed-shark

Conversation

@benibenj
Copy link
Copy Markdown
Contributor

@benibenj benibenj commented May 4, 2026

Copilot Generated Description: Catch potential errors when revealing a session in the Agent Sessions view to handle cases where the tree model may be temporarily inconsistent during async refresh. This change prevents unhandled errors from occurring when attempting to access the relative position of a session.
Fixes #309891

Copilot AI review requested due to automatic review settings May 4, 2026 10:17
@benibenj benibenj enabled auto-merge May 4, 2026 10:17
@benibenj benibenj self-assigned this May 4, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the Agent Sessions view’s “reveal session” behavior against transient tree model inconsistencies that can occur during async refresh, preventing unhandled tree errors when trying to scroll a session into view (#309891).

Changes:

  • Wraps the tree visibility check (getRelativeTop) and reveal call in a try/catch to avoid propagating tree-model exceptions.
  • Returns false if the tree operation fails during refresh, instead of throwing.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsControl.ts Adds error handling around tree reveal logic to avoid unhandled errors during async refresh.

Copilot's findings

Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsControl.ts:850

  • setFocus/setSelection can also throw TreeError if the tree model changes between hasNode(session) and these calls (they resolve nodes/list indexes internally). To fully prevent the unhandled TreeError, consider moving these calls inside the same try/catch (or guarding similarly) so transient refresh races don't still crash.
		this.sessionsList.setFocus([session]);
		this.sessionsList.setSelection([session]);
  • Files reviewed: 1/1 changed files
  • Comments generated: 1

@benibenj benibenj merged commit b759e19 into main May 4, 2026
30 checks passed
@benibenj benibenj deleted the benibenj/unemployed-shark branch May 4, 2026 11:58
@vs-code-engineering vs-code-engineering Bot added this to the 1.120.0 milestone May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Unhandled Error] TreeError [AgentSessionsView] Tree element not found: [object Object]

3 participants