Skip to content

test(e2e): defeat template-filter pollution in the bundle_init wizard - #2123

Draft
rugpanov wants to merge 2 commits into
mainfrom
fix/e2e-bundle-init-terminal-readiness
Draft

test(e2e): defeat template-filter pollution in the bundle_init wizard#2123
rugpanov wants to merge 2 commits into
mainfrom
fix/e2e-bundle-init-terminal-readiness

Conversation

@rugpanov

Copy link
Copy Markdown
Contributor

Why

bundle_init :: should initialize new project still flakes on the Windows shard with "Can't complete cli bundle init wizard" (its two follow-on tests then cascade), despite #2034 gating the first keystroke on tab readiness. Two races remain:

  1. Keystroke focus race — the editor tab becoming active doesn't guarantee the xterm holds keyboard focus, so keys fired next can land in the tab chrome instead of the wizard.
  2. Template-filter pollution — per BundleInitWizard.bundleInitInTerminal (see its own comment), the Python extension can inject env-setup text into the freshly opened terminal, and that text lands in the wizard's template search filter. The typed default-python then appends to that text, matches no template, and the wizard stalls until the 40s completion loop times out.

The terminal buffer isn't reliably readable via the wdio API on this editor-hosted terminal, so the fix hardens the input path rather than reading state back.

What

  • Focus the terminal input (workbench.action.terminal.focus) after the tab is active and before typing, so wizard keystrokes aren't swallowed by the editor-tab chrome.
  • Clear the template search filter with a burst of Backspace keys before typing the template name — a no-op when the filter is already empty, and it removes any injected env-setup text so default-python matches.
  • The Enter-hammering completion loop (which accepts the remaining default-python prompt defaults) and the ground-truth workspace-root gate are unchanged.

Test-only: no production code, settings, persisted state, telemetry, or when-clause flags. Nothing changes for shards that never hit the races.

Verification

  • tsc -p src/test/e2e/tsconfig.json: no new errors (the sole error is the pre-existing assert {type: "json"} in wdio.conf.ts, untouched here).
  • eslint + prettier -c: clean on the touched file.
  • e2e-only behavior is verified via isolated CI runs of bundle_init on this branch (repeated, since one green run ≠ stable).

This pull request and its description were written by Isaac.

## Why

`bundle_init :: should initialize new project` still flakes on the Windows
shard with "Can't complete cli bundle init wizard" (its two follow-on tests
then cascade), despite #2034 gating the first keystroke on tab-readiness.
Two races remain: keystrokes can land before the editor terminal holds
keyboard focus, and — per BundleInitWizard.bundleInitInTerminal — the Python
extension can inject env-setup text into the freshly opened terminal that
lands in the template *search filter*, so the typed "default-python" appends
to that text, matches no template, and the wizard stalls until the 40s
completion loop times out.

## What

- Move keyboard focus into the editor-hosted terminal
  (`workbench.action.terminal.focus`) before typing, so wizard keystrokes
  aren't swallowed by the editor-tab chrome.
- Clear the template search filter with a burst of Backspace keys before
  typing the template name (a no-op when the filter is empty), removing any
  injected env-setup text so the name matches.
- The completion loop and the ground-truth workspace-root gate are unchanged.

Test-only: no production code, settings, persisted state, telemetry, or
when-clause flags. Nothing changes for shards that never hit the races.

## Verification

- `tsc -p src/test/e2e/tsconfig.json`: no new errors (the sole error is the
  pre-existing `assert {type: "json"}` in `wdio.conf.ts`, untouched here).
- `eslint` + `prettier -c` clean on the touched file.
- e2e-only behavior verified via isolated CI runs of `bundle_init` on the
  branch (repeated, since one green run != stable).

Co-authored-by: Isaac
@rugpanov
rugpanov deployed to test-trigger-is August 14, 2026 20:05 — with GitHub Actions Active
@rugpanov
rugpanov deployed to test-trigger-is August 14, 2026 20:06 — with GitHub Actions Active
@rugpanov

Copy link
Copy Markdown
Contributor Author

🤖 Integration tests triggered for 887af748 — ⏳ running.
View run

## Why

Review (Codex + a devil's-advocate pass) flagged two robustness gaps in the
first commit: a 50-backspace burst can leave a prefix when the Python
extension injects a long activation line (a Windows venv/conda activate with
an absolute path exceeds 50 chars), and the terminal-focus callback didn't
return the command, so `executeWorkbench` resolved before focus completed and
relied on the trailing sleep alone.

## What

- Over-provision the filter clear to 200 backspaces. Backspacing an empty
  filter is a no-op, so a larger count only adds safety margin for long
  injected lines; it can't corrupt a clean run.
- Return `executeCommand` from the focus callback so `executeWorkbench` awaits
  focus completing before the keystrokes are sent.
- Trim the filter-clear comment so it no longer restates the block above it.

Still test-only: no production code, settings, state, telemetry, or
when-clause flags.

## Verification

- `tsc -p src/test/e2e/tsconfig.json`: no new errors (only the pre-existing
  `assert {type: "json"}` in `wdio.conf.ts`).
- `eslint` + `prettier -c` clean on the touched file.

Co-authored-by: Isaac
@rugpanov
rugpanov deployed to test-trigger-is August 14, 2026 20:16 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown
Contributor

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/vscode

Inputs:

  • PR number: 2123
  • Commit SHA: e0c08501102c137d3e700ca2b06520f6dac4cae7

Checks will be approved automatically on success.

@rugpanov
rugpanov deployed to test-trigger-is August 14, 2026 20:16 — with GitHub Actions Active
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.

1 participant