Skip to content

fix(terminal): scope server-pane wakes to the sleep and attempt they belong to - #52531

Merged
Jinwoo-H merged 1 commit into
layout-owner-v2from
fix/slept-wake-scoping
Nov 29, 2026
Merged

Jinwoo-H merged 1 commit into
layout-owner-v2from
fix/slept-wake-scoping

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

A server pane can wake a slept terminal when you show it or type into it. Two pieces of that wake logic remembered too much:

  1. The pane remembered "this terminal was slept" forever, even after it woke and ran normally again.
  2. The pane remembered "the user asked to wake" even after the reconnect attempt that the key started had failed.

Both now forget at the right moment.

Before / after

Before After
A slept agent pane wakes under the same terminal id, later another client restarts it while you type Keys typed at the old screen were sent to the restarted terminal They are dropped, as for any other restart
You type one key into a server pane while the server is unreachable; the workspace is slept later; the server comes back hours later The reconnect woke the slept workspace (resumed its agent) The reconnect is automatic and does not wake it

Mechanism

  • host-slept-terminals.ts: new forgetHostSleptTerminal. The transport calls it when a subscription to that terminal attaches, which is the host serving it live. Held keys now follow only a sleep that is still in progress.
  • remote-runtime-pty-transport.ts: the user wake is cleared on every recovery change that is not an attempt in flight (backoff, latched disconnected, parked for an external trigger, idle, disposed). requestUserWake also drops the wake at once when there is no attempt to carry it.

Kept from #52260: wake on show or type, keys typed during a real wake reach the woken terminal once and in order, a restart by another client drops them, one retry per wake gesture.

Tests

  • Two new unit tests in remote-runtime-pty-transport-wake-input.test.ts; each fails with its fix reverted (checked).
  • remote-runtime-pty-transport-* unit tests: pass with the switch on and off.
  • e2e local-slept-terminal-wake-keys: pass, switch on and off.
  • e2e paired-desktop-server-slept-pane-status: 5 passed switch on; 4 passed, 1 skipped (switch-on only) switch off.
  • pnpm run typecheck:ci passes.

Switch-off changes

Both fixes run with the switch off; this code from #52260 is not gated. With the switch off, the only differences are the two rows in the table above.

Visible changes

None beyond the two bug fixes above.

Performance

None, because the changes are one set delete when a terminal subscription attaches and one flag clear on recovery phase changes.

Risk

Level: Low. The riskiest part is the wake flag clearing too early, which would make a reconnect ask as automatic and leave a slept pane slept until shown or typed into again. A plain revert backs it out.

…belong to

A terminal the host serves live again is no longer remembered as slept, so a later
restart by another client drops keys typed at the old screen (#10065). A wake asked
by a key or reveal now ends with the reconnect attempt it started, so a failed attempt
cannot wake a workspace slept in the meantime.
@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge; no actionable defects were found.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

The PR limits remembered sleep state and user wake requests to their intended lifetime.

  • Live terminals lose their old sleep mark before a later restart.
  • Failed reconnect attempts no longer carry a user's wake request forward.

No actionable issues found. Tests were inspected but not run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[User types while disconnected] --> B[Mark this attempt as a user wake]
  B --> C{Attempt outcome}
  C -->|Terminal binds| D[Settle held input for that terminal]
  D --> E[Subscription completes]
  E --> F[Forget its sleep marker]
  C -->|Fails or waits for an outside trigger| G[Clear the user wake request]
  G --> H[Later reconnect stays automatic]
Loading

Reviews (1) · Last reviewed commit: "fix(terminal): scope server-pane wakes t..." · Reviewed by Greptile

@Jinwoo-H
Jinwoo-H merged commit 10a8ca7 into layout-owner-v2 Nov 29, 2026
72 of 73 checks passed
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