Skip to content

chore(debug): add flag-gated event tracing to bridge + session panel#84

Open
DFearing wants to merge 1 commit intomainfrom
debug/bridge-event-trace
Open

chore(debug): add flag-gated event tracing to bridge + session panel#84
DFearing wants to merge 1 commit intomainfrom
debug/bridge-event-trace

Conversation

@DFearing
Copy link
Copy Markdown
Owner

@DFearing DFearing commented May 3, 2026

Summary

Tracing-only change. Adds a flag-gated `dlog` so we can capture exactly which leg of the SSE → bridge → panel pipeline drops events when the intermittent non-rendering bug recurs. Silent by default — no behavioral change unless the flag is enabled.

Enable

Tracepoints

`use-vscode-bridge.ts` (9 dlog calls):

  • per-event arrival with type / sessionId / drop-mode / selected-match
  • warmup-drop early-return
  • per-session buffer push (with new size)
  • `sessionsWithActivity` DEDUP vs ADD branches (the suspected re-render dropper)
  • `flushSessionEvents` entry
  • dismissed-session re-add path
  • rAF `eventVersion` bump

`session-canvas-panel.tsx` (1 dlog call):

  • per-render: `logLen / newEvents / consumed`

Test plan

  • Flag off (default): no `[af]` lines in console; behavior unchanged.
  • Flag on: opening the app produces a stream of `[af] event ...` and `[af] panel render ...` lines correlated with hook events.
  • When the bug recurs: copy console, share, root-cause from the log.

🤖 Generated with Claude Code

Adds a tiny debug-flag module (web/lib/debug-flag.ts) and dlog tracepoints
inside the SSE→bridge→panel pipeline so the next time the intermittent
non-rendering bug recurs we can capture ground-truth data instead of
guessing.

Enable via:
  - URL: http://localhost:3000/?debug=events
  - Or: localStorage.setItem('AGENT_FLOW_DEBUG', 'events')

When the flag is off, dlog is a single-branch no-op — no behavioral
change to the bridge or panel.

Tracepoints:
  - bridge.onEvent: per-event arrival with type, sessionId, drop-mode,
    selected-match
  - droppingRef early-return path
  - per-session buffer push
  - sessionsWithActivity DEDUP vs ADD branches
  - flushSessionEvents entry
  - dismissed-session re-add path
  - rAF eventVersion bump
  - SessionCanvasPanel render: logLen / newEvents / consumed

Co-Authored-By: Claude Opus 4.7 (1M context) <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.

2 participants