From 773e654616e67dfbfc083a0b6efb928f22f1dd6c Mon Sep 17 00:00:00 2001 From: ypratama Date: Tue, 8 Sep 2026 17:35:43 +0700 Subject: [PATCH] Fix: Add protected_label field immune to Proxy overwrites - UI always reads protected_label first --- src/lib/actions/agents.ts | 5 ++++- src/lib/actions/agentsMongo.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) 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: {