fix(app): read views after queued writes, reload on write failure

- Page and journal views read through the write queue after the previous
  view's pending saves, so they never load stale text.
- A failed write reloads the current view and shows a message instead of
  leaving blocks on temporary ids; inserts also trigger reconciliation.
- Completion replaces the query range, not up to the caret, and closes
  when the caret moves away.
- Renaming a page reloads it so rewritten links are not overwritten.
- Dropping below an expanded parent lands as its first child, where the
  indicator is drawn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-10-21 04:08:36 +02:00
1 parent fce7526fcf
commit 5e25db3e24
9 files changed
+102 -29

No files matched your search

+4 -3
View File
@@ -9,7 +9,7 @@ class WriteQueue {
WriteQueue({this.onError});
/// Called with any error a task throws; the task's own future also completes with it.
final void Function(Object error, StackTrace stack)? onError;
void Function(Object error, StackTrace stack)? onError;
final _tasks = Queue<Future<void> Function()>();
bool _running = false;
@@ -23,13 +23,14 @@ class WriteQueue {
return (_idle ??= Completer<void>()).future;
}
Future<T> run<T>(Future<T> Function() task) {
/// Queues `task`. Reads pass `report: false` so their errors do not reach [onError].
Future<T> run<T>(Future<T> Function() task, {bool report = true}) {
final done = Completer<T>();
_tasks.add(() async {
try {
done.complete(await task());
} catch (e, st) {
onError?.call(e, st);
if (report) onError?.call(e, st);
done.completeError(e, st);
}
});