feat: a browser page in the right sidebar, and icon tabs

- the right sidebar gains a Browser tab: address bar (back/forward, URL,
  go, stop/reload, open in the system browser), history, quick links for
  localhost:3000/5173/8080, and an embedded WebView on Android/iOS with an
  error bar and retry; desktop shows a mobile-only hint
- Android allows cleartext traffic so local dev servers over HTTP load in
  the WebView
- the tab row is now icons with tooltips (Files, Project knowledge,
  Terminal, Browser), so four tabs fit a phone without truncated labels;
  the tabs are kept alive offstage, so switching away and back keeps the
  browser page and terminal state
- webview_flutter 4.14.1; version 0.6.7+607; tests cover the tab icons and
  the desktop fallback
This commit is contained in:
blumia committed 2026-12-04 02:02:19 +08:00
1 parent fedc4dd79c
commit ce944751b4
10 files changed
+563 -24

No files matched your search

+43 -7
View File
@@ -12,6 +12,7 @@ import '../api/models.dart';
import '../api/transport.dart';
import '../state.dart';
import '../widgets/markdown_view.dart';
import 'browser_panel.dart';
import 'knowledge_panel.dart';
import 'terminal_panel.dart';
import '../l10n.dart';
@@ -110,6 +111,10 @@ class _FilesPanelState extends State<FilesPanel> {
int _tab = 0;
/// Tabs built at least once. Kept alive (offstage) so the browser, terminal
/// and knowledge pages keep their state when another tab is shown.
final Set<int> _built = {0};
@override
void initState() {
super.initState();
@@ -426,7 +431,20 @@ class _FilesPanelState extends State<FilesPanel> {
children: [
_tabs(theme),
const Divider(height: 1),
Expanded(child: _body(theme)),
Expanded(
child: Stack(
children: [
for (var i = 0; i < 4; i++)
if (_built.contains(i))
Positioned.fill(
child: Offstage(
offstage: _tab != i,
child: _tabBody(i, theme),
),
),
],
),
),
],
),
),
@@ -436,7 +454,14 @@ class _FilesPanelState extends State<FilesPanel> {
/// 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 = ['Files', 'Project knowledge', 'Terminal'];
// Icons only: four labels no longer fit a phone's panel width. The
// tooltips keep them identifiable.
const tabs = [
(Icons.folder_outlined, 'Files'),
(Icons.menu_book_outlined, 'Project knowledge'),
(Icons.terminal, 'Terminal'),
(Icons.public, 'Browser'),
];
return Padding(
padding: const EdgeInsets.fromLTRB(12, 6, 2, 6),
child: Row(
@@ -449,11 +474,20 @@ class _FilesPanelState extends State<FilesPanel> {
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
segments: [
for (var i = 0; i < labels.length; i++)
ButtonSegment(value: i, label: AppText(labels[i])),
for (var i = 0; i < tabs.length; i++)
ButtonSegment(
value: i,
icon: Tooltip(
message: tr(tabs[i].$2),
child: Icon(tabs[i].$1, size: 19),
),
),
],
selected: {_tab},
onSelectionChanged: (v) => setState(() => _tab = v.first),
onSelectionChanged: (v) => setState(() {
_tab = v.first;
_built.add(v.first);
}),
),
),
IconButton(
@@ -466,15 +500,17 @@ class _FilesPanelState extends State<FilesPanel> {
);
}
Widget _body(ThemeData theme) {
Widget _tabBody(int index, ThemeData theme) {
if (_root.isEmpty) {
return const Center(child: AppText('This session has no directory'));
}
switch (_tab) {
switch (index) {
case 1:
return KnowledgePanel(app: widget.app, directory: _root);
case 2:
return TerminalPanel(app: widget.app, directory: _root);
case 3:
return const BrowserPanel();
default:
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,