From afd747fcf203d867a7585331c35dd09b6172d972 Mon Sep 17 00:00:00 2001 From: Jiachen Fan Date: Wed, 15 Jul 2026 15:32:49 +0800 Subject: [PATCH] fix(DIARCHERS-1547): MCP trigger toggle no-op on first click MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The md-switch @change fired before v-model wrote the new value back to token.allow_trigger, so toggleMcpTrigger read the stale value and sent the current (unchanged) state to the backend — the first click was a no-op and the toggle only appeared to work on the second click. Use the new value emitted by @change ($event) instead of reading token.allow_trigger, matching the existing pattern in AdminClusters.vue. --- .../src/components/user/UserGlobalTokens.vue | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/dashboard-client/src/components/user/UserGlobalTokens.vue b/src/dashboard-client/src/components/user/UserGlobalTokens.vue index 46c2de2f..ecb34e58 100644 --- a/src/dashboard-client/src/components/user/UserGlobalTokens.vue +++ b/src/dashboard-client/src/components/user/UserGlobalTokens.vue @@ -82,7 +82,7 @@ {{ t.last_used_at ? formatDate(t.last_used_at) : '—' }} - + @@ -565,10 +565,12 @@ export default { .catch(() => {}) }, - toggleMcpTrigger (token) { - // v-model has already flipped token.allow_trigger to the new value; - // read it directly rather than negating again. - const newVal = token.allow_trigger + toggleMcpTrigger (token, newVal) { + // md-switch emits the new model value via @change. Rely on that + // explicit value rather than reading token.allow_trigger, which is + // not guaranteed to be updated by v-model yet when @change fires + // (that timing gap caused the "first click is a no-op" bug). + token.allow_trigger = newVal UserTokenService.setMcpTrigger(token.token_id, newVal) .catch(() => { token.allow_trigger = !newVal }) },