| ... | @@ -20,6 +20,7 @@ import { | ... | @@ -20,6 +20,7 @@ import { |
| 20 | resolveEnvModeLabel, | 20 | resolveEnvModeLabel, |
| 21 | resolveEffectiveEnvMode, | 21 | resolveEffectiveEnvMode, |
| 22 | resolveLockedWorkspaceLabel, | 22 | resolveLockedWorkspaceLabel, |
| | 23 | shouldShowEnvironmentIndicator, |
| 23 | } from "./BranchToolbar.logic"; | 24 | } from "./BranchToolbar.logic"; |
| 24 | import { BranchToolbarBranchSelector } from "./BranchToolbarBranchSelector"; | 25 | import { BranchToolbarBranchSelector } from "./BranchToolbarBranchSelector"; |
| 25 | import { BranchToolbarEnvironmentSelector } from "./BranchToolbarEnvironmentSelector"; | 26 | import { BranchToolbarEnvironmentSelector } from "./BranchToolbarEnvironmentSelector"; |
| ... | @@ -60,6 +61,7 @@ interface MobileRunContextSelectorProps { | ... | @@ -60,6 +61,7 @@ interface MobileRunContextSelectorProps { |
| 60 | environmentId: EnvironmentId; | 61 | environmentId: EnvironmentId; |
| 61 | availableEnvironments: readonly EnvironmentOption[] | undefined; | 62 | availableEnvironments: readonly EnvironmentOption[] | undefined; |
| 62 | showEnvironmentPicker: boolean; | 63 | showEnvironmentPicker: boolean; |
| | 64 | showEnvironmentIndicator: boolean; |
| 63 | onEnvironmentChange: ((environmentId: EnvironmentId) => void) | undefined; | 65 | onEnvironmentChange: ((environmentId: EnvironmentId) => void) | undefined; |
| 64 | effectiveEnvMode: EnvMode; | 66 | effectiveEnvMode: EnvMode; |
| 65 | activeWorktreePath: string | null; | 67 | activeWorktreePath: string | null; |
| ... | @@ -72,6 +74,7 @@ const MobileRunContextSelector = memo(function MobileRunContextSelector({ | ... | @@ -72,6 +74,7 @@ const MobileRunContextSelector = memo(function MobileRunContextSelector({ |
| 72 | environmentId, | 74 | environmentId, |
| 73 | availableEnvironments, | 75 | availableEnvironments, |
| 74 | showEnvironmentPicker, | 76 | showEnvironmentPicker, |
| | 77 | showEnvironmentIndicator, |
| 75 | onEnvironmentChange, | 78 | onEnvironmentChange, |
| 76 | effectiveEnvMode, | 79 | effectiveEnvMode, |
| 77 | activeWorktreePath, | 80 | activeWorktreePath, |
| ... | @@ -94,7 +97,7 @@ const MobileRunContextSelector = memo(function MobileRunContextSelector({ | ... | @@ -94,7 +97,7 @@ const MobileRunContextSelector = memo(function MobileRunContextSelector({ |
| 94 | : resolveCurrentWorkspaceLabel(activeWorktreePath); | 97 | : resolveCurrentWorkspaceLabel(activeWorktreePath); |
| 95 | const isLocked = envLocked || envModeLocked; | 98 | const isLocked = envLocked || envModeLocked; |
| 96 | const EnvironmentIcon = activeEnvironment?.isPrimary ? MonitorIcon : CloudIcon; | 99 | const EnvironmentIcon = activeEnvironment?.isPrimary ? MonitorIcon : CloudIcon; |
| 97 | const icon = showEnvironmentPicker ? ( | 100 | const icon = showEnvironmentIndicator ? ( |
| 98 | // Button's base styles apply `-mx-0.5` to descendant SVGs, which eats 4px | 101 | // Button's base styles apply `-mx-0.5` to descendant SVGs, which eats 4px |
| 99 | // out of whatever gap we set. mx-0! cancels that so gap-0.5 reads as 2px. | 102 | // out of whatever gap we set. mx-0! cancels that so gap-0.5 reads as 2px. |
| 100 | <span className="inline-flex shrink-0 items-center gap-0.5"> | 103 | <span className="inline-flex shrink-0 items-center gap-0.5"> |
| ... | @@ -108,7 +111,7 @@ const MobileRunContextSelector = memo(function MobileRunContextSelector({ | ... | @@ -108,7 +111,7 @@ const MobileRunContextSelector = memo(function MobileRunContextSelector({ |
| 108 | <> | 111 | <> |
| 109 | {icon} | 112 | {icon} |
| 110 | <span className="min-w-0 truncate"> | 113 | <span className="min-w-0 truncate"> |
| 111 | {showEnvironmentPicker ? (activeEnvironment?.label ?? "Run on") : workspaceLabel} | 114 | {showEnvironmentIndicator ? (activeEnvironment?.label ?? "Run on") : workspaceLabel} |
| 112 | </span> | 115 | </span> |
| 113 | </> | 116 | </> |
| 114 | ); | 117 | ); |
| ... | @@ -234,6 +237,12 @@ export const BranchToolbar = memo(function BranchToolbar({ | ... | @@ -234,6 +237,12 @@ export const BranchToolbar = memo(function BranchToolbar({ |
| 234 | const showEnvironmentPicker = Boolean( | 237 | const showEnvironmentPicker = Boolean( |
| 235 | availableEnvironments && availableEnvironments.length > 1 && onEnvironmentChange, | 238 | availableEnvironments && availableEnvironments.length > 1 && onEnvironmentChange, |
| 236 | ); | 239 | ); |
| | 240 | const activeEnvironmentOption = |
| | 241 | availableEnvironments?.find((env) => env.environmentId === environmentId) ?? null; |
| | 242 | const showEnvironmentIndicator = shouldShowEnvironmentIndicator({ |
| | 243 | activeEnvironment: activeEnvironmentOption, |
| | 244 | canPickEnvironment: showEnvironmentPicker, |
| | 245 | }); |
| 237 | const isMobile = useIsMobile(); | 246 | const isMobile = useIsMobile(); |
| 238 | | 247 | |
| 239 | if (!hasActiveThread || !activeProject) return null; | 248 | if (!hasActiveThread || !activeProject) return null; |
| ... | @@ -247,6 +256,7 @@ export const BranchToolbar = memo(function BranchToolbar({ | ... | @@ -247,6 +256,7 @@ export const BranchToolbar = memo(function BranchToolbar({ |
| 247 | environmentId={environmentId} | 256 | environmentId={environmentId} |
| 248 | availableEnvironments={availableEnvironments} | 257 | availableEnvironments={availableEnvironments} |
| 249 | showEnvironmentPicker={showEnvironmentPicker} | 258 | showEnvironmentPicker={showEnvironmentPicker} |
| | 259 | showEnvironmentIndicator={showEnvironmentIndicator} |
| 250 | onEnvironmentChange={onEnvironmentChange} | 260 | onEnvironmentChange={onEnvironmentChange} |
| 251 | effectiveEnvMode={effectiveEnvMode} | 261 | effectiveEnvMode={effectiveEnvMode} |
| 252 | activeWorktreePath={activeWorktreePath} | 262 | activeWorktreePath={activeWorktreePath} |
| ... | @@ -254,13 +264,13 @@ export const BranchToolbar = memo(function BranchToolbar({ | ... | @@ -254,13 +264,13 @@ export const BranchToolbar = memo(function BranchToolbar({ |
| 254 | /> | 264 | /> |
| 255 | ) : ( | 265 | ) : ( |
| 256 | <div className="flex min-w-0 shrink-0 items-center gap-1"> | 266 | <div className="flex min-w-0 shrink-0 items-center gap-1"> |
| 257 | {showEnvironmentPicker && availableEnvironments && onEnvironmentChange && ( | 267 | {showEnvironmentIndicator && availableEnvironments && ( |
| 258 | <> | 268 | <> |
| 259 | <BranchToolbarEnvironmentSelector | 269 | <BranchToolbarEnvironmentSelector |
| 260 | envLocked={envLocked} | 270 | envLocked={envLocked} |
| 261 | environmentId={environmentId} | 271 | environmentId={environmentId} |
| 262 | availableEnvironments={availableEnvironments} | 272 | availableEnvironments={availableEnvironments} |
| 263 | onEnvironmentChange={onEnvironmentChange} | 273 | {...(showEnvironmentPicker && onEnvironmentChange ? { onEnvironmentChange } : {})} |
| 264 | /> | 274 | /> |
| 265 | <Separator orientation="vertical" className="mx-0.5 h-3.5!" /> | 275 | <Separator orientation="vertical" className="mx-0.5 h-3.5!" /> |
| 266 | </> | 276 | </> |