fix: back button returns to parent agent instead of homepage
When viewing a child agent (an agent with parentAgentId set), the back button now navigates to the parent agent screen instead of always going to the homepage. Added handleBack callback in AgentScreenContent that checks for parentAgentId and routes accordingly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
3f0a08ad50
commit
7d233777db
@@ -153,6 +153,26 @@ function AgentScreenContent({ serverId, agentId, onBack }: AgentScreenContentPro
|
||||
resolvedAgentId ? state.sessions[serverId]?.agents?.get(resolvedAgentId) : undefined
|
||||
);
|
||||
|
||||
// Get parent agent ID for back navigation
|
||||
const parentAgentId = agent?.parentAgentId;
|
||||
|
||||
// Navigate to parent agent if this is a child, otherwise go to homepage
|
||||
const handleBack = useCallback(() => {
|
||||
if (parentAgentId) {
|
||||
// Child agent: navigate back to parent
|
||||
router.push({
|
||||
pathname: "/agent/[serverId]/[agentId]",
|
||||
params: {
|
||||
serverId: serverId,
|
||||
agentId: parentAgentId,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
// Root agent: navigate to homepage
|
||||
onBack();
|
||||
}
|
||||
}, [parentAgentId, router, serverId, onBack]);
|
||||
|
||||
// Select the agents Map directly - this is a stable reference that only changes when agents are added/removed
|
||||
const allAgents = useSessionStore((state) => state.sessions[serverId]?.agents);
|
||||
|
||||
@@ -507,7 +527,7 @@ function AgentScreenContent({ serverId, agentId, onBack }: AgentScreenContentPro
|
||||
{/* Header */}
|
||||
<BackHeader
|
||||
title={agent.title || "Agent"}
|
||||
onBack={onBack}
|
||||
onBack={handleBack}
|
||||
rightContent={
|
||||
<View ref={menuButtonRef} collapsable={false}>
|
||||
<Pressable onPress={handleOpenMenu} style={styles.menuButton}>
|
||||
|
||||
Reference in New Issue
Block a user