feat: remove import agent feature from UI

Remove the import agent functionality from the app while preserving
the underlying resume capability in the agent code.

Changes:
- Remove ImportAgentModal and import flow from create-agent-modal.tsx
- Remove "Import Agent" menu item from agent screen
- Remove "Import" button from home footer
- Remove resumeAgent from session context and store
- Remove list_persisted_agents WS messages from server
- Remove handleListPersistedAgentsRequest handler
- Clean up unused styles and types

The resumeAgent capability remains in the agent manager for potential
future use or internal tooling.
This commit is contained in:
Mohamed Boudra
2026-01-08 21:48:48 +07:00
parent f2e03c53c1
commit cc74d6d0d2
9 changed files with 80 additions and 1297 deletions

View File

@@ -29,7 +29,6 @@ import {
GitBranch,
Folder,
RotateCcw,
Download,
Users,
ChevronRight,
PlusIcon,
@@ -39,7 +38,6 @@ import { MenuHeader } from "@/components/headers/menu-header";
import { BackHeader } from "@/components/headers/back-header";
import { AgentStreamView } from "@/components/agent-stream-view";
import { AgentInputArea } from "@/components/agent-input-area";
import { ImportAgentModal } from "@/components/create-agent-modal";
import { ExplorerSidebar } from "@/components/explorer-sidebar";
import { FileDropZone } from "@/components/file-drop-zone";
import type { ImageAttachment } from "@/components/message-input";
@@ -184,7 +182,6 @@ function AgentScreenContent({
const [menuPosition, setMenuPosition] = useState({ top: 0, left: 0 });
const [menuContentHeight, setMenuContentHeight] = useState(0);
const menuButtonRef = useRef<View>(null);
const [showImportAgentModal, setShowImportAgentModal] = useState(false);
const addImagesRef = useRef<((images: ImageAttachment[]) => void) | null>(null);
const handleFilesDropped = useCallback((files: ImageAttachment[]) => {
@@ -636,15 +633,6 @@ function AgentScreenContent({
router.push({ pathname: "/", params });
}, [agent, agentModel, handleCloseMenu, router, serverId]);
const handleImportAgent = useCallback(() => {
handleCloseMenu();
setShowImportAgentModal(true);
}, [handleCloseMenu]);
const handleCloseImportAgentModal = useCallback(() => {
setShowImportAgentModal(false);
}, []);
const handleNavigateToChildAgent = useCallback(
(childAgentId: string) => {
handleCloseMenu();
@@ -659,25 +647,14 @@ function AgentScreenContent({
[handleCloseMenu, router, serverId]
);
const importAgentModal = (
<ImportAgentModal
isVisible={showImportAgentModal}
onClose={handleCloseImportAgentModal}
serverId={serverId}
/>
);
if (!agent) {
return (
<>
<View style={styles.container}>
<MenuHeader title="Agent" />
<View style={styles.errorContainer}>
<Text style={styles.errorText}>Agent not found</Text>
</View>
<View style={styles.container}>
<MenuHeader title="Agent" />
<View style={styles.errorContainer}>
<Text style={styles.errorText}>Agent not found</Text>
</View>
{importAgentModal}
</>
</View>
);
}
@@ -879,10 +856,6 @@ function AgentScreenContent({
<Folder size={16} color={theme.colors.foreground} />
<Text style={styles.menuItemText}>Browse Files</Text>
</Pressable>
<Pressable onPress={handleImportAgent} style={styles.menuItem}>
<Download size={16} color={theme.colors.foreground} />
<Text style={styles.menuItemText}>Import Agent</Text>
</Pressable>
<Pressable onPress={handleCreateNewAgent} style={styles.menuItem}>
<PlusIcon size={16} color={theme.colors.foreground} />
<Text style={styles.menuItemText}>New Agent</Text>
@@ -934,8 +907,6 @@ function AgentScreenContent({
{isMobile && resolvedAgentId && (
<ExplorerSidebar serverId={serverId} agentId={resolvedAgentId} />
)}
{importAgentModal}
</>
);
}

File diff suppressed because it is too large Load Diff

View File

@@ -3,12 +3,11 @@ import { View, Pressable, Text, Platform, Modal, Alert } from "react-native";
import { useRouter } from "expo-router";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { StyleSheet, useUnistyles } from "react-native-unistyles";
import { AudioLines, Users, Plus, Download } from "lucide-react-native";
import { AudioLines, Users, Plus } from "lucide-react-native";
import { useRealtime } from "@/contexts/realtime-context";
import { useDaemonConnections } from "@/contexts/daemon-connections-context";
import { FOOTER_HEIGHT } from "@/constants/layout";
import { RealtimeControls } from "./realtime-controls";
import { ImportAgentModal } from "./create-agent-modal";
import Animated, {
FadeIn,
FadeOut,
@@ -22,7 +21,6 @@ export function HomeFooter() {
const router = useRouter();
const { isRealtimeMode, startRealtime } = useRealtime();
const { connectionStates } = useDaemonConnections();
const [showImportModal, setShowImportModal] = useState(false);
const [showRealtimeHostPicker, setShowRealtimeHostPicker] = useState(false);
// Guard Reanimated entry/exit transitions on Android to avoid ViewGroup.dispatchDraw crashes
// tracked in react-native-reanimated#8422.
@@ -141,25 +139,6 @@ export function HomeFooter() {
<Text style={styles.footerButtonText}>Agents</Text>
</Pressable>
<Pressable
onPress={() => {
setShowImportModal(true);
}}
style={({ pressed }) => [
styles.footerButton,
pressed && styles.buttonPressed,
]}
>
<View style={styles.footerIconWrapper}>
<Download
size={iconSize}
color={theme.colors.foreground}
style={iconStyle}
/>
</View>
<Text style={styles.footerButtonText}>Import</Text>
</Pressable>
<Pressable
onPress={() => {
console.log("[HomeFooter] New Agent button pressed");
@@ -202,10 +181,6 @@ export function HomeFooter() {
</View>
</Animated.View>
<ImportAgentModal
isVisible={showImportModal}
onClose={() => setShowImportModal(false)}
/>
<Modal
visible={showRealtimeHostPicker}
transparent

View File

@@ -208,7 +208,6 @@ export interface SessionContextValue {
worktreeName?: string;
requestId?: string;
}) => void;
resumeAgent: (options: { handle: any; overrides?: any; requestId?: string }) => void;
setAgentMode: (agentId: string, modeId: string) => void;
respondToPermission: (agentId: string, requestId: string, response: any) => void;
}
@@ -1573,19 +1572,6 @@ export function SessionProvider({ children, serverUrl, serverId }: SessionProvid
ws.send(msg);
}, [encodeImages, ws]);
const resumeAgent = useCallback(({ handle, overrides, requestId }: { handle: any; overrides?: any; requestId?: string }) => {
const msg: WSInboundMessage = {
type: "session",
message: {
type: "resume_agent_request",
handle,
...(overrides ? { overrides } : {}),
...(requestId ? { requestId } : {}),
},
};
ws.send(msg);
}, [ws]);
const setAgentMode = useCallback((agentId: string, modeId: string) => {
const msg: WSInboundMessage = {
type: "session",
@@ -1816,7 +1802,6 @@ export function SessionProvider({ children, serverUrl, serverId }: SessionProvid
sendAgentMessage,
sendAgentAudio,
createAgent,
resumeAgent,
setAgentMode,
respondToPermission,
}),
@@ -1840,7 +1825,6 @@ export function SessionProvider({ children, serverUrl, serverId }: SessionProvid
sendAgentMessage,
sendAgentAudio,
createAgent,
resumeAgent,
setAgentMode,
respondToPermission,
]
@@ -1866,7 +1850,6 @@ export function SessionProvider({ children, serverUrl, serverId }: SessionProvid
sendAgentAudio,
deleteAgent,
createAgent,
resumeAgent,
setAgentMode,
respondToPermission,
}), [
@@ -1886,7 +1869,6 @@ export function SessionProvider({ children, serverUrl, serverId }: SessionProvid
sendAgentAudio,
deleteAgent,
createAgent,
resumeAgent,
setAgentMode,
respondToPermission,
]);

View File

@@ -105,7 +105,6 @@ const RESPONSE_TYPE_MAP: Record<string, SessionOutboundMessage["type"]> = {
git_repo_info_request: "git_repo_info_response",
list_provider_models_request: "list_provider_models_response",
list_conversations_request: "list_conversations_response",
list_persisted_agents_request: "list_persisted_agents_response",
create_agent_request: "agent_state",
refresh_agent_request: "agent_state",
initialize_agent_request: "initialize_agent_request",

View File

@@ -204,7 +204,6 @@ export interface SessionState {
worktreeName?: string;
requestId?: string;
}) => Promise<void>;
resumeAgent: (options: { handle: any; overrides?: any; requestId?: string }) => void;
setAgentMode: (agentId: string, modeId: string) => void;
respondToPermission: (agentId: string, requestId: string, response: any) => void;
} | null;

View File

@@ -407,12 +407,6 @@ export const RestartServerRequestMessageSchema = z.object({
reason: z.string().optional(),
});
export const ListPersistedAgentsRequestMessageSchema = z.object({
type: z.literal("list_persisted_agents_request"),
provider: AgentProviderSchema.optional(),
limit: z.number().int().positive().optional(),
});
export const InitializeAgentRequestMessageSchema = z.object({
type: z.literal("initialize_agent_request"),
agentId: z.string(),
@@ -557,7 +551,6 @@ export const SessionInboundMessageSchema = z.discriminatedUnion("type", [
HighlightedDiffRequestSchema,
FileExplorerRequestSchema,
FileDownloadTokenRequestSchema,
ListPersistedAgentsRequestMessageSchema,
GitRepoInfoRequestMessageSchema,
ClearAgentAttentionMessageSchema,
]);
@@ -750,25 +743,6 @@ export const AgentDeletedMessageSchema = z.object({
}),
});
const PersistedAgentDescriptorPayloadSchema = z.object({
provider: AgentProviderSchema,
sessionId: z.string(),
cwd: z.string(),
title: z.string(),
lastActivityAt: z.string(),
persistence: AgentPersistenceHandleSchema,
timeline: z.array(AgentTimelineItemPayloadSchema),
});
export type PersistedAgentDescriptorPayload = z.infer<typeof PersistedAgentDescriptorPayloadSchema>;
export const ListPersistedAgentsResponseSchema = z.object({
type: z.literal("list_persisted_agents_response"),
payload: z.object({
items: z.array(PersistedAgentDescriptorPayloadSchema),
}),
});
export const GitDiffResponseSchema = z.object({
type: z.literal("git_diff_response"),
payload: z.object({
@@ -863,7 +837,6 @@ export const SessionOutboundMessageSchema = z.discriminatedUnion("type", [
AgentPermissionRequestMessageSchema,
AgentPermissionResolvedMessageSchema,
AgentDeletedMessageSchema,
ListPersistedAgentsResponseSchema,
GitDiffResponseSchema,
HighlightedDiffResponseSchema,
FileExplorerResponseSchema,
@@ -896,7 +869,6 @@ export type DeleteConversationResponseMessage = z.infer<typeof DeleteConversatio
export type AgentPermissionRequestMessage = z.infer<typeof AgentPermissionRequestMessageSchema>;
export type AgentPermissionResolvedMessage = z.infer<typeof AgentPermissionResolvedMessageSchema>;
export type AgentDeletedMessage = z.infer<typeof AgentDeletedMessageSchema>;
export type ListPersistedAgentsResponseMessage = z.infer<typeof ListPersistedAgentsResponseSchema>;
export type ListProviderModelsResponseMessage = z.infer<
typeof ListProviderModelsResponseMessageSchema
>;
@@ -916,7 +888,6 @@ export type ListProviderModelsRequestMessage = z.infer<
>;
export type ResumeAgentRequestMessage = z.infer<typeof ResumeAgentRequestMessageSchema>;
export type DeleteAgentRequestMessage = z.infer<typeof DeleteAgentRequestMessageSchema>;
export type ListPersistedAgentsRequestMessage = z.infer<typeof ListPersistedAgentsRequestMessageSchema>;
export type InitializeAgentRequestMessage = z.infer<typeof InitializeAgentRequestMessageSchema>;
export type SetAgentModeMessage = z.infer<typeof SetAgentModeMessageSchema>;
export type AgentPermissionResponseMessage = z.infer<typeof AgentPermissionResponseMessageSchema>;

View File

@@ -856,10 +856,6 @@ export class Session {
await this.handleFileDownloadTokenRequest(msg);
break;
case "list_persisted_agents_request":
await this.handleListPersistedAgentsRequest(msg);
break;
case "git_repo_info_request":
await this.handleGitRepoInfoRequest(msg);
break;
@@ -1550,9 +1546,18 @@ export class Session {
}
if (normalized.createWorktree) {
const targetBranch = normalized.createNewBranch
? normalized.newBranchName
: normalized.baseBranch;
let targetBranch: string;
if (normalized.createNewBranch) {
targetBranch = normalized.newBranchName!;
} else {
// Resolve current branch name from HEAD
const { stdout } = await execAsync("git rev-parse --abbrev-ref HEAD", {
cwd,
env: READ_ONLY_GIT_ENV,
});
targetBranch = stdout.trim();
}
if (!targetBranch) {
throw new Error(
@@ -1730,12 +1735,6 @@ export class Session {
}
}
if (createWorktree && !createNewBranch && !baseBranch) {
throw new Error(
"Base branch is required when creating a worktree without a new branch"
);
}
return {
baseBranch,
createNewBranch,
@@ -1836,48 +1835,6 @@ export class Session {
}
}
private async handleListPersistedAgentsRequest(
msg: Extract<SessionInboundMessage, { type: "list_persisted_agents_request" }>
): Promise<void> {
const { provider, limit } = msg;
try {
const entries = await this.agentManager.listPersistedAgents({
provider,
limit,
});
this.emit({
type: "list_persisted_agents_response",
payload: {
items: entries.map((entry) => ({
provider: entry.provider,
sessionId: entry.sessionId,
cwd: entry.cwd,
title: entry.title ?? `Session ${entry.sessionId.slice(0, 8)}`,
lastActivityAt: entry.lastActivityAt.toISOString(),
persistence: entry.persistence,
timeline: entry.timeline ?? [],
})),
},
});
} catch (error) {
console.error(
`[Session ${this.clientId}] Failed to list persisted agents:`,
error
);
this.emit({
type: "activity_log",
payload: {
id: uuidv4(),
timestamp: new Date(),
type: "error",
content: `Failed to list saved agents: ${
(error as Error)?.message ?? error
}`,
},
});
}
}
/**
* Handle set agent mode request
*/

View File

@@ -5,7 +5,6 @@ import type {
SessionOutboundMessage,
AgentSnapshotPayload,
AgentStreamEventPayload,
PersistedAgentDescriptorPayload,
} from "../messages.js";
import type {
AgentModelDefinition,
@@ -296,16 +295,6 @@ export class DaemonClient {
);
}
async listPersistedAgents(): Promise<PersistedAgentDescriptorPayload[]> {
this.send({ type: "list_persisted_agents_request" });
return this.waitFor((msg) => {
if (msg.type === "list_persisted_agents_response") {
return msg.payload.items;
}
return null;
});
}
async resumeAgent(
handle: AgentPersistenceHandle,
overrides?: Partial<CreateAgentOptions>