fix: remove immediate foreground terminal bypass#4592
Closed
nwparker wants to merge 1 commit into
Closed
Conversation
nwparker
force-pushed
the
nwparker/simplify-opentui-foreground-fix
branch
from
June 3, 2026 21:35
a976359 to
bc424c9
Compare
Contributor
Author
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
isLatencySensitiveForegroundOutputbypass instead of keeping the additive rolling budget from fix: stop OpenTUI redraw and git polling freezes #4585.pty-connection.tsdeletes the immediate foreground classifier and routes foreground PTY bytes through the scheduler.Diagnosis
I did not complete a true historical bisect before merging #4585. That PR fixed the repros, but it stacked a budget on top of the suspect code. This follow-up narrows the bad code more directly.
Controlled replay results on a diagnosis branch:
mainwith fix: stop OpenTUI redraw and git polling freezes #4585 reverted failed the captured OpenCode replay:maxTimerDrift=925.4ms foregroundWrites=74063 deferredForegroundEnqueues=02c8bbacca1d775353db44dad72127aa2f38bbfcf,perf: batch visible terminal output floods) conflicts through later terminal work and also removes the scheduler itself, which is not the minimal safe change.maxTimerDrift=375.8ms foregroundWrites=74063 deferredForegroundEnqueues=74063So the bad hunk is #4039's immediate foreground bypass for <=2KB chunks / recent ANSI redraws, not the scheduler machinery as a whole.
Refs #4039, #4558, #4559, #4581, #4585.
Test plan
Rebased on
origin/mainat843d969c7d; branch headbc424c9217.pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/pty-connection.test.ts src/main/git/status-upstream-probe-churn.test.tspnpm typecheckpnpm exec oxfmt --check src/renderer/src/components/terminal-pane/pty-connection.ts src/renderer/src/components/terminal-pane/pty-connection.test.tspnpm exec oxlint src/renderer/src/components/terminal-pane/pty-connection.ts src/renderer/src/components/terminal-pane/pty-connection.test.tspnpm testnpx playwright test tests/e2e/terminal-foreground-redraw-freeze.spec.ts --config tests/playwright.config.ts --project electron-headless -g "captured OpenCode/OpenTUI" --reporter=json > .tmp/simplify-rebased-terminal-captured.jsonelapsed=363.9ms maxTimerDrift=334.1ms samples=1 foregroundWrites=74063 deferredForegroundEnqueues=74063 deferredForegroundWrites=1 scheduledDrains=2SKIP_BUILD=1 npx playwright test tests/e2e/terminal-foreground-redraw-freeze.spec.ts --config tests/playwright.config.ts --project electron-headless -g "active OpenTUI-style" --reporter=json > .tmp/simplify-rebased-terminal-synthetic.jsonelapsed=34.8ms maxTimerDrift=2.7ms samples=2 foregroundWrites=270 deferredForegroundEnqueues=270 deferredForegroundWrites=11 scheduledDrains=1SKIP_BUILD=1 npx playwright test tests/e2e/git-no-upstream-polling-churn.spec.ts --config tests/playwright.config.ts --project electron-headless --reporter=json > .tmp/simplify-rebased-git-polling.jsonelapsed=7201.8ms maxTimerDrift=4.2ms samples=450 noUpstreamFailures=1 missingOriginFailures=1