Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/view/page/ssh/page/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -994,8 +994,14 @@ class SSHPageState extends ConsumerState<SSHPage>
final selected = picked?.firstOrNull;
if (selected == null) return;

// A snippet can wait (`${sleep N}`) through a reconnect or a switch to
// tmux, and what is left must not be typed into the shell that replaced
// it — the same rule the startup snippet path runs under (_runStartupInput).
final shell = _session;
bool alive() => mounted && identical(_session, shell);

try {
await selected.runInTerm(_terminal, spi);
await selected.runInTerm(_terminal, spi, alive: alive);
} catch (e, s) {
if (!mounted) return;
context.showErrSheet(e, s, '${libL10n.snippet}: ${selected.name}');
Expand Down
6 changes: 6 additions & 0 deletions lib/view/page/ssh/snippet_run.dart
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,16 @@ class _SnippetRunViewState extends State<_SnippetRunView> {
// Entered, unlike the terminal page's own snippet paths: there the user
// is at a prompt and can finish the line themselves, whereas this dialog
// exists to run the thing and show what it printed.
//
// A `${sleep N}` step can outlive its shell, and what is left is not
// typed into one that replaced it. Not `mounted`: continued in the
// terminal tab, the session and its shell carry on there, the snippet
// with them; closed, the session goes and its shell with it.
await widget.snippet.runInTerm(
_sess.terminal,
widget.spi,
autoEnter: true,
alive: () => identical(_sess.foreground, shell),
);
} catch (e, s) {
Loggers.app.warning('Snippet run failed', e, s);
Expand Down
Loading