# 2026-01-23 Memory Log

## Baby Connect Skill - Major Improvements

**Session Context:** Continued from 2026-01-22 session where bottle feeding was tested. Had to delete erroneous 60oz entry (should have been 60ml).

### Key Changes Made

1. **Deleted erroneous 60oz entry** via browser automation
   - Found delete icon: `a.delete` inside `.st` entry divs
   - Confirmation dialog: click button with text "Ok"

2. **Rewrote SKILL.md completely:**
   - Added Quick Reference table at top for fast lookups
   - Parameterized all JavaScript snippets (variables at top)
   - Added Sleep logging workflow (`showSleepDlg()`)
   - Added verification step to confirm entries saved correctly
   - Added DOM Reference section with full structure
   - Better troubleshooting with symptom → fix table
   - Documented time format: `10:02PM` (no space, no leading zero)

### Critical Learnings Captured

**Unit Toggle Order (most important):**
```javascript
_uinfo.DUnit = 1;  // SET FIRST for ml
document.getElementById('bibunit').innerText = 'ml';
qtyInput.value = '60';  // THEN set quantity
```

**Delete Entry Pattern:**
```javascript
// Find entry by text match
document.querySelectorAll('.st').forEach(entry => {
  if (entry.querySelector('.st_tl')?.innerText.includes('TARGET')) {
    entry.querySelector('a.delete').click();
  }
});
// Then confirm with button text "Ok"
```

**Golden Rules documented:**
1. NEVER use ref-based clicking
2. Set unit BEFORE quantity for ml
3. Always wait 1-2 seconds after opening dialogs
4. Verify after save by checking the feed

### Additional Improvements (Session 2)

**Discovered all available dialog functions:**
```javascript
showBibDlg(), showNursingDlg(), showDiaperDlg(), showSleepDlg(),
showPumpingDlg(), showCupDlg(), showBathDlg(), showMedicineDlg(),
showTempDlg(), showWeightDlg(), showMoodDlg(), showPottyDlg(), etc.
```

**Added Nursing workflow:**
- Input IDs: `#left_side`, `#right_side`, `#last_left`, `#last_right`
- Anna uses this frequently for Quinn

### Codex Review Feedback (Session 3)

Ran `codex exec -m gpt-5.2-codex` for thorough skill review. Key improvements implemented:

1. **Structured error handling** - All snippets now return `OK:` or `ERR:` prefixed responses
2. **try/catch wrappers** - No more silent failures from null dereferences
3. **Dialog validation** - Check required elements exist before filling
4. **Dual event dispatch** - Both `change` AND `input` events for SPA compatibility
5. **Unit verification** - Verify `#bibunit` text after setting `_uinfo.DUnit`
6. **Session check helper** - Detect expired sessions before operations
7. **Edit entry workflow** - NEW workflow for modifying existing entries
8. **Timestamp matching** - Delete/edit can match by time for precision
9. **Prerequisites documented** - Login state, page, timing requirements
10. **Credential security note** - Never paste creds in logs, use 1Password

### Refactored with Progressive Disclosure (Session 4)

Applied Claude Skills Best Practices - SKILL.md is now the "Manager", reference files are "Specialists":

**Before:** 698 lines (monolithic)
**After:** 211 lines (map) + reference files (specialists)

**New Structure:**
```
babyconnect-browser/
├── SKILL.md (211 lines - the Manager)
├── snippets/
│   ├── helpers.js (80 lines)
│   ├── bottle.js (78 lines)
│   ├── nursing.js (68 lines)
│   ├── diaper.js (62 lines)
│   └── sleep.js (49 lines)
└── reference/
    ├── dom-reference.md (110 lines)
    └── troubleshooting.md (97 lines)
```

**Key changes:**
- SKILL.md now contains workflows with "read snippets/X.js" instructions
- Full JavaScript moved to separate snippet files
- DOM selectors and troubleshooting in reference/ (loaded on-demand)
- Zero duplication between files
- Imperative tone throughout

### Skill Status: Production Ready ✅
- Read activity ✅
- Log bottle (ml/oz) ✅
- Log nursing ✅
- Log diaper ✅
- Log sleep ✅
- Edit entries ✅
- Delete entries ✅
- Verification step ✅
- Session check ✅

### finance-news
- **Completed Issue #36 (Large Portfolio Support):**
  - Implemented `yfinance` batch downloading (O(1) request) for portfolios > 15 symbols.
  - Added tiered fetching: only fetch news/summaries for top 10 movers.
  - Split WhatsApp delivery into two messages: Macro Briefing + Portfolio Updates (avoids length limits).
  - Merged PR #54 into `kesslerio/finance-news-openclaw-skill`.
  - **Note:** `niemandBot` could not review PRs (permissions); needs collaborator invite for future repos.


## Baby Connect Diaper Automation Fix (8:33 PM PST)

**Problem:** BM + Wet diaper type couldn't be logged via automation - React ignored JavaScript `element.click()` calls.

**Solution:** Use Playwright's native `act` actions instead of `evaluate` with DOM manipulation:
```
browser action=act request={"kind": "click", "ref": "<child_div_ref>"}
browser action=act request={"kind": "click", "ref": "<bm_wet_div_ref>"}
browser action=act request={"kind": "select", "ref": "<size_dropdown_ref>", "values": ["Medium"]}
```

**Why:** React's synthetic event system responds to Playwright's simulated user interactions but ignores native DOM events from `element.click()`.

**Files updated:**
- `/home/art/clawd/skills/babyconnect-browser/SKILL.md` - New diaper workflow using native clicks
- `/home/art/Obsidian/04-Reference/Automation/Baby Connect Failure Report.md` - Marked resolved
