refactor(app): remove unused CreateAgentModal
Agent creation now uses the /agent/new route exclusively. Remove the legacy modal and related deep link handling. 🤖 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
a12af74c7b
commit
1f9a35dafd
@@ -35,8 +35,7 @@ import { AgentStreamView } from "@/components/agent-stream-view";
|
|||||||
import { AgentInputArea } from "@/components/agent-input-area";
|
import { AgentInputArea } from "@/components/agent-input-area";
|
||||||
import { AgentList } from "@/components/agent-list";
|
import { AgentList } from "@/components/agent-list";
|
||||||
import { useAggregatedAgents } from "@/hooks/use-aggregated-agents";
|
import { useAggregatedAgents } from "@/hooks/use-aggregated-agents";
|
||||||
import { CreateAgentModal, ImportAgentModal } from "@/components/create-agent-modal";
|
import { ImportAgentModal } from "@/components/create-agent-modal";
|
||||||
import type { CreateAgentInitialValues } from "@/hooks/use-agent-form-state";
|
|
||||||
import { useDaemonConnections } from "@/contexts/daemon-connections-context";
|
import { useDaemonConnections } from "@/contexts/daemon-connections-context";
|
||||||
import type { ConnectionStatus } from "@/contexts/daemon-connections-context";
|
import type { ConnectionStatus } from "@/contexts/daemon-connections-context";
|
||||||
import { formatConnectionStatus } from "@/utils/daemons";
|
import { formatConnectionStatus } from "@/utils/daemons";
|
||||||
@@ -183,11 +182,7 @@ function AgentScreenContent({
|
|||||||
const [menuPosition, setMenuPosition] = useState({ top: 0, left: 0 });
|
const [menuPosition, setMenuPosition] = useState({ top: 0, left: 0 });
|
||||||
const [menuContentHeight, setMenuContentHeight] = useState(0);
|
const [menuContentHeight, setMenuContentHeight] = useState(0);
|
||||||
const menuButtonRef = useRef<View>(null);
|
const menuButtonRef = useRef<View>(null);
|
||||||
const [showCreateAgentModal, setShowCreateAgentModal] = useState(false);
|
|
||||||
const [showImportAgentModal, setShowImportAgentModal] = useState(false);
|
const [showImportAgentModal, setShowImportAgentModal] = useState(false);
|
||||||
const [createAgentInitialValues, setCreateAgentInitialValues] = useState<
|
|
||||||
CreateAgentInitialValues | undefined
|
|
||||||
>();
|
|
||||||
|
|
||||||
const resolvedAgentId = agentId;
|
const resolvedAgentId = agentId;
|
||||||
|
|
||||||
@@ -568,10 +563,6 @@ function AgentScreenContent({
|
|||||||
router.push({ pathname: "/agent/new", params });
|
router.push({ pathname: "/agent/new", params });
|
||||||
}, [agent, agentModel, handleCloseMenu, router, serverId]);
|
}, [agent, agentModel, handleCloseMenu, router, serverId]);
|
||||||
|
|
||||||
const handleCloseCreateAgentModal = useCallback(() => {
|
|
||||||
setShowCreateAgentModal(false);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleImportAgent = useCallback(() => {
|
const handleImportAgent = useCallback(() => {
|
||||||
handleCloseMenu();
|
handleCloseMenu();
|
||||||
setShowImportAgentModal(true);
|
setShowImportAgentModal(true);
|
||||||
@@ -595,15 +586,6 @@ function AgentScreenContent({
|
|||||||
[handleCloseMenu, router, serverId]
|
[handleCloseMenu, router, serverId]
|
||||||
);
|
);
|
||||||
|
|
||||||
const createAgentModal = (
|
|
||||||
<CreateAgentModal
|
|
||||||
isVisible={showCreateAgentModal}
|
|
||||||
onClose={handleCloseCreateAgentModal}
|
|
||||||
initialValues={createAgentInitialValues}
|
|
||||||
serverId={serverId}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
const importAgentModal = (
|
const importAgentModal = (
|
||||||
<ImportAgentModal
|
<ImportAgentModal
|
||||||
isVisible={showImportAgentModal}
|
isVisible={showImportAgentModal}
|
||||||
@@ -621,7 +603,6 @@ function AgentScreenContent({
|
|||||||
<Text style={styles.errorText}>Agent not found</Text>
|
<Text style={styles.errorText}>Agent not found</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
{createAgentModal}
|
|
||||||
{importAgentModal}
|
{importAgentModal}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -872,7 +853,6 @@ function AgentScreenContent({
|
|||||||
</View>
|
</View>
|
||||||
</Modal>
|
</Modal>
|
||||||
</View>
|
</View>
|
||||||
{createAgentModal}
|
|
||||||
{importAgentModal}
|
{importAgentModal}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { HomeHeader } from "@/components/headers/home-header";
|
|||||||
import { HomeFooter } from "@/components/home-footer";
|
import { HomeFooter } from "@/components/home-footer";
|
||||||
import { EmptyState } from "@/components/empty-state";
|
import { EmptyState } from "@/components/empty-state";
|
||||||
import { AgentList } from "@/components/agent-list";
|
import { AgentList } from "@/components/agent-list";
|
||||||
import { CreateAgentModal, ImportAgentModal } from "@/components/create-agent-modal";
|
import { ImportAgentModal } from "@/components/create-agent-modal";
|
||||||
import { useAggregatedAgents } from "@/hooks/use-aggregated-agents";
|
import { useAggregatedAgents } from "@/hooks/use-aggregated-agents";
|
||||||
import { useLocalSearchParams, useRouter } from "expo-router";
|
import { useLocalSearchParams, useRouter } from "expo-router";
|
||||||
import { endNavigationTiming, HOME_NAVIGATION_KEY } from "@/utils/navigation-timing";
|
import { endNavigationTiming, HOME_NAVIGATION_KEY } from "@/utils/navigation-timing";
|
||||||
@@ -24,7 +24,6 @@ export default function HomeScreen() {
|
|||||||
refreshAll,
|
refreshAll,
|
||||||
} = useAggregatedAgents();
|
} = useAggregatedAgents();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [showCreateModal, setShowCreateModal] = useState(false);
|
|
||||||
const [showImportModal, setShowImportModal] = useState(false);
|
const [showImportModal, setShowImportModal] = useState(false);
|
||||||
const [pendingImportServerId, setPendingImportServerId] = useState<string | null>(null);
|
const [pendingImportServerId, setPendingImportServerId] = useState<string | null>(null);
|
||||||
const { modal, flow, action, serverId: serverIdParam } = useLocalSearchParams<{
|
const { modal, flow, action, serverId: serverIdParam } = useLocalSearchParams<{
|
||||||
@@ -34,7 +33,6 @@ export default function HomeScreen() {
|
|||||||
serverId?: string;
|
serverId?: string;
|
||||||
}>();
|
}>();
|
||||||
const deepLinkHandledRef = useRef<string | null>(null);
|
const deepLinkHandledRef = useRef<string | null>(null);
|
||||||
const createDeepLinkHandledRef = useRef<string | null>(null);
|
|
||||||
|
|
||||||
// Keyboard animation
|
// Keyboard animation
|
||||||
const { height: keyboardHeight } = useReanimatedKeyboardAnimation();
|
const { height: keyboardHeight } = useReanimatedKeyboardAnimation();
|
||||||
@@ -62,10 +60,6 @@ export default function HomeScreen() {
|
|||||||
openImportModal();
|
openImportModal();
|
||||||
}, [openImportModal]);
|
}, [openImportModal]);
|
||||||
|
|
||||||
const handleCloseCreateModal = useCallback(() => {
|
|
||||||
setShowCreateModal(false);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleCloseImportModal = useCallback(() => {
|
const handleCloseImportModal = useCallback(() => {
|
||||||
setShowImportModal(false);
|
setShowImportModal(false);
|
||||||
setPendingImportServerId(null);
|
setPendingImportServerId(null);
|
||||||
@@ -77,12 +71,6 @@ export default function HomeScreen() {
|
|||||||
(value) => typeof value === "string" && value.trim().toLowerCase() === "import"
|
(value) => typeof value === "string" && value.trim().toLowerCase() === "import"
|
||||||
);
|
);
|
||||||
}, [action, flow, modal]);
|
}, [action, flow, modal]);
|
||||||
const wantsCreateDeepLink = useMemo(() => {
|
|
||||||
const values = [modal, flow, action];
|
|
||||||
return values.some(
|
|
||||||
(value) => typeof value === "string" && value.trim().toLowerCase() === "create"
|
|
||||||
);
|
|
||||||
}, [action, flow, modal]);
|
|
||||||
const deepLinkServerId = typeof serverIdParam === "string" ? serverIdParam : null;
|
const deepLinkServerId = typeof serverIdParam === "string" ? serverIdParam : null;
|
||||||
const deepLinkKey = useMemo(() => {
|
const deepLinkKey = useMemo(() => {
|
||||||
if (!wantsImportDeepLink) {
|
if (!wantsImportDeepLink) {
|
||||||
@@ -95,16 +83,6 @@ export default function HomeScreen() {
|
|||||||
serverId: deepLinkServerId,
|
serverId: deepLinkServerId,
|
||||||
});
|
});
|
||||||
}, [action, flow, modal, deepLinkServerId, wantsImportDeepLink]);
|
}, [action, flow, modal, deepLinkServerId, wantsImportDeepLink]);
|
||||||
const createDeepLinkKey = useMemo(() => {
|
|
||||||
if (!wantsCreateDeepLink) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JSON.stringify({
|
|
||||||
action: action ?? null,
|
|
||||||
flow: flow ?? null,
|
|
||||||
modal: modal ?? null,
|
|
||||||
});
|
|
||||||
}, [action, flow, modal, wantsCreateDeepLink]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!wantsImportDeepLink || !deepLinkKey) {
|
if (!wantsImportDeepLink || !deepLinkKey) {
|
||||||
@@ -117,17 +95,6 @@ export default function HomeScreen() {
|
|||||||
deepLinkHandledRef.current = deepLinkKey;
|
deepLinkHandledRef.current = deepLinkKey;
|
||||||
openImportModal(deepLinkServerId);
|
openImportModal(deepLinkServerId);
|
||||||
}, [deepLinkKey, deepLinkServerId, openImportModal, wantsImportDeepLink]);
|
}, [deepLinkKey, deepLinkServerId, openImportModal, wantsImportDeepLink]);
|
||||||
useEffect(() => {
|
|
||||||
if (!wantsCreateDeepLink || !createDeepLinkKey) {
|
|
||||||
createDeepLinkHandledRef.current = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (createDeepLinkHandledRef.current === createDeepLinkKey) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
createDeepLinkHandledRef.current = createDeepLinkKey;
|
|
||||||
setShowCreateModal(true);
|
|
||||||
}, [createDeepLinkKey, wantsCreateDeepLink]);
|
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
@@ -166,8 +133,7 @@ export default function HomeScreen() {
|
|||||||
{/* Home Footer */}
|
{/* Home Footer */}
|
||||||
<HomeFooter />
|
<HomeFooter />
|
||||||
|
|
||||||
{/* Create Agent Modal */}
|
{/* Import Agent Modal */}
|
||||||
<CreateAgentModal isVisible={showCreateModal} onClose={handleCloseCreateModal} />
|
|
||||||
<ImportAgentModal
|
<ImportAgentModal
|
||||||
isVisible={showImportModal}
|
isVisible={showImportModal}
|
||||||
onClose={handleCloseImportModal}
|
onClose={handleCloseImportModal}
|
||||||
|
|||||||
@@ -1705,10 +1705,6 @@ function LazyAgentFlowModal(props: Omit<AgentFlowModalProps, "onAfterClose">) {
|
|||||||
return <AgentFlowModal {...props} onAfterClose={handleAfterClose} />;
|
return <AgentFlowModal {...props} onAfterClose={handleAfterClose} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CreateAgentModal(props: ModalWrapperProps) {
|
|
||||||
return <LazyAgentFlowModal {...props} flow="create" />;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function ImportAgentModal(props: ModalWrapperProps) {
|
export function ImportAgentModal(props: ModalWrapperProps) {
|
||||||
return <LazyAgentFlowModal {...props} flow="import" />;
|
return <LazyAgentFlowModal {...props} flow="import" />;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user