Render speak tool calls inline as spoken messages
Instead of showing speak tool calls as expandable tool call badges, render them inline with a mic icon header matching assistant message styling.
This commit is contained in:
@@ -26,6 +26,7 @@ import { Check, ChevronDown, X } from "lucide-react-native";
|
|||||||
import { usePanelStore } from "@/stores/panel-store";
|
import { usePanelStore } from "@/stores/panel-store";
|
||||||
import {
|
import {
|
||||||
AssistantMessage,
|
AssistantMessage,
|
||||||
|
SpeakMessage,
|
||||||
UserMessage,
|
UserMessage,
|
||||||
ActivityLog,
|
ActivityLog,
|
||||||
ToolCall,
|
ToolCall,
|
||||||
@@ -359,6 +360,21 @@ const AgentStreamViewComponent = forwardRef<AgentStreamViewHandle, AgentStreamVi
|
|||||||
|
|
||||||
if (payload.source === "agent") {
|
if (payload.source === "agent") {
|
||||||
const data = payload.data;
|
const data = payload.data;
|
||||||
|
|
||||||
|
if (
|
||||||
|
data.name === "speak" &&
|
||||||
|
data.detail.type === "unknown" &&
|
||||||
|
typeof data.detail.input === "string" &&
|
||||||
|
data.detail.input.trim()
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<SpeakMessage
|
||||||
|
message={data.detail.input}
|
||||||
|
timestamp={item.timestamp.getTime()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ToolCall
|
<ToolCall
|
||||||
toolName={data.name}
|
toolName={data.name}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import {
|
|||||||
Copy,
|
Copy,
|
||||||
TriangleAlertIcon,
|
TriangleAlertIcon,
|
||||||
Scissors,
|
Scissors,
|
||||||
|
MicVocal,
|
||||||
} from "lucide-react-native";
|
} from "lucide-react-native";
|
||||||
import { StyleSheet, useUnistyles, UnistylesRuntime } from "react-native-unistyles";
|
import { StyleSheet, useUnistyles, UnistylesRuntime } from "react-native-unistyles";
|
||||||
import Animated, {
|
import Animated, {
|
||||||
@@ -913,6 +914,65 @@ export const AssistantMessage = memo(function AssistantMessage({
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
interface SpeakMessageProps {
|
||||||
|
message: string;
|
||||||
|
timestamp: number;
|
||||||
|
disableOuterSpacing?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const speakMessageStylesheet = StyleSheet.create((theme) => ({
|
||||||
|
container: {
|
||||||
|
paddingHorizontal: theme.spacing[2],
|
||||||
|
paddingVertical: theme.spacing[3],
|
||||||
|
},
|
||||||
|
containerSpacing: {
|
||||||
|
marginBottom: theme.spacing[4],
|
||||||
|
},
|
||||||
|
header: {
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: theme.spacing[2],
|
||||||
|
marginBottom: theme.spacing[2],
|
||||||
|
},
|
||||||
|
headerLabel: {
|
||||||
|
fontFamily: Fonts.sans,
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: "500",
|
||||||
|
color: theme.colors.foregroundMuted,
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
fontFamily: Fonts.sans,
|
||||||
|
fontSize: theme.fontSize.base,
|
||||||
|
lineHeight: 22,
|
||||||
|
color: theme.colors.foreground,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const SpeakMessage = memo(function SpeakMessage({
|
||||||
|
message,
|
||||||
|
timestamp,
|
||||||
|
disableOuterSpacing,
|
||||||
|
}: SpeakMessageProps) {
|
||||||
|
const { theme } = useUnistyles();
|
||||||
|
const resolvedDisableOuterSpacing = useDisableOuterSpacing(disableOuterSpacing);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
testID="speak-message"
|
||||||
|
style={[
|
||||||
|
speakMessageStylesheet.container,
|
||||||
|
!resolvedDisableOuterSpacing && speakMessageStylesheet.containerSpacing,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<View style={speakMessageStylesheet.header}>
|
||||||
|
<MicVocal size={14} color={theme.colors.foregroundMuted} />
|
||||||
|
<Text style={speakMessageStylesheet.headerLabel}>Spoke</Text>
|
||||||
|
</View>
|
||||||
|
<Text style={speakMessageStylesheet.text}>{message}</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
interface ActivityLogProps {
|
interface ActivityLogProps {
|
||||||
type: "system" | "info" | "success" | "error" | "artifact";
|
type: "system" | "info" | "success" | "error" | "artifact";
|
||||||
message: string;
|
message: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user