Repository navigation
Conversation
默认 Chats 在 AQBot 后增加 ThinkWatch Lite,模板为
thinkwatch://import?service=newapi&url={address}&key={key}。
{address} 由 resolveChatUrl 编码为站点根地址(不带 /v1),{key} 补全 sk- 前缀。
已保存过 Chats 的站点不受影响。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe default chat preset list adds ThinkWatch Lite with a ChangesChat preset
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~3 minutes Change: Feature · Severity of issue fixed: Low Suggested reviewers: Merge Risk: ⚪ Minimal · up to The new preset uses the configured server address and active key to form its import link, with no identified merge-blocking risk. Pre-merge checks |
|
Agent
Links
User request
Out of scope — refuse
Open gate — do not open unless all are satisfied
go buildor tests passed: partly。new-api 一侧按代码推导生成的链接,未在本地运行(见下);ThinkWatch Lite 一侧对这条链接的解析有实际测试。Kind
Issue facts
/v1写进地址;站长要自己查到正确的模板才能添加。thinkwatch://import?service=newapi&url=…&key=…;缺少的只是默认条目。Change
默认
Chats在 AQBot 后增加ThinkWatch Lite,模板为thinkwatch://import?service=newapi&url={address}&key={key}。resolveChatUrl已处理这两个占位符:{address}替换为encodeURIComponent后的服务器地址(站点根地址,不带/v1,ThinkWatch Lite 自行拼接路径),{key}替换为补全sk-前缀的密钥。令牌行操作先取这把令牌的真实密钥;侧栏聊天入口由chatLinkRequiresApiKey识别{key},先取启用中的密钥。两处都走resolveChatUrl,不需要改前端。已保存过聊天预设的站点不受影响。service=newapi时,ThinkWatch Lite 用这把密钥读取/v1/dashboard/billing/subscription与/v1/dashboard/billing/usage(并从公开的/api/status取额度显示单位),在上游旁显示额度与用量。Research
Duplicate / prior art
ThinkWatch、thinkwatch、聊天预设、chat preset、默认聊天Docs and code
setting/chat.go(默认列表);model/option.go(默认值初始化Chats,保存过的优先);controller/misc.go(/api/status返回chats);web/src/features/chat/lib/chat-links.ts(占位符替换)。只需改默认列表。Alternatives considered
{address}、{key}。{thinkwatchConfig}专用占位符,在chat-links.ts中编码整段参数。sk-加字母数字,不编码也不会破坏查询串;ThinkWatch Lite 接受的密钥字符为A-Za-z0-9与- _ . ~ + / = :。A 不改前端,站长也能直接看懂和修改这条模板。Files
setting/chat.goBehavior
thinkwatch://import?service=newapi&url=<编码后的站点地址>&key=sk-…,ThinkWatch Lite 打开「新建上游」对话框并预填,用户确认后才保存。Verification
改动通过阅读代码核对,未在本地运行 new-api;
go vet、go build、make test以及前端的 typecheck 与 test 由本仓库 CI 运行。gofmt -l setting/chat.go无输出(格式正确)。resolveChatUrl的逻辑推导:服务器地址https://api.example.com、密钥abc123XYZ生成thinkwatch://import?service=newapi&url=https%3A%2F%2Fapi.example.com&key=sk-abc123XYZ。ThinkWatch Lite 用测试a_new_api_chat_preset_link_is_accepted解析这条链接(以及带端口、子路径的站点地址),结果为服务类型 New API、地址https://api.example.com、密钥sk-abc123XYZ,在 ThinkWatch Lite 的 CI 中通过(Import links: tests for the links New API and Sub2API generate ThinkWatchProject/ThinkWatch-Lite#323)。ThinkWatch Lite 2026.10.16 已发布。Risks
http://,ThinkWatch Lite 会拒绝该链接。ThinkWatch Lite 早于 2026.10.16 的版本会忽略这类链接。令牌行在取真实密钥后再打开链接,可能被弹窗拦截(fix(keys): open chat preset links inside the click gesture #5395),这对所有自定义协议条目相同。Scope check
Summary by CodeRabbit