Files
pipelines/app/lib/features/chat/shell/chat_shell_output_view.dart
T
alan 89882d90f3 Draw chat shell runs in an xterm terminal that takes typed input
The card's output area is now an xterm.dart emulator kept per run by the
controller: it is fed the raw stream in order, takes typing and paste while
the command runs (with a key toolbar and a soft-keyboard field on touch
platforms), resizes the process to its layout, opens printed links, shrinks
finished runs to their output and opens full screen. A reconnect resumes from
the byte the card holds; Copy output copies the server's plain text.
2026-11-09 20:08:33 +00:00

66 lines
1.9 KiB
Dart

import 'package:flutter/material.dart';
import '../conversation/chat_card_styles.dart';
import 'chat_shell_run.dart';
import 'chat_shell_runs_controller.dart';
import 'chat_shell_terminal_keys.dart';
import 'chat_shell_terminal_view.dart';
/// The output area of one command card: the run's terminal emulator, which
/// takes typing while the command runs (with the key toolbar below it), or
/// its retained output read-only once it ended.
class ChatShellOutputView extends StatelessWidget {
const ChatShellOutputView({
super.key,
required this.run,
required this.controller,
required this.cupertino,
required this.viewKey,
required this.fullScreen,
});
final ChatShellRun run;
final ChatShellRunsController controller;
final bool cupertino;
/// Replaced when the full-screen view closes, so the card's view sizes the
/// terminal to itself again.
final Key viewKey;
/// True while the full-screen view sizes the terminal.
final bool fullScreen;
@override
Widget build(BuildContext context) {
if (!run.running && run.output.isEmpty) {
return Text(
'No output.',
key: const Key('chat-shell-output-empty'),
style: chatCardSecondaryStyle(context, cupertino),
);
}
final session = controller.terminals.session(run);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: [
ChatShellTerminalView(
key: viewKey,
session: session,
cupertino: cupertino,
autoResize: !fullScreen,
),
if (session.live && !fullScreen)
Padding(
padding: const EdgeInsets.only(top: 8),
child: ChatShellTerminalKeys(
session: session,
cupertino: cupertino,
field: chatShellTouchFirst(),
),
),
],
);
}
}