- 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).
64 lines
2.1 KiB
Dart
64 lines
2.1 KiB
Dart
// The chat's Markdown renderer, shared by message text, thinking blocks,
|
|
// compaction summaries and file previews.
|
|
import 'package:flutter/material.dart';
|
|
import 'package:gpt_markdown/gpt_markdown.dart';
|
|
// gpt_markdown renders through its own Material port; its colours come from
|
|
// that port's theme, so it has to be handed ours.
|
|
import 'package:material_ui/material_ui.dart' as mui;
|
|
|
|
/// gpt_markdown builds its widgets with `material_ui`, whose `Theme.of` falls
|
|
/// back to a light theme: without this the code panel and inline chips stayed
|
|
/// light (and their text dark) in the dark theme.
|
|
mui.ThemeData markdownThemeData(ThemeData theme) => mui.ThemeData(
|
|
useMaterial3: true,
|
|
brightness: theme.brightness,
|
|
colorScheme: mui.ColorScheme.fromSeed(
|
|
seedColor: theme.colorScheme.primary,
|
|
brightness: theme.brightness,
|
|
),
|
|
);
|
|
|
|
class MarkdownView extends StatelessWidget {
|
|
final String text;
|
|
final double fontSize;
|
|
final Color? color;
|
|
|
|
/// A little air around headings; messages use the default, thinking blocks
|
|
/// and previews a tighter one.
|
|
final double height;
|
|
|
|
const MarkdownView(
|
|
this.text, {
|
|
super.key,
|
|
this.fontSize = 15,
|
|
this.color,
|
|
this.height = 1.45,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return mui.Theme(
|
|
data: markdownThemeData(Theme.of(context)),
|
|
child: GptMarkdown(
|
|
_taskMarkers(text),
|
|
// The server already streams deltas; show them as they arrive.
|
|
isStreaming: false,
|
|
style: TextStyle(fontSize: fontSize, height: height, color: color),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// gpt_markdown draws task lists with `material_ui`'s Checkbox, which wants
|
|
/// a `material_ui` Material ancestor the app never provides (its Scaffold is
|
|
/// Flutter's). Boxed emoji read the same and cost no widget tree.
|
|
static String _taskMarkers(String source) {
|
|
var out = source.replaceAllMapped(
|
|
RegExp(r'^(\s*)[-*+]\s+\[[xX]\]\s+', multiLine: true),
|
|
(match) => '${match[1]}- ✅ ');
|
|
out = out.replaceAllMapped(
|
|
RegExp(r'^(\s*)[-*+]\s+\[\s?\]\s+', multiLine: true),
|
|
(match) => '${match[1]}- ⬜ ');
|
|
return out;
|
|
}
|
|
}
|