@@ -3,6 +3,7 @@ import { EnvironmentId, ProjectId, ProviderInstanceId, ThreadId } from "@t3tools
33import type { Project , Thread } from "../types" ;
44import {
55 buildBrowseGroups ,
6+ buildCommandPaletteProjectMetadata ,
67 buildProjectActionItems ,
78 buildThreadActionItems ,
89 buildLinkedThreadActionItems ,
@@ -55,6 +56,124 @@ describe("linked pull request thread navigation", () => {
5556 } ) ;
5657} ) ;
5758
59+ describe ( "buildCommandPaletteProjectMetadata" , ( ) => {
60+ const localEnvironmentId = EnvironmentId . make ( "environment-local" ) ;
61+ const remoteEnvironmentId = EnvironmentId . make ( "environment-build-box" ) ;
62+ const locations = new Map ( [
63+ [ localEnvironmentId , { kind : "local" as const , label : "Local" , machine : "laptop" as const } ] ,
64+ [
65+ remoteEnvironmentId ,
66+ { kind : "remote" as const , label : "Build box" , machine : "server" as const } ,
67+ ] ,
68+ ] ) ;
69+
70+ it ( "makes every member environment and path searchable" , ( ) => {
71+ const metadata = buildCommandPaletteProjectMetadata ( {
72+ projects : [
73+ {
74+ environmentId : localEnvironmentId ,
75+ title : "T3 Code" ,
76+ workspaceRoot : "/Users/theo/Projects/t3code" ,
77+ } ,
78+ {
79+ environmentId : remoteEnvironmentId ,
80+ title : "t3code" ,
81+ workspaceRoot : "/srv/t3code" ,
82+ } ,
83+ ] ,
84+ locationByEnvironmentId : locations ,
85+ } ) ;
86+
87+ expect ( metadata . searchTerms ) . toEqual ( [
88+ "T3 Code" ,
89+ "/Users/theo/Projects/t3code" ,
90+ "Local" ,
91+ "t3code" ,
92+ "/srv/t3code" ,
93+ "Build box" ,
94+ ] ) ;
95+ expect ( metadata . environmentLabels ) . toEqual ( [ "Local" , "Build box" ] ) ;
96+
97+ const [ filteredGroup ] = filterCommandPaletteGroups ( {
98+ activeGroups : [ ] ,
99+ query : "build box" ,
100+ isInSubmenu : false ,
101+ projectSearchItems : [
102+ {
103+ kind : "action" ,
104+ value : "project:t3code" ,
105+ title : "T3 Code" ,
106+ searchTerms : metadata . searchTerms ,
107+ icon : null ,
108+ run : async ( ) => undefined ,
109+ } ,
110+ ] ,
111+ threadSearchItems : [ ] ,
112+ } ) ;
113+ expect ( filteredGroup ?. items ) . toHaveLength ( 1 ) ;
114+ } ) ;
115+
116+ it ( "deduplicates grouped checkouts by environment" , ( ) => {
117+ const metadata = buildCommandPaletteProjectMetadata ( {
118+ projects : [
119+ {
120+ environmentId : remoteEnvironmentId ,
121+ title : "T3 Code" ,
122+ workspaceRoot : "/srv/t3code" ,
123+ } ,
124+ {
125+ environmentId : remoteEnvironmentId ,
126+ title : "T3 Code worktree" ,
127+ workspaceRoot : "/srv/t3code-feature" ,
128+ } ,
129+ ] ,
130+ locationByEnvironmentId : locations ,
131+ } ) ;
132+
133+ expect ( metadata . environmentLabels ) . toEqual ( [ "Build box" ] ) ;
134+ } ) ;
135+
136+ it ( "deduplicates distinct environments with the same label" , ( ) => {
137+ const secondRemoteEnvironmentId = EnvironmentId . make ( "environment-build-box-2" ) ;
138+ const metadata = buildCommandPaletteProjectMetadata ( {
139+ projects : [
140+ {
141+ environmentId : remoteEnvironmentId ,
142+ title : "T3 Code" ,
143+ workspaceRoot : "/srv/t3code" ,
144+ } ,
145+ {
146+ environmentId : secondRemoteEnvironmentId ,
147+ title : "T3 Code mirror" ,
148+ workspaceRoot : "/srv/mirror/t3code" ,
149+ } ,
150+ ] ,
151+ locationByEnvironmentId : new Map ( [
152+ [ remoteEnvironmentId , { label : "Build box" } ] ,
153+ [ secondRemoteEnvironmentId , { label : "Build box" } ] ,
154+ ] ) ,
155+ } ) ;
156+
157+ expect ( metadata . environmentLabels ) . toEqual ( [ "Build box" ] ) ;
158+ } ) ;
159+
160+ it ( "uses a human-readable fallback when presentation data is unavailable" , ( ) => {
161+ const metadata = buildCommandPaletteProjectMetadata ( {
162+ projects : [
163+ {
164+ environmentId : remoteEnvironmentId ,
165+ title : "T3 Code" ,
166+ workspaceRoot : "/srv/t3code" ,
167+ } ,
168+ ] ,
169+ locationByEnvironmentId : new Map ( ) ,
170+ } ) ;
171+
172+ expect ( metadata . searchTerms ) . toContain ( "Remote" ) ;
173+ expect ( metadata . environmentLabels ) . toEqual ( [ "Remote" ] ) ;
174+ } ) ;
175+ } ) ;
176+
58177describe ( "reduceCommandPaletteUiState" , ( ) => {
59178 const closedState = { open : false , mode : "command" , openIntent : null } as const ;
60179
0 commit comments