Skip to content

Commit e55af33

Browse files
committed
Add file explorer and terminal buttons to the repo toolbar
Two icon buttons before Auto / Fetch / Pull / Push, shown in every section: one opens the repository in the OS file manager, the other opens a new terminal tab, same as the branch menu's "Open in terminal". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Faq4ehWkqnAGg5hto4znpj
1 parent ad5ea52 commit e55af33

2 files changed

Lines changed: 46 additions & 1 deletion

File tree

‎flutter/lib/welcome/welcome_screen.dart‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,8 @@ class _WelcomeScreenState extends State<WelcomeScreen> {
411411
onToggleTheme: AppTheme.toggle,
412412
isPinned: _isPinned,
413413
onTogglePin: _togglePin,
414+
repoPath: tab.path,
415+
onOpenTerminal: tab.path == null ? null : _openNewTerminal,
414416
),
415417
const UpdateBanner(),
416418
Expanded(

‎flutter/lib/widgets/app_top_bar.dart‎

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22

33
import '../l10n/app_locale.dart';
44
import '../models/repo_tab.dart';
5+
import '../repo/file_explorer.dart';
56
import '../repo/git_actions.dart';
67
import '../repo/repo_controller.dart';
78
import '../shortcuts/app_shortcuts.dart';
@@ -20,7 +21,7 @@ const double kRepoToolbarHeight = 46;
2021
/// 1. `Branchi [tab] [tab] [+] … ☾ 📌 ⚙` - the open tabs, with the
2122
/// app-wide buttons.
2223
/// 2. `[branch] [History | Changes N | Files | Report] …
23-
/// [● Auto 1:42 ▾] Fetch Pull [Push]` - the selected tab's
24+
/// 📁 >_ [● Auto 1:42 ▾] Fetch Pull [Push]` - the selected tab's
2425
/// repository toolbar; only when that tab has a repository open
2526
/// ([controller] non-null).
2627
///
@@ -39,6 +40,8 @@ class AppTopBar extends StatelessWidget {
3940
required this.onToggleTheme,
4041
required this.isPinned,
4142
required this.onTogglePin,
43+
this.repoPath,
44+
this.onOpenTerminal,
4245
});
4346

4447
final List<RepoTab> tabs;
@@ -56,6 +59,13 @@ class AppTopBar extends StatelessWidget {
5659
final bool isPinned;
5760
final VoidCallback onTogglePin;
5861

62+
/// The active tab's repository folder, opened by the file explorer button.
63+
final String? repoPath;
64+
65+
/// Opens a new terminal in the repository (same as the branch menu's
66+
/// "Open in terminal").
67+
final VoidCallback? onOpenTerminal;
68+
5969
@override
6070
Widget build(BuildContext context) {
6171
final controller = this.controller;
@@ -130,6 +140,14 @@ class AppTopBar extends StatelessWidget {
130140
);
131141
}
132142

143+
Future<void> _openFileExplorer(BuildContext context, String path) async {
144+
final messenger = ScaffoldMessenger.maybeOf(context);
145+
final error = await openInFileExplorer(path);
146+
if (error != null) {
147+
messenger?.showSnackBar(SnackBar(content: Text(error)));
148+
}
149+
}
150+
133151
Widget _buildRepoToolbar(BuildContext context, RepoController controller) {
134152
final b = context.branchi;
135153
return Container(
@@ -150,6 +168,31 @@ class AppTopBar extends StatelessWidget {
150168
],
151169
),
152170
),
171+
if (repoPath != null) ...[
172+
_HoverBox(
173+
tooltip: translate('bs_open_explorer'),
174+
onTap: () => _openFileExplorer(context, repoPath!),
175+
padding: const EdgeInsets.all(6),
176+
child: Icon(Icons.folder_open_outlined, size: 16, color: b.muted),
177+
),
178+
const SizedBox(width: 4),
179+
],
180+
if (onOpenTerminal != null) ...[
181+
_HoverBox(
182+
tooltip: translate('bs_open_terminal'),
183+
onTap: onOpenTerminal,
184+
padding: const EdgeInsets.all(6),
185+
child: Icon(Icons.terminal, size: 16, color: b.muted),
186+
),
187+
const SizedBox(width: 4),
188+
],
189+
if (repoPath != null || onOpenTerminal != null)
190+
Container(
191+
width: 1,
192+
height: 18,
193+
margin: const EdgeInsets.symmetric(horizontal: 8),
194+
color: b.line,
195+
),
153196
AutoPullButton(
154197
watcher: controller.watcher,
155198
isBusy: controller.isPulling,

0 commit comments

Comments
 (0)