Skip to content

Commit b6f8732

Browse files
committed
Keyboard shortcuts with a Settings list; Activity grouped by day
Alt+F9 toggles Activity, Ctrl/Cmd+1-4 pick History, Changes, Files and Report, Ctrl+Tab / Ctrl+Shift+Tab and Alt+1-9 switch repo tabs. Keys show in tooltips and in a read-only Settings > Keyboard shortcuts page. Activity rows are grouped under Today / Yesterday / date headers, with a relative time after the message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Faq4edqhkSFNm9LMD8KnUP
1 parent d54588f commit b6f8732

8 files changed

Lines changed: 479 additions & 77 deletions

File tree

‎flutter/lib/l10n/translations.dart‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,19 @@ const Map<String, Map<String, String>> translations = {
142142
'no_current_branch': 'No current branch.',
143143
'accent_color': 'Accent color',
144144
'activity': 'Activity',
145+
'settings_shortcuts': 'Keyboard shortcuts',
146+
'settings_shortcuts_description': 'Keys for moving around Branchi.',
147+
'shortcuts_panels': 'Panels',
148+
'shortcuts_sections': 'Sections',
149+
'shortcuts_tabs': 'Tabs',
150+
'shortcut_terminal': 'Show or hide the terminal',
151+
'shortcut_activity': 'Show or hide activity',
152+
'shortcut_next_tab': 'Next tab',
153+
'shortcut_previous_tab': 'Previous tab',
154+
'shortcut_go_to_tab': 'Go to tab 1–9',
155+
'activity_today': 'Today',
156+
'activity_yesterday': 'Yesterday',
157+
'activity_just_now': 'just now',
145158
'ready': 'Ready',
146159
'editor_explorer': 'Explorer',
147160
'editor_modified': 'Modified',
@@ -580,6 +593,19 @@ const Map<String, Map<String, String>> translations = {
580593
'no_current_branch': 'لا يوجد فرع حالي.',
581594
'accent_color': 'اللون المميز',
582595
'activity': 'النشاط',
596+
'settings_shortcuts': 'اختصارات لوحة المفاتيح',
597+
'settings_shortcuts_description': 'مفاتيح للتنقل في Branchi.',
598+
'shortcuts_panels': 'اللوحات',
599+
'shortcuts_sections': 'الأقسام',
600+
'shortcuts_tabs': 'علامات التبويب',
601+
'shortcut_terminal': 'إظهار الطرفية أو إخفاؤها',
602+
'shortcut_activity': 'إظهار النشاط أو إخفاؤه',
603+
'shortcut_next_tab': 'علامة التبويب التالية',
604+
'shortcut_previous_tab': 'علامة التبويب السابقة',
605+
'shortcut_go_to_tab': 'الانتقال إلى علامة التبويب 1–9',
606+
'activity_today': 'اليوم',
607+
'activity_yesterday': 'أمس',
608+
'activity_just_now': 'الآن',
583609
'ready': 'جاهز',
584610
'editor_explorer': 'المستكشف',
585611
'editor_modified': 'معدّل',
@@ -1018,6 +1044,19 @@ const Map<String, Map<String, String>> translations = {
10181044
'no_current_branch': 'شاخه فعلی وجود ندارد.',
10191045
'accent_color': 'رنگ تأکیدی',
10201046
'activity': 'فعالیت',
1047+
'settings_shortcuts': 'میانبرهای صفحه‌کلید',
1048+
'settings_shortcuts_description': 'کلیدهای جابه‌جایی در Branchi.',
1049+
'shortcuts_panels': 'پنل‌ها',
1050+
'shortcuts_sections': 'بخش‌ها',
1051+
'shortcuts_tabs': 'تب‌ها',
1052+
'shortcut_terminal': 'نمایش یا پنهان کردن ترمینال',
1053+
'shortcut_activity': 'نمایش یا پنهان کردن فعالیت',
1054+
'shortcut_next_tab': 'تب بعدی',
1055+
'shortcut_previous_tab': 'تب قبلی',
1056+
'shortcut_go_to_tab': 'رفتن به تب ۱ تا ۹',
1057+
'activity_today': 'امروز',
1058+
'activity_yesterday': 'دیروز',
1059+
'activity_just_now': 'همین الان',
10211060
'ready': 'آماده',
10221061
'editor_explorer': 'کاوشگر',
10231062
'editor_modified': 'تغییر یافته',

‎flutter/lib/logs/logs_panel.dart‎

Lines changed: 161 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
import 'dart:async';
2+
13
import 'package:flutter/material.dart';
24

5+
import '../l10n/app_calendar.dart';
6+
37
import '../l10n/app_locale.dart';
48
import 'action_log.dart';
59
import 'action_stats_label.dart';
10+
import '../theme/app_theme.dart';
611

712
/// Minimum and maximum drag-resize height for the logs/terminal panels.
813
const double kPanelMinHeight = 80;
@@ -38,77 +43,113 @@ class PanelResizeHandle extends StatelessWidget {
3843
}
3944
}
4045

41-
/// The bottom logs panel: a timestamped list of git actions run through
42-
/// [GitActions], newest first.
43-
class LogsPanel extends StatelessWidget {
46+
/// The bottom logs panel: git actions run through [GitActions], newest
47+
/// first, grouped by day ("Today", "Yesterday", "Sep 8, 2026"). Today's
48+
/// recent actions show a relative time ("4 min ago"); hovering a time shows
49+
/// the exact one.
50+
class LogsPanel extends StatefulWidget {
4451
const LogsPanel({super.key, required this.height, required this.onHeightChanged});
4552

4653
final double height;
4754
final ValueChanged<double> onHeightChanged;
4855

56+
@override
57+
State<LogsPanel> createState() => _LogsPanelState();
58+
}
59+
60+
class _LogsPanelState extends State<LogsPanel> {
61+
/// Keeps "4 min ago" current.
62+
Timer? _ticker;
63+
64+
@override
65+
void initState() {
66+
super.initState();
67+
_ticker = Timer.periodic(
68+
const Duration(seconds: 30),
69+
(_) => setState(() {}),
70+
);
71+
}
72+
73+
@override
74+
void dispose() {
75+
_ticker?.cancel();
76+
super.dispose();
77+
}
78+
4979
@override
5080
Widget build(BuildContext context) {
51-
final colorScheme = Theme.of(context).colorScheme;
81+
final b = context.branchi;
5282
return Column(
5383
mainAxisSize: MainAxisSize.min,
5484
children: [
5585
PanelResizeHandle(
56-
onDrag: (delta) => onHeightChanged(
57-
(height + delta).clamp(kPanelMinHeight, kPanelMaxHeight),
86+
onDrag: (delta) => widget.onHeightChanged(
87+
(widget.height + delta).clamp(kPanelMinHeight, kPanelMaxHeight),
5888
),
5989
),
6090
Container(
61-
height: height,
91+
height: widget.height,
6292
decoration: BoxDecoration(
63-
color: colorScheme.surface,
64-
border: Border(top: BorderSide(color: colorScheme.outlineVariant)),
93+
color: b.bg,
94+
border: Border(top: b.hairline),
6595
),
66-
child: AnimatedBuilder(
67-
animation: ActionLog.instance,
96+
child: ListenableBuilder(
97+
listenable: Listenable.merge(
98+
[ActionLog.instance, AppCalendarSettings.preference],
99+
),
68100
builder: (context, _) {
69101
final entries = ActionLog.instance.entries;
70102
if (entries.isEmpty) {
71103
return Center(
72104
child: Text(
73105
translate('no_logged_actions'),
74-
style: TextStyle(color: colorScheme.onSurfaceVariant),
106+
style: TextStyle(color: b.muted),
75107
),
76108
);
77109
}
110+
final now = DateTime.now();
111+
final cal = AppCalendarSettings.current;
112+
// Day headers between the entries: a String is a header,
113+
// an ActionLogEntry a row.
114+
final items = <Object>[];
115+
DateTime? day;
116+
for (final entry in entries) {
117+
final t = entry.timestamp;
118+
final entryDay = DateTime(t.year, t.month, t.day);
119+
if (entryDay != day) {
120+
day = entryDay;
121+
items.add(_dayLabel(entryDay, now, cal));
122+
}
123+
items.add(entry);
124+
}
78125
return GestureDetector(
79126
onSecondaryTapUp: (details) =>
80127
_showClearMenu(context, details.globalPosition),
81128
behavior: HitTestBehavior.translucent,
82129
child: ListView.builder(
83-
itemCount: entries.length,
130+
padding: const EdgeInsets.only(bottom: 8),
131+
itemCount: items.length,
84132
itemBuilder: (context, index) {
85-
final entry = entries[index];
86-
return ListTile(
87-
dense: true,
88-
leading: Icon(
89-
entry.success
90-
? Icons.check_circle_outline
91-
: Icons.error_outline,
92-
size: 16,
93-
color:
94-
entry.success ? colorScheme.primary : colorScheme.error,
95-
),
96-
title: Row(
97-
children: [
98-
Flexible(
99-
child: Text(
100-
entry.action,
101-
overflow: TextOverflow.ellipsis,
102-
),
133+
final item = items[index];
134+
if (item is String) {
135+
return Padding(
136+
padding: const EdgeInsetsDirectional.fromSTEB(
137+
16, 10, 16, 4),
138+
child: Text(
139+
item.toUpperCase(),
140+
style: TextStyle(
141+
fontSize: 11,
142+
color: b.muted,
143+
letterSpacing: 0.44,
103144
),
104-
if (entry.stats != null) ...[
105-
const SizedBox(width: 10),
106-
ActionStatsLabel(stats: entry.stats!),
107-
],
108-
],
109-
),
110-
subtitle: entry.success ? null : Text(entry.detail ?? ''),
111-
trailing: Text(_formatTimestamp(entry.timestamp)),
145+
),
146+
);
147+
}
148+
return _row(
149+
context,
150+
item as ActionLogEntry,
151+
now,
152+
cal,
112153
);
113154
},
114155
),
@@ -120,6 +161,87 @@ class LogsPanel extends StatelessWidget {
120161
);
121162
}
122163

164+
Widget _row(
165+
BuildContext context,
166+
ActionLogEntry entry,
167+
DateTime now,
168+
AppCalendar cal,
169+
) {
170+
final b = context.branchi;
171+
final detail = entry.success ? null : entry.detail;
172+
return Padding(
173+
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
174+
child: Column(
175+
crossAxisAlignment: CrossAxisAlignment.start,
176+
children: [
177+
Row(
178+
children: [
179+
Icon(
180+
entry.success ? Icons.check : Icons.close,
181+
size: 14,
182+
color: entry.success ? b.add : b.del,
183+
),
184+
const SizedBox(width: 10),
185+
Flexible(
186+
child: Text(
187+
entry.action,
188+
maxLines: 1,
189+
overflow: TextOverflow.ellipsis,
190+
style: TextStyle(fontSize: 13, color: b.fg),
191+
),
192+
),
193+
if (entry.stats != null) ...[
194+
const SizedBox(width: 10),
195+
ActionStatsLabel(stats: entry.stats!),
196+
],
197+
const SizedBox(width: 8),
198+
Tooltip(
199+
message: cal.digits(_clock(entry.timestamp, seconds: true)),
200+
child: Text(
201+
'· ${_time(entry.timestamp, now, cal)}',
202+
style: TextStyle(fontSize: 12, color: b.muted),
203+
),
204+
),
205+
],
206+
),
207+
if (detail != null && detail.isNotEmpty)
208+
Padding(
209+
padding: const EdgeInsetsDirectional.only(start: 24, top: 2),
210+
child: Text(
211+
detail,
212+
style: TextStyle(fontSize: 12, color: b.del),
213+
),
214+
),
215+
],
216+
),
217+
);
218+
}
219+
220+
static String _dayLabel(DateTime day, DateTime now, AppCalendar cal) {
221+
final today = DateTime(now.year, now.month, now.day);
222+
final daysAgo = today.difference(day).inDays;
223+
if (daysAgo == 0) return translate('activity_today');
224+
if (daysAgo == 1) return translate('activity_yesterday');
225+
return cal.formatDate(day);
226+
}
227+
228+
/// "just now" / "4 min ago" within the last hour, else "14:32".
229+
static String _time(DateTime time, DateTime now, AppCalendar cal) {
230+
final diff = now.difference(time);
231+
if (diff.inMinutes < 1) return translate('activity_just_now');
232+
if (diff.inMinutes < 60) {
233+
return translate('report_ago_minutes')
234+
.replaceAll('{n}', cal.digits(diff.inMinutes));
235+
}
236+
return cal.digits(_clock(time));
237+
}
238+
239+
static String _clock(DateTime t, {bool seconds = false}) {
240+
String two(int v) => v.toString().padLeft(2, '0');
241+
final hm = '${two(t.hour)}:${two(t.minute)}';
242+
return seconds ? '$hm:${two(t.second)}' : hm;
243+
}
244+
123245
Future<void> _showClearMenu(BuildContext context, Offset position) async {
124246
final selection = await showMenu<String>(
125247
context: context,
@@ -137,10 +259,4 @@ class LogsPanel extends StatelessWidget {
137259
ActionLog.instance.clear();
138260
}
139261
}
140-
141-
String _formatTimestamp(DateTime timestamp) {
142-
String twoDigits(int value) => value.toString().padLeft(2, '0');
143-
return '${twoDigits(timestamp.hour)}:${twoDigits(timestamp.minute)}:'
144-
'${twoDigits(timestamp.second)}';
145-
}
146262
}

0 commit comments

Comments
 (0)