@@ -14,7 +14,9 @@ export interface CommandPaletteItem {
1414 readonly value : string ;
1515 readonly searchTerms : ReadonlyArray < string > ;
1616 readonly title : ReactNode ;
17+ /** Optional content rendered inline before the title text. */
1718 readonly titleLeadingContent ?: ReactNode ;
19+ /** Optional content rendered inline after the title text (before the timestamp). */
1820 readonly titleTrailingContent ?: ReactNode ;
1921 readonly description ?: string ;
2022 readonly timestamp ?: string ;
@@ -72,24 +74,26 @@ export function buildProjectActionItems(input: {
7274 } ) ) ;
7375}
7476
75- export function buildThreadActionItems ( input : {
76- threads : ReadonlyArray <
77- Pick <
78- SidebarThreadSummary ,
79- "archivedAt" | "branch" | "createdAt" | "environmentId" | "id" | "projectId" | "title"
80- > & {
81- updatedAt ?: string | undefined ;
82- latestUserMessageAt ?: string | null ;
83- }
84- > ;
77+ export type BuildThreadActionItemsThread = Pick <
78+ SidebarThreadSummary ,
79+ "archivedAt" | "branch" | "createdAt" | "environmentId" | "id" | "projectId" | "title"
80+ > & {
81+ updatedAt ?: string | undefined ;
82+ latestUserMessageAt ?: string | null ;
83+ } ;
84+
85+ export function buildThreadActionItems < TThread extends BuildThreadActionItemsThread > ( input : {
86+ threads : ReadonlyArray < TThread > ;
8587 activeThreadId ?: Thread [ "id" ] ;
8688 projectTitleById : ReadonlyMap < Project [ "id" ] , string > ;
8789 sortOrder : SidebarThreadSortOrder ;
8890 icon : ReactNode ;
91+ /** Optional content rendered inline before the title text per-thread. */
92+ renderLeadingContent ?: ( thread : TThread ) => ReactNode ;
93+ /** Optional content rendered inline after the title text per-thread. */
94+ renderTrailingContent ?: ( thread : TThread ) => ReactNode ;
8995 runThread : ( thread : Pick < SidebarThreadSummary , "environmentId" | "id" > ) => Promise < void > ;
9096 limit ?: number ;
91- renderLeadingContent ?: ( thread : Pick < SidebarThreadSummary , "id" > ) => ReactNode ;
92- renderTrailingContent ?: ( thread : Pick < SidebarThreadSummary , "id" > ) => ReactNode ;
9397} ) : CommandPaletteActionItem [ ] {
9498 const sortedThreads = sortThreads (
9599 input . threads . filter ( ( thread ) => thread . archivedAt === null ) ,
@@ -115,26 +119,22 @@ export function buildThreadActionItems(input: {
115119 const leadingContent = input . renderLeadingContent ?.( thread ) ;
116120 const trailingContent = input . renderTrailingContent ?.( thread ) ;
117121
118- return Object . assign (
119- {
120- kind : "action" as const ,
121- value : `thread:${ thread . id } ` ,
122- searchTerms : [ thread . title , projectTitle ?? "" , thread . branch ?? "" ] ,
123- title : thread . title ,
124- description : descriptionParts . join ( " · " ) ,
125- timestamp : formatRelativeTimeLabel (
126- thread . latestUserMessageAt ?? thread . updatedAt ?? thread . createdAt ,
127- ) ,
128- icon : input . icon ,
129- } ,
130- leadingContent ? { titleLeadingContent : leadingContent } : { } ,
131- trailingContent ? { titleTrailingContent : trailingContent } : { } ,
132- {
133- run : async ( ) => {
134- await input . runThread ( thread ) ;
135- } ,
122+ return {
123+ kind : "action" ,
124+ value : `thread:${ thread . id } ` ,
125+ searchTerms : [ thread . title , projectTitle ?? "" , thread . branch ?? "" ] ,
126+ title : thread . title ,
127+ description : descriptionParts . join ( " · " ) ,
128+ timestamp : formatRelativeTimeLabel (
129+ thread . latestUserMessageAt ?? thread . updatedAt ?? thread . createdAt ,
130+ ) ,
131+ icon : input . icon ,
132+ ...( leadingContent ? { titleLeadingContent : leadingContent } : { } ) ,
133+ ...( trailingContent ? { titleTrailingContent : trailingContent } : { } ) ,
134+ run : async ( ) => {
135+ await input . runThread ( thread ) ;
136136 } ,
137- ) ;
137+ } ;
138138 } ) ;
139139}
140140
0 commit comments