Fix terminal e2e flakiness with a real terminal driver#17144
Merged
Hona merged 5 commits intoanomalyco:devfrom Mar 12, 2026
Merged
Fix terminal e2e flakiness with a real terminal driver#17144Hona merged 5 commits intoanomalyco:devfrom
Hona merged 5 commits intoanomalyco:devfrom
Conversation
Contributor
There was a problem hiding this comment.
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/runTerminalE2E 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-idis 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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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.