feat: 让单个 Agent 的配置可达并支持一键切换 - #10
Merged
Merged
Conversation
The detail page, its route and the ActivateAgent path all existed already; nothing navigated to /agents/:agentId, so the whole feature was unreachable except by typing the URL. Each overview row now links to it, as an explicit button rather than a whole-row link: the row already carries Launch, and two competing targets is how you start an Agent while meaning to configure it. Configuration is offered even when the Agent is not installed, since pointing it at a Provider needs no binary. Applying no longer demands a freshly typed key and a passing probe. The backend asks for neither: it resolves the key from the request, then the Profile secret, then the Provider record (internal/app/agent.go:92-102), and never requires a probe. A user changing only the model was being made to paste their key again. Apply is now gated on a key existing somewhere, and the skipped test is stated rather than enforced. AgentQuickSwitch adds the CC-Switch-shaped part: one click between the Profiles that already list this Agent. A Profile is already a named bundle of Provider and model, so this reuses them instead of inventing a second grouping concept. Switching sends an empty key for the backend to resolve, so no plaintext key is handled; Profiles the backend would reject for a missing key or model are disabled rather than allowed to fail on a round trip. Two tests changed rather than being deleted. "keeps apply disabled until a probe succeeds" encoded the gate this commit removes, and now asserts the real constraint: no key anywhere means no apply. The verdict-clearing test kept its purpose but asserts the verdict, since Apply no longer reflects it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Closes #5
三步全做,对应 #5 里拆的三段。
第一步:打通入口
调研发现这个功能本来就写完了 —— 详情页、路由、
ActivateAgent写入链路全都在,但没有任何地方跳转到/agents/:agentId,所以除了手输 URL 没人能用到它。现在每个总览行都链接到它。用的是明确的「配置」按钮而不是整行可点:行内已经有「启动」,两个竞争的点击目标就是"想改配置结果启动了 Agent"的成因。
未安装的 Agent 也提供配置入口 —— 把它指向某个 Provider 不需要二进制存在,而写好的配置正是之后安装时会读取的。
第二步:放宽前端自己发明的门禁
原来要求「新输入的 key」+「probe 通过」才能应用。后端两者都不要求:key 有三级 fallback(请求 → Profile secret → Provider 记录,internal/app/agent.go:92-102),probe 从来不是前置条件。
后果是:一个 Provider 里已存 key 的用户,只想换个模型,却被迫重新粘一次 key 并跑一次连接测试。
现在应用按钮的条件是「某处存在 key」,跳过测试是明确告知而非禁止。同时补了两句提示说明 key 从哪来、未测试也可应用 —— 否则空的 key 输入框在有 key 的 Provider 上会读作"没有 key",而可点的应用按钮看起来像 bug。
第三步:CC-Switch 式一键切换
AgentQuickSwitch在详情页顶部给出这个 Agent 可用的 Profile 芯片,一点即切。复用 Profile 而不新建概念 —— 这是 #5 里列的取舍之一。Profile 本来就是"Provider + model 的命名组合",正是快速切换需要的东西;再造一套分组只会让两个概念互相解释。
其余取舍的选择:切换时不做连接测试(这正是"快速"的意义,且
ActivateAgent会先备份配置文件);发送空 key 让后端解析,所以切换全程不接触明文 key;后端会拒绝的 Profile(缺 key 或缺 model)在这里就禁用,而不是让它跑一趟再报错。只列出agentIds包含当前 Agent 的 Profile——应用一个不含它的会静默扩大该 Profile 的作用域。两个测试是改写而非删除
keeps apply disabled until a probe succeeds编码的正是本次移除的门禁。它的注释写着"a rejected key must not reach a config file",但那个约束是前端自己发明的。改写为断言真实约束:任何地方都没有 key 时才禁用。verdict 清除的测试保留了原意(编辑 key 后旧结论必须失效),但改为断言 verdict 本身 —— 因为应用按钮已经不再反映它,继续断言按钮等于什么都没测。
验证
tsc --noEmit与生产构建通过#/agents/codex路由可达,无后端时正确降级为「找不到可配置的 Agent」而非崩溃go test ./internal/...通过,headless CLI 构建通过未能验证的部分
桌面 GUI 在我这台机器上构建不了:上游把
wails/v3升到了v3.0.0-beta.3,本机模块缓存只有 beta.2,而proxy.golang.org网络不通。这与本次改动无关(headless 构建和全部测试都正常),但意味着我没有在真实桌面窗口里点过这些按钮。快速切换的实际写入效果、以及一键切换后配置文件的落盘结果,需要在能构建 GUI 的环境里再确认一次。🤖 Generated with Claude Code