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

+24 -2
View File
@@ -78,7 +78,6 @@ void main() {
final tag = detectCompletion('x #se', 5)!;
final v = applyCompletion(
'x #se',
5,
tag,
const CompletionItem('Second Brain', 'Second Brain'),
);
@@ -87,7 +86,6 @@ void main() {
expect(
applyCompletion(
'[[Ru]]',
4,
page,
const CompletionItem('Rust', 'Rust'),
).text,
@@ -95,6 +93,16 @@ void main() {
);
});
test('replaces only the query even if the caret moved', () {
final q = detectCompletion('[[foo]]', 5)!;
final v = applyCompletion(
'[[foo]]',
q,
const CompletionItem('Foo', 'Foo'),
);
expect(v.text, '[[Foo]]');
});
test('auto-pairs brackets', () {
final v = autoPair(
const TextEditingValue(
@@ -152,6 +160,20 @@ void main() {
});
});
test('a failed write makes the app reload its view', () async {
final app = AppState(MemoryBackend());
final gen = app.generation;
await app.queue
.run<void>(() async => throw StateError('boom'))
.catchError((_) {});
expect(app.generation, gen + 1);
expect(app.writeError, contains('boom'));
await app.queue
.run<void>(() async => throw StateError('read'), report: false)
.catchError((_) {});
expect(app.generation, gen + 1);
});
test(
'WriteQueue runs tasks in order even when they finish out of order',
() async {