feat: the terminal, project knowledge, and downloads that can be cancelled
- lib/api/terminal.dart: the PTY protocol (create/resize/restart/close, and the /api/terminal/ws binary control frames) with a reconnecting socket that replays the server snapshot at the size it was drawn for. - lib/terminal_state.dart: an xterm model plus that socket, kept per workspace on AppState, so closing the panel or switching tabs keeps the shell; the app reattaches when it returns from the background. - lib/screens/terminal_panel.dart: TerminalView, a status bar (keyboard, restart, clear, close) and a Termux-style key bar whose CTRL/ALT/SHIFT modifiers also apply to what the phone keyboard types. - lib/screens/knowledge_panel.dart: notes, todos and plans from /api/project-context, searchable, with a full page for a plan's Markdown and its raw editor. - Downloads stream with a progress dialog (bytes, total, percent) and a cancel that aborts the request; the save dialog only opens on success. The request asks for `accept-encoding: identity` so Content-Length exists. - MarkdownView renders task lists as ✅/⬜ instead of material_ui's Checkbox, which wants a material_ui Material ancestor the app lacks. - Dialogs own their TextEditingControllers, so closing one no longer trips a framework assertion in debug builds. - 0.3.11 (311).
This commit is contained in:
1 parent
60d02083d3
commit
5f95e2da97
14 files changed
+2347
-57
No files matched your search
@@ -10,6 +10,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'api/client.dart';
|
||||
import 'api/models.dart';
|
||||
import 'storage.dart';
|
||||
import 'terminal_state.dart';
|
||||
|
||||
const _eventTypes = [
|
||||
'session.created',
|
||||
@@ -67,6 +68,13 @@ class AppState extends ChangeNotifier {
|
||||
|
||||
ChatState? chat;
|
||||
|
||||
/// Terminals by workspace directory: switching sessions or tabs keeps the
|
||||
/// shell alive, and each directory gets its own.
|
||||
final Map<String, TerminalSessionState> terminals = {};
|
||||
|
||||
TerminalSessionState terminalFor(String directory) => terminals.putIfAbsent(
|
||||
directory, () => TerminalSessionState(this, directory));
|
||||
|
||||
/// Public way to signal UI changes (notifyListeners is protected).
|
||||
void touch() => notifyListeners();
|
||||
|
||||
@@ -178,6 +186,13 @@ class AppState extends ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<void> disconnect() async {
|
||||
for (final terminal in terminals.values) {
|
||||
// Closing the shell on the server is right when the connection itself
|
||||
// goes away; a panel close only detaches.
|
||||
await terminal.closeSession();
|
||||
terminal.dispose();
|
||||
}
|
||||
terminals.clear();
|
||||
client?.close();
|
||||
client = null;
|
||||
conn = null;
|
||||
@@ -325,6 +340,9 @@ class AppState extends ChangeNotifier {
|
||||
_startStream();
|
||||
await refreshSessions();
|
||||
if (chat != null) await chat!.reloadTail();
|
||||
for (final terminal in terminals.values) {
|
||||
await terminal.reconnectIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
void _applyEvent(Map<String, dynamic> ev) {
|
||||
|
||||
Reference in new issue
Block a user