Skip to content

Commit 95d4da5

Browse files
robrab2000claude
andauthored
fix(clients): open a delegated child's approval on the environment it runs in (#28592)
Co-authored-by: Claude Fable 5.1 <[email protected]>
1 parent 46e90ba commit 95d4da5

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ function ThreadDetailBody(
772772
accessibilityLabel: `Open ${childInput.hasPendingApprovals ? "approval" : "question"} from ${childInput.title}`,
773773
onPress: () => {
774774
Keyboard.dismiss();
775-
openLinkedThread({ environmentId: props.environmentId, threadId: childInput.id });
775+
openLinkedThread({ environmentId: childInput.environmentId, threadId: childInput.id });
776776
},
777777
};
778778
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type {
2+
EnvironmentId,
23
OrchestrationV2PendingBackgroundTask,
34
OrchestrationV2ProviderGoal,
45
ThreadId,
@@ -34,7 +35,8 @@ import type { ThreadNowItem } from "./ThreadNow";
3435
export function childInputNowItem(input: {
3536
readonly childThreadInputs: ReadonlyArray<EnvironmentThreadShell>;
3637
readonly parentAwaitingUser: boolean;
37-
readonly onOpenThread: (threadId: ThreadId) => void;
38+
// A task delegated to a linked environment lives there, not where the parent runs.
39+
readonly onOpenThread: (threadId: ThreadId, environmentId: EnvironmentId) => void;
3840
}): (ThreadNowItem & { readonly waitingLabel: string }) | null {
3941
const { childThreadInputs, onOpenThread } = input;
4042
const first = childThreadInputs[0];
@@ -55,15 +57,15 @@ export function childInputNowItem(input: {
5557
<Fragment key={child.id}>
5658
{index > 0 ? " " : null}
5759
<span className="whitespace-nowrap">
58-
<InlineButton tone="muted" onClick={() => onOpenThread(child.id)}>
60+
<InlineButton tone="muted" onClick={() => onOpenThread(child.id, child.environmentId)}>
5961
{child.title}
6062
</InlineButton>
6163
{index < childThreadInputs.length - 1 ? "," : null}
6264
</span>
6365
</Fragment>
6466
)),
6567
actions: (
66-
<InlineButton onClick={() => onOpenThread(first.id)}>
68+
<InlineButton onClick={() => onOpenThread(first.id, first.environmentId)}>
6769
{first.hasPendingApprovals ? "Open approval" : "Open question"}
6870
</InlineButton>
6971
),

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import { useEnvironmentScope } from "~/state/session";
5656
import { threadEnvironment } from "../../state/threads";
5757
import { vcsEnvironment } from "../../state/vcs";
5858
import { useChildThreadInputs, readThreadShell, waitForThreadShell } from "../../state/entities";
59+
import { serverEnvironment } from "../../state/server";
5960
import { environmentShell } from "../../state/shell";
6061
import { ThreadStatusLine } from "./ThreadStatusLine";
6162
import { formatRelativeTimeLabel } from "../../timestampFormat";
@@ -455,14 +456,20 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) {
455456
};
456457
const handleStopBackgroundWorkStable = useStableCallback(handleStopBackgroundWork);
457458
const openRelatedThreadGenerationRef = useRef(0);
458-
const onOpenRelatedThread = async (threadId: ThreadId) => {
459+
// A task delegated to a linked environment opens there; the default is this thread's own.
460+
const onOpenRelatedThread = async (
461+
threadId: ThreadId,
462+
threadEnvironmentId: EnvironmentId = environmentId,
463+
) => {
459464
const generation = ++openRelatedThreadGenerationRef.current;
460-
const threadRef = scopeThreadRef(environmentId, threadId);
465+
const threadRef = scopeThreadRef(threadEnvironmentId, threadId);
461466
const isEnvironmentLive = () =>
462-
appAtomRegistry.get(environmentShell.stateValueAtom(environmentId)).status === "live";
467+
appAtomRegistry.get(environmentShell.stateValueAtom(threadEnvironmentId)).status === "live";
463468
// The shell can leave idle subagent children out, so absence is not deletion there: the
464469
// route decides from the thread's own detail.
465-
const shellOmitsChildren = serverConfig?.shellThreadFamilies === true;
470+
const shellOmitsChildren =
471+
appAtomRegistry.get(serverEnvironment.configValueAtom(threadEnvironmentId))
472+
?.shellThreadFamilies === true;
466473
// A just-launched child can reach this timeline before its shell syncs.
467474
if (!shellOmitsChildren && isEnvironmentLive() && readThreadShell(threadRef) === null) {
468475
const location = router.latestLocation;

0 commit comments

Comments
 (0)