Skip to content

fix(i18n): drop the retired "shown once" claim from the generate-key toast - #320

Merged
argszero merged 1 commit into
mainfrom
fix/ak-gen-toast-retired-once-only-claim
Sep 28, 2026
Merged

argszero merged 1 commit into
mainfrom
fix/ak-gen-toast-retired-once-only-claim

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

Generating an API key in Settings toasts a claim the product retired in v1.22.1:

已生成新 API Key「{name}」(完整 key 已展示,仅此一次)
New API Key “{name}” generated (full key shown once)

Both sentences were true when they were written (68f9f70, #86, v1.21): the list endpoint returned
only a masked key, the full value came back from POST /api/api-keys and was kept in a session-only
Live.fullKeys cache that a refresh dropped. #95 (799c18d, v1.22.1) closed that state — its own
message records "removed the Live.fullKeys session cache and the 'shown once' logic":

  • GET /api/api-keys now returns the owner-visible full_key next to the masked key
    (src/dao.rs; pinned by routes::tests → "撤销前列表返回属主完整 key")
  • copyKey() copies k.full_key straight from the list data, with the masked key only as a
    fallback — so the full key is retrievable at any time, including after a reload
  • ui/README.md documents it as designed behaviour: 「一键复制完整 key……列表脱敏展示
    atk_live_****xxxx,复制为完整值」

#95 removed that logic and one of its carriers (settings.ak.copy.once, zh/en). This one stayed
behind, and so did a comment in the same function — while the code three lines below copyKey()
still states the policy the string violates:

// 防御性兜底:full_key 缺失时退化为复制脱敏 key,绝不提示「仅生成时展示一次」

So the settings page tells the user to treat the key as unrecoverable while the list keeps a button
that recovers it. The wording is the only thing wrong: the mask-and-copy behaviour is fine and is left
alone.

Changes

  • ui/js/i18n.js — settings.ak.gen.ok in both packs, value only:
    • zh: 已生成新 API Key「{name}」(完整 key 可在列表中随时复制)
    • en: New API Key “{name}” generated (full key can be copied from the list anytime)
  • ui/js/app.js — the sibling comment that repeated the same retired fact
    (「完整 key 仅生成时可得」) now names the mechanism instead (full_key ships with the row).
  • ui/index.html — cache-bust tokens for the two changed assets (i18n.js, app.js → 20260928-1).

No key is added or removed (688 keys before and after; the {name} slot is kept in both packs), no
backend change, no behaviour change. The declared-unreachable settings.ak.gen.ok.mock is left exactly
as it is — it is registered in UNREACHABLE_PACK_KEYS as old-design, and that axis is closed.

No gate. The value restates a retired fact rather than encoding an invariant, and the repository's
standing decision on that axis is to fix the data and not to guard the prose (precedents: #309, #310,
#312–#315).

Related Issue

Tests

  • cargo test — 417 passed / 0 failed (the run at the parent commit is the same 417; the
    change touches no tested byte but ui/js/i18n.js is read by the i18n gates, so the count
    matters)
  • cargo fmt --check — clean
  • cargo clippy --all-targets -- -D warnings — clean
  • A/B verification script (tmp/r110/verify.py, run against the tree under test via git -C):
    on the pre-fix tree 8 legs are red — both pack values, "no shipped string value carries the
    fact" (2 of 1701), "every surviving site is a comment line", and the three cache-bust legs —
    on this branch all legs are green. The four legs that assert the behaviour the new sentence
    describes (list returns full_key, copyKey consumes it, the list is reloaded after generating,
    the Rust test pinning it) pass on both trees, which is the point: only the wording moved.

Checklist

  • 分支命名符合约定(fix/)
  • Commit message 使用 Conventional Commits 格式
  • 单一职责,改动最小化

…toast

`settings.ak.gen.ok` (both packs) told the user the full API key is shown
"仅此一次" / "once". That sentence was true when it was written (#86, v1.21) and
stopped being true in v1.22.1 (#95): `GET /api/api-keys` now returns the
owner-visible `full_key` next to the masked `key` (`src/dao.rs`, pinned by
`routes::tests`), `copyKey()` copies it straight from the list data, and the
`Live.fullKeys` session cache is gone -- which is why #95's own message records
"removed ... the 'shown once' logic" and deletes the sibling string
`settings.ak.copy.once`.

#95 removed the logic and one carrier and left this one restating the retired
fact. The comment three lines below `copyKey()` still states the policy the
string violates: 「绝不提示「仅生成时展示一次」」.

Value-only fix; no key added or removed:

- zh: 已生成新 API Key「{name}」(完整 key 可在列表中随时复制)
- en: New API Key “{name}” generated (full key can be copied from the list anytime)

The sibling comment that repeated the same retired fact ("完整 key 仅生成时可得")
now names the mechanism, and `ui/index.html` bumps the two changed cache-bust
tokens.

No behaviour change: the list keeps showing the backend-masked value, the copy
button keeps handing out `full_key`, and the `{name}` slot is kept in both
packs. Key counts are untouched (688 keys before and after), so the i18n gates
still pass unchanged.
@argszero

Copy link
Copy Markdown
Owner Author

Self-review (committer; allow_self_merge: true is configured for this task).

Scope — 3 files, +7/−5, no production logic touched: two i18n string values (zh + en), one comment in ui/js/app.js, and the two ?v= cache-bust tokens for exactly the two changed .js files.

What the change is — settings.ak.gen.ok claimed "full key shown once" / 「仅此一次」. That fact was retired in 799c18d (#95, v1.22.1), which made the full key copyable at any time from the API-key list. The claim and the product have contradicted each other since. The toast now states the behaviour the code actually has.

Verification

  • cargo test on the branch: 417/0; cargo fmt --check rc=0; cargo clippy --all-targets -- -D warnings rc=0.
  • CI on this PR: msrv pass (26s), test / fmt / clippy pass (2m17s).
  • Repo-internal evidence harness (A/B): an independently materialised tree at the base commit fails the check (the shipped string still carries the retired fact), while the worktree passes all checks.

Blast radius — settings.ak.gen.ok.mock is untouched and remains in the src/i18n_pack.rs sunset list. No new i18n keys are added, so the pack counters (ZH/EN_KEY_COUNT, T_LITERAL_*, STATIC_ATTR_*) are unchanged. ui/index.html carries only the two cache-bust bumps.

No outstanding review feedback; merging.

@argszero
argszero merged commit 1211439 into main Sep 28, 2026
2 checks passed
@argszero
argszero deleted the fix/ak-gen-toast-retired-once-only-claim branch September 28, 2026 04:51
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