Repository navigation
fix: ssh: a waiting snippet stops typing when its shell is replaced - #2014
Conversation
|
I have read the CLA Document and I hereby sign the CLA |
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Merge Risk:
|
The startup snippet path (_runStartupInput) guards every runInTerm with
an alive check for exactly this: a snippet can wait through a reconnect
or a tmux switch via a ${sleep N} step, and what is left of it must not
be typed into the shell that replaced it. The two other snippet entry
points had no guard:
- the toolbar / virtual-key picker (_pickSnippet) typed into the
terminal object, which survives the session it belonged to — the
remainder landed in the reconnect's new shell, or in whatever session
the user had switched to;
- the snippet run dialog (_run) kept going after its foreground shell
ended for good or the session was handed over to a tab.
Both now pass an alive closure in the same shape init.dart already
runs under: the toolbar's compares the page's session by identity, the
dialog's compares the bound foreground shell. Nothing types after the
shell it was written for is gone.
The snippet engine's Step_Sleep already checks alive between steps
(snippet.dart) — this only feeds it, at the two call sites that did not.
5b00404 to
b4eb993
Compare
What this changes
A snippet with a
${sleep N}step can outlive the shell it was written for: the connection reconnects, the user switches to tmux, the foreground shell ends, or the snippet-run dialog hands its session over to a tab. The snippet engine already stops between steps when itsalivecallback answers false (Step_Sleepinsnippet.dart), and the startup snippet path guards everyrunInTermwith exactly that check (_runStartupInputininit.dart, whose comment states the rule: "what is left must not be typed into the shell that replaced it").Two snippet entry points passed no
aliveat all, so their remainder landed in whatever replaced their shell — a freshly reconnected bare shell, or the session the user had switched to:_pickSnippet): the terminal object survives its session, so text kept going into it across a reconnect. Now captures the page's_sessionand passesalive: mounted && identical(_session, shell)— the same identity checkinit.dartruns under._SnippetRunViewState._run): now passesalive: mounted && identical(_sess.foreground, shell)— typing stops when the bound foreground shell ends for good (onForegroundDone) or the session is handed over.Nothing about the engine changes; the two call sites just feed it the check it was built for.
How it was tested
flutter test test/unit/server/snippet_local_test.dart test/widget/snippet_list_test.dartpass (8).flutter analyzeon both touched files clean. The behavior fix itself is the twoaliveclosures — exercised end-to-end by the startup path's existing wiring, which this now matches on both remaining entry points.Windows 11, Flutter 3.50.0. No model / ARB file changed, no
crates/change, no formatter run over untouched code.Summary by CodeRabbit