šŸ› fix(needs-you): log a failed side-session read once, not every minute

Merged
AT
16d ago
+172-15

Why

Alok's transcripts filled with dozens of identical lines, one per minute:

  • needs-you: side sessions not read (SyntaxError: JSON Parse error: Unexpected identifier "No")
  • needs-you: side sessions not read (HooksError: needs-you: $.mcp.call: no connected MCP tool "get_session" on a server named "ccd_session_mgmt")

The band polls the app's session tools every minute and logged every failed read. Two causes:

  1. Plain-text answers. get_session / list_sessions answer some calls with prose, not JSON (checked live: get_session on an unknown id answers Session local_… not found. as an MCP error). The band JSON-parsed it.
  2. No session tools. Where ccd_session_mgmt is not connected (a terminal session), every read throws.

What changes

  • jsonOf: an answer that is an MCP error or not JSON reads as undefined, so self stays unknown (retried quietly next minute) and a plain-text list lists nothing. No log.
  • afterFailure (pure, exported): a missing session tool logs one line, needs-you: side sessions are not shown in this session (no app session tools), and stops reading until the session starts again. Any other failure logs once, and again only after a read succeeds.
  • session.start resets the read state (selfId, reading, lastLogged), so a reload re-checks.
  • README: a paragraph on the above. Plugin 0.1.2 (after #23's 0.1.1).

Tests (claude plugin test packages/needs-you: 15 pass)

  • plain-text and error answers: five reads across four polls, nothing logged;
  • missing tool: the engine's real message stops reading with one line (unit: the test kit skips a throwing hook, so a rejection with that text can't be faked end to end);
  • repeated failure: six failing reads log one line; after a success, the same failure logs once more.

Evidence from real sessions

See the comment below: two headless sessions with the plugin, one on main's copy and one on this branch, each running ~4 minutes, debug logs counted.

Coordinated with the session that wrote #23 (it merged first; this is rebased on it).

šŸ¤– Generated with Claude Code


Summary by cubic

  • Frontend: Page 1
  • Cart: Cart page
  • Frontend: Page 1
  • Frontend: Breadcrumbs
  • Description: This is an accessible page.