Skip to content

Fix terminal e2e flakiness with a real terminal driver#17144

Merged
Hona merged 5 commits intoanomalyco:devfrom
Hona:fix/terminal-e2e-driver
Mar 12, 2026
Merged

Fix terminal e2e flakiness with a real terminal driver#17144
Hona merged 5 commits intoanomalyco:devfrom
Hona:fix/terminal-e2e-driver

Conversation

@Hona
Copy link
Copy Markdown
Member

@Hona Hona commented Mar 12, 2026

Summary

  • standardize terminal e2e coverage on a dedicated terminal driver
  • move terminal-facing tests onto shared readiness and typing helpers
  • document the terminal testing pattern for future coverage

TL;DR

The flakiness was not the PTY itself. The tests were waiting on the wrong signals.

A visible terminal, a mounted textarea, or an open WebSocket did not guarantee that terminal output had actually been rendered and settled yet. Because the terminal is canvas-backed and its write pipeline completes asynchronously, the tests could type, switch tabs, or assert persistence before the rendered terminal state had caught up.

That race made the tests intermittently look like input or persistence was broken when the terminal pipeline was still in flight.

@Hona Hona requested a review from adamdotdevin as a code owner March 12, 2026 06:59
Copilot AI review requested due to automatic review settings March 12, 2026 06:59
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 reduces terminal-related E2E flakiness by adding a dedicated, test-enabled terminal driver in the app and standardizing terminal tests on shared “ready” and “type+wait for output” helpers.

Changes:

  • Add a test-only terminal driver that tracks terminal connection state and rendered/received output.
  • Introduce waitTerminalReady / runTerminal E2E helpers and migrate terminal-facing tests to use them.
  • Document the recommended terminal testing pattern for future E2E coverage.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/app/src/components/terminal.tsx Adds an E2E driver hook to track connection and rendered output; exposes PTY id for tests.
packages/app/e2e/actions.ts Adds waitTerminalReady, runTerminal, and terminalState helpers used by terminal-related specs.
packages/app/e2e/fixtures.ts Enables the terminal driver globally for E2E runs via addInitScript.
packages/app/e2e/terminal/terminal.spec.ts Uses waitTerminalReady instead of visibility-only checks.
packages/app/e2e/terminal/terminal-tabs.spec.ts Replaces ad-hoc typing/readiness logic with shared helpers; tightens polling timeouts.
packages/app/e2e/terminal/terminal-init.spec.ts Uses waitTerminalReady for mount/readiness assertions.
packages/app/e2e/settings/settings-keybinds.spec.ts Uses waitTerminalReady after toggling the terminal via keybind.
packages/app/e2e/prompt/prompt-slash-terminal.spec.ts Uses waitTerminalReady after /terminal toggle.
packages/app/e2e/AGENTS.md Documents the new terminal testing approach and helper functions.
Comments suppressed due to low confidence (1)

packages/app/src/components/terminal.tsx:629

  • data-pty-id is added unconditionally to the terminal DOM node. Since this is only used by the e2e terminal driver, consider only rendering this attribute when the e2e driver is enabled to avoid exposing internal PTY IDs in non-test builds.
        "select-text": true,
        "size-full px-6 py-3 font-mono relative overflow-hidden": true,
        [local.class ?? ""]: !!local.class,
      }}
      {...others}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/app/src/components/terminal.tsx Outdated
Comment thread packages/app/e2e/actions.ts
@Hona Hona merged commit 328c6de into anomalyco:dev Mar 12, 2026
11 of 12 checks passed
ChicK00o pushed a commit to ChicK00o/opencode that referenced this pull request Mar 12, 2026
demostanis pushed a commit to demostanis/opencode that referenced this pull request Mar 19, 2026
demostanis pushed a commit to demostanis/opencode that referenced this pull request Mar 20, 2026
balcsida pushed a commit to balcsida/opencode that referenced this pull request Mar 24, 2026
balcsida pushed a commit to balcsida/opencode that referenced this pull request Apr 8, 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.

2 participants