@@ -8259,6 +8259,123 @@ it("edits the last message from an untouched automatic tag and restores that tag
82598259 expect ( h . input ( ) ) . not . toHaveAccessibleName ( "Edit message" ) ;
82608260} ) ;
82618261
8262+ it ( "tags the agent last tagged in a Solo chat whenever an empty composer is shown" , ( ) => {
8263+ const viewer = "e" . repeat ( 64 ) ;
8264+ const h = mount ( { } , undefined , viewer ) ;
8265+ h . setLibrary ( [ first , second ] ) ;
8266+ h . setProfiles (
8267+ new Map ( [
8268+ [ first . pubkey , { name : "Ada" , isAgent : true } ] ,
8269+ [ second . pubkey , { name : "Bea" , isAgent : true } ] ,
8270+ ] ) ,
8271+ ) ;
8272+ h . retarget ( {
8273+ ownSoloConversation : true ,
8274+ requireMention : true ,
8275+ session : {
8276+ ...h . session ,
8277+ channels : { ...h . session . channels , list : ( ) => soloList } ,
8278+ } as unknown as RelaySession ,
8279+ } ) ;
8280+ expect ( h . input ( ) ) . toHaveValue ( "" ) ;
8281+ h . setRows ( [
8282+ editableMessage ( {
8283+ id : "1" . repeat ( 64 ) ,
8284+ authorId : viewer ,
8285+ mentions : [ first . pubkey ] ,
8286+ } ) ,
8287+ editableMessage ( {
8288+ id : "2" . repeat ( 64 ) ,
8289+ authorId : viewer ,
8290+ mentions : [ second . pubkey ] ,
8291+ } ) ,
8292+ // Neither an agent's message nor a thread reply chooses the agent.
8293+ editableMessage ( {
8294+ id : "3" . repeat ( 64 ) ,
8295+ authorId : second . pubkey ,
8296+ mentions : [ first . pubkey ] ,
8297+ } ) ,
8298+ editableMessage ( {
8299+ id : "4" . repeat ( 64 ) ,
8300+ authorId : viewer ,
8301+ mentions : [ first . pubkey ] ,
8302+ threadRootId : "1" . repeat ( 64 ) ,
8303+ } ) ,
8304+ ] ) ;
8305+ expect ( h . input ( ) ) . toHaveValue ( "@Bea " ) ;
8306+ expect ( h . commands ( ) . recipients ) . toEqual ( [
8307+ { pubkey : second . pubkey , name : "Bea" } ,
8308+ ] ) ;
8309+ // A removed tag stays removed while the chat is shown.
8310+ act ( ( ) => h . input ( ) . removeRecipient ( second . pubkey ) ) ;
8311+ h . fill ( "" ) ;
8312+ expect ( h . input ( ) ) . toHaveValue ( "" ) ;
8313+ // Coming back to the chat tags the agent again, whether the conversation or
8314+ // its retained tab is shown again.
8315+ h . present ( false ) ;
8316+ h . present ( true ) ;
8317+ expect ( h . input ( ) ) . toHaveValue ( "@Bea " ) ;
8318+ act ( ( ) => h . input ( ) . removeRecipient ( second . pubkey ) ) ;
8319+ h . fill ( "" ) ;
8320+ h . retarget ( { shown : false } ) ;
8321+ expect ( h . input ( ) ) . toHaveValue ( "" ) ;
8322+ h . retarget ( { shown : true } ) ;
8323+ expect ( h . input ( ) ) . toHaveValue ( "@Bea " ) ;
8324+ // Text without a tag is left as written.
8325+ act ( ( ) => h . input ( ) . removeRecipient ( second . pubkey ) ) ;
8326+ h . fill ( "for people" ) ;
8327+ h . present ( false ) ;
8328+ h . present ( true ) ;
8329+ expect ( h . input ( ) ) . toHaveValue ( "for people" ) ;
8330+ // Off with remembered agents.
8331+ h . fill ( "" ) ;
8332+ setRememberAgentsPreference ( false ) ;
8333+ h . present ( false ) ;
8334+ h . present ( true ) ;
8335+ expect ( h . input ( ) ) . toHaveValue ( "" ) ;
8336+ setRememberAgentsPreference ( true ) ;
8337+ } ) ;
8338+
8339+ it ( "waits for complete agent choices before tagging the agent last tagged in a Solo chat" , ( ) => {
8340+ const viewer = "e" . repeat ( 64 ) ;
8341+ // The local agent is usable before the library holding the latest agent loads.
8342+ const control = localAgentsFixture ( [
8343+ { ...localAgent , pubkey : first . pubkey , name : "Ada" } ,
8344+ ] ) ;
8345+ const h = mount (
8346+ { scope : `https://relay.example.test:${ "d" . repeat ( 64 ) } ` } ,
8347+ control ,
8348+ viewer ,
8349+ ) ;
8350+ h . setLibrary ( [ ] , "loading" ) ;
8351+ h . retarget ( {
8352+ ownSoloConversation : true ,
8353+ requireMention : true ,
8354+ session : {
8355+ ...h . session ,
8356+ channels : { ...h . session . channels , list : ( ) => soloList } ,
8357+ } as unknown as RelaySession ,
8358+ } ) ;
8359+ h . setRows ( [
8360+ editableMessage ( {
8361+ id : "1" . repeat ( 64 ) ,
8362+ authorId : viewer ,
8363+ mentions : [ first . pubkey ] ,
8364+ } ) ,
8365+ editableMessage ( {
8366+ id : "2" . repeat ( 64 ) ,
8367+ authorId : viewer ,
8368+ mentions : [ second . pubkey ] ,
8369+ } ) ,
8370+ ] ) ;
8371+ expect ( h . input ( ) ) . toHaveValue ( "" ) ;
8372+ h . setLibrary ( [ { pubkey : second . pubkey , name : "Bea" } ] ) ;
8373+ expect ( h . input ( ) ) . toHaveValue ( "@Bea " ) ;
8374+ expect ( h . commands ( ) . recipients ) . toEqual ( [
8375+ { pubkey : second . pubkey , name : "Bea" } ,
8376+ ] ) ;
8377+ } ) ;
8378+
82628379it ( "keeps remembered agents while typing during upload without taking focus when publication finishes" , async ( ) => {
82638380 const key = keypair ( ) ;
82648381 const agent = { pubkey : key . pubkey , name : "Honey" } ;
0 commit comments