Skip to content

Commit d14ccdf

Browse files
robrab2000claude
andcommitted
fix(clients): open a delegated child's approval on the environment it runs in
A task delegated to a linked environment shows its pending approval or question on the parent thread, but "Open approval" and the child title links opened the child by thread id alone, scoped to the parent's environment. That thread does not exist there, so the app fell through to the new-thread page. The mobile child-input pill had the same bug. The child shell already carries the environment it runs on, so pass it through to the open handler and resolve liveness, shell presence and the route against that environment. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent b50d8a1 commit d14ccdf

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
@@ -731,7 +731,7 @@ function ThreadDetailBody(props: ThreadDetailScreenProps) {
731731
accessibilityLabel: `Open ${childInput.hasPendingApprovals ? "approval" : "question"} from ${childInput.title}`,
732732
onPress: () => {
733733
Keyboard.dismiss();
734-
openLinkedThread({ environmentId: props.environmentId, threadId: childInput.id });
734+
openLinkedThread({ environmentId: childInput.environmentId, threadId: childInput.id });
735735
},
736736
};
737737
}

‎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
@@ -51,6 +51,7 @@ import { useEnvironmentScope } from "~/state/session";
5151
import { threadEnvironment } from "../../state/threads";
5252
import { vcsEnvironment } from "../../state/vcs";
5353
import { useChildThreadInputs, readThreadShell, waitForThreadShell } from "../../state/entities";
54+
import { serverEnvironment } from "../../state/server";
5455
import { environmentShell } from "../../state/shell";
5556
import { ThreadStatusLine } from "./ThreadStatusLine";
5657
import { formatRelativeTimeLabel } from "../../timestampFormat";
@@ -427,14 +428,20 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) {
427428
};
428429
const handleStopBackgroundWorkStable = useStableCallback(handleStopBackgroundWork);
429430
const openRelatedThreadGenerationRef = useRef(0);
430-
const onOpenRelatedThread = async (threadId: ThreadId) => {
431+
// A task delegated to a linked environment opens there; the default is this thread's own.
432+
const onOpenRelatedThread = async (
433+
threadId: ThreadId,
434+
threadEnvironmentId: EnvironmentId = environmentId,
435+
) => {
431436
const generation = ++openRelatedThreadGenerationRef.current;
432-
const threadRef = scopeThreadRef(environmentId, threadId);
437+
const threadRef = scopeThreadRef(threadEnvironmentId, threadId);
433438
const isEnvironmentLive = () =>
434-
appAtomRegistry.get(environmentShell.stateValueAtom(environmentId)).status === "live";
439+
appAtomRegistry.get(environmentShell.stateValueAtom(threadEnvironmentId)).status === "live";
435440
// The shell can leave idle subagent children out, so absence is not deletion there: the
436441
// route decides from the thread's own detail.
437-
const shellOmitsChildren = serverConfig?.shellThreadFamilies === true;
442+
const shellOmitsChildren =
443+
appAtomRegistry.get(serverEnvironment.configValueAtom(threadEnvironmentId))
444+
?.shellThreadFamilies === true;
438445
// A just-launched child can reach this timeline before its shell syncs.
439446
if (!shellOmitsChildren && isEnvironmentLive() && readThreadShell(threadRef) === null) {
440447
const location = router.latestLocation;

0 commit comments

Comments
 (0)