[object Object]

← back to Marketing Command Center

accounts panel: use live Meta token-health so a dead token flips to needs-creds instead of showing green

4a03044a5ad05ea90fa834b363289935059ba2a4 · 2026-07-15 14:18:09 -0700 · Steve Abrams

Files touched

Diff

commit 4a03044a5ad05ea90fa834b363289935059ba2a4
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Wed Jul 15 14:18:09 2026 -0700

    accounts panel: use live Meta token-health so a dead token flips to needs-creds instead of showing green
---
 modules/accounts/index.js | 14 +++++++++-----
 modules/channels/index.js |  4 ++++
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/modules/accounts/index.js b/modules/accounts/index.js
index eab1f04..4b60aac 100644
--- a/modules/accounts/index.js
+++ b/modules/accounts/index.js
@@ -58,8 +58,10 @@ function linkedinAccount() {
 
 // Normalize the channels platformStatus() map + its setup providers into the flat,
 // UI-ready account list the rail renders.
-function buildAccounts() {
-  const st = channels.platformStatus();
+async function buildAccounts() {
+  // Use the SAME health-augmented status /channels/status uses — a dead Meta token
+  // must flip connected:false here too, not show green on mere env-presence.
+  const st = channels.augmentMetaHealth(channels.platformStatus(), await channels.metaTokenHealth());
   const byPlatform = providerByPlatform();
   const redir = channels.redirectUriFor;
 
@@ -81,7 +83,9 @@ function buildAccounts() {
       connected: !!s.connected,
       configured: !!s.configured,
       accounts: s.accounts || [],
-      caveat: s.caveat || null,
+      // a definitively-dead Meta token surfaces its reconnect reason as the caveat
+      caveat: s.tokenError || s.caveat || null,
+      needsReconnect: !!s.needsReconnect,
       needs: s.needs || null,
       scopes: s.scopes || [],
       connectUrl: s.connectUrl || null,
@@ -115,9 +119,9 @@ module.exports = {
   title: 'Accounts',
   icon: '🔑',
   mount(router) {
-    router.get('/list', (_req, res) => {
+    router.get('/list', async (_req, res) => {
       try {
-        const accounts = buildAccounts().map(a => ({ ...a, bucket: bucketOf(a) }));
+        const accounts = (await buildAccounts()).map(a => ({ ...a, bucket: bucketOf(a) }));
         const counts = accounts.reduce((m, a) => (m[a.bucket] = (m[a.bucket] || 0) + 1, m), {});
         res.json({
           accounts,
diff --git a/modules/channels/index.js b/modules/channels/index.js
index 191b756..b3c265c 100644
--- a/modules/channels/index.js
+++ b/modules/channels/index.js
@@ -586,3 +586,7 @@ module.exports = {
 module.exports.platformStatus = platformStatus;
 module.exports.setupProviders = () => SETUP_PROVIDERS;
 module.exports.redirectUriFor = redirectUri;
+// Live token-health so the accounts rail can show the SAME truth as /channels/status
+// (a dead Meta token flips connected:false instead of showing green on env-presence).
+module.exports.metaTokenHealth = metaTokenHealth;
+module.exports.augmentMetaHealth = augmentMetaHealth;

← a26137e Fix staged vhost: MCC front door + public /reels/*.mp4 + /pr  ·  back to Marketing Command Center  ·  Add deploy/apply-cutover.sh — paste-safe one-command nginx c 9ef59f0 →