refactor: restore agent status bar and clean up input area layout
- Add AgentStatusBar back to agent screen layout above controls - Remove duplicate mode badge from AgentInputArea (now only in status bar) - Simplify AgentInputArea to horizontal layout matching RealtimeControls - Set both controls to height: 88 for consistent sizing - Remove conditional rendering that caused component to unmount 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -7,13 +7,16 @@ import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
|||||||
import { BackHeader } from "@/components/headers/back-header";
|
import { BackHeader } from "@/components/headers/back-header";
|
||||||
import { AgentStreamView } from "@/components/agent-stream-view";
|
import { AgentStreamView } from "@/components/agent-stream-view";
|
||||||
import { AgentInputArea } from "@/components/agent-input-area";
|
import { AgentInputArea } from "@/components/agent-input-area";
|
||||||
|
import { AgentStatusBar } from "@/components/agent-status-bar";
|
||||||
import { useSession } from "@/contexts/session-context";
|
import { useSession } from "@/contexts/session-context";
|
||||||
|
import { useRealtime } from "@/contexts/realtime-context";
|
||||||
|
|
||||||
export default function AgentScreen() {
|
export default function AgentScreen() {
|
||||||
const { theme } = useUnistyles();
|
const { theme } = useUnistyles();
|
||||||
const insets = useSafeAreaInsets();
|
const insets = useSafeAreaInsets();
|
||||||
const { id } = useLocalSearchParams<{ id: string }>();
|
const { id } = useLocalSearchParams<{ id: string }>();
|
||||||
const { agents, agentStreamState, pendingPermissions, respondToPermission } = useSession();
|
const { agents, agentStreamState, pendingPermissions, respondToPermission } = useSession();
|
||||||
|
const { isRealtimeMode } = useRealtime();
|
||||||
|
|
||||||
// Keyboard animation
|
// Keyboard animation
|
||||||
const { height: keyboardHeight } = useReanimatedKeyboardAnimation();
|
const { height: keyboardHeight } = useReanimatedKeyboardAnimation();
|
||||||
@@ -60,13 +63,19 @@ export default function AgentScreen() {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Agent Input - will hide itself when realtime is active */}
|
{/* Footer area - status bar + controls */}
|
||||||
<ReanimatedAnimated.View
|
<View style={[styles.footerContainer, { paddingBottom: insets.bottom }]}>
|
||||||
entering={FadeIn.duration(250).delay(100)}
|
{/* Status bar - always visible, floating above controls */}
|
||||||
style={[styles.inputContainer, { paddingBottom: insets.bottom }]}
|
<AgentStatusBar agentId={id!} />
|
||||||
>
|
|
||||||
<AgentInputArea agentId={id!} />
|
{/* Controls - only show AgentInputArea when not in realtime mode */}
|
||||||
</ReanimatedAnimated.View>
|
{/* When in realtime mode, GlobalFooter handles showing RealtimeControls */}
|
||||||
|
{!isRealtimeMode && (
|
||||||
|
<View style={styles.controlsContainer}>
|
||||||
|
<AgentInputArea agentId={id!} />
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
</ReanimatedAnimated.View>
|
</ReanimatedAnimated.View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
@@ -80,8 +89,10 @@ const styles = StyleSheet.create((theme) => ({
|
|||||||
content: {
|
content: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
},
|
},
|
||||||
inputContainer: {
|
footerContainer: {
|
||||||
backgroundColor: theme.colors.background,
|
backgroundColor: theme.colors.background,
|
||||||
|
},
|
||||||
|
controlsContainer: {
|
||||||
borderTopWidth: theme.borderWidth[1],
|
borderTopWidth: theme.borderWidth[1],
|
||||||
borderTopColor: theme.colors.border,
|
borderTopColor: theme.colors.border,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { View, TextInput, Pressable, Text } from "react-native";
|
import { View, TextInput, Pressable } from "react-native";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
||||||
import { Mic, ArrowUp, AudioLines, Square, ChevronDown } from "lucide-react-native";
|
import { Mic, ArrowUp, AudioLines, Square } from "lucide-react-native";
|
||||||
import { useSession } from "@/contexts/session-context";
|
import { useSession } from "@/contexts/session-context";
|
||||||
import { useRealtime } from "@/contexts/realtime-context";
|
import { useRealtime } from "@/contexts/realtime-context";
|
||||||
import { useAudioRecorder } from "@/hooks/use-audio-recorder";
|
import { useAudioRecorder } from "@/hooks/use-audio-recorder";
|
||||||
import { ModeSelectorModal } from "./mode-selector-modal";
|
|
||||||
|
|
||||||
interface AgentInputAreaProps {
|
interface AgentInputAreaProps {
|
||||||
agentId: string;
|
agentId: string;
|
||||||
@@ -13,21 +12,13 @@ interface AgentInputAreaProps {
|
|||||||
|
|
||||||
export function AgentInputArea({ agentId }: AgentInputAreaProps) {
|
export function AgentInputArea({ agentId }: AgentInputAreaProps) {
|
||||||
const { theme } = useUnistyles();
|
const { theme } = useUnistyles();
|
||||||
const { agents, ws, sendAgentMessage, sendAgentAudio, setAgentMode } = useSession();
|
const { ws, sendAgentMessage, sendAgentAudio } = useSession();
|
||||||
const { isRealtimeMode, startRealtime } = useRealtime();
|
const { startRealtime } = useRealtime();
|
||||||
const audioRecorder = useAudioRecorder();
|
const audioRecorder = useAudioRecorder();
|
||||||
|
|
||||||
const [userInput, setUserInput] = useState("");
|
const [userInput, setUserInput] = useState("");
|
||||||
const [isRecording, setIsRecording] = useState(false);
|
const [isRecording, setIsRecording] = useState(false);
|
||||||
const [isProcessing, setIsProcessing] = useState(false);
|
const [isProcessing, setIsProcessing] = useState(false);
|
||||||
const [showModeSelector, setShowModeSelector] = useState(false);
|
|
||||||
|
|
||||||
const agent = agents.get(agentId);
|
|
||||||
|
|
||||||
// Hide when realtime is active - global footer takes over
|
|
||||||
if (isRealtimeMode) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleSendMessage() {
|
async function handleSendMessage() {
|
||||||
if (!userInput.trim() || !ws.isConnected) return;
|
if (!userInput.trim() || !ws.isConnected) return;
|
||||||
@@ -82,10 +73,6 @@ export function AgentInputArea({ agentId }: AgentInputAreaProps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleModeChange(modeId: string) {
|
|
||||||
setAgentMode(agentId, modeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
const hasText = userInput.trim().length > 0;
|
const hasText = userInput.trim().length > 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -101,26 +88,8 @@ export function AgentInputArea({ agentId }: AgentInputAreaProps) {
|
|||||||
editable={!isRecording && ws.isConnected}
|
editable={!isRecording && ws.isConnected}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Controls row */}
|
{/* Buttons */}
|
||||||
<View style={styles.controlsRow}>
|
<View style={styles.buttonRow}>
|
||||||
{/* Mode badge - only show if agent has modes */}
|
|
||||||
{agent && agent.availableModes && agent.availableModes.length > 0 && (
|
|
||||||
<Pressable
|
|
||||||
onPress={() => setShowModeSelector(true)}
|
|
||||||
style={({ pressed }) => [
|
|
||||||
styles.modeBadge,
|
|
||||||
pressed && styles.modeBadgePressed,
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<Text style={styles.modeBadgeText}>
|
|
||||||
{agent.availableModes?.find(m => m.id === agent.currentModeId)?.name || agent.currentModeId || 'default'}
|
|
||||||
</Text>
|
|
||||||
<ChevronDown size={14} color={theme.colors.mutedForeground} />
|
|
||||||
</Pressable>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Buttons */}
|
|
||||||
<View style={styles.buttonRow}>
|
|
||||||
{hasText ? (
|
{hasText ? (
|
||||||
// Send button when text is entered
|
// Send button when text is entered
|
||||||
<Pressable
|
<Pressable
|
||||||
@@ -166,64 +135,35 @@ export function AgentInputArea({ agentId }: AgentInputAreaProps) {
|
|||||||
</Pressable>
|
</Pressable>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* Mode selector modal */}
|
|
||||||
<ModeSelectorModal
|
|
||||||
visible={showModeSelector}
|
|
||||||
agent={agent || null}
|
|
||||||
onModeChange={handleModeChange}
|
|
||||||
onClose={() => setShowModeSelector(false)}
|
|
||||||
/>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create((theme) => ({
|
const styles = StyleSheet.create((theme) => ({
|
||||||
container: {
|
container: {
|
||||||
padding: theme.spacing[4],
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
paddingHorizontal: theme.spacing[4],
|
||||||
|
paddingVertical: theme.spacing[4],
|
||||||
gap: theme.spacing[3],
|
gap: theme.spacing[3],
|
||||||
|
height: 88,
|
||||||
},
|
},
|
||||||
textInput: {
|
textInput: {
|
||||||
minHeight: 44,
|
flex: 1,
|
||||||
maxHeight: 120,
|
minHeight: 40,
|
||||||
|
maxHeight: 80,
|
||||||
paddingHorizontal: theme.spacing[4],
|
paddingHorizontal: theme.spacing[4],
|
||||||
paddingVertical: theme.spacing[3],
|
paddingVertical: theme.spacing[2],
|
||||||
backgroundColor: theme.colors.muted,
|
backgroundColor: theme.colors.muted,
|
||||||
borderRadius: theme.borderRadius.lg,
|
borderRadius: theme.borderRadius.lg,
|
||||||
color: theme.colors.foreground,
|
color: theme.colors.foreground,
|
||||||
fontSize: theme.fontSize.base,
|
fontSize: theme.fontSize.base,
|
||||||
},
|
},
|
||||||
controlsRow: {
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
gap: theme.spacing[2],
|
|
||||||
},
|
|
||||||
modeBadge: {
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: theme.spacing[2],
|
|
||||||
paddingHorizontal: theme.spacing[3],
|
|
||||||
paddingVertical: theme.spacing[2],
|
|
||||||
backgroundColor: theme.colors.muted,
|
|
||||||
borderRadius: theme.borderRadius.full,
|
|
||||||
},
|
|
||||||
modeBadgePressed: {
|
|
||||||
backgroundColor: theme.colors.accent,
|
|
||||||
},
|
|
||||||
modeBadgeText: {
|
|
||||||
color: theme.colors.mutedForeground,
|
|
||||||
fontSize: theme.fontSize.xs,
|
|
||||||
fontWeight: theme.fontWeight.semibold,
|
|
||||||
textTransform: "capitalize",
|
|
||||||
},
|
|
||||||
buttonRow: {
|
buttonRow: {
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
gap: theme.spacing[2],
|
gap: theme.spacing[2],
|
||||||
marginLeft: "auto",
|
|
||||||
},
|
},
|
||||||
sendButton: {
|
sendButton: {
|
||||||
width: 40,
|
width: 40,
|
||||||
|
|||||||
Reference in New Issue
Block a user