@@ -32,42 +32,43 @@ function savedAudiences() {
3232
3333test ( "conversation scopes isolate identities, channels, and threads" , async ( ) => {
3434 const store = await loadStore ( ) ;
35- const channelA = store . getPersistentAgentAudienceScope ( {
36- ownerPubkey : ownerA ,
37- channelId : "channel-a" ,
38- } ) ;
39- const channelB = store . getPersistentAgentAudienceScope ( {
40- ownerPubkey : ownerA ,
41- channelId : "channel-b" ,
42- } ) ;
43- const threadA1 = store . getPersistentAgentAudienceScope ( {
44- ownerPubkey : ownerA ,
45- channelId : "channel-a" ,
46- threadRootId : "root-1" ,
47- } ) ;
48- const threadA2 = store . getPersistentAgentAudienceScope ( {
49- ownerPubkey : ownerA ,
50- channelId : "channel-a" ,
51- threadRootId : "root-2" ,
52- } ) ;
53- const otherIdentity = store . getPersistentAgentAudienceScope ( {
54- ownerPubkey : ownerB ,
55- channelId : "channel-a" ,
56- } ) ;
57-
58- for ( const scope of [ channelA , channelB , threadA1 , threadA2 , otherIdentity ] ) {
35+ const scopes = [
36+ store . getPersistentAgentAudienceScope ( {
37+ ownerPubkey : ownerA ,
38+ channelId : "channel-a" ,
39+ threadRootId : "root-1" ,
40+ } ) ,
41+ store . getPersistentAgentAudienceScope ( {
42+ ownerPubkey : ownerA ,
43+ channelId : "channel-a" ,
44+ threadRootId : "root-2" ,
45+ } ) ,
46+ store . getPersistentAgentAudienceScope ( {
47+ ownerPubkey : ownerA ,
48+ channelId : "channel-b" ,
49+ threadRootId : "root-1" ,
50+ } ) ,
51+ store . getPersistentAgentAudienceScope ( {
52+ ownerPubkey : ownerB ,
53+ channelId : "channel-a" ,
54+ threadRootId : "root-1" ,
55+ } ) ,
56+ ] ;
57+
58+ for ( const scope of scopes ) {
5959 assert . ok ( scope ) ;
6060 store . setPersistentAgentAudience ( scope , [ agentA ] ) ;
6161 }
6262
63- assert . equal ( new Set ( Object . keys ( savedAudiences ( ) ) ) . size , 5 ) ;
63+ assert . equal ( new Set ( Object . keys ( savedAudiences ( ) ) ) . size , 4 ) ;
6464} ) ;
6565
6666test ( "successful fast send promotes without a persisted draft key" , async ( ) => {
6767 const store = await loadStore ( 1 ) ;
6868 const scope = store . getPersistentAgentAudienceScope ( {
6969 ownerPubkey : ownerA ,
7070 channelId : "channel-a" ,
71+ threadRootId : "root" ,
7172 } ) ;
7273 store . setPersistentAgentAudienceEnabled ( true ) ;
7374
@@ -206,42 +207,26 @@ test("new recipients retain explicit mention order", async () => {
206207 assert . deepEqual ( savedAudiences ( ) , { [ scope ] : [ agentB , agentA ] } ) ;
207208} ) ;
208209
209- test ( "first new-message send resolves its destination after capturing generation " , async ( ) => {
210+ test ( "timeline scope is intentionally unsupported " , async ( ) => {
210211 const store = await loadStore ( 7 ) ;
211- const capturedGeneration = store . getPersistentAgentAudienceGeneration ( ) ;
212- store . setPersistentAgentAudienceEnabled ( true ) ;
213- const scope = store . getPersistentAgentAudienceScope ( {
214- ownerPubkey : ownerA ,
215- channelId : "resolved-dm" ,
216- } ) ;
217-
218- store . promotePersistentAgentAudience ( {
219- expectedGeneration : capturedGeneration ,
220- expectedRevision : null ,
221- scope,
222- explicitAgentPubkeys : [ agentA ] ,
223- } ) ;
224-
225- assert . deepEqual ( savedAudiences ( ) , { [ scope ] : [ agentA ] } ) ;
212+ assert . equal (
213+ store . getPersistentAgentAudienceScope ( {
214+ ownerPubkey : ownerA ,
215+ channelId : "channel-a" ,
216+ } ) ,
217+ null ,
218+ ) ;
226219} ) ;
227220
228- test ( "disable during new-message destination preparation invalidates promotion" , async ( ) => {
229- const store = await loadStore ( 8 ) ;
230- store . setPersistentAgentAudienceEnabled ( true ) ;
231- const capturedGeneration = store . getPersistentAgentAudienceGeneration ( ) ;
232- store . setPersistentAgentAudienceEnabled ( false ) ;
221+ test ( "thread root audience initializes once and explicit clear wins on reopen" , async ( ) => {
222+ const store = await loadStore ( 10 ) ;
223+ const scope = `${ ownerA } :channel-a:thread:root` ;
233224 store . setPersistentAgentAudienceEnabled ( true ) ;
234- const scope = store . getPersistentAgentAudienceScope ( {
235- ownerPubkey : ownerA ,
236- channelId : "resolved-dm" ,
237- } ) ;
238225
239- store . promotePersistentAgentAudience ( {
240- expectedGeneration : capturedGeneration ,
241- expectedRevision : null ,
242- scope,
243- explicitAgentPubkeys : [ agentA ] ,
244- } ) ;
226+ store . initializePersistentAgentAudience ( scope , [ agentB , agentA ] ) ;
227+ assert . deepEqual ( savedAudiences ( ) , { [ scope ] : [ agentB , agentA ] } ) ;
245228
246- assert . deepEqual ( savedAudiences ( ) , { } ) ;
229+ store . setPersistentAgentAudience ( scope , [ ] ) ;
230+ store . initializePersistentAgentAudience ( scope , [ agentA ] ) ;
231+ assert . deepEqual ( savedAudiences ( ) , { [ scope ] : [ ] } ) ;
247232} ) ;
0 commit comments