Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
6a776e5
feat(web,mobile): take over a device an idle thread still holds
12ya Nov 8, 2026
1b15169
fix(server): only take a device over from a thread with no work in fl…
12ya Nov 8, 2026
4692840
revert(server): drop the idle-only takeover guard
12ya Nov 8, 2026
3cde288
feat(web,mobile): offer Take over while the holder is still running
12ya Nov 8, 2026
0c7a599
Merge branch 'main' into feat/device-takeover-prompt
12ya Nov 9, 2026
b715441
Merge remote-tracking branch 'github/main' into feat/device-takeover-…
maria-rcks Nov 10, 2026
8138144
fix(web,mobile): holder with pending background work reads as running
maria-rcks Nov 10, 2026
4422ed2
fix(web,mobile): name the holder thread in each Take over button
maria-rcks Nov 10, 2026
8fa225d
Merge branch 'main' into feat/device-takeover-prompt
12ya Nov 12, 2026
1ee9153
Merge branch 'main' into feat/device-takeover-prompt
12ya Nov 15, 2026
ab98312
Merge branch 'main' into feat/device-takeover-prompt
12ya Nov 15, 2026
8b725fd
Merge branch 'main' into feat/device-takeover-prompt
12ya Nov 16, 2026
88c0947
chore: merge main into device takeover branch
maria-rcks Nov 18, 2026
c129b3a
fix(web,mobile): preserve holder navigation and translate takeover copy
maria-rcks Nov 18, 2026
81afab2
fix(mobile): sync formatted takeover translation keys
maria-rcks Nov 18, 2026
9e75732
Merge branch 'main' into feat/device-takeover-prompt
12ya Nov 18, 2026
6b8fe38
Merge branch 'main' into feat/device-takeover-prompt
12ya Nov 19, 2026
ddaa961
Merge branch 'main' into feat/device-takeover-prompt
12ya Nov 20, 2026
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
115 changes: 112 additions & 3 deletions apps/mobile/src/features/devices/DevicePreviewRouteScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import { SheetCloseButton } from "../../components/ui/SheetHeader";
import { Button } from "../../components/ui/Button";
import * as Dialog from "../../components/ui/Dialog";
import { scopeThreadRef } from "@t3tools/client-runtime/environment";
import {
deviceToolVersionLabels,
deviceToolUpdateOwnership,
deviceToolUpdatePolicy,
otherThreadDeviceSessions,
} from "@t3tools/client-runtime/state/device";
import { useIsFocused, useNavigation, type StaticScreenProps } from "@react-navigation/native";
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
import { threadRuntimeIsActive } from "@t3tools/client-runtime/state/shell";
import { backgroundWorkHoldsCompletion } from "@t3tools/shared/orchestrationV2PendingBackgroundWork";
import {
StackActions,
useIsFocused,
useNavigation,
type StaticScreenProps,
} from "@react-navigation/native";
import { EnvironmentId, ThreadId, type DeviceSession } from "@t3tools/contracts";
import * as Cause from "effect/Cause";
import { msg, T, useGT } from "gt-react-native";
import { msg, T, useGT, Var } from "gt-react-native";
import { useEffect, useRef, useState, type RefObject } from "react";
import * as Haptics from "expo-haptics";
import { Accelerometer } from "expo-sensors";
Expand All @@ -36,6 +45,7 @@ import { deriveBottomControlInsets } from "../../lib/reserved-regions";
import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
import { uuidv4 } from "../../lib/uuid";
import { deviceEnvironment, useDeviceHubAccess } from "../../state/device";
import { useThreadShell } from "../../state/entities";
import { useEnvironmentQuery } from "../../state/query";
import { useAtomCommand } from "../../state/use-atom-command";
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
Expand Down Expand Up @@ -90,6 +100,7 @@ export function DevicePreviewScreen({
readonly initialDeviceKey?: string;
}) {
const embedded = onMaximize !== undefined;
const navigation = useNavigation();
const insets = useSafeAreaInsets();
// In a pane the stream sits below the pane's bar, which content otherwise slides under.
const barOverlap = useBarOverlap();
Expand All @@ -106,10 +117,14 @@ export function DevicePreviewScreen({
const [controlsVisible, setControlsVisible] = useState(true);
const retryHost = useAtomCommand(deviceEnvironment.list);
const shutdown = useAtomCommand(deviceEnvironment.shutdown, { reportFailure: false });
const close = useAtomCommand(deviceEnvironment.close, { reportFailure: false });
const streamRef = useRef<DeviceStreamRef>(null);
const state = useEnvironmentQuery(deviceEnvironment.state({ environmentId, input: {} }));
const previews = threadDevicePreviews(state.data, threadId);
const preview = selectedThreadDevicePreview(previews, selectedKey);
const holders = preview
? otherThreadDeviceSessions(state.data?.sessions ?? [], preview.session)
: [];
const onInputConnected = async (connected: boolean) => {
setInputConnected(connected);
if (!connected) setControlsVisible(true);
Expand Down Expand Up @@ -151,6 +166,32 @@ export function DevicePreviewScreen({
}
};

const takeOver = async (holder: DeviceSession) => {
const result = await close({
environmentId,
input: { threadId: holder.threadId, hostId: holder.hostId, deviceId: holder.deviceId },
});
if (result._tag === "Failure") {
Dialog.alert(gt("Could not take over device"), String(Cause.squash(result.cause)));
}
};
const holderBanners = holders.map((holder) => (
<DeviceHolderBanner
key={holder.threadId}
environmentId={environmentId}
holder={holder}
onOpenThread={() =>
navigation.dispatch(
(embedded ? StackActions.push : StackActions.replace)("Thread", {
environmentId,
threadId: holder.threadId,
}),
)
}
onTakeOver={() => takeOver(holder)}
/>
));

const controls: AppBarMenuItem[] = [
...(state.data?.hosts
.filter(
Expand Down Expand Up @@ -284,6 +325,9 @@ export function DevicePreviewScreen({
]}
/>
<View style={{ height: barOverlap }} />
{holderBanners.length > 0 ? (
<View className="gap-2 px-3 pb-2">{holderBanners}</View>
) : null}
</>
) : null}
{preview && focused && foreground ? (
Expand Down Expand Up @@ -351,6 +395,7 @@ export function DevicePreviewScreen({
/>
<DeviceOptionsMenu items={menuItems} />
</GlassSurface>
{holderBanners.length > 0 ? <View className="mt-2 gap-2">{holderBanners}</View> : null}
</View>
</Animated.View>
) : (
Expand All @@ -376,6 +421,70 @@ export function DevicePreviewScreen({
);
}

function DeviceHolderBanner(props: {
readonly environmentId: EnvironmentId;
readonly holder: DeviceSession;
readonly onOpenThread: () => void;
readonly onTakeOver: () => Promise<void>;
}) {
const gt = useGT();
const shell = useThreadShell(scopeThreadRef(props.environmentId, props.holder.threadId));
const running =
threadRuntimeIsActive(shell?.runtime) ||
backgroundWorkHoldsCompletion(shell?.pendingBackgroundTasks ?? []);
const [takingOver, setTakingOver] = useState(false);
const title = shell?.title.trim() || gt("another thread");
return (
<GlassSurface className="flex-row items-center gap-3 px-3 py-2">
<Pressable
accessibilityRole="link"
accessibilityLabel={gt("Open thread {title}", { title })}
className="min-w-0 flex-1"
onPress={props.onOpenThread}
>
<AppText numberOfLines={2} className="text-sm text-foreground-muted">
{running ? (
<T>
Busy in{" "}
<AppText className="font-t3-medium text-sm text-foreground">
<Var>{title}</Var>
</AppText>
, which is running.
</T>
) : shell ? (
<T>
Busy in{" "}
<AppText className="font-t3-medium text-sm text-foreground">
<Var>{title}</Var>
</AppText>
, which isn't running.
</T>
) : (
<T>
Busy in{" "}
<AppText className="font-t3-medium text-sm text-foreground">
<Var>{title}</Var>
</AppText>
.
</T>
)}
</AppText>
</Pressable>
<Button
label={gt("Take over")}
accessibilityLabel={gt("Take over from {title}", { title })}
tone="primary"
size="compact"
loading={takingOver}
onPress={() => {
setTakingOver(true);
void props.onTakeOver().finally(() => setTakingOver(false));
}}
/>
</GlassSurface>
);
}

function DeviceOptionsMenu({ items }: { readonly items: ReadonlyArray<AppBarMenuItem> }) {
const gt = useGT();
return (
Expand Down
44 changes: 44 additions & 0 deletions apps/mobile/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2039,6 +2039,7 @@
"9e33004237e3c6a0": "Verstanden",
"0cf35ae8d7452516": "Gerät konnte nicht heruntergefahren werden",
"94f8e4fd2497326d": "Versionen der Geräte-Tools",
"b632b6f918e8bd7b": "Gerät konnte nicht übernommen werden",
"84718257bae3bc62": "{host} erneut versuchen",
"30c35ac54f6f8a88": "Versionen der Geräte-Tools prüfen",
"67ac0604fc3d0a97": "Stream neu laden",
Expand All @@ -2054,7 +2055,50 @@
"9f69be831934bb6d": "Gerätesteuerung ausblenden",
"4dfe18eea6b9c818": "Gerätevorschau schließen",
"41bfb61ffe885a86": "Gerätesteuerung anzeigen",
"cfae7ef07c37220e": "einem anderen Thread",
"2025fc2a5f89a7fb": "Thread {title} öffnen",
"746c576ea195806b": "Übernehmen",
"23d5d026ee80963b": "Von {title} übernehmen",
"59235647923be335": "Geräteoptionen",
"4104bad7a6a8b8b7": [
"Belegt durch ",
{
"t": "AppText",
"i": 1,
"c": {
"i": 2,
"k": "_gt_value_2",
"v": "v"
}
},
", läuft gerade."
],
"337acff156b4268b": [
"Belegt durch ",
{
"t": "AppText",
"i": 1,
"c": {
"i": 2,
"k": "_gt_value_2",
"v": "v"
}
},
", läuft gerade nicht."
],
"d61c4ee92724bb14": [
"Belegt durch ",
{
"t": "AppText",
"i": 1,
"c": {
"i": 2,
"k": "_gt_value_2",
"v": "v"
}
},
"."
],
"a373590cbd15c434": "Verbindung zum Gerät wird hergestellt...",
"bf9ade51c568a251": "Geräte-Viewer konnte nicht starten. Verbinde dich erneut, um es noch einmal zu versuchen.",
"e51517909200c9ea": "Geräte-Viewer wurde beendet. Verbinde dich erneut, um es noch einmal zu versuchen.",
Expand Down
47 changes: 47 additions & 0 deletions apps/mobile/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2039,6 +2039,7 @@
"9e33004237e3c6a0": "Got it",
"0cf35ae8d7452516": "Could not shut down device",
"94f8e4fd2497326d": "Device tool versions",
"b632b6f918e8bd7b": "Could not take over device",
"84718257bae3bc62": "Retry {host}",
"30c35ac54f6f8a88": "Check device tool versions",
"67ac0604fc3d0a97": "Reload stream",
Expand All @@ -2054,7 +2055,53 @@
"9f69be831934bb6d": "Hide device controls",
"4dfe18eea6b9c818": "Close device preview",
"41bfb61ffe885a86": "Show device controls",
"cfae7ef07c37220e": "another thread",
"2025fc2a5f89a7fb": "Open thread {title}",
"746c576ea195806b": "Take over",
"23d5d026ee80963b": "Take over from {title}",
"59235647923be335": "Device options",
"4104bad7a6a8b8b7": [
"Busy in",
" ",
{
"t": "AppText",
"i": 1,
"c": {
"i": 2,
"k": "_gt_value_2",
"v": "v"
}
},
", which is running."
],
"337acff156b4268b": [
"Busy in",
" ",
{
"t": "AppText",
"i": 1,
"c": {
"i": 2,
"k": "_gt_value_2",
"v": "v"
}
},
", which isn't running."
],
"d61c4ee92724bb14": [
"Busy in",
" ",
{
"t": "AppText",
"i": 1,
"c": {
"i": 2,
"k": "_gt_value_2",
"v": "v"
}
},
"."
],
"a373590cbd15c434": "Connecting to device...",
"bf9ade51c568a251": "Device viewer could not start. Reconnect to try again.",
"e51517909200c9ea": "Device viewer stopped. Reconnect to try again.",
Expand Down
44 changes: 44 additions & 0 deletions apps/mobile/src/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2039,6 +2039,7 @@
"9e33004237e3c6a0": "Entendido",
"0cf35ae8d7452516": "No se pudo apagar el dispositivo",
"94f8e4fd2497326d": "Versiones de las herramientas de dispositivos",
"b632b6f918e8bd7b": "No se pudo tomar el control del dispositivo",
"84718257bae3bc62": "Reintentar {host}",
"30c35ac54f6f8a88": "Comprobar versiones de las herramientas de dispositivos",
"67ac0604fc3d0a97": "Recargar transmisión",
Expand All @@ -2054,7 +2055,50 @@
"9f69be831934bb6d": "Ocultar controles del dispositivo",
"4dfe18eea6b9c818": "Cerrar vista previa del dispositivo",
"41bfb61ffe885a86": "Mostrar controles del dispositivo",
"cfae7ef07c37220e": "otro hilo",
"2025fc2a5f89a7fb": "Abrir hilo {title}",
"746c576ea195806b": "Tomar control",
"23d5d026ee80963b": "Tomar control de {title}",
"59235647923be335": "Opciones del dispositivo",
"4104bad7a6a8b8b7": [
"En uso en ",
{
"t": "AppText",
"i": 1,
"c": {
"i": 2,
"k": "_gt_value_2",
"v": "v"
}
},
", que está en ejecución."
],
"337acff156b4268b": [
"En uso en ",
{
"t": "AppText",
"i": 1,
"c": {
"i": 2,
"k": "_gt_value_2",
"v": "v"
}
},
", que no está en ejecución."
],
"d61c4ee92724bb14": [
"En uso en ",
{
"t": "AppText",
"i": 1,
"c": {
"i": 2,
"k": "_gt_value_2",
"v": "v"
}
},
"."
],
"a373590cbd15c434": "Conectando con el dispositivo...",
"bf9ade51c568a251": "No se pudo iniciar el visor del dispositivo. Vuelve a conectarte para intentarlo de nuevo.",
"e51517909200c9ea": "El visor del dispositivo se detuvo. Vuelve a conectarte para intentarlo de nuevo.",
Expand Down
Loading
Loading