The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): a viewer learns the CAS revision from session.updated receipts
Teknium7e8d0c8e52af
diff --git a/apps/desktop/src/api/canonical-protocol.ts b/apps/desktop/src/api/canonical-protocol.tsindex 08cb1ee345d..d1d7ee9ded7 100644--- a/apps/desktop/src/api/canonical-protocol.ts+++ b/apps/desktop/src/api/canonical-protocol.ts@@ -465,6 +465,14 @@ export class CanonicalDesktopProtocol {// pending fanout is where a viewer learns the value its next mutation must present.if (event.type === 'session.info' && typeof payload.revision === 'number') { this.revisions.set(owner, payload.revision) }+ // N91: another viewer's committed mutation broadcasts its receipt as session.updated. Adopt+ // it monotonically (a replayed older receipt never rewinds) and settle superseded retained edits.+ if (event.type === 'session.updated' && typeof payload.revision === 'number' && (payload.session_id ?? sid) === sid &&+ payload.revision > (this.revisions.get(owner) ?? -1)) {+ this.revisions.set(owner, payload.revision)+ this.retireSupersededMutations({ session_id: sid, profile }, payload.revision)+ }+if (typeof payload.prompt_id === 'string') {if (event.type.endsWith('.settled')) { this.prompts.delete(canonicalSessionKey(payload.prompt_id, profile));diff --git a/apps/desktop/src/api/canonical-session-updated-revision.test.ts b/apps/desktop/src/api/canonical-session-updated-revision.test.tsnew file mode 100644index 00000000000..edfa39cef45--- /dev/null+++ b/apps/desktop/src/api/canonical-session-updated-revision.test.ts@@ -0,0 +1,20 @@+import { expect, test } from 'vitest'++import { CanonicalDesktopProtocol } from './canonical-protocol'++// N91: viewer B learns the CAS revision viewer A's rename committed from the session.updated+// receipt fanout, and a replayed older receipt never rewinds it.+test('a second viewer adopts the revision from session.updated, monotonically', () => {+ const a = new CanonicalDesktopProtocol()+ const b = new CanonicalDesktopProtocol()++ for (const v of [a, b]) { v.result('session.resume', { session_id: 's' }, { session_id: 's', revision: 7, execution_generation: 3 }) }+ const receipt = { session_id: 's', revision: 8, title: 'A' }+ a.result('session.title', a.prepare('session.title', { session_id: 's', title: 'A' }), receipt)+ b.event({ type: 'session.updated', session_id: 's', payload: receipt })+ expect(b.prepare('session.branch', { session_id: 's' }).expected_revision).toBe(8)+ b.event({ type: 'session.updated', session_id: 's', payload: { session_id: 's', revision: 6 } })+ expect(b.prepare('session.compress', { session_id: 's' }).expected_revision).toBe(8)+ b.event({ type: 'session.updated', session_id: 's', payload: { session_id: 'other', revision: 20 } })+ expect(b.prepare('session.archive', { session_id: 's', archived: true }).expected_revision).toBe(8)+})