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:
1 parent
d9d5424318
commit
6ced914757
9 files changed
+272
-56
No files matched your search
@@ -64,11 +64,15 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
final Set<String> _collapsedSteps = {};
|
||||
final Set<String> _expandedSteps = {};
|
||||
|
||||
/// Ticks the activity strip's clock while a turn runs.
|
||||
Timer? _runClock;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
chat.addListener(_onChat);
|
||||
_inputFocus.addListener(_onFocusChanged);
|
||||
if (chat.running) _startClock();
|
||||
// The list is reversed: offset 0 is the newest message (the bottom), and
|
||||
// older pages grow above without moving what is on screen.
|
||||
_scroll.addListener(() {
|
||||
@@ -87,6 +91,11 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
|
||||
void _onChat() {
|
||||
if (mounted) setState(() {});
|
||||
if (chat.running) {
|
||||
_startClock();
|
||||
} else {
|
||||
_stopClock();
|
||||
}
|
||||
if (_stick) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
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() {
|
||||
if (mounted) setState(() {});
|
||||
}
|
||||
@@ -102,6 +122,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
void dispose() {
|
||||
chat.removeListener(_onChat);
|
||||
_inputFocus.removeListener(_onFocusChanged);
|
||||
_stopClock();
|
||||
_draftCtrl.dispose();
|
||||
_inputFocus.dispose();
|
||||
_scroll.dispose();
|
||||
@@ -148,6 +169,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
Expanded(child: _messageList()),
|
||||
_permissions(),
|
||||
_forms(),
|
||||
if (chat.running) _activityStrip(),
|
||||
_composer(widget.keyboardInset),
|
||||
],
|
||||
),
|
||||
@@ -291,7 +313,9 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
if (last.error != null && !last.error!.isEmpty) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
var start = 0;
|
||||
final idx = chat.msgs.indexWhere((x) => x.id == m.id);
|
||||
|
||||
@@ -257,17 +257,20 @@ class _SessionListPaneState extends State<SessionListPane> {
|
||||
List<_SessionGroup> _groups(List<Session> sessions) {
|
||||
final map = <String, List<Session>>{};
|
||||
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)
|
||||
? '\u0000chats'
|
||||
: session.directory;
|
||||
: slashPath(session.directory);
|
||||
map.putIfAbsent(key, () => []).add(session);
|
||||
}
|
||||
final groups = [
|
||||
for (final entry in map.entries)
|
||||
_SessionGroup(
|
||||
key: entry.key,
|
||||
label: _groupLabel(entry.key),
|
||||
path: entry.key == '\u0000chats' ? '' : entry.key,
|
||||
label: _groupLabel(entry.value.first.directory),
|
||||
// The first session's own path: the server knows that spelling.
|
||||
path: entry.key == '\u0000chats' ? '' : entry.value.first.directory,
|
||||
sessions: entry.value
|
||||
..sort((a, b) => b.updated.compareTo(a.updated)),
|
||||
),
|
||||
@@ -294,50 +297,74 @@ class _SessionListPaneState extends State<SessionListPane> {
|
||||
|
||||
Widget _groupHeader(_SessionGroup group, {required bool collapsed}) {
|
||||
final theme = Theme.of(context);
|
||||
return InkWell(
|
||||
onTap: () => setState(() {
|
||||
if (collapsed) {
|
||||
_collapsed.remove(group.key);
|
||||
} else {
|
||||
_collapsed.add(group.key);
|
||||
}
|
||||
}),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(14, 10, 4, 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(collapsed ? Icons.chevron_right : Icons.expand_more,
|
||||
size: 16, color: theme.hintColor),
|
||||
const SizedBox(width: 2),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
final scheme = theme.colorScheme;
|
||||
final radius = BorderRadius.circular(10);
|
||||
// A tinted band, at least a session row's height: a project reads as a
|
||||
// section, not as another row.
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(8, 10, 8, 2),
|
||||
child: Material(
|
||||
color: scheme.surfaceContainerHighest.withValues(alpha: 0.5),
|
||||
borderRadius: radius,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: InkWell(
|
||||
onTap: () => setState(() {
|
||||
if (collapsed) {
|
||||
_collapsed.remove(group.key);
|
||||
} else {
|
||||
_collapsed.add(group.key);
|
||||
}
|
||||
}),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(minHeight: 56),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(10, 10, 4, 10),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
group.label.isEmpty ? '未命名项目' : group.label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 12.5, fontWeight: FontWeight.w700),
|
||||
),
|
||||
if (group.path.isNotEmpty)
|
||||
Text(
|
||||
group.path,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style:
|
||||
TextStyle(fontSize: 10.5, color: theme.hintColor),
|
||||
Icon(collapsed ? Icons.chevron_right : Icons.expand_more,
|
||||
size: 18, color: scheme.onSurfaceVariant),
|
||||
const SizedBox(width: 6),
|
||||
Icon(Icons.folder_outlined,
|
||||
size: 16, color: scheme.primary),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
group.label.isEmpty ? '未命名项目' : group.label,
|
||||
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),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user