Fix e2e daemon isolation and fast model defaults
This commit is contained in:
@@ -12,6 +12,7 @@ import { StyleSheet, UnistylesRuntime, useUnistyles } from "react-native-unistyl
|
||||
import { Plus, Settings } from "lucide-react-native";
|
||||
import { router } from "expo-router";
|
||||
import { usePanelStore } from "@/stores/panel-store";
|
||||
import { useSessionStore } from "@/stores/session-store";
|
||||
import { AgentList } from "./agent-list";
|
||||
import { useAggregatedAgents } from "@/hooks/use-aggregated-agents";
|
||||
import { useSidebarAnimation } from "@/contexts/sidebar-animation-context";
|
||||
@@ -24,6 +25,30 @@ interface SlidingSidebarProps {
|
||||
selectedAgentId?: string;
|
||||
}
|
||||
|
||||
function buildCreateAgentRouteFromSelectedAgentKey(selectedAgentKey?: string) {
|
||||
if (!selectedAgentKey) {
|
||||
return { pathname: "/" as const, params: {} as Record<string, string> };
|
||||
}
|
||||
|
||||
const [serverId, agentId] = selectedAgentKey.split(":", 2);
|
||||
if (!serverId || !agentId) {
|
||||
return { pathname: "/" as const, params: {} as Record<string, string> };
|
||||
}
|
||||
|
||||
const state = useSessionStore.getState();
|
||||
const agent = state.sessions[serverId]?.agents.get(agentId);
|
||||
if (!agent) {
|
||||
return { pathname: "/" as const, params: {} as Record<string, string> };
|
||||
}
|
||||
|
||||
const params: Record<string, string> = { serverId: agent.serverId };
|
||||
if (agent.provider) params.provider = agent.provider;
|
||||
if (agent.currentModeId) params.modeId = agent.currentModeId;
|
||||
if (agent.model) params.model = agent.model;
|
||||
if (agent.cwd) params.workingDir = agent.cwd;
|
||||
return { pathname: "/" as const, params };
|
||||
}
|
||||
|
||||
export function SlidingSidebar({ selectedAgentId }: SlidingSidebarProps) {
|
||||
const { theme } = useUnistyles();
|
||||
const insets = useSafeAreaInsets();
|
||||
@@ -81,17 +106,20 @@ export function SlidingSidebar({ selectedAgentId }: SlidingSidebarProps) {
|
||||
closeToAgent();
|
||||
}, [closeToAgent]);
|
||||
|
||||
const handleCreateAgent = useCallback(() => {
|
||||
router.push(buildCreateAgentRouteFromSelectedAgentKey(selectedAgentId));
|
||||
}, [selectedAgentId]);
|
||||
|
||||
// Mobile: close sidebar and navigate
|
||||
const handleCreateAgentMobile = useCallback(() => {
|
||||
closeToAgent();
|
||||
router.push("/");
|
||||
}, [closeToAgent]);
|
||||
handleCreateAgent();
|
||||
}, [closeToAgent, handleCreateAgent]);
|
||||
|
||||
// Desktop: just navigate, don't close
|
||||
const handleCreateAgentDesktop = useCallback(() => {
|
||||
router.push("/");
|
||||
}, []);
|
||||
handleCreateAgent();
|
||||
}, [handleCreateAgent]);
|
||||
|
||||
// Mobile: close sidebar and navigate
|
||||
const handleSettingsMobile = useCallback(() => {
|
||||
@@ -211,6 +239,7 @@ export function SlidingSidebar({ selectedAgentId }: SlidingSidebarProps) {
|
||||
styles.newAgentButton,
|
||||
hovered && styles.newAgentButtonHovered,
|
||||
]}
|
||||
testID="sidebar-new-agent"
|
||||
onPress={handleCreateAgentMobile}
|
||||
>
|
||||
<Plus size={18} color={theme.colors.foreground} />
|
||||
@@ -262,6 +291,7 @@ export function SlidingSidebar({ selectedAgentId }: SlidingSidebarProps) {
|
||||
styles.newAgentButton,
|
||||
hovered && styles.newAgentButtonHovered,
|
||||
]}
|
||||
testID="sidebar-new-agent"
|
||||
onPress={handleCreateAgentDesktop}
|
||||
>
|
||||
<Plus size={18} color={theme.colors.foreground} />
|
||||
|
||||
Reference in New Issue
Block a user