Files
pipelines/app/lib/features/terminal/terminal_listing.dart
T
alan 30934aa71c Toggle the terminal with Alt/Ctrl/Cmd+T, animate it, focus it, and cycle its tabs with Ctrl+Tab
Alt+T, Ctrl+T and Cmd+T join Ctrl+` as early focus-manager key handlers, so
they toggle the panel, window or narrow page from anywhere without reaching
the shell or a text field. Opening with no terminal starts one. The shown
terminal takes the keyboard (also on reload and tab changes) and hiding gives
it back. The panel slides from the bottom edge as the app shrinks, the window
scales and fades, both on Motion.standard and off under reduced motion.
While shown, Ctrl+Tab/Ctrl+Shift+Tab move between terminal tabs instead of
chat panes. The tooltip and menu list the shortcuts the platform delivers.
2026-11-09 23:43:56 +00:00

33 lines
811 B
Dart

import 'dart:async';
/// The machines' terminal lists being read, so the surface can wait until
/// every one has arrived (to start a terminal only when there is none).
class TerminalListing {
int _pending = 0;
final List<Completer<void>> _waiters = [];
/// Runs [read], counted as pending until it ends.
Future<void> track(Future<void> Function() read) async {
_pending++;
try {
await read();
} finally {
_pending--;
if (_pending == 0) {
for (final waiter in _waiters) {
waiter.complete();
}
_waiters.clear();
}
}
}
/// Completes once nothing is pending.
Future<void> idle() {
if (_pending == 0) return Future.value();
final waiter = Completer<void>();
_waiters.add(waiter);
return waiter.future;
}
}