feat: the files sidebar, Markdown thinking, a banner that clears

- The chat's top-right menu only repeated the per-turn menu. It now opens a
  files sidebar that slides in from the right, the way the official client's
  right panel does: browse the session directory with a breadcrumb and an up
  key, filter the current directory, search its subdirectories (bounded,
  skipping .git/node_modules/build and friends), preview text/code/Markdown/
  images, edit and save text files, create files and folders, and download
  any file through the system save dialog.
- The panel's "..." menu carries the official client's "显示被 git 忽略的文件"
  toggle (the listing asks the server to respect gitignore by default) and a
  refresh. 项目知识 and 终端 have their tabs, marked as coming later.
- Thinking blocks are Markdown too (headings, lists, inline code), rendered
  with the shared MarkdownView at a smaller, quieter size.
- The reconnect banner stayed forever: the stream loop sets it when the SSE
  connection drops and nothing cleared it. Any event proves the stream is
  back (the server greets every connection with server.connected), so it now
  clears the message then.
- Markdown rendering moved to lib/widgets/markdown_view.dart, shared by
  messages, thinking, compaction summaries and file previews.
Version 0.3.9 (code 309).
This commit is contained in:
blumia committed 2026-11-20 18:25:28 +08:00
1 parent b9433c30cb
commit 9b53338908
9 files changed
+1118 -80

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
// 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(
text,
// The server already streams deltas; show them as they arrive.
isStreaming: false,
style: TextStyle(fontSize: fontSize, height: height, color: color),
),
);
}
}