AGENTS.md: a background result knows what it was for

The rule F1's sweep applied across Notes, the player, document detail and the
readers: a buffer carries its record's id, a load into a selection is held
rather than detached, and work that can't be canceled checks a generation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Greg ShuflinandClaude Opus 5.5 committed 2026-10-04 04:44:34 -07:00
1 parent d47c21cf86
commit f8fad97f81
1 file changed
+22
+22
View File
@@ -108,6 +108,28 @@ finished, whatever else it does.
executor. Any lib function that reaches the network should be `async` rather
than taking a `tokio::runtime::Handle` to block on. This is not per-agent:
it holds for every agent that opens something living on another node.
- **A result knows what it was for.** Anything a screen loads, saves or plays
in the background can finish after the user has moved on — another note
selected, the document closed, a different track started — and it must not
land on whatever is selected *now*.
- **A buffer carries the id of the record it belongs to.** A save takes its
destination and its text from the same value, never the destination from a
separate "selected" field. A stale apply can then at worst show the wrong
text for a moment; it can never write one record's text into another, which
then syncs everywhere. That is the bug Notes' `OpenNote` closed: a slow load
of note A installed A's body under B's title, and the next keystroke
autosaved it into B.
- **A load applied into a selection is held, not detached.** Keep its `Task`
in a field (`_load_task`): assigning the next one drops the old, and gpui
cancels a dropped `Task`, so the latest selection wins by construction
rather than by a "still selected?" check each async step has to remember.
Compose gets the same from `LaunchedEffect(key)`, which cancels the previous
coroutine when the key changes.
- Where the work can't be canceled because it has already handed something
off, check a generation at the point it applies — `player_controls`'
`play_seq`, compared under the audio lock. A result applied by id looks its
target up by that id (`detail_view`'s `detail_for`) rather than writing
into whatever is open.
# Build Commands