Skip to content

fix: clear transcript and prompt state on disconnect; document status stats fields#39

Open
Swissola wants to merge 1 commit into
anthropics:mainfrom
Swissola:fix/disconnect-state-clear
Open

fix: clear transcript and prompt state on disconnect; document status stats fields#39
Swissola wants to merge 1 commit into
anthropics:mainfrom
Swissola:fix/disconnect-state-clear

Conversation

@Swissola

Copy link
Copy Markdown

Problem

Two small correctness issues found while reading the firmware:

1. Stale state on reconnect (data.h)

When dataConnected() returns false the disconnect branch zeroes the session
counters but leaves nLines, promptId, promptTool, and promptHint with
their last live values. On a quick reconnect within the same run the UI renders
stale transcript lines, and if the device happens to echo the old promptId
before receiving a fresh snapshot it sends a ghost approval/denial.

Fix: clear all four fields alongside the session counters in the disconnect
branch.

2. Undocumented stats fields in status response (REFERENCE.md)

The status response JSON example includes { "appr": 42, "deny": 3, "vel": 8, "nap": 12, "lvl": 5 } but the document has no table explaining what any of these mean. Implementors have to read firmware source to understand them.

Fix: add a stats field table below the status response block.

Changes

  • src/data.h — +1 line in disconnect branch
  • REFERENCE.md — +10 lines documenting stats object fields

Test plan

  • Flash firmware, connect bridge, disconnect, reconnect — transcript should be empty on reconnect rather than showing previous session lines
  • Confirm no pending-prompt UI element remains after disconnect
  • Read REFERENCE.md stats table for correctness against xfer.h status handler

🤖 Generated with Claude Code

…s fields

data.h: when the bridge connection times out, nLines and the promptId/Tool/Hint
fields were left populated from the last live snapshot. A reconnect within the
same session would show stale transcript lines and, if the device happened to
echo the old promptId, a ghost approval could be sent. Clear them in the
disconnect branch alongside the session counters.

REFERENCE.md: the stats object in the status response had no field definitions.
Add a table documenting appr, deny, vel, nap, and lvl so implementors know what
each counter means without reading firmware source.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
rushabh91 added a commit to rushabh91/claude-desktop-buddy that referenced this pull request May 30, 2026
…ropics#38 anthropics#39 anthropics#31 anthropics#25 anthropics#27 anthropics#26 anthropics#24 anthropics#33 anthropics#34 anthropics#32 anthropics#15)

Bug fixes:
- ble_bridge.cpp: replace volatile rxHead/rxTail with portMUX spinlock to fix
  dual-core memory-barrier race between BLE Core-0 callbacks and main-loop Core-1 (anthropics#40)
- data.h: skip oldest entries when bridge sends >16, always show newest (anthropics#38 + anthropics#33)
- data.h: clear nLines/promptId/promptTool/promptHint on disconnect so reconnect
  shows a clean slate instead of stale transcript and ghost approval prompt (anthropics#39)
- xfer.h: reject file command with ok:false when path would overflow the 80-byte
  buffer instead of silently truncating to a mangled LittleFS path (anthropics#31)
- stats.h: widen approvals/denials to uint32_t (uint16_t overflows at ~65k, silently
  corrupting mood tier); update NVS keys to getUInt/putUInt (anthropics#25)

UX fixes:
- main.cpp: remove msgScroll=0 reset on lineGen change — scroll position is now
  preserved while new transcript lines arrive; maxBack clamp still handles bounds (anthropics#26)
- main.cpp: auto-dismiss stale approval prompt after 5 minutes so a crashed bridge
  never leaves the panel stuck; promptTimedOut flag survives bridge re-sends (anthropics#27)
- stats.h + main.cpp: persist brightness level in NVS (s_brt); load and apply after
  settingsLoad() in setup(); save via settingsSave() when cycled in menu (anthropics#24)

Enhancements:
- data.h: grow TamaState.lines from 8 to 16 entries (+736 bytes RAM) (anthropics#33)
- main.cpp: show BT/USB connection badge in transcript corner when not scrolled (anthropics#34)
- main.cpp: replace elapsed-time header on approval prompt with 5-minute countdown;
  turns red below 30s; shares PROMPT_TIMEOUT_MS with the auto-dismiss logic (anthropics#32)
- main.cpp: add ascending two-note celebrate chime (2000→2800 Hz) on P_CELEBRATE
  state entry; edge-triggered once per window; gated by settings().sound (anthropics#15)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant