Add the app's terminal surface: bottom panel, floating window and full-screen page

This commit is contained in:
2026-11-09 21:42:52 +00:00
parent a5842e6b3b
commit acd160b49e
28 changed files with 2266 additions and 10 deletions
+57
View File
@@ -0,0 +1,57 @@
import 'package:flutter/widgets.dart';
import '../core/api_gateway.dart';
import '../core/servers/chat/chat_server_pool.dart';
import '../features/terminal/terminal_hub.dart';
import '../features/terminal/terminal_layout.dart';
import '../features/terminal/terminal_machines.dart';
import '../features/terminal/terminal_surface.dart';
import '../features/terminal/terminal_toggle_button.dart';
/// The app's machine terminals: one hub over every connected machine (the
/// chat pool's, else the app's own server), kept for the app's lifetime so
/// shells and their output survive navigation and hidden panels.
class AppTerminals {
AppTerminals({
required ChatServerPool? pool,
required Listenable connection,
required bool Function() connected,
required ApiGateway gateway,
required String machineId,
required String machineName,
required this.layout,
}) : machines = pool != null
? PoolTerminalMachines(pool)
: SingleTerminalMachines(
connection: connection,
connected: connected,
machine: TerminalMachine(
id: machineId,
name: machineName,
gateway: gateway,
),
) {
hub = TerminalHub(machines);
}
final ValueNotifier<List<TerminalMachine>> machines;
final TerminalLayout layout;
late final TerminalHub hub;
/// [shell] with the terminal panel, window or page around it.
Widget surround(Widget shell, {required bool cupertino}) => TerminalSurface(
hub: hub,
layout: layout,
cupertino: cupertino,
child: shell,
);
/// The bar button showing or hiding the terminal.
Widget toggle({required bool cupertino}) =>
TerminalToggleButton(layout: layout, cupertino: cupertino);
void dispose() {
hub.dispose();
machines.dispose();
}
}
+3
View File
@@ -1,3 +1,4 @@
import '../features/terminal/terminal_layout.dart';
import '../core/session/server_session.dart';
import '../ui/scale/ui_scale.dart';
import 'package:flutter/foundation.dart';
@@ -60,6 +61,7 @@ Future<void> runPipelinesApp({
// not hold the first frame, and applies when it lands.
final animationSpeed = AnimationSpeedController.instance.restore();
final uiScale = UiScaleController.instance.restore();
final terminalLayout = TerminalLayout.instance.restore();
final quickSwitchAnimation = QuickSwitchAnimationController.instance
.restore();
final font = AppFontController.instance.restore(wait: appFontStartupWait);
@@ -68,6 +70,7 @@ Future<void> runPipelinesApp({
await font;
await animationSpeed;
await uiScale;
await terminalLayout;
await quickSwitchAnimation;
final server = await resolveLaunchServer(
base: base,
+24 -1
View File
@@ -32,6 +32,8 @@ import '../features/updates/launch_update_dialog.dart';
import '../features/updates/web_release.dart';
import '../features/settings/server_connections.dart';
import 'app.dart';
import 'app_terminals.dart';
import '../features/terminal/terminal_layout.dart';
import 'app_route.dart';
import 'app_router.dart';
import 'app_session.dart';
@@ -82,9 +84,13 @@ class PipelinesApp extends StatefulWidget {
this.androidInstaller = downloadAndInstall,
this.webRefresher = refreshWebPage,
this.tabLocationsStore,
this.terminalLayout,
});
final TabLocationsStore? tabLocationsStore;
/// The terminal surface's saved layout; null is the device's own.
final TerminalLayout? terminalLayout;
final ServerEndpoint server;
final PipelinesClient? client;
final bool? cupertino;
@@ -195,6 +201,7 @@ class _PipelinesAppState extends State<PipelinesApp>
},
);
NotificationServiceHandoff? _deliveryHandoff;
late final AppTerminals _terminals;
@override
void initState() {
@@ -213,6 +220,18 @@ class _PipelinesAppState extends State<PipelinesApp>
serverId: widget.serverId,
);
bindServerIdentity(_session.gateway, widget.serverId);
_terminals = AppTerminals(
pool: widget.chatPool,
connection: _session,
connected: () => _session.connected,
gateway: _session.gateway,
machineId: widget.serverId ?? 'server',
machineName:
widget.servers?.catalog.active?.name ??
widget.server.uri?.host ??
'This server',
layout: widget.terminalLayout ?? TerminalLayout.instance,
);
_ownsProvider = widget.routeInformationProvider == null;
_provider =
widget.routeInformationProvider ??
@@ -421,6 +440,7 @@ class _PipelinesAppState extends State<PipelinesApp>
if (_ownsProvider) {
(_provider as PlatformRouteInformationProvider).dispose();
}
_terminals.dispose();
_session.dispose();
super.dispose();
}
@@ -697,7 +717,8 @@ class _PipelinesAppState extends State<PipelinesApp>
Widget _buildShell(BuildContext context, AppRoute route) =>
ValueListenableBuilder<int>(
valueListenable: _attentionCount,
builder: (context, count, _) => _shellFor(route, count),
builder: (context, count, _) =>
_terminals.surround(_shellFor(route, count), cupertino: _cupertino),
);
Widget _shellFor(AppRoute route, int attentionCount) {
@@ -715,6 +736,7 @@ class _PipelinesAppState extends State<PipelinesApp>
final runsRoute = tab(AppDestination.runs);
final chatRoute = tab(AppDestination.chat);
return AdaptiveShell(
barActions: [_terminals.toggle(cupertino: _cupertino)],
attentionCount: attentionCount,
cupertino: _cupertino,
destination: _destinationOf(route.kind),
@@ -803,6 +825,7 @@ class _PipelinesAppState extends State<PipelinesApp>
// Settings is a page of the Pipelines tab (its bar's gear), not a
// tab; the shell shows it with Back to Pipelines.
AppDestination.settings: (_) => SettingsScreen(
terminalLayout: _terminals.layout,
navigationScope: _navigationScope,
client: _session.client,
// A phone signs in at the web login; a browser has its own.