Skip to content

refactor(terminal): replace shell-integration polling with event-based wait #427

Description

@edelauna

Summary

Track moving VS Code terminal shell-integration startup waiting from bounded polling (p-wait-for) to vscode.window.onDidChangeTerminalShellIntegration in a focused follow-up PR.

This was prototyped in #277 but should be separated because it affects every VS Code integrated-terminal command, not only profile overrides. The narrower cmd.exe compatibility path can remain in #277.

Motivation

An event-based wait can react immediately when shell integration becomes available and avoid polling during startup. The existing bounded polling path is simpler and should remain until the event-driven lifecycle is proven independently.

Risks to cover

  • Missed-event race if shell integration becomes available between the initial property check and listener registration.
  • Listener and timeout disposal on success, timeout, cancellation, and terminal disposal.
  • Events for unrelated terminals.
  • VS Code compatibility and mocks.
  • Slow-start shells and remote environments such as Windows, WSL, SSH, and dev containers.

Acceptance criteria

  • Subscribe before relying on event delivery and re-check terminal.shellIntegration after listener registration.
  • Dispose the listener and timer on every completion path.
  • Add focused tests for already-available integration, availability after subscription, availability during subscription setup, timeout cleanup, and unrelated-terminal events.
  • Validate at least Windows and one slow-start or remote-shell scenario.
  • Keep fallback behavior conservative: do not automatically replay a command after shellIntegration.executeCommand() has been called unless non-submission is definitive.

Context

Follow-up from #277 review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions