# v0.23.0 Release Notes

> v0.22.3 -> v0.23.0

## Summary

Brings Telegram online as a first-class chat runtime alongside Discord, with shared session naming, background push, and a TUI-driven enablement flow. Reworks the cross-runtime confirmation gate so chat platforms no longer block each other in-flight. CLI surface narrows as Discord auth moves into the TUI wizard.
<details>
<summary>翻譯</summary>
將 Telegram 接入為與 Discord 並列的對話 runtime，共用 session 命名、背景推播與 TUI 啟用流程。重塑跨 runtime 的 confirm gate，讓多平台不再相互阻塞。CLI 表面收斂，Discord 授權移入 TUI wizard。
</details>

## ⚠️ Breaking Changes

### Pending gate switched from global flag to runtime-scoped listener registry

The confirmation / `ask_user` / `store_secret` gate no longer uses the global `pending.Active` atomic flag. Each runtime now registers a prefix-matched listener and claims only matching queue entries, so Telegram, Discord, and CLI can run their own confirm flows side by side without one runtime blocking another.

**Before:**
```go
// global gate
if pending.Active.Load() {
    // confirm flow is in flight somewhere
}
```

**After:**
```go
// per-session gate, prefix-routed listeners
if pending.HasListener(sessionID) {
    // a listener with a matching prefix is registered for this session
}

// register a listener for a runtime (TUI / CLI use "", Telegram daemon uses "tg-")
unregister := pending.RegisterListener("tg-")
defer unregister()

// claim the next entry whose session matches the prefix
entry := pending.PickNextFor("tg-")
```

**Migration:**
```go
// Old call sites reading the global flag
if pending.Active.Load() { ... }

// New form: scope the check to the session you are dispatching for
if pending.HasListener(sess.ID) { ... }
```

Package path also moved: `internal/pending/` → `internal/runtime/pending.go`. Fork maintainers consuming the internal package must update imports and replace `Active` reads with `HasListener(sessionID)`; daemon-side runtimes must register a listener (with the appropriate session prefix) at boot and call the returned `unregister` on shutdown.

<details>
<summary>翻譯</summary>

Confirmation／`ask_user`／`store_secret` 流程的閘門由全域 `pending.Active` atomic flag，改為 runtime 各自 `RegisterListener(prefix)` 並以 `HasListener(sessionID)` 檢查、`PickNextFor(prefix)` 取對應條目。Telegram、Discord、CLI 可並行各自 confirm flow，互不阻塞。

Package 路徑由 `internal/pending/` 移至 `internal/runtime/pending.go`。Fork 維護者需同步更新 import，把 `pending.Active.Load()` 改成 `pending.HasListener(sess.ID)`，daemon 側 runtime 啟動時需以對應 prefix 註冊 listener，停機時呼叫回傳的 `unregister`。

</details>

### `agen discord` CLI subcommand removed

Discord enablement moved entirely into the TUI `/discord` popup chain (token entry, verification, keychain write, daemon reload). The CLI subcommand and its standalone `addDiscord.go` entry are gone.

**Migration:**
```text
# Old
agen discord <action>

# New
agen           # start TUI
/discord       # popup chain handles token + verification + keychain
```

<details>
<summary>翻譯</summary>

`agen discord` CLI 子命令與獨立的 `addDiscord.go` 入口移除。Discord 啟用統一由 TUI `/discord` popup chain 處理（token 輸入、驗證、keychain 寫入、daemon reload）。

</details>

## Changes

### FEAT
- Add Telegram bot enablement and daemon reload support (@pardnchiu) [ca38c47]
- Add Telegram runtime support and improve session handling (@pardnchiu) [bfa5989]
- Add Telegram push delivery and generalize runtime push hooks (@pardnchiu) [443fccb]
- Add Telegram voice delivery and reuse bot client for push (@pardnchiu) [e7358cc]

<details>
<summary>翻譯</summary>

- 新增 Telegram bot 啟用與 daemon reload 支援
- 新增 Telegram runtime 支援，並改善 session 處理
- 新增 Telegram 結果推送，把背景 push hook 抽成通用 runtime registry
- 新增 Telegram 語音檔案投遞，並重用 bot client 做 push

</details>

### UPDATE
- Add Telegram chat verification and reduce event log noise (@pardnchiu) [00ffce1]
- Add chat-platform prompt builder and refine Telegram reply layout (@pardnchiu) [f452e1e]
- Upgrade Telegram runtime confirmation flow and go-bot dependency (@pardnchiu) [dd69fe6]

<details>
<summary>翻譯</summary>

- 新增 Telegram chat 授權驗證，並收斂事件 log 雜訊
- 引入 chat-platform 系統 prompt 組裝器，並調整 Telegram 回覆排版
- 升級 Telegram confirm／ask_user 流程與 go-bot 依賴

</details>

### REFACTOR
- Improve runtime status display and persist bot usernames (@pardnchiu) [f1c36ea]
- Limit switch session popup to a visible window (@pardnchiu) [d0803b3]
- Route Telegram helper-prefixed messages through named sessions (@pardnchiu) [333f77f]

<details>
<summary>翻譯</summary>

- 改善 runtime 狀態顯示，並持久化 bot username
- 將 session 切換 popup 限制在可見視窗範圍
- Telegram `:name` 前綴訊息走 named session 路由（與 TUI `exec.Run` 對齊）

</details>

### REMOVE
- Remove CLI discord command and move auth into TUI (@pardnchiu) [3ad147c]

<details>
<summary>翻譯</summary>

- 移除 `agen discord` CLI 子命令，授權流程改由 TUI 內處理

</details>

## Scope

- `internal/runtime/telegram/` — FEAT, UPDATE (`new.go`, `run.go`, `session.go`, `push.go`, `auth.go`, `pending.go`)
- `internal/runtime/tui/` — FEAT, REFACTOR (`commandTelegram.go`, `commandDiscord.go`, `slog.go`, `init.go`, `commandSwitch.go`, `update.go`)
- `internal/runtime/` — BREAKING (`pending.go` moved from `internal/pending/`)
- `internal/runtime/cli/` — BREAKING (`pending.go`)
- `internal/runtime/discord/` — REFACTOR, FEAT (`new.go`, `push.go`, `session.go`)
- `internal/agents/exec/` — FEAT, UPDATE (`execute.go`, `push.go`, `getSession.go`, `execWithSubagent.go`, `toolCall.go`)
- `internal/tools/` — BREAKING (`askUser.go`, `storeSecret.go`)
- `internal/session/` — UPDATE (`session.go`, `config.go`, `bot.go`)
- `cmd/app/` — REMOVE, FEAT (`main.go`, `cmdDeamon.go`, removed `addDiscord.go`)
- `configs/prompts/` — FEAT, UPDATE (`telegram_system_prompt.md`)
- `internal/utils/` — REFACTOR (`utils.go`)

***

Generated by [SKILL](https://github.com/pardnchiu/skill-version-generate)
