Skip to content

Commit c394249

Browse files
committed
refactor(mobile): use shared workflow UI controls
1 parent 8b05ab9 commit c394249

4 files changed

Lines changed: 195 additions & 200 deletions

File tree

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export function SubagentRow(props: {
3232
readonly environmentId: EnvironmentId;
3333
readonly subagent: SubagentRowSubagent;
3434
readonly elapsed: ReactNode;
35-
readonly reserveMetadataAction?: boolean;
3635
}) {
3736
const presentation = resolveSubagentRowPresentation(props.subagent);
3837
const detail = subagentCardDetail(presentation.detail);
@@ -71,11 +70,7 @@ export function SubagentRow(props: {
7170
<SymbolView name="chevron.right" size={12} tintColorClassName="accent-icon-subtle" />
7271
) : null}
7372
</View>
74-
<SubagentMetadata
75-
environmentId={props.environmentId}
76-
subagent={props.subagent}
77-
className={props.reserveMetadataAction ? "pr-9" : undefined}
78-
/>
73+
<SubagentMetadata environmentId={props.environmentId} subagent={props.subagent} />
7974
{detail ? (
8075
<Text
8176
numberOfLines={3}
@@ -95,7 +90,6 @@ export function SubagentRow(props: {
9590
function SubagentMetadata(props: {
9691
readonly environmentId: EnvironmentId;
9792
readonly subagent: SubagentRowSubagent;
98-
readonly className?: string;
9993
}) {
10094
const { environmentId, subagent } = props;
10195
const config = useEnvironmentServerConfig(environmentId);
@@ -119,7 +113,7 @@ function SubagentMetadata(props: {
119113
childProject,
120114
});
121115
return (
122-
<View className={cn("min-w-0 flex-row items-center gap-1.5", props.className)}>
116+
<View className="min-w-0 flex-row items-center gap-1.5">
123117
<ProviderIcon
124118
provider={provider?.driver ?? subagent.driver}
125119
iconUrl={provider?.iconUrl}
Lines changed: 34 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { useAtomValue } from "@effect/atom-react";
22
import type { EnvironmentId, OrchestrationV2Subagent } from "@t3tools/contracts";
33
import { useState } from "react";
4-
import { Alert, Pressable, View } from "react-native";
4+
import { View } from "react-native";
55

6-
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
7-
import { SymbolView } from "../../components/ui/AppSymbol";
8-
import { cn } from "../../lib/cn";
6+
import * as Dialog from "../../components/ui/Dialog";
7+
import { IconButton } from "../../components/ui/IconButton";
98
import { orchestrationEnvironment } from "../../state/orchestration";
109
import { threadEnvironment } from "../../state/threads";
1110
import { useAtomCommand } from "../../state/use-atom-command";
@@ -32,55 +31,38 @@ export function SubagentStopButton(props: {
3231
const workflow = target.kind === "workflow";
3332
const label =
3433
props.subagent.workflow?.name ?? resolveSubagentRowPresentation(props.subagent).title;
35-
const confirmStop = () =>
36-
Alert.alert(
37-
workflow ? "Stop workflow?" : "Stop agent?",
38-
workflow ? `Every running agent in ${label} stops.` : `Stop ${label}?`,
39-
[
40-
{ text: "Cancel", style: "cancel" },
41-
{
42-
text: "Stop",
43-
style: "destructive",
44-
onPress: async () => {
45-
setStopping(true);
46-
try {
47-
const result =
48-
target.kind === "workflow"
49-
? await stopWorkflow({ environmentId: props.environmentId, input: target.input })
50-
: await interruptTurn({
51-
environmentId: props.environmentId,
52-
input: target.input,
53-
});
54-
if (result._tag === "Failure") {
55-
Alert.alert(workflow ? "Could not stop workflow" : "Could not stop agent");
56-
}
57-
} finally {
58-
setStopping(false);
59-
}
60-
},
61-
},
62-
],
63-
);
34+
const stop = async () => {
35+
setStopping(true);
36+
try {
37+
const result =
38+
target.kind === "workflow"
39+
? await stopWorkflow({ environmentId: props.environmentId, input: target.input })
40+
: await interruptTurn({ environmentId: props.environmentId, input: target.input });
41+
if (result._tag === "Failure") {
42+
Dialog.alert(workflow ? "Could not stop workflow" : "Could not stop agent");
43+
}
44+
} finally {
45+
setStopping(false);
46+
}
47+
};
6448

6549
return (
66-
<Pressable
67-
accessibilityRole="button"
68-
accessibilityLabel={`Stop ${workflow ? "workflow" : "agent"} ${label}`}
69-
accessibilityState={{ disabled: stopping, busy: stopping }}
70-
disabled={stopping}
71-
onPress={confirmStop}
72-
className={cn(
73-
"size-11 items-center justify-center active:opacity-70 disabled:opacity-50",
74-
props.className,
75-
)}
76-
>
77-
<View className="size-6 items-center justify-center rounded-full bg-danger">
78-
{stopping ? (
79-
<AppActivityIndicator size="small" />
80-
) : (
81-
<SymbolView name="stop.fill" size={9} tintColorClassName="accent-danger-foreground" />
82-
)}
83-
</View>
84-
</Pressable>
50+
<View className={props.className}>
51+
<IconButton
52+
icon="stop.fill"
53+
variant="danger"
54+
accessibilityLabel={`${stopping ? "Stopping" : "Stop"} ${workflow ? "workflow" : "agent"} ${label}`}
55+
disabled={stopping}
56+
onPress={() =>
57+
Dialog.confirm({
58+
title: workflow ? "Stop workflow?" : "Stop agent?",
59+
message: workflow ? `Every running agent in ${label} stops.` : `Stop ${label}?`,
60+
confirmText: "Stop",
61+
destructive: true,
62+
onConfirm: () => void stop(),
63+
})
64+
}
65+
/>
66+
</View>
8567
);
8668
}

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import { NativeHeader, NativeScreen } from "../../native/ThemedScreenStack";
2828
import { SubagentRow } from "./SubagentRow";
2929
import { SubagentStopButton } from "./SubagentStopButton";
3030
import { ThreadWorkflowGroup } from "./ThreadWorkflowGroup";
31-
import { resolveSubagentStopTarget } from "./threadAgentsPresentation";
3231
import { ScreenContent } from "../../components/ui/ScreenContent";
3332
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
3433

@@ -175,7 +174,6 @@ function AgentRow(props: {
175174
environmentId={props.environmentId}
176175
subagent={subagent}
177176
elapsed={<AgentElapsed subagent={subagent} tickSeconds={props.tickSeconds} />}
178-
reserveMetadataAction={resolveSubagentStopTarget(subagent) !== null}
179177
/>
180178
</View>
181179
);
@@ -184,6 +182,7 @@ function AgentRow(props: {
184182
childThreadId === null ? (
185183
<View
186184
accessible
185+
className="min-w-0 flex-1"
187186
accessibilityHint="Provider-managed agent. Its work appears in the transcript."
188187
>
189188
{row}
@@ -193,20 +192,16 @@ function AgentRow(props: {
193192
accessibilityRole="link"
194193
accessibilityHint="Opens this agent thread"
195194
onPress={() => props.onOpen(childThreadId)}
196-
className="active:opacity-70"
195+
className="min-w-0 flex-1 active:opacity-70"
197196
>
198197
{row}
199198
</Pressable>
200199
);
201200

202201
return (
203-
<View className="-mr-2.5 pr-2.5">
202+
<View className="flex-row items-center">
204203
{content}
205-
<SubagentStopButton
206-
environmentId={props.environmentId}
207-
subagent={subagent}
208-
className="absolute right-0 top-6"
209-
/>
204+
<SubagentStopButton environmentId={props.environmentId} subagent={subagent} />
210205
</View>
211206
);
212207
}

0 commit comments

Comments
 (0)