fix(mobile): remove provider setup (#9721)
This commit is contained in:
1 parent
120fab18d8
commit
9eb4d71681
19 files changed
+32
-1095
No files matched your search
@@ -56,7 +56,6 @@ import { SettingsAuthRouteScreen } from "./features/settings/SettingsAuthRouteSc
|
||||
import { SettingsEnvironmentsRouteScreen } from "./features/settings/SettingsEnvironmentsRouteScreen";
|
||||
import { SettingsLegalRouteScreen } from "./features/settings/SettingsLegalRouteScreen";
|
||||
import { SettingsProjectGroupingRouteScreen } from "./features/settings/SettingsProjectGroupingRouteScreen";
|
||||
import { SettingsProviderSetupRouteScreen } from "./features/settings/SettingsProviderSetupRouteScreen";
|
||||
import { UsageRouteScreen } from "./features/usage/UsageRouteScreen";
|
||||
import { SettingsRouteScreen } from "./features/settings/SettingsRouteScreen";
|
||||
import { ShowcaseCaptureCoordinator } from "./features/showcase/ShowcaseCaptureCoordinator";
|
||||
@@ -165,13 +164,6 @@ const SettingsContentStack = createNativeStackNavigator({
|
||||
title: "Add Environment",
|
||||
},
|
||||
}),
|
||||
SettingsProviderSetup: createNativeStackScreen({
|
||||
screen: SettingsProviderSetupRouteScreen,
|
||||
linking: "providers/:environmentId/:instanceId",
|
||||
options: {
|
||||
title: "Antigravity",
|
||||
},
|
||||
}),
|
||||
SettingsArchive: createNativeStackScreen({
|
||||
screen: ArchivedThreadsRouteScreen,
|
||||
linking: "archive",
|
||||
|
||||
@@ -111,12 +111,6 @@ function ConfiguredConnectOnboardingRouteScreen() {
|
||||
<CloudEnvironmentRows
|
||||
connectedCloudEnvironments={connectedCloudEnvironments}
|
||||
onReconnectEnvironment={onReconnectEnvironment}
|
||||
onSetupProvider={(params) =>
|
||||
navigation.navigate("SettingsSheet", {
|
||||
screen: "SettingsContent",
|
||||
params: { screen: "SettingsProviderSetup", params },
|
||||
})
|
||||
}
|
||||
showHeader={false}
|
||||
/>
|
||||
) : (
|
||||
|
||||
@@ -26,8 +26,6 @@ import { cn } from "../../lib/cn";
|
||||
import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
|
||||
import type { ConnectedEnvironmentSummary } from "../../state/remote-runtime-types";
|
||||
import { serverEnvironment } from "../../state/server";
|
||||
import { ProviderSetupLink } from "../settings/ProviderSetupLink";
|
||||
import type { ProviderSetupRouteParams } from "../settings/SettingsProviderSetupRouteScreen";
|
||||
import { availableCloudEnvironmentPresentation } from "../cloud/cloudEnvironmentPresentation";
|
||||
import { hasCloudPublicConfig } from "../cloud/publicConfig";
|
||||
import { ConnectionStatusDot } from "./ConnectionStatusDot";
|
||||
@@ -36,7 +34,6 @@ import { type RelayEnvironmentView, useConnectionController } from "./useConnect
|
||||
interface CloudEnvironmentRowsProps {
|
||||
readonly connectedCloudEnvironments: ReadonlyArray<ConnectedEnvironmentSummary>;
|
||||
readonly onReconnectEnvironment: (environmentId: EnvironmentId) => void;
|
||||
readonly onSetupProvider?: (target: ProviderSetupRouteParams) => void;
|
||||
readonly showcaseAvailableEnvironments?: ReadonlyArray<RelayEnvironmentView>;
|
||||
readonly showcaseSignedIn?: boolean;
|
||||
/**
|
||||
@@ -151,7 +148,6 @@ function CloudEnvironmentRowsContent(
|
||||
onDisconnect={() => handleDisconnectCloudEnvironment(environment.environmentId)}
|
||||
errorExpanded={expandedErrorId === environment.environmentId}
|
||||
onToggleError={() => handleToggleCloudError(environment.environmentId)}
|
||||
onSetupProvider={props.onSetupProvider}
|
||||
/>
|
||||
))}
|
||||
{availableCloudEnvironments.map((environment, index) => (
|
||||
@@ -215,7 +211,6 @@ function ConnectedCloudEnvironmentRow(props: {
|
||||
readonly onConnect: () => void;
|
||||
readonly onDisconnect: () => void;
|
||||
readonly onToggleError: () => void;
|
||||
readonly onSetupProvider?: (target: ProviderSetupRouteParams) => void;
|
||||
}) {
|
||||
const serverConfig = useAtomValue(
|
||||
serverEnvironment.configValueAtom(props.environment.environmentId),
|
||||
@@ -240,23 +235,6 @@ function ConnectedCloudEnvironmentRow(props: {
|
||||
onToggleError={props.onToggleError}
|
||||
value={props.environment.connectionState !== "available"}
|
||||
/>
|
||||
{props.onSetupProvider
|
||||
? serverConfig?.providers
|
||||
.filter((provider) => provider.setup?.canAuthenticate || provider.setup?.canInstall)
|
||||
.map((provider) => (
|
||||
<ProviderSetupLink
|
||||
key={provider.instanceId}
|
||||
provider={provider}
|
||||
disabled={props.environment.connectionState !== "connected"}
|
||||
onPress={() =>
|
||||
props.onSetupProvider?.({
|
||||
environmentId: props.environment.environmentId,
|
||||
instanceId: provider.instanceId,
|
||||
})
|
||||
}
|
||||
/>
|
||||
))
|
||||
: null}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@ import { cn } from "../../lib/cn";
|
||||
import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
|
||||
import type { ConnectedEnvironmentSummary } from "../../state/remote-runtime-types";
|
||||
import { serverEnvironment } from "../../state/server";
|
||||
import { ProviderSetupLink } from "../settings/ProviderSetupLink";
|
||||
import type { ProviderSetupRouteParams } from "../settings/SettingsProviderSetupRouteScreen";
|
||||
import { ConnectionStatusDot } from "./ConnectionStatusDot";
|
||||
|
||||
function connectionStatusLabel(environment: ConnectedEnvironmentSummary): string | null {
|
||||
@@ -33,7 +31,6 @@ export function ConnectionEnvironmentRow(props: {
|
||||
readonly onToggle: () => void;
|
||||
readonly onReconnect: (environmentId: EnvironmentId) => void;
|
||||
readonly onRemove: (environmentId: EnvironmentId) => void;
|
||||
readonly onSetupProvider: (target: ProviderSetupRouteParams) => void;
|
||||
readonly onUpdate: (
|
||||
environmentId: EnvironmentId,
|
||||
updates: { readonly label: string; readonly displayUrl: string },
|
||||
@@ -182,22 +179,6 @@ export function ConnectionEnvironmentRow(props: {
|
||||
</>
|
||||
)}
|
||||
|
||||
{serverConfig?.providers
|
||||
.filter((provider) => provider.setup?.canAuthenticate || provider.setup?.canInstall)
|
||||
.map((provider) => (
|
||||
<ProviderSetupLink
|
||||
key={provider.instanceId}
|
||||
provider={provider}
|
||||
disabled={props.environment.connectionState !== "connected"}
|
||||
onPress={() =>
|
||||
props.onSetupProvider({
|
||||
environmentId: props.environment.environmentId,
|
||||
instanceId: provider.instanceId,
|
||||
})
|
||||
}
|
||||
/>
|
||||
))}
|
||||
|
||||
<View className="flex-row justify-end gap-2">
|
||||
{props.environment.isRelayManaged ? null : (
|
||||
<Pressable
|
||||
|
||||
@@ -75,12 +75,6 @@ export function ConnectionsRouteScreen() {
|
||||
onReconnect={onReconnectEnvironment}
|
||||
onRemove={onRemoveEnvironmentPress}
|
||||
onUpdate={onUpdateEnvironment}
|
||||
onSetupProvider={(params) =>
|
||||
navigation.navigate("SettingsSheet", {
|
||||
screen: "SettingsContent",
|
||||
params: { screen: "SettingsProviderSetup", params },
|
||||
})
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
))}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import type { ServerProvider } from "@t3tools/contracts";
|
||||
import { Pressable } from "react-native";
|
||||
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { SymbolView } from "../../components/AppSymbol";
|
||||
import { ProviderIcon } from "../../components/ProviderIcon";
|
||||
import { providerNeedsSetup } from "./provider-setup-state";
|
||||
|
||||
export function ProviderSetupLink(props: {
|
||||
readonly provider: ServerProvider;
|
||||
readonly disabled?: boolean;
|
||||
readonly onPress: () => void;
|
||||
}) {
|
||||
const label = props.provider.displayName ?? props.provider.driver;
|
||||
return (
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
disabled={props.disabled}
|
||||
onPress={props.onPress}
|
||||
className="min-h-12 flex-row items-center gap-3 px-4 py-3 active:opacity-70 disabled:opacity-40"
|
||||
>
|
||||
<ProviderIcon provider={props.provider.driver} size={18} />
|
||||
<Text className="min-w-0 flex-1 text-base text-foreground">
|
||||
{providerNeedsSetup(props.provider) ? `Set up ${label}` : `Manage ${label}`}
|
||||
</Text>
|
||||
<SymbolView name="chevron.right" size={12} tintColorClassName="accent-foreground" />
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
@@ -137,12 +137,6 @@ export function SettingsEnvironmentsRouteScreen() {
|
||||
onReconnect={onReconnectEnvironment}
|
||||
onRemove={onRemoveEnvironmentPress}
|
||||
onUpdate={handleUpdateEnvironment}
|
||||
onSetupProvider={(params) =>
|
||||
navigation.navigate("SettingsSheet", {
|
||||
screen: "SettingsContent",
|
||||
params: { screen: "SettingsProviderSetup", params },
|
||||
})
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
))}
|
||||
@@ -170,12 +164,6 @@ export function SettingsEnvironmentsRouteScreen() {
|
||||
<CloudEnvironmentRows
|
||||
connectedCloudEnvironments={connectedCloudEnvironments}
|
||||
onReconnectEnvironment={onReconnectEnvironment}
|
||||
onSetupProvider={(params) =>
|
||||
navigation.navigate("SettingsSheet", {
|
||||
screen: "SettingsContent",
|
||||
params: { screen: "SettingsProviderSetup", params },
|
||||
})
|
||||
}
|
||||
{...(SHOWCASE_ENABLED
|
||||
? {
|
||||
showcaseAvailableEnvironments: SHOWCASE_AVAILABLE_CLOUD_ENVIRONMENTS,
|
||||
|
||||
@@ -1,574 +0,0 @@
|
||||
import { useAtomValue } from "@effect/atom-react";
|
||||
import { useNavigation, type StaticScreenProps } from "@react-navigation/native";
|
||||
import type { AtomCommandResult } from "@t3tools/client-runtime/state/runtime";
|
||||
import {
|
||||
ANTIGRAVITY_AUTH_METHODS,
|
||||
AuthOrchestrationOperateScope,
|
||||
EnvironmentId,
|
||||
ProviderInstanceId,
|
||||
} from "@t3tools/contracts";
|
||||
import * as Schema from "effect/Schema";
|
||||
import { AsyncResult } from "effect/unstable/reactivity";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { Alert, Platform, Pressable, ScrollView, View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
|
||||
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
|
||||
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
|
||||
import { ProviderIcon } from "../../components/ProviderIcon";
|
||||
import { cn } from "../../lib/cn";
|
||||
import { tryCopyTextWithHaptic } from "../../lib/copyTextWithHaptic";
|
||||
import { tryOpenExternalUrl } from "../../lib/openExternalUrl";
|
||||
import { NativeStackScreenOptions } from "../../native/StackHeader";
|
||||
import { appAtomRegistry } from "../../state/atom-registry";
|
||||
import { useEnvironments } from "../../state/environments";
|
||||
import { useEnvironmentQuery } from "../../state/query";
|
||||
import { serverEnvironment } from "../../state/server";
|
||||
import { environmentSession } from "../../state/session";
|
||||
import { useAtomCommand } from "../../state/use-atom-command";
|
||||
import {
|
||||
antigravityEnabledPatch,
|
||||
readAntigravityAuthMethod,
|
||||
resolveProviderSignInPresentation,
|
||||
} from "./provider-setup-state";
|
||||
|
||||
export type ProviderSetupRouteParams = {
|
||||
readonly environmentId: EnvironmentId;
|
||||
readonly instanceId: ProviderInstanceId;
|
||||
};
|
||||
|
||||
const PRIVATE_COMMAND_OPTIONS = { reportFailure: false, reportDefect: false } as const;
|
||||
const isEnvironmentId = Schema.is(EnvironmentId);
|
||||
const isProviderInstanceId = Schema.is(ProviderInstanceId);
|
||||
|
||||
function SetupButton(props: {
|
||||
readonly label: string;
|
||||
readonly disabled?: boolean;
|
||||
readonly primary?: boolean;
|
||||
readonly destructive?: boolean;
|
||||
readonly onPress: () => void;
|
||||
}) {
|
||||
return (
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
disabled={props.disabled}
|
||||
onPress={props.onPress}
|
||||
className={cn(
|
||||
"min-h-11 items-center justify-center border border-white/25 px-4 py-3 active:opacity-70 disabled:opacity-40",
|
||||
props.primary && "bg-white",
|
||||
)}
|
||||
>
|
||||
<Text
|
||||
className={cn(
|
||||
"text-base font-t3-medium text-white",
|
||||
props.primary && "text-black",
|
||||
props.destructive && "text-red-400",
|
||||
)}
|
||||
>
|
||||
{props.label}
|
||||
</Text>
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
|
||||
/** The same screen stays inside Settings or the current model picker. */
|
||||
export function SettingsProviderSetupRouteScreen({
|
||||
route,
|
||||
}: StaticScreenProps<ProviderSetupRouteParams>) {
|
||||
if (
|
||||
!isEnvironmentId(route.params?.environmentId) ||
|
||||
!isProviderInstanceId(route.params?.instanceId)
|
||||
) {
|
||||
return (
|
||||
<View className="flex-1 bg-black p-5">
|
||||
<Text className="text-base text-white">This provider link is not valid.</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<ProviderSetupScreen
|
||||
key={`${route.params.environmentId}:${route.params.instanceId}`}
|
||||
{...route.params}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function ProviderSetupScreen({ environmentId, instanceId }: ProviderSetupRouteParams) {
|
||||
const navigation = useNavigation();
|
||||
const insets = useSafeAreaInsets();
|
||||
const { presentationById } = useEnvironments();
|
||||
const environment = presentationById.get(environmentId);
|
||||
const environmentLabel = environment?.entry.target.label ?? "this environment";
|
||||
const isConnected = environment?.connection.phase === "connected";
|
||||
const config = useAtomValue(serverEnvironment.configValueAtom(environmentId));
|
||||
const provider = config?.providers.find((item) => item.instanceId === instanceId);
|
||||
const access = useEnvironmentQuery(environmentSession.sessionStateAtom(environmentId));
|
||||
const canOperate =
|
||||
access.data?.authenticated === true &&
|
||||
access.data.scopes?.includes(AuthOrchestrationOperateScope) === true;
|
||||
const target = { environmentId, input: { instanceId } };
|
||||
const authQuery = useEnvironmentQuery(
|
||||
canOperate && provider?.setup?.canAuthenticate
|
||||
? serverEnvironment.providerAuthState(target)
|
||||
: null,
|
||||
);
|
||||
const installQuery = useEnvironmentQuery(
|
||||
canOperate && provider?.setup?.canInstall
|
||||
? serverEnvironment.providerInstallState(target)
|
||||
: null,
|
||||
);
|
||||
const auth = authQuery.data;
|
||||
const installation = installQuery.data;
|
||||
const startAuth = useAtomCommand(serverEnvironment.startProviderAuth, PRIVATE_COMMAND_OPTIONS);
|
||||
const completeAuth = useAtomCommand(
|
||||
serverEnvironment.completeProviderAuth,
|
||||
PRIVATE_COMMAND_OPTIONS,
|
||||
);
|
||||
const cancelAuth = useAtomCommand(serverEnvironment.cancelProviderAuth, PRIVATE_COMMAND_OPTIONS);
|
||||
const logout = useAtomCommand(serverEnvironment.logoutProviderAuth, PRIVATE_COMMAND_OPTIONS);
|
||||
const startInstall = useAtomCommand(
|
||||
serverEnvironment.startProviderInstall,
|
||||
PRIVATE_COMMAND_OPTIONS,
|
||||
);
|
||||
const cancelInstall = useAtomCommand(
|
||||
serverEnvironment.cancelProviderInstall,
|
||||
PRIVATE_COMMAND_OPTIONS,
|
||||
);
|
||||
const removeInstall = useAtomCommand(
|
||||
serverEnvironment.removeProviderInstallation,
|
||||
PRIVATE_COMMAND_OPTIONS,
|
||||
);
|
||||
const updateSettings = useAtomCommand(serverEnvironment.updateSettings, PRIVATE_COMMAND_OPTIONS);
|
||||
const [callbackUrl, setCallbackUrl] = useState("");
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const busyRef = useRef(false);
|
||||
const authActive =
|
||||
auth?.phase === "starting" || auth?.phase === "waiting" || auth?.phase === "verifying";
|
||||
const installActive =
|
||||
installation?.phase === "downloading" ||
|
||||
installation?.phase === "extracting" ||
|
||||
installation?.phase === "verifying";
|
||||
const controlsDisabled = busy || !isConnected || !canOperate;
|
||||
const {
|
||||
signedIn,
|
||||
showSignOut,
|
||||
message: authMessage,
|
||||
} = resolveProviderSignInPresentation(provider, auth);
|
||||
const authMethod = readAntigravityAuthMethod(
|
||||
config?.settings.providerInstances[instanceId]?.config ??
|
||||
(instanceId === "antigravity" ? config?.settings.providers.antigravity : undefined),
|
||||
);
|
||||
const usesBrowser = authMethod === "oauth-personal" || authMethod === "oauth-business";
|
||||
const methodLabel =
|
||||
ANTIGRAVITY_AUTH_METHODS.find((method) => method.value === authMethod)?.label ??
|
||||
"Google account";
|
||||
|
||||
// Return URLs never enter saved drafts, navigation params, or diagnostics.
|
||||
useEffect(() => {
|
||||
setCallbackUrl("");
|
||||
}, [auth?.flowId, auth?.phase]);
|
||||
|
||||
const perform = useCallback(
|
||||
async (command: () => Promise<AtomCommandResult<unknown, unknown>>, failureMessage: string) => {
|
||||
if (busyRef.current || !isConnected || !canOperate) return false;
|
||||
busyRef.current = true;
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
const result = await command();
|
||||
if (!AsyncResult.isSuccess(result)) {
|
||||
setError(failureMessage);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch {
|
||||
setError(failureMessage);
|
||||
return false;
|
||||
} finally {
|
||||
busyRef.current = false;
|
||||
setBusy(false);
|
||||
}
|
||||
},
|
||||
[canOperate, isConnected],
|
||||
);
|
||||
|
||||
const setEnabled = (enabled: boolean) => {
|
||||
const currentConfig = appAtomRegistry.get(serverEnvironment.configValueAtom(environmentId));
|
||||
const currentProvider = currentConfig?.providers.find((item) => item.instanceId === instanceId);
|
||||
if (!currentConfig || !currentProvider) return;
|
||||
const patch = antigravityEnabledPatch(currentConfig.settings, currentProvider, enabled);
|
||||
if (!patch) return;
|
||||
void perform(
|
||||
() => updateSettings({ environmentId, input: { patch } }),
|
||||
"Could not change this provider. Reconnect and try again.",
|
||||
);
|
||||
};
|
||||
|
||||
const title = provider?.displayName ?? "Antigravity";
|
||||
return (
|
||||
<View className="flex-1 bg-black">
|
||||
<NativeStackScreenOptions
|
||||
options={{
|
||||
title,
|
||||
headerShown: Platform.OS !== "android",
|
||||
headerTransparent: false,
|
||||
headerStyle: { backgroundColor: "#000" },
|
||||
headerTintColor: "#fff",
|
||||
contentStyle: { backgroundColor: "#000" },
|
||||
}}
|
||||
/>
|
||||
{Platform.OS === "android" ? (
|
||||
<AndroidScreenHeader title={title} onBack={() => navigation.goBack()} />
|
||||
) : null}
|
||||
<ScrollView
|
||||
className="flex-1"
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
contentContainerClassName="gap-5 px-5 pt-5"
|
||||
contentContainerStyle={{ paddingBottom: insets.bottom + 24 }}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
showsVerticalScrollIndicator={false}
|
||||
>
|
||||
<View className="flex-row items-center gap-3">
|
||||
<ProviderIcon provider="antigravity" size={28} />
|
||||
<Text className="min-w-0 flex-1 text-base text-white">{environmentLabel}</Text>
|
||||
</View>
|
||||
{!isConnected ? (
|
||||
<Text className="text-base text-white">
|
||||
Reconnect to this environment to continue setup.
|
||||
</Text>
|
||||
) : access.error ? (
|
||||
<View className="gap-3">
|
||||
<Text className="text-base text-white">Could not check your environment access.</Text>
|
||||
<SetupButton label="Retry" onPress={access.refresh} />
|
||||
</View>
|
||||
) : !access.data ? (
|
||||
<Text className="text-base text-white">Checking environment access.</Text>
|
||||
) : !canOperate ? (
|
||||
<Text className="text-base text-white">
|
||||
This connection cannot manage providers. Pair again with permission to operate this
|
||||
environment.
|
||||
</Text>
|
||||
) : null}
|
||||
{!config ? (
|
||||
<Text className="text-base text-white">Loading provider settings.</Text>
|
||||
) : !provider || provider.driver !== "antigravity" ? (
|
||||
<Text className="text-base text-white">
|
||||
This provider is not available on this environment.
|
||||
</Text>
|
||||
) : (
|
||||
<>
|
||||
<View className="gap-3">
|
||||
<Text className="text-base text-white">
|
||||
{provider.enabled ? "Enabled" : "Disabled"}
|
||||
{provider.installed
|
||||
? `. Installed${provider.version ? ` ${provider.version}` : ""}`
|
||||
: ". Not installed"}
|
||||
</Text>
|
||||
<SetupButton
|
||||
label={provider.enabled ? "Disable Antigravity" : "Enable Antigravity"}
|
||||
disabled={controlsDisabled}
|
||||
onPress={() => {
|
||||
if (!provider.enabled) {
|
||||
setEnabled(true);
|
||||
return;
|
||||
}
|
||||
Alert.alert(
|
||||
"Disable Antigravity?",
|
||||
`This stops Antigravity sessions on ${environmentLabel}. Google credentials stay saved.`,
|
||||
[
|
||||
{ text: "Cancel", style: "cancel" },
|
||||
{ text: "Disable", style: "destructive", onPress: () => setEnabled(false) },
|
||||
],
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
{provider.setup?.canInstall ? (
|
||||
<View className="gap-3 border-t border-white/20 pt-4">
|
||||
{installActive ? (
|
||||
<>
|
||||
<Text accessibilityLiveRegion="polite" className="text-base text-white">
|
||||
{installation.phase === "downloading"
|
||||
? `Downloading ${Math.round(installation.downloadedBytes / 1_048_576)}${installation.totalBytes === null ? "" : ` of ${Math.round(installation.totalBytes / 1_048_576)}`} MB`
|
||||
: installation.phase === "extracting"
|
||||
? "Extracting Antigravity files."
|
||||
: "Checking the Antigravity installation."}
|
||||
</Text>
|
||||
<SetupButton
|
||||
label="Cancel install"
|
||||
disabled={controlsDisabled || installation.operationId === null}
|
||||
onPress={() => {
|
||||
const operationId = installation.operationId;
|
||||
if (!operationId) return;
|
||||
void perform(
|
||||
() =>
|
||||
cancelInstall({ environmentId, input: { instanceId, operationId } }),
|
||||
"Could not cancel the install. Try again.",
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
) : !provider.installed ? (
|
||||
<SetupButton
|
||||
label={
|
||||
installation?.phase === "failed" || installation?.phase === "cancelled"
|
||||
? "Retry install"
|
||||
: "Install Antigravity"
|
||||
}
|
||||
primary
|
||||
disabled={controlsDisabled || authActive}
|
||||
onPress={() =>
|
||||
void perform(
|
||||
() => startInstall(target),
|
||||
"Could not start the install. Try again.",
|
||||
)
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
{installation?.message ? (
|
||||
<Text className="text-sm text-white">{installation.message}</Text>
|
||||
) : null}
|
||||
{installation?.canRemove && !installActive ? (
|
||||
<SetupButton
|
||||
label="Remove managed install"
|
||||
destructive
|
||||
disabled={controlsDisabled || authActive}
|
||||
onPress={() => {
|
||||
Alert.alert(
|
||||
"Remove the Antigravity install?",
|
||||
`This removes T3's managed install from ${environmentLabel}. Providers that use it will need it installed again. Google credentials and threads stay.`,
|
||||
[
|
||||
{ text: "Cancel", style: "cancel" },
|
||||
{
|
||||
text: "Remove",
|
||||
style: "destructive",
|
||||
onPress: () =>
|
||||
void perform(
|
||||
() => removeInstall(target),
|
||||
"Could not remove the managed install. Try again.",
|
||||
),
|
||||
},
|
||||
],
|
||||
);
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
{installQuery.error ? (
|
||||
<Text className="text-sm text-white">
|
||||
Install status is unavailable. Reconnect and try again.
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
) : !provider.installed ? (
|
||||
<Text className="text-base text-white">
|
||||
Antigravity cannot be installed on this environment. Use a supported server host or
|
||||
set an executable path in provider settings.
|
||||
</Text>
|
||||
) : null}
|
||||
{provider.setup?.canAuthenticate ? (
|
||||
<View className="gap-3 border-t border-white/20 pt-4">
|
||||
<Text className="text-lg font-t3-medium text-white">{methodLabel}</Text>
|
||||
<Text className="text-base text-white">
|
||||
{signedIn
|
||||
? "Signed in. Credentials stay on this environment."
|
||||
: provider.auth.status === "unknown"
|
||||
? "Sign-in has not been checked."
|
||||
: usesBrowser
|
||||
? "Sign in with the Google account you use for Antigravity."
|
||||
: "Connect with the credentials set in provider settings on web or desktop."}
|
||||
</Text>
|
||||
{authActive ? (
|
||||
<>
|
||||
<Text accessibilityLiveRegion="polite" className="text-base text-white">
|
||||
{auth.phase === "starting"
|
||||
? usesBrowser
|
||||
? "Starting Google sign-in."
|
||||
: "Checking credentials."
|
||||
: auth.phase === "verifying"
|
||||
? usesBrowser
|
||||
? "Checking Google sign-in."
|
||||
: "Checking credentials."
|
||||
: auth.authorizationUrl
|
||||
? "Complete sign-in in your browser."
|
||||
: "Sign-in is open on another client. Complete it there or wait for it to expire."}
|
||||
</Text>
|
||||
{auth.authorizationUrl && auth.phase === "waiting" ? (
|
||||
<>
|
||||
<SetupButton
|
||||
label="Open Google sign-in"
|
||||
primary
|
||||
disabled={controlsDisabled}
|
||||
onPress={() => {
|
||||
if (!auth.authorizationUrl) return;
|
||||
void tryOpenExternalUrl(auth.authorizationUrl, "provider-auth").then(
|
||||
(opened) => {
|
||||
if (!opened)
|
||||
setError(
|
||||
"Could not open Google sign-in. Copy the link and open it in your browser.",
|
||||
);
|
||||
},
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<SetupButton
|
||||
label="Copy sign-in link"
|
||||
disabled={controlsDisabled}
|
||||
onPress={() => {
|
||||
if (!auth.authorizationUrl) return;
|
||||
void tryCopyTextWithHaptic(auth.authorizationUrl, {
|
||||
target: "provider-sign-in-link",
|
||||
}).then((copied) => {
|
||||
if (!copied) setError("Could not copy the sign-in link.");
|
||||
});
|
||||
}}
|
||||
/>
|
||||
<Text className="text-sm leading-5 text-white">
|
||||
After sign-in, the browser will open a 127.0.0.1 address that cannot load
|
||||
on your phone. Copy that full address and paste it here.
|
||||
</Text>
|
||||
<TextInput
|
||||
accessibilityLabel="Google sign-in return URL"
|
||||
autoCapitalize="none"
|
||||
autoComplete="off"
|
||||
autoCorrect={false}
|
||||
className="min-h-12 rounded-none border border-white/25 bg-black px-3 py-3 text-base text-white"
|
||||
editable={!controlsDisabled}
|
||||
keyboardType="url"
|
||||
onChangeText={setCallbackUrl}
|
||||
placeholder="http://127.0.0.1:.../"
|
||||
textContentType="none"
|
||||
value={callbackUrl}
|
||||
/>
|
||||
<SetupButton
|
||||
label="Complete sign-in"
|
||||
primary
|
||||
disabled={
|
||||
controlsDisabled || callbackUrl.trim().length === 0 || !auth.flowId
|
||||
}
|
||||
onPress={() => {
|
||||
const flowId = auth.flowId;
|
||||
if (!flowId) return;
|
||||
const submittedUrl = callbackUrl.trim();
|
||||
setCallbackUrl("");
|
||||
void perform(
|
||||
() =>
|
||||
completeAuth({
|
||||
environmentId,
|
||||
input: { instanceId, flowId, callbackUrl: submittedUrl },
|
||||
}),
|
||||
"Could not complete Google sign-in. Check the return URL and try again.",
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
{auth.expiresAt ? (
|
||||
<Text className="text-sm text-white">
|
||||
Sign-in expires at{" "}
|
||||
{new Date(auth.expiresAt).toLocaleTimeString([], {
|
||||
hour: "numeric",
|
||||
minute: "2-digit",
|
||||
})}
|
||||
.
|
||||
</Text>
|
||||
) : null}
|
||||
{auth.flowId ? (
|
||||
<SetupButton
|
||||
label="Cancel sign-in"
|
||||
disabled={controlsDisabled}
|
||||
onPress={() => {
|
||||
const flowId = auth.flowId;
|
||||
if (!flowId) return;
|
||||
setCallbackUrl("");
|
||||
void perform(
|
||||
() => cancelAuth({ environmentId, input: { instanceId, flowId } }),
|
||||
"Could not cancel sign-in. Try again.",
|
||||
);
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
) : showSignOut ? (
|
||||
<SetupButton
|
||||
label={usesBrowser ? "Sign out of Google" : "Disconnect"}
|
||||
destructive
|
||||
disabled={controlsDisabled}
|
||||
onPress={() => {
|
||||
Alert.alert(
|
||||
usesBrowser ? "Sign out of Google?" : "Disconnect Antigravity?",
|
||||
`This stops Antigravity sessions for ${title} on ${environmentLabel}. Threads and files stay.`,
|
||||
[
|
||||
{ text: "Cancel", style: "cancel" },
|
||||
{
|
||||
text: "Sign out",
|
||||
style: "destructive",
|
||||
onPress: () =>
|
||||
void perform(
|
||||
() => logout(target),
|
||||
"Could not sign out of Google. Try again.",
|
||||
),
|
||||
},
|
||||
],
|
||||
);
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<SetupButton
|
||||
label={
|
||||
usesBrowser
|
||||
? auth?.phase === "failed" || auth?.phase === "cancelled"
|
||||
? "Retry Google sign-in"
|
||||
: "Sign in with Google"
|
||||
: auth?.phase === "failed" || auth?.phase === "cancelled"
|
||||
? "Retry connection"
|
||||
: "Connect"
|
||||
}
|
||||
primary
|
||||
disabled={
|
||||
controlsDisabled ||
|
||||
!provider.enabled ||
|
||||
!provider.installed ||
|
||||
installActive ||
|
||||
authQuery.isPending
|
||||
}
|
||||
onPress={() =>
|
||||
void perform(
|
||||
() => startAuth(target),
|
||||
"Could not start Google sign-in. Try again.",
|
||||
)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{!provider.enabled && !signedIn ? (
|
||||
<Text className="text-sm text-white">Enable Antigravity to sign in.</Text>
|
||||
) : !provider.installed && !signedIn ? (
|
||||
<Text className="text-sm text-white">Install Antigravity to sign in.</Text>
|
||||
) : null}
|
||||
{authMessage ? <Text className="text-sm text-white">{authMessage}</Text> : null}
|
||||
{authQuery.error ? (
|
||||
<Text className="text-sm text-white">
|
||||
Sign-in status is unavailable. Reconnect and try again.
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
) : null}
|
||||
{provider.message ? (
|
||||
<Text className="text-sm text-white">{provider.message}</Text>
|
||||
) : null}
|
||||
</>
|
||||
)}
|
||||
{error ? (
|
||||
<Text accessibilityRole="alert" className="text-base text-red-400">
|
||||
{error}
|
||||
</Text>
|
||||
) : null}
|
||||
{busy ? (
|
||||
<Text accessibilityLiveRegion="polite" className="text-sm text-white">
|
||||
Waiting for the environment.
|
||||
</Text>
|
||||
) : null}
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,159 +0,0 @@
|
||||
import {
|
||||
DEFAULT_SERVER_SETTINGS,
|
||||
ProviderDriverKind,
|
||||
ProviderInstanceId,
|
||||
ServerProvider,
|
||||
resolveProviderInstanceEnabled,
|
||||
} from "@t3tools/contracts";
|
||||
import * as Schema from "effect/Schema";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { antigravityEnabledPatch, resolveProviderSignInPresentation } from "./provider-setup-state";
|
||||
|
||||
const provider = Schema.decodeSync(ServerProvider)({
|
||||
instanceId: "antigravity",
|
||||
driver: "antigravity",
|
||||
enabled: false,
|
||||
installed: false,
|
||||
version: null,
|
||||
status: "disabled",
|
||||
auth: { status: "unauthenticated" },
|
||||
checkedAt: "2026-09-02T00:00:00.000Z",
|
||||
models: [],
|
||||
});
|
||||
|
||||
describe("resolveProviderSignInPresentation", () => {
|
||||
const completedFlow = { phase: "succeeded", message: "Google sign-in is complete." } as const;
|
||||
|
||||
it("offers sign-in after saved credentials expire, even if the old flow succeeded", () => {
|
||||
expect(
|
||||
resolveProviderSignInPresentation(
|
||||
{
|
||||
enabled: true,
|
||||
auth: { status: "authenticated" },
|
||||
},
|
||||
completedFlow,
|
||||
),
|
||||
).toEqual({
|
||||
signedIn: true,
|
||||
showSignOut: true,
|
||||
message: completedFlow.message,
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveProviderSignInPresentation(
|
||||
{
|
||||
enabled: true,
|
||||
auth: { status: "unauthenticated" },
|
||||
},
|
||||
completedFlow,
|
||||
),
|
||||
).toEqual({
|
||||
signedIn: false,
|
||||
showSignOut: false,
|
||||
message: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("allows credential cleanup without claiming a disabled unknown account is signed in", () => {
|
||||
expect(
|
||||
resolveProviderSignInPresentation(
|
||||
{
|
||||
enabled: false,
|
||||
auth: { status: "unknown" },
|
||||
},
|
||||
completedFlow,
|
||||
),
|
||||
).toEqual({
|
||||
signedIn: false,
|
||||
showSignOut: true,
|
||||
message: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps progress while Google sign-in is still pending", () => {
|
||||
const flow = { phase: "verifying", message: "Checking Google sign-in." } as const;
|
||||
expect(
|
||||
resolveProviderSignInPresentation(
|
||||
{
|
||||
enabled: true,
|
||||
auth: { status: "unauthenticated" },
|
||||
},
|
||||
flow,
|
||||
),
|
||||
).toEqual({
|
||||
signedIn: false,
|
||||
showSignOut: false,
|
||||
message: flow.message,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("antigravityEnabledPatch", () => {
|
||||
it("enables a legacy instance without losing its executable path or models", () => {
|
||||
const settings = {
|
||||
...DEFAULT_SERVER_SETTINGS,
|
||||
providers: {
|
||||
...DEFAULT_SERVER_SETTINGS.providers,
|
||||
antigravity: {
|
||||
...DEFAULT_SERVER_SETTINGS.providers.antigravity,
|
||||
enabled: false,
|
||||
binaryPath: "/opt/google/agy-acp",
|
||||
customModels: ["gemini-native"],
|
||||
},
|
||||
},
|
||||
};
|
||||
const patch = antigravityEnabledPatch(settings, provider, true);
|
||||
const instance = patch?.providerInstances?.[provider.instanceId];
|
||||
|
||||
expect(instance).toMatchObject({
|
||||
enabled: true,
|
||||
config: { binaryPath: "/opt/google/agy-acp", customModels: ["gemini-native"] },
|
||||
});
|
||||
expect(instance?.config).not.toHaveProperty("enabled");
|
||||
expect(instance && resolveProviderInstanceEnabled(instance)).toBe(true);
|
||||
expect(settings.providers.antigravity.enabled).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps separate accounts and environment overrides when enabling a custom instance", () => {
|
||||
const workId = ProviderInstanceId.make("google_work");
|
||||
const personalId = ProviderInstanceId.make("google_personal");
|
||||
const personal = { driver: ProviderDriverKind.make("antigravity"), enabled: true };
|
||||
const settings = {
|
||||
...DEFAULT_SERVER_SETTINGS,
|
||||
providerInstances: {
|
||||
[personalId]: personal,
|
||||
[workId]: {
|
||||
driver: ProviderDriverKind.make("antigravity"),
|
||||
displayName: "Work Google",
|
||||
enabled: false,
|
||||
config: { enabled: false, binaryPath: "/work/agy-acp", futureSetting: "keep" },
|
||||
environment: [{ name: "WORK_PROXY", value: "http://proxy", sensitive: false }],
|
||||
},
|
||||
},
|
||||
};
|
||||
const patch = antigravityEnabledPatch(settings, { ...provider, instanceId: workId }, true);
|
||||
|
||||
expect(patch?.providerInstances?.[personalId]).toBe(personal);
|
||||
expect(patch?.providerInstances?.[workId]).toMatchObject({
|
||||
displayName: "Work Google",
|
||||
enabled: true,
|
||||
config: { binaryPath: "/work/agy-acp", futureSetting: "keep" },
|
||||
environment: [{ name: "WORK_PROXY", value: "http://proxy", sensitive: false }],
|
||||
});
|
||||
expect(patch?.providers).toBeUndefined();
|
||||
});
|
||||
|
||||
it("does not change a different driver", () => {
|
||||
expect(
|
||||
antigravityEnabledPatch(
|
||||
DEFAULT_SERVER_SETTINGS,
|
||||
{
|
||||
...provider,
|
||||
driver: ProviderDriverKind.make("codex"),
|
||||
},
|
||||
true,
|
||||
),
|
||||
).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -1,76 +0,0 @@
|
||||
import {
|
||||
ANTIGRAVITY_AUTH_METHODS,
|
||||
type AntigravityAuthMethod,
|
||||
DEFAULT_SERVER_SETTINGS,
|
||||
type ProviderAuthState,
|
||||
type ServerProvider,
|
||||
type ServerSettings,
|
||||
type ServerSettingsPatch,
|
||||
} from "@t3tools/contracts";
|
||||
|
||||
/** Read the configured method from an instance config. Unknown values fall back to personal. */
|
||||
export function readAntigravityAuthMethod(config: unknown): AntigravityAuthMethod {
|
||||
const value =
|
||||
config !== null && typeof config === "object" && "authMethod" in config
|
||||
? config.authMethod
|
||||
: undefined;
|
||||
return (
|
||||
ANTIGRAVITY_AUTH_METHODS.find((method) => method.value === value)?.value ?? "oauth-personal"
|
||||
);
|
||||
}
|
||||
|
||||
/** A completed sign-in flow does not prove that saved credentials are still valid. */
|
||||
export function resolveProviderSignInPresentation(
|
||||
provider: Pick<ServerProvider, "enabled" | "auth"> | undefined,
|
||||
flow: Pick<ProviderAuthState, "phase" | "message"> | null,
|
||||
) {
|
||||
const signedIn = provider?.auth.status === "authenticated";
|
||||
return {
|
||||
signedIn,
|
||||
showSignOut: signedIn || (provider?.enabled === false && provider.auth.status === "unknown"),
|
||||
message: flow?.phase === "succeeded" && !signedIn ? null : (flow?.message ?? null),
|
||||
};
|
||||
}
|
||||
|
||||
/** Keep one enabled flag when a legacy provider becomes an explicit instance. */
|
||||
export function antigravityEnabledPatch(
|
||||
settings: ServerSettings,
|
||||
provider: ServerProvider,
|
||||
enabled: boolean,
|
||||
): ServerSettingsPatch | null {
|
||||
if (provider.driver !== "antigravity") return null;
|
||||
|
||||
const { enabled: _legacyEnabled, ...legacyConfig } = settings.providers.antigravity;
|
||||
const instance = settings.providerInstances[provider.instanceId] ?? {
|
||||
driver: provider.driver,
|
||||
config: legacyConfig,
|
||||
};
|
||||
const config =
|
||||
instance.config !== null &&
|
||||
typeof instance.config === "object" &&
|
||||
!Array.isArray(instance.config)
|
||||
? Object.fromEntries(Object.entries(instance.config).filter(([key]) => key !== "enabled"))
|
||||
: instance.config;
|
||||
|
||||
return {
|
||||
...(provider.instanceId === "antigravity"
|
||||
? { providers: { antigravity: DEFAULT_SERVER_SETTINGS.providers.antigravity } }
|
||||
: {}),
|
||||
providerInstances: {
|
||||
...settings.providerInstances,
|
||||
[provider.instanceId]: { ...instance, enabled, config },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/** Setup remains available when the provider has no selectable models. */
|
||||
export function providerNeedsSetup(provider: ServerProvider): boolean {
|
||||
return (
|
||||
(provider.setup?.canAuthenticate === true || provider.setup?.canInstall === true) &&
|
||||
(!provider.enabled ||
|
||||
!provider.installed ||
|
||||
provider.auth.status !== "authenticated" ||
|
||||
provider.availability === "unavailable" ||
|
||||
provider.models.length === 0)
|
||||
);
|
||||
}
|
||||
@@ -904,7 +904,7 @@ export function NewTaskDraftScreen(props: {
|
||||
) {
|
||||
Alert.alert(
|
||||
"Antigravity model unavailable",
|
||||
"Open model settings to finish setup or choose another model.",
|
||||
"Set up Antigravity on web or desktop, or choose another model.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import type {
|
||||
ProviderOptionDescriptor,
|
||||
ProviderOptionSelection,
|
||||
RuntimeMode,
|
||||
ServerProvider,
|
||||
} from "@t3tools/contracts";
|
||||
import { useAtomValue } from "@effect/atom-react";
|
||||
import type { LegendListRenderItemProps } from "@legendapp/list/react-native";
|
||||
import { AnimatedLegendList } from "@legendapp/list/reanimated";
|
||||
import { HeaderHeightContext } from "@react-navigation/elements";
|
||||
@@ -52,11 +50,6 @@ import {
|
||||
} from "../../native/StackHeader";
|
||||
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
|
||||
import { serverEnvironment } from "../../state/server";
|
||||
import { ProviderSetupLink } from "../settings/ProviderSetupLink";
|
||||
import {
|
||||
SettingsProviderSetupRouteScreen,
|
||||
type ProviderSetupRouteParams,
|
||||
} from "../settings/SettingsProviderSetupRouteScreen";
|
||||
import { useAtomCommand } from "../../state/use-atom-command";
|
||||
import { useNewTaskFlow } from "./new-task-flow-provider";
|
||||
import {
|
||||
@@ -73,7 +66,6 @@ import {
|
||||
canCommitPendingModel,
|
||||
modelMatchesCatalogQuery,
|
||||
pendingModelAfterPress,
|
||||
providerSetupCandidates,
|
||||
providerSectionIsCollapsed,
|
||||
} from "./thread-settings-sheet-state";
|
||||
|
||||
@@ -446,7 +438,10 @@ function ThreadSettingsSessionProvider(
|
||||
const commitPendingModel = useCallback(() => {
|
||||
if (pendingModel) {
|
||||
if (!canCommitPendingModel(pendingModel, props.providerGroups)) {
|
||||
Alert.alert("Model unavailable", "Complete provider setup or select another model.");
|
||||
Alert.alert(
|
||||
"Model unavailable",
|
||||
"Set up this provider on web or desktop, or select another model.",
|
||||
);
|
||||
return false;
|
||||
}
|
||||
void Haptics.selectionAsync();
|
||||
@@ -581,11 +576,6 @@ type ThreadSettingsCatalogItem =
|
||||
readonly isFirst: boolean;
|
||||
readonly isLast: boolean;
|
||||
}
|
||||
| {
|
||||
readonly kind: "setup";
|
||||
readonly key: string;
|
||||
readonly provider: ServerProvider;
|
||||
}
|
||||
| {
|
||||
readonly kind: "empty";
|
||||
readonly key: "empty";
|
||||
@@ -795,37 +785,20 @@ function ThreadSettingsOptionsItem(props: {
|
||||
/** One native scroll owner for the model catalog and its related settings. */
|
||||
function ThreadSettingsMainContent(props: {
|
||||
readonly onOpenSubmenu: (submenu: ThreadSettingsSubmenuPage) => void;
|
||||
readonly onOpenProviderSetup: (instanceId: ProviderInstanceId) => void;
|
||||
}) {
|
||||
const session = useThreadSettingsSession();
|
||||
const config = useAtomValue(serverEnvironment.configValueAtom(session.environmentId));
|
||||
const catalogItems = useThreadSettingsCatalogItems(session);
|
||||
const [animationsReady, setAnimationsReady] = useState(false);
|
||||
const nativeHeaderHeight = use(HeaderHeightContext) ?? 0;
|
||||
const hasActiveCatalogFilter =
|
||||
session.providerFilter !== null || session.searchQuery.trim().length > 0;
|
||||
const usesTransparentNativeHeader = Platform.OS === "ios" && NATIVE_LIQUID_GLASS_SUPPORTED;
|
||||
const setupProviders = useMemo(
|
||||
() =>
|
||||
providerSetupCandidates({
|
||||
providers: config?.providers ?? [],
|
||||
instanceId: session.providerInstanceId,
|
||||
providerFilter: session.providerFilter,
|
||||
query: session.searchQuery,
|
||||
}),
|
||||
[config?.providers, session.providerInstanceId, session.providerFilter, session.searchQuery],
|
||||
);
|
||||
const listItems = useMemo<ReadonlyArray<ThreadSettingsCatalogItem>>(
|
||||
() => [
|
||||
...(catalogItems.length === 0 ? ([{ kind: "empty", key: "empty" }] as const) : catalogItems),
|
||||
...setupProviders.map((provider) => ({
|
||||
kind: "setup" as const,
|
||||
key: `setup:${provider.instanceId}`,
|
||||
provider,
|
||||
})),
|
||||
{ kind: "options", key: "options" },
|
||||
],
|
||||
[catalogItems, setupProviders],
|
||||
[catalogItems],
|
||||
);
|
||||
const renderCatalogItem = useCallback(
|
||||
(itemProps: LegendListRenderItemProps<ThreadSettingsCatalogItem>) => {
|
||||
@@ -842,13 +815,6 @@ function ThreadSettingsMainContent(props: {
|
||||
option={item.option}
|
||||
/>
|
||||
);
|
||||
} else if (item.kind === "setup") {
|
||||
content = (
|
||||
<ProviderSetupLink
|
||||
provider={item.provider}
|
||||
onPress={() => props.onOpenProviderSetup(item.provider.instanceId)}
|
||||
/>
|
||||
);
|
||||
} else if (item.kind === "empty") {
|
||||
content = (
|
||||
<View className="items-center px-8 py-14">
|
||||
@@ -876,7 +842,7 @@ function ThreadSettingsMainContent(props: {
|
||||
</Animated.View>
|
||||
);
|
||||
},
|
||||
[animationsReady, hasActiveCatalogFilter, props.onOpenProviderSetup, props.onOpenSubmenu],
|
||||
[animationsReady, hasActiveCatalogFilter, props.onOpenSubmenu],
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -1002,7 +968,6 @@ function ThreadSettingsChoiceContent(props: {
|
||||
type ThreadSettingsPickerStackParams = {
|
||||
ThreadSettingsModels: undefined;
|
||||
ThreadSettingsChoice: ThreadSettingsSubmenuPage & { readonly title: string };
|
||||
ThreadSettingsProviderSetup: ProviderSetupRouteParams;
|
||||
};
|
||||
|
||||
type ThreadSettingsPickerPresentation = {
|
||||
@@ -1146,13 +1111,6 @@ function ThreadSettingsModelsScreen() {
|
||||
}}
|
||||
/>
|
||||
<ThreadSettingsMainContent
|
||||
onOpenProviderSetup={(instanceId) => {
|
||||
if (!session.environmentId) return;
|
||||
navigation.navigate("ThreadSettingsProviderSetup", {
|
||||
environmentId: session.environmentId,
|
||||
instanceId,
|
||||
});
|
||||
}}
|
||||
onOpenSubmenu={(submenu) => {
|
||||
const title =
|
||||
submenu.kind === "runtime"
|
||||
@@ -1287,11 +1245,6 @@ function ThreadSettingsPickerNavigator(props: ThreadSettingsPickerPresentation)
|
||||
component={ThreadSettingsChoiceScreen}
|
||||
options={({ route }) => ({ title: route.params.title })}
|
||||
/>
|
||||
<ThreadSettingsPickerStack.Screen
|
||||
name="ThreadSettingsProviderSetup"
|
||||
component={SettingsProviderSetupRouteScreen}
|
||||
options={{ title: "Antigravity" }}
|
||||
/>
|
||||
</ThreadSettingsPickerStack.Navigator>
|
||||
</ThreadSettingsPickerPresentationContext.Provider>
|
||||
);
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
ProviderInstanceId,
|
||||
ServerProvider,
|
||||
type ProviderOptionSelection,
|
||||
} from "@t3tools/contracts";
|
||||
import * as Schema from "effect/Schema";
|
||||
import { ProviderInstanceId, type ProviderOptionSelection } from "@t3tools/contracts";
|
||||
|
||||
import type { ModelOption } from "../../lib/modelOptions";
|
||||
import {
|
||||
canCommitPendingModel,
|
||||
modelMatchesCatalogQuery,
|
||||
pendingModelAfterPress,
|
||||
providerSetupCandidates,
|
||||
} from "./thread-settings-sheet-state";
|
||||
|
||||
function modelOption(
|
||||
@@ -123,77 +117,3 @@ describe("thread settings sheet state", () => {
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
const decodeServerProvider = Schema.decodeSync(ServerProvider);
|
||||
|
||||
function setupProvider(overrides: Partial<ServerProvider> = {}): ServerProvider {
|
||||
return decodeServerProvider({
|
||||
instanceId: "antigravity",
|
||||
driver: "antigravity",
|
||||
displayName: "Antigravity",
|
||||
enabled: false,
|
||||
installed: false,
|
||||
version: null,
|
||||
status: "disabled",
|
||||
auth: { status: "unauthenticated" },
|
||||
checkedAt: "2026-09-02T00:00:00.000Z",
|
||||
setup: { canAuthenticate: true, canInstall: true },
|
||||
models: [],
|
||||
...overrides,
|
||||
});
|
||||
}
|
||||
|
||||
describe("providerSetupCandidates", () => {
|
||||
const unfiltered = { providerFilter: null, query: "" };
|
||||
|
||||
it("offers setup without a selectable model and after sign-out", () => {
|
||||
const disabled = setupProvider();
|
||||
const signedOut = setupProvider({ enabled: true, installed: true });
|
||||
|
||||
expect(providerSetupCandidates({ providers: [disabled], ...unfiltered })).toEqual([disabled]);
|
||||
expect(providerSetupCandidates({ providers: [signedOut], ...unfiltered })).toEqual([signedOut]);
|
||||
});
|
||||
|
||||
it("uses the selected environment's status for identical instance IDs", () => {
|
||||
const offlineAccount = setupProvider();
|
||||
const readyAccount = setupProvider({
|
||||
enabled: true,
|
||||
installed: true,
|
||||
auth: { status: "authenticated" },
|
||||
models: [{ slug: "gemini-native", name: "Gemini", isCustom: false, capabilities: null }],
|
||||
});
|
||||
|
||||
expect(providerSetupCandidates({ providers: [offlineAccount], ...unfiltered })).toHaveLength(1);
|
||||
expect(providerSetupCandidates({ providers: [readyAccount], ...unfiltered })).toEqual([]);
|
||||
});
|
||||
|
||||
it("limits existing threads to their provider and respects search", () => {
|
||||
const personal = setupProvider();
|
||||
const work = setupProvider({
|
||||
instanceId: ProviderInstanceId.make("google_work"),
|
||||
displayName: "Work Google",
|
||||
});
|
||||
|
||||
expect(
|
||||
providerSetupCandidates({
|
||||
providers: [personal, work],
|
||||
...unfiltered,
|
||||
instanceId: work.instanceId,
|
||||
}),
|
||||
).toEqual([work]);
|
||||
expect(
|
||||
providerSetupCandidates({
|
||||
providers: [personal, work],
|
||||
providerFilter: work.instanceId,
|
||||
query: "work",
|
||||
}),
|
||||
).toEqual([work]);
|
||||
expect(
|
||||
providerSetupCandidates({
|
||||
providers: [personal, work],
|
||||
providerFilter: null,
|
||||
query: "no-match",
|
||||
}),
|
||||
).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -1,26 +1,4 @@
|
||||
import type { ProviderInstanceId, ServerProvider } from "@t3tools/contracts";
|
||||
import type { ModelOption, ProviderGroup } from "../../lib/modelOptions";
|
||||
import { providerNeedsSetup } from "../settings/provider-setup-state";
|
||||
|
||||
/** Read setup choices from this environment, not the selectable model list. */
|
||||
export function providerSetupCandidates(input: {
|
||||
readonly providers: ReadonlyArray<ServerProvider>;
|
||||
readonly instanceId?: ProviderInstanceId;
|
||||
readonly providerFilter: string | null;
|
||||
readonly query: string;
|
||||
}): ReadonlyArray<ServerProvider> {
|
||||
const query = input.query.trim().toLocaleLowerCase();
|
||||
return input.providers.filter(
|
||||
(provider) =>
|
||||
providerNeedsSetup(provider) &&
|
||||
(input.instanceId === undefined || provider.instanceId === input.instanceId) &&
|
||||
(input.providerFilter === null || provider.instanceId === input.providerFilter) &&
|
||||
(query.length === 0 ||
|
||||
[provider.displayName ?? "", provider.driver, provider.instanceId].some((label) =>
|
||||
label.toLocaleLowerCase().includes(query),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
/** Match the terms a user can actually see or recognize in the model picker. */
|
||||
export function modelMatchesCatalogQuery(input: {
|
||||
@@ -53,7 +31,7 @@ export function pendingModelAfterPress(input: {
|
||||
return input.current?.key === input.pressed.key ? input.current : input.pressed;
|
||||
}
|
||||
|
||||
/** A model can disappear while its setup page is open inside the picker. */
|
||||
/** A model can disappear while the picker is open. */
|
||||
export function canCommitPendingModel(
|
||||
pending: ModelOption,
|
||||
groups: ReadonlyArray<ProviderGroup>,
|
||||
|
||||
@@ -118,7 +118,7 @@ export function useCreateProjectThread() {
|
||||
const providerError = !serverConfig
|
||||
? "Provider settings are still loading. Try again."
|
||||
: isModelSelectionUnavailable(serverConfig, input.modelSelection)
|
||||
? "Antigravity model unavailable. Open model settings to finish setup or choose another model."
|
||||
? "Antigravity model unavailable. Set it up on web or desktop, or choose another model."
|
||||
: null;
|
||||
if (providerError !== null) {
|
||||
setPendingConnectionError(providerError);
|
||||
|
||||
@@ -276,7 +276,7 @@ export function useThreadComposerState() {
|
||||
) {
|
||||
Alert.alert(
|
||||
"Antigravity model unavailable",
|
||||
"Open model settings to finish setup or choose another model.",
|
||||
"Set up Antigravity on web or desktop, or choose another model.",
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -636,7 +636,7 @@ export function useThreadOutboxDrain(): void {
|
||||
if (isModelSelectionUnavailable(serverConfig, settings.modelSelection)) {
|
||||
return restoreQueuedMessage(
|
||||
queuedMessage,
|
||||
"Antigravity model unavailable. Open model settings to finish setup or choose another model.",
|
||||
"Antigravity model unavailable. Set it up on web or desktop, or choose another model.",
|
||||
);
|
||||
}
|
||||
const { reportFailure } = makeDeliveryHelpers(queuedMessage);
|
||||
@@ -729,7 +729,7 @@ export function useThreadOutboxDrain(): void {
|
||||
if (isModelSelectionUnavailable(currentConfig, settings.modelSelection)) {
|
||||
return restoreQueuedMessage(
|
||||
persistedMessage,
|
||||
"Antigravity model unavailable. Open model settings to finish setup or choose another model.",
|
||||
"Antigravity model unavailable. Set it up on web or desktop, or choose another model.",
|
||||
);
|
||||
}
|
||||
const sendSettings = resolveQueuedThreadSettings(
|
||||
@@ -811,7 +811,7 @@ export function useThreadOutboxDrain(): void {
|
||||
if (isModelSelectionUnavailable(serverConfig, settings.modelSelection)) {
|
||||
return restoreQueuedMessage(
|
||||
queuedMessage,
|
||||
"Antigravity model unavailable. Open model settings to finish setup or choose another model.",
|
||||
"Antigravity model unavailable. Set it up on web or desktop, or choose another model.",
|
||||
);
|
||||
}
|
||||
let prepared: PreparedTurnAttachments;
|
||||
@@ -855,7 +855,7 @@ export function useThreadOutboxDrain(): void {
|
||||
if (isModelSelectionUnavailable(currentConfig, settings.modelSelection)) {
|
||||
return restoreQueuedMessage(
|
||||
persistedMessage,
|
||||
"Antigravity model unavailable. Open model settings to finish setup or choose another model.",
|
||||
"Antigravity model unavailable. Set it up on web or desktop, or choose another model.",
|
||||
);
|
||||
}
|
||||
const sendSettings = resolveQueuedThreadSettings(
|
||||
|
||||
@@ -12,16 +12,13 @@ not sign in this T3 Code provider.
|
||||
## Set up Antigravity
|
||||
|
||||
On web or desktop, open **Settings** > **Providers**, select the device that runs your project,
|
||||
then select **Antigravity**. On mobile, open **Settings** > **Environments**, expand the
|
||||
environment, then choose **Set up Antigravity**. An existing setup shows **Manage Antigravity**.
|
||||
The model picker can open setup for the selected environment too.
|
||||
then select **Antigravity**. Provider setup is not available in the mobile app.
|
||||
|
||||
1. Choose **Enable Antigravity**. Antigravity is off by default.
|
||||
2. Choose **Install Antigravity**. T3 Code downloads the official runtime from Google to that
|
||||
environment. Installation continues if you leave the page or reconnect.
|
||||
3. Choose **Sign in with Google**.
|
||||
4. Choose **Open sign-in page** on web or desktop, or **Open Google sign-in** on mobile. You can
|
||||
use **Copy sign-in link** to open it in another browser.
|
||||
4. Choose **Open sign-in page**. You can use **Copy sign-in link** to open it in another browser.
|
||||
5. Complete Google sign-in. Use the account you use for Antigravity.
|
||||
6. Wait for T3 Code to confirm sign-in and load the model choices. Select an Antigravity model
|
||||
in the thread's model picker.
|
||||
@@ -36,8 +33,8 @@ machine as the T3 Code environment, sign-in can finish directly.
|
||||
|
||||
On a phone or another computer, the final page will usually fail to load. This is expected.
|
||||
Copy the full address from the browser, including everything after `?`, and paste it into the
|
||||
return URL field in T3 Code. Choose **Continue** on web or desktop, or **Complete sign-in** on
|
||||
mobile. Do not change the address to your server's hostname.
|
||||
return URL field in the web or desktop client where you started setup. Choose **Continue**. Do not
|
||||
change the address to your server's hostname.
|
||||
|
||||
Return to the same T3 Code client and environment where you started sign-in. Another client
|
||||
can see that sign-in is in progress, but cannot complete that attempt. The setup screen shows
|
||||
@@ -50,7 +47,7 @@ callback page alone does not prove account access.
|
||||
### Other sign-in methods
|
||||
|
||||
**Sign-in method** in the Antigravity provider settings on web or desktop selects how the
|
||||
agent authenticates. Mobile shows the selected method and its connect controls.
|
||||
agent authenticates.
|
||||
|
||||
| Method | What you enter | How it signs in |
|
||||
| -------------------------- | ---------------------------------------- | ------------------------------- |
|
||||
@@ -159,11 +156,11 @@ Each Antigravity provider instance has its own Google sign-in on its environment
|
||||
**Add provider** in web or desktop provider settings to create a separate instance for another
|
||||
account. To replace an instance's account, sign out first, then sign in again.
|
||||
|
||||
| Action | Result |
|
||||
| -------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Disable Antigravity | Stops the instance's sessions. Keeps Google sign-in, thread history, and files. |
|
||||
| Sign out of Google | Stops the instance's sessions and removes its saved Google credentials. Keeps thread history and files. |
|
||||
| Remove downloaded runtime on web or desktop, or Remove managed install on mobile | Removes the runtime shared by Antigravity instances on that environment. Keeps Google credentials, thread history, and files. |
|
||||
| Action | Result |
|
||||
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Disable Antigravity | Stops the instance's sessions. Keeps Google sign-in, thread history, and files. |
|
||||
| Sign out of Google | Stops the instance's sessions and removes its saved Google credentials. Keeps thread history and files. |
|
||||
| Remove downloaded runtime | Removes the runtime shared by Antigravity instances on that environment. Keeps Google credentials, thread history, and files. |
|
||||
|
||||
Send `/logout` by itself in an Antigravity thread to sign out that provider instance. This has
|
||||
the same effect as **Sign out of Google**, including stopping its other sessions.
|
||||
@@ -186,7 +183,8 @@ To check account access and reload models on web or desktop, open **Settings** >
|
||||
and select the circular arrow beside **Checked** at the top of the page. Its tooltip says
|
||||
**Refresh provider status**. On mobile, use **Refresh models** in the model picker.
|
||||
Refresh uses saved Google sign-in and does not open a login page. If sign-in is required,
|
||||
use the provider's setup controls. Automatic status checks verify the installation only.
|
||||
use the provider's setup controls on web or desktop. Automatic status checks verify the
|
||||
installation only.
|
||||
|
||||
The packaged runtime can be slow to start, especially on Windows. Health checks, model refresh,
|
||||
and sign-out each allow up to 90 seconds before reporting a timeout.
|
||||
|
||||
@@ -206,15 +206,14 @@ If reconnecting after an app update fails, retry the SSH launch once. The launch
|
||||
## Antigravity Google sign-in
|
||||
|
||||
Antigravity runs and saves its Google credentials on the selected environment. You can install
|
||||
it and sign in from a remote web, desktop, or mobile client without an SSH login.
|
||||
it and sign in from a remote web or desktop client without an SSH login.
|
||||
|
||||
Start in **Settings** > **Providers** on web or desktop. On mobile, open **Settings** >
|
||||
**Environments**, expand the environment, then choose **Set up Antigravity**.
|
||||
Start in **Settings** > **Providers**, select the environment, then choose **Antigravity**.
|
||||
Provider setup is not available in the mobile app.
|
||||
|
||||
After Google sign-in, a remote browser usually reaches a `127.0.0.1` page that cannot load.
|
||||
Copy that full address into the return URL field in the same T3 Code client. Choose
|
||||
**Continue** on web or desktop, or **Complete sign-in** on mobile. Keep the address unchanged.
|
||||
Do not paste the return URL into a thread or bug report.
|
||||
Copy that full address into the return URL field in the same T3 Code client and choose
|
||||
**Continue**. Keep the address unchanged. Do not paste the return URL into a thread or bug report.
|
||||
|
||||
See [Antigravity setup](./providers-antigravity.md) for installation, expiry, and account changes.
|
||||
|
||||
|
||||
Reference in new issue
Block a user