Skip to content

Commit 0449cf3

Browse files
fix(web,mobile): offer link-and-move only to a session that may link this machine
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
1 parent f8ae190 commit 0449cf3

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎apps/mobile/src/features/threads/HandoffRequestCard.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useAtomValue } from "@effect/atom-react";
12
import {
23
HANDOFF_LINK_DEFAULT_ACCESS,
34
handoffLinkCandidates,
@@ -100,8 +101,11 @@ function PendingHandoffRequest(props: {
100101
);
101102
const options = targets.data?.options ?? [];
102103
// Machines this client is connected to that the thread's environment has no link to yet.
104+
// Linking is changed on this thread's machine too, which this session may not be allowed to.
105+
const mayLinkHere = useAtomValue(peerLinkEnvironment.link.permissionAtom(props.environmentId));
103106
const linkable = handoffLinkCandidates(useLinkableMachines(props.environmentId, true)).filter(
104-
(machine) => !options.some((option) => option.environmentId === machine.environmentId),
107+
(machine) =>
108+
mayLinkHere && !options.some((option) => option.environmentId === machine.environmentId),
105109
);
106110
const pickedLinkable = linkable.find((machine) => machine.environmentId === picked);
107111
// This device creates the link's code there, which its session must be allowed to.

‎apps/web/src/components/chat/HandoffRequestCard.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ function PendingHandoffRequest(props: {
9292
// Machines this client is connected to and may link the thread's environment to itself.
9393
const candidates = handoffLinkCandidates(useLinkableMachines(props.environmentId, true));
9494
const mayLink = useEnvironmentsWithScope(candidates, AuthAccessWriteScope);
95+
// Linking is changed on this thread's machine too, which this session may not be allowed to.
96+
const mayLinkHere = useAtomValue(peerLinkEnvironment.link.permissionAtom(props.environmentId));
9597
const linkable = candidates.filter(
9698
(machine) =>
99+
mayLinkHere &&
97100
mayLink.has(machine.environmentId) &&
98101
!options.some((option) => option.environmentId === machine.environmentId),
99102
);

0 commit comments

Comments
 (0)