@@ -46,8 +46,6 @@ const IDENTITY_MENU_LINKS: ReadonlyArray<{
4646 } ,
4747] ;
4848
49- /** Above this roster size the chip menu adds filtering and scrolls the grid. */
50- const QUICK_SWITCH_VISIBLE_AGENT_LIMIT = 6 ;
5149const AGENT_VALUE_PREFIX = "agent:" ;
5250const COMMAND_VALUE_PREFIX = "command:" ;
5351const LINK_VALUE_PREFIX = "link:" ;
@@ -175,13 +173,11 @@ type SidebarAgentMenuParams = {
175173 activeName : string ;
176174 agents : readonly AgentMenuAgent [ ] ;
177175 identities : ReadonlyMap < string , AgentIdentityResult > ;
178- filter : string ;
179176 pinnedAgentIds : readonly string [ ] ;
180177 connected : boolean ;
181178 openMode : "hover" | "click" ;
182179 agentUnreadCount : ( agentId : string ) => number ;
183180 agentApprovalCount : ( agentId : string ) => number ;
184- onFilterChange : ( next : string ) => void ;
185181 onPointerEnter : ( ) => void ;
186182 onPointerLeave : ( ) => void ;
187183 onAfterShow : ( ) => void ;
@@ -213,14 +209,9 @@ function isApplePlatform(): boolean {
213209 return / M a c | i P h o n e | i P a d | i P o d / u. test ( globalThis . navigator ?. platform ?? "" ) ;
214210}
215211
216- /** Rows for the chip switcher. Small rosters list everything; larger rosters
217- add filtering while keeping every unpinned option reachable by scrolling. */
218212function sidebarAgentMenuRows ( params : {
219213 agents : readonly AgentMenuAgent [ ] ;
220- activeId : string ;
221- filter : string ;
222214 pinnedAgentIds : readonly string [ ] ;
223- identities : ReadonlyMap < string , AgentIdentityResult > ;
224215} ) {
225216 const { agents } = params ;
226217 const availableIds = new Set ( agents . map ( ( agent ) => normalizeAgentId ( agent . id ) ) ) ;
@@ -229,26 +220,11 @@ function sidebarAgentMenuRows(params: {
229220 . map ( ( agentId ) => normalizeAgentId ( agentId ) )
230221 . filter ( ( agentId ) => availableIds . has ( agentId ) ) ,
231222 ) ;
232- const sorted = agents . toSorted ( ( a , b ) => {
223+ return agents . toSorted ( ( a , b ) => {
233224 const aPinned = pinnedIds . has ( normalizeAgentId ( a . id ) ) ? 0 : 1 ;
234225 const bPinned = pinnedIds . has ( normalizeAgentId ( b . id ) ) ? 0 : 1 ;
235226 return aPinned - bPinned ;
236227 } ) ;
237- if ( agents . length <= QUICK_SWITCH_VISIBLE_AGENT_LIMIT ) {
238- return { rows : sorted , showFilter : false } ;
239- }
240- const query = params . filter . trim ( ) . toLowerCase ( ) ;
241- if ( query ) {
242- const rows = sorted . filter ( ( entry ) => {
243- const agentId = normalizeAgentId ( entry . id ) ;
244- return (
245- agentId . toLowerCase ( ) . includes ( query ) ||
246- normalizeAgentLabel ( entry , params . identities . get ( agentId ) ) . toLowerCase ( ) . includes ( query )
247- ) ;
248- } ) ;
249- return { rows, showFilter : true } ;
250- }
251- return { rows : sorted , showFilter : true } ;
252228}
253229
254230function renderAgentRow ( agent : AgentMenuAgent , params : SidebarAgentMenuParams ) {
@@ -337,7 +313,7 @@ export function renderSidebarAgentMenu(params: SidebarAgentMenuParams) {
337313 return nothing ;
338314 }
339315 const { activeId, activeName, agents } = params ;
340- const { rows, showFilter } = sidebarAgentMenuRows ( params ) ;
316+ const rows = sidebarAgentMenuRows ( params ) ;
341317 return html `
342318 < openclaw-menu-surface >
343319 < wa-dropdown
@@ -387,13 +363,7 @@ export function renderSidebarAgentMenu(params: SidebarAgentMenuParams) {
387363 if ( params . openMode === "hover" ) {
388364 return ;
389365 }
390- if ( showFilter ) {
391- event . currentTarget
392- . querySelector < HTMLInputElement > ( ".sidebar-agent-menu__filter input" )
393- ?. focus ( ) ;
394- } else {
395- focusActiveAgentMenuItem ( event . currentTarget ) ;
396- }
366+ focusActiveAgentMenuItem ( event . currentTarget ) ;
397367 } }
398368 @keydown=${ ( event : KeyboardEvent ) => {
399369 if ( moveSidebarMenuFocus ( event ) ) {
@@ -429,37 +399,9 @@ export function renderSidebarAgentMenu(params: SidebarAgentMenuParams) {
429399 ${ agents . length > 1
430400 ? html `
431401 < div class ="sidebar-customize-menu__title "> ${ t ( "agentChip.agents" ) } </ div >
432- ${ showFilter
433- ? html `
434- < div class ="sidebar-agent-menu__filter ">
435- < input
436- type ="text "
437- .value =${ params . filter }
438- placeholder =${ t ( "agentChip.filterAgents" ) }
439- aria-label=${ t ( "agentChip.filterAgents" ) }
440- @input=${ ( event : Event ) =>
441- params . onFilterChange ( ( event . target as HTMLInputElement ) . value ) }
442- @keydown=${ ( event : KeyboardEvent ) => {
443- if ( moveSidebarMenuFocus ( event ) ) {
444- return ;
445- }
446- // Keep editing keys out of Web Awesome's document-level
447- // menu handler; Escape still dismisses the whole menu.
448- if ( event . key !== "Escape" && event . key !== "Tab" ) {
449- event . stopPropagation ( ) ;
450- }
451- } }
452- />
453- </ div >
454- `
455- : nothing }
456- ${ rows . length > 0
457- ? html `< div class ="sidebar-agent-menu__agent-grid ">
458- ${ rows . map ( ( entry ) => renderAgentRow ( entry , params ) ) }
459- </ div > `
460- : html `< div class ="sidebar-agent-menu__empty ">
461- ${ t ( "agentChip.noAgentMatches" ) }
462- </ div > ` }
402+ < div class ="sidebar-agent-menu__agent-grid ">
403+ ${ rows . map ( ( entry ) => renderAgentRow ( entry , params ) ) }
404+ </ div >
463405 `
464406 : nothing }
465407 < div class ="sidebar-customize-menu__separator " role ="separator "> </ div >
0 commit comments