( params: ResolveDevcontainerSelectionParams )
| 46 | * - Loaded + no configs → input mode, user must provide path |
| 47 | */ |
| 48 | export function resolveDevcontainerSelection( |
| 49 | params: ResolveDevcontainerSelectionParams |
| 50 | ): DevcontainerSelection { |
| 51 | const { selectedRuntime, availabilityState } = params; |
| 52 | |
| 53 | // Not devcontainer mode - hide controls, allow creation |
| 54 | if (selectedRuntime.mode !== RUNTIME_MODE.DEVCONTAINER) { |
| 55 | return { |
| 56 | configPath: "", |
| 57 | configs: [], |
| 58 | uiMode: "hidden", |
| 59 | helperText: null, |
| 60 | isCreatable: true, |
| 61 | }; |
| 62 | } |
| 63 | |
| 64 | const selectedPath = selectedRuntime.configPath.trim(); |
| 65 | |
| 66 | // Loading state - show skeleton placeholder to avoid flash when switching to dropdown |
| 67 | if (availabilityState.status === "loading") { |
| 68 | return { |
| 69 | configPath: selectedPath, |
| 70 | configs: [], |
| 71 | uiMode: "loading", |
| 72 | helperText: null, |
| 73 | isCreatable: false, // Block creation until configs loaded |
| 74 | }; |
| 75 | } |
| 76 | |
| 77 | // Failed state - show input, default to standard path if no selection |
| 78 | if (availabilityState.status === "failed") { |
| 79 | const resolvedPath = selectedPath || DEFAULT_DEVCONTAINER_CONFIG_PATH; |
| 80 | return { |
| 81 | configPath: resolvedPath, |
| 82 | configs: [], |
| 83 | uiMode: "input", |
| 84 | helperText: "Configs couldn't be loaded. Enter a path to continue.", |
| 85 | isCreatable: resolvedPath.length > 0, |
| 86 | }; |
| 87 | } |
| 88 | |
| 89 | // Loaded state - check for available configs |
| 90 | const availability = availabilityState.data.devcontainer; |
| 91 | const configs = availability ? getDevcontainerConfigs(availability) : []; |
| 92 | |
| 93 | // Loaded but no configs found - devcontainer option is hidden in UI, |
| 94 | // but if somehow reached, block creation |
| 95 | if (configs.length === 0) { |
| 96 | return { |
| 97 | configPath: "", |
| 98 | configs: [], |
| 99 | uiMode: "hidden", |
| 100 | helperText: null, |
| 101 | isCreatable: false, |
| 102 | }; |
| 103 | } |
| 104 | |
| 105 | // Loaded with configs - show dropdown |
no test coverage detected