@@ -52,6 +52,52 @@ describe("AppSidebar agent chip", () => {
5252 expect ( request ) . toHaveBeenCalledWith ( "agent.identity.get" , { agentId : "main" } ) ;
5353 } ) ;
5454
55+ it ( "keeps the configured roster label when identity hydration returns a fallback" , async ( ) => {
56+ const request = vi . fn ( async ( _method : string , params : { agentId : string } ) =>
57+ params . agentId === "main"
58+ ? { agentId : "main" , name : "Workspace Molty" , avatar : "🦞" }
59+ : { agentId : "rust-claw" , name : "Assistant" , avatar : "🦀" } ,
60+ ) ;
61+ const gatewayHarness = createGatewayHarness ( { request } as unknown as GatewayBrowserClient ) ;
62+ const agentIdentity = createAgentIdentityCapability ( gatewayHarness . gateway ) ;
63+ const { sidebar } = await mountSidebar (
64+ gatewayHarness . gateway ,
65+ createSessions ( "main" , [ "agent:main:main" ] ) ,
66+ "panel" ,
67+ {
68+ defaultId : "main" ,
69+ mainKey : "main" ,
70+ scope : "per-sender" ,
71+ agents : [ { id : "main" } , { id : "rust-claw" , name : "rust-claw" } ] ,
72+ } ,
73+ [ ] ,
74+ agentIdentity ,
75+ ) ;
76+
77+ sidebar . connected = true ;
78+ await vi . waitFor ( ( ) => {
79+ expect ( sidebar . querySelector ( ".sidebar-agent-card__name" ) ?. textContent ?. trim ( ) ) . toBe (
80+ "Workspace Molty" ,
81+ ) ;
82+ } ) ;
83+ sidebar . querySelector < HTMLButtonElement > ( ".sidebar-agent-card__main" ) ?. click ( ) ;
84+ await vi . waitFor ( ( ) => {
85+ expect ( request ) . toHaveBeenCalledWith ( "agent.identity.get" , { agentId : "rust-claw" } ) ;
86+ const labels = [
87+ ...sidebar . querySelectorAll ( ".sidebar-agent-menu .agent-select__option-label" ) ,
88+ ] . map ( ( element ) => element . textContent ?. trim ( ) ) ;
89+ expect ( labels ) . toEqual ( [ "Workspace Molty" , "rust-claw" ] ) ;
90+ } ) ;
91+ await vi . waitFor ( ( ) => {
92+ const rustRow = [
93+ ...sidebar . querySelectorAll < HTMLElement > ( ".sidebar-agent-menu__agent-switch" ) ,
94+ ] . find ( ( row ) => row . textContent ?. includes ( "rust-claw" ) ) ;
95+ expect (
96+ rustRow ?. querySelector ( ".agent-select__avatar--text" ) ?. getAttribute ( "data-avatar" ) ,
97+ ) . toBe ( "🦀" ) ;
98+ } ) ;
99+ } ) ;
100+
55101 it ( "hydrates agents added while the switcher remains open" , async ( ) => {
56102 const request = vi . fn ( async ( _method : string , params : { agentId : string } ) => ( {
57103 agentId : params . agentId ,
0 commit comments