# WO-39: Keep Telegram's working indicator alive through active work

**Status:** complete in repository; verified for user publication
**Priority:** P1
**Date:** 2026-09-05 PDT

## Requirement and root cause

The user requires a visible working indicator throughout background work in
Telegram DMs and public/private groups. All three private reply paths cleared
their typing interval when the first native draft was acknowledged. A following
silent tool call or unchanged draft had no refresh, so Telegram's short-lived
typing action expired while work continued. Group paths already used recurring
typing, but shutdown could not directly reach a quick-chat timer once that timer
had transferred out of the staging map.

An initial transient typing failure also returned permission to continue
without creating a refresh timer, leaving admitted media/context preparation
without its working heartbeat.

## Implementation

- Keep one run-owned 3-second heartbeat through media preparation, model/tool
  work, native previews, and final delivery. Native draft success never retires
  that heartbeat; terminal reply cleanup does.
- Track active timer cleanups after staging transfers, attach the admitted
  work's cancellation signal, and clear every active lease on bridge shutdown.
  Cleanup removes both the timer and its abort listener.
- Reject late initial acknowledgements from cancelled/replaced work; continue
  refreshing after transient failures. Preserve permanent write refusals and
  reply authorization before visible activity.
- Coalesce refresh ticks while one transport call remains in flight and reuse
  an active runner's lease when steering arrives.
- Space native drafts at 1.2 seconds so draft updates and 3-second heartbeats
  fit together within the existing shared 40-per-30-second typing budget.
- Preserve numeric DM/group/topic routing and guest-query exclusions.

Timers express an admitted live process's ownership; they are not persisted or
revived for stale runs after restart. Visible refresh still depends on Telegram
accepting the API request and a responsive process/transport.

## Verification

`packages/cli/tests/telegram-working-indicator.test.ts` exercises the real task,
admin-chat, and quick-chat reply handlers with mocked inference/tool work and
mocked Telegram API responses. It verifies successful first drafts followed by
18 seconds of silence, delayed final delivery, public/private groups and topics,
media preparation, cancellation/shutdown before completion settles, late
acknowledgements, transient failures, coalescing, steering, and shared budget.

- **220 tests passed** across eight suites: working-indicator, transport-contract,
  attention-evidence, api-governor, write-capability, bridge-lifecycle,
  lifecycle-leak, and bot-api-10.
- After adding explicit permanent-refusal ownership cleanup and generation
  failure coverage, **76 tests passed** across six affected transport/lifecycle
  suites, including all **17 working-indicator tests**.
- CLI `tsc --noEmit` and scoped `git diff --check` passed. All tests use the
  CLI hermetic network boundary and synthetic temporary workspaces.

## Delivery boundary

Scoped source/test/document commit only. No real Telegram requests, inference,
publication, service restart, or mutation of the running Telegram workspace.

Final ownership review also routed queue-retirement cleanup through the shared typing lease cleanup, releasing its abort listener and ownership-map entry as well as the interval. All 56 tests across working-indicator, write-capability, bridge-lifecycle, and lifecycle-leak passed; /tmp/omnius-wo39-cleanup.log. The documented cadence now matches the implemented three seconds.

## Repository closure — September 5

All confirmed findings and independent review follow-ups in this order are resolved. The [program verification ledger](TOOL-QUALITY-2026-09-05.md#verification-ledger) records the final full suites and clean build. Earlier pending integration notes above are historical and superseded by this closure.

Scoped repair commits delivered to origin/main: 53216239, c17ae247. Publication and subsequent live acceptance remain with the user.

Source and integration locations:

- [packages/cli/src/tui/telegram-bridge.ts](../../../packages/cli/src/tui/telegram-bridge.ts)
- [packages/cli/tests/telegram-working-indicator.test.ts](../../../packages/cli/tests/telegram-working-indicator.test.ts)
