Skip to content

Commit 543fd2e

Browse files
Merge remote-tracking branch 'origin/main' into fix/issue-29117
2 parents 272b287 + 30654b3 commit 543fd2e

91 files changed

Lines changed: 4526 additions & 195 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/mobile/src/features/archive/useArchivedThreadSnapshots.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { useMemo } from "react";
99

1010
import { appAtomRegistry } from "../../state/atom-registry";
1111
import { orchestrationEnvironment } from "../../state/orchestration";
12+
import { serverEnvironment } from "../../state/server";
13+
import { environmentThreadShells } from "../../state/threads";
1214

1315
function archivedSnapshotAtom(environmentId: EnvironmentId) {
1416
return orchestrationEnvironment.archivedShellSnapshot({
@@ -19,6 +21,10 @@ function archivedSnapshotAtom(environmentId: EnvironmentId) {
1921

2022
const archivedSnapshotsAtom = createArchivedThreadSnapshotsAtomFamily({
2123
getSnapshotAtom: archivedSnapshotAtom,
24+
hiddenThreadTagsAtom: serverEnvironment.hiddenThreadTagsAtom,
25+
hiddenThreadKeysAtom: environmentThreadShells.hiddenThreadKeysAtom,
26+
liveThreadRefsAtom: environmentThreadShells.threadRefsAtom,
27+
anyEnvironmentHidingAtom: environmentThreadShells.anyEnvironmentHidingAtom,
2228
labelPrefix: "mobile:archived-thread-snapshots",
2329
});
2430

‎apps/mobile/src/features/keyboard/CommandPalette.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import {
4646
useProjects,
4747
useServerConfigs,
4848
useThreadShell,
49-
useThreadShells,
49+
useVisibleThreadShells,
5050
} from "../../state/entities";
5151
import { useThreadSearch } from "../../state/queries";
5252
import { requestThreadMessageJump } from "../threads/threadMessageJump";
@@ -226,7 +226,7 @@ export function CommandPalette(props: {
226226
const selectDetail = useSelectWorkspaceDetail();
227227
const runCommand = props.onCommand;
228228
const projects = useProjects();
229-
const threads = useThreadShells();
229+
const threads = useVisibleThreadShells();
230230
const activeThreadRef = parseActiveThreadPath(props.pathname);
231231
const activeThread = useThreadShell(activeThreadRef);
232232
const visitThread = useAtomCommand(threadEnvironment.visit, { reportFailure: false });

‎apps/mobile/src/features/pull-requests/usePullRequestThreads.ts‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { useAtomValue } from "@effect/atom-react";
2+
import { visibleLinkedThreads } from "@t3tools/client-runtime/state/threads";
13
import { AsyncResult } from "effect/reactivity";
24
import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
35
import * as Dialog from "../../components/ui/Dialog";
@@ -27,6 +29,7 @@ import { uuidv4 } from "../../lib/uuid";
2729
import { useEnvironmentServerConfig } from "../../state/entities";
2830
import { composerPullRequests } from "../../state/pull-requests";
2931
import { useEnvironmentQuery } from "../../state/query";
32+
import { environmentThreadShells } from "../../state/threads";
3033
import { useEnvironmentScope } from "../../state/session";
3134
import {
3235
createNewTaskDraft,
@@ -69,8 +72,18 @@ export function usePullRequestThreads(
6972
const [lastRelations, setLastRelations] = useState({ key, data: relations.data });
7073
if (relations.data && (lastRelations.key !== key || relations.data !== lastRelations.data))
7174
setLastRelations({ key, data: relations.data });
72-
const threads =
73-
(relations.data ?? (lastRelations.key === key ? lastRelations.data : null))?.threads ?? [];
75+
const hiddenKeys = useAtomValue(environmentThreadShells.hiddenThreadKeysAtom);
76+
const hidingAnywhere = useAtomValue(environmentThreadShells.anyEnvironmentHidingAtom);
77+
const loadedThreadRefs = useAtomValue(
78+
environmentThreadShells.environmentThreadRefsAtom(target.environmentId),
79+
);
80+
const threads = visibleLinkedThreads(
81+
(relations.data ?? (lastRelations.key === key ? lastRelations.data : null))?.threads ?? [],
82+
target.environmentId,
83+
loadedThreadRefs,
84+
hiddenKeys,
85+
hidingAnywhere,
86+
);
7487
const connected = usePullRequestConnected(params.environmentId);
7588
const canOperate = useEnvironmentScope(target.environmentId, AuthOrchestrationOperateScope);
7689
const canAsk = !connected || canOperate;
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
import type {
2+
EnvironmentId,
3+
OrchestrationV2GetNativeChildWorkResult,
4+
OrchestrationV2NativeChildWork,
5+
ThreadId,
6+
} from "@t3tools/contracts";
7+
import { ScrollView, View } from "react-native";
8+
import { useSafeAreaInsets } from "react-native-safe-area-context";
9+
10+
import { AppText as Text } from "../../components/ui/AppText";
11+
import { Button } from "../../components/ui/Button";
12+
import { Sheet } from "../../components/ui/Sheet";
13+
import { orchestrationEnvironment } from "../../state/orchestration";
14+
import { useEnvironmentQuery } from "../../state/query";
15+
16+
const stepLabel = (type: string) => {
17+
const words = type.toLowerCase().replaceAll("_", " ");
18+
return words.charAt(0).toUpperCase() + words.slice(1);
19+
};
20+
21+
/** Read-only view of what a provider-native subagent's children did. Mount only while open. */
22+
export function NativeChildWorkSheet(props: {
23+
readonly environmentId: EnvironmentId;
24+
readonly threadId: ThreadId;
25+
readonly onClose: () => void;
26+
}) {
27+
const insets = useSafeAreaInsets();
28+
const query = useEnvironmentQuery<OrchestrationV2GetNativeChildWorkResult, unknown>(
29+
orchestrationEnvironment.nativeChildWork({
30+
environmentId: props.environmentId,
31+
input: { threadId: props.threadId },
32+
}),
33+
);
34+
const children = query.data?.children;
35+
return (
36+
<Sheet title="Subagent work" onClose={props.onClose}>
37+
<ScrollView
38+
contentInsetAdjustmentBehavior="automatic"
39+
contentContainerStyle={{
40+
gap: 16,
41+
paddingHorizontal: 20,
42+
paddingTop: 12,
43+
paddingBottom: Math.max(20, insets.bottom),
44+
}}
45+
>
46+
<Text className="font-sans text-xs text-foreground-secondary">
47+
Read only. These subagents cannot take messages.
48+
</Text>
49+
{query.error !== null ? (
50+
<Text selectable className="font-sans text-sm text-danger-foreground">
51+
{query.error}
52+
</Text>
53+
) : children === undefined ? (
54+
<Text className="font-sans text-sm text-foreground-secondary">Loading…</Text>
55+
) : children.length === 0 ? (
56+
<Text className="font-sans text-sm text-foreground-secondary">
57+
The provider has no record of which subagents this call started.
58+
</Text>
59+
) : (
60+
children.map((child) => <NativeChild key={child.conversationId} child={child} />)
61+
)}
62+
<View className="flex-row justify-end">
63+
<Button
64+
label="Refresh"
65+
tone="secondary"
66+
disabled={query.isPending}
67+
onPress={query.refresh}
68+
/>
69+
</View>
70+
</ScrollView>
71+
</Sheet>
72+
);
73+
}
74+
75+
function NativeChild(props: { readonly child: OrchestrationV2NativeChildWork }) {
76+
const { child } = props;
77+
return (
78+
<View className="gap-2">
79+
<Text className="font-t3-bold text-sm text-foreground">{child.role || "Subagent"}</Text>
80+
<Text selectable className="font-sans text-sm text-foreground-secondary">
81+
{child.prompt}
82+
</Text>
83+
{child.truncated ? (
84+
<Text className="font-sans text-xs text-foreground-secondary">
85+
Earlier steps are not shown.
86+
</Text>
87+
) : null}
88+
{child.steps === null ? (
89+
<Text className="font-sans text-xs text-foreground-secondary">No transcript yet.</Text>
90+
) : (
91+
<View className="gap-2 border-l border-border ps-3">
92+
{child.steps.map((step) => (
93+
<View key={step.index} className="gap-1">
94+
<Text className="font-t3-bold text-xs text-foreground-secondary">
95+
{stepLabel(step.type)}
96+
{step.status !== null && step.status !== "DONE"
97+
? ` · ${stepLabel(step.status)}`
98+
: ""}
99+
</Text>
100+
{step.toolCalls.length === 0 ? null : (
101+
<Text selectable className="font-mono text-xs text-foreground">
102+
{step.toolCalls.map((call) => `${call.name} ${call.input}`).join("\n")}
103+
</Text>
104+
)}
105+
{step.text === null ? null : (
106+
<Text selectable className="font-mono text-xs text-foreground">
107+
{step.text}
108+
</Text>
109+
)}
110+
</View>
111+
))}
112+
</View>
113+
)}
114+
</View>
115+
);
116+
}

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import {
22
formatProviderSubagentStatus,
33
type ProviderSubagentStatus,
44
} from "@t3tools/client-runtime/state/thread-execution";
5-
import { isOrchestrationV2WorkActive } from "@t3tools/contracts";
5+
import { isOrchestrationV2WorkActive, type EnvironmentId, type ThreadId } from "@t3tools/contracts";
6+
import { useState } from "react";
67
import { View } from "react-native";
78

89
import { AppText as Text } from "../../components/ui/AppText";
910
import { ProviderIcon } from "../../components/ProviderIcon";
1011
import { Button } from "../../components/ui/Button";
12+
import { NativeChildWorkSheet } from "./NativeChildWorkSheet";
1113
import { useVisibleSecondClock } from "./use-visible-second-clock";
1214

1315
export function ProviderSubagentBar(props: {
@@ -16,7 +18,10 @@ export function ProviderSubagentBar(props: {
1618
readonly effortLabel: string | null;
1719
readonly status: ProviderSubagentStatus | null;
1820
readonly onOpenParent: (() => void) | null;
21+
/** Set for providers whose children T3 reads on demand instead of streaming. */
22+
readonly inspect: { readonly environmentId: EnvironmentId; readonly threadId: ThreadId } | null;
1923
}) {
24+
const [inspecting, setInspecting] = useState(false);
2025
const live = props.status !== null && isOrchestrationV2WorkActive(props.status.status);
2126
const nowMs = useVisibleSecondClock(live);
2227
const statusLabel = formatProviderSubagentStatus(props.status, nowMs);
@@ -59,9 +64,15 @@ export function ProviderSubagentBar(props: {
5964
{statusLabel} · Runs on its own
6065
</Text>
6166
</View>
67+
{props.inspect ? (
68+
<Button label="Work" tone="secondary" onPress={() => setInspecting(true)} />
69+
) : null}
6270
{props.onOpenParent ? (
6371
<Button label="Open parent" tone="secondary" onPress={props.onOpenParent} />
6472
) : null}
73+
{props.inspect && inspecting ? (
74+
<NativeChildWorkSheet {...props.inspect} onClose={() => setInspecting(false)} />
75+
) : null}
6576
</View>
6677
);
6778
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import {
6565
} from "../../state/use-composer-drafts";
6666
import { appAtomRegistry } from "../../state/atom-registry";
6767
import type { ComposerDocumentAttachment } from "../../lib/composerContext";
68-
import { useProject, useThreadShells } from "../../state/entities";
68+
import { useProject, useVisibleThreadShells } from "../../state/entities";
6969
import { useMentionableEnvironments } from "../../state/environments";
7070
import { useLinkedEnvironments } from "../../state/peerLinks";
7171
import { scopeProjectRef } from "@t3tools/client-runtime/environment";
@@ -539,7 +539,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
539539
draftMessage: draftMessage,
540540
ownerKey: composerDraftKey,
541541
environmentId: props.environmentId,
542-
threadShells: useThreadShells(),
542+
threadShells: useVisibleThreadShells(),
543543
environments: offersLinkedEnvironments(props.serverConfig)
544544
? mentionableEnvironments
545545
: NO_MACHINES,

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,14 @@ function ThreadDetailBody(
17221722
reportedModelSelection,
17231723
)}
17241724
status={props.providerSubagentStatus ?? null}
1725+
inspect={
1726+
providerSubagentProvider?.driver === "antigravity"
1727+
? {
1728+
environmentId: props.environmentId,
1729+
threadId: props.selectedThread.id,
1730+
}
1731+
: null
1732+
}
17251733
onOpenParent={
17261734
props.selectedThread.lineage.parentThreadId === null
17271735
? null

‎apps/mobile/src/state/composer-attachment-uploads.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ vi.mock("./entities", () => ({
9999
useProjects: () => [],
100100
useServerConfigs: () => new Map([["environment-1", config]]),
101101
useThreadShells: () => [],
102+
useVisibleThreadShells: () => [],
102103
}));
103104
vi.mock("./projects", () => ({ environmentProjects: {} }));
104105
vi.mock("./workspace", () => ({ workspaceConnections: {} }));

‎apps/mobile/src/state/entities.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ export function useThreadShells(): ReadonlyArray<EnvironmentThreadShell> {
173173
return useAtomValue(environmentThreadShells.threadShellsAtom);
174174
}
175175

176+
/** Thread shells minus those the tag filter hides, for lists that show threads to the user. */
177+
export function useVisibleThreadShells(): ReadonlyArray<EnvironmentThreadShell> {
178+
return useAtomValue(environmentThreadShells.visibleThreadShellsAtom);
179+
}
180+
176181
export function useNavigationThreadShells(): ReadonlyArray<EnvironmentThreadShell> {
177182
return useAtomValue(environmentThreadShells.navigationThreadShellsAtom);
178183
}

‎apps/mobile/src/state/threads.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
pendingThreadCreationOutcomesAtom,
2222
selectThreadCreationDetail,
2323
} from "./pending-thread-creation";
24+
import { serverEnvironment } from "./server";
2425
import { environmentShell } from "./shell";
2526
import { threadOutboxManager } from "./thread-outbox";
2627

@@ -43,6 +44,7 @@ export const environmentThreadDetails = createEnvironmentThreadDetailAtoms(
4344
export const environmentThreadShells = createEnvironmentThreadShellAtoms({
4445
catalogValueAtom: environmentCatalog.catalogValueAtom,
4546
snapshotAtom: threadEnvironment.snapshotAtom,
47+
hiddenThreadTagsAtom: serverEnvironment.hiddenThreadTagsAtom,
4648
});
4749
export const childThreadApprovalsAtom = createChildThreadApprovalsAtom({
4850
childThreadInputsAtom: environmentThreadShells.childThreadInputsAtom,

0 commit comments

Comments
 (0)