Skip to content

WebUI: prevent replay-from-start when clicking terminal during initial hydrate#406

Merged
edwin-zvs merged 1 commit into
mainfrom
webui-codex-focus-stabilize
Jun 16, 2026
Merged

WebUI: prevent replay-from-start when clicking terminal during initial hydrate#406
edwin-zvs merged 1 commit into
mainfrom
webui-codex-focus-stabilize

Conversation

@edwin-zvs

Copy link
Copy Markdown
Contributor

When clicking the xterm area in Web UI while Codex (or any PTY-backed) session is still hydrating its initial history, the terminal can appear to replay from the beginning. This patch defers focus/claim until hydrate completes:

  • On terminal host click, if the session’s xterm handle isn’t loaded yet, stash pendingTerminalFocusId and return (no refit/claim/focus yet).
  • After initial hydrate completes (handle.loaded = true), if pendingTerminalFocusId matches the session, run refitTerminal({ claim: true, immediate: true }) and focus, then clear the flag.

Effect: avoids geometry churn mid-hydrate that can lead to replay-from-start visuals on PTY sessions (Codex).

No behavior change for already-loaded terminals; normal click-to-focus and resize-claim remains instant.

… prevent replay-from-start on click

- On terminal host click, if the session's xterm handle isn't loaded yet,
  stash a pendingTerminalFocusId and return without refit/claim/focus.
- When hydrate completes (handle.loaded = true), if pendingTerminalFocusId matches,
  perform the refit({claim: true, immediate: true}) and focus then clear the flag.
- Prevents Codex/PTY sessions from appearing to replay from the beginning when
  clicking during initial pty_replay/transcript hydrate.
@edwin-zvs
edwin-zvs merged commit ea1919d into main Jun 16, 2026
1 check passed
@edwin-zvs edwin-zvs mentioned this pull request Jun 16, 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.

1 participant