Skip to content

Canvases: Fix explicit reopening of restored Agent Host canvases - #343706

Merged
Joaquín Ruales (jruales) merged 2 commits into
mainfrom
jruales-restored-canvas-reopening
Oct 23, 2026
Merged

Joaquín Ruales (jruales) merged 2 commits into
mainfrom
jruales-restored-canvas-reopening

Conversation

@jruales

@jruales Joaquín Ruales (jruales) commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes a pre-existing bug on main, discovered while testing #340458. This PR is independent of that Canvas-management work; no menu or extension-management changes are included. No separate issue has been filed.

Resuming a Copilot session intentionally suppresses unprojected restored Canvas instances so old URLs are not automatically reopened. An explicit Show Canvas request did not remove that suppression, so the runtime successfully opened the Canvas but VS Code never received its state or active membership.

Capture the requested instance's suppression state before rpc.canvas.open, then publish its successful live result unless a newer lifecycle event or existing projection supersedes it. The bundled runtime emits session.canvas.opened before the RPC resolves, so a request-scoped listener preserves the latest root opened/closed/unavailable event for this instance. Newer opened data takes precedence over the response; closed/unavailable events prevent stale publication. A concurrent user message cannot erase the explicit request's original intent. The listener is disposed in finally, without introducing persistent tracking maps or changing passive restoration behavior.

Failures leave suppression intact, and replaced/released/disposed runtimes cannot publish late results. Other restored instances remain hidden, and normal event-driven projection and owner/chat routing are unchanged.

The activity-bar Canvas menu lists active instances, whereas the editor + menu also lists available definitions. Publishing the explicitly reopened instance restores its active membership without changing that distinction.

Independent reviews of the original commit were completed by GPT-6.1 Sol, Claude Opus 5.5, and Gemini 4 Argon. The lifecycle and concurrent-user-message findings were addressed, including newer suppressed state and concurrent response ordering. Suggestions to broaden no-event recovery for already-projected canvases or change passive closed-instance suppression were left out because those are pre-existing behaviors outside this fix. Both GitHub Copilot review threads have been addressed and resolved.

Validation (Node 24.22.0, isolated worktree):

  • fnm exec --using 24.22.0 npm run build-fast -- --client-only — passed.
  • fnm exec --using 24.22.0 ./scripts/test.sh --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts --grep 'explicit restored canvas reopening' --reporter dot — original fix: 4 failing regression cases before the fix; review follow-up: 5 additional race cases failed before the follow-up fix. All are covered by the passing selection below.
  • fnm exec --using 24.22.0 ./scripts/test.sh --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts --run src/vs/platform/agentHost/test/node/copilotAgent.test.ts --grep '[Cc]anvas' --reporter dot — passed, 47 tests. Covers before/after/missing open events, failed-open retry, restored-instance isolation, exact chat routing, disabled canvases, disposal, handoff, concurrent user messages, closed/unavailable events and recovery, newer suppressed state, concurrent response ordering, and existing Canvas lifecycle behavior.
  • fnm exec --using 24.22.0 ./scripts/test-integration.sh --run src/vs/platform/agentHost/test/node/copilotSdkCanvas.integrationTest.ts --reporter dot — passed, 3 tests reported. Uses the bundled SDK and a model-free isolated provider; verifies an explicit reopen after cold resume returns the current live URL without a new recorded-open event.
  • fnm exec --using 24.22.0 npm run typecheck-client — passed.
  • fnm exec --using 24.22.0 npm run eslint -- src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts src/vs/platform/agentHost/test/node/copilotSdkCanvas.integrationTest.ts — passed.
  • git diff --check and commit hygiene hooks — passed.

No full test suite or hands-on Agents-window UI run was performed. The existing live OSS window and original Copilot extension files were left untouched.

Manual verification: resume a session with a previously opened Canvas; confirm it is not automatically presented, then choose that Canvas from the editor + menu. It should publish an active Canvas and become available in the activity-bar Canvas menu, while other restored instances remain suppressed.

🤖 Written by GitHub Copilot on behalf of Joaquín Ruales (@jruales).

Project the successful open RPC snapshot for the requested restored canvas without unsuppressing other restored instances. Preserve runtime lifetime guards and add regression coverage for event ordering, failures, ownership and handoff.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 24ac2663-3c86-4675-b0f2-790aac5e3dcb
Copilot AI balanced review requested due to automatic review settings October 23, 2026 05:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Concurrent lifecycle events or user messages can cause delayed open responses to publish stale Canvas state or leave a successful reopen unpublished.

2 open issues
What changed in this PR

This PR fixes explicit reopening of restored Agent Host Canvases without automatically revealing other restored instances. It is independent of the broader Canvas-management work.

Changes:

  • Projects the Canvas returned by a successful explicit open when that instance remains suppressed.
  • Adds regression tests for event ordering, failed-open retries, routing, and runtime lifecycle boundaries.
  • Extends bundled-SDK coverage to verify explicit reopening after cold resume.
File Description
src/​vs/​platform/​agentHost/​test/​node/​copilotSdkCanvas.integrationTest.ts Verifies the reopened Canvas returns its current URL without another recorded-open event.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgentSession.test.ts Adds focused reopening, suppression, and lifecycle regression tests.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgentSession.ts Projects successful explicit-open responses for suppressed restored instances.

Review effort: Balanced

Keep request-time suppression intent independently of user messages and observe only the requested instance's root lifecycle events until the open RPC settles. Prefer newer opened state, do not revive closed or unavailable canvases, and preserve already-published projections. Add deferred-response, concurrent-open and recovery regressions.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 24ac2663-3c86-4675-b0f2-790aac5e3dcb
@jruales
Joaquín Ruales (jruales) requested a balanced review from Copilot October 23, 2026 06:53
@jruales Joaquín Ruales (jruales) changed the title Fix explicit reopening of restored Agent Host canvases Canvases: Fix explicit reopening of restored Agent Host canvases Oct 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused fix preserves passive restoration and lifecycle safeguards, with regression coverage for the affected ordering and concurrency paths and no unresolved findings.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@jruales

Copy link
Copy Markdown
Contributor Author

CC Ulugbek Abdullaev (@ulugbekna)
a small fix for a bug I found when working on Customizations

@jruales
Joaquín Ruales (jruales) merged commit 60edc61 into main Oct 23, 2026
60 checks passed
@jruales
Joaquín Ruales (jruales) deleted the jruales-restored-canvas-reopening branch October 23, 2026 07:47
@vs-code-engineering vs-code-engineering Bot added this to the 1.144.0 milestone Oct 23, 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.

Agents window: explicitly reopening a restored Canvas does not show it

3 participants