feat(connections): manage environment availability #5598
ClosedDominicVonk(GitHub profile, opens in a new tab)wants to merge 5 commits into
main fromrefs/pull/5598/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
DominicVonk(GitHub profile, opens in a new tab) changed the title
- apps/mobile/src/connection/storage.ts lines 58 to 75OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -51,0 +55,21 @@55+ Effect.map((document) => new Set(document.disabledEnvironmentIds)),56+ Effect.mapError((error) => targetPersistenceError("list-targets", error)),57+ ),58+ setEnabled: (environmentId, enabled) =>59+ catalog60+ .update((document) => ({61+ ...document,62+ disabledEnvironmentIds: enabled63+ ? document.disabledEnvironmentIds.filter((candidate) => candidate !== environmentId)64+ : [...new Set([...document.disabledEnvironmentIds, environmentId])],65+ }))66+ .pipe(Effect.mapError((error) => targetPersistenceError("register-connection", error))),67+ reconcile: (environmentIds) =>68+ catalog69+ .update((document) => ({70+ ...document,71+ disabledEnvironmentIds: document.disabledEnvironmentIds.filter((environmentId) =>72+ environmentIds.has(environmentId),73+ ),74+ }))75+ .pipe(Effect.mapError((error) => targetPersistenceError("register-connection", error))),apps/web/src/connection/storage.ts lines 379 to 387OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -370,3 +371,17 @@370371 );371372 const catalog = yield* makeCatalogStore(makeCatalogBackend(database));372373374+ const activationStore = ConnectionActivationStore.of({375+ listDisabled: catalog.read.pipe(376+ Effect.map((document) => new Set(document.disabledEnvironmentIds)),377+ Effect.mapError((cause) => persistenceError("list-targets", cause)),378+ ),379+ setEnabled: (environmentId, enabled) =>380+ catalog381+ .update((document) => ({382+ ...document,383+ disabledEnvironmentIds: enabled384+ ? document.disabledEnvironmentIds.filter((candidate) => candidate !== environmentId)385+ : [...new Set([...document.disabledEnvironmentIds, environmentId])],386+ }))387+ .pipe(Effect.mapError((cause) => persistenceError("register-connection", cause))),
- packages/client-runtime/src/connection/registry.ts line 434OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -347 +359 @@347359 if (yield* Ref.getAndSet(started, true)) {packages/client-runtime/src/connection/registry.ts line 857Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -628,3 +643,4 @@628643 Effect.catchTag("EnvironmentNotRegisteredError", () => Effect.void),629644 Effect.withSpan("EnvironmentRegistry.retryNow"),630645 );646+ const setEnabled = Effect.fn("EnvironmentRegistry.setEnabled")(function* (
- apps/mobile/src/connection/storage.ts lines 72 to 72OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -46,6 +53,20 @@46- .pipe(Effect.mapError((error) => targetPersistenceError("register-connection", error))),53+ .pipe(Effect.mapError((error) => targetPersistenceError("set-activation", error))),4754 remove: (target) =>4855 catalog4956 .update((document) => removeConnectionFromCatalog(document, target))5057 .pipe(Effect.mapError((error) => targetPersistenceError("remove-connection", error))),5158 });59+ const activationStore = ConnectionActivationStore.of({60+ listDisabled: catalog.read.pipe(61+ Effect.map((document) => new Set(document.disabledEnvironmentIds)),62+ Effect.mapError((error) => targetPersistenceError("list-targets", error)),63+ ),64+ setEnabled: (environmentId, enabled) =>65+ catalog66+ .update((document) => ({67+ ...document,68+ disabledEnvironmentIds: enabled69+ ? document.disabledEnvironmentIds.filter((candidate) => candidate !== environmentId)70+ : [...new Set([...document.disabledEnvironmentIds, environmentId])],71+ }))72+ .pipe(Effect.mapError((error) => targetPersistenceError("reconcile-activation", error))),apps/mobile/src/connection/storage.ts lines 53 to 53OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -36,11 +43,11 @@3643 const targetStore = ConnectionTargetStore.of({3744 list: catalog.read.pipe(3845 Effect.map((document) => document.targets),39- Effect.mapError((error) => targetPersistenceError("list-targets", error)),46+ Effect.mapError((error) => targetPersistenceError("list-activation", error)),4047 ),4148 });4249 const registrationStore = ConnectionRegistrationStore.of({4350 register: (registration) =>4451 catalog4552 .update((document) => registerConnectionInCatalog(document, registration))46- .pipe(Effect.mapError((error) => targetPersistenceError("register-connection", error))),53+ .pipe(Effect.mapError((error) => targetPersistenceError("set-activation", error))),apps/mobile/src/connection/storage.ts lines 62 to 62OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -37,15 +44,19 @@3744 list: catalog.read.pipe(3845 Effect.map((document) => document.targets),39- Effect.mapError((error) => targetPersistenceError("list-targets", error)),46+ Effect.mapError((error) => targetPersistenceError("list-activation", error)),4047 ),4148 });4249 const registrationStore = ConnectionRegistrationStore.of({4350 register: (registration) =>4451 catalog4552 .update((document) => registerConnectionInCatalog(document, registration))46- .pipe(Effect.mapError((error) => targetPersistenceError("register-connection", error))),53+ .pipe(Effect.mapError((error) => targetPersistenceError("set-activation", error))),4754 remove: (target) =>4855 catalog4956 .update((document) => removeConnectionFromCatalog(document, target))5057 .pipe(Effect.mapError((error) => targetPersistenceError("remove-connection", error))),5158 });59+ const activationStore = ConnectionActivationStore.of({60+ listDisabled: catalog.read.pipe(61+ Effect.map((document) => new Set(document.disabledEnvironmentIds)),62+ Effect.mapError((error) => targetPersistenceError("list-targets", error)),apps/mobile/src/connection/storage.ts lines 81 to 81OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -51,0 +61,21 @@61+ Effect.map((document) => new Set(document.disabledEnvironmentIds)),62+ Effect.mapError((error) => targetPersistenceError("list-targets", error)),63+ ),64+ setEnabled: (environmentId, enabled) =>65+ catalog66+ .update((document) => ({67+ ...document,68+ disabledEnvironmentIds: enabled69+ ? document.disabledEnvironmentIds.filter((candidate) => candidate !== environmentId)70+ : [...new Set([...document.disabledEnvironmentIds, environmentId])],71+ }))72+ .pipe(Effect.mapError((error) => targetPersistenceError("reconcile-activation", error))),73+ reconcile: (environmentIds) =>74+ catalog75+ .update((document) => ({76+ ...document,77+ disabledEnvironmentIds: document.disabledEnvironmentIds.filter((environmentId) =>78+ environmentIds.has(environmentId),79+ ),80+ }))81+ .pipe(Effect.mapError((error) => targetPersistenceError("register-connection", error))),apps/mobile/src/connection/storage.ts lines 46 to 46OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -36,4 +43,4 @@3643 const targetStore = ConnectionTargetStore.of({3744 list: catalog.read.pipe(3845 Effect.map((document) => document.targets),39- Effect.mapError((error) => targetPersistenceError("list-targets", error)),46+ Effect.mapError((error) => targetPersistenceError("list-activation", error)),
- packages/client-runtime/src/connection/registry.ts line 582OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -556,3 +579,4 @@556579 ? yield* profiles.get(target.connectionId)557580 : Option.none();558581582+ yield* activation.setEnabled(environmentId, true);
- packages/client-runtime/src/connection/registry.ts lines 364 to 364OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -344,3 +358,7 @@344358 );345359346360 const start = Effect.gen(function* () {361+ if (yield* Ref.get(started)) {362+ return;363+ }364+ yield* activation.reconcile(new Set(persistedTargets.map((target) => target.environmentId)));
- packages/client-runtime/src/connection/connectivity.ts line 52OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -19,0 +32,21 @@32+export const followNetworkStatus = Effect.fnUntraced(function* (options: {33+ readonly apply: (status: NetworkStatus) => Effect.Effect<void>;34+}) {35+ const connectivity = yield* Connectivity;36+ const wakeups = yield* ConnectionWakeups.ConnectionWakeups;37+ const reportCount = yield* Ref.make(0);38+ const appliedStatus = yield* Ref.make<Option.Option<NetworkStatus>>(Option.none());39+ const applyLock = yield* Semaphore.make(1);40+41+ const applyStatus = Effect.fnUntraced(function* (status: NetworkStatus) {42+ const changed = yield* Ref.modify(appliedStatus, (current) =>43+ Option.isSome(current) && current.value === status44+ ? ([false, current] as const)45+ : ([true, Option.some(status)] as const),46+ );47+ if (changed) {48+ yield* options.apply(status);49+ }50+ });51+52+ yield* connectivity.changes.pipe(
- apps/mobile/src/state/use-remote-environment-registry.ts line 143OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -140,3 +140,4 @@140140 connectionState: environment.connectionState,141141 connectionError: environment.connectionError,142142 connectionErrorTraceId: environment.connectionErrorTraceId,143+ enabled: environment.connectionState !== "available",
- packages/client-runtime/src/connection/connectivity.ts lines 66 to 74OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -19,0 +54,21 @@54+ const startedAt = yield* Ref.get(reportCount);55+ const status = yield* connectivity.status;56+ yield* applyLock.withPermits(1)(57+ Effect.gen(function* () {58+ if ((yield* Ref.get(reportCount)) === startedAt) {59+ yield* applyStatus(status);60+ }61+ }),62+ );63+ });64+65+ yield* connectivity.changes.pipe(66+ Stream.runForEach((status) =>67+ applyLock.withPermits(1)(68+ applyStatus(status).pipe(69+ Effect.flatMap((changed) =>70+ changed ? Ref.update(reportCount, (count) => count + 1) : Effect.void,71+ ),72+ ),73+ ),74+ ),
- apps/web/src/components/settings/ConnectionsSettings.tsx line 1575Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1488,0 +1544,21 @@1544+ <p className="text-xs text-muted-foreground">1545+ Connect to this environment from this device.1546+ </p>1547+ </div>1548+ <Switch1549+ aria-label={`${environment.label} enabled`}1550+ checked={enabled}1551+ onCheckedChange={(nextEnabled) =>1552+ onSetEnabled(environmentId, nextEnabled)1553+ }1554+ />1555+ </div>1556+ {environment.relayManaged ? (1557+ <p className="text-sm text-muted-foreground">1558+ Managed by T3 Connect. Tunnel details update automatically.1559+ </p>1560+ ) : isEditableBearer ? (1561+ <div className="grid gap-4 sm:grid-cols-2">1562+ <Field>1563+ <FieldLabel htmlFor={labelInputId}>Label</FieldLabel>1564+ <Input
- packages/client-runtime/src/connection/registry.ts line 275OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -259,4 +270,6 @@259270 Scope.provide(scope),260271 Effect.onError(() => Scope.close(scope, Exit.void)),261272 );262- yield* supervisor.connect;273+ if (desired) {274+ yield* supervisor.connect;275+ }
- apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx line 141Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -124,18 +120,3 @@124120 paddingBottom: Math.max(insets.bottom, 18) + 18,125121 }}126122 >127- {hasLocalEnvironments ? (128- <View collapsable={false} className="overflow-hidden rounded-[24px] bg-card">129- {localEnvironments.map((environment, index) => (130- <View131- key={environment.environmentId}132- collapsable={false}133- className={cn(index !== 0 && "border-t border-border")}134- >135- <ConnectionEnvironmentRow136- environment={environment}137- expanded={expandedId === environment.environmentId}138- onToggle={() => handleToggle(environment.environmentId)}139- onReconnect={onReconnectEnvironment}140- onRemove={onRemoveEnvironmentPress}141- onUpdate={handleUpdateEnvironment}
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/mobile/src/features/connection/CloudEnvironmentRows.tsx line 226Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -223,4 +268,4 @@223268 props.onDisconnect();224269 }}225270 onToggleError={props.onToggleError}226- value={props.environment.connectionState !== "available"}271+ value={props.environment.enabled}packages/client-runtime/src/connection/registry.ts line 497OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -397,10 +484,14 @@397484 if ((yield* Ref.get(platformEnvironmentIds)).has(environmentId)) {398485 return;399486 }400- yield* registrations.register(registration);401- yield* Ref.update(persistedTargetsByEnvironment, (current) => {402- const next = new Map(current);403- next.set(environmentId, registration.target);404- return next;405- });406- yield* installEntryLocked(entry);487+ yield* activationStateLock.withPermits(1)(488+ Effect.gen(function* () {489+ yield* registrations.register(registration);490+ yield* activation.setEnabled(environmentId, true);491+ disabledEnvironmentIds.delete(environmentId);492+ yield* Ref.update(persistedTargetsByEnvironment, (current) => {493+ const next = new Map(current);494+ next.set(environmentId, registration.target);495+ return next;496+ });497+ yield* installEntryLocked(entry, { initiallyDesired: true });
- apps/web/src/components/settings/ConnectionsSettings.tsx lines 1555 to 1565Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1488,0 +1542,21 @@1542+ <DialogDescription>1543+ Update how this device connects to {environment.label}.1544+ </DialogDescription>1545+ </DialogHeader>1546+ <DialogPanel>1547+ <div className="flex flex-col gap-4">1548+ <div className="flex items-center justify-between gap-4 rounded-md bg-muted/30 px-3 py-2">1549+ <div className="flex flex-col gap-0.5">1550+ <p className="text-sm font-medium text-foreground">Enabled</p>1551+ <p className="text-xs text-muted-foreground">1552+ Connect to this environment from this device.1553+ </p>1554+ </div>1555+ <Switch1556+ aria-label={`${environment.label} enabled`}1557+ checked={editEnabled}1558+ onCheckedChange={(nextEnabled) => {1559+ setEditEnabled(nextEnabled);1560+ void onSetEnabled(environmentId, nextEnabled);1561+ }}1562+ />apps/web/src/components/settings/ConnectionsSettings.tsx lines 1551 to 1565Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1488,0 +1542,21 @@1542+ <DialogDescription>1543+ Update how this device connects to {environment.label}.1544+ </DialogDescription>1545+ </DialogHeader>1546+ <DialogPanel>1547+ <div className="flex flex-col gap-4">1548+ <div className="flex items-center justify-between gap-4 rounded-md bg-muted/30 px-3 py-2">1549+ <div className="flex flex-col gap-0.5">1550+ <p className="text-sm font-medium text-foreground">Enabled</p>1551+ <p className="text-xs text-muted-foreground">1552+ Connect to this environment from this device.1553+ </p>1554+ </div>1555+ <Switch1556+ aria-label={`${environment.label} enabled`}1557+ checked={editEnabled}1558+ onCheckedChange={(nextEnabled) => {1559+ setEditEnabled(nextEnabled);1560+ void onSetEnabled(environmentId, nextEnabled);1561+ }}1562+ />apps/web/src/connection/onboarding.ts line 51Resolvedby DominicVonk(GitHub profile, opens in a new tab)@@ -36,3 +36,16 @@3636 execute: (input: { readonly target: DesktopSshEnvironmentTarget; readonly label?: string }) =>3737 ConnectionOnboarding.pipe(Effect.flatMap((onboarding) => onboarding.registerSsh(input))),3838 });39+40+export const updateBearerConnection = createRuntimeCommand(connectionAtomRuntime, {41+ label: "web:connection:update-bearer",42+ scheduler: onboardingScheduler,43+ concurrency: {44+ mode: "serial",45+ key: (input: { readonly environmentId: EnvironmentId }) => input.environmentId,46+ },47+ execute: (input: {48+ readonly environmentId: EnvironmentId;49+ readonly label: string;50+ readonly httpBaseUrl: string;51+ }) => ConnectionOnboarding.pipe(Effect.flatMap((onboarding) => onboarding.updateBearer(input))),
- apps/mobile/src/features/connection/CloudEnvironmentRows.tsx line 226Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -223,4 +262,4 @@223262 props.onDisconnect();224263 }}225264 onToggleError={props.onToggleError}226- value={props.environment.connectionState !== "available"}265+ value={props.environment.enabled}packages/client-runtime/src/connection/onboarding.ts line 171OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -148 +151,21 @@151+ Effect.fail(152+ new ConnectionBlockedError({153+ reason: "configuration",154+ detail: "The saved environment is no longer registered.",155+ }),156+ ),157+ ),158+ );148159 yield* registry.register(registration);160+ if (!wasEnabled) {161+ yield* registry.setEnabled(input.environmentId, false).pipe(162+ Effect.catchTag("EnvironmentNotRegisteredError", () =>163+ Effect.fail(164+ new ConnectionBlockedError({165+ reason: "configuration",166+ detail: "The saved environment is no longer registered.",167+ }),168+ ),169+ ),170+ );171+ }apps/web/src/components/settings/ConnectionsSettings.tsx line 1453OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1405,0 +1433,21 @@1433+ setDisplayUrl(environment.displayUrl ?? "");1434+ setEditEnabled(environment.enabled);1435+ }1436+ },1437+ [environment.displayUrl, environment.enabled, environment.label, isSaving],1438+ );1439+1440+ const handleSave = useCallback(async () => {1441+ setIsSaving(true);1442+ try {1443+ const updated = await onUpdate(environmentId, { label, displayUrl });1444+ if (updated) {1445+ const activationUpdated = await onSetEnabled(environmentId, editEnabled);1446+ if (activationUpdated) {1447+ setEditDialogOpen(false);1448+ }1449+ }1450+ } finally {1451+ setIsSaving(false);1452+ }1453+ }, [displayUrl, editEnabled, environmentId, label, onSetEnabled, onUpdate]);
- packages/client-runtime/src/connection/onboarding.ts lines 162 to 169OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -148 +149,21 @@149+ Effect.map((state) => state.desired),150+ Effect.catchTag("EnvironmentNotRegisteredError", () =>151+ Effect.fail(152+ new ConnectionBlockedError({153+ reason: "configuration",154+ detail: "The saved environment is no longer registered.",155+ }),156+ ),157+ ),158+ );148159 yield* registry.register(registration);160+ if (!wasEnabled) {161+ yield* registry.setEnabled(input.environmentId, false).pipe(162+ Effect.catchTag("EnvironmentNotRegisteredError", () =>163+ Effect.fail(164+ new ConnectionBlockedError({165+ reason: "configuration",166+ detail: "The saved environment is no longer registered.",167+ }),168+ ),169+ ),packages/client-runtime/src/connection/onboarding.ts lines 150 to 157OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -145,3 +145,13 @@145145 entry: Option.fromUndefinedOr(entry),146146 credential,147147 });148+ const wasEnabled = yield* registry.state(input.environmentId).pipe(149+ Effect.map((state) => state.desired),150+ Effect.catchTag("EnvironmentNotRegisteredError", () =>151+ Effect.fail(152+ new ConnectionBlockedError({153+ reason: "configuration",154+ detail: "The saved environment is no longer registered.",155+ }),156+ ),157+ ),
- apps/mobile/src/features/connection/CloudEnvironmentRows.tsx line 145Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -137,7 +147,19 @@147+ <View148+ collapsable={false}149+ className="overflow-hidden rounded-[24px] bg-card"150+ >137151 {props.connectedCloudEnvironments.map((environment, index) => (138152 <ConnectedCloudEnvironmentRow139153 key={environment.environmentId}140154 environment={environment}141155 borderTop={index !== 0}142- onConnect={() => props.onReconnectEnvironment(environment.environmentId)}143- onDisconnect={() => handleDisconnectCloudEnvironment(environment.environmentId)}156+ onConnect={() => {157+ if (environment.enabled) {158+ props.onReconnectEnvironment(environment.environmentId);159+ return;160+ }161+ props.onSetEnvironmentEnabled(environment.environmentId, true);162+ }}163+ onDisconnect={() =>164+ props.onSetEnvironmentEnabled(environment.environmentId, false)165+ }apps/mobile/src/features/connection/ConnectionEnvironmentRow.tsx line 187Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -131,3 +166,17 @@131166 exiting={FadeOut.duration(150)}132167 className="gap-3 px-4 pb-4"133168 >169+ <View className="flex-row items-center justify-between rounded-[14px] bg-input px-3.5 py-2.5">170+ <View className="flex-1 gap-0.5 pr-3">171+ <Text className="text-sm font-t3-bold text-foreground">Enabled</Text>172+ <Text className="text-xs text-foreground-muted">173+ Connect to this environment from this device.174+ </Text>175+ </View>176+ <Switch177+ accessibilityLabel={`${props.environment.environmentLabel} enabled`}178+ value={props.environment.enabled}179+ onValueChange={(enabled) =>180+ props.onSetEnabled(props.environment.environmentId, enabled)181+ }182+ />
- apps/mobile/src/features/connection/EnvironmentActivationSwitch.tsx line 37Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +13,21 @@13+ readonly activeTrackColor?: string;14+ readonly enabled: boolean;15+ readonly inactiveTrackColor?: string;16+ readonly onValueChange: (enabled: boolean) => Promise<AtomCommandResult<unknown, unknown>>;17+}) {18+ const [pending, setPending] = useState<PendingActivation | null>(null);19+ const isPending = pending !== null && props.enabled === pending.previous;20+ const value = isPending ? pending.requested : props.enabled;21+22+ const handleValueChange = useCallback(23+ async (enabled: boolean) => {24+ const request = { previous: props.enabled, requested: enabled };25+ setPending(request);26+ try {27+ const result = await props.onValueChange(enabled);28+ if (!AsyncResult.isSuccess(result)) {29+ setPending((current) => (current === request ? null : current));30+ }31+ } catch {32+ setPending((current) => (current === request ? null : current));33+ }
- apps/mobile/src/state/workspaceModel.ts line 42Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -38,3 +39,4 @@3839 environmentLabel: environment.label,3940 displayUrl: environment.displayUrl ?? "",4041 isRelayManaged: environment.relayManaged,42+ enabled: environment.enabled,apps/web/src/components/settings/ConnectionsSettings.tsx line 1464Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1461,4 +1504,3 @@14611504 ) : null}14621505 </div>14631506 <div className="flex w-full shrink-0 items-center gap-2 sm:w-auto sm:justify-end">1464- {versionMismatch &&
DominicVonk(GitHub profile, opens in a new tab) changed the title
- packages/client-runtime/src/connection/onboarding.ts line 148OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -145,4 +145,4 @@145145 entry: Option.fromUndefinedOr(entry),146146 credential,147147 });148- yield* registry.register(registration);148+ yield* registry.updateRegistration(registration).pipe(
- packages/client-runtime/src/connection/layer.ts lines 43 to 49OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -32,7 +37,13 @@3237 const connectionStartupLayer = Layer.effectDiscard(3338 Effect.gen(function* () {3439 const registry = yield* EnvironmentRegistry.EnvironmentRegistry;35- const platformSource = yield* PlatformConnectionSource.PlatformConnectionSource;36- yield* registry.start;37- yield* platformSource.registrations.pipe(38- Stream.runForEach(registry.reconcilePlatform),40+ const platformSource =41+ yield* PlatformConnectionSource.PlatformConnectionSource;42+ yield* registry.start.pipe(43+ Effect.tapError((error) =>44+ Effect.logWarning(45+ "Could not initialize environment connections; retrying.",46+ { error },47+ ),48+ ),49+ Effect.retry(Schedule.exponential("1 second")),
- apps/mobile/src/features/connection/EnvironmentActivationSwitch.tsx line 40Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +13,21 @@13+ readonly enabled: boolean;14+ readonly inactiveTrackColor?: string;15+ readonly onValueChange: (enabled: boolean) => Promise<AtomCommandResult<unknown, unknown>>;16+}) {17+ const [pending, setPending] = useState<PendingActivation | null>(null);18+ const isPending = pending !== null && props.enabled === pending.previous;19+ const value = isPending ? pending.requested : props.enabled;20+21+ const handleValueChange = useCallback(22+ async (enabled: boolean) => {23+ const request = { previous: props.enabled, requested: enabled };24+ setPending(request);25+ try {26+ await props.onValueChange(enabled);27+ setPending((current) => (current === request ? null : current));28+ } catch {29+ setPending((current) => (current === request ? null : current));30+ }31+ },32+ [props.enabled, props.onValueChange],33+ );
DominicVonk(GitHub profile, opens in a new tab) changed the title
- apps/mobile/src/features/threads/ThreadRouteScreen.tsx line 339Resolvedby DominicVonk(GitHub profile, opens in a new tab)@@ -326,9 +327,13 @@326327 [knownTerminalSessions, selectedThreadProject?.workspaceRoot],327328 );328329 const selectedThreadDetailWorktreePath = selectedThreadDetail?.worktreePath ?? null;329- const handleReconnectEnvironment = useCallback(() => {330- if (!environmentId) {330+ const handleActivateEnvironment = useCallback(() => {331+ if (!environmentId || routeEnvironmentRuntime === null) {332+ return;333+ }334+ if (threadEnvironmentActivationAction(routeEnvironmentRuntime.enabled) === "enable") {335+ void onSetEnvironmentEnabled(environmentId, true);331336 return;332337 }333338 onReconnectEnvironment(environmentId);334- }, [environmentId, onReconnectEnvironment]);339+ }, [environmentId, onReconnectEnvironment, onSetEnvironmentEnabled, routeEnvironmentRuntime]);
- packages/client-runtime/src/state/presentation.ts line 44OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -35,3 +38,7 @@3538 if (entry === undefined) {3639 return null;3740 }41+ const enabled = Option.getOrNull(AsyncResult.value(get(input.enabledAtom(environmentId))));42+ if (enabled === null) {43+ return null;44+ }
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.







Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
0e7b63bd-2d4d-484d-a078-94de13fc3259You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share