fix: events in the 500 ms focus window never touch another agent's draft or queue

Co-Authored-By: Ovis Fast (Claude) <[email protected]>
This commit is contained in:
FactorandOvis Fast committed 2026-11-19 12:09:09 +01:00
1 parent d852c406dd
commit dd95bf2c68
3 files changed
+63

No files matched your search

+17
View File
@@ -478,3 +478,20 @@ export function overLimit(text) {
export function canAutoSend(ready, key) {
return ready instanceof Set && ready.has(key);
}
/**
* Is the composer still talking to the agent whose draft the field shows?
*
* The field shows the draft of `before` (the agent the composer was synced to
* when an event began). After a sync the focus may have moved: then the event
* belongs to an agent that is not the target any more, and it must not touch
* the draft or the queue of the new one.
*
* @param {{before:string, after:string, target:string}} keys - `before`: the
* key the composer had before the sync; `after`: the key it has now;
* `target`: the key of the agent under the focus ("" for none)
* @returns {boolean}
*/
export function stillSameAgent({ before, after, target }) {
return before !== "" && before === after && before === target;
}