Skip to content

fix(channels): converge on runtime per-channel files + live status in admin - #25

Merged
maksymhryzodub-prog merged 3 commits into
mainfrom
fix/telegram-restart-recovery
Aug 7, 2026
Merged

fix(channels): converge on runtime per-channel files + live status in admin#25
maksymhryzodub-prog merged 3 commits into
mainfrom
fix/telegram-restart-recovery

Conversation

@maksymhryzodub-prog

Copy link
Copy Markdown
Contributor

Problem

Second half of the Telegram restart-recovery fix (runtime side: CleanSlice/runtime#7). The API read/wrote the legacy data/channels.json while the runtime moved to per-channel data/channels/<type>.json:

  • a bot configured from agent chat was invisible in the admin Channels tab and to deploy-time env injection;
  • a panel-then-chat history showed — and re-injected on redeploy — the stale panel token;
  • the tab showed config presence, not live state, so a dead channel looked healthy.

Full root cause and decisions: specs/003-telegram-restart-recovery/ (spec, research, contracts — included in this PR).

Changes

API (agentChannel slice)

  • GET /agents/:id/channels: reads data/channels/telegram.json, falls back read-only to the frozen legacy file for pre-convergence agents (a groups-only per-channel file still defers to legacy — env/panel-configured bots keep working), merges runtime-written data/channels/status.jsonconnected / statusReason / statusUpdatedAt (null = unknown).
  • PUT /agents/:id/channels: writes per-channel files via read-modify-write preserving the runtime-owned groups; omitted channels get {removed: true} tombstones (never deletes — stale pod env vars must not resurrect them). Legacy file is never written again.
  • buildAgentEnv: tombstoned channel → no TELEGRAM_* env injection (new spec).

Admin

  • Channels tab: live Connected / Disconnected (+reason) / Unknown badge; storage description corrected (was still data/channels.json + wrong restart semantics).

SDK: regenerated for admin and app from the updated swagger.

Version: 0.3.30 → 0.3.31 — release-platform tags v0.3.31 on merge so this reaches prod.

Testing

  • api Jest: 132 pass (was 118) — new: per-channel read, legacy fallback, tombstone-beats-legacy, groups-only-defers, status merge (connected: null without status), PUT preserve-groups/tombstone/no-op, env-injection exclusion.
  • tsc --noEmit clean.
  • E2E on staging after both merges: specs/003-telegram-restart-recovery/quickstart.md scenarios 1–5.

Rollout

Merge after CleanSlice/runtime#7 — agents run ghcr.io/cleanslice/runtime:latest with imagePullPolicy: Always, so the runtime half is live for an agent as soon as it restarts on the new image; already-broken agents heal on their next restart with zero manual steps.

🤖 Generated with Claude Code

maksymhryzodub-prog and others added 3 commits August 7, 2026 15:00
… admin

Companion to CleanSlice/runtime#7 (telegram restart recovery). The API read
the legacy data/channels.json while the runtime long since moved to
data/channels/<type>.json — chat-configured bots were invisible in the admin
Channels tab and to deploy-time env injection, and a panel-then-chat history
served the stale panel token.

- AgentChannelGateway reads data/channels/telegram.json (read-only fallback
  to the frozen legacy file for pre-convergence agents; a groups-only
  per-channel file still defers to legacy) and merges the runtime-written
  data/channels/status.json into GET /agents/:id/channels.
- PUT writes per-channel files via read-modify-write preserving the
  runtime-owned group registry; channels omitted from the exhaustive list
  get {removed: true} tombstones so stale pod env vars can't resurrect them.
- AgentChannelDto gains connected / statusReason / statusUpdatedAt
  (null = unknown); SDK clients regenerated for admin and app.
- Admin Channels tab: live Connected/Disconnected(+reason)/Unknown badge,
  storage copy corrected (was still describing data/channels.json).
- buildAgentEnv spec: tombstoned channel injects no TELEGRAM_* env vars.
- specs/003-telegram-restart-recovery/: spec-kit artifacts (spec, research,
  plan, contracts, tasks with status).

Version: 0.3.30 → 0.3.31 (release-platform tags v0.3.31 on merge).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…recovery

# Conflicts:
#	.specify/feature.json
Auto-merge combined the branch's channel-status fields with main's usage
overview endpoint inside generated files — regenerate from the merged
swagger so the artifacts match the generator output exactly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@maksymhryzodub-prog
maksymhryzodub-prog merged commit c5ab286 into main Aug 7, 2026
1 check passed
@maksymhryzodub-prog
maksymhryzodub-prog deleted the fix/telegram-restart-recovery branch August 10, 2026 09:15
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.

1 participant