Skip to content

Commit fb778ab

Browse files
PR Batch Testervoida6claude
committed
feat(mobile): tap the background work pill to see what is running
The pill only said "Waiting on 4 monitors" and couldn't be tapped. Tapping it now opens a Background work sheet that lists each pending subagent, command, monitor and background task, and a subagent row opens its thread. The pill's container also lets touches through now; before, only the connection and child-input pills could receive a tap. Co-authored-by: ravdeep kainth <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent e704190 commit fb778ab

5 files changed

Lines changed: 181 additions & 1 deletion

File tree

‎apps/mobile/src/Stack.tsx‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import { GitConfirmSheet } from "./features/threads/git/GitConfirmSheet";
6969
import { GitOverviewSheet } from "./features/threads/git/GitOverviewSheet";
7070
import { ThreadPullRequestsSheet } from "./features/threads/ThreadPullRequestsSheet";
7171
import { ThreadAgentsSheet } from "./features/threads/ThreadAgentsSheet";
72+
import { ThreadBackgroundWorkSheet } from "./features/threads/ThreadBackgroundWorkSheet";
7273
import { ThreadQueueSheet } from "./features/threads/ThreadQueueControl";
7374
import { ThreadRouteScreen } from "./features/threads/ThreadRouteScreen";
7475
import { McpAppFullscreenScreen } from "./features/threads/McpAppFullscreenScreen";
@@ -551,6 +552,7 @@ const WORKSPACE_OVERLAY_ROUTES = new Set([
551552
"SettingsLegal",
552553
"SettingsSheet",
553554
"ThreadAgents",
555+
"ThreadBackgroundWork",
554556
"ThreadPullRequests",
555557
"ThreadQueue",
556558
"ThreadReviewComment",
@@ -864,6 +866,15 @@ const RootStackConfig = createWorkspaceStackNavigator({
864866
sheetGrabberVisible: true,
865867
},
866868
}),
869+
ThreadBackgroundWork: createNativeStackScreen({
870+
screen: ThreadBackgroundWorkSheet,
871+
options: {
872+
...FORM_SHEET_PRESENTATION_OPTIONS,
873+
headerShown: false,
874+
sheetAllowedDetents: [0.5, 0.9],
875+
sheetGrabberVisible: true,
876+
},
877+
}),
867878
GitOverview: createNativeStackScreen({
868879
screen: GitOverviewSheet,
869880
linking: `${THREAD_LINKING_PREFIX}/git`,
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
import { useAtomValue } from "@effect/atom-react";
2+
import { scopeThreadRef } from "@t3tools/client-runtime/environment";
3+
import {
4+
presentPendingBackgroundWork,
5+
type PendingBackgroundWorkItem,
6+
} from "@t3tools/client-runtime/state/thread-execution";
7+
import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
8+
import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
9+
import * as Haptics from "expo-haptics";
10+
import { Platform, Pressable, ScrollView, View } from "react-native";
11+
import { ScreenStack } from "react-native-screens";
12+
import { useSafeAreaInsets } from "react-native-safe-area-context";
13+
14+
import { AndroidSheetHeader } from "../../components/ui/AndroidScreenHeader";
15+
import { SymbolView } from "../../components/ui/AppSymbol";
16+
import { AppText as Text } from "../../components/ui/AppText";
17+
import { ScreenContent } from "../../components/ui/ScreenContent";
18+
import { NativeStackScreenOptions, nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";
19+
import { NativeHeader, NativeScreen } from "../../native/ThemedScreenStack";
20+
import { environmentThreadShells } from "../../state/threads";
21+
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
22+
23+
const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
24+
25+
type BackgroundWorkTarget = { readonly environmentId: EnvironmentId; readonly threadId: ThreadId };
26+
27+
const KIND_LABELS: Record<PendingBackgroundWorkItem["kind"], string> = {
28+
subagent: "Subagent",
29+
command: "Command",
30+
monitor: "Monitor",
31+
background_task: "Background task",
32+
};
33+
34+
export function ThreadBackgroundWorkSheet({ route }: StaticScreenProps<BackgroundWorkTarget>) {
35+
const { layout } = useAdaptiveWorkspaceLayout();
36+
const target = route.params;
37+
const navigation = useNavigation();
38+
const insets = useSafeAreaInsets();
39+
const thread = useAtomValue(
40+
environmentThreadShells.threadShellAtom(scopeThreadRef(target.environmentId, target.threadId)),
41+
);
42+
const items = presentPendingBackgroundWork(thread?.pendingBackgroundTasks ?? [])?.items ?? [];
43+
44+
const openChildThread = (childThreadId: ThreadId) => {
45+
void Haptics.selectionAsync();
46+
// Same as the agents sheet: the child thread belongs in the workspace stack, not above a leaf sheet.
47+
navigation.dispatch(
48+
StackActions.replace("Thread", {
49+
environmentId: target.environmentId,
50+
threadId: childThreadId,
51+
}),
52+
);
53+
};
54+
55+
const content = (
56+
<ScrollView
57+
nestedScrollEnabled
58+
className="flex-1"
59+
contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
60+
contentContainerClassName="px-5 pb-6"
61+
contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 16) + 8 }}
62+
>
63+
{items.length === 0 ? (
64+
<Text className="pt-6 text-center text-sm text-foreground-muted">
65+
Nothing running in the background.
66+
</Text>
67+
) : (
68+
items.map((item) => (
69+
<BackgroundWorkRow key={item.taskId} item={item} onOpen={openChildThread} />
70+
))
71+
)}
72+
</ScrollView>
73+
);
74+
75+
if (Platform.OS === "ios") {
76+
return (
77+
<View collapsable={false} className="flex-1 bg-sheet">
78+
<ScreenStack style={{ flex: 1 }}>
79+
<NativeScreen
80+
activityState={2}
81+
enabled
82+
isNativeStack
83+
screenId="thread-background-work-sheet-native"
84+
scrollEdgeEffects={HEADER_SCROLL_EDGE_EFFECTS}
85+
className="flex-1 bg-sheet"
86+
>
87+
{content}
88+
<NativeHeader
89+
backgroundColor="rgba(0,0,0,0)"
90+
tintColorClassName="accent-foreground"
91+
hideBackButton
92+
hideShadow={false}
93+
title="Background work"
94+
titleColorClassName="accent-foreground"
95+
titleFontSize={18}
96+
titleFontWeight="800"
97+
translucent
98+
/>
99+
</NativeScreen>
100+
</ScreenStack>
101+
</View>
102+
);
103+
}
104+
105+
return (
106+
<View collapsable={false} className="flex-1 bg-sheet">
107+
<NativeStackScreenOptions options={{ sheetCornerRadius: 28 }} />
108+
<AndroidSheetHeader title="Background work" onBack={() => navigation.goBack()} />
109+
<ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent>
110+
</View>
111+
);
112+
}
113+
114+
function BackgroundWorkRow(props: {
115+
readonly item: PendingBackgroundWorkItem;
116+
readonly onOpen: (childThreadId: ThreadId) => void;
117+
}) {
118+
const { item } = props;
119+
const childThreadId = item.childThreadId;
120+
const row = (
121+
<View className="flex-row items-center gap-3 border-b border-border py-3.5">
122+
<SymbolView
123+
name={
124+
item.kind === "subagent"
125+
? "person.2"
126+
: item.kind === "monitor"
127+
? { ios: "bolt", android: "bolt" }
128+
: "terminal"
129+
}
130+
size={15}
131+
tintColorClassName="accent-foreground-muted"
132+
type="monochrome"
133+
/>
134+
<View className="min-w-0 flex-1">
135+
<Text className="font-t3-medium text-sm text-foreground" numberOfLines={2}>
136+
{item.label}
137+
</Text>
138+
<Text className="text-xs text-foreground-muted">{KIND_LABELS[item.kind]}</Text>
139+
</View>
140+
{childThreadId !== undefined ? (
141+
<SymbolView name="chevron.right" size={12} tintColorClassName="accent-icon-subtle" />
142+
) : null}
143+
</View>
144+
);
145+
146+
if (childThreadId === undefined) return <View accessible>{row}</View>;
147+
return (
148+
<Pressable
149+
accessibilityRole="link"
150+
accessibilityHint="Opens this subagent's thread"
151+
onPress={() => props.onOpen(childThreadId)}
152+
className="active:opacity-70"
153+
>
154+
{row}
155+
</Pressable>
156+
);
157+
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,13 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
501501
.map((item) => item.label)
502502
.join(", ")}`,
503503
waiting: pendingBackgroundWork.waiting,
504+
onPress: () => {
505+
Keyboard.dismiss();
506+
navigation.navigate("ThreadBackgroundWork", {
507+
environmentId: props.environmentId,
508+
threadId: props.selectedThread.id,
509+
});
510+
},
504511
};
505512
}
506513
if (props.selectedThread.goal !== null && contentPresentationKind === "ready") {

‎apps/mobile/src/features/threads/floating-working-control.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ export function FloatingWorkingControl(props: {
156156
hasQueue ||
157157
(props.devicePreview !== null && props.browserPreview !== null);
158158
const statusInteractive =
159-
props.status?.kind === "connection" || props.status?.kind === "child-input";
159+
props.status?.kind === "connection" ||
160+
props.status?.kind === "child-input" ||
161+
props.status?.kind === "background";
160162
const capsuleInteractive = statusInteractive || hasQueue || hasAgents || hasPreview;
161163
const statusContent =
162164
props.status !== null ? (
@@ -409,8 +411,10 @@ function FloatingStatusLabel(props: {
409411
<StatusLabelRow
410412
key="background"
411413
accessibilityLabel={props.status.accessibilityLabel}
414+
accessibilityRole="button"
412415
className="gap-2"
413416
onLayout={props.onLayout}
417+
onPress={props.status.onPress}
414418
>
415419
<SymbolView
416420
name={props.status.waiting ? { ios: "bolt", android: "bolt" } : "terminal"}

‎apps/mobile/src/features/threads/floating-working-status.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export type FloatingWorkingStatus =
1515
readonly label: string;
1616
readonly accessibilityLabel: string;
1717
readonly waiting: boolean;
18+
readonly onPress: () => void;
1819
}
1920
| { readonly kind: "goal"; readonly label: string; readonly accessibilityLabel: string }
2021
| { readonly kind: "preparing"; readonly label: string }

0 commit comments

Comments
 (0)