Skip to content

feat(store): a failure keeps its code, so history reads in either language - #58

Merged
fylorn merged 1 commit into
mainfrom
i18n/history-error
Sep 20, 2026
Merged

fylorn merged 1 commit into
mainfrom
i18n/history-error

Conversation

@fylorn

@fylorn fylorn commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

A failed request's reason reached the app twice: live, as a RequestFailed
event, and again from /history after a reload. The event carried a code from
the start of this work; the row did not — the error column held only the
sentence, so every failure in the traffic table turned back into English the
moment the window was reopened
.

The row carries the code now. Two nullable columns beside the existing one
(error_code, error_args), and RequestRow.error / HistoryRow.error are a
Msg assembled from the three.

A row written before this has no code, so it comes back with an empty one —
which the app does not recognize, so it shows the text, the same fallback it
uses for a code newer than itself. Nothing is migrated and nothing is lost; the
migration test drops the two columns and checks the old rows survive.

Msg::plain builds one of those codeless messages. It is the fallback, not the
usual way: new messages come from msg!.

Also here: the scan rule set

The why of every built-in rule is the sentence the Findings page prints under
each finding, and it was Chinese. Six rules also had Chinese ids:

was is
忽略指令 ignore-previous-zh
新指令 new-instructions-zh
你现在是 you-are-now-zh
凭据外泄 exfil-credentials
凭据外泄2 exfil-credentials-reversed
写启动项 write-startup-item

An override file in ~/.thinkwatch/scan-rules.yaml that disables one of these
by its old id will report that the id is unknown. The patterns themselves are
untouched — they still match Chinese injections, which is the point of having
them.

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 reads a cut
request back out of /history, so it covers the new columns end to end.

🤖 Generated with Claude Code

…guage

A failed request's reason reached the app twice: live, as a
`RequestFailed` event, and again from `/history` after a reload. The
event carried a code from the start of this work; the row did not — the
`error` column held only the sentence, so every failure in the traffic
table turned back into English the moment the window was reopened.

The row carries the code now. Two nullable columns beside the existing
one (`error_code`, `error_args`), and `RequestRow.error` and
`HistoryRow.error` are a `Msg` assembled from the three. A row written
before this has no code, so it comes back with an empty one — which the
app does not recognize, so it shows the text, the same fallback it uses
for a code newer than itself. Nothing is migrated and nothing is lost.

`Msg::plain` builds one of those codeless messages. It is the fallback,
not the usual way: new messages come from `msg!`.

Separately, `tw-scan`'s rule set is English. The `why` of every built-in
rule is the sentence the Findings page prints under each finding, and
six rules had Chinese ids — `忽略指令` is now `ignore-previous-zh`,
`凭据外泄` is `exfil-credentials`, and so on. An override file that
disables a built-in rule by its old Chinese id will report that the id
is unknown.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fylorn
fylorn merged commit f085119 into main Sep 20, 2026
1 check passed
@fylorn
fylorn deleted the i18n/history-error branch September 20, 2026 07:47
@fylorn fylorn mentioned this pull request Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant