mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 23:36:20 +00:00
feat(graph): graph view with network, local, synapse, cluster and namespace modes
- synapse-ffi: graph_data() returns the whole page-level graph (links, tags, property refs, block refs/embeds per page, unlinked mentions, decayed synapses) as parallel arrays with degree, backlinks, Louvain clusters and primary tags; cached by op seq, synapse state and hour. - synapse-ffi: ForceLayout, a Barnes-Hut force layout stepped from Dart on a Rust worker thread (pin/unpin for dragging, reheat). - app: Graph view with a mode selector (Network, Local, Synapses, Clusters, Namespaces, Timeline), filters (title, tag, date range, min links, orphans, journals, mentions), pan/zoom, node drag, hover highlighting, activation pulse, cluster hulls, radial namespace/tag tree, and a local graph panel on every page. Edges render as one vertex mesh, nodes in colour/size batches, culled to the viewport. - Tests: Rust extraction/mentions/cache/clusters/layout; widget tests for mode switching, filters and layout restarts; a real-app integration smoke test with frame timings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6a4a76670b
commit
e43452f5af
29 files changed
+6177
-76
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../backend/graph_backend.dart';
|
||||
import '../graph/network_canvas.dart';
|
||||
import 'write_queue.dart';
|
||||
|
||||
sealed class AppRoute {
|
||||
@@ -19,6 +20,26 @@ class AllPagesRoute extends AppRoute {
|
||||
const AllPagesRoute();
|
||||
}
|
||||
|
||||
enum GraphMode {
|
||||
network('Network', Icons.hub_outlined),
|
||||
local('Local', Icons.adjust_rounded),
|
||||
brain('Synapses', Icons.bolt_outlined),
|
||||
clusters('Clusters', Icons.bubble_chart_outlined),
|
||||
tree('Namespaces', Icons.account_tree_outlined),
|
||||
timeline('Timeline', Icons.timeline_rounded);
|
||||
|
||||
const GraphMode(this.label, this.icon);
|
||||
final String label;
|
||||
final IconData icon;
|
||||
}
|
||||
|
||||
/// The graph view in a given mode, optionally focused on a page.
|
||||
class GraphRoute extends AppRoute {
|
||||
const GraphRoute(this.mode, {this.focusId});
|
||||
final GraphMode mode;
|
||||
final String? focusId;
|
||||
}
|
||||
|
||||
/// A page, by id or (for links that may not exist yet) by title.
|
||||
class PageTarget extends AppRoute {
|
||||
const PageTarget({this.id, this.title}) : assert(id != null || title != null);
|
||||
@@ -49,6 +70,9 @@ class AppState extends ChangeNotifier {
|
||||
ThemeMode themeMode = ThemeMode.system;
|
||||
final List<PageBrief> recent = [];
|
||||
|
||||
/// Node positions shared by the graph views (stable layouts across modes and filters).
|
||||
final graphPositions = PositionCache();
|
||||
|
||||
/// Last page shown (for synapse reinforcement on navigation).
|
||||
String? _lastPageId;
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@ class WriteQueue {
|
||||
/// Called with any error a task throws; the task's own future also completes with it.
|
||||
void Function(Object error, StackTrace stack)? onError;
|
||||
|
||||
/// Bumped after each successful write (reads pass `report: false` and do not count).
|
||||
final revision = ValueNotifier<int>(0);
|
||||
|
||||
final _tasks = Queue<Future<void> Function()>();
|
||||
bool _running = false;
|
||||
Completer<void>? _idle;
|
||||
@@ -28,7 +31,9 @@ class WriteQueue {
|
||||
final done = Completer<T>();
|
||||
_tasks.add(() async {
|
||||
try {
|
||||
done.complete(await task());
|
||||
final out = await task();
|
||||
if (report) revision.value++;
|
||||
done.complete(out);
|
||||
} catch (e, st) {
|
||||
if (report) onError?.call(e, st);
|
||||
done.completeError(e, st);
|
||||
|
||||
Reference in new issue
Block a user