diff --git a/src/lib/actions/agents.ts b/src/lib/actions/agents.ts index 88eb869..c738ae6 100644 --- a/src/lib/actions/agents.ts +++ b/src/lib/actions/agents.ts @@ -30,9 +30,12 @@ export async function updateAgent(agentId: string, label: string) { return { success: false, message: "Agent tidak ditemukan di database lokal." }; } + // Write both label AND protected_label. + // protected_label is ONLY set by the UI — the Proxy NEVER touches it. + // This ensures custom names survive even if the Proxy overwrites label field. await db.collection('agent_registry').updateOne( { _id: agent._id }, - { $set: { label: label } } + { $set: { label: label, protected_label: label } } ); // Bismillah: Hapus semua data duplikat/hantu milik agent ini agar tidak ditimpa oleh proxy lawas/bug ganda diff --git a/src/lib/actions/agentsMongo.ts b/src/lib/actions/agentsMongo.ts index 76bb3d6..00ce0c5 100644 --- a/src/lib/actions/agentsMongo.ts +++ b/src/lib/actions/agentsMongo.ts @@ -160,7 +160,7 @@ export async function fetchAgentsFromMongo( organization_uuid: '', provisioned: item.provisioned ?? true, activated: true, - label: item.label || uuid, + label: item.protected_label || item.label || uuid, created_at: { human: 'N/A', date: '', unix_time: 0 }, updated_at: { human: 'N/A', date: '', unix_time: 0 }, last_seen_at: {