Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/mobile/src/connection/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@ export const updateBearerConnection = createRuntimeCommand(connectionAtomRuntime
Effect.flatMap((onboarding) => onboarding.updateBearer(input)),
),
});

export const reachesEnvironment = createRuntimeCommand(connectionAtomRuntime, {
label: "mobile:connection:reaches-environment",
execute: (input: { readonly host: string; readonly environmentId: EnvironmentId }) =>
ConnectionOnboarding.ConnectionOnboarding.pipe(
Effect.flatMap((onboarding) => onboarding.reaches(input)),
),
});
31 changes: 24 additions & 7 deletions apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { SymbolView } from "../../components/ui/AppSymbol";
import { hasCloudPublicConfig } from "../cloud/publicConfig";
import { CloudEnvironmentRows } from "./CloudEnvironmentRows";
import { autoConnectReport, devAutoConnectAttemptAtom } from "./devAutoConnect";
import { linkedEnvironmentPrefillAtom } from "./linkedEnvironmentPrefill";
import { splitEnvironmentSections } from "./environmentSections";
import { leaveSettingsPage } from "../settings/settings-navigation";
import { workspaceHasColumns } from "../layout/workspace/workspace-selection-store";
Expand All @@ -40,6 +41,8 @@ type ConnectionsNewRouteParams = {
readonly pairingUrl?: string;
readonly autoConnect?: string;
readonly routeFor?: EnvironmentId;
/** A linked machine this app chose to pair with; its details come from app state, never the link. */
readonly linked?: string;
};

