Skip to content

feat(portal): add / remove channel instances from the UI#57

Merged
Germey merged 1 commit into
mainfrom
feat/portal-add-remove-channel
Jul 4, 2026
Merged

feat(portal): add / remove channel instances from the UI#57
Germey merged 1 commit into
mainfrom
feat/portal-add-remove-channel

Conversation

@acedatacloud-dev

Copy link
Copy Markdown
Member

What & why

Portal 之前只能编辑 channels.toml已有的渠道 —— 加一个新渠道得手改文件或跑 channels init。这个 PR 让新增 / 删除渠道全在 UI 里完成,客户 setup 更顺。

  • 总览新增 「+ WeChat / + Telegram」 按钮。
  • 每个编辑器新增 「Connection」卡:instance_id、端点(WeChat base_url / Telegram api_base)、token 来源(env 变量名 或 文件路径 —— 永远不存 token 本身)。
  • 新增 「Remove channel」卡 + 「Delete this channel」(带确认框)。
  • Save 仍是整文件重写:新增 = 多 post 一个实例,删除 = 少 post 一个。后端 save() 本就接受任意实例集合并做校验,所以纯前端改动(+测试)。

Testing

  • ruff clean;全套件 485 pass / 1 skip(3 个 pre-existing Windows-only fail,与本 PR 无关)。
  • 新增 4 个后端测试:add / remove / 清空 round-trip + 静态守卫(INDEX_HTML 含新控件)。
  • Playwright 端到端:「+ Telegram」→ 填 Connection(instance_id=tg1 + token env AC_TG)→ Save → channels.toml 写入新的 [[channels.telegram]] 块;「Delete this channel」→ 确认框 → Save → 该块从文件消失。

🤖 对抗评审

Reviewer: Claude general-purpose subagent(此机无 Codex),read-only,一轮。VERDICT: CLEAN —— 逐项核对无缺陷:

  1. removeCurrent() 索引钳制(删首/中/尾/唯一)+ 删空写有效空 config,load_channels_config 正常重解析、channels start 不崩。
  2. 新实例半填 → 后端清晰 400(instance_id/base_url/api_base 校验),不会 500 或静默坏写。
  3. token/端点是用户输入_toml_str 转义 + 写前 parse_channels_config 复校(scheme / embedded-cred / 重名),无 TOML 注入。
  4. 重复 instance_id → 400 拒绝并回显。
  5. #cid/#cbase/#tref 等固定 id:每次只渲染一个编辑器,无 DOM 重复;未保存时改 instance_id 仅显示层,Save 后生效。
  6. 新实例 token_resolvable=falseloadForCurrent() 提前返回,不会用空/未存 id 打 gateway;token 始终服务端解析,不进浏览器。

RISK,无需 fix/rebut。

Previously the portal could only edit channels that already existed in channels.toml; adding one meant hand-editing the file or running channels init. Now the overview has +WeChat / +Telegram buttons, each editor has a Connection card (instance_id, endpoint, and token source = env-var name or file path), and a Delete card removes the instance. Save rewrites the whole file, so add = post one more instance, delete = post one fewer (backend save() already accepted an arbitrary instance set; this is frontend-only).

Playwright-verified: +Telegram -> fill Connection -> Save writes a new [[channels.telegram]] block; Delete -> confirm -> Save removes it. 4 new backend tests (add/remove/empty round-trip + a static guard); full suite 485 pass/1 skip. Adversarial review (Explore subagent): VERDICT CLEAN.
@Germey Germey merged commit 117a442 into main Jul 4, 2026
3 checks passed
@Germey Germey deleted the feat/portal-add-remove-channel branch July 4, 2026 05:44
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.

2 participants