Skip to content

feat: remote session notifications via Tailscale and ntfy - #286

Closed
tfriedel wants to merge 4 commits into
backnotprop:mainfrom
tfriedel:feat/remote-notifications
Closed

tfriedel wants to merge 4 commits into
backnotprop:mainfrom
tfriedel:feat/remote-notifications

Conversation

@tfriedel

@tfriedel tfriedel commented Mar 14, 2026 •

Copy link
Copy Markdown

Summary

Fixes #192 — remote Claude Code sessions can now open the plan review UI without port forwarding.

Note: This is not a general-purpose solution — it relies on Tailscale, tmux, and/or ntfy, which are not common dependencies. It's shared as a working proof-of-concept and inspiration for how remote access can work. A more general solution (e.g., a session router on a fixed port, or first-class support for Claude Code surfacing hook messages) is still needed for broad adoption. See #192 for discussion.

What's here

  • Tailscale auto-detection: Detects Tailscale hostname via tailscale status --self --json, so the server URL is directly reachable (e.g. http://mybox.ts.net:PORT). Also supports explicit PLANNOTATOR_HOSTNAME env var.
  • Random ports in remote mode: Removed the fixed port 19432 default, so parallel Claude sessions work without port conflicts.
  • 0.0.0.0 binding: Server binds to all interfaces when a non-localhost hostname is detected.
  • tmux popup: When $TMUX is set, shows a tmux display-popup with the server URL — works inside Claude Code's TUI since it's a tmux-layer overlay that bypasses Claude's stdio capture.
  • ntfy push notification: When CLAUDE_HOOKS_NTFY_URL is set (compatible with existing claude-code ntfy hooks), sends a push notification with a clickable link.
  • Short URLs via paste service: Uses the existing paste service (zero-knowledge encrypted) for compact share links when the server isn't directly reachable.

Why this isn't the general solution

The core problem is that Claude Code doesn't surface hook stderr to the user — it captures it to a socket. This means there's no built-in way for a hook to communicate a URL (or anything else) to the user while it's running.

The workarounds here are all external channels:

  • Tailscale — requires the user to have a mesh VPN set up
  • tmux popup — requires the user to be running inside tmux
  • ntfy — requires a push notification service

For users without any of these, the only option remains manual SSH port forwarding (ssh -L PORT:localhost:PORT), which is fragile since ports are now random.

Ideas for a general solution

  1. Claude Code feature request: A hook progress/message channel that surfaces stderr (or a dedicated stream) to the user's terminal. This would solve the problem at the root.
  2. Session router: A long-lived server on a fixed port that multiplexes multiple plan sessions on subpaths (/session/<id>). Users forward one port, all sessions are accessible. More complex but works without external dependencies.
  3. VS Code Remote auto-forwarding: VS Code Remote already auto-forwards ports. If the server prints a localhost:PORT URL to stderr, VS Code picks it up. This works today for VS Code Remote users — the missing piece is just surfacing the URL.

Test plan

  • Tested on remote SSH session with Tailscale — tmux popup shows http://hostname:port, opens in local browser, full approve/deny works
  • Tested ntfy push notification — clickable link arrives on phone
  • Verify local (non-remote) mode is unchanged — should still open browser directly
  • Verify parallel Claude sessions get different random ports
  • Verify fallback when Tailscale is not installed (falls back to localhost + share URL)

🤖 Generated with Claude Code

@backnotprop

Copy link
Copy Markdown
Owner

Thank you. I will take a look at this and test it out.

@tfriedel

tfriedel commented Mar 15, 2026 •

Copy link
Copy Markdown
Author

I've been trying this out since yesterday and for me the the ntfy system works best. I prefer that over the tmux popups.
I get a notifaction popup on my desktop, click on it and the plan opens immediately.

This is the script I use for that:
https://github.com/joshsymonds/nix-config/blob/main/home-manager/claude-code/hooks/ntfy-notifier.sh

I also use it to get notifications when claude asks for permissions.

Auto-detect the Tailscale hostname (or PLANNOTATOR_HOSTNAME) so remote users
can open the review server directly in their browser — full approve/deny,
no port forwarding needed. The user-facing URL hostname is resolved
separately from the bind address, and a read-only share.plannotator.ai URL
is generated as a fallback when no reachable hostname is available.

Notification delivery: ntfy push (optional via CLAUDE_HOOKS_NTFY_URL) with
stderr as the fallback. Short URLs via the paste service for compact links.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@tfriedel
tfriedel force-pushed the feat/remote-notifications branch from 3fcb6c9 to 6edf06b Compare June 21, 2026 23:18
@tfriedel tfriedel changed the title feat: remote session notifications via Tailscale, tmux, and ntfy feat: remote session notifications via Tailscale and ntfy Jun 21, 2026
tfriedel and others added 3 commits June 22, 2026 01:33
handleServerReady still called openBrowser in remote sessions; when the
VS Code IPC bridge was unavailable, openBrowser fell through to
xdg-open/open/start and launched a browser on the remote host (e.g. an
X-forwarded window over SSH). Remote sessions now bail out after the IPC
attempt — the reachable URL is already delivered via stderr + ntfy.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ns to Pi

Addresses code-review findings on the remote-notification feature:

- remote.ts: guard detectTailscaleHostname with a 3s timeout that kills the
  subprocess, so a wedged tailscaled can't hang the notification or leak a
  process. Add resetServerUrlHostnameCache test helper.
- share-url.ts: split runtime-agnostic prepareRemoteShareLink (compute) from
  writeRemoteShareLink (Bun stderr emit); notifyNtfy now honors options.fetchImpl
  and the duplicated stderr formatting is extracted to emitShareLink.
- Port the full feature to the Pi (Node) server: getServerUrlHostname +
  timeout-guarded tailscale probe and random ports in network.ts; vendor
  share-url/compress/crypto; surface reachable URL / share-link fallback + ntfy
  via ctx.ui.notify for plan/review/annotate remote sessions.
- Docs/comments: drop stale fixed-19432 remote-port claims (AGENTS.md, in-code
  doc comments, planAgentInstructions) now that remote uses random ports +
  resolved hostnames.
- Tests: random remote port + getServerUrlHostname (Pi), prepareRemoteShareLink
  reachable/fallback + ntfy-via-fetchImpl (Bun).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… drift

Addresses code-review findings on the remote-notifications work:

- Pi openBrowser now never launches a browser on the remote host, even when
  PLANNOTATOR_BROWSER/BROWSER is set — mirrors the Bun server's remote bail.
- Extract hostname resolution (env priority, memoization, DNSName parsing)
  into packages/shared/hostname.ts, used by both the Bun (remote.ts) and Pi
  (network.ts) runtimes; only the tailscale spawn stays runtime-specific.
- Don't cache the "localhost" fallback, so the long-lived Pi process can still
  resolve a hostname on a later review if tailscaled wasn't ready at first.
- Drop the unproducible "remote-default" portSource from all 5 unions.
- Pi notifyRemoteShareLink error path now surfaces the failure reason + paste
  hint instead of an unreachable localhost URL.
- Remove dead !isRemote from browser.ts glimpse condition.
- Sweep stale "remote defaults to 19432" claims across READMEs, marketing docs
  (add Tailscale guidance + PLANNOTATOR_HOSTNAME), header comments, and the
  manual SSH test doc.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@backnotprop

Copy link
Copy Markdown
Owner

Closing this older, conflicted proof of concept while remote capabilities are investigated under #899. The original issue #192 is already closed. Thank you for documenting and testing the Tailscale, tmux, and ntfy approach.

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.

Remote Claude Code sessions: no way to open plan review UI without a local browser

2 participants