diff --git a/package.json b/package.json index fab6ea54..15a1e3df 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "thinkwatch-lite", "private": true, "description": "Desktop app for a local AI API gateway on macOS, Windows and Linux", - "version": "2026.11.19", + "version": "2026.11.20", "type": "module", "packageManager": "pnpm@11.13.1", "scripts": { diff --git a/scripts/shots/core/en/status.json b/scripts/shots/core/en/status.json index b9f3f535..73b857ea 100644 --- a/scripts/shots/core/en/status.json +++ b/scripts/shots/core/en/status.json @@ -18,5 +18,5 @@ "reachable": [] }, "uptime_secs": 0, - "version": "0.98.1" + "version": "0.99.0" } diff --git a/scripts/shots/core/zh/status.json b/scripts/shots/core/zh/status.json index b9f3f535..73b857ea 100644 --- a/scripts/shots/core/zh/status.json +++ b/scripts/shots/core/zh/status.json @@ -18,5 +18,5 @@ "reachable": [] }, "uptime_secs": 0, - "version": "0.98.1" + "version": "0.99.0" } diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 3c6da4fe..2c0017bd 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -4950,7 +4950,7 @@ dependencies = [ [[package]] name = "thinkwatch-lite" -version = "2026.11.19" +version = "2026.11.20" dependencies = [ "anyhow", "base64 0.22.1", @@ -5459,8 +5459,8 @@ dependencies = [ [[package]] name = "tw-api" -version = "0.98.1" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.98.1#df1022c4d214d58c9774ce32a092854e345ea51e" +version = "0.99.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.99.0#2bcbcbb62450978a10925812f7c327eee380b8fa" dependencies = [ "serde", "serde_json", @@ -5471,8 +5471,8 @@ dependencies = [ [[package]] name = "tw-dialect" -version = "0.98.1" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.98.1#df1022c4d214d58c9774ce32a092854e345ea51e" +version = "0.99.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.99.0#2bcbcbb62450978a10925812f7c327eee380b8fa" dependencies = [ "memchr", "serde", @@ -5481,8 +5481,8 @@ dependencies = [ [[package]] name = "tw-guard" -version = "0.98.1" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.98.1#df1022c4d214d58c9774ce32a092854e345ea51e" +version = "0.99.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.99.0#2bcbcbb62450978a10925812f7c327eee380b8fa" dependencies = [ "aho-corasick", "base64 0.22.1", @@ -5503,8 +5503,8 @@ dependencies = [ [[package]] name = "tw-link" -version = "0.98.1" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.98.1#df1022c4d214d58c9774ce32a092854e345ea51e" +version = "0.99.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.99.0#2bcbcbb62450978a10925812f7c327eee380b8fa" dependencies = [ "serde", "serde_json", @@ -5530,8 +5530,8 @@ dependencies = [ [[package]] name = "tw-types" -version = "0.98.1" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.98.1#df1022c4d214d58c9774ce32a092854e345ea51e" +version = "0.99.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.99.0#2bcbcbb62450978a10925812f7c327eee380b8fa" dependencies = [ "serde", "ts-rs", @@ -5539,8 +5539,8 @@ dependencies = [ [[package]] name = "tw-watch" -version = "0.98.1" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.98.1#df1022c4d214d58c9774ce32a092854e345ea51e" +version = "0.99.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.99.0#2bcbcbb62450978a10925812f7c327eee380b8fa" dependencies = [ "libc", "notify", @@ -5550,8 +5550,8 @@ dependencies = [ [[package]] name = "tw-yaml" -version = "0.98.1" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.98.1#df1022c4d214d58c9774ce32a092854e345ea51e" +version = "0.99.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.99.0#2bcbcbb62450978a10925812f7c327eee380b8fa" dependencies = [ "saphyr-parser", "thiserror 2.0.21", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index a64f6d03..e5ccc5d4 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thinkwatch-lite" -version = "2026.11.19" +version = "2026.11.20" edition = "2024" # **这个数决定依赖能升到哪一版。**edition 2024 的解析器只挑声明的 Rust # 版本编得动的依赖:写 1.85 的时候,`cargo update` 一直停在旧的 time 和 @@ -26,12 +26,12 @@ license = "MIT" # twcore 二进制必须和这里编译进去的协议镜像来自同一个 core 版本 —— 打包脚本正是 # 从 tw-api 锁到的 tag 去取二进制的(见 scripts/fetch-core.sh)。 [workspace.dependencies] -tw-api = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.98.1" } -tw-types = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.98.1" } -tw-yaml = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.98.1" } -tw-guard = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.98.1" } -tw-watch = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.98.1" } -tw-link = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.98.1" } +tw-api = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.99.0" } +tw-types = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.99.0" } +tw-yaml = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.99.0" } +tw-guard = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.99.0" } +tw-watch = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.99.0" } +tw-link = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.99.0" } [lib] name = "thinkwatch_lite_lib" diff --git a/src-tauri/src/call.rs b/src-tauri/src/call.rs index db062738..103f9c83 100644 --- a/src-tauri/src/call.rs +++ b/src-tauri/src/call.rs @@ -3,8 +3,7 @@ //! **只是转发的端点不再各有一个命令。**以前一个端点在这一层要写一个命令, //! 参数名、路径、请求类型各写一遍,前端再按命令名和参数名调一遍 —— 参数名 //! 拼错是运行时才知道的事。现在界面按端点名调(类型来自生成的 `tw-api.ts`), -//! 这里按名字找到 `tw_api::ep` 里那一个端点。搜索能力可随 Core 扩展,三个搜索 -//! 端点直接转发 JSON 交给 Core 校验;其余端点先按钉住的协议类型校验。 +//! 这里按名字找到 `tw_api::ep` 里那一个端点。概览和搜索保留 Core 返回的能力字段。 //! //! **界面够得着的端点只有 [`ALLOWED`] 里这些。**不在里面的有意不给:密钥明文 //! (`KeyValue`,复制走 Rust 这边直接写剪贴板)、让 core 退出、诊断包的正文、 @@ -208,13 +207,12 @@ webview_endpoints![ SyncRepublish, ]; -/// 搜索端点保留 Core 的可扩展能力字段,其余请求先按端点类型校验。 +/// 概览和搜索端点保留 Core 的可扩展能力字段。 async fn relay(c: &ControlClient, params: &[&str], req: Value) -> Out { - // Search capabilities evolve on Core independently of the bundled API. - // Only these already-allowlisted routes accept extensible JSON. Core still - // validates every request, with the same authenticated transport and paths. - if matches!(E::NAME, "WebTools" | "SaveWebTools" | "TestWebTool") { - return Ok(c.call::>(params, &req).await?); + if (E::NAME == "Overview" && req.is_null()) + || matches!(E::NAME, "WebTools" | "SaveWebTools" | "TestWebTool") + { + return Ok(c.call::>(params, &req).await?); } let req: E::Req = serde_json::from_value(req).map_err(|e| { CmdError::plain(format!( @@ -226,9 +224,9 @@ async fn relay(c: &ControlClient, params: &[&str], req: Value) -> O serde_json::to_value(res).map_err(|e| CmdError::plain(e.to_string())) } -struct SearchEndpoint(std::marker::PhantomData); +struct ExtensibleEndpoint(std::marker::PhantomData); -impl Endpoint for SearchEndpoint { +impl Endpoint for ExtensibleEndpoint { const METHOD: tw_api::Method = E::METHOD; const PATH: &'static str = E::PATH; const PARAMS: &'static [&'static str] = E::PARAMS; diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index eab2c822..a4089846 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "ThinkWatch Lite", - "version": "2026.11.19", + "version": "2026.11.20", "identifier": "app.thinkwatch.lite", "build": { "beforeDevCommand": "pnpm dev", diff --git a/src/generated/tw-api.ts b/src/generated/tw-api.ts index 21fa3844..fa461d1d 100644 --- a/src/generated/tw-api.ts +++ b/src/generated/tw-api.ts @@ -3337,6 +3337,10 @@ export type OutcomeDetail = { "action": "recorded", } | { "action": "replaced", * 界面需要的是「有哪些上游、规则怎么写的、谁健康」,不是那份 YAML。 */ export type Overview = { +/** + * Routing changes take effect on the next request, including manual selection. + */ +hard_route_switch?: boolean, /** * 配置文件现在的版本号。和 `GET /config` 的 `version`、改配置时带的 * `base_version` 是同一个。 diff --git a/src/i18n/core.zh.json b/src/i18n/core.zh.json index d0c1372c..2946dc8d 100644 --- a/src/i18n/core.zh.json +++ b/src/i18n/core.zh.json @@ -444,6 +444,11 @@ "gw.wait.mixed": "等待期间没有可处理此请求的上游恢复可用。因 429 暂停:{rate_limited!names}。达到按分钟或小时计的用量上限:{window_full!names}。当天、当周或当月的用量上限已用完:{used_up!names}。达到并发上限:{busy!names}。请稍后重试。", "gw.route.upstream_missing": "配置中不存在「{upstream}」。", "gw.route.selected_upstream_missing": "规则「{rule}」选中的上游「{upstream}」在配置中不存在。", + "gw.route.socket_target": "当前规则选中的上游与此 WebSocket 连接不同。请通过 HTTP 发送此请求以使用当前路由。", + "gw.route.changed": "请求发出前路由已更改。请重新发送请求以使用当前路由。", + "gw.route.history.reasoning": "无法确认当前选中的上游账号能读取此对话的加密推理。请在当前路由下新建对话。", + "gw.route.history.content": "无法确认当前选中的上游账号能读取此对话的加密历史,例如压缩上下文或工具结果。请在当前路由下新建对话。", + "gw.route.history.stored": "此请求引用了上游账号保存的历史,无法确认当前账号能访问。请在当前路由下新建对话。", "gw.route.sealed_upstream_gone": "此对话的历史由上游「{upstream}」加密,该上游已不在配置中,其他上游无法读取。请开始新的对话。", "gw.route.all_selected_disabled": "路由选中的上游均已停用:{detail}", "gw.route.protocol_mismatch": "{path} 只能由 {wanted} 格式的上游处理,而上游「{upstream}」是 {got} 格式。", diff --git a/src/keys/KeyDialog.i18n.ts b/src/keys/KeyDialog.i18n.ts index 36db35bf..c853b4d7 100644 --- a/src/keys/KeyDialog.i18n.ts +++ b/src/keys/KeyDialog.i18n.ts @@ -18,7 +18,8 @@ export const keyDialogText = messages( namePlaceholder: "例如 codex", nameHint: "流量与会话里按它区分客户端", route: "路由", - routeHint: "决定这把密钥的请求发往哪些上游", + routeHint: "指定路由后,这把密钥独立于默认路由设置。", + pinRoute: (name: string) => `固定使用 ${name}`, limit: "并发上限", noLimit: "不限", enabled: "启用", @@ -45,7 +46,8 @@ export const keyDialogText = messages( namePlaceholder: "e.g. codex", nameHint: "Identifies the client in Traffic and Sessions", route: "Route", - routeHint: "Decides which upstreams this key's requests go to", + routeHint: "Assign a route to make this key independent of the default route setting.", + pinRoute: (name: string) => `Always use ${name}`, limit: "Concurrency limit", noLimit: "No limit", enabled: "Enabled", diff --git a/src/keys/KeyDialog.tsx b/src/keys/KeyDialog.tsx index 38149c9b..773b25ea 100644 --- a/src/keys/KeyDialog.tsx +++ b/src/keys/KeyDialog.tsx @@ -1,3 +1,4 @@ +import { routeConfirmText } from "@/routing/RouteConfirmDialogs.i18n"; import { Label } from "@/ui/label"; import { useState } from "react"; import { RotateCwIcon } from "lucide-react"; @@ -45,6 +46,7 @@ export function KeyDialog({ usageLoaded, routes, defaultRoute, + hardRouteSwitch, catalog, rowDays, version, @@ -62,6 +64,7 @@ export function KeyDialog({ usageLoaded: boolean; routes: RouteView[]; defaultRoute: string; + hardRouteSwitch: boolean; /** 网关知道的全部模型,用来勾选可见范围。取不到时为空 */ catalog: KnownModel[]; /** 请求记录留几天(概览里的)。每月的用量上限要求至少 31 天 */ @@ -74,6 +77,7 @@ export function KeyDialog({ onRotate: (name: string) => void; }) { const t = useText(keyDialogText); + const switchText = useText(routeConfirmText); const dialogFocus = useDialogFocus(); const common = useText(commonText); const [name, setName] = useState(editing?.name ?? ""); @@ -203,18 +207,19 @@ export function KeyDialog({ setRoute(nextValue)}> {/* 不绑就是走默认路由 —— 写出来,而不是留一个空白 */} {routeLabel(null, defaultRoute)} - {routes - .filter((r) => r.name !== defaultRoute) - .map((r) => ( - - {r.name} - - ))} + {routes.map((r) => ( + + {r.name === defaultRoute ? t.pinRoute(r.name) : r.name} + + ))}

{t.routeHint}

+ {hardRouteSwitch && editing && (route || defaultRoute) !== (editing.route || defaultRoute) && ( +

{switchText.cutover}

+ )}