happy icon indicating copy to clipboard operation
happy copied to clipboard

Manual `happy notify` works, but session-status notifications (Claude finished / waiting for input) are never delivered

Open carrot0117 opened this issue 5 months ago • 5 comments

Manual happy notify works, but session-status notifications (Claude finished / waiting for input) are never delivered

Environment

  • Happy CLI version: 1.1.9
  • Claude Code version: 2.1.195
  • Node: node20 (/opt/node20/bin)
  • OS (CLI host): Linux (remote container)
  • Mobile: iOS
  • Daemon: running, connected to wss://api.cluster-fluster.com (heartbeat OK)

What works

  • Manual push works reliably: happy notify -p "..." -t "..." returns ✓ Push notification sent successfully! and the notification is received on the iPhone (lock screen / background).
  • App-in-foreground: conversation content syncs correctly in real time.
  • iOS system settings: notifications allowed, Background App Refresh enabled, Low Power Mode off.

What doesn't work

  • Session-status notifications are never delivered. When a session goes from running → idle (Claude finished / waiting for user input), no push arrives on the phone — even with the app backgrounded / locked.
  • Confirmed reproducible: end a turn so the session becomes idle → no notification, while a manual happy notify sent at the same time is received.

Diagnostics collected

  • happy doctor: daemon PID running, connected to server, sessions tracked normally.
  • Daemon log (*-daemon.log) shows Session reported / Session webhook / lifecycleState: running events, but no automatic notification/push events are ever emitted for session state changes. Only manual notify produces a delivered push.
  • /root/.happy/settings.json shows "onboardingCompleted": false (pairing still functions).

Analysis

Because manual notify is delivered but session-state notifications are not, the APNs delivery path is healthy. The gap is in the auto-trigger for session-state notifications — the daemon never emits them. Possibly related to an in-app "notify on completion / waiting" setting not being enabled, and/or onboardingCompleted: false leaving notification preferences uninitialized.

Questions for maintainers

  1. Is the "notify when session finishes / waits for input" behavior controlled by a mobile-app setting, a CLI flag, or server-side session state?
  2. Should the daemon log auto-notification attempts? (Currently there is no trace of any.)
  3. Could onboardingCompleted: false prevent notification preferences from being initialized?

中文说明

环境

  • Happy CLI 1.1.9,Claude Code 2.1.195,node20,CLI 运行在 Linux 远程容器;手机端 iOS。
  • daemon 正常运行,已连上 wss://api.cluster-fluster.com,心跳正常。

正常的部分

  • happy notify -p "..." -t "..." 返回发送成功,iPhone 锁屏/后台能收到。
  • App 前台时对话内容实时同步正常。
  • iOS 系统:已允许通知、已开后台刷新、未开低电量模式。

异常的部分

  • 会话状态通知从收不到:会话由「运行中」变为 idle(Claude 完成 / 等待输入)时,锁屏/后台都没有推送。
  • 可复现:会话进入 idle 时无通知,但同一时刻手动 happy notify 能收到。

已收集的诊断

  • happy doctor:daemon 在跑、已连服务端、会话追踪正常。
  • daemon 日志有 Session reported / webhook / lifecycleState 事件,但从未产生任何自动通知/推送事件;只有手动 notify 会真正投递。
  • settings.json 中 "onboardingCompleted": false(但配对可用)。

分析

手动能收、会话状态收不到 → APNs 通道正常,问题在会话状态通知的自动触发:daemon 根本没发。可能与 App 内「完成/等待时通知」开关未开、或 onboardingCompleted:false 导致通知偏好未初始化有关。

想问维护者

  1. 「会话完成/等待时通知」由手机 App 设置、CLI 参数、还是服务端会话状态控制?
  2. daemon 是否应记录自动通知的尝试?(目前完全没有痕迹)
  3. onboardingCompleted:false 会不会导致通知偏好未初始化?

carrot0117 avatar Jul 01 '26 02:07 carrot0117

found the real cause - it's not that the daemon fails to emit, the server is silently suppressing the push.

the daemon IS sending it: grep your daemon log for sendSessionNotification dispatched via server (kind=done) and you'll see it returns 200. the loss is server-side. the presence check hasActiveNonMachineSocket (in packages/happy-server/sources/app/events/eventRouter.ts) counts any non-machine socket as "user is looking", and a running coding session opens a session-scoped socket that never sends app-state, so the undefined → active fallback marks it permanently active. result: while any coding session runs, every done/permission/question push is suppressed before it reaches expo. happy notify slips through because it doesn't go through dispatchSessionEventPush.

fix: narrow that check to user-scoped sockets only (mobile app / web). daemon (machine-scoped) and coding sessions (session-scoped) are background processes that never surface notifications and shouldn't suppress push. i have a local patch, happy to open a PR.

to confirm it's the same on your end: when you repro, is a happy coding session running in a terminal, or is the web app open, alongside the daemon?

thanks for the detailed report!

djv56666 avatar Jul 02 '26 09:07 djv56666

Thanks, this explains everything — the manual-notify-works-but-session-notifications-don't pattern matches your hasActiveNonMachineSocket analysis exactly.

To answer your question: yes. In my repro there was always a Happy coding session running in a terminal (in a remote container), alongside the daemon. That session was continuously active the whole time I was missing done/waiting notifications — which lines up perfectly with "any running coding session opens a session-scoped socket that permanently marks the user as active and suppresses the push."

I can't pull the sendSessionNotification dispatched via server (kind=done) log line now because the container was recycled and /root/.happy/logs was cleared, but the behavioral evidence is fully consistent: happy notify (which bypasses dispatchSessionEventPush) was always delivered, while session-state pushes never were — and only while a coding session was live.

Your fix (narrowing the presence check to user-scoped sockets only, so machine- and session-scoped sockets don't count as "user is looking") sounds exactly right. Please do open the PR — happy to test the patched build once it's up.

carrot0117 avatar Jul 02 '26 09:07 carrot0117

that confirmation is gold - "coding session always running in the remote container" is exactly the smoking gun, thanks for checking.

PR is up: #1471. since you're on the hosted api.cluster-fluster.com, you'll be able to test once it's merged and deployed; if you self-host, rebuild from that branch and you can try right away.

thanks for offering to test it!

djv56666 avatar Jul 02 '26 09:07 djv56666

Awesome, thanks for the fast turnaround! I'm on the hosted api.cluster-fluster.com, so I'll wait for #1471 to merge and deploy, then verify with a backgrounded coding session. Will report back here once I can confirm on my end. 🙏

carrot0117 avatar Jul 02 '26 09:07 carrot0117

Your remote-container confirmation is strong workflow evidence, especially the fact that a live coding session itself suppressed the alert you needed.

If you still use this pattern, could you share:

  1. Which alert matters most in practice: waiting for input, permission, error, or completion?
  2. How long can an agent sit idle before a missed alert becomes costly?
  3. What workaround do you use now—manual notify, polling the app, or another channel?
  4. Would an explicit delivery result (sent / suppressed / failed) restore trust, or is guaranteed delivery the only acceptable outcome?

I'm ranking product work from actual user workflows; a short reply is plenty.

bogdanbaciu21 avatar Jul 17 '26 07:07 bogdanbaciu21