Skip to content
40 changes: 20 additions & 20 deletions apps/mobile/src/features/threads/SubagentRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ export function SubagentRow(props: {
readonly elapsed: ReactNode;
/** The task runs in a linked environment this app is connected to. */
readonly canOpenRemote?: boolean;
/** Vertically centered on the trailing edge of the full row. */
readonly trailing?: ReactNode;
}) {
const presentation = resolveSubagentRowPresentation(props.subagent, props.canOpenRemote);
const detail = subagentCardDetail(presentation.detail);
return (
<View className="flex-row gap-3">
<View className="h-5 justify-center">
<SubagentStatusDot tone={presentation.tone} placement="sheet" />
</View>
<View className="flex-row items-center gap-3">
<View className="min-w-0 flex-1 gap-1">
<View className="min-h-5 flex-row items-center gap-2">
<View className="flex-row items-center gap-3">
<SubagentStatusDot tone={presentation.tone} placement="sheet" />
<View className="min-w-0 flex-1 flex-row items-baseline gap-1.5">
<Text
numberOfLines={1}
Expand All @@ -73,30 +73,30 @@ export function SubagentRow(props: {
>
{presentation.statusLabel}
</Text>
{props.elapsed}
{presentation.runsOn !== null ? (
<Text numberOfLines={1} className="shrink text-xs text-foreground-muted">
on {presentation.runsOn}
</Text>
) : null}
</View>
{props.elapsed}
{presentation.canOpenThread ? (
<SymbolView name="chevron.right" size={12} tintColorClassName="accent-icon-subtle" />
</View>
<View className="gap-1 pl-5">
<SubagentMetadata environmentId={props.environmentId} subagent={props.subagent} />
{detail ? (
<Text
numberOfLines={3}
className={cn(
"text-xs text-foreground-muted",
presentation.tone === "failed" && SUBAGENT_TONE_TEXT_CLASS.failed,
)}
>
{detail}
</Text>
) : null}
</View>
<SubagentMetadata environmentId={props.environmentId} subagent={props.subagent} />
{detail ? (
<Text
numberOfLines={3}
className={cn(
"text-xs text-foreground-muted",
presentation.tone === "failed" && SUBAGENT_TONE_TEXT_CLASS.failed,
)}
>
{detail}
</Text>
) : null}
</View>
{props.trailing}
</View>
);
}
Expand Down
69 changes: 41 additions & 28 deletions apps/mobile/src/features/threads/ThreadAgentsSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";

import { SheetHeader } from "../../components/ui/SheetHeader";
import { AppText as Text } from "../../components/ui/AppText";
import { SymbolView } from "../../components/ui/AppSymbol";
import { environmentThreadDetails } from "../../state/threads";
import { useEnvironments } from "../../state/environments";
import { SubagentRow } from "./SubagentRow";
Expand Down Expand Up @@ -145,45 +146,57 @@ function AgentRow(props: {
presentationById.has(id),
);

const row = (
<View className="py-3.5">
<SubagentRow
environmentId={props.environmentId}
subagent={subagent}
canOpenRemote={target !== null}
elapsed={<AgentElapsed subagent={subagent} tickSeconds={props.tickSeconds} />}
/>
</View>
const body = (
<SubagentRow
environmentId={props.environmentId}
subagent={subagent}
canOpenRemote={target !== null}
elapsed={<AgentElapsed subagent={subagent} tickSeconds={props.tickSeconds} />}
/>
);

const content =
target === null ? (
const stop = <SubagentStopButton environmentId={props.environmentId} subagent={subagent} />;
const chevron =
target === null ? null : (
<View
accessible
className="min-w-0 flex-1"
accessibilityHint={
subagent.remoteChild === undefined
? "Provider-managed agent. Its work appears in the transcript."
: `Runs on ${subagent.remoteChild.label}. Connect to it to open its thread.`
}
accessibilityElementsHidden
importantForAccessibility="no"
className="size-12 items-center justify-center"
>
{row}
<SymbolView name="chevron.right" size={24} tintColorClassName="accent-icon-subtle" />
</View>
);

if (target === null) {
return (
<View className="flex-row items-center py-3.5">
<View
accessible
className="min-w-0 flex-1"
accessibilityHint={
subagent.remoteChild === undefined
? "Provider-managed agent. Its work appears in the transcript."
: `Runs on ${subagent.remoteChild.label}. Connect to it to open its thread.`
}
>
{body}
</View>
{stop}
</View>
) : (
);
}

return (
<View className="flex-row items-center py-3.5">
<Pressable
accessibilityRole="link"
accessibilityHint="Opens this agent's thread"
onPress={() => props.onOpen(target)}
className="min-w-0 flex-1 active:opacity-70"
>
{row}
{body}
</Pressable>
);

return (
<View className="flex-row items-center">
{content}
<SubagentStopButton environmentId={props.environmentId} subagent={subagent} />
{stop}
{chevron}
</View>
);
}
Expand Down
42 changes: 20 additions & 22 deletions apps/mobile/src/features/threads/ThreadWorkflowGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from "@t3tools/contracts";
import { deriveSubagentElapsedMs, formatDuration } from "@t3tools/shared/orchestrationTiming";
import { useState, type ReactNode } from "react";
import { ScrollView, View } from "react-native";
import { Pressable, ScrollView, View } from "react-native";

import { AppText as Text } from "../../components/ui/AppText";
import { SymbolView, type AppSymbolName } from "../../components/ui/AppSymbol";
Expand Down Expand Up @@ -61,7 +61,7 @@ export function ThreadWorkflowGroup(props: {
return (
<View className="my-2">
<ListSection>
<View className="flex-row items-center">
<View className="flex-row items-center gap-2 pr-2">
<RowPressable
accessibilityRole="button"
accessibilityLabel={`${label} workflow, ${statusLabel}`}
Expand All @@ -71,26 +71,24 @@ export function ThreadWorkflowGroup(props: {
onPress={() => setSelected(nextWorkflowSelection(rail, selected))}
className="min-w-0 flex-1 active:opacity-70"
>
<WorkflowHeaderLayout
label={label}
statusLabel={statusLabel}
timing={group.workflow}
accessory={
rail.length > 0 ? (
<SymbolView
name={open ? "chevron.up" : "chevron.down"}
size={12}
tintColorClassName="accent-icon-subtle"
/>
) : null
}
/>
<WorkflowHeaderLayout label={label} statusLabel={statusLabel} timing={group.workflow} />
</RowPressable>
<SubagentStopButton
environmentId={props.environmentId}
subagent={props.subagent}
className="mr-2"
/>
<SubagentStopButton environmentId={props.environmentId} subagent={props.subagent} />
{rail.length > 0 ? (
<Pressable
accessibilityElementsHidden
importantForAccessibility="no"
onPress={() => setSelected(nextWorkflowSelection(rail, selected))}
className="active:opacity-70"
hitSlop={8}
>
<SymbolView
name={open ? "chevron.up" : "chevron.down"}
size={12}
tintColorClassName="accent-icon-subtle"
/>
</Pressable>
) : null}
</View>
{rail.length > 0 ? (
<ScrollView
Expand Down Expand Up @@ -256,7 +254,7 @@ function WorkflowHeaderLayout(props: {
readonly label: string;
readonly statusLabel: string;
readonly timing: ElapsedTiming;
readonly accessory: ReactNode;
readonly accessory?: ReactNode;
}) {
const elapsed = useElapsedLabel(props.timing);
return (
Expand Down
Loading