Repository navigation
feat(api): slugs for every closed set, and core's text in a written register - #35
Merged
Merged
Conversation
The desktop app decided behaviour by comparing the Chinese text core sent: `GroupView.kind == "手动选"` and `"轮流"` in four places plus the tray menu, a table mapping 按顺序 back to `fallback`, `StorageStatus.level !== "正常"` and `AttemptView.outcome === "成功"`. Rewording any of those in core broke the app with no compile error, and the wording is exactly what the app is now rewriting into a formal register. A field whose value comes from a fixed set core defines now carries an identifier, as `trust` and `billing` already did, and the app maps it to its own label: - `GroupView.kind`, `DryRunResult.strategy`: the config word (`fallback` / `select` / `load-balance` / `url-test` / `cheapest`) - `StorageStatus.level`: `ok` / `metadata_only` / `stopped` / `unavailable` - `ConfigReloaded.origin`, `ConfigVersion.origin`: `ui` / `cli` / `external` / `rollback` / `rotation` - `ConfigRejected.stage`: `syntax` / `schema` / `semantics` - `LocallyAnswered.probe`: the probe id - `QuotaWindow.label` becomes `window`: `5h` / `7d` / `weekly` - `AttemptView.outcome`: `served` / `status` / `error`, with `status` and `error` beside it - `LeakSeen.secret`, `LeakGroup.secret` (was `kind`) and `RedactedItem.secret` (was `what`): the secret type, such as `anthropic-api-key` - `L1Segment` carries a `stage` (`step` + `peer`); `L1Result.notes` becomes `skipped` with a reason, and `failed` names the stage an error happened at - `AdoptResponse.takes_effect_note` becomes `takes_effect` Labels that only restated a slug next to them are gone: `ProbeView.label` / `what`, `DriftView.label`, `ScanFinding.kind_label`, `DetectedClient.takes_effect_note` / `verified_note`, `SpeedEstimate.note`, `ReplayQuote.note`. The scan rule summary (`rules_origin`) becomes `rules_active` / `rules_custom` / `rules_disabled`. Lists that mixed fixed labels into data are structured: `RuleView.to` is optional with a `deny` flag instead of 拒绝 or (只改参数), and `RuleView.conditions`, `DryRunResult.set`, `RuleTrace.mismatch` and `PlanView.fields` carry keys and values instead of sentences such as 带缓存 or 删掉 env.X. `Translated.dropped` lists the dropped fields by position. `SecretView.display` no longer prefixes 环境变量. `ManualClient.how` now contains the gateway address. The app replaced a 网关地址 placeholder that core never sent, so the steps said 填我们的地址. Sentences that carry runtime detail (errors, hints, diagnosis findings) stay in core; the CLI and the diagnostics bundle keep their own labels. The workspace goes to 0.4.0 for the app to pin. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The desktop app now follows a written register: statements rather than asides or questions, no first or second person, 费用 for amounts, and no explanations of internal mechanics. Much of what it displays is written here, and read like someone talking: 连不上上游。检查 base_url…, 密钥要你自己在 Zed 的界面里填一次 —— 我们够不着, 补丁自检没过 … 这是个 bug, 请把配置文件贴到 issue 里. The same sentences reach AI clients as gateway errors and people reading the CLI, the logs and the diagnostics bundle. Rewritten: control-plane and gateway errors, configuration validation, link test results, client adoption notes and diagnosis findings, scan findings and the built-in rule reasons, the diagnostics bundle, the notes written into adopted client configs, twcore's output and help text, and logs. Terms follow the app: 上游, 接口地址, 网关密钥, 请求记录, 非官方端点, 按量计费. Names are quoted as 「name」 instead of in backticks, which the UI shows literally. Errors carry no trailing 。, so the UI can place them in a sentence. The adoption file formats stay as they are: the comment block markers and the Chinese keys of `*.thinkwatch.json` are read back on restore, so changing them would strand clients adopted by an earlier version. Only the prose inside them changed. `bin/twcore/tests/copy.rs` reads the string literals in product code and the rule reasons in `rules.yaml`, and fails on the spoken forms the app's `copy.test.ts` rejects plus the ones removed here. The app's test only sees its own `.tsx` files, so without this nothing checks what core sends. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Thanks for the PR. One thing before review: this targets
No need to close and reopen: click Edit next to the PR title and change the base branch to See CONTRIBUTING.md and CONTRIBUTING.md for the branch contract. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Two things, one commit each:
trustandbillingalready worked. Lists that mixed fixed labels into data (rule conditions, dry-run rewrites, plan fields, link test segments) carry keys and values instead of sentences. Sentences with runtime detail (errors, hints, diagnosis findings) stay in core.The workspace goes to 0.4.0. The protocol changes are breaking.
Why
ThinkWatch Lite rewrote its UI copy in a formal register (ThinkWatchProject/ThinkWatch-Lite#36): statements rather than asides or questions, no first or second person, 费用 for amounts, and no explanations of internal mechanics. Several strings it shows verbatim come from core. Some of them it also uses to decide behaviour:
GroupView.kind == "手动选"/"轮流"inConfig.tsx(three places) and in the tray menu (src-tauri/src/lib.rs), plus a{ 按顺序: "fallback", … }table mapping the label back to the config wordStorageStatus.level !== "正常"inDashboard.tsxAttemptView.outcome === "成功"inRequestDrawer.tsxManualClient.how.replace("网关地址", gateway_base)inClients.tsx. Core never sent that placeholder, so users read 填我们的地址.Rewording any of these in core would have broken the app without a compile error. Rewriting the Chinese in place would keep that coupling, so fixed sets become identifiers instead.
Protocol changes
Slugs instead of labels
GroupView.kind,DryRunResult.strategyfallback/select/load-balance/url-test/cheapestStorageStatus.levelok/metadata_only/stopped/unavailableConfigReloaded.origin,ConfigVersion.originui/cli/external/rollback/rotationConfigRejected.stagesyntax/schema/semanticsLocallyAnswered.probehealth_check…), same asProbeView.idQuotaWindow.label→window5h/7d/weeklyAttemptView.outcomeserved/status/error, with newstatus: Option<u16>anderror: Option<String>LeakSeen.secret,LeakGroup.kind→secret,RedactedItem.what→secretAdoptResponse.takes_effect_note→takes_effectimmediately/on_restartRemoved because they restated a slug next to them:
ProbeView.label/what,DriftView.label(usemetric),ScanFinding.kind_label(usekind),DetectedClient.takes_effect_note/verified_note,SpeedEstimate.noteandReplayQuote.note(usebilling,cost_microsand the token count).ScanResponse.rules_originbecomesrules_active/rules_custom/rules_disabled.Structured instead of sentences
RuleView.toto: Option<String>plusdeny: boolRuleView.conditions[{ field: "model", values: ["claude-*"] }, { field: "cache", values: ["true"] }]DryRunResult.set[{ field: "model", value: "x" }]RuleTrace.whymismatch: { field, want: [..], got }orerrorfor a condition that cannot be evaluatedDryRunResult.reasonno_matchandunavailabledenyrule (unavailableis explained byskipped)PlanView.fields[{ op: "set" | "remove", path, value? }], novaluefor the gateway keyL1Segment.namestage: { step: "config" | "dns" | "tcp" | "tls" | "handshake", peer: "upstream" | "proxy" }L1Result.notesskipped: [{ stage, reason: "plain_http" | "ip_address" | "proxy_resolves" }]L1Result.errorfailed: Option<L1Stage>says whereL1Result.targetfor/proxies/testhkTranslated.droppedthinking,top_k,messages.content.thinking…SecretView.display${KEY}(masked otherwise, as before)ManualClient.howSecret types:
anthropic-api-key,openai-api-key,openai-project-key,github-personal-token,github-oauth-token,github-server-token,github-user-token,github-fine-grained-token,slack-bot-token,slack-user-token,slack-app-token,aws-access-key-id,aws-temporary-key-id,google-api-key,google-oauth-token,gitlab-token,stripe-live-key,stripe-restricted-key,npm-token,digitalocean-token,sendgrid-key,private-key,jwt,conn-string-password,internal-ip,internal-domain.Rows already stored keep the old text:
routingJSON in request history has Chinese outcomes, andleaks.kindholds the old names. No migration; the app should show an unknown value as it is.Follow-up in ThinkWatch Lite
After this is released as
v0.4.0, bump thetw-apitag insrc-tauri/Cargo.tomland the bundled binary, then:Config.tsxand useg.kinddirectly. Compare with"select"and"load-balance"inConfig.tsxand in the tray group menu (src-tauri/src/lib.rs). Show labels from one table, also used forDryRunResult.strategyinDryRun.tsx.Dashboard.tsxcheckslevel !== "ok"and labels the three other values. The existing 转发不受影响 suffix stays.RequestDrawer.tsxcolours byoutcome === "served"and showsstatusorerror.ConfigRejected.stage(App.tsx, where 错误 is appended today),ConfigVersion.origin(ConfigDialogs.tsx),QuotaWindow.window(UpstreamTable.tsx), probe names and descriptions by id (Config.tsx),LeakGroup.secret(Dashboard.tsx),RedactedItem.secret(App.tsxtooltip),DriftView.metric(Security.tsx),takes_effect/verified(Clients.tsx).Security.tsx), the replay quote frombilling/cost_micros/input_tokens(RequestDrawer.tsx), and the dry-run text forno_matchandunavailable(DryRun.tsx).Routes.tsx), dry-run rewrites and mismatches (DryRun.tsx), plan fields (Clients.tsx), and link test segments, skipped steps andfailed(upstreams/TestDialogs.tsx,ProxyDialog.tsx,ProxyTable.tsx).how.replace("网关地址", …)inClients.tsx.types.tsmirrors all of the above.copy.test.tsdoes not see strings core sends at runtime; this PR adds the matching check on the core side (below).How it was verified
cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings: clean.cargo test --workspace: 1284 passed, 0 failed, 2 ignored (the real-network L1 tests, updated for the new stage fields).scripts/smoke.sh: 48 passed, 0 failed. It warns that memory is 33 MB against the 30 MB target, which the script counts as within its no-regression limit of 40 MB.bin/twcore/tests/copy.rsreads every string literal in product code (comments and test modules excluded) and the rule reasons incrates/tw-scan/data/rules.yaml. It fails on the spoken forms Lite'scopy.test.tsrejects, first and second person, and the forms removed here. Adding a scratch file with"连不上上游,你看看"made it fail on 连不上, 你 and 看看.GroupType::slug()to the word serde reads from the config, and assert that eachConditionView.fieldis a key ofWhen.served/status503 / 429),LocallyAnswered.probe == "health_check"andConfigRejected.stage == "schema".Nothing here touches forwarding, redaction, masking or credential handling beyond renaming what a redaction hit is called. Masking of keys in plan fields and diffs is unchanged: key fields carry no
value.Notes for review
=== ThinkWatch 接管开始 ===markers and the Chinese keys of*.thinkwatch.json(怎么手动还原, 文件是我们建的 …) are read back on restore. Changing them would strand clients adopted by an earlier version. Only the prose inside changed, and the copy test lists those two keys as format.ext.primary→weekly,secondary→5h) keeps the existing labels as they were.CONTROL_API_VERSIONstays 1, as with earlier breaking changes: the app pins core by tag and bundles the binary from the same release.main, as with the recent PRs, although CONTRIBUTING and the base guard still point todev.🤖 Generated with Claude Code