Skip to content
Merged
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
2 changes: 1 addition & 1 deletion apps/mobile/src/features/threads/ThreadDetailScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ function ThreadDetailBody(props: ThreadDetailScreenProps) {
accessibilityLabel: `Open ${childInput.hasPendingApprovals ? "approval" : "question"} from ${childInput.title}`,
onPress: () => {
Keyboard.dismiss();
openLinkedThread({ environmentId: props.environmentId, threadId: childInput.id });
openLinkedThread({ environmentId: childInput.environmentId, threadId: childInput.id });
},
};
}
Expand Down
8 changes: 5 additions & 3 deletions apps/web/src/components/chat/ThreadActivityBanners.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {
EnvironmentId,
OrchestrationV2PendingBackgroundTask,
OrchestrationV2ProviderGoal,
ThreadId,
Expand Down Expand Up @@ -34,7 +35,8 @@ import type { ThreadNowItem } from "./ThreadNow";
export function childInputNowItem(input: {
readonly childThreadInputs: ReadonlyArray<EnvironmentThreadShell>;
readonly parentAwaitingUser: boolean;
readonly onOpenThread: (threadId: ThreadId) => void;
// A task delegated to a linked environment lives there, not where the parent runs.
readonly onOpenThread: (threadId: ThreadId, environmentId: EnvironmentId) => void;
}): (ThreadNowItem & { readonly waitingLabel: string }) | null {
const { childThreadInputs, onOpenThread } = input;
const first = childThreadInputs[0];
Expand All @@ -55,15 +57,15 @@ export function childInputNowItem(input: {
<Fragment key={child.id}>
{index > 0 ? " " : null}
<span className="whitespace-nowrap">
<InlineButton tone="muted" onClick={() => onOpenThread(child.id)}>
<InlineButton tone="muted" onClick={() => onOpenThread(child.id, child.environmentId)}>
{child.title}
</InlineButton>
{index < childThreadInputs.length - 1 ? "," : null}
</span>
</Fragment>
)),
actions: (
<InlineButton onClick={() => onOpenThread(first.id)}>
<InlineButton onClick={() => onOpenThread(first.id, first.environmentId)}>
{first.hasPendingApprovals ? "Open approval" : "Open question"}
</InlineButton>
),
Expand Down
15 changes: 11 additions & 4 deletions apps/web/src/components/chat/useThreadLifecycle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { useEnvironmentScope } from "~/state/session";
import { threadEnvironment } from "../../state/threads";
import { vcsEnvironment } from "../../state/vcs";
import { useChildThreadInputs, readThreadShell, waitForThreadShell } from "../../state/entities";
import { serverEnvironment } from "../../state/server";
import { environmentShell } from "../../state/shell";
import { ThreadStatusLine } from "./ThreadStatusLine";
import { formatRelativeTimeLabel } from "../../timestampFormat";
Expand Down Expand Up @@ -427,14 +428,20 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) {
};
const handleStopBackgroundWorkStable = useStableCallback(handleStopBackgroundWork);
const openRelatedThreadGenerationRef = useRef(0);
const onOpenRelatedThread = async (threadId: ThreadId) => {
// A task delegated to a linked environment opens there; the default is this thread's own.
const onOpenRelatedThread = async (
threadId: ThreadId,
threadEnvironmentId: EnvironmentId = environmentId,
) => {
const generation = ++openRelatedThreadGenerationRef.current;
const threadRef = scopeThreadRef(environmentId, threadId);
const threadRef = scopeThreadRef(threadEnvironmentId, threadId);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
const isEnvironmentLive = () =>
appAtomRegistry.get(environmentShell.stateValueAtom(environmentId)).status === "live";
appAtomRegistry.get(environmentShell.stateValueAtom(threadEnvironmentId)).status === "live";
// The shell can leave idle subagent children out, so absence is not deletion there: the
// route decides from the thread's own detail.
const shellOmitsChildren = serverConfig?.shellThreadFamilies === true;
const shellOmitsChildren =
appAtomRegistry.get(serverEnvironment.configValueAtom(threadEnvironmentId))
?.shellThreadFamilies === true;
// A just-launched child can reach this timeline before its shell syncs.
if (!shellOmitsChildren && isEnvironmentLive() && readThreadShell(threadRef) === null) {
const location = router.latestLocation;
Expand Down
Loading