Repository navigation
feat(gateway): the gateway speaks English, and its errors carry a code - #54
Merged
Merged
Conversation
Everything the gateway said about a failure was Chinese: the body a Claude Code or Codex session prints when a request is refused, and the `RequestFailed` event the desktop app renders in its traffic table. Neither audience is reliably Chinese-reading, and the app has to say it in whichever of its two languages is in use. `GatewayError` carries a `Msg` instead of a `String`, and so does `Event::RequestFailed`. The sentence that reaches an AI client is `detail.text`, in English, behind the `[ThinkWatch]` prefix it always had; the app reads `detail.code` and says it in its own words. About fifty messages carry a code now, from `gw.auth.key_disabled` to `gw.toolcall.cut`. Two of them stopped being strings in a more useful way: - The failover chain used to be pasted onto the end of the message (`"…(已尝试:a → b)"`). It is `with_attempts`, which leaves the code alone and puts the chain in `args`, so an app can put it where its own sentence wants it. - A stream that breaks mid-flight keeps the code of whatever broke it and only prefixes the English text, instead of becoming a new, codeless "响应流中断:…". The rest of the crate is English too: the `thiserror` messages in `access`, `limits` and `oauth`; the ChatGPT sign-in and token paths; the probe and inference-test results; the tool wall's "(unnamed)" and "(response text)"; the fixture replay's field names; every `tracing` line and every `expect`. `crates/tw-gateway/src` no longer contains a Chinese string literal. `tw-store` writes `message.text` to the history row, so a row's `error` column is English now — the app renders a row from the event, not from that column. Tests that read a message read a code where one exists (`assert_eq!(e.detail.code, "gw.config.proxy_undefined")`), which is shorter and no longer breaks when a sentence is reworded. The no-key test also checks the key never reaches `args`, not only the text. Still Chinese, and not in this change: everything outside `tw-gateway` — `tw-control`, `tw-adopt`, `tw-config`, `tw-scan`, `tw-engine` and the `twcore` CLI. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Sep 20, 2026
Merged
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.
Everything the gateway said about a failure was Chinese: the body a Claude Code
or Codex session prints when a request is refused, and the
RequestFailedeventthe desktop app renders in its traffic table. Neither audience is reliably
Chinese-reading, and the app has to say it in whichever of its two languages is
in use.
GatewayErrorcarries aMsginstead of aString, and so doesEvent::RequestFailed. The sentence that reaches an AI client isdetail.text,in English, behind the
[ThinkWatch]prefix it always had; the app readsdetail.codeand says it in its own words. About fifty messages carry a codenow, from
gw.auth.key_disabledtogw.toolcall.cut.Two that stopped being strings in a more useful way
The failover chain used to be pasted onto the end of the message:
It is
with_attemptsnow, which leaves the code alone and puts the chain inargs, so an app can put it where its own sentence wants it.A stream that breaks mid-flight keeps the code of whatever broke it and only
prefixes the English text, instead of becoming a new, codeless
"响应流中断:…".The rest of the crate
English too: the
thiserrormessages inaccess,limitsandoauth; theChatGPT sign-in and token paths; the probe and inference-test results; the tool
wall's
(unnamed)and(response text); the fixture replay's field names;every
tracingline and everyexpect.crates/tw-gateway/srcno longercontains a Chinese string literal.
tw-storewritesmessage.textto the history row, so a row'serrorcolumnis English now — the app renders a row from the event, not from that column.
Tests
Tests that read a message read a code where one exists
(
assert_eq!(e.detail.code, "gw.config.proxy_undefined")), which is shorter andno longer breaks when a sentence is reworded. The no-key test also checks the
key never reaches
args, not only the text.Still Chinese
Everything outside
tw-gateway:tw-control,tw-adopt,tw-config,tw-scan,tw-engineand thetwcoreCLI.Verified
cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace(78 suites, 0 failures) and./scripts/smoke.sh(51 passed, 0 failed). The smoke script's check that a cutrequest is recorded with its usage reads the English text now.
🤖 Generated with Claude Code