export function ConnectionsNewRouteScreen({
Expand All @@ -48,30 +51,35 @@ export function ConnectionsNewRouteScreen({
const params = route.params ?? {};
// Dev-only prefill prevents production links from supplying an attacker-chosen host and token.
const routePairingUrl = __DEV__ ? (params.pairingUrl?.trim() ?? "") : "";
const known = useAtomValue(linkedEnvironmentPrefillAtom);
const linked = known !== null && known.environmentId === params.linked ? known : null;
// A new prefill link replaces whatever the form held.
return (
<PairingForm
key={routePairingUrl}
key={`${routePairingUrl}:${linked?.environmentId ?? ""}`}
routePairingUrl={routePairingUrl}
routeFor={params.routeFor}
routeFor={params.routeFor ?? linked?.environmentId}
linked={linked}
/>
);
}

function PairingForm({
routePairingUrl,
routeFor,
linked,
}: {
readonly routePairingUrl: string;
readonly routeFor: EnvironmentId | undefined;
readonly linked: { readonly label: string; readonly host: string | null } | null;
}) {
const gt = useGT();
const { connectionPairingUrl, onChangeConnectionPairingUrl, onConnectPress } =
useRemoteConnections();
const navigation = useNavigation();
const insets = useSafeAreaInsets();
const [initialPairing] = useState(() => parsePairingUrl(routePairingUrl || connectionPairingUrl));
const [hostInput, setHostInput] = useState(initialPairing.host);
const [hostInput, setHostInput] = useState(linked?.host ?? initialPairing.host);
const [codeInput, setCodeInput] = useState(initialPairing.code);
const [isSubmitting, setIsSubmitting] = useState(false);
const [submitError, setSubmitError] = useState<string | null>(null);
Expand Down Expand Up @@ -188,7 +196,11 @@ function PairingForm({

return (
<SettingsScreen
title={gt("Add environment")}
title={
linked
? gt("Connect to {environment}", { environment: linked.label })
: gt("Add environment")
}
actions={[
{
accessibilityLabel: connecting
Expand Down Expand Up @@ -263,9 +275,14 @@ function PairingForm({
)}
>
{pairingConnectionError ??
gt(
"For machines on your local network or tailnet. The machine keeps its own provider credentials.",
)}
(linked
? gt(
"Create a pairing code on {environment}, in its Settings → Sharing & access or with `t3 auth pairing create`, and enter it here.",
{ environment: linked.label },
)
: gt(
"For machines on your local network or tailnet. The machine keeps its own provider credentials.",
))}
</Text>
</View>

Expand Down
12 changes: 12 additions & 0 deletions apps/mobile/src/features/connection/linkedEnvironmentPrefill.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { EnvironmentId } from "@t3tools/contracts";
import { Atom } from "effect/reactivity";

/**
* A linked machine the add-environment screen opens for, with what the environment that links to
* it said about it. Set only by this app; a route names the machine and never supplies an address.
*/
export const linkedEnvironmentPrefillAtom = Atom.make<{
readonly environmentId: EnvironmentId;
readonly label: string;
readonly host: string | null;
} | null>(null).pipe(Atom.withLabel("linked-environment-prefill"));
66 changes: 63 additions & 3 deletions apps/mobile/src/features/threads/LinkedThreadSheet.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { useIsFocused, useNavigation, type StaticScreenProps } from "@react-navigation/native";
import {
StackActions,
useIsFocused,
useNavigation,
type StaticScreenProps,
} from "@react-navigation/native";
import {
isLinkedThreadWorking,
linkedThreadFailure,
Expand Down Expand Up @@ -31,11 +36,12 @@ import {
type ThreadFeedActivity,
type ThreadFeedEntry,
} from "../../lib/threadActivity";
import { useLinkedThreadView } from "../../state/linkedThread";
import { useConnectLinkedEnvironment, useLinkedThreadView } from "../../state/linkedThread";
import { peerLinkEnvironment } from "../../state/peerLinks";
import { useEnvironmentQuery } from "../../state/query";
import { useMarkdownPreviewStyles } from "../files/FileMarkdownPreview";
import { ReadOnlyComposerBar } from "./ReadOnlyComposerBar";
import { useOpenLinkedThread } from "./useOpenLinkedThread";

type LinkedThreadRouteParams = {
readonly viaEnvironmentId: string;
Expand Down Expand Up @@ -290,6 +296,21 @@ function LinkedThreadView(props: { readonly target: LinkedThreadTarget }) {
// Follows new items only while the reader is already at the end.
const atEnd = useRef(true);
const working = projection !== null && isLinkedThreadWorking(projection);
const connection = useConnectLinkedEnvironment(target);
const connectState = connection.state;
const openThread = useOpenLinkedThread();
const connect = async () => {
const outcome = await connection.connect();
if (outcome.type === "unreachable") return;
// This sheet closes either way: the thread opens where the app is now connected, or the
// add-environment screen takes its place.
if (outcome.type === "connected") {
navigation.goBack();
openThread({ environmentId: target.environmentId, threadId: target.threadId });
return;
}
navigation.dispatch(StackActions.replace("ConnectionsNew", { linked: target.environmentId }));
};
return (
<View collapsable={false} className="flex-1 bg-sheet">
<SheetHeader
Expand Down Expand Up @@ -355,7 +376,46 @@ function LinkedThreadView(props: { readonly target: LinkedThreadTarget }) {
className="gap-2 px-3 pt-1.5"
style={{ paddingBottom: Math.max(insets.bottom, 10) + 6 }}
>
<LinkedThreadComposer label={label} via={via} working={working} />
<LinkedThreadComposer
label={label}
via={via}
working={working}
action={
<Button
tone="secondary"
label={gt("Connect to interact")}
loading={connectState.phase === "connecting"}
onPress={() => void connect()}
/>
}
notice={
connectState.phase === "connecting" ? (
<Text
accessibilityLiveRegion="polite"
className="px-2 text-xs text-foreground-muted"
>
{gt("Connecting to {environment}...", { environment: label })}
</Text>
) : connectState.phase === "unreachable" ? (
<View
accessibilityLiveRegion="polite"
className="gap-1 rounded-2xl border border-danger-border bg-danger px-3.5 py-3"
>
<Text className="font-t3-medium text-sm text-danger-foreground">
{gt("{label} is not reachable from this device", {
label: connectState.label,
})}
</Text>
<Text className="text-sm text-danger-foreground">
<T>
Join a network it is on, such as its Tailscale network, and try again. You can
keep reading here.
</T>
</Text>
</View>
) : null
}
/>
</View>
</ScreenContent>
</View>
Expand Down
7 changes: 6 additions & 1 deletion apps/mobile/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,10 @@
"93e37fedae7eaa5b": "T3 Code auf {host} war zu beschäftigt, um zu antworten.",
"5c5941732d5dfac6": "Die Kopplungsdaten sind ungültig.",
"b8ca23ad7dda376e": "Diese Adresse führt zu {host}, einem anderen Rechner. Füge sie stattdessen als eigene Umgebung hinzu.",
"0c0150a90b582a7a": "Die URL der Umgebung ist ungültig.",
"693cb5c4fb40f109": "Nur gespeicherte Bearer-Umgebungen können bearbeitet werden.",
"5f5844b910cb1544": "Die gespeicherten Bearer-Zugangsdaten sind nicht verfügbar.",
"51b0133f1ed3cf5c": "Die Bezeichnung der Umgebung darf nicht leer sein.",
"0c0150a90b582a7a": "Die URL der Umgebung ist ungültig.",
"3aa15bfbe1920376": "Aktualisiere T3 Code auf {host} manuell; es kann sich nicht selbst aktualisieren.",
"71907f57b7ec64d5": "{host} ist nicht mit einer kompatiblen T3-Code-Version zurückgekommen.",
"e77ac580a4ddcd3b": "Verfügbar",
Expand Down Expand Up @@ -1966,11 +1966,13 @@
"28ae2c5e144a8c02": "Einstellungen öffnen",
"41e3df8a7b6d5d9d": "Ungültiger QR-Code",
"c28525066e29c024": "Der gescannte QR-Code wurde nicht erkannt.",
"8a333daf9b7fd03f": "Mit {environment} verbinden",
"53c162d8868a1d0e": "Umgebung hinzufügen",
"403dd9b445331000": "Wird verbunden",
"44bbcfd33b751bd6": "Adresse",
"42fd195574793f9e": "Code",
"51b31345c7bed6f0": "Kopplungscode",
"e1cb1c8599e84e26": "Erstelle auf {environment} einen Kopplungscode, in dessen Einstellungen → Freigabe & Zugriff oder mit `t3 auth pairing create`, und gib ihn hier ein.",
"7d6f419f8ab7f779": "Für Rechner in deinem lokalen Netzwerk oder Tailnet. Der Rechner behält seine eigenen Anbieter-Anmeldedaten.",
"36f32bd159bdc0d1": "QR-Code scannen",
"11fd02455d938901": "Scanne den Code von {command} oder aus den Verbindungseinstellungen am Desktop",
Expand Down Expand Up @@ -4155,8 +4157,11 @@
"009e2ca841fdc1ef": "diese Umgebung",
"596842e9e887232b": "Wird von {label} gelesen …",
"ff889c17671b40af": "Frühere laden",
"d49e5c66faa5d153": "Verbinden, um zu interagieren",
"93e690821c726e13": "{label} ist von diesem Gerät aus nicht erreichbar",
"0014ce0aaf1bd68a": "Schreibgeschützt",
"048b8a737af895ac": "Noch nichts in diesem Thread.",
"d148218513d9950a": "Tritt einem Netzwerk bei, in dem es sich befindet, etwa seinem Tailscale-Netzwerk, und versuche es erneut. Du kannst hier weiterlesen.",
"1410155e503a917f": "{denial} Wechsle den Modus dieses Threads, um fortzufahren.",
"81ceeceeb521bba6": "Zu {mode} wechseln",
"6ebd73c7bfb58bb7": "App",
Expand Down
7 changes: 6 additions & 1 deletion apps/mobile/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,10 @@
"93e37fedae7eaa5b": "T3 Code on {host} was too busy to answer.",
"5c5941732d5dfac6": "The pairing details are invalid.",
"b8ca23ad7dda376e": "That address reaches {host}, a different machine. Add it as its own environment instead.",
"0c0150a90b582a7a": "The environment URL is invalid.",
"693cb5c4fb40f109": "Only saved bearer environments can be edited.",
"5f5844b910cb1544": "The saved bearer credential is unavailable.",
"51b0133f1ed3cf5c": "Environment label cannot be empty.",
"0c0150a90b582a7a": "The environment URL is invalid.",
"3aa15bfbe1920376": "Update T3 Code on {host} manually; it cannot update itself.",
"71907f57b7ec64d5": "{host} did not come back on a compatible T3 Code version.",
"e77ac580a4ddcd3b": "Available",
Expand Down Expand Up @@ -1966,11 +1966,13 @@
"28ae2c5e144a8c02": "Open Settings",
"41e3df8a7b6d5d9d": "Invalid QR code",
"c28525066e29c024": "Scanned QR code was not recognized.",
"8a333daf9b7fd03f": "Connect to {environment}",
"53c162d8868a1d0e": "Add environment",
"403dd9b445331000": "Connecting",
"44bbcfd33b751bd6": "Address",
"42fd195574793f9e": "Code",
"51b31345c7bed6f0": "Pairing code",
"e1cb1c8599e84e26": "Create a pairing code on {environment}, in its Settings → Sharing & access or with `t3 auth pairing create`, and enter it here.",
"7d6f419f8ab7f779": "For machines on your local network or tailnet. The machine keeps its own provider credentials.",
"36f32bd159bdc0d1": "Scan QR code",
"11fd02455d938901": "Scan the code from {command} or desktop Connections settings",
Expand Down Expand Up @@ -4156,8 +4158,11 @@
"009e2ca841fdc1ef": "this environment",
"596842e9e887232b": "Reading from {label}…",
"ff889c17671b40af": "Load earlier",
"d49e5c66faa5d153": "Connect to interact",
"93e690821c726e13": "{label} is not reachable from this device",
"0014ce0aaf1bd68a": "Read-only",
"048b8a737af895ac": "Nothing in this thread yet.",
"d148218513d9950a": "Join a network it is on, such as its Tailscale network, and try again. You can keep reading here.",
"1410155e503a917f": "{denial} Switch this thread's mode to continue.",
"81ceeceeb521bba6": "Switch to {mode}",
"6ebd73c7bfb58bb7": "App",
Expand Down
7 changes: 6 additions & 1 deletion apps/mobile/src/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,10 @@
"93e37fedae7eaa5b": "T3 Code en {host} estaba demasiado ocupado para responder.",
"5c5941732d5dfac6": "Los datos de emparejamiento no son válidos.",
"b8ca23ad7dda376e": "Esa dirección lleva a {host}, otra máquina. Añádela como un entorno propio.",
"0c0150a90b582a7a": "La URL del entorno no es válida.",
"693cb5c4fb40f109": "Solo se pueden editar los entornos bearer guardados.",
"5f5844b910cb1544": "La credencial bearer guardada no está disponible.",
"51b0133f1ed3cf5c": "La etiqueta del entorno no puede estar vacía.",
"0c0150a90b582a7a": "La URL del entorno no es válida.",
"3aa15bfbe1920376": "Actualiza T3 Code en {host} manualmente; no puede actualizarse solo.",
"71907f57b7ec64d5": "{host} no volvió con una versión compatible de T3 Code.",
"e77ac580a4ddcd3b": "Disponible",
Expand Down Expand Up @@ -1966,11 +1966,13 @@
"28ae2c5e144a8c02": "Abrir Ajustes",
"41e3df8a7b6d5d9d": "Código QR no válido",
"c28525066e29c024": "No se reconoció el código QR escaneado.",
"8a333daf9b7fd03f": "Conectar con {environment}",
"53c162d8868a1d0e": "Añadir entorno",
"403dd9b445331000": "Conectando",
"44bbcfd33b751bd6": "Dirección",
"42fd195574793f9e": "Código",
"51b31345c7bed6f0": "Código de emparejamiento",
"e1cb1c8599e84e26": "Crea un código de emparejamiento en {environment}, en sus Ajustes → Compartir y acceso o con `t3 auth pairing create`, e introdúcelo aquí.",
"7d6f419f8ab7f779": "Para máquinas de tu red local o tailnet. La máquina conserva sus propias credenciales de proveedores.",
"36f32bd159bdc0d1": "Escanear código QR",
"11fd02455d938901": "Escanea el código de {command} o de los ajustes de Conexiones del escritorio",
Expand Down Expand Up @@ -4150,8 +4152,11 @@
"009e2ca841fdc1ef": "este entorno",
"596842e9e887232b": "Leyendo desde {label}…",
"ff889c17671b40af": "Cargar anteriores",
"d49e5c66faa5d153": "Conectar para interactuar",
"93e690821c726e13": "No se puede acceder a {label} desde este dispositivo",
"0014ce0aaf1bd68a": "Solo lectura",
"048b8a737af895ac": "Aún no hay nada en este hilo.",
"d148218513d9950a": "Únete a una red en la que esté, como su red de Tailscale, y vuelve a intentarlo. Puedes seguir leyendo aquí.",
"1410155e503a917f": "{denial} Cambia el modo de este hilo para continuar.",
"81ceeceeb521bba6": "Cambiar a {mode}",
"6ebd73c7bfb58bb7": "App",
Expand Down
7 changes: 6 additions & 1 deletion apps/mobile/src/i18n/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,10 @@
"93e37fedae7eaa5b": "T3 Code sur {host} était trop occupé pour répondre.",
"5c5941732d5dfac6": "Les informations d’appairage ne sont pas valides.",
"b8ca23ad7dda376e": "Cette adresse mène à {host}, une autre machine. Ajoutez-la plutôt comme environnement distinct.",
"0c0150a90b582a7a": "L’URL de l’environnement n’est pas valide.",
"693cb5c4fb40f109": "Seuls les environnements bearer enregistrés peuvent être modifiés.",
"5f5844b910cb1544": "Les identifiants bearer enregistrés ne sont pas disponibles.",
"51b0133f1ed3cf5c": "Le libellé de l’environnement ne peut pas être vide.",
"0c0150a90b582a7a": "L’URL de l’environnement n’est pas valide.",
"3aa15bfbe1920376": "Mettez à jour T3 Code sur {host} manuellement ; il ne peut pas se mettre à jour seul.",
"71907f57b7ec64d5": "{host} n’est pas revenu sur une version compatible de T3 Code.",
"e77ac580a4ddcd3b": "Disponible",
Expand Down Expand Up @@ -1966,11 +1966,13 @@
"28ae2c5e144a8c02": "Ouvrir les Réglages",
"41e3df8a7b6d5d9d": "Code QR non valide",
"c28525066e29c024": "Le code QR scanné n’a pas été reconnu.",
"8a333daf9b7fd03f": "Se connecter à {environment}",
"53c162d8868a1d0e": "Ajouter un environnement",
"403dd9b445331000": "Connexion",
"44bbcfd33b751bd6": "Adresse",
"42fd195574793f9e": "Code",
"51b31345c7bed6f0": "Code d’appairage",
"e1cb1c8599e84e26": "Créez un code d’appairage sur {environment}, dans ses Paramètres → Partage et accès ou avec `t3 auth pairing create`, puis saisissez-le ici.",
"7d6f419f8ab7f779": "Pour les machines de votre réseau local ou de votre tailnet. La machine garde ses propres identifiants de fournisseur.",
"36f32bd159bdc0d1": "Scanner un code QR",
"11fd02455d938901": "Scannez le code de {command} ou des paramètres Connexions du bureau",
Expand Down Expand Up @@ -4150,8 +4152,11 @@
"009e2ca841fdc1ef": "cet environnement",
"596842e9e887232b": "Lecture depuis {label}…",
"ff889c17671b40af": "Charger les précédents",
"d49e5c66faa5d153": "Se connecter pour interagir",
"93e690821c726e13": "{label} n’est pas accessible depuis cet appareil",
"0014ce0aaf1bd68a": "Lecture seule",
"048b8a737af895ac": "Rien dans ce fil pour l’instant.",
"d148218513d9950a": "Rejoignez un réseau sur lequel il se trouve, comme son réseau Tailscale, puis réessayez. Vous pouvez continuer à lire ici.",
"1410155e503a917f": "{denial} Changez le mode de ce fil pour continuer.",
"81ceeceeb521bba6": "Passer en {mode}",
"6ebd73c7bfb58bb7": "App",
Expand Down
Loading
Loading