feat(app): mouse back/forward buttons walk the tab history

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-10-26 04:11:27 +01:00
1 parent 141e1a20d0
commit a8559fd467
3 files changed
+104 -67

No files matched your search

+77 -64
View File
@@ -1,4 +1,6 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'
show kBackMouseButton, kForwardMouseButton;
import 'package:flutter/material.dart';
import '../state/app_state.dart';
@@ -65,73 +67,84 @@ class _ShellState extends State<Shell> {
for (final e in actions.entries)
...Map.fromEntries(activators(app.keymap.of(e.key), e.value)),
},
child: Focus(
autofocus: true,
child: LayoutBuilder(
builder: (context, box) {
final narrow = box.maxWidth < 760;
final sidebar = _Sidebar(
onNavigate: () {
if (narrow) _scaffold.currentState?.closeDrawer();
},
);
return Scaffold(
key: _scaffold,
drawer: narrow
? Drawer(backgroundColor: colors.surface, child: sidebar)
: null,
body: Row(
children: [
if (!narrow)
AnimatedContainer(
duration: const Duration(milliseconds: 180),
curve: Curves.easeOutCubic,
width: _sidebar ? 248 : 0,
child: ClipRect(
child: OverflowBox(
alignment: Alignment.topLeft,
minWidth: 248,
maxWidth: 248,
child: sidebar,
),
),
),
Expanded(
child: Column(
children: [
_TopBar(
narrow: narrow,
onMenu: () => narrow
? _scaffold.currentState?.openDrawer()
: setState(() => _sidebar = !_sidebar),
),
if (!narrow) const TabStrip(),
Expanded(
child: KeyedSubtree(
key: ValueKey((app.tab.uid, route, app.generation)),
child: switch (route) {
JournalsRoute() => const JournalsView(),
TimelineRoute() => const GraphView(
mode: GraphMode.timeline,
),
GraphRoute() => GraphView(
mode: route.mode,
focusId: route.focusId,
),
AllPagesRoute() => const AllPagesView(),
SettingsRoute() => const SettingsView(),
TagRoute() => TagView(name: route.name),
PageTarget() => PageScreen(target: route),
},
// The mouse's back/forward side buttons work like the arrows, as in a browser.
child: Listener(
onPointerDown: (e) {
if (e.buttons & kBackMouseButton != 0) app.back();
if (e.buttons & kForwardMouseButton != 0) app.forward();
},
child: Focus(
autofocus: true,
child: LayoutBuilder(
builder: (context, box) {
final narrow = box.maxWidth < 760;
final sidebar = _Sidebar(
onNavigate: () {
if (narrow) _scaffold.currentState?.closeDrawer();
},
);
return Scaffold(
key: _scaffold,
drawer: narrow
? Drawer(backgroundColor: colors.surface, child: sidebar)
: null,
body: Row(
children: [
if (!narrow)
AnimatedContainer(
duration: const Duration(milliseconds: 180),
curve: Curves.easeOutCubic,
width: _sidebar ? 248 : 0,
child: ClipRect(
child: OverflowBox(
alignment: Alignment.topLeft,
minWidth: 248,
maxWidth: 248,
child: sidebar,
),
),
],
),
Expanded(
child: Column(
children: [
_TopBar(
narrow: narrow,
onMenu: () => narrow
? _scaffold.currentState?.openDrawer()
: setState(() => _sidebar = !_sidebar),
),
if (!narrow) const TabStrip(),
Expanded(
child: KeyedSubtree(
key: ValueKey((
app.tab.uid,
route,
app.generation,
)),
child: switch (route) {
JournalsRoute() => const JournalsView(),
TimelineRoute() => const GraphView(
mode: GraphMode.timeline,
),
GraphRoute() => GraphView(
mode: route.mode,
focusId: route.focusId,
),
AllPagesRoute() => const AllPagesView(),
SettingsRoute() => const SettingsView(),
TagRoute() => TagView(name: route.name),
PageTarget() => PageScreen(target: route),
},
),
),
],
),
),
),
],
),
);
},
],
),
);
},
),
),
),
);
+20
View File
@@ -177,6 +177,26 @@ void main() {
expect(app.route, isA<JournalsRoute>());
});
testWidgets('mouse back/forward buttons walk the history', (tester) async {
final app = await pump(tester, demo());
app.go(const AllPagesRoute());
await settle(tester);
Future<void> press(int button) async {
final mouse = await tester.createGesture(
kind: PointerDeviceKind.mouse,
buttons: button,
);
await mouse.down(const Offset(800, 500));
await mouse.up();
await settle(tester);
}
await press(kBackMouseButton);
expect(app.route, isA<JournalsRoute>());
await press(kForwardMouseButton);
expect(app.route, isA<AllPagesRoute>());
});
testWidgets('strip shows titles; middle-click closes, plus opens', (
tester,
) async {
+7 -3
View File
@@ -149,6 +149,9 @@ Both are plain names with no page, shown as one row of pills under the title.
same-name type or tag; "Rename" there never renames the hub itself.
- In the graph every tag is a virtual node drawn as a hollow accent ring and linked to its
pages with a separate edge kind (TAGGED); tapping one opens its tag view.
A hub's implicit tag (or a tag named like a hub) has no ring of its own: the hub node
stands for it.
- The mouse's back/forward side buttons move through the tab's history, like the arrows.
## Hubs, namespaces and cleanup
- **Hub** (folder icon): a page kind, not a note: no outline, a title, a short description
@@ -170,9 +173,10 @@ Both are plain names with no page, shown as one row of pills under the title.
note that keeps the original outline; title clashes are shown inline) and "Add to hub…".
- Every page's `⋯` menu (notes and hubs) ends with "Delete page…": the same confirmation as
All pages; tabs showing it step back (or fall back to Journals) and recents drop it.
- All pages ▸ "Clean up": dialog listing legacy Logseq pages (`contents`, `hls__...`, pages
with `type:: system`, ...) with checkboxes; "Delete (n)" removes only the checked ones
and their blocks.
- All pages ▸ "Clean up": dialog listing empty pages (no text in any block, not a hub, no
type, tags or description; all preselected) and legacy Logseq pages (`contents`,
`hls__...`, pages with `type:: system`, ...) with checkboxes and "Select all/none";
"Delete (n)" removes only the checked ones and their blocks.
## Page sidebar and All pages
- The sidebar icon next to a note's `⋯` menu toggles a right sidebar (collapsed by default,