Skip to content

feat(agents): add debug agent alerts and Terminal session navigation - #13

Merged
DerRafDev merged 1 commit into
mainfrom
feat/agent-question-prototype
Nov 6, 2026
Merged

DerRafDev merged 1 commit into
mainfrom
feat/agent-question-prototype

Conversation

@DerRafDev

Copy link
Copy Markdown
Owner

What

Debug-only prototype that shows when a Claude Code session is waiting for an answer to a structured question (AskUserQuestion): an amber ● Claude · N in the menu bar, an Agents page in the popover, and Go to Session to bring the Terminal.app tab with the question to the front. Off unless launched with TOKENBAR_AGENT_HOOKS=1 (listed, unchecked, in the shared scheme). Not part of Release builds.

Why

To see at a glance whether an agent session is stopped waiting for you, without checking every terminal. This first version covers the signals that could be verified end to end with real sessions; approvals, Codex, hook installation, and listener authentication are left for later (see docs/roadmap.md).

How it was tested

  • scripts/lint.sh, scripts/test.sh (209 tests), Debug build without warnings.
  • Event sequences captured from real Claude Code sessions (2.1.116 and 2.1.319) before writing the mapping. Approvals were left out because Claude Code sends no event when the user approves (only when the command finishes) or denies.
  • Transport: command hooks with /usr/bin/curl on loopback. With TokenBar closed, Claude Code shows no errors and no noticeable delay (http hooks printed ECONNREFUSED on every event, so they were rejected).
  • Live in the menu bar: ● Claude · 3 → session closed → 2 → answered → 1 → answered → back to usage.
  • Go to Session with three real sessions in the same folder, each in its own Terminal window: each one brought the right tab, question still open, to the front, also from another app. A closed session whose TTY was reused by a new tab brought nothing to the front.
  • Manual test of the full flow in the app by the maintainer.
  • Unit tests: store (deduplication, resolve, end, dismiss), hook mapping (including captured sequences and malformed origin headers), HTTP parsing, loopback end to end, navigation decisions with a simulated environment (exact target, app only, closed session, reused TTY, session closed between drawing and click).

How to try it: docs/testing-agent-alerts.md. Design and limits: docs/agents.md.

Checklist

  • scripts/lint.sh and scripts/test.sh pass locally
  • No tokens, cookies, account IDs, or real responses in code, fixtures, or logs
  • Docs updated if behavior or architecture changed

🤖 Generated with Claude Code

Debug builds launched with TOKENBAR_AGENT_HOOKS=1 show Claude Code
sessions waiting for an answer to a structured question
(AskUserQuestion): an amber "Claude · N" in the menu bar and an Agents
page in the popover. Answering, the next prompt, or the end of the
session removes the entry; Esc sends no event, so Dismiss removes it.

Claude Code command hooks post each payload with /usr/bin/curl to a
listener bound to 127.0.0.1 and always exit 0, so Claude Code shows no
error or delay while TokenBar is closed. Approvals are not counted:
Claude Code sends no event when the user approves or denies.

Go to Session brings the Terminal.app tab with the question to the
front. The hook reports the Claude Code process and its TTY; TokenBar
confirms both with the kernel and checks them again on click, so a
closed tab whose TTY was reused never comes to the front. Other apps
get Open <App>. The Apple Events entitlement is Debug only.

Not yet: listener authentication, installing hooks from the app,
Codex, and exact targets outside Terminal.app.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying tokenbar with  Cloudflare Pages  Cloudflare Pages

Latest commit: a14bdcc
Status: ✅  Deploy successful!
Preview URL: https://4948a259.tokenbar-2vf.pages.dev
Branch Preview URL: https://feat-agent-question-prototyp.tokenbar-2vf.pages.dev

View logs

@DerRafDev
DerRafDev merged commit 064d2c5 into main Nov 6, 2026
4 checks passed
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