#6891: fix: Telegram health probe should detect webhook delivery errors
channel: telegram
app: web-ui
commands
Cluster:
Session Management and Fixes
## Summary
Fixes #6889
The web UI health badge always shows "Health OK" (green) even when Telegram (or any channel) is failing. Three independent issues combine to cause this:
### Bug 1: Telegram probe ignores webhook delivery errors
`probeTelegram()` calls `getMe` and `getWebhookInfo` but only reads `url` and `has_custom_certificate`. It ignores `pending_update_count`, `last_error_date`, and `last_error_message` -- so the probe returns `ok: true` as long as the bot token is valid, even when messages are not being delivered.
### Bug 2: Health summary `ok` is hardcoded to `true`
`getHealthSnapshot()` always returns `{ ok: true, ... }` regardless of channel probe results. The `ok` field is never derived from actual health data.
### Bug 3: Web UI badge only checks WebSocket connectivity
The topbar health badge renders based on `state.connected` (WebSocket alive), not channel health. It never fetches or displays probe results.
## Changes
### `src/telegram/probe.ts`
- Extended `TelegramProbe.webhook` type with `pendingUpdateCount`, `lastErrorDate`, `lastErrorMessage`
- Parse these fields from `getWebhookInfo` response
- Mark probe `ok: false` when `last_error_date` is within 10 minutes
### `src/telegram/probe.test.ts` (new)
5 test cases covering normal operation, getMe failure, recent webhook error, stale webhook error, and getWebhookInfo failure.
### `src/commands/health.ts`
- Derive `summary.ok` from channel probe results: `false` if any configured channel has a failed probe
### `ui/src/ui/app-render.ts`
- Badge shows "Degraded" (no green dot) when `debugHealth.ok === false`
- Shows "OK" (green) when healthy, "Offline" when disconnected
### `ui/src/ui/app-gateway.ts`
- Fetch health with `probe: true` on WebSocket connect so the badge has real data immediately
## Testing
```
pnpm vitest run src/telegram/probe.test.ts # 5 passed
pnpm vitest run src/commands/health.test.ts # 3 passed (no regressions)
```
Most Similar PRs
#11804: fix(webhook): return 503 from health endpoints when last processing...
by coygeek · 2026-02-08
70.5%
#9879: Improve gateway probe diagnostics for slow channels
by wrgrant · 2026-02-05
69.0%
#20420: Telegram webhook listener to use the gateway's HTTP server instead ...
by kesor · 2026-02-18
67.7%
#17918: fix(telegram): start webhook listener before setWebhook + forward w...
by Glucksberg · 2026-02-16
66.9%
#20309: [BUG]: fix telegram webhook should wait for abort signal instead of...
by kesor · 2026-02-18
65.7%
#22694: telegram: stabilize multi-account webhook mode
by Dongik · 2026-02-21
64.9%
#18915: fix(telegram): pass video width/height to sendVideo to prevent portra…
by storyarcade · 2026-02-17
63.9%
#10123: fix: guard deep health probe against unreachable gateway (#9091)
by petter-b · 2026-02-06
63.9%
#3368: fix: sessions navigation, DM thread display, and DM thread delivery...
by Lukavyi · 2026-01-28
63.5%
#14443: fix(telegram): skip General topic thread ID for all chat types (#14...
by lailoo · 2026-02-12
63.3%