feat: tabs own the panel header, a Termux key bar, and agent memory
- The panel's top row is now the tab group plus the close button; each tab keeps its own header: the files tab has the breadcrumb with new/more (or the name and edit/download while previewing), knowledge its search and refresh, the terminal its status. - The key bar is Termux's two rows of seven: ESC / — HOME ↑ END PGUP, then TAB CTRL ALT ← ↓ → PGDN; the modifiers still apply to what the phone keyboard types. - The panel is a dialog, so it gives the IME's height back itself (viewInsets.bottom). The key bar and the terminal stay above the keyboard, and the PTY reflows to the smaller terminal. - Project knowledge gains the memory tab: both scopes from /api/agent-memory/all, absent when the server has memory switched off, with type, edit and delete. - File preview editing passes minLines: null alongside expands. - 0.3.12 (312).
This commit is contained in:
1 parent
5f95e2da97
commit
5a371e4faf
8 files changed
+675
-231
No files matched your search
+180
-168
@@ -387,57 +387,198 @@ class _FilesPanelState extends State<FilesPanel> {
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return SafeArea(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
child: Padding(
|
||||
// The panel is a dialog, so it does not shrink for the keyboard on its
|
||||
// own: give the IME's height back here, or it covers the terminal's
|
||||
// key bar and its last lines.
|
||||
padding:
|
||||
EdgeInsets.only(bottom: MediaQuery.viewInsetsOf(context).bottom),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_tabs(theme),
|
||||
const Divider(height: 1),
|
||||
Expanded(child: _body(theme)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// The tab row is the panel's title now; the only global action left is
|
||||
/// closing the panel. Everything else belongs to the tab's own header.
|
||||
Widget _tabs(ThemeData theme) {
|
||||
const labels = ['文件', '项目知识', '终端'];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 6, 2, 6),
|
||||
child: Row(
|
||||
children: [
|
||||
_header(theme),
|
||||
_tabs(theme),
|
||||
const Divider(height: 1),
|
||||
Expanded(child: _body(theme)),
|
||||
Expanded(
|
||||
child: SegmentedButton<int>(
|
||||
showSelectedIcon: false,
|
||||
style: const ButtonStyle(
|
||||
visualDensity: VisualDensity.compact,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
segments: [
|
||||
for (var i = 0; i < labels.length; i++)
|
||||
ButtonSegment(value: i, label: Text(labels[i])),
|
||||
],
|
||||
selected: {_tab},
|
||||
onSelectionChanged: (v) => setState(() => _tab = v.first),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
tooltip: '关闭侧栏',
|
||||
onPressed: () => Navigator.of(context).maybePop(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _header(ThemeData theme) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(6, 6, 6, 0),
|
||||
child: Row(
|
||||
children: [
|
||||
if (_previewPath != null)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
tooltip: '返回',
|
||||
onPressed: () => setState(() => _previewPath = null),
|
||||
)
|
||||
else
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
Widget _body(ThemeData theme) {
|
||||
if (_root.isEmpty) {
|
||||
return const Center(child: Text('这个会话没有关联目录'));
|
||||
}
|
||||
switch (_tab) {
|
||||
case 1:
|
||||
return KnowledgePanel(app: widget.app, directory: _root);
|
||||
case 2:
|
||||
return TerminalPanel(app: widget.app, directory: _root);
|
||||
default:
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_pathBar(theme),
|
||||
Expanded(
|
||||
child: _previewPath != null
|
||||
? _previewBody(theme)
|
||||
: _browserBody(theme),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _browserBody(ThemeData theme) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 0, 12, 6),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _search,
|
||||
onChanged: (v) => setState(() {
|
||||
_query = v;
|
||||
_deepResults = [];
|
||||
_deepDone = false;
|
||||
}),
|
||||
style: const TextStyle(fontSize: 14),
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
prefixIcon: const Icon(Icons.search, size: 20),
|
||||
hintText: '搜索当前目录…',
|
||||
suffixIcon: _query.trim().isEmpty
|
||||
? null
|
||||
: IconButton(
|
||||
icon: const Icon(Icons.travel_explore, size: 20),
|
||||
tooltip: '搜索子目录',
|
||||
onPressed: _searching ? null : _deepSearch,
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(vertical: 10, horizontal: 12),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (_searching)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(_previewPath != null ? _previewName : '文件',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 16, fontWeight: FontWeight.w600)),
|
||||
if (_previewPath == null && _root.isNotEmpty)
|
||||
Text(_rootName,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 12, color: theme.hintColor)),
|
||||
const SizedBox(
|
||||
width: 14,
|
||||
height: 14,
|
||||
child: CircularProgressIndicator(strokeWidth: 2)),
|
||||
const SizedBox(width: 8),
|
||||
Text('正在搜索子目录…(${_deepResults.length})',
|
||||
style: TextStyle(fontSize: 12, color: theme.hintColor)),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (_previewPath != null) ...[
|
||||
Expanded(child: _list(theme)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// The tab's own header: where you are, plus what you can do here. The
|
||||
/// panel's global actions (close) sit in the tab row above.
|
||||
Widget _pathBar(ThemeData theme) {
|
||||
final crumbs = _crumbs;
|
||||
final preview = _previewPath != null;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(4, 0, 4, 4),
|
||||
child: Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: Icon(preview ? Icons.arrow_back : Icons.arrow_upward,
|
||||
size: 20),
|
||||
tooltip: preview ? '返回' : '上一级',
|
||||
onPressed: preview
|
||||
? () => setState(() => _previewPath = null)
|
||||
: (_path == _root ? null : _up),
|
||||
),
|
||||
Expanded(
|
||||
child: preview
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(_previewName,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 13.5, fontWeight: FontWeight.w600)),
|
||||
Text(_previewPath!,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 11, color: theme.hintColor)),
|
||||
],
|
||||
)
|
||||
: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
_crumb(theme, _rootName, () => _load(_root),
|
||||
last: crumbs.isEmpty),
|
||||
for (var i = 0; i < crumbs.length; i++) ...[
|
||||
Text(' / ', style: TextStyle(color: theme.hintColor)),
|
||||
_crumb(theme, crumbs[i], () => _goToCrumb(i),
|
||||
last: i == crumbs.length - 1),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (preview) ...[
|
||||
if (_previewText != null)
|
||||
IconButton(
|
||||
icon: Icon(_editing ? Icons.visibility_outlined : Icons.edit_outlined),
|
||||
icon: Icon(_editing
|
||||
? Icons.visibility_outlined
|
||||
: Icons.edit_outlined),
|
||||
tooltip: _editing ? '预览' : '编辑',
|
||||
onPressed: _saving
|
||||
? null
|
||||
: () => setState(() => _editing = !_editing),
|
||||
onPressed:
|
||||
_saving ? null : () => setState(() => _editing = !_editing),
|
||||
),
|
||||
if (_editing)
|
||||
IconButton(
|
||||
@@ -495,136 +636,6 @@ class _FilesPanelState extends State<FilesPanel> {
|
||||
],
|
||||
),
|
||||
],
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
tooltip: '关闭',
|
||||
onPressed: () => Navigator.of(context).maybePop(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _tabs(ThemeData theme) {
|
||||
const labels = ['文件', '项目知识', '终端'];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 4, 12, 8),
|
||||
child: SegmentedButton<int>(
|
||||
showSelectedIcon: false,
|
||||
style: const ButtonStyle(
|
||||
visualDensity: VisualDensity.compact,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
segments: [
|
||||
for (var i = 0; i < labels.length; i++)
|
||||
ButtonSegment(value: i, label: Text(labels[i])),
|
||||
],
|
||||
selected: {_tab},
|
||||
onSelectionChanged: (v) => setState(() => _tab = v.first),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _body(ThemeData theme) {
|
||||
if (_root.isEmpty) {
|
||||
return const Center(child: Text('这个会话没有关联目录'));
|
||||
}
|
||||
switch (_tab) {
|
||||
case 1:
|
||||
return KnowledgePanel(app: widget.app, directory: _root);
|
||||
case 2:
|
||||
return TerminalPanel(app: widget.app, directory: _root);
|
||||
default:
|
||||
if (_previewPath != null) return _previewBody(theme);
|
||||
return _browser(theme);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _browser(ThemeData theme) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_pathBar(theme),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 0, 12, 6),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _search,
|
||||
onChanged: (v) => setState(() {
|
||||
_query = v;
|
||||
_deepResults = [];
|
||||
_deepDone = false;
|
||||
}),
|
||||
style: const TextStyle(fontSize: 14),
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
prefixIcon: const Icon(Icons.search, size: 20),
|
||||
hintText: '搜索当前目录…',
|
||||
suffixIcon: _query.trim().isEmpty
|
||||
? null
|
||||
: IconButton(
|
||||
icon: const Icon(Icons.travel_explore, size: 20),
|
||||
tooltip: '搜索子目录',
|
||||
onPressed: _searching ? null : _deepSearch,
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(vertical: 10, horizontal: 12),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (_searching)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(
|
||||
width: 14,
|
||||
height: 14,
|
||||
child: CircularProgressIndicator(strokeWidth: 2)),
|
||||
const SizedBox(width: 8),
|
||||
Text('正在搜索子目录…(${_deepResults.length})',
|
||||
style: TextStyle(fontSize: 12, color: theme.hintColor)),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(child: _list(theme)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _pathBar(ThemeData theme) {
|
||||
final crumbs = _crumbs;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(4, 0, 8, 4),
|
||||
child: Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.arrow_upward, size: 20),
|
||||
tooltip: '上一级',
|
||||
onPressed: _path == _root ? null : _up,
|
||||
),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
_crumb(theme, _rootName, () => _load(_root), last: crumbs.isEmpty),
|
||||
for (var i = 0; i < crumbs.length; i++) ...[
|
||||
Text(' / ', style: TextStyle(color: theme.hintColor)),
|
||||
_crumb(theme, crumbs[i], () => _goToCrumb(i),
|
||||
last: i == crumbs.length - 1),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -800,6 +811,7 @@ class _FilesPanelState extends State<FilesPanel> {
|
||||
child: TextField(
|
||||
controller: _editor,
|
||||
maxLines: null,
|
||||
minLines: null,
|
||||
expands: true,
|
||||
style: const TextStyle(fontSize: 13, fontFamily: 'monospace', height: 1.4),
|
||||
textAlignVertical: TextAlignVertical.top,
|
||||
|
||||
Reference in new issue
Block a user