fix: centre the context ring, show a live status while running, and settle project rows

- The folded composer aligns to its bottom edge, so the 16px usage ring sat
  below the 36px keys; a 10px bottom padding puts it on their centre line (the
  two-row layout was already centred).
- A running turn no longer shows the finished turn's footer (model · mode ·
  time, with its copy/fork menu). Above the input there is now an activity
  strip like dsh-Go's: "思考中 / 正在回复 / 正在读取 · …" with the current
  step's summary and a clock that ticks each second.
- Project headers in the sidebar are tinted bands at least a session row tall,
  with a folder icon, a bolder name and the path beneath, so the project and
  its sessions read as different levels.
- Project names take the last path segment with either separator, and path
  comparisons unify `\`/`/` (case-insensitively for drive-letter paths); the
  grouping key does too, so a Windows server no longer shows a full path or
  splits one project in two.
- 0.3.19 (319).
This commit is contained in:
blumia committed 2026-11-22 11:59:33 +08:00
1 parent d9d5424318
commit 6ced914757
9 files changed
+272 -56

No files matched your search

+11
View File
@@ -5,6 +5,17 @@
--- ---
## 0.3.19 输入框环居中、运行状态条、侧栏项目层级与 Windows 路径(分支 `flutter`)
| 项 | 结果 |
| --- | --- |
| 上下文环 | 单行输入框用 `CrossAxisAlignment.end`,16px 的环贴着底部而按键是 36px;给环加 10px 底边距,与按键同一中轴(有焦点时的两行布局本来就是居中,未改) |
| 运行中的尾部 | 运行中不再显示上一轮的 footer(模型 · 模式 · 用时,以及“复制回答 / 从这里分叉”菜单):`_turnRows` 在 `chat.running` 为真时不加 footer。改为在输入框上方显示 dsh-Go 风格的活动条:「思考中 / 正在回复 / 正在读取 · …」加当前步骤摘要和秒表,每秒刷新 |
| 侧栏项目 | 项目分组头改成带底色的圆角条,最小高度 56,加文件夹图标;标题 13.5 粗体、路径作副标题,与会话行的层级更清楚 |
| Windows 路径 | 项目名只取路径最后一段,`/` 与 `\` 都识别;同一项目的比较统一分隔符(盘符路径忽略大小写),分组键也统一分隔符,避免一个项目被拆成两组 |
| 版本 | **0.3.19(code 319)** |
---
## 0.3.18 需要密码的服务器无法输入密码(分支 `flutter`) ## 0.3.18 需要密码的服务器无法输入密码(分支 `flutter`)
| 项 | 结果 | | 项 | 结果 |
+4 -2
View File
@@ -5,7 +5,7 @@ Android first. This branch (`flutter`) is a framework evaluation: the same
feature set as the earlier Asuka/Go and MyGo attempts, reimplemented in feature set as the earlier Asuka/Go and MyGo attempts, reimplemented in
Flutter to compare mobile UI maturity. Flutter to compare mobile UI maturity.
Status: 0.3.18 — servers (passwordless / password login, HTTP/HTTPS and Status: 0.3.19 — servers (passwordless / password login, HTTP/HTTPS and
SOCKS5/socks5h proxy, self-signed certificates and pinning), session list with search and live SOCKS5/socks5h proxy, self-signed certificates and pinning), session list with search and live
events, chat with streaming Markdown and full history paging, tool steps events, chat with streaming Markdown and full history paging, tool steps
grouped per turn (icon, one-line summary, foldable run) with image previews, a grouped per turn (icon, one-line summary, foldable run) with image previews, a
@@ -22,7 +22,9 @@ composer folds to one line when unfocused (or when the keyboard is dismissed)
and opens into two rows on focus, as in dsh-Go: the model and its thinking level and opens into two rows on focus, as in dsh-Go: the model and its thinking level
form one pill, the Build/Plan mode a separate chip (picked from a sheet). A form one pill, the Build/Plan mode a separate chip (picked from a sheet). A
message sent while a turn runs can steer it or queue for its end, and waits as a message sent while a turn runs can steer it or queue for its end, and waits as a
pending bubble that can be withdrawn. The picker groups providers, favourites, pending bubble that can be withdrawn; while a turn runs, an activity strip above
the input names the current step and its clock instead of the finished turn's
footer. The picker groups providers, favourites,
recents and context size. The sidebar footer names the connected server (tap to recents and context size. The sidebar footer names the connected server (tap to
switch) beside a settings key; settings holds appearance (theme mode and seed switch) beside a settings key; settings holds appearance (theme mode and seed
colour, device-local), the server's follow-up behavior (steer or queue on a send colour, device-local), the server's follow-up behavior (steer or queue on a send
+25 -4
View File
@@ -167,13 +167,34 @@ class ProjectInfo {
String get label { String get label {
if (name.trim().isNotEmpty) return name.trim(); if (name.trim().isNotEmpty) return name.trim();
final trimmed = return pathLeaf(canonical);
canonical.replaceAll(RegExp(r'/+$'), '');
final index = trimmed.lastIndexOf('/');
return index >= 0 ? trimmed.substring(index + 1) : trimmed;
} }
} }
/// The last segment of a path, treating `\` and `/` alike: a Windows server
/// sends `C:\...` and a project has to read as its folder name, not the path.
String pathLeaf(String path) {
final trimmed = path.replaceAll(RegExp(r'[/\\]+$'), '');
final index = trimmed.lastIndexOf(RegExp(r'[/\\]'));
return index >= 0 ? trimmed.substring(index + 1) : trimmed;
}
/// A path with `\` written as `/` and no trailing slash, for comparing and
/// grouping directory names from a Windows or a POSIX server.
String slashPath(String path) =>
path.replaceAll('\\', '/').replaceAll(RegExp(r'/+$'), '');
/// Whether two directory paths name the same place. Separators are unified;
/// a drive-letter path compares case-insensitively, as Windows does.
bool samePath(String a, String b) {
final x = slashPath(a);
final y = slashPath(b);
if (x == y) return true;
final windows = RegExp(r'^[A-Za-z]:').hasMatch(x) ||
RegExp(r'^[A-Za-z]:').hasMatch(y);
return windows && x.toLowerCase() == y.toLowerCase();
}
class ContentPart { class ContentPart {
final String type; final String type;
final String text; final String text;
+119 -1
View File
@@ -64,11 +64,15 @@ class _ChatScreenState extends State<ChatScreen> {
final Set<String> _collapsedSteps = {}; final Set<String> _collapsedSteps = {};
final Set<String> _expandedSteps = {}; final Set<String> _expandedSteps = {};
/// Ticks the activity strip's clock while a turn runs.
Timer? _runClock;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
chat.addListener(_onChat); chat.addListener(_onChat);
_inputFocus.addListener(_onFocusChanged); _inputFocus.addListener(_onFocusChanged);
if (chat.running) _startClock();
// The list is reversed: offset 0 is the newest message (the bottom), and // The list is reversed: offset 0 is the newest message (the bottom), and
// older pages grow above without moving what is on screen. // older pages grow above without moving what is on screen.
_scroll.addListener(() { _scroll.addListener(() {
@@ -87,6 +91,11 @@ class _ChatScreenState extends State<ChatScreen> {
void _onChat() { void _onChat() {
if (mounted) setState(() {}); if (mounted) setState(() {});
if (chat.running) {
_startClock();
} else {
_stopClock();
}
if (_stick) { if (_stick) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
if (_scroll.hasClients) _scroll.jumpTo(0); if (_scroll.hasClients) _scroll.jumpTo(0);
@@ -94,6 +103,17 @@ class _ChatScreenState extends State<ChatScreen> {
} }
} }
void _startClock() {
_runClock ??= Timer.periodic(const Duration(seconds: 1), (_) {
if (mounted && chat.running) setState(() {});
});
}
void _stopClock() {
_runClock?.cancel();
_runClock = null;
}
void _onFocusChanged() { void _onFocusChanged() {
if (mounted) setState(() {}); if (mounted) setState(() {});
} }
@@ -102,6 +122,7 @@ class _ChatScreenState extends State<ChatScreen> {
void dispose() { void dispose() {
chat.removeListener(_onChat); chat.removeListener(_onChat);
_inputFocus.removeListener(_onFocusChanged); _inputFocus.removeListener(_onFocusChanged);
_stopClock();
_draftCtrl.dispose(); _draftCtrl.dispose();
_inputFocus.dispose(); _inputFocus.dispose();
_scroll.dispose(); _scroll.dispose();
@@ -148,6 +169,7 @@ class _ChatScreenState extends State<ChatScreen> {
Expanded(child: _messageList()), Expanded(child: _messageList()),
_permissions(), _permissions(),
_forms(), _forms(),
if (chat.running) _activityStrip(),
_composer(widget.keyboardInset), _composer(widget.keyboardInset),
], ],
), ),
@@ -291,7 +313,9 @@ class _ChatScreenState extends State<ChatScreen> {
if (last.error != null && !last.error!.isEmpty) { if (last.error != null && !last.error!.isEmpty) {
out.add(_Row('error', last.id, -1)); out.add(_Row('error', last.id, -1));
} }
if (last.completed > 0 && _turnEndsAt(to)) { // A running turn has no "done" strip (nor its copy/fork menu): the
// activity strip above the composer speaks for it instead.
if (last.completed > 0 && _turnEndsAt(to) && !chat.running) {
out.add(_Row('footer', last.id, -1)); out.add(_Row('footer', last.id, -1));
} }
} }
@@ -1317,6 +1341,100 @@ class _ChatScreenState extends State<ChatScreen> {
); );
} }
/// What the agent is doing right now, for the strip above the composer.
({String title, String detail}) _activity() {
for (var i = chat.msgs.length - 1; i >= 0; i--) {
final m = chat.msgs[i];
if (m.type != 'assistant') continue;
for (var p = m.content.length - 1; p >= 0; p--) {
final part = m.content[p];
final st = part.state?.status ?? '';
if (part.type == 'tool' &&
(st == 'running' || st == 'streaming' || st == 'pending')) {
return (title: '正在${_stepLabel(part)}', detail: _stepSummary(part));
}
}
if (m.completed == 0) {
// No tool running yet: say which part of the reply is being written.
final text =
m.content.any((p) => p.type == 'text' && p.text.trim().isNotEmpty);
final reasoning = m.content
.any((p) => p.type == 'reasoning' && p.text.trim().isNotEmpty);
if (text) return (title: '正在回复', detail: '');
if (reasoning) return (title: '思考中', detail: '');
}
break;
}
return (title: '思考中', detail: '');
}
/// The running turn started with the newest user message.
int _runningStart() {
for (var i = chat.msgs.length - 1; i >= 0; i--) {
if (chat.msgs[i].type == 'user') return chat.msgs[i].created;
}
return 0;
}
String _elapsedSince(int start) {
if (start <= 0) return '';
final secs =
((DateTime.now().millisecondsSinceEpoch - start) / 1000).round();
if (secs <= 0) return '';
if (secs < 60) return '$secs 秒';
return '${secs ~/ 60}:${(secs % 60).toString().padLeft(2, '0')}';
}
/// dsh-Go's activity strip: the current step and its clock, above the input.
Widget _activityStrip() {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
final act = _activity();
final elapsed = _elapsedSince(_runningStart());
return Padding(
padding: const EdgeInsets.fromLTRB(14, 2, 14, 2),
child: Row(
children: [
SizedBox(
width: 13,
height: 13,
child: CircularProgressIndicator(
strokeWidth: 1.7,
color: scheme.primary,
),
),
const SizedBox(width: 8),
Expanded(
child: Text.rich(
TextSpan(children: [
TextSpan(
text: act.title,
style: TextStyle(
fontSize: 12.5,
fontWeight: FontWeight.w600,
color: scheme.onSurface,
),
),
if (act.detail.isNotEmpty)
TextSpan(
text: ' · ${act.detail}',
style: TextStyle(fontSize: 12, color: theme.hintColor),
),
if (elapsed.isNotEmpty)
TextSpan(
text: ' · $elapsed',
style: TextStyle(fontSize: 12, color: theme.hintColor),
),
]),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
],
),
);
}
String _turnDuration(Message m) { String _turnDuration(Message m) {
var start = 0; var start = 0;
final idx = chat.msgs.indexWhere((x) => x.id == m.id); final idx = chat.msgs.indexWhere((x) => x.id == m.id);
+69 -42
View File
@@ -257,17 +257,20 @@ class _SessionListPaneState extends State<SessionListPane> {
List<_SessionGroup> _groups(List<Session> sessions) { List<_SessionGroup> _groups(List<Session> sessions) {
final map = <String, List<Session>>{}; final map = <String, List<Session>>{};
for (final session in sessions) { for (final session in sessions) {
// Group on a separator-normalised key so a Windows server's mix of
// `\` and `/` does not split one project into two.
final key = _isChatDirectory(session.directory) final key = _isChatDirectory(session.directory)
? '\u0000chats' ? '\u0000chats'
: session.directory; : slashPath(session.directory);
map.putIfAbsent(key, () => []).add(session); map.putIfAbsent(key, () => []).add(session);
} }
final groups = [ final groups = [
for (final entry in map.entries) for (final entry in map.entries)
_SessionGroup( _SessionGroup(
key: entry.key, key: entry.key,
label: _groupLabel(entry.key), label: _groupLabel(entry.value.first.directory),
path: entry.key == '\u0000chats' ? '' : entry.key, // The first session's own path: the server knows that spelling.
path: entry.key == '\u0000chats' ? '' : entry.value.first.directory,
sessions: entry.value sessions: entry.value
..sort((a, b) => b.updated.compareTo(a.updated)), ..sort((a, b) => b.updated.compareTo(a.updated)),
), ),
@@ -294,50 +297,74 @@ class _SessionListPaneState extends State<SessionListPane> {
Widget _groupHeader(_SessionGroup group, {required bool collapsed}) { Widget _groupHeader(_SessionGroup group, {required bool collapsed}) {
final theme = Theme.of(context); final theme = Theme.of(context);
return InkWell( final scheme = theme.colorScheme;
onTap: () => setState(() { final radius = BorderRadius.circular(10);
if (collapsed) { // A tinted band, at least a session row's height: a project reads as a
_collapsed.remove(group.key); // section, not as another row.
} else { return Padding(
_collapsed.add(group.key); padding: const EdgeInsets.fromLTRB(8, 10, 8, 2),
} child: Material(
}), color: scheme.surfaceContainerHighest.withValues(alpha: 0.5),
child: Padding( borderRadius: radius,
padding: const EdgeInsets.fromLTRB(14, 10, 4, 4), clipBehavior: Clip.antiAlias,
child: Row( child: InkWell(
children: [ onTap: () => setState(() {
Icon(collapsed ? Icons.chevron_right : Icons.expand_more, if (collapsed) {
size: 16, color: theme.hintColor), _collapsed.remove(group.key);
const SizedBox(width: 2), } else {
Expanded( _collapsed.add(group.key);
child: Column( }
crossAxisAlignment: CrossAxisAlignment.start, }),
child: ConstrainedBox(
constraints: const BoxConstraints(minHeight: 56),
child: Padding(
padding: const EdgeInsets.fromLTRB(10, 10, 4, 10),
child: Row(
children: [ children: [
Text( Icon(collapsed ? Icons.chevron_right : Icons.expand_more,
group.label.isEmpty ? '未命名项目' : group.label, size: 18, color: scheme.onSurfaceVariant),
maxLines: 1, const SizedBox(width: 6),
overflow: TextOverflow.ellipsis, Icon(Icons.folder_outlined,
style: const TextStyle( size: 16, color: scheme.primary),
fontSize: 12.5, fontWeight: FontWeight.w700), const SizedBox(width: 6),
), Expanded(
if (group.path.isNotEmpty) child: Column(
Text( crossAxisAlignment: CrossAxisAlignment.start,
group.path, mainAxisSize: MainAxisSize.min,
maxLines: 1, children: [
overflow: TextOverflow.ellipsis, Text(
style: group.label.isEmpty ? '未命名项目' : group.label,
TextStyle(fontSize: 10.5, color: theme.hintColor), maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 13.5,
fontWeight: FontWeight.w700,
color: scheme.onSurface),
),
if (group.path.isNotEmpty)
Padding(
padding: const EdgeInsets.only(top: 2),
child: Text(
group.path,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 11, color: theme.hintColor),
),
),
],
), ),
),
IconButton(
icon: const Icon(Icons.add, size: 18),
tooltip: '在此项目新会话',
visualDensity: VisualDensity.compact,
onPressed: () => _newSession(directory: group.path),
),
], ],
), ),
), ),
IconButton( ),
icon: const Icon(Icons.add, size: 18),
tooltip: '在此项目新会话',
visualDensity: VisualDensity.compact,
onPressed: () => _newSession(directory: group.path),
),
],
), ),
), ),
); );
+3 -5
View File
@@ -474,16 +474,14 @@ class AppState extends ChangeNotifier {
String projectLabelFor(String directory) { String projectLabelFor(String directory) {
if (directory.isEmpty) return ''; if (directory.isEmpty) return '';
for (final project in projects) { for (final project in projects) {
if (project.canonical == directory) return project.label; if (samePath(project.canonical, directory)) return project.label;
} }
final trimmed = directory.replaceAll(RegExp(r'/+$'), ''); return pathLeaf(directory);
final index = trimmed.lastIndexOf('/');
return index >= 0 ? trimmed.substring(index + 1) : trimmed;
} }
ProjectInfo? projectFor(String directory) { ProjectInfo? projectFor(String directory) {
for (final project in projects) { for (final project in projects) {
if (project.canonical == directory) return project; if (samePath(project.canonical, directory)) return project;
} }
return null; return null;
} }
+7 -1
View File
@@ -187,7 +187,13 @@ class _ComposerBoxState extends State<ComposerBox> {
Expanded(child: _field()), Expanded(child: _field()),
const SizedBox(width: 4), const SizedBox(width: 4),
if (accessory != null) ...[ if (accessory != null) ...[
accessory, // The keys are 36 high and the row aligns to its bottom:
// lift the smaller accessory by half the difference so it
// sits on the keys' centre line, not below it.
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: accessory,
),
const SizedBox(width: 2), const SizedBox(width: 2),
], ],
widget.trailing, widget.trailing,
+1 -1
View File
@@ -2,7 +2,7 @@ name: openchamber
description: "A lightweight OpenChamber client for phones." description: "A lightweight OpenChamber client for phones."
publish_to: 'none' publish_to: 'none'
version: 0.3.18+318 version: 0.3.19+319
environment: environment:
sdk: ^3.14.0 sdk: ^3.14.0
+33
View File
@@ -0,0 +1,33 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:openchamber/api/models.dart';
void main() {
test('a Windows project path reads as its folder name', () {
expect(pathLeaf(r'C:\msys64\home\Gary\Sources\pineapple-notepad'),
'pineapple-notepad');
expect(pathLeaf('/home/blumia/Sources/telegram/'), 'telegram');
expect(pathLeaf('relative'), 'relative');
expect(
ProjectInfo(id: 'p', canonical: r'C:\work\pineapple-notepad').label,
'pineapple-notepad',
);
expect(
ProjectInfo(id: 'p', canonical: '/w/x', name: '显式名称').label,
'显式名称',
);
});
test('the same place compares across separators and Windows case', () {
expect(samePath(r'C:\x\y', 'C:/x/y'), isTrue);
expect(samePath(r'C:\X\y', r'c:\x\Y'), isTrue);
expect(samePath('/a/b/', '/a/b'), isTrue);
expect(samePath('/a/b', '/a/c'), isFalse);
// A POSIX path stays case-sensitive.
expect(samePath('/a/B', '/a/b'), isFalse);
});
test('slashPath only unifies separators', () {
expect(slashPath(r'C:\a\b\'), 'C:/a/b');
});
}