Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/shots/core/en/status.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"reachable": []
},
"uptime_secs": 0,
"version": "0.98.1"
"version": "0.99.0"
}
2 changes: 1 addition & 1 deletion scripts/shots/core/zh/status.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"reachable": []
},
"uptime_secs": 0,
"version": "0.98.1"
"version": "0.99.0"
}
30 changes: 15 additions & 15 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 和
Expand All @@ -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"
Expand Down
18 changes: 8 additions & 10 deletions src-tauri/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
//! **只是转发的端点不再各有一个命令。**以前一个端点在这一层要写一个命令,
//! 参数名、路径、请求类型各写一遍,前端再按命令名和参数名调一遍 —— 参数名
//! 拼错是运行时才知道的事。现在界面按端点名调(类型来自生成的 `tw-api.ts`),
//! 这里按名字找到 `tw_api::ep` 里那一个端点。搜索能力可随 Core 扩展,三个搜索
//! 端点直接转发 JSON 交给 Core 校验;其余端点先按钉住的协议类型校验。
//! 这里按名字找到 `tw_api::ep` 里那一个端点。概览和搜索保留 Core 返回的能力字段。
//!
//! **界面够得着的端点只有 [`ALLOWED`] 里这些。**不在里面的有意不给:密钥明文
//! (`KeyValue`,复制走 Rust 这边直接写剪贴板)、让 core 退出、诊断包的正文、
Expand Down Expand Up @@ -208,13 +207,12 @@ webview_endpoints![
SyncRepublish,
];

/// 搜索端点保留 Core 的可扩展能力字段,其余请求先按端点类型校验。
/// 概览和搜索端点保留 Core 的可扩展能力字段。
async fn relay<E: Endpoint>(c: &ControlClient, params: &[&str], req: Value) -> Out<Value> {
// 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::<SearchEndpoint<E>>(params, &req).await?);
if (E::NAME == "Overview" && req.is_null())
|| matches!(E::NAME, "WebTools" | "SaveWebTools" | "TestWebTool")
{
return Ok(c.call::<ExtensibleEndpoint<E>>(params, &req).await?);
}
let req: E::Req = serde_json::from_value(req).map_err(|e| {
CmdError::plain(format!(
Expand All @@ -226,9 +224,9 @@ async fn relay<E: Endpoint>(c: &ControlClient, params: &[&str], req: Value) -> O
serde_json::to_value(res).map_err(|e| CmdError::plain(e.to_string()))
}

struct SearchEndpoint<E>(std::marker::PhantomData<E>);
struct ExtensibleEndpoint<E>(std::marker::PhantomData<E>);

impl<E: Endpoint> Endpoint for SearchEndpoint<E> {
impl<E: Endpoint> Endpoint for ExtensibleEndpoint<E> {
const METHOD: tw_api::Method = E::METHOD;
const PATH: &'static str = E::PATH;
const PARAMS: &'static [&'static str] = E::PARAMS;
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 4 additions & 0 deletions src/generated/tw-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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` 是同一个。
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/core.zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -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} 格式。",
Expand Down
6 changes: 4 additions & 2 deletions src/keys/KeyDialog.i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const keyDialogText = messages(
namePlaceholder: "例如 codex",
nameHint: "流量与会话里按它区分客户端",
route: "路由",
routeHint: "决定这把密钥的请求发往哪些上游",
routeHint: "指定路由后,这把密钥独立于默认路由设置。",
pinRoute: (name: string) => `固定使用 ${name}`,
limit: "并发上限",
noLimit: "不限",
enabled: "启用",
Expand All @@ -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",
Expand Down
19 changes: 12 additions & 7 deletions src/keys/KeyDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { routeConfirmText } from "@/routing/RouteConfirmDialogs.i18n";
import { Label } from "@/ui/label";
import { useState } from "react";
import { RotateCwIcon } from "lucide-react";
Expand Down Expand Up @@ -45,6 +46,7 @@ export function KeyDialog({
usageLoaded,
routes,
defaultRoute,
hardRouteSwitch,
catalog,
rowDays,
version,
Expand All @@ -62,6 +64,7 @@ export function KeyDialog({
usageLoaded: boolean;
routes: RouteView[];
defaultRoute: string;
hardRouteSwitch: boolean;
/** 网关知道的全部模型,用来勾选可见范围。取不到时为空 */
catalog: KnownModel[];
/** 请求记录留几天(概览里的)。每月的用量上限要求至少 31 天 */
Expand All @@ -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 ?? "");
Expand Down Expand Up @@ -203,18 +207,19 @@ export function KeyDialog({
<SelectField id="k-route" value={route} onValueChange={(nextValue) => setRoute(nextValue)}>
{/* 不绑就是走默认路由 —— 写出来,而不是留一个空白 */}
<SelectOption value="">{routeLabel(null, defaultRoute)}</SelectOption>
{routes
.filter((r) => r.name !== defaultRoute)
.map((r) => (
<SelectOption key={r.name} value={r.name}>
{r.name}
</SelectOption>
))}
{routes.map((r) => (
<SelectOption key={r.name} value={r.name}>
{r.name === defaultRoute ? t.pinRoute(r.name) : r.name}
</SelectOption>
))}
</SelectField>
<p className="tw-label text-muted-foreground">{t.routeHint}</p>
</div>
</div>

{hardRouteSwitch && editing && (route || defaultRoute) !== (editing.route || defaultRoute) && (
<p className="tw-label text-muted-foreground">{switchText.cutover}</p>
)}
<div className="flex min-w-0 flex-col gap-1.5 sm:w-1/2 sm:pr-2">
<Label className="tw-body font-medium" htmlFor="k-limit">
{t.limit}
Expand Down
1 change: 1 addition & 0 deletions src/keys/KeysPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ export default function KeysPage({
usageLoaded={usage.byKey !== undefined}
routes={ov.routes}
defaultRoute={ov.default_route}
hardRouteSwitch={ov.hard_route_switch === true}
catalog={catalog.data ?? []}
rowDays={ov.retention.row_days}
version={version}
Expand Down
1 change: 1 addition & 0 deletions src/routing/ChainMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ function describe(
const ms = membersOf(
g,
ov.providers.map((p) => p.name),
ov.hard_route_switch,
);
const ordered = g.kind === "fallback" || g.kind === "select";
const line = node.idle && !g.builtin ? t.unreferenced : (ordered ? t.members : t.membersUnordered)(strategyText(g), ms);
Expand Down
8 changes: 8 additions & 0 deletions src/routing/GroupDialog.i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export const groupDialogText = messages(
toggleMember: (on: boolean, name: string) => `${on ? "移出" : "加入"} ${name}`,
disabledSuffix: " · 已停用",
preferred: "优先使用",
activeUpstream: "使用中",
selectUpstream: "选中",
orderSelectOnly: "保存后,下一次请求发往选中的上游。无法读取的加密历史或上游保存的历史会报错。",

setPreferred: "设为优先",
orderSelect: "拖动调整顺序。选定的上游不可用时,按顺序使用其余成员。",
orderFallback: "拖动调整顺序:依次使用,前一个不可用时使用下一个。",
Expand Down Expand Up @@ -47,6 +51,10 @@ export const groupDialogText = messages(
toggleMember: (on: boolean, name: string) => `${on ? "Remove" : "Add"} ${name}`,
disabledSuffix: " · Disabled",
preferred: "Preferred",
activeUpstream: "Active",
selectUpstream: "Select",
orderSelectOnly: "Once saved, the next request goes to the selected upstream. Unreadable encrypted or upstream-stored history returns an error.",

setPreferred: "Set as preferred",
orderSelect: "Drag to reorder. When the selected upstream is unavailable, the other members are used in order.",
orderFallback: "Drag to reorder: members are used in turn, moving to the next when one is unavailable.",
Expand Down
20 changes: 11 additions & 9 deletions src/routing/GroupDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ export function GroupDialog({
: badWeight !== undefined
? t.weightInvalid(badWeight)
: null;
const strategy = strategies().find((s) => s.id === kind);
const strict = ov.hard_route_switch === true && kind === "select";
const preferredLabel = strict ? t.activeUpstream : t.preferred;
const strategy = strategies(ov.hard_route_switch).find((s) => s.id === kind);

async function save() {
setSaving(true);
Expand Down Expand Up @@ -174,7 +176,7 @@ export function GroupDialog({
label={rt.strategy}
value={kind}
onChange={setKind}
options={strategies().map((s) => ({ id: s.id, label: groupKindLabel(s.id) }))}
options={strategies(ov.hard_route_switch).map((s) => ({ id: s.id, label: groupKindLabel(s.id) }))}
/>
<p key={kind} className="flex flex-wrap items-center gap-x-1.5 tw-label text-muted-foreground motion-fade">
{strategy?.desc}
Expand Down Expand Up @@ -211,7 +213,7 @@ export function GroupDialog({
<TableHead className="w-7 px-0" />
<TableHead className="w-7 px-0" />
<TableHead>{t.upstream}</TableHead>
{kind === "select" && <TableHead className="w-28 text-right">{t.preferred}</TableHead>}
{kind === "select" && <TableHead className="w-28 text-right">{preferredLabel}</TableHead>}
{balanced && <TableHead className="w-24 text-right">{t.weight}</TableHead>}
</TableRow>
</TableHeader>
Expand All @@ -235,10 +237,10 @@ export function GroupDialog({
>
<TableCell
className="px-0 pl-2 text-muted-foreground/60"
aria-label={t.dragMember(n)}
{...reorder.handle(i)}
aria-label={strict ? undefined : t.dragMember(n)}
{...(!strict ? reorder.handle(i) : {})}
>
<GripVerticalIcon className="size-3.5" />
{!strict && <GripVerticalIcon className="size-3.5" />}
</TableCell>
<TableCell className="px-0">
<Checkbox
Expand Down Expand Up @@ -276,15 +278,15 @@ export function GroupDialog({
<TableCell className="text-right">
{on &&
(preferred === n ? (
<Badge variant="secondary">{t.preferred}</Badge>
<Badge variant="secondary">{preferredLabel}</Badge>
) : (
<Button
variant="ghost"
size="xs"
className="text-muted-foreground opacity-0 transition-opacity group-hover/member:opacity-100 focus-visible:opacity-100"
onClick={() => setSelected(n)}
>
{t.setPreferred}
{strict ? t.selectUpstream : t.setPreferred}
</Button>
))}
</TableCell>
Expand Down Expand Up @@ -312,7 +314,7 @@ export function GroupDialog({
)}
<Note>
{kind === "select"
? t.orderSelect
? (strict ? t.orderSelectOnly : t.orderSelect)
: kind === "fallback"
? t.orderFallback
: balanced
Expand Down
Loading
Loading