feat(portal): add / remove channel instances from the UI#57
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Portal 之前只能编辑
channels.toml里已有的渠道 —— 加一个新渠道得手改文件或跑channels init。这个 PR 让新增 / 删除渠道全在 UI 里完成,客户 setup 更顺。instance_id、端点(WeChatbase_url/ Telegramapi_base)、token 来源(env 变量名 或 文件路径 —— 永远不存 token 本身)。save()本就接受任意实例集合并做校验,所以纯前端改动(+测试)。Testing
ruffclean;全套件 485 pass / 1 skip(3 个 pre-existing Windows-only fail,与本 PR 无关)。INDEX_HTML含新控件)。instance_id=tg1+ token envAC_TG)→ Save →channels.toml写入新的[[channels.telegram]]块;「Delete this channel」→ 确认框 → Save → 该块从文件消失。🤖 对抗评审
Reviewer: Claude
general-purposesubagent(此机无 Codex),read-only,一轮。VERDICT: CLEAN —— 逐项核对无缺陷:removeCurrent()索引钳制(删首/中/尾/唯一)+ 删空写有效空 config,load_channels_config正常重解析、channels start不崩。_toml_str转义 + 写前parse_channels_config复校(scheme / embedded-cred / 重名),无 TOML 注入。#cid/#cbase/#tref等固定 id:每次只渲染一个编辑器,无 DOM 重复;未保存时改instance_id仅显示层,Save 后生效。token_resolvable=false→loadForCurrent()提前返回,不会用空/未存 id 打 gateway;token 始终服务端解析,不进浏览器。无
RISK,无需 fix/rebut。