Repository navigation
Description
Summary
beeper watch silently ignores the -t / --target flag. It only honors --base-url. When both a desktop and beeper-server target are configured, beeper watch --target desktop falls through to the default target instead, so on a workstation where beeper-server is the default and is still initializing, the WS handshake succeeds but no domain events ever fire. Other CLI commands (chats list, messages list, messages send, messages search, etc.) honor --target correctly — the bug is watch-specific.
Environment
- CLI:
@beeper/cli0.6.2 - Beeper Desktop: 4.2.923 (
com.automattic.beeper.desktop,desktoptarget on:23373) - Beeper Server: 4.2.933 (
com.automattic.beeper.desktop.nightly,beeper-servertarget on:23374, default target,state: initializing) - OS: Linux
$ beeper targets list --json | jq -r '.data[] | "\(.id)\t\(.baseURL)\tdefault=\(.default)\treachable=\(.reachable)"'
beeper-server http://127.0.0.1:23374 default=true reachable=true
desktop http://127.0.0.1:23373 default=false reachable=true
Steps to reproduce
-
Have both a
desktoptarget and abeeper-servertarget configured, with the initializing one as default. (Equivalently: any setup where--target Xshould differ from the default.) -
In one terminal, run:
beeper watch --target desktop --json --events -
In another terminal, send a message to any chat the desktop target can see, e.g.:
beeper send text --target desktop --to '<chatID>' --message "watch test" --wait
Expected behavior
beeper watch connects to the desktop target's WS (port 23373), and stdout receives message.upserted / chat.upserted events for the send. The number of watch.message lifecycle events on stderr matches the WS messages emitted on stdout.
Actual behavior
beeper watch connects to the beeper-server target's WS (port 23374) — the default target, ignoring --target desktop. Because beeper-server is initializing and has no chats/messages flowing through it, no domain events ever fire. stdout stops at 2 lines:
{"type":"ready","version":1,"chatIDs":[]}
{"type":"subscriptions.updated","chatIDs":["*"],"app":{"state":false}}
The "app":{"state":false} field in subscriptions.updated is a symptom of pointing at an uninitialized server, not a CLI gating bug as it might first appear.
Diagnostic evidence
strace on the watch process confirms it connects to the wrong port with the wrong token:
GET /v1/ws HTTP/1.1
Host: 127.0.0.1:23374 ← should be :23373 with --target desktop
Authorization: Bearer syt_… ← beeper-server token, not desktop bdapi_… token
A side-by-side raw-WS test against ws://127.0.0.1:23373/v1/ws (with the desktop token from ~/.beeper/targets/desktop.json) receives 4 domain events in 7 seconds while messages are flowing. Same connection mode, same subscription payload — events flow normally.
Root cause
commands/watch.js (in the bundled CLI source at ~/.cache/beeper-cli/binary/<hash>/dist/commands/watch.js):
async run() {
const { flags } = await this.parse(Watch);
...
const token = await requireToken();
const baseURL = await getBaseURL(flags['base-url']); // <-- only --base-url
...
}getBaseURL is called with only flags['base-url'] — flags.target (which oclif populates from -t / --target) is never read. So --target is silently dropped and the default target is used.
For comparison, other commands appear to resolve the target before calling getBaseURL / via the request pipeline, which is why they honor --target correctly.
Workaround
Bypass --target by passing --base-url + the target's token via env var:
DESKTOP_TOKEN=$(jq -r .auth.accessToken ~/.beeper/targets/desktop.json)
BEEPER_ACCESS_TOKEN="$DESKTOP_TOKEN" beeper watch \
--base-url http://127.0.0.1:23373 \
--jsonThis delivers events as expected.
Suggested fix
Plumb flags.target through to the same target-resolution path the other commands use. Roughly:
- const baseURL = await getBaseURL(flags['base-url']);
+ const baseURL = await getBaseURL({ baseURL: flags['base-url'], target: flags.target });
+ const token = await requireToken({ target: flags.target });(token resolution is also currently target-unaware: the strace shows the default target's token being sent regardless of --target.)
Happy to send a PR if it's helpful.
Activity
linear-code commentedon Jun 16, 2026
LABS-106
coderabbitai commentedon Jun 16, 2026
🔗 Related PRs
#8 - CLI fixes [merged]
🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!
skill: link upstream issue for 'beeper watch' --target bug
fix(cli): honor --target in watch (#23)
batuhan commentedon Sep 25, 2026
Fixed by #23:
watchnow resolves its token and base URL from--target. Ships in the next release.This action is being done autonomously.