Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/services/agent_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,8 @@ async def import_agent_impl(
for sub_agent_id in managed_agents:
insert_related_agent(parent_agent_id=mapping_agent_id[need_import_agent_id],
child_agent_id=mapping_agent_id[sub_agent_id],
tenant_id=tenant_id)
tenant_id=tenant_id,
user_id=user_id)
else:
# Current agent still has sub-agents that haven't been imported
agent_stack.append(need_import_agent_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ export default function AgentList({
return;
}

// First check if there are unsaved changes BEFORE switching to new agent
const canSwitch = await checkUnsavedChanges.saveWithModal();
if (!canSwitch) {
return;
}

// Load agent detail and set as current
try {
const result = await searchAgentInfo(Number(agent.id));
Expand All @@ -115,12 +121,6 @@ export default function AgentList({
log.error("Failed to load agent detail:", error);
message.error(t("agentConfig.agents.detailsLoadFailed"));
}

// Check if can switch (has unsaved changes)
const canSwitch = await checkUnsavedChanges.saveWithModal();
if (!canSwitch) {
return;
}
};

// Handle export agent
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/[locale]/space/components/AgentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export default function AgentCard({ agent, onRefresh }: AgentCardProps) {
<div className="h-4 mb-2" aria-hidden />
)}
<div className="flex-1 overflow-hidden">
<p className="text-sm text-slate-600 dark:text-slate-300 line-clamp-4">
<p className="text-sm text-slate-600 dark:text-slate-300">
{agent.description || t("space.noDescription", "No description")}
</p>
</div>
Expand Down
4 changes: 1 addition & 3 deletions frontend/app/[locale]/space/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,13 @@ export default function SpacePage() {
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ duration: 0.5, delay: 0.2 }}
className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 pb-8"
className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 2xl:grid-cols-4 gap-4 pb-8"
>
{/* Create/Import agent card - only for admin */}
<motion.div
initial={{ opacity: 0, scale: 0.9 }}
animate={{ opacity: 1, scale: 1 }}
transition={{ duration: 0.3, delay: 0.3 }}
className="aspect-[4/3]"
>
<div className="w-full h-full flex flex-col gap-2">
{/* Create new agent - top half */}
Expand Down Expand Up @@ -187,7 +186,6 @@ export default function SpacePage() {
initial={{ opacity: 0, scale: 0.9 }}
animate={{ opacity: 1, scale: 1 }}
transition={{ duration: 0.3, delay: 0.3 + (index + 1) * 0.05 }}
className="aspect-[4/3]"
>
<AgentCard agent={agent} onRefresh={onRefresh} />
</motion.div>
Expand Down
7 changes: 4 additions & 3 deletions test/backend/services/test_agent_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3370,6 +3370,7 @@ async def test_import_agent_impl_imports_all_agents_and_links_relations(
parent_agent_id=202,
child_agent_id=101,
tenant_id="test_tenant",
user_id="test_user",
)


Expand Down Expand Up @@ -6535,8 +6536,8 @@ async def fake_import_agent_by_agent_id(import_agent_info, tenant_id, user_id, s

relationships = []

def fake_insert_related_agent(parent_agent_id, child_agent_id, tenant_id):
relationships.append((parent_agent_id, child_agent_id, tenant_id))
def fake_insert_related_agent(parent_agent_id, child_agent_id, tenant_id, user_id):
relationships.append((parent_agent_id, child_agent_id, tenant_id, user_id))

async def fake_update_tool_list(tenant_id, user_id):
return None
Expand All @@ -6563,7 +6564,7 @@ async def fake_update_tool_list(tenant_id, user_id):
# Child (2) must be imported before parent (1)
assert imported_ids == [2, 1]
# Relationship should be created between new IDs 101 (child) and 100 (parent)
assert relationships == [(100 + 1, 100 + 2, "tenant1")]
assert relationships == [(100 + 1, 100 + 2, "tenant1", "user1")]


# =====================================================================
Expand Down
Loading