[object Object]

← back to Norma

chore: refactor (named consts, optional chaining) + v1.4.0 (session close)

128ac1bd7d591f47da8f560aa95087b48aa550df · 2026-08-18 15:40:00 -0700 · Steve Abrams

Files touched

Diff

commit 128ac1bd7d591f47da8f560aa95087b48aa550df
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Tue Aug 18 15:40:00 2026 -0700

    chore: refactor (named consts, optional chaining) + v1.4.0 (session close)
---
 agents/instagram-agent/account-notes.js  | 7 ++++---
 agents/instagram-agent/calendar.js       | 3 ++-
 agents/instagram-agent/package-lock.json | 4 ++--
 agents/instagram-agent/package.json      | 2 +-
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/agents/instagram-agent/account-notes.js b/agents/instagram-agent/account-notes.js
index c63b666..7495021 100644
--- a/agents/instagram-agent/account-notes.js
+++ b/agents/instagram-agent/account-notes.js
@@ -25,6 +25,7 @@ const { listAccounts } = require('./live-media');
 const DATA = path.join(__dirname, 'data');
 const NOTES_FILE = path.join(DATA, 'account-notes.json');
 const VIEWER = path.join(__dirname, 'public', 'notes-viewer.html');
+const MAX_NOTE_LENGTH = 4000; // per-account note character cap
 
 function readNotes() {
   try { return JSON.parse(fs.readFileSync(NOTES_FILE, 'utf8')); } catch { return {}; }
@@ -56,8 +57,8 @@ function registerNotesRoutes(app) {
       }
       const accounts = listAccounts().map((a) => ({
         handle: a.handle, ig_user_id: a.ig_user_id, page_name: a.page_name || '',
-        note: (notes[a.ig_user_id] && notes[a.ig_user_id].note) || '',
-        updated_at: (notes[a.ig_user_id] && notes[a.ig_user_id].updated_at) || null,
+        note: notes[a.ig_user_id]?.note || '',
+        updated_at: notes[a.ig_user_id]?.updated_at || null,
       }));
       res.json({ accounts });
     } catch (e) { res.status(500).json({ error: e.message }); }
@@ -69,7 +70,7 @@ function registerNotesRoutes(app) {
       const b = req.body || {};
       const id = String(b.account || '');
       if (!rosterIds().has(id)) return res.status(400).json({ error: 'unknown account (not in roster)' });
-      const note = typeof b.note === 'string' ? b.note.slice(0, 4000) : '';
+      const note = typeof b.note === 'string' ? b.note.slice(0, MAX_NOTE_LENGTH) : '';
       const notes = readNotes();
       if (note.trim() === '') delete notes[id];              // empty = clear the note
       else notes[id] = { note, updated_at: new Date().toISOString() };
diff --git a/agents/instagram-agent/calendar.js b/agents/instagram-agent/calendar.js
index 46dad05..555bdb7 100644
--- a/agents/instagram-agent/calendar.js
+++ b/agents/instagram-agent/calendar.js
@@ -24,6 +24,7 @@ const path = require('path');
 const { listAccounts, readCache, readTombstones } = require('./live-media');
 
 const VIEWER = path.join(__dirname, 'public', 'calendar-viewer.html');
+const THUMBS_PER_DAY = 8; // max thumbnails collected per calendar day in the month grid
 
 // Stable per-account color by golden-angle hue rotation — deterministic, no config dependency,
 // every account maximally distinct from its neighbours.
@@ -79,7 +80,7 @@ function monthView({ month, accountsParam }) {
       d.count++; monthCount++;
       d.byAccount[id] = (d.byAccount[id] || 0) + 1;
       perAccountMonth[id] = (perAccountMonth[id] || 0) + 1;
-      if (d.thumbs.length < 8 && p.thumb) {
+      if (d.thumbs.length < THUMBS_PER_DAY && p.thumb) {
         d.thumbs.push({ thumb: p.thumb, permalink: p.permalink, handle: byId[id].handle, color: byId[id].color });
       }
     }
diff --git a/agents/instagram-agent/package-lock.json b/agents/instagram-agent/package-lock.json
index 9e51778..db61e20 100644
--- a/agents/instagram-agent/package-lock.json
+++ b/agents/instagram-agent/package-lock.json
@@ -1,12 +1,12 @@
 {
   "name": "norma-instagram-agent",
-  "version": "1.3.1",
+  "version": "1.4.0",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "norma-instagram-agent",
-      "version": "1.3.1",
+      "version": "1.4.0",
       "dependencies": {
         "dotenv": "^16.4.5"
       }
diff --git a/agents/instagram-agent/package.json b/agents/instagram-agent/package.json
index ff73af0..b4f04d5 100644
--- a/agents/instagram-agent/package.json
+++ b/agents/instagram-agent/package.json
@@ -1,6 +1,6 @@
 {
   "name": "norma-instagram-agent",
-  "version": "1.3.1",
+  "version": "1.4.0",
   "description": "Norma Instagram Agent — Posts, Reels, and Stories via Meta Graph API",
   "main": "server.js",
   "scripts": {

← f60474f auto-data-snapshot: 2026-08-18T15:36:46 (1 data files) — age  ·  back to Norma  ·  auto-data-snapshot: 2026-08-18T17:12:33 (1 data files) — age 5aaef1d →