Repository navigation
Run one off Bash commands from the composer #7
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b361b27
feat(composer): run one-off Bash commands as agent context
Kaloyanes de32486
feat(chat): show expandable Bash results on user messages
Kaloyanes 0ee5cf0
fix(composer): center Bash glow around the input
Kaloyanes 5c43d44
feat(chat): show Bash results inline with messages
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
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
95 changes: 95 additions & 0 deletions
95
apps/mobile/src/features/threads/BashMessageDisclosure.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,95 @@ | ||
| import { | ||
| composerBashStatusLabel, | ||
| parseComposerBashOutput, | ||
| type ComposerBashCommand, | ||
| } from "@t3tools/client-runtime/composer-bash"; | ||
| import type { ReactNode } from "react"; | ||
| import { Pressable, ScrollView, View, type ColorValue } from "react-native"; | ||
| import Animated, { FadeIn, FadeInUp, FadeOut, ReduceMotion } from "react-native-reanimated"; | ||
| import { AppText as Text } from "../../components/AppText"; | ||
| import { cn } from "../../lib/cn"; | ||
| import { ThreadDisclosureChevron } from "./thread-work-log"; | ||
|
|
||
| export function BashMessageDisclosure({ | ||
| command, | ||
| expanded, | ||
| onToggle, | ||
| children, | ||
| chevronColor, | ||
| }: { | ||
| command: ComposerBashCommand | undefined; | ||
| expanded: boolean; | ||
| onToggle: () => void; | ||
| children: ReactNode; | ||
| chevronColor: ColorValue; | ||
| }) { | ||
| if (!command) return children; | ||
|
|
||
| return ( | ||
| <View className="min-w-0 gap-2 rounded-xl"> | ||
| <Pressable | ||
| accessibilityRole="button" | ||
| accessibilityLabel={composerBashStatusLabel(command)} | ||
| accessibilityState={{ expanded }} | ||
| onPress={onToggle} | ||
| className="min-h-11 flex-row items-center justify-between gap-2" | ||
| > | ||
| <Animated.View key={command.status} entering={FadeIn.duration(200)} className="shrink"> | ||
| <Text | ||
| className={cn( | ||
| "shrink font-t3-medium text-xs", | ||
| command.status === "failed" ? "text-danger-foreground" : "text-foreground-secondary", | ||
| )} | ||
| > | ||
| {composerBashStatusLabel(command)} | ||
| </Text> | ||
| </Animated.View> | ||
| <ThreadDisclosureChevron | ||
| expanded={expanded} | ||
| collapsedDirection="down" | ||
| size={14} | ||
| tintColor={chevronColor} | ||
| /> | ||
| </Pressable> | ||
| {children} | ||
| {expanded && ( | ||
| <Animated.View | ||
| entering={FadeInUp.duration(220).reduceMotion(ReduceMotion.System)} | ||
| exiting={FadeOut.duration(140)} | ||
| > | ||
| <BashOutput command={command} /> | ||
| </Animated.View> | ||
| )} | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| function BashOutput({ command }: { command: ComposerBashCommand }) { | ||
| if (!command.output) { | ||
| return ( | ||
| <Text className="text-xs text-foreground-secondary"> | ||
| {command.status === "running" ? "Running command…" : "No command output."} | ||
| </Text> | ||
| ); | ||
| } | ||
| const { exitCode, stdout, stderr } = parseComposerBashOutput(command.output); | ||
| return ( | ||
| <View className="gap-1"> | ||
| <ScrollView nestedScrollEnabled style={{ maxHeight: 320 }}> | ||
| <Text selectable className="font-mono text-xs text-user-bubble-foreground"> | ||
| {stdout} | ||
| {stdout && stderr ? "\n" : null} | ||
| {stderr ? ( | ||
| <Text className="font-mono text-xs text-danger-foreground">{stderr}</Text> | ||
| ) : null} | ||
| {!stdout && !stderr ? "No output" : null} | ||
| </Text> | ||
| </ScrollView> | ||
| {exitCode !== null && ( | ||
| <Text className="self-end font-mono text-2xs text-foreground-secondary"> | ||
| exit {exitCode} | ||
| </Text> | ||
| )} | ||
| </View> | ||
| ); | ||
| } |
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the mobile thread feed, expansion is now tracked under
bash-collapsed:${message.id}, but this width condition still checks the obsoletebash:${message.id}key. Consequently, the condition never widens a normally expanded Bash result, so short commands such as!lscan leave multiline output cramped into the command bubble instead of usinguserBubbleMaxWidth.Useful? React with 👍 / 👎.