From f42c5e83c7379c01f72090d769d45097ab758579 Mon Sep 17 00:00:00 2001 From: fylorn <249551762+fylorn@users.noreply.github.com> Date: Mon, 9 Nov 2026 00:06:40 +0800 Subject: [PATCH 1/4] chore(release): publish Lite 2026.11.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Release Lite 2026.11.4 with Core 0.89.2. Traffic columns can be hidden and reordered, with a saved compact preset and date/time layout for smaller windows. Request rows show the upstream model and retain the requested name when routing changes it. Credential names align consistently, and stored HTTP details identify redacted archives. The bundled Core reduces credential false positives, honors native system proxies for system-mode upstreams, and preserves Mistral array content and split placeholders. System proxy settings refresh on configuration apply/reload. Protocol 58 and store schema 28 are unchanged. Validation: the prepared snapshot in #414 passed both frontend typechecks, 1435 frontend tests, production build, 1022 local Rust tests, workspace Clippy, native WKWebView interaction/layout checks and the three platform CI gates. Core 0.89.2 is published; all 14 assets and seven checksum pairs were verified. The release tag will point to the identical tested source tree after this PR’s checks pass. Pricing matching from #405 is unchanged. The Mistral fixes cover reproduced compatibility defects; the incomplete original report is not claimed fully resolved. --- package.json | 2 +- release-notes/2026.11.4.md | 9 ++ scripts/shots/core/en/status.json | 2 +- scripts/shots/core/zh/status.json | 2 +- scripts/shots/scenes.ts | 7 +- src-tauri/Cargo.lock | 30 ++-- src-tauri/Cargo.toml | 14 +- src-tauri/tauri.conf.json | 2 +- src/traffic/ColumnSettings.tsx | 66 ++++++++ src/traffic/ModelCell.tsx | 22 +++ src/traffic/RequestTable.tsx | 184 ++++++++-------------- src/traffic/SessionRow.tsx | 40 ++--- src/traffic/Traffic.i18n.tsx | 18 ++- src/traffic/TrafficPage.tsx | 32 ++-- src/traffic/cells.tsx | 25 +-- src/traffic/columns.test.ts | 32 ++++ src/traffic/columns.ts | 74 +++++++++ src/traffic/drawer/Content.i18n.ts | 28 ++-- src/traffic/drawer/Content.tsx | 2 + src/traffic/drawer/Raw.tsx | 7 +- src/traffic/drawer/RequestDrawer.i18n.tsx | 12 +- src/traffic/tableColumns.test.tsx | 48 ++++++ 22 files changed, 443 insertions(+), 215 deletions(-) create mode 100644 release-notes/2026.11.4.md create mode 100644 src/traffic/ColumnSettings.tsx create mode 100644 src/traffic/ModelCell.tsx create mode 100644 src/traffic/columns.test.ts create mode 100644 src/traffic/columns.ts create mode 100644 src/traffic/tableColumns.test.tsx diff --git a/package.json b/package.json index 0153da6c..5f5af8d8 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.3", + "version": "2026.11.4", "type": "module", "packageManager": "pnpm@11.13.0", "scripts": { diff --git a/release-notes/2026.11.4.md b/release-notes/2026.11.4.md new file mode 100644 index 00000000..93bff9a1 --- /dev/null +++ b/release-notes/2026.11.4.md @@ -0,0 +1,9 @@ +Traffic columns can now be hidden and reordered, with a compact preset that keeps model, token and cost information visible in smaller windows. Preferences are saved locally and apply to request rows and session rows. Older records display their date and time on separate lines. + +Request rows show the model name sent to the upstream, with the original requested name underneath when routing changes it. Both lines share the existing width limit, and hovering reveals the complete names. Credential names align with the column heading, with recognized application icons placed after the name. + +HTTP record details now explain when stored headers and bodies are redacted. The decoded view and raw view use consistent labels so a redacted archive is not mistaken for an exact wire capture. + +This release bundles Core 0.89.2, which reduces credential false positives in code and pool logs, enables native system proxies for upstreams configured to use them, and preserves Mistral array response fragments and split placeholders during format conversion. Applying or reloading configuration refreshes system proxy settings. The Mistral fixes cover reproduced compatibility defects; the original report of delayed or truncated output still needs confirmation with complete traffic. + +The control-plane protocol remains 58 and the request-store schema remains 28. Existing settings, upstreams, request history and usage history are kept. diff --git a/scripts/shots/core/en/status.json b/scripts/shots/core/en/status.json index 1dd98618..dd3c8c2a 100644 --- a/scripts/shots/core/en/status.json +++ b/scripts/shots/core/en/status.json @@ -16,5 +16,5 @@ "reachable": [] }, "uptime_secs": 0, - "version": "0.88.0" + "version": "0.89.2" } diff --git a/scripts/shots/core/zh/status.json b/scripts/shots/core/zh/status.json index 1dd98618..dd3c8c2a 100644 --- a/scripts/shots/core/zh/status.json +++ b/scripts/shots/core/zh/status.json @@ -16,5 +16,5 @@ "reachable": [] }, "uptime_secs": 0, - "version": "0.88.0" + "version": "0.89.2" } diff --git a/scripts/shots/scenes.ts b/scripts/shots/scenes.ts index 44e891c6..e1be482e 100644 --- a/scripts/shots/scenes.ts +++ b/scripts/shots/scenes.ts @@ -31,11 +31,10 @@ export const SCENES: Scene[] = [ { id: "traffic", page: "requests", - // **等表格真的画出来。**表体走 `useDeferredValue`:机器忙的时候,取数和两次相同的 - // 快照都过去了,延后的那一次渲染还没提交 —— 拍下来只有进行中的那一行,而流水线照样 - // 算它成功 + // 等历史请求画出来。虚拟表只画可见的一段,不再等上百行;tbody 上的 + // data-slot 可能被右键菜单触发器覆盖,按请求行自己的标记找。 setup: async () => { - await waitFor(() => (document.querySelectorAll("[data-slot=table-body] > tr").length > 100 ? document.body : null), 30_000); + await waitFor(() => (document.querySelectorAll("tbody > tr[data-row]").length > 10 ? document.body : null), 30_000); }, }, { id: "clients", page: "clients" }, diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 6abf0f2a..ce94a103 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -4950,7 +4950,7 @@ dependencies = [ [[package]] name = "thinkwatch-lite" -version = "2026.11.3" +version = "2026.11.4" dependencies = [ "anyhow", "base64 0.22.1", @@ -5458,8 +5458,8 @@ dependencies = [ [[package]] name = "tw-api" -version = "0.89.1" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.1#c3a4a3949f993f4d67cdc525c59690cc97fa8d38" +version = "0.89.2" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" dependencies = [ "serde", "serde_json", @@ -5470,8 +5470,8 @@ dependencies = [ [[package]] name = "tw-dialect" -version = "0.89.1" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.1#c3a4a3949f993f4d67cdc525c59690cc97fa8d38" +version = "0.89.2" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" dependencies = [ "memchr", "serde", @@ -5480,8 +5480,8 @@ dependencies = [ [[package]] name = "tw-guard" -version = "0.89.1" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.1#c3a4a3949f993f4d67cdc525c59690cc97fa8d38" +version = "0.89.2" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" dependencies = [ "aho-corasick", "base64 0.22.1", @@ -5502,8 +5502,8 @@ dependencies = [ [[package]] name = "tw-link" -version = "0.89.1" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.1#c3a4a3949f993f4d67cdc525c59690cc97fa8d38" +version = "0.89.2" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" dependencies = [ "serde", "serde_json", @@ -5529,8 +5529,8 @@ dependencies = [ [[package]] name = "tw-types" -version = "0.89.1" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.1#c3a4a3949f993f4d67cdc525c59690cc97fa8d38" +version = "0.89.2" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" dependencies = [ "serde", "ts-rs", @@ -5538,8 +5538,8 @@ dependencies = [ [[package]] name = "tw-watch" -version = "0.89.1" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.1#c3a4a3949f993f4d67cdc525c59690cc97fa8d38" +version = "0.89.2" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" dependencies = [ "libc", "notify", @@ -5549,8 +5549,8 @@ dependencies = [ [[package]] name = "tw-yaml" -version = "0.89.1" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.1#c3a4a3949f993f4d67cdc525c59690cc97fa8d38" +version = "0.89.2" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" dependencies = [ "saphyr-parser", "thiserror 2.0.21", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 08a6c33e..37d1c71d 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thinkwatch-lite" -version = "2026.11.3" +version = "2026.11.4" 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.89.1" } -tw-types = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.1" } -tw-yaml = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.1" } -tw-guard = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.1" } -tw-watch = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.1" } -tw-link = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.1" } +tw-api = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.2" } +tw-types = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.2" } +tw-yaml = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.2" } +tw-guard = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.2" } +tw-watch = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.2" } +tw-link = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.2" } [lib] name = "thinkwatch_lite_lib" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 7ed120a6..b54541c9 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.3", + "version": "2026.11.4", "identifier": "app.thinkwatch.lite", "build": { "beforeDevCommand": "pnpm dev", diff --git a/src/traffic/ColumnSettings.tsx b/src/traffic/ColumnSettings.tsx new file mode 100644 index 00000000..ea0659d3 --- /dev/null +++ b/src/traffic/ColumnSettings.tsx @@ -0,0 +1,66 @@ +import type { Dispatch, SetStateAction } from "react"; +import { ArrowDownIcon, ArrowUpIcon, Columns3Icon } from "lucide-react"; +import { useText } from "@/i18n"; +import { Button } from "@/ui/button"; +import { Checkbox } from "@/ui/checkbox"; +import { Popover, PopoverContent, PopoverTitle, PopoverTrigger } from "@/ui/popover"; +import { COMPACT_COLUMNS, DEFAULT_COLUMNS, moveColumn, toggleColumn, type Columns } from "./columns"; +import { trafficText } from "./Traffic.i18n"; +import type { Col } from "./virtual"; + +export function ColumnSettings({ settings, columns, onChange }: { + settings: Columns; + columns: Col[]; + onChange: Dispatch>; +}) { + const t = useText(trafficText); + return ( + + + + + + {t.columns} +
+ + +
+
+ {settings.order.map((col, i) => ( +
+ + + +
+ ))} +
+
+
+ ); +} diff --git a/src/traffic/ModelCell.tsx b/src/traffic/ModelCell.tsx new file mode 100644 index 00000000..ead17042 --- /dev/null +++ b/src/traffic/ModelCell.tsx @@ -0,0 +1,22 @@ +import { useText } from "@/i18n"; +import type { RequestRow } from "@/types"; +import { Tip } from "@/ui/tip"; +import { Lines } from "./cells"; +import { trafficText } from "./Traffic.i18n"; +import { NAME_PX } from "./virtual"; + +/** 发给上游的名字在主行;只有发生改名,才在下面补上请求名。两行共用同一列宽。 */ +export function ModelCell({ r }: { r: Pick }) { + const t = useText(trafficText); + const requested = r.model ?? "—"; + const sent = r.sentModel || requested; + const changed = sent !== requested; + return ( + : requested}> +
+ {sent} + {changed && {t.requestedModel(requested)}} +
+
+ ); +} diff --git a/src/traffic/RequestTable.tsx b/src/traffic/RequestTable.tsx index 33aee5e8..302f1579 100644 --- a/src/traffic/RequestTable.tsx +++ b/src/traffic/RequestTable.tsx @@ -33,7 +33,9 @@ import { StatusDot, type StatusTone } from "@/ui/status-dot"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/ui/table"; import { Tip } from "@/ui/tip"; import { copyText } from "@/ui/notify"; -import { DIM, Elapsed, Lines, NotSentIcon, ROW, RowKeyCell } from "./cells"; +import { ALL_COLUMNS, numericColumn } from "./columns"; +import { ModelCell } from "./ModelCell"; +import { DIM, Elapsed, Lines, NotSentIcon, ROW, RowKeyCell, TimeStamp } from "./cells"; import type { Cursor, Group } from "./grouping"; import { rowMark, type ViaConfig } from "./modelVia"; import { SessionRow, SessionSizerCell, sessionItems, sessionWidths } from "./SessionRow"; @@ -103,8 +105,7 @@ export function RequestTable({ onToggleGroup, onOpenSession, onAbortSession, - showClient, - hints, + columns, cursor, fresh, freshGroups, @@ -131,9 +132,7 @@ export function RequestTable({ onOpenSession: (id: string) => void; /** 中止一次会话里在跑的请求:交给页面弹确认 */ onAbortSession: (id: string) => void; - showClient: boolean; - /** 有哪一行带着推测出的应用:有的话密钥那一格给标志留出位置,名字才对得齐 */ - hints: boolean; + columns: Col[]; /** 键盘选中的那一行:一条请求,或者一个组头 */ cursor: Cursor | null; /** 刚到的那几行,滑进来 */ @@ -155,7 +154,7 @@ export function RequestTable({ const via = useViaConfig(); const items = useMemo(() => itemsOf(rows, groups, openGroups), [rows, groups, openGroups]); const sizers = useSizers(items, t, ts, today, via); - const sizer = (col: Col) => ; + const sizer = (col: Col) => ; return ( - - - {/* 只有一把密钥时这一列每行都一样 —— 那是零信息 */} - {showClient && ( - - {t.client} - {sizer("client")} - - )} - - {t.model} - {sizer("model")} - - - {t.upstream} - {sizer("upstream")} - - {/* 首 token 和总耗时合成一列,生成速度在它的悬停里 —— 非流式请求没有首 token */} - - - + {columns.map((col) => { + const sort = SORT_COLUMN[col]; + const className = cn(col === "status" && "py-1.5", numericColumn(col) && "text-right"); + return sort ? ( + + ) : ( + + {t[col]}{sizer(col)} + + ); + })} {/* 行尾的「…」:和右键是同一份菜单 */} @@ -234,16 +215,10 @@ export function RequestTable({ */} {rows.length === 0 ? ( ({ + status: "w-10", time: "w-14", client: "w-20", model: "w-28", upstream: "w-20", + latency: "w-20 ml-auto", tokens: "w-14 ml-auto", cost: "w-12 ml-auto", + })[col])} /> ) : ( it.kind === "session" ? (
- +
) : (
- {requestCell(col, it.r, { hints, via, today })} + {requestCell(col, it.r, { via, today })}
), )} @@ -357,7 +329,10 @@ function Sizer({ ); } -const COLS: Col[] = ["status", "time", "client", "model", "upstream", "latency", "tokens", "cost"]; +const COLS = ALL_COLUMNS; +const SORT_COLUMN: Partial> = { + status: "status", time: "time", latency: "duration", tokens: "tokens", cost: "cost", +}; /** * 每一列垫哪几项:按 `requestWidths` / `sessionWidths` 估出的宽度取前几名。上游那一列 @@ -442,10 +417,13 @@ function requestWidths(r: RequestRow, t: Text, today: number, via: ViaConfig | n ]; return { status: 2 + textWidth(statusText(r, t)), - time: textWidth(when(r.atMs, today)), + time: Math.max(...when(r.atMs, today).split(" ").map(textWidth)), // 来源的记号在同一个限宽的块里(见 `KeyCell`) client: capped(textWidth(r.client), NAME_PX.client, r.peer ? 18 : 0) + (r.peer ? 3 : 0), - model: capped(textWidth(r.model ?? "—"), NAME_PX.model), + model: capped(Math.max( + textWidth(r.sentModel ?? r.model ?? "—"), + r.sentModel && r.sentModel !== r.model ? textWidth(t.requestedModel(r.model ?? "—")) : 0, + ), NAME_PX.model), upstream: badges.reduce((a, b) => a + b + 1, name), upstreamMin: Math.max(nameMin, ...badges), // 在跑的:首 token 加上一个时钟(「0:42」) @@ -528,8 +506,7 @@ function Body({ groups, hits, openGroups, - showClient, - hints, + columns, via, today, cursor, @@ -550,8 +527,7 @@ function Body({ groups?: Group[]; hits?: ReadonlyMap; openGroups: ReadonlySet; - showClient: boolean; - hints: boolean; + columns: Col[]; via: ViaConfig | null; today: number; cursor: Cursor | null; @@ -575,6 +551,11 @@ function Body({ const guess = useRef({ ...GUESS, learned: new Set() }); /** 量到的高度变了:重算每一项的位置 */ const [measured, setMeasured] = useState(0); + useLayoutEffect(() => { + sizes.current.clear(); + guess.current = { ...GUESS, learned: new Set() }; + setMeasured((n) => n + 1); + }, [columns]); const [region, setRegion] = useState({ top: 0, bottom: 1200 + OVERSCAN_PX }); const estimate = useCallback( @@ -751,7 +732,7 @@ function Body({ const itemsFor = (m: MenuTarget): MenuItems | null => { if (m.kind === "request") { const r = rows.find((x) => x.id === m.id); - return r ? requestItems(r, t, showClient, onOpen, onFilter) : null; + return r ? requestItems(r, t, onOpen, onFilter) : null; } const g = groups?.find((x) => x.id === m.id); if (!g) return null; @@ -769,7 +750,7 @@ function Body({ const opened = useJustOpened(openGroups); const atRow = cursor?.kind === "request" ? cursor.id : null; const atHead = cursor?.kind === "session" ? cursor.id : null; - const cols = showClient ? 9 : 8; + const cols = columns.length + 1; const above = offsets[start] ?? 0; const below = (offsets[items.length] ?? 0) - (offsets[end] ?? 0); return ( @@ -792,10 +773,9 @@ function Body({ r={it.r} hit={hits?.get(it.r.id)} sameClient={it.prev !== undefined && clientKey(it.prev) === clientKey(it.r)} - sameModel={it.prev !== undefined && (it.prev.model ?? "") === (it.r.model ?? "")} + sameModel={it.prev !== undefined && it.prev.model === it.r.model && it.prev.sentModel === it.r.sentModel} sameProvider={it.prev !== undefined && upstreamText(it.prev) === upstreamText(it.r)} - showClient={showClient} - hints={hints} + columns={columns} via={via} today={today} selected={atRow === it.r.id} @@ -810,8 +790,7 @@ function Body({ key={it.key} g={it.g} open={it.open} - showClient={showClient} - hints={hints} + columns={columns} // 右边开着的那次会话,或者键盘停在这个组头上 selected={selectedSession === it.g.id || atHead === it.g.id} fresh={it.g.id !== null && freshGroups.has(it.g.id)} @@ -877,7 +856,6 @@ const TONE: Record, StatusTone> = { function requestItems( r: RequestRow, t: Text, - showClient: boolean, onOpen: (id: number) => void, onFilter: (f: (prev: Filter) => Filter) => void, ): MenuItems { @@ -897,7 +875,7 @@ function requestItems( }, ] as const) : []), - ...(showClient + ...(r.client ? ([ { kind: "item", @@ -917,7 +895,7 @@ function requestItems( [ new Date(r.atMs).toLocaleString(), r.client, - r.model ?? "", + r.sentModel && r.sentModel !== r.model ? `${r.model ?? "—"} → ${r.sentModel}` : r.model ?? "", upstreamText(r), r.path, r.status ?? r.state, @@ -941,27 +919,20 @@ function requestItems( } /** 一行的一格里画什么。行自己和表头量列宽的那一块(`Sizer`)都用它 */ -function requestCell(col: Col, r: RequestRow, c: { hints: boolean; via: ViaConfig | null; today: number }): ReactNode { +function requestCell(col: Col, r: RequestRow, c: { via: ViaConfig | null; today: number }): ReactNode { switch (col) { case "status": return ; case "time": return ( - {when(r.atMs, c.today)} + ); case "client": - return ; + return ; case "model": - return ( - // 截断要套在里面一层:`max-width` 加在 td 上会被表格自己的列宽算法吃掉,长名字照样把这一列撑开 - -
- {r.model ?? "—"} -
-
- ); + return ; case "upstream": return ; case "latency": @@ -982,8 +953,7 @@ const Row = memo(function Row({ sameClient, sameModel, sameProvider, - showClient, - hints, + columns, via, today, selected, @@ -999,8 +969,7 @@ const Row = memo(function Row({ sameClient: boolean; sameModel: boolean; sameProvider: boolean; - showClient: boolean; - hints: boolean; + columns: Col[]; /** 对「别名」「指定」用的配置(见 `modelVia.ts`)。换了一版配置每一行重画一次 */ via: ViaConfig | null; today: number; @@ -1014,7 +983,7 @@ const Row = memo(function Row({ onCursor: (c: Cursor) => void; }) { const t = useText(trafficText); - const c = { hints, via, today }; + const c = { via, today }; // 点一行和键盘选中一行是同一件事:之后的方向键从这一行接着走 const activate = () => { onCursor({ kind: "request", id: r.id }); @@ -1034,32 +1003,19 @@ const Row = memo(function Row({ hit && "border-b-0 [&:has(+tr:hover)]:bg-foreground/[0.035]", )} > - {/* - 状态用色点编码。**25 个灰色 200 排成一列是零信息** —— - 眼睛要能一眼扫到那个 5xx,而不是逐行读数字。 - */} - {requestCell("status", r, c)} - {/* - 时间用绝对值。**相对时间在这一列会塌掉** —— 打开应用 - 看昨天那次时,整列全是「1d」,而这一列的用途就是把 - 某一行对上号。完整的日期和时间留给悬停。 - */} - {requestCell("time", r, c)} - {showClient && {requestCell("client", r, c)}} - {/* - 模型。**这一列决定了这次多贵、多慢** —— 同一个客户端 - 连着发的两次请求,差别往往只在这里。 - */} - {requestCell("model", r, c)} - {requestCell("upstream", r, c)} - {/* - 数字右对齐。左对齐时 253ms 和 1486ms 的个位对不齐, - 扫一列找最慢的那条要逐行读 —— 而这一列存在的意义就是 - 扫出极值。 - */} - {requestCell("latency", r, c)} - {requestCell("tokens", r, c)} - {requestCell("cost", r, c)} + {columns.map((col) => ( + {requestCell(col, r, c)} + ))} {/* **点「…」不能连带打开这一行。**按钮上的点击会冒泡到行上,行一收到 就去开详情,菜单和抽屉会一起出来。只在悬停、选中、菜单开着时出现: @@ -1091,7 +1047,7 @@ const Row = memo(function Row({ )} > - + diff --git a/src/traffic/SessionRow.tsx b/src/traffic/SessionRow.tsx index a70d2fb7..fa1605ec 100644 --- a/src/traffic/SessionRow.tsx +++ b/src/traffic/SessionRow.tsx @@ -11,7 +11,8 @@ import { StatusDot } from "@/ui/status-dot"; import { TableCell, TableRow } from "@/ui/table"; import { Tip } from "@/ui/tip"; import { copyText } from "@/ui/notify"; -import { KeyCell, ROW } from "./cells"; +import { numericColumn } from "./columns"; +import { KeyCell, ROW, TimeStamp } from "./cells"; import { costCell } from "./costCell"; import { SessionCost } from "./SessionCost"; import { sessionsText } from "./Sessions.i18n"; @@ -47,8 +48,7 @@ type Text = (typeof sessionsText)["zh"]; export const SessionRow = memo(function SessionRow({ g, open, - showClient, - hints, + columns, selected, fresh, onToggle, @@ -57,9 +57,7 @@ export const SessionRow = memo(function SessionRow({ }: { g: Group; open: boolean; - showClient: boolean; - /** 同请求行:密钥那一格要不要给应用的标志留位置 */ - hints: boolean; + columns: Col[]; selected: boolean; /** 刚出现的会话,滑进来 */ fresh: boolean; @@ -70,7 +68,7 @@ export const SessionRow = memo(function SessionRow({ }) { const t = useText(sessionsText); const f = sessionFacts(g); - const c: CellCtx = { t, open, selected, hints, onToggle }; + const c: CellCtx = { t, open, selected, onToggle }; const openIt = () => { // 点组头和点请求行一样,键盘接着从这一行往下走 onCursor({ kind: "session", id: f.id }); @@ -86,14 +84,11 @@ export const SessionRow = memo(function SessionRow({ onClick={openIt} className={cn(ROW, "bg-foreground/[0.025] font-medium", fresh && "motion-row-in")} > - {sessionCell("status", f, c)} - {sessionCell("time", f, c)} - {showClient && {sessionCell("client", f, c)}} - {sessionCell("model", f, c)} - {sessionCell("upstream", f, c)} - {sessionCell("latency", f, c)} - {sessionCell("tokens", f, c)} - {sessionCell("cost", f, c)} + {columns.map((col) => ( + + {sessionCell(col, f, c)} + + ))} e.stopPropagation()}> @@ -148,10 +143,10 @@ function sessionFacts(g: Group): Facts { }; } -type CellCtx = { t: Text; open: boolean; selected: boolean; hints: boolean; onToggle: (id: string) => void }; +type CellCtx = { t: Text; open: boolean; selected: boolean; onToggle: (id: string) => void }; /** 组头的一格。组头自己和表头量列宽的那一块(`SessionSizerCell`)都用它 */ -function sessionCell(col: Col, f: Facts, { t, open, selected, hints, onToggle }: CellCtx): ReactNode { +function sessionCell(col: Col, f: Facts, { t, open, selected, onToggle }: CellCtx): ReactNode { const { id, s, first, n, providers } = f; switch (col) { case "status": @@ -202,12 +197,12 @@ function sessionCell(col: Col, f: Facts, { t, open, selected, hints, onToggle }: - {when(n.started)} + {t.runningTip(n.running)} ) : ( - when(n.started) + ); case "client": return ( @@ -216,7 +211,6 @@ function sessionCell(col: Col, f: Facts, { t, open, selected, hints, onToggle }: masked={first?.keyMasked} hint={first?.hint} peer={first?.peer} - hints={hints} /> ); case "model": @@ -246,9 +240,9 @@ function sessionCell(col: Col, f: Facts, { t, open, selected, hints, onToggle }: } /** 表头里量列宽用的组头的一格:和组头里的那一格画得一模一样,只是没人点得到它 */ -export function SessionSizerCell({ col, g, hints }: { col: Col; g: Group; hints: boolean }) { +export function SessionSizerCell({ col, g }: { col: Col; g: Group }) { const t = useText(sessionsText); - return sessionCell(col, sessionFacts(g), { t, open: false, selected: false, hints, onToggle: () => {} }); + return sessionCell(col, sessionFacts(g), { t, open: false, selected: false, onToggle: () => {} }); } /** @@ -262,7 +256,7 @@ export function sessionWidths(g: Group, t: Text): Widths { const upstream = capped(names(providers), NAME_PX.upstream, 22) + 3; return { status: 3 + textWidth(t.turnCount(n.turns)) + (n.failed > 0 ? 2 + String(n.failed).length : 0), - time: textWidth(when(n.started)) + (n.running > 0 ? 2 : 0), + time: Math.max(...when(n.started).split(" ").map(textWidth)) + (n.running > 0 ? 2 : 0), client: capped(textWidth(s?.client ?? first?.client ?? ""), NAME_PX.client, first?.peer ? 18 : 0) + (first?.peer ? 3 : 0), model: capped(names(n.models), NAME_PX.model), upstream, diff --git a/src/traffic/Traffic.i18n.tsx b/src/traffic/Traffic.i18n.tsx index 1a2059bd..fd642eb9 100644 --- a/src/traffic/Traffic.i18n.tsx +++ b/src/traffic/Traffic.i18n.tsx @@ -94,6 +94,14 @@ export const trafficText = messages( /** 读历史失败了,但之后事件流上来了几条:表照常画,上面挂这一句 */ historyPartial: "请求记录读取失败,以下仅为此后收到的请求。", + columns: "列设置", + compactColumns: "紧凑视图", + resetColumns: "恢复默认", + moveColumnUp: (name: string) => `将${name}列前移`, + moveColumnDown: (name: string) => `将${name}列后移`, + requestedModel: (name: string) => `请求:${name}`, + sentModel: (name: string) => `发往上游:${name}`, + // 表头 status: "状态", time: "时间", @@ -152,7 +160,7 @@ export const trafficText = messages( retryingTip: (names: string[], at: string) => `等待重试上游:${names.join("、")}。最晚等到 ${at}。`, // 上游一列的徽标和它们的悬浮说明 - /** 客户端写的是别名,按这家上游换成了它的模型名。模型那一列照旧是客户端写的名称 */ + /** 客户端写的是别名,按这家上游换成了它的模型名。模型列同时显示发出的模型名与请求名 */ aliasTip: (model: string, upstream: string, sent: string) => `${model} 是别名,发往 ${upstream} 的模型名是 ${sent}。`, /** 决定去向的规则用了「指定模型」:上游和模型都是规则列出的 */ pinned: "指定", @@ -261,6 +269,14 @@ export const trafficText = messages( historyFailed: "Could not load the request log", historyPartial: "The request log could not be loaded. Only requests received since then are shown below.", + columns: "Columns", + compactColumns: "Compact view", + resetColumns: "Reset columns", + moveColumnUp: (name: string) => `Move ${name} column earlier`, + moveColumnDown: (name: string) => `Move ${name} column later`, + requestedModel: (name: string) => `Requested: ${name}`, + sentModel: (name: string) => `Sent upstream: ${name}`, + status: "Status", time: "Time", client: "Key", diff --git a/src/traffic/TrafficPage.tsx b/src/traffic/TrafficPage.tsx index 6abd6747..2ccaf2cf 100644 --- a/src/traffic/TrafficPage.tsx +++ b/src/traffic/TrafficPage.tsx @@ -28,6 +28,8 @@ import { useArrivals } from "./arrivals"; import { copyText } from "@/ui/notify"; import { groupAt, groupBySession, isAt, lines, step, visible, type Cursor, type Group } from "./grouping"; import { mergeFound, useHistorySearch, type HistorySearch } from "./historySearch"; +import { ColumnSettings } from "./ColumnSettings"; +import { useTrafficColumns } from "./columns"; import { RequestTable, type RequestTableHandle } from "./RequestTable"; import { SessionSheet } from "./SessionPanel"; import { AbortSessionDialog, abortable } from "./abort"; @@ -141,8 +143,8 @@ export default function TrafficPage({ new Set(universe.flatMap((r) => (r.client ? [r.client] : []))).size > 1 || new Set(universe.map((r) => r.hint ?? "")).size > 1 || universe.some((r) => r.peer); - /** 有哪一行带着推测出的应用。按全集算:筛选一变,密钥那一格的缩进不该跟着跳 */ - const hints = useMemo(() => universe.some((r) => r.hint), [universe]); + /** 列的显隐和顺序是本机偏好,不随筛选变化。 */ + const { settings: columnSettings, setSettings: setColumnSettings, columns } = useTrafficColumns(showClient); /* 刚到的请求和刚出现的会话,滑进来。**按全集算**,见 `useArrivals`。 @@ -298,16 +300,19 @@ export default function TrafficPage({ 不和筛选放在一起,放在页头右边,两个里选一个:逐条看请求,或者看会话(收起 来就是会话列表,展开是那次任务的每一轮)。 */ - setGrouped(v === "sessions")} - disabled={none} - /> +
+ + setGrouped(v === "sessions")} + disabled={none} + /> +
} summary={ // 历史读完之前,「0 条请求」不是真的;读失败时也说不出一共几条 @@ -555,8 +560,7 @@ export default function TrafficPage({ scroller={listRef} rows={rows} hits={found?.hits} - showClient={showClient} - hints={hints} + columns={columns} cursor={cursor} fresh={fresh} freshGroups={freshGroups} diff --git a/src/traffic/cells.tsx b/src/traffic/cells.tsx index 011862ad..e26a7511 100644 --- a/src/traffic/cells.tsx +++ b/src/traffic/cells.tsx @@ -39,8 +39,7 @@ export const MENU_REVEAL = * 默认窗口下整张表被撑宽,被挤出视野的是最后一列费用。名字够认出是哪一把;打码 * 的值、推测的应用、来源一项一行写在悬停里,请求详情里也都有。 * - * `hints`:表里有哪一行带着推测出的应用。有的话没有应用的行也留出标志的位置, - * 名字才对得齐。 + * 名字始终在最前面与表头对齐,识别到的应用标志跟在名字后;未知应用不占位。 * * **整块封顶**(`NAME_PX`):名字再长也只截断名字,标志和来源记号留着;悬停第一行就是 * 完整的名字(连同打码的值)。 @@ -50,13 +49,11 @@ export function KeyCell({ masked, hint, peer, - hints, }: { client: string; masked?: string; hint?: string; peer?: string; - hints: boolean; }) { const t = useText(trafficText); const tip = [ @@ -67,13 +64,8 @@ export function KeyCell({ return ( }> - {hints && - (hint ? ( - - ) : ( - - ))} {client} + {hint && } {/* 非本机来的,名字后面挂一个记号:这台网关对局域网开着,这一条不是本机发的。 **地址进悬停**,不写在格子里 —— 一串 IP 有一百像素,整列跟着它变宽, @@ -91,8 +83,17 @@ export function KeyCell({ } /** 一条请求的密钥那一格 */ -export function RowKeyCell({ r, hints }: { r: RequestRow; hints: boolean }) { - return ; +export function RowKeyCell({ r }: { r: RequestRow }) { + return ; +} + +/** 历史记录的日期与时间分行,今天的时间保持一行。 */ +export function TimeStamp({ text }: { text: string }) { + return ( + + {text.split(" ").map((part, i) => {part})} + + ); } /** 每一种在上游标志的位置上画的图形和颜色 */ diff --git a/src/traffic/columns.test.ts b/src/traffic/columns.test.ts new file mode 100644 index 00000000..bdb1d5c4 --- /dev/null +++ b/src/traffic/columns.test.ts @@ -0,0 +1,32 @@ +import { describe, expect, it } from "vitest"; +import { ALL_COLUMNS, COMPACT_COLUMNS, DEFAULT_COLUMNS, moveColumn, normalizeColumns, toggleColumn, visibleColumns } from "./columns"; + +describe("流量列设置", () => { + it("修复无效或旧的偏好,始终保留状态首列并补齐缺少的列", () => { + expect(normalizeColumns(null)).toEqual(DEFAULT_COLUMNS); + const settings = normalizeColumns({ order: ["cost", "cost", "unknown", null], hidden: ["status", "time", "unknown", "time"] }); + expect(settings.order).toEqual(["status", "cost", ...ALL_COLUMNS.filter((c) => c !== "status" && c !== "cost")]); + expect(settings.hidden).toEqual(["time"]); + }); + + it("密钥默认随数据显隐;手动显示后单密钥也可见", () => { + expect(visibleColumns(DEFAULT_COLUMNS, false)).not.toContain("client"); + expect(visibleColumns(DEFAULT_COLUMNS, true)).toContain("client"); + const selected = toggleColumn(DEFAULT_COLUMNS, "client", true); + expect(visibleColumns(selected, false)).toContain("client"); + expect(visibleColumns(toggleColumn(selected, "client", false), true)).not.toContain("client"); + }); + + it("调整顺序和隐藏后往返存储仍保留选择", () => { + const settings = moveColumn(toggleColumn(DEFAULT_COLUMNS, "upstream", false), "cost", -1); + const restored = normalizeColumns(JSON.parse(JSON.stringify(settings))); + expect(visibleColumns(restored, true)).toEqual(["status", "time", "client", "model", "latency", "cost", "tokens"]); + expect(moveColumn(restored, "status", 1)).toBe(restored); + expect(moveColumn(restored, "time", -1)).toBe(restored); + expect(toggleColumn(restored, "status", false)).toBe(restored); + }); + + it("紧凑视图保留模型、token 和费用", () => { + expect(visibleColumns(COMPACT_COLUMNS, true)).toEqual(["status", "time", "model", "tokens", "cost"]); + }); +}); diff --git a/src/traffic/columns.ts b/src/traffic/columns.ts new file mode 100644 index 00000000..17057f22 --- /dev/null +++ b/src/traffic/columns.ts @@ -0,0 +1,74 @@ +import { useEffect, useMemo, useState } from "react"; +import type { Col } from "./virtual"; + +export const ALL_COLUMNS: Col[] = ["status", "time", "client", "model", "upstream", "latency", "tokens", "cost"]; +export interface Columns { + order: Col[]; + hidden: Col[]; + /** 默认只有多把密钥时显示;手动选过之后遵从选择。 */ + autoClient: boolean; +} +export const DEFAULT_COLUMNS: Columns = { order: ALL_COLUMNS, hidden: [], autoClient: true }; +export const COMPACT_COLUMNS: Columns = { + order: ["status", "time", "model", "tokens", "cost", "client", "upstream", "latency"], + hidden: ["client", "upstream", "latency"], + autoClient: false, +}; +const STORAGE_KEY = "tw-traffic-columns"; +const isCol = (v: unknown): v is Col => ALL_COLUMNS.includes(v as Col); + +/** 旧偏好或损坏的数据不能让表头与行丢列。状态固定在首列,保留会话展开入口。 */ +export function normalizeColumns(value: unknown): Columns { + if (!value || typeof value !== "object") return DEFAULT_COLUMNS; + const v = value as Partial; + const order = [...new Set
([ + "status", ...(Array.isArray(v.order) ? v.order.filter(isCol) : []), ...ALL_COLUMNS, + ])]; + const hidden = Array.isArray(v.hidden) ? [...new Set(v.hidden.filter((c) => isCol(c) && c !== "status"))] : []; + return { order, hidden, autoClient: v.autoClient !== false }; +} + +export function visibleColumns(settings: Columns, multipleClients: boolean): Col[] { + return settings.order.filter((col) => + !settings.hidden.includes(col) && (col !== "client" || !settings.autoClient || multipleClients), + ); +} + +export function toggleColumn(settings: Columns, col: Col, shown: boolean): Columns { + if (col === "status") return settings; + return { + ...settings, + hidden: shown ? settings.hidden.filter((c) => c !== col) : [...new Set([...settings.hidden, col])], + autoClient: col === "client" ? false : settings.autoClient, + }; +} + +export function moveColumn(settings: Columns, col: Col, by: -1 | 1): Columns { + const at = settings.order.indexOf(col); + const next = at + by; + if (at <= 0 || next <= 0 || next >= settings.order.length) return settings; + const order = [...settings.order]; + [order[at], order[next]] = [order[next]!, order[at]!]; + return { ...settings, order }; +} + +export const numericColumn = (col: Col) => col === "latency" || col === "tokens" || col === "cost"; + +export function useTrafficColumns(multipleClients: boolean) { + const [settings, setSettings] = useState(() => { + try { + return normalizeColumns(JSON.parse(window.localStorage.getItem(STORAGE_KEY) ?? "null")); + } catch { + return DEFAULT_COLUMNS; + } + }); + useEffect(() => { + try { + window.localStorage.setItem(STORAGE_KEY, JSON.stringify(settings)); + } catch { + // 无法存储时,本次窗口仍可调整。 + } + }, [settings]); + const columns = useMemo(() => visibleColumns(settings, multipleClients), [settings, multipleClients]); + return { settings, setSettings, columns }; +} diff --git a/src/traffic/drawer/Content.i18n.ts b/src/traffic/drawer/Content.i18n.ts index 803ccc7f..38b0e7c4 100644 --- a/src/traffic/drawer/Content.i18n.ts +++ b/src/traffic/drawer/Content.i18n.ts @@ -9,9 +9,12 @@ const count = (n: number, one: string, many: string) => (n === 1 ? `1 ${one}` : */ export const contentText = messages( { - /** 看法:按对话读出来,或者报文原样 */ - views: { parsed: "解析", raw: "原始报文" }, + /** 看法:按对话读出来,或者查看已脱敏的报文记录 */ + views: { parsed: "解析", raw: "报文记录" }, viewsLabel: "内容的显示方式", + redactedRecord: + "请求头和正文在记录时会再次脱敏,此处的占位符不一定发给了上游。发送前实际替换的位置见安全记录。", + copyRecord: "复制记录", /** 原始报文看哪一边:客户端收发的,或者网关和上游之间的 */ sides: { client: "客户端一侧", upstream: "上游一侧" }, sidesLabel: "报文的一侧", @@ -38,10 +41,10 @@ export const contentText = messages( showEarlierEvents: "显示全部事件", // 解析不出来的时候 - unknownFormat: "无法识别此请求的格式,原文见「原始报文」", - requestCut: "请求过大,仅保存了开头部分,无法解析,原文见「原始报文」", - requestUnreadable: "请求正文无法解析,原文见「原始报文」", - responseUnreadable: "回答的格式无法识别,原文见「原始报文」", + unknownFormat: "无法识别此请求的格式,内容见「报文记录」", + requestCut: "请求过大,仅保存了开头部分,无法解析,内容见「报文记录」", + requestUnreadable: "请求正文无法解析,内容见「报文记录」", + responseUnreadable: "回答的格式无法识别,内容见「报文记录」", /** 认得出格式,但里面没有文字、思考或工具调用 */ noAnswer: "回答中没有可显示的内容", @@ -55,8 +58,11 @@ export const contentText = messages( liveFailed: (why: string) => `无法显示实时内容:${why}`, }, { - views: { parsed: "Parsed", raw: "Raw" }, + views: { parsed: "Parsed", raw: "Recorded HTTP" }, viewsLabel: "How the content is shown", + redactedRecord: + "Headers and bodies are redacted again for the record. A placeholder here may not have been sent upstream. See the security records for what was replaced before sending.", + copyRecord: "Copy record", sides: { client: "Client side", upstream: "Upstream side" }, sidesLabel: "Side of the exchange", attemptsLabel: "Attempt", @@ -75,10 +81,10 @@ export const contentText = messages( earlierEvents: (n: number) => (n === 1 ? "1 earlier event" : `${n.toLocaleString()} earlier events`), showEarlierEvents: "Show all events", - unknownFormat: "The format of this request is not recognized; see Raw for the original", - requestCut: "The request was too large to save in full and cannot be parsed; see Raw for the beginning", - requestUnreadable: "The request body cannot be parsed; see Raw for the original", - responseUnreadable: "The response format is not recognized; see Raw for the original", + unknownFormat: "The format of this request is not recognized; see Recorded HTTP", + requestCut: "The request was too large to save in full and cannot be parsed; see Recorded HTTP for the beginning", + requestUnreadable: "The request body cannot be parsed; see Recorded HTTP", + responseUnreadable: "The response format is not recognized; see Recorded HTTP", noAnswer: "The response has nothing to show", sameAsClient: "The body is the same as on the client side", diff --git a/src/traffic/drawer/Content.tsx b/src/traffic/drawer/Content.tsx index c9048e90..9429984e 100644 --- a/src/traffic/drawer/Content.tsx +++ b/src/traffic/drawer/Content.tsx @@ -159,6 +159,8 @@ export function Content({ )} +

{t.redactedRecord}

+ {liveError && (
{t.liveFailed(liveError)} diff --git a/src/traffic/drawer/Raw.tsx b/src/traffic/drawer/Raw.tsx index 62d6d67a..a8906d05 100644 --- a/src/traffic/drawer/Raw.tsx +++ b/src/traffic/drawer/Raw.tsx @@ -2,7 +2,6 @@ import { memo, useLayoutEffect, useMemo, useRef, useState, type ReactNode, type import { ChevronRightIcon } from "lucide-react"; import { size } from "@/format"; import { useText } from "@/i18n"; -import { commonText } from "@/i18n/common.i18n"; import { cn } from "@/lib/utils"; import { useMarker, useScrollToFirstHit } from "@/security/Highlight"; import { prettyJson } from "@/prettyJson"; @@ -25,7 +24,7 @@ const RECENT_EVENTS = 200; const BLOCK = 48; /** - * 「内容 › 原始报文」:一段报文原样 —— 请求行、头、正文;回答的状态行、头,和流里的每一个事件 + * 「内容 › 报文记录」:已脱敏的请求行、头、正文;回答的状态行、头,和流里的每一个事件 * 往下追加。等宽,和请求详情原来的正文同一个样子(`BodyText`)。 * * **跟随最新**(`follow`):回答在长时,回答那一框停在最底下;往上翻就停下(`onUserScroll`), @@ -85,10 +84,10 @@ function plain(head: HeadView | null, body: string | null): string { } function CopyAll({ text }: { text: () => string }) { - const common = useText(commonText); + const t = useText(contentText); return ( ); } diff --git a/src/traffic/drawer/RequestDrawer.i18n.tsx b/src/traffic/drawer/RequestDrawer.i18n.tsx index 558f4e32..0e88c7b6 100644 --- a/src/traffic/drawer/RequestDrawer.i18n.tsx +++ b/src/traffic/drawer/RequestDrawer.i18n.tsx @@ -194,10 +194,10 @@ export const requestDrawerText = messages( // 重放 replayIntro: (em: (x: ReactNode) => ReactNode) => ( - <>将此请求{em("原样")}发送至另一个上游,并排对比结果 + <>将{em("记录中的请求")}发送至另一个上游,并排对比结果 ), - asIsTip: "使用记录中保存的原始请求体,内容与原请求完全一致。", - asIs: "「原样」的含义", + asIsTip: "使用保存时已脱敏的请求体,其中的占位符和遮蔽后的值也会一并发送。", + asIs: "记录的内容", /** 选重放目标的那个下拉框,上游列表没取到 */ upstreamsFailed: "上游列表读取失败", /** 下拉框里原来那个上游名后面的标记 */ @@ -384,12 +384,12 @@ export const requestDrawerText = messages( replayIntro: (em: (x: ReactNode) => ReactNode) => ( <> - Send this request {em("as is")} to another upstream and compare the results side by side + Send {em("the recorded request")} to another upstream and compare the results side by side ), asIsTip: - "Uses the original request body saved in the record; the content is identical to the original request.", - asIs: "What “as is” means", + "Uses the body redacted for storage, including any placeholders and masked values.", + asIs: "About the stored request", upstreamsFailed: "Could not load the upstreams", originalUpstream: " (original)", estimateCost: "Estimate cost", diff --git a/src/traffic/tableColumns.test.tsx b/src/traffic/tableColumns.test.tsx new file mode 100644 index 00000000..d6216f59 --- /dev/null +++ b/src/traffic/tableColumns.test.tsx @@ -0,0 +1,48 @@ +import type { ReactNode } from "react"; +import { renderToStaticMarkup } from "react-dom/server"; +import { describe, expect, it, vi } from "vitest"; +import type { RequestRow } from "@/types"; +import { ModelCell } from "./ModelCell"; +import { KeyCell } from "./cells"; +import { RequestTable } from "./RequestTable"; + +vi.mock("@/ui/tip", () => ({ Tip: ({ children }: { children: ReactNode }) => <>{children} })); +vi.mock("./useModelVia", () => ({ useViaConfig: () => null })); + +const row: RequestRow = { id: 1, client: "my-client", model: "opus", sentModel: "glm-5.3", provider: "relay", path: "/v1/messages", atMs: 0, state: "done", status: 200 }; + +function table(grouped: boolean) { + return renderToStaticMarkup( {}} onOpenSession={() => {}} + onAbortSession={() => {}} cursor={null} fresh={new Set()} freshGroups={new Set()} today={0} + sortKey="time" sortDir="desc" onSort={() => {}} onCursor={() => {}} onOpen={() => {}} onFilter={() => {}} + groups={grouped ? [{ id: "s", session: null, rows: [row] }] : undefined} + />); +} + +describe("流量表列与内容", () => { + it.each([false, true])("自定义列顺序在请求和会话表头、表体一致(归组 %s)", (grouped) => { + const html = table(grouped); + const header = html.match(//)![0]; + expect(header.indexOf("费用")).toBeLessThan(header.indexOf("模型")); + expect(header).not.toContain("上游"); + const rows = html.match(/]*data-(?:row|session)=[\s\S]*?<\/tr>/g)!; + expect(rows.length).toBe(grouped ? 2 : 1); + for (const r of rows) expect((r.match(/ { + const html = renderToStaticMarkup(); + expect(html.indexOf("glm-5.3")).toBeLessThan(html.indexOf("opus")); + expect(html).toContain("max-width:208px"); + const same = renderToStaticMarkup(); + expect(same.match(/opus/g)).toHaveLength(1); + }); + + it("未知应用的密钥名不留前置图标占位", () => { + const html = renderToStaticMarkup(); + expect(html).toContain("my-client"); + expect(html).not.toContain("aria-hidden"); + }); +}); From bb9ac534e72d011968c81afd4dca47d1bdd32978 Mon Sep 17 00:00:00 2001 From: fylorn <249551762+fylorn@users.noreply.github.com> Date: Mon, 9 Nov 2026 13:28:29 +0800 Subject: [PATCH 2/4] Connect Codex to the hot-reloaded gateway model catalog --- README.md | 4 +- README.zh-CN.md | 2 +- src-tauri/crates/tw-adopt/src/clients.rs | 67 ++++++--- src-tauri/crates/tw-adopt/src/plan.rs | 7 +- src-tauri/crates/tw-adopt/tests/roundtrip.rs | 140 ++++++++++++++++++- src-tauri/src/clients/ops.rs | 8 +- src-tauri/src/clients/ops/tests.rs | 16 +++ 7 files changed, 220 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 557667ad..503e8a85 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,9 @@ before the client runs them. DeepSeek Harness are pointed at the gateway in one step, with the change previewed, the original file backed up and a restore always available; Cursor, Continue and Antigravity CLI come with instructions. Switching - upstreams then happens in the gateway alone. + upstreams then happens in the gateway alone. Codex uses a remote native model + catalog: model and alias changes appear on its next catalog refresh without + rewriting client configuration. Codex may cache the picker list. - **Protection against relays.** A relay sees every request in full and can rewrite every answer. Secrets & privacy swaps API keys, private keys, JWTs, connection-string passwords, Chinese resident ID numbers and bank card numbers diff --git a/README.zh-CN.md b/README.zh-CN.md index 2dc357af..0b951925 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -42,7 +42,7 @@ Claude Code、Codex 等 AI 客户端的本地网关,支持 macOS、Windows 与 ## 要点 -- **一次接入,随时切换。** Claude Code、Claude Desktop、Codex、opencode、Pi、oh-my-pi、Grok Build、Qwen Code、Hermes Agent、Zed、Aider 与 DeepSeek Harness 可一键指向网关,写入前预览改动、备份原文件,随时可以还原;Cursor、Continue 与 Antigravity CLI 提供配置说明。此后切换上游只在网关中完成。 +- **一次接入,随时切换。** Claude Code、Claude Desktop、Codex、opencode、Pi、oh-my-pi、Grok Build、Qwen Code、Hermes Agent、Zed、Aider 与 DeepSeek Harness 可一键指向网关,写入前预览改动、备份原文件,随时可以还原;Cursor、Continue 与 Antigravity CLI 提供配置说明。此后切换上游只在网关中完成。Codex 使用原生远程模型目录,模型和别名变更在下次目录刷新时生效,无需重写客户端配置;模型选择器可能保留客户端缓存。 - **防范中转站。** 中转站能看到请求的全部内容,也能改写每一次回答。「密钥与隐私」在请求发出前把 API 密钥、私钥、JWT、连接串口令、身份证号与银行卡号换成占位符,中转站拿不到原值。回答中若出现下载即执行、外发环境变量或凭据文件、读取私钥、写入开机启动项或定时任务之类的工具调用,「危险命令」会在客户端执行之前切断回答。「内容过滤」在请求发出前删除藏在不可见字符里的指令,可以直接拒绝提示注入,也可以删除或替换请求和模型回答中的指定词语。各项防护出厂处于「监控」状态,只记录并发出通知,逐项开启后生效;每条规则可单独设定动作。 - **上游互相对照。** 每个上游都与服务同一模型的其他上游对照:回答中的模型名与发出的不同、报告的输入明显偏多或偏少、提示缓存读取偏低,都会在上游列表的那一行标出,悬停可见证据与样本数。 - **扫描 MCP、技能与钩子。** 十三款客户端的 MCP 服务器并列显示并标出第三方服务器;客户端配置、技能、钩子与项目指令中的隐藏字符、提示注入、危险命令与过宽权限会被找出。 diff --git a/src-tauri/crates/tw-adopt/src/clients.rs b/src-tauri/crates/tw-adopt/src/clients.rs index 9f4a4298..0c9affdc 100644 --- a/src-tauri/crates/tw-adopt/src/clients.rs +++ b/src-tauri/crates/tw-adopt/src/clients.rs @@ -279,6 +279,8 @@ pub(crate) const NO_KEY: &str = "no-key"; #[derive(Debug, Clone)] pub struct Edit { pub path: Vec, + /// TOML has no null: a null edit removes this field while retaining its + /// original value for restoration. JSON/YAML nulls remain literal values. pub value: Val, /// 这个值是密钥。决定它进不进旁文件、要不要提示权限。 pub secret: bool, @@ -1028,16 +1030,9 @@ pub fn edits(client: &Client, gw: &Gateway) -> Vec { // `POST /v1/responses`,`http_headers` 原样送达, // `experimental_bearer_token` 变成 `Authorization: Bearer`。 // - // **这里曾经有一条「Codex 不从网关取模型列表」的接管代价,删了。** - // 0.139.0 确实一个 GET 都没有,0.153.4 开始会先来一个 - // `GET /v1/models?client_version=…` —— 但它要的是 Codex 自己的目录 - // 格式(顶层 `models`),网关答的是 OpenAI 的 `data` 形状,它解码 - // 失败,只记一行日志。**而这不影响任何人用**:codex 的 - // `models-manager/models.json` 是 `include_str!` 编进二进制的,远端 - // 目录只是补充;模型名在内置表里就没有任何提示,不在就按兜底的 - // 272k 上下文跑。openai/codex 今天的 main 上还加了闸 —— 设了自定义 - // base_url 又没设 `model_catalog_url` 的 provider 直接跳过这次请求。 - // 一条不拦人、还在自己消失的事,不值得占接管对话框的一行。 + // The native remote catalog uses a separate endpoint: /v1/models keeps + // its standard OpenAI shape. Configure discovery once; later model and + // alias changes come from the live gateway, not config rewrites. "codex" => { let p = |k: &str| { vec![ @@ -1062,6 +1057,14 @@ pub fn edits(client: &Client, gw: &Gateway) -> Vec { value: Val::s(gw.v1()), secret: false, }, + Edit { + path: p("model_catalog_url"), + value: Val::s(format!("{}/codex/models", gw.base.trim_end_matches('/'))), + secret: false, + }, + e(&["features", "api_key_model_discovery"], Val::Bool(true)), + e(&["model_catalog_json"], Val::Null), + e(&["model_providers", PROVIDER_ID, "env_key"], Val::Null), // `wire_api = "chat"` 已经被上游移除,只剩 responses Edit { path: p("wire_api"), @@ -1091,15 +1094,16 @@ pub fn edits(client: &Client, gw: &Gateway) -> Vec { secret: false, }, ]; - if let Some(k) = &gw.key { - // 名字带 experimental_,上游可能改。**改了也只是丢掉鉴权, - // 上面那个 http_headers 仍然认得出是谁发的。** - v.push(Edit { - path: p("experimental_bearer_token"), - value: Val::s(k), - secret: true, - }); - } + // API-key discovery needs an API key, even on a gateway that does + // not require authentication. A sentinel avoids falling back to + // the user's OpenAI credentials and enables remote discovery. + v.push(Edit { + path: p("experimental_bearer_token"), + value: Val::s(gw.key.as_deref().unwrap_or(NO_KEY)), + // The field's original value can still be a real credential. + // Keep it out of sidecars even when writing the sentinel. + secret: true, + }); v } // 写 v1 的写法:v1 和 v2 都认。已经有原生那一条的见 [`edits_for`] @@ -1208,6 +1212,31 @@ pub fn edits_for(client: &Client, gw: &Gateway, current: &str) -> Vec { "hermes-agent" => crate::hermes::edits(gw, current), "codex" => { let mut v = edits(client, gw); + // The selected default profile overrides root fields. Keep inactive + // profiles intact and restore these few fields on disconnect. + if let Ok(Some(Val::Str(profile))) = crate::toml::get(current, &["profile"]) { + let p = |field: &str| vec!["profiles".into(), profile.clone(), field.into()]; + v.push(Edit { + path: p("model_provider"), + value: Val::s(PROVIDER_ID), + secret: false, + }); + v.push(Edit { + path: p("model_catalog_json"), + value: Val::Null, + secret: false, + }); + v.push(Edit { + path: vec![ + "profiles".into(), + profile, + "features".into(), + "api_key_model_discovery".into(), + ], + value: Val::Bool(true), + secret: false, + }); + } v.extend(codex_detail_mode(current)); v } diff --git a/src-tauri/crates/tw-adopt/src/plan.rs b/src-tauri/crates/tw-adopt/src/plan.rs index 4d765d14..38064203 100644 --- a/src-tauri/crates/tw-adopt/src/plan.rs +++ b/src-tauri/crates/tw-adopt/src/plan.rs @@ -592,7 +592,12 @@ pub(crate) fn adopt_file( }, }; originals.push(Original::new(p, was)); - carries_secret |= secret; + carries_secret |= *secret && *value != Val::s(crate::clients::NO_KEY); + if fmt == Format::Toml && *value == Val::Null { + text = drop_(fmt, &text, &r, client)?; + targets.push(Target::Remove(p.clone())); + continue; + } // 已经是这个值了就不碰那一段字节:JSON 的数组和对象是重新排出来的, // 重排一遍会换掉原来的排版 —— 重复接管也就不再是空操作 let same = fmt == Format::Json diff --git a/src-tauri/crates/tw-adopt/tests/roundtrip.rs b/src-tauri/crates/tw-adopt/tests/roundtrip.rs index 30175867..11ff386e 100644 --- a/src-tauri/crates/tw-adopt/tests/roundtrip.rs +++ b/src-tauri/crates/tw-adopt/tests/roundtrip.rs @@ -324,7 +324,145 @@ fn adopting_codex_keeps_every_project_trust_and_mcp_server() { assert!(after.contains(r#"wire_api = "responses""#), "{after}"); assert!(after.contains("X-ThinkWatch-Client"), "{after}"); // 实测:不配 env_key 它也照发请求;env_key 指向没 export 的变量反而起不来 - assert!(!after.contains("env_key"), "不该写 env_key:{after}"); + assert_eq!( + tw_adopt::toml::get(&after, &["model_providers", "thinkwatch", "env_key"]).unwrap(), + None + ); +} + +#[test] +fn codex_uses_a_remote_catalog_without_persisting_the_model_list() { + let b = bed("codex", CODEX); + let c = client("codex"); + let p = plan_adopt(&c, &b.home, &gw(), &Around::default()).unwrap(); + apply(&c, &p, &b.backups).unwrap(); + let path = c.config_path(&b.home); + let after = read(&path); + let get = |p: &[&str]| tw_adopt::toml::get(&after, p).unwrap(); + assert_eq!( + get(&["model_providers", "thinkwatch", "model_catalog_url"]), + Some(tw_adopt::json::Val::s("http://127.0.0.1:8080/codex/models")) + ); + assert_eq!( + get(&["features", "api_key_model_discovery"]), + Some(tw_adopt::json::Val::Bool(true)) + ); + assert_eq!(get(&["model"]), Some(tw_adopt::json::Val::s("gpt-5.6-sol"))); + + let mut changed = gw(); + changed.models = vec!["brand-new-model".into()]; + let again = plan_adopt(&c, &b.home, &changed, &Around::default()).unwrap(); + assert!(again.is_noop(), "Model changes must not rewrite config"); + assert!(!after.contains("brand-new-model")); +} + +#[test] +fn codex_local_catalog_and_active_profile_are_reversibly_overridden() { + use tw_adopt::json::Val; + let seed = format!( + r#"profile = "work" +model_provider = "my-provider" +model_catalog_json = "/private/catalog.json" +{CODEX} +[features] +api_key_model_discovery = false +other_feature = true + +[profiles.work] +model_provider = "work-provider" +model_catalog_json = "/private/work-catalog.json" +model_reasoning_effort = "high" +[profiles.work.features] +api_key_model_discovery = false + +[profiles.personal] +model_provider = "personal-provider" +model_catalog_json = "/private/personal-catalog.json" +"# + ); + let b = bed("codex", &seed); + let c = client("codex"); + let path = c.config_path(&b.home); + let p = plan_adopt(&c, &b.home, &gw(), &Around::default()).unwrap(); + apply(&c, &p, &b.backups).unwrap(); + let after = read(&path); + let get = |p: &[&str]| tw_adopt::toml::get(&after, p).unwrap(); + assert_eq!(get(&["model_catalog_json"]), None); + assert_eq!(get(&["profiles", "work", "model_catalog_json"]), None); + assert_eq!( + get(&["profiles", "work", "model_provider"]), + Some(Val::s("thinkwatch")) + ); + assert_eq!( + get(&["profiles", "work", "features", "api_key_model_discovery"]), + Some(Val::Bool(true)) + ); + assert_eq!( + get(&["profiles", "work", "model_reasoning_effort"]), + Some(Val::s("high")) + ); + assert_eq!( + get(&["profiles", "personal", "model_catalog_json"]), + Some(Val::s("/private/personal-catalog.json")) + ); + let again = plan_adopt(&c, &b.home, &gw(), &Around::default()).unwrap(); + assert!(again.is_noop()); + apply(&c, &again, &b.backups).unwrap(); + let r = plan_restore(&c, &b.home).unwrap(); + apply_restore(&c, &r, &b.backups).unwrap(); + assert_eq!( + tw_adopt::toml::value(&read(&path)).unwrap().normalized(), + tw_adopt::toml::value(&restored_codex(&seed)) + .unwrap() + .normalized() + ); +} + +#[test] +fn codex_without_a_gateway_key_uses_a_non_secret_discovery_sentinel() { + let seed = format!( + "{CODEX}\n[model_providers.thinkwatch]\nenv_key = \"UNSET_ORIGINAL_PROVIDER_KEY\"\nexperimental_bearer_token = \"original-provider-credential\"\n" + ); + let b = bed("codex", &seed); + let c = client("codex"); + let mut gateway = gw(); + gateway.key = None; + let p = plan_adopt(&c, &b.home, &gateway, &Around::default()).unwrap(); + assert!(!p.carries_secret); + apply(&c, &p, &b.backups).unwrap(); + let sidecar = tw_adopt::sentinel::sidecar_path(&c.config_path(&b.home)); + assert!(!read(&sidecar).contains("original-provider-credential")); + assert_eq!( + tw_adopt::toml::get( + &read(&c.config_path(&b.home)), + &["model_providers", "thinkwatch", "env_key"] + ) + .unwrap(), + None + ); + assert_eq!( + tw_adopt::toml::get( + &read(&c.config_path(&b.home)), + &["model_providers", "thinkwatch", "experimental_bearer_token"] + ) + .unwrap(), + Some(tw_adopt::json::Val::s("no-key")) + ); + let r = plan_restore(&c, &b.home).unwrap(); + apply_restore(&c, &r, &b.backups).unwrap(); + let restored = read(&c.config_path(&b.home)); + assert_eq!( + tw_adopt::toml::get(&restored, &["model_providers", "thinkwatch", "env_key"]).unwrap(), + Some(tw_adopt::json::Val::s("UNSET_ORIGINAL_PROVIDER_KEY")) + ); + assert_eq!( + tw_adopt::toml::get( + &restored, + &["model_providers", "thinkwatch", "experimental_bearer_token"] + ) + .unwrap(), + Some(tw_adopt::json::Val::s("original-provider-credential")) + ); } #[test] diff --git a/src-tauri/src/clients/ops.rs b/src-tauri/src/clients/ops.rs index cc28dbe3..49d4cb87 100644 --- a/src-tauri/src/clients/ops.rs +++ b/src-tauri/src/clients/ops.rs @@ -240,7 +240,13 @@ fn setup_of(c: &Client, steps: Vec, gw: &clients::Gateway) -> wire::ManualS fields: clients::edits(c, gw) .iter() .chain(&clients::also_edits(c, gw)) - .map(|e| field(wire::FieldOp::Set, &e.path, Some(&e.value), e.secret)) + .map(|e| { + if c.format == clients::Format::Toml && e.value == tw_adopt::json::Val::Null { + field(wire::FieldOp::Remove, &e.path, None, e.secret) + } else { + field(wire::FieldOp::Set, &e.path, Some(&e.value), e.secret) + } + }) .collect(), endpoint: c.endpoint(gw), } diff --git a/src-tauri/src/clients/ops/tests.rs b/src-tauri/src/clients/ops/tests.rs index afde4401..fe16bed7 100644 --- a/src-tauri/src/clients/ops/tests.rs +++ b/src-tauri/src/clients/ops/tests.rs @@ -92,6 +92,22 @@ fn every_client_says_how_to_connect_it_by_hand_without_the_key() { ); let json = serde_json::to_string(&r).unwrap(); assert!(!json.contains("tw-d"), "{json}"); + let codex = r.clients.iter().find(|c| c.id == "codex").unwrap(); + let local = codex + .manual + .fields + .iter() + .find(|f| f.path == "model_catalog_json") + .unwrap(); + assert!(matches!(local.op, wire::FieldOp::Remove)); + assert!(local.value.is_none()); + assert!( + codex + .manual + .fields + .iter() + .any(|f| f.path == "model_providers.thinkwatch.model_catalog_url") + ); } #[test] From c14a3bd9881fe0d92e34b0cd8b4eb7216d6144e5 Mon Sep 17 00:00:00 2001 From: fylorn <249551762+fylorn@users.noreply.github.com> Date: Mon, 9 Nov 2026 21:08:22 +0800 Subject: [PATCH 3/4] chore(release): prepare Lite 2026.11.7 catalog integration --- package.json | 2 +- release-notes/2026.11.7.md | 7 +++++++ scripts/shots/core/en/status.json | 2 +- scripts/shots/core/zh/status.json | 2 +- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 2 +- src/i18n/core.zh.json | 2 ++ 8 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 release-notes/2026.11.7.md diff --git a/package.json b/package.json index 72f1b807..b18a4cc8 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.6", + "version": "2026.11.7", "type": "module", "packageManager": "pnpm@11.13.0", "scripts": { diff --git a/release-notes/2026.11.7.md b/release-notes/2026.11.7.md new file mode 100644 index 00000000..e63f49dc --- /dev/null +++ b/release-notes/2026.11.7.md @@ -0,0 +1,7 @@ +Codex can now discover gateway models through a remote native catalog. Connect or reconnect Codex through Clients after upgrading, then restart Codex once to load the new connection settings. Subsequent model, alias and permission changes use the gateway's existing hot reload path and appear on the next catalog refresh without rewriting client configuration. + +Discovery uses gateway authentication and model permissions. Native upstream instructions and tools are preserved when available; ordinary upstreams use a conservative coding profile. The standard OpenAI models endpoint keeps its existing response shape. Codex can cache its picker list, so an already open client may need to refresh its catalog or restart before showing changes. + +Codex adoption configures discovery while preserving inactive profiles and restoring overridden fields when disconnected. Existing credentials are not copied into sidecar metadata. Manual setup instructions correctly show fields that need removing. + +This release bundles Core 0.90.0, including the native catalog and an update to patched bundled SQLite for RUSTSEC-2026-0459. The control-plane protocol remains 58 and the request-store schema remains 28. Existing settings, upstreams, request history and usage history are preserved. diff --git a/scripts/shots/core/en/status.json b/scripts/shots/core/en/status.json index dd3c8c2a..bfacdc96 100644 --- a/scripts/shots/core/en/status.json +++ b/scripts/shots/core/en/status.json @@ -16,5 +16,5 @@ "reachable": [] }, "uptime_secs": 0, - "version": "0.89.2" + "version": "0.90.0" } diff --git a/scripts/shots/core/zh/status.json b/scripts/shots/core/zh/status.json index dd3c8c2a..bfacdc96 100644 --- a/scripts/shots/core/zh/status.json +++ b/scripts/shots/core/zh/status.json @@ -16,5 +16,5 @@ "reachable": [] }, "uptime_secs": 0, - "version": "0.89.2" + "version": "0.90.0" } diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 38ddf42f..e05edf5e 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -4950,7 +4950,7 @@ dependencies = [ [[package]] name = "thinkwatch-lite" -version = "2026.11.6" +version = "2026.11.7" dependencies = [ "anyhow", "base64 0.22.1", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index a7013b88..1cd04300 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thinkwatch-lite" -version = "2026.11.6" +version = "2026.11.7" edition = "2024" # **这个数决定依赖能升到哪一版。**edition 2024 的解析器只挑声明的 Rust # 版本编得动的依赖:写 1.85 的时候,`cargo update` 一直停在旧的 time 和 diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 2636eb28..d66a02be 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.6", + "version": "2026.11.7", "identifier": "app.thinkwatch.lite", "build": { "beforeDevCommand": "pnpm dev", diff --git a/src/i18n/core.zh.json b/src/i18n/core.zh.json index 1241b88c..26e33ca3 100644 --- a/src/i18n/core.zh.json +++ b/src/i18n/core.zh.json @@ -399,6 +399,8 @@ "gw.chatgpt.token_status": "令牌端点返回 {status}:{body}", "gw.chatgpt.token_not_json": "令牌端点的响应不是 JSON。", "gw.chatgpt.token_missing": "令牌端点的响应中没有 {field}。", + "gw.codex_catalog.client_version": "Codex 模型目录需要且只能指定一个 major.minor.patch 格式的 client_version。", + "gw.codex_catalog.too_large": "Codex 模型目录超过 1 MiB,请减少此网关密钥可用的模型。", "// ── gw.models / gw.probe:获取模型清单、检查上游 ───────────────────": "", "gw.models.check_failed": "检查未通过。", "gw.models.no_endpoint": "上游没有提供模型清单的接口(HTTP {status})。", From ad1db86c96f58a10af1d912811325a4e64f8e698 Mon Sep 17 00:00:00 2001 From: fylorn <249551762+fylorn@users.noreply.github.com> Date: Mon, 9 Nov 2026 21:36:54 +0800 Subject: [PATCH 4/4] chore(core): pin the native catalog release to v0.90.0 --- src-tauri/Cargo.lock | 28 ++++++++++++++-------------- src-tauri/Cargo.toml | 12 ++++++------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index e05edf5e..16d3c88d 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -5458,8 +5458,8 @@ dependencies = [ [[package]] name = "tw-api" -version = "0.89.2" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" +version = "0.90.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.90.0#d84fb38d3aae204ad3e256071596a62a2d543d1a" dependencies = [ "serde", "serde_json", @@ -5470,8 +5470,8 @@ dependencies = [ [[package]] name = "tw-dialect" -version = "0.89.2" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" +version = "0.90.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.90.0#d84fb38d3aae204ad3e256071596a62a2d543d1a" dependencies = [ "memchr", "serde", @@ -5480,8 +5480,8 @@ dependencies = [ [[package]] name = "tw-guard" -version = "0.89.2" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" +version = "0.90.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.90.0#d84fb38d3aae204ad3e256071596a62a2d543d1a" dependencies = [ "aho-corasick", "base64 0.22.1", @@ -5502,8 +5502,8 @@ dependencies = [ [[package]] name = "tw-link" -version = "0.89.2" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" +version = "0.90.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.90.0#d84fb38d3aae204ad3e256071596a62a2d543d1a" dependencies = [ "serde", "serde_json", @@ -5529,8 +5529,8 @@ dependencies = [ [[package]] name = "tw-types" -version = "0.89.2" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" +version = "0.90.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.90.0#d84fb38d3aae204ad3e256071596a62a2d543d1a" dependencies = [ "serde", "ts-rs", @@ -5538,8 +5538,8 @@ dependencies = [ [[package]] name = "tw-watch" -version = "0.89.2" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" +version = "0.90.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.90.0#d84fb38d3aae204ad3e256071596a62a2d543d1a" dependencies = [ "libc", "notify", @@ -5549,8 +5549,8 @@ dependencies = [ [[package]] name = "tw-yaml" -version = "0.89.2" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" +version = "0.90.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.90.0#d84fb38d3aae204ad3e256071596a62a2d543d1a" dependencies = [ "saphyr-parser", "thiserror 2.0.21", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 1cd04300..9520e946 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -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.89.2" } -tw-types = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.2" } -tw-yaml = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.2" } -tw-guard = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.2" } -tw-watch = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.2" } -tw-link = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.2" } +tw-api = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.90.0" } +tw-types = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.90.0" } +tw-yaml = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.90.0" } +tw-guard = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.90.0" } +tw-watch = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.90.0" } +tw-link = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.90.0" } [lib] name = "thinkwatch_lite_lib"
- {sizer("status")} - - {sizer("time")} - - {sizer("latency")} - - {sizer("tokens")} - - {sizer("cost")} - + {sizer(col)} +