Repository navigation
feat: show agent task progress in threads #26564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+1,605
−69
Closed
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
09cd966
feat: show agent task progress in threads
Kaloyanes 2d81031
fix(web): preserve upstream sidebar controls with task progress
Kaloyanes 77ea3c4
fix: address task progress review findings
Kaloyanes 557e85f
fix: retain incomplete task progress after a run stops
Kaloyanes 7676333
fix(mobile): keep actions available with stopped progress
Kaloyanes aed7506
fix(mobile): keep stopped task details reachable beside status actions
Kaloyanes c162404
merge: resolve task progress with current upstream main
Kaloyanes f375756
merge: resolve task progress with upstream main
Kaloyanes bef318c
feat(web): put task progress behind Labs and the thread details menu
Kaloyanes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import Svg, { Circle } from "react-native-svg"; | ||
| import { withUniwind } from "uniwind"; | ||
|
|
||
| const ThemedCircle = withUniwind(Circle); | ||
|
|
||
| const RADIUS = 8; | ||
| const CIRCUMFERENCE = 2 * Math.PI * RADIUS; | ||
|
|
||
| /** Fills clockwise with `fraction` in the color `colorClassName` resolves to. */ | ||
| export function ProgressRing(props: { | ||
| readonly fraction: number; | ||
| readonly size: number; | ||
| readonly colorClassName: string; | ||
| }) { | ||
| const filled = Math.min(1, Math.max(0, props.fraction)); | ||
| return ( | ||
| <Svg width={props.size} height={props.size} viewBox="0 0 20 20" accessible={false}> | ||
| <ThemedCircle | ||
| cx={10} | ||
| cy={10} | ||
| r={RADIUS} | ||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeOpacity={0.2} | ||
| strokeWidth={3} | ||
| colorClassName={props.colorClassName} | ||
| /> | ||
| {filled > 0 ? ( | ||
| <ThemedCircle | ||
| cx={10} | ||
| cy={10} | ||
| r={RADIUS} | ||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeWidth={3} | ||
| strokeLinecap="round" | ||
| strokeDasharray={`${CIRCUMFERENCE * filled} ${CIRCUMFERENCE}`} | ||
| rotation={-90} | ||
| origin="10, 10" | ||
| colorClassName={props.colorClassName} | ||
| /> | ||
| ) : null} | ||
| </Svg> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
158 changes: 158 additions & 0 deletions
158
apps/mobile/src/features/threads/ThreadProgressSheet.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| import type { OrchestrationV2PlanStep } from "@t3tools/contracts"; | ||
| import type { TodoRunState } from "@t3tools/client-runtime/state/todo-progress"; | ||
| import BottomSheet, { BottomSheetView } from "@expo/ui/community/bottom-sheet"; | ||
| import { ScrollView, StyleSheet, useWindowDimensions, View } from "react-native"; | ||
| import { useResolveClassNames } from "uniwind"; | ||
|
|
||
| import { AppText as Text } from "../../components/ui/AppText"; | ||
| import { SymbolView } from "../../components/ui/AppSymbol"; | ||
| import { cn } from "../../lib/cn"; | ||
| import { | ||
| presentThreadProgress, | ||
| presentThreadProgressStep, | ||
| THREAD_PROGRESS_TONE_CLASSES, | ||
| type ThreadProgressTone, | ||
| } from "./thread-progress-presentation"; | ||
|
|
||
| const SEGMENT_TRACK_CLASSES = { | ||
| active: "bg-adaptive-sky-600-400/20", | ||
| waiting: "bg-warning-foreground/20", | ||
| done: "bg-adaptive-emerald-700-300/20", | ||
| muted: "bg-foreground-muted/20", | ||
| } as const satisfies Record<ThreadProgressTone, string>; | ||
|
|
||
| const SEGMENT_FILL_CLASSES = { | ||
| active: "bg-adaptive-sky-600-400", | ||
| waiting: "bg-warning-foreground", | ||
| done: "bg-adaptive-emerald-700-300", | ||
| muted: "bg-foreground-muted", | ||
| } as const satisfies Record<ThreadProgressTone, string>; | ||
|
|
||
| const ROW_TINT_CLASSES = { | ||
| active: "bg-adaptive-sky-600-400/10", | ||
| waiting: "bg-warning-foreground/10", | ||
| done: "", | ||
| muted: "", | ||
| } as const satisfies Record<ThreadProgressTone, string>; | ||
|
|
||
| function ProgressSegments(props: { | ||
| readonly segments: ReadonlyArray<{ | ||
| readonly id: string; | ||
| readonly status: OrchestrationV2PlanStep["status"]; | ||
| }> | null; | ||
| readonly fraction: number; | ||
| readonly tone: ThreadProgressTone; | ||
| }) { | ||
| const track = SEGMENT_TRACK_CLASSES[props.tone]; | ||
| const fill = SEGMENT_FILL_CLASSES[props.tone]; | ||
| if (props.segments === null) { | ||
| return ( | ||
| <View className={cn("h-1.5 overflow-hidden rounded-full", track)}> | ||
| <View | ||
| className={cn("h-full rounded-full", fill)} | ||
| style={{ width: `${Math.round(props.fraction * 100)}%` }} | ||
| /> | ||
| </View> | ||
| ); | ||
| } | ||
| return ( | ||
| <View className="flex-row gap-1"> | ||
| {props.segments.map(({ id, status }) => ( | ||
| <View key={id} className={cn("h-1.5 flex-1 overflow-hidden rounded-full", track)}> | ||
| {status === "completed" ? <View className={cn("h-full w-full", fill)} /> : null} | ||
| {status === "running" ? <View className={cn("h-full w-[45%]", fill)} /> : null} | ||
| </View> | ||
| ))} | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| export function ThreadProgressSheet({ | ||
| open, | ||
| onClose, | ||
| steps, | ||
| state, | ||
| }: { | ||
| readonly open: boolean; | ||
| readonly onClose: () => void; | ||
| readonly steps: ReadonlyArray<OrchestrationV2PlanStep>; | ||
| readonly state: TodoRunState; | ||
| }) { | ||
| const { height: windowHeight } = useWindowDimensions(); | ||
| const progress = presentThreadProgress(steps, state); | ||
| const background = StyleSheet.flatten(useResolveClassNames("bg-screen")); | ||
| return ( | ||
| <BottomSheet | ||
| index={open ? 0 : -1} | ||
| onClose={onClose} | ||
| enablePanDownToClose | ||
| backgroundStyle={background} | ||
| > | ||
| <BottomSheetView> | ||
| <View className="px-5 pb-2"> | ||
| <View className="flex-row items-baseline justify-between"> | ||
| <Text accessibilityRole="header" className="text-2xl font-t3-bold text-foreground"> | ||
| Progress | ||
| </Text> | ||
| <Text className="text-sm tabular-nums text-foreground-muted">{progress.summary}</Text> | ||
| </View> | ||
| <View className="mt-3"> | ||
| <ProgressSegments | ||
| segments={progress.segments} | ||
| fraction={progress.fraction} | ||
| tone={progress.tone} | ||
| /> | ||
| </View> | ||
| </View> | ||
| <ScrollView | ||
| style={{ maxHeight: windowHeight * 0.55 }} | ||
| contentContainerStyle={{ paddingHorizontal: 12, paddingBottom: 36, paddingTop: 6 }} | ||
| > | ||
| {steps.map((step) => { | ||
| const row = presentThreadProgressStep(step, state); | ||
| const tone = THREAD_PROGRESS_TONE_CLASSES[row.tone]; | ||
| return ( | ||
| <View | ||
| key={step.id} | ||
| accessibilityState={{ selected: step.status === "running" }} | ||
| className={cn( | ||
| "flex-row items-center gap-3 rounded-2xl px-3 py-3", | ||
| row.highlight && ROW_TINT_CLASSES[row.tone], | ||
| )} | ||
| > | ||
| <SymbolView | ||
| name={row.icon} | ||
| size={22} | ||
| tintColorClassName={tone.accent} | ||
| type="monochrome" | ||
| weight="medium" | ||
| /> | ||
| <View className="min-w-0 flex-1"> | ||
| <Text | ||
| className={cn( | ||
| "text-base", | ||
| row.highlight ? "font-t3-bold text-foreground" : "text-foreground-muted", | ||
| row.strike && "line-through", | ||
| )} | ||
| > | ||
| {step.text} | ||
| </Text> | ||
| {row.note ? ( | ||
| <Text | ||
| className={cn( | ||
| "mt-0.5 text-xs font-t3-medium", | ||
| row.tone === "waiting" ? tone.text : "text-foreground-muted", | ||
| )} | ||
| > | ||
| {row.note} | ||
| </Text> | ||
| ) : null} | ||
| </View> | ||
| </View> | ||
| ); | ||
| })} | ||
| </ScrollView> | ||
| </BottomSheetView> | ||
| </BottomSheet> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.