@@ -300,6 +300,116 @@ describe("buildThreadActionItems", () => {
300300 expect . objectContaining ( { value : `thread:${ idThread . id } ` } ) ,
301301 ] ) ;
302302 } ) ;
303+
304+ it ( "hides subagent threads but keeps forks" , ( ) => {
305+ const parentId = ThreadId . make ( "parent" ) ;
306+ const items = buildThreadActionItems ( {
307+ threads : [
308+ makeThread ( { id : parentId , title : "Parent" } ) ,
309+ makeThread ( {
310+ id : ThreadId . make ( "subagent" ) ,
311+ title : "Subagent" ,
312+ lineage : {
313+ rootThreadId : parentId ,
314+ parentThreadId : parentId ,
315+ relationshipToParent : "subagent" ,
316+ } ,
317+ } ) ,
318+ makeThread ( {
319+ id : ThreadId . make ( "fork" ) ,
320+ title : "Fork" ,
321+ lineage : {
322+ rootThreadId : parentId ,
323+ parentThreadId : parentId ,
324+ relationshipToParent : "fork" ,
325+ } ,
326+ } ) ,
327+ ] ,
328+ projectTitleById : new Map ( ) ,
329+ sortOrder : "updated_at" ,
330+ icon : null ,
331+ runThread : async ( ) => undefined ,
332+ } ) ;
333+
334+ expect ( items . map ( ( item ) => item . value ) . toSorted ( ) ) . toEqual ( [ "thread:fork" , "thread:parent" ] ) ;
335+ } ) ;
336+
337+ it ( "ranks word-start title matches above newer mid-word matches" , ( ) => {
338+ const items = buildThreadActionItems ( {
339+ threads : [
340+ makeThread ( {
341+ id : ThreadId . make ( "mid-word" ) ,
342+ title : "Fix oauth redirect" ,
343+ updatedAt : "2026-03-20T00:00:00.000Z" ,
344+ } ) ,
345+ makeThread ( {
346+ id : ThreadId . make ( "word-start" ) ,
347+ title : "Clean up auth tokens" ,
348+ updatedAt : "2026-03-02T00:00:00.000Z" ,
349+ } ) ,
350+ makeThread ( {
351+ id : ThreadId . make ( "branch-word-start" ) ,
352+ title : "Refactor login" ,
353+ branch : "feature/auth-cleanup" ,
354+ updatedAt : "2026-03-01T00:00:00.000Z" ,
355+ } ) ,
356+ ] ,
357+ projectTitleById : new Map ( ) ,
358+ sortOrder : "updated_at" ,
359+ icon : null ,
360+ runThread : async ( ) => undefined ,
361+ } ) ;
362+
363+ const groups = filterCommandPaletteGroups ( {
364+ activeGroups : [ ] ,
365+ query : "auth" ,
366+ isInSubmenu : false ,
367+ projectSearchItems : [ ] ,
368+ threadSearchItems : items ,
369+ } ) ;
370+
371+ expect ( groups [ 0 ] ?. items . map ( ( item ) => item . value ) ) . toEqual ( [
372+ "thread:word-start" ,
373+ "thread:branch-word-start" ,
374+ "thread:mid-word" ,
375+ ] ) ;
376+ } ) ;
377+
378+ it ( "breaks ties within a match tier by latest user message" , ( ) => {
379+ const items = buildThreadActionItems ( {
380+ threads : [
381+ makeThread ( {
382+ id : ThreadId . make ( "prefix-stale" ) ,
383+ title : "Auth refactor" ,
384+ updatedAt : "2026-03-20T00:00:00.000Z" ,
385+ latestUserMessageAt : "2025-09-01T00:00:00.000Z" ,
386+ } ) ,
387+ makeThread ( {
388+ id : ThreadId . make ( "word-fresh" ) ,
389+ title : "Fix auth refresh" ,
390+ updatedAt : "2026-03-10T00:00:00.000Z" ,
391+ latestUserMessageAt : "2026-03-10T00:00:00.000Z" ,
392+ } ) ,
393+ ] ,
394+ projectTitleById : new Map ( ) ,
395+ sortOrder : "updated_at" ,
396+ icon : null ,
397+ runThread : async ( ) => undefined ,
398+ } ) ;
399+
400+ const groups = filterCommandPaletteGroups ( {
401+ activeGroups : [ ] ,
402+ query : "auth" ,
403+ isInSubmenu : false ,
404+ projectSearchItems : [ ] ,
405+ threadSearchItems : items ,
406+ } ) ;
407+
408+ expect ( groups [ 0 ] ?. items . map ( ( item ) => item . value ) ) . toEqual ( [
409+ "thread:word-fresh" ,
410+ "thread:prefix-stale" ,
411+ ] ) ;
412+ } ) ;
303413} ) ;
304414
305415describe ( "filterPinnedBrowseEntries" , ( ) => {
0 commit comments