Skip to content

Fix Autofix event delivery and cross-tab Detected actions - #880

Merged
Kai Tao (vanzue) merged 3 commits into
mainfrom
dev/vanzue/autofix-routing
Sep 7, 2026
Merged

Fix Autofix event delivery and cross-tab Detected actions#880
Kai Tao (vanzue) merged 3 commits into
mainfrom
dev/vanzue/autofix-routing

Conversation

@vanzue

Copy link
Copy Markdown
Contributor

Summary

Isolates two Autofix correctness fixes from the separate GetPaneContext work. This PR does not include the new context API or its performance changes.

  • Capture the stable pane SessionId when registering VT callbacks and resolve its owning tab on the UI thread, so an expired TermControl weak reference cannot silently drop command-failure events.
  • Scope Detected-button actions to the requested pane and tab before submitting Autofix. Ignore cross-tab, stale, missing-target, and repeated actions; preserve compatibility with older pane-only events only when the pane matches.
  • Include the active tab identity in diagnostics-button events, matching the existing keyboard action.

Regression coverage

  • Add a deterministic two-tab test using real PowerShell failures, the diagnostics button, and an ACP fixture. Both tabs enter Detected; clicking B submits only B, then clicking A independently submits A.
  • The new test fails on the previous deployed build because A receives a prompt when only B was clicked, and passes on this branch.
  • Add reducer coverage for target isolation, stale/missing targets, pane-only compatibility, repeat clicks, and closed panes.
  • Replace obsolete AutofixParser initial_prompt assertions with scoped dispatch and downstream ACP evidence. Pin WSL proposal observations and input to the correct helper.
  • Add release checklist coverage C295 and verify both full and incremental report mappings.

Validation

  • Full WTA suite: 2056 passed, 1 ignored.
  • Debug Terminal and explicit-target WTA built and deployed; packaged binary hashes match the branch outputs.
  • Combined AutofixRouting, ShellIntegration, AutofixParser, and AutofixPane E2E: 23 passed, 0 failed, 0 skipped, including WSL.
  • User manually reproduced and retested the dual-Detected scenario. Logs show only the selected helper submitting; Run actions return to their respective source panes.

Preserve stable pane identity across asynchronous VT dispatch and validate detected-action targets before replaying a failure. Add dual-tab UI-to-ACP regression coverage and update Autofix test oracles.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 77616472-cc8d-4566-9050-60ab09248076
Copilot AI lite review requested due to automatic review settings September 7, 2026 05:40

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

The new AutofixRouting ItE2E test can fail deterministically when it reads the fixture log before the file exists (Select-String on a non-existent path).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR improves Autofix correctness by ensuring VT-based failure events and “Detected” opt-in actions are routed to the intended pane/tab, preventing silent drops and cross-tab submissions. It also adds targeted regression coverage (unit + ItE2E) and updates the release checklist/README to reflect the new scenarios.

Changes:

  • Capture and use stable pane SessionId for VT callback routing, and tag relevant protocol events with tab identity for proper helper-side isolation.
  • Harden helper-side autofix_execute_from_detected handling to reject untargeted/cross-tab/stale actions while preserving legacy pane-only compatibility when safe.
  • Add deterministic two-tab routing coverage and strengthen parser/WSL E2E assertions with scoped evidence.
File summaries
File Description
tools/wta/src/autofix_tests.rs Adds reducer/unit tests for Detected action target isolation and legacy/stale handling.
tools/wta/src/app/autofix.rs Scopes Detected execution to matching pane/tab and ignores cross-tab/untargeted actions.
tools/wta/src/app_events.rs Wires WT event payload (pane_id/tab_id) into the updated Detected execution handler.
test/e2e/tests/Feature.AutofixRouting.Tests.ps1 New ItE2E test covering two Detected tabs and ensuring diagnostics clicks submit only to the selected tab.
test/e2e/tests/Feature.AutofixParser.Tests.ps1 Replaces prompt-content assertions with scoped helper/master evidence and pins observations to the correct helper/session.
test/e2e/tests/Feature.AutofixPane.Tests.ps1 Pins WSL helper identity and scopes proposal/card interactions to the correct agent pane session.
test/e2e/README.md Documents the new AutofixRouting suite and updates AutofixPane suite counts/coverage notes.
test/e2e/ItE2E/Public/Agent.ps1 Extends Wait-TerminalActionProposal with -PaneSessionId to avoid cross-helper card ambiguity.
src/cascadia/TerminalApp/TerminalPage.h Declares _FindTabIdForSessionId for session-id-based tab resolution.
src/cascadia/TerminalApp/TerminalPage.cpp Captures stable SessionId for VT callbacks, resolves owning tab by SessionId on UI thread, and includes tab_id in Detected execute events.
doc/release-check-list.md Adds release checklist item C295 for cross-tab Detected isolation coverage.
Review details
  • Files reviewed: 11/11 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/e2e/tests/Feature.AutofixRouting.Tests.ps1
Comment thread tools/wta/src/app/autofix.rs Fixed
@github-actions

This comment has been minimized.

Create the routing fixture log before launching helpers and reword the target-rejection diagnostic without adding dictionary exceptions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 77616472-cc8d-4566-9050-60ab09248076
Copilot AI review requested due to automatic review settings September 7, 2026 05:51

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.

🔵 Needs a closer look

TerminalPage::_RegisterTerminalEvents now declares an unused weakTerm variable in the modified VT callback block, which can break builds when warnings are treated as errors.

Review details

Suppressed comments (2)

Previously missed (1) — in code that hasn't changed since the last review.

src/cascadia/TerminalApp/TerminalPage.cpp:8089

  • _FindTabIdForSessionId currently walks every pane and calls _FindSessionIdForControl(control) for each node, which formats a GUID into a string each time. Since TermControl::Connection().SessionId() is already a winrt::guid, you can parse sessionId once and compare GUIDs to avoid repeated string allocations/conversions on a hot VT-sequence path.

This issue also appears on line 8133 of the same file.

src/cascadia/TerminalApp/TerminalPage.cpp:8135

  • weakTerm is now unused after switching the VT callback to capture paneIdStr instead of a TermControl weak_ref. Leaving this in place will trigger an unused-variable warning (and can fail builds if warnings are treated as errors).
        {
            winrt::weak_ref<TermControl> weakTerm{ term };
            const auto paneIdStr = _FindSessionIdForControl(term);
  • Files reviewed: 11/11 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Comment thread tools/wta/src/app/autofix.rs Fixed
@github-actions

This comment has been minimized.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 77616472-cc8d-4566-9050-60ab09248076
Copilot AI review requested due to automatic review settings September 7, 2026 06:13

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

TerminalPage::_RegisterTerminalEvents leaves an unused local (weakTerm) that can break builds under warnings-as-errors.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 11/11 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread src/cascadia/TerminalApp/TerminalPage.cpp

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 routing fixes are consistently scoped and backed by focused unit and end-to-end regression coverage.

Review details
  • Files reviewed: 11/11 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@vanzue
Kai Tao (vanzue) merged commit db609f8 into main Sep 7, 2026
12 checks passed
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.

4 participants