Skip to content

fix(term): defer controller resync until terminal data is loaded - #3511

Open
kruux wants to merge 1 commit into
wavetermdev:mainfrom
kruux:fix/term-defer-resync-until-loaded
Open

kruux wants to merge 1 commit into
wavetermdev:mainfrom
kruux:fix/term-defer-resync-until-loaded

Conversation

@kruux

@kruux kruux commented Sep 16, 2026

Copy link
Copy Markdown

Fixes #3162

Problem

With fish as the shell, every new terminal tab printed could not read response to Primary Device Attribute query after a 10-second delay. fish sends a DA1 query at startup and waits for the terminal's reply.

Root cause

TermWrap.handleTermData drops xterm.js replies while loaded is false. The shell is started by resyncController("initial resize"), which can run before initTerminal() finishes loading the initial terminal data, so fish's DA1 reply is discarded and fish waits out its timeout. It is a race, so it depends on timing.

Fix

A resync requested before the terminal is loaded is held in pendingResyncReason and run once loading completes.

Testing

Linux, fish 4.9.3, local dev build:

  • Time to first prompt in a new fish tab: ~10,000 ms before, 17-43 ms after, warning gone.
  • Covers fresh launch, rapid successive tabs, and restart with existing tabs.
  • bash is unaffected (14-25 ms before and after).
  • The reload replay guard from 95b1767 still holds: 0 input frames replayed on reload.

Repro

Set fish as the shell and open a new tab; the warning appears after about 10 seconds.

Alternatives considered

  • Resyncing at the end of initTerminal() fixes the same tests but misses TermResyncHandler, which fires on SSH/WSL connection changes, and can start the shell before the element is sized.
  • Replaying heldData does not fix it; the replies are dropped, not buffered.

handleTermData drops xterm.js replies until initTerminal has loaded the
initial terminal data, but the "initial resize" resync started the shell
before that. fish sends a Primary Device Attribute (DA1) query at startup,
never got the reply, and waited 10s before printing a warning on every
new tab.

Hold resync requests made before loading finishes and run the latest one
once the terminal is loaded.

Fixes wavetermdev#3162

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Sep 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 8e6cdf40-69fb-4299-acc4-b39b6580fa6f

📥 Commits

Reviewing files that changed from the base of the PR and between a4447c1 and 23ad2e9.

📒 Files selected for processing (1)
  • frontend/app/view/term/termwrap.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Walkthrough

TermWrap now stores a resynchronization reason when the terminal is not loaded. After initial terminal data loading completes, it marks the terminal as loaded, clears the stored reason, and asynchronously calls resyncController. This preserves responses to shell startup queries such as fish’s Primary Device Attribute query.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 23ad2

The deferred resynchronization change has no identified merge-blocking risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: delaying controller resynchronization until terminal data is loaded.
Description check ✅ Passed The description directly explains the fish shell startup issue, root cause, fix, testing, and alternatives. It is fully related to the changeset.
Linked Issues check ✅ Passed Issue #3162 requires support for fish's Primary Device Attribute query without the compatibility warning or the startup delay. In frontend/app/view/term/termwrap.ts, resyncController defers reques…
Out of Scope Changes check ✅ Passed The reported change is limited to frontend/app/view/term/termwrap.ts. The new pending-resync state and deferred replay directly support the fish startup fix in issue #3162. No unrelated change is id…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

[Bug]: fish could not read response to Primary Device Attribute query

2 participants