@@ -131,6 +131,7 @@ export function WelcomeWizard({
131131 const [ setupIds , setSetupIds ] = useState < readonly EnvironmentId [ ] > (
132132 resumeEnvironmentId ? [ resumeEnvironmentId ] : [ ] ,
133133 ) ;
134+ const [ importSelection , setImportSelection ] = useState < ImportSelection | null > ( null ) ;
134135 const [ isImporting , setIsImporting ] = useState ( false ) ;
135136 const finishingPromiseRef = useRef < Promise < boolean > | null > ( null ) ;
136137 const completionErrorToastIdRef = useRef < ReturnType < typeof toastManager . add > | null > ( null ) ;
@@ -286,6 +287,8 @@ export function WelcomeWizard({
286287 ) : (
287288 < ImportStep
288289 scans = { scans }
290+ importSelection = { importSelection }
291+ onImportSelectionChange = { setImportSelection }
289292 isImporting = { isImporting }
290293 setIsImporting = { setIsImporting }
291294 onDone = { finish }
@@ -1190,13 +1193,23 @@ function AgentInstallTerminal({
11901193
11911194const IMPORT_PERMISSION_MESSAGE = "This connection cannot import projects or thread history." ;
11921195
1196+ interface ImportSelection {
1197+ // Computers whose projects were listed when the selection changed; later ones get the defaults.
1198+ readonly environmentIds : ReadonlySet < EnvironmentId > ;
1199+ readonly keys : ReadonlySet < string > ;
1200+ }
1201+
11931202function ImportStep ( {
11941203 scans,
1204+ importSelection,
1205+ onImportSelectionChange,
11951206 isImporting,
11961207 setIsImporting,
11971208 onDone,
11981209} : {
11991210 readonly scans : ReturnType < typeof useProjectScans > ;
1211+ readonly importSelection : ImportSelection | null ;
1212+ readonly onImportSelectionChange : ( next : ImportSelection ) => void ;
12001213 readonly isImporting : boolean ;
12011214 readonly setIsImporting : ( value : boolean ) => void ;
12021215 readonly onDone : (
@@ -1209,7 +1222,6 @@ function ImportStep({
12091222 const writableEnvironments = useEnvironmentsWithScope ( scans , AuthOrchestrationOperateScope ) ;
12101223 const createProject = useAtomCommand ( projectEnvironment . create , { reportFailure : false } ) ;
12111224 const importThreads = useAtomCommand ( agentSessionImport , { reportFailure : false } ) ;
1212- const [ selectedPaths , setSelectedPaths ] = useState < ReadonlySet < string > | null > ( null ) ;
12131225 const importWarningRef = useRef ( "" ) ;
12141226 const importedThreadCountRef = useRef ( 0 ) ;
12151227 const importedProjectsRef = useRef ( new Map < string , ScopedProjectRef > ( ) ) ;
@@ -1237,8 +1249,20 @@ function ImportStep({
12371249 } ) ) ,
12381250 ) ,
12391251 ) ;
1240- const selectedKeys = selectedPaths ?? new Set ( recent . map ( ( candidate ) => candidate . key ) ) ;
1241- const selected = candidates . filter ( ( candidate ) => selectedKeys . has ( candidate . key ) ) ;
1252+ const recentKeys = new Set ( recent . map ( ( candidate ) => candidate . key ) ) ;
1253+ const selected = candidates . filter ( ( candidate ) =>
1254+ importSelection ?. environmentIds . has ( candidate . environmentId )
1255+ ? importSelection . keys . has ( candidate . key )
1256+ : recentKeys . has ( candidate . key ) ,
1257+ ) ;
1258+ const selectedKeys = new Set ( selected . map ( ( candidate ) => candidate . key ) ) ;
1259+ const setSelectedKeys = ( keys : ReadonlySet < string > ) =>
1260+ onImportSelectionChange ( {
1261+ environmentIds : new Set (
1262+ scans . flatMap ( ( scan ) => ( scan . data === null ? [ ] : [ scan . environmentId ] ) ) ,
1263+ ) ,
1264+ keys,
1265+ } ) ;
12421266
12431267 const canImport = selected . every ( ( candidate ) =>
12441268 writableEnvironments . has ( candidate . environmentId ) ,
@@ -1448,15 +1472,15 @@ function ImportStep({
14481472 variant = "ghost"
14491473 size = "xs"
14501474 disabled = { isImporting || selected . length === candidates . length }
1451- onClick = { ( ) => setSelectedPaths ( new Set ( candidates . map ( ( item ) => item . key ) ) ) }
1475+ onClick = { ( ) => setSelectedKeys ( new Set ( candidates . map ( ( item ) => item . key ) ) ) }
14521476 >
14531477 Select all
14541478 </ Button >
14551479 < Button
14561480 variant = "ghost"
14571481 size = "xs"
14581482 disabled = { isImporting || selected . length === 0 }
1459- onClick = { ( ) => setSelectedPaths ( new Set ( ) ) }
1483+ onClick = { ( ) => setSelectedKeys ( new Set ( ) ) }
14601484 >
14611485 Select none
14621486 </ Button >
@@ -1509,7 +1533,7 @@ function ImportStep({
15091533 < ImportCandidateList
15101534 candidates = { scanCandidates }
15111535 selectedKeys = { selectedKeys }
1512- onSelectionChange = { setSelectedPaths }
1536+ onSelectionChange = { setSelectedKeys }
15131537 />
15141538 </ fieldset >
15151539 ) ;
0 commit comments