# 2026-02-09 Memory Log

## Brain Module Phase 4 — Completed
- Replaced Monaco code editor with rendered markdown preview (ReactMarkdown + remarkGfm)
- Added Monaco DiffEditor (inline mode) for proposed changes only
- AI-only editing via chat assistant and "Add to brain" corrections
- Accept & Save / Reject workflow for all proposed changes
- Cumulative changes — AI/corrections build on current proposed content
- Editable diff editor — direct manual edits also show as inline diff
- "Edit" button to enter edit mode manually
- Version History — click commits to view old content, revert to restore with git commit
- Move correction button — searchable dropdown, related items shown first (starred ★)
- Corrections panel opens by default
- Hide/Show resolved corrections toggle

## Brain Bug Fixes
- Fixed `claude-sonnet-4-5-20250514` → `claude-opus-4-5-20251101` (404 model ID)
- Fixed regex truncation: `([\s\S]*?)` lazy → `([\s\S]*)` greedy (nested code blocks)
- Fixed `max_tokens` 8192 → 16384 for large agent files
- Fixed `.next` build cache corruption (`clientModules` undefined)

## Pending Brain Bugs
- Move button state isolation — shared boolean toggle → per-item state tracking needed
- Reposition Move button to right of "Add to Brain" button
- "Add to brain" changes not accumulating properly (DiffEditor `modified` prop resets)

## Key Technical Decisions
- Brain AI model: `claude-opus-4-5-20251101` for improve + apply-correction
- Greedy regex critical for files with nested code fences
- Cumulative AI changes: send current proposed content to APIs, not just saved file
- No side-by-side diff (truncation issues) — inline diff only

## Approved Models (Set by Dave)
- Claude Opus 4.6: main session
- Claude Opus 4.5: coding builds
- Claude Sonnet 4.5: sub-agent spawns
- Claude Haiku 4.5: lightweight tasks
- DO NOT use outdated models (opus 4-1, opus 4, etc.)

#brain #bugs #models #decisions

## CIP (CustomerPro Insights) - Ben's Project
- **Repo:** `symphco/customerpro-insights-5d726d` (note the suffix!)
- **Local clone:** `/tmp/customerpro-insights` (⚠️ ephemeral — may not survive reboot)
- **Branches:** `main`, `development`, `feature/credit-scoring-config-ui`
- **Deploy:** GCP Cloud Build (triggered on push to `development`)
- **Contact:** Ben (benjude._.) — Discord id 1295305060363931759
- **Channel:** 1470357803108667516
- **Lesson:** Subagent must verify builds compile before declaring done. Got burned by TS type mismatches that only showed up in GCP build.

## TIL (Today I Learned)

### SafeNow Login Issues - Root Causes Matter
- **Problem:** Paul couldn't login — first wrong email (`you@lgu.gov.ph` instead of `test-admin@safenow.local`), then later stale build with undefined env vars
- **Root cause:** Stale `.next/` cache with `NEXT_PUBLIC_FIRESTORE_NAMESPACE=undefined` → collection names became `undefined_users` instead of `dev_users`
- **Fix:** Clean build cache, rebuild with proper env vars loaded
- **Lesson:** When Next.js throws weird errors like "Cannot read properties of undefined (reading 'indexOf')", suspect stale build artifacts first

### Next.js Environment Variables - Build Cache Gotcha
- Environment variables are **baked into the build** for `NEXT_PUBLIC_*` vars
- Changing `.env.local` after build = no effect until rebuild
- Always clean `.next/` when env vars change to avoid mysterious runtime errors
- This bit me twice today on SafeNow

### Password Visibility Toggles - Keep It Simple
- Eye/EyeOff icons from lucide-react
- Toggle button positioned `absolute right-3` inside input container
- Input type switches: `type={showPassword ? "text" : "password"}`
- Disable toggle during form submission for better UX
- Clean, minimal implementation beats over-engineered solutions

### Icon Files for Next.js App Router
- `src/app/icon.png` (32×32) → favicon
- `src/app/apple-icon.png` (180×180) → iOS touch icon
- `src/app/favicon.ico` (multi-size) → legacy browser support
- Next.js automatically serves these at `/icon`, `/apple-icon`, `/favicon.ico`
- No need for manual `<link>` tags in layout — framework handles it

### Git Backup Strategy - HTTPS > SSH for Large Repos
- SSH pushes timeout on repos with large binary assets (design files >50MB)
- HTTPS with `gh auth` token is faster and more reliable (~150MB/s)
- Backup sweep running successfully: 18+ products, zero failures
- Timestamped commits: "Auto-backup 2026-02-10 03:37 GMT+8"

### End-of-Day Stats (2026-02-09)
- **Sessions:** 100 active
- **Total tokens:** 4.45M (Opus 4.6: 2.7M, Sonnet 4.5: 1.5M, Opus 4.5: 149k)
- **Estimated cost:** ~$164.87
- **Model split:** Group chats (47), Other (53)
- Heartbeat model switch to Sonnet 4.5 saving ~5x on recurring polls
