Skip to content

fix(ui): remove the dead plan-note hint from the listing form - #177

Merged
argszero merged 1 commit into
mainfrom
fix/share-plan-hint-dead-note
Sep 12, 2026
Merged

argszero merged 1 commit into
mainfrom
fix/share-plan-hint-dead-note

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

showPlanHint() on the listing (上架) form appended a · {note} suffix describing the selected plan's endpoint conventions. That suffix can never render: the plan source it reads — Live.plans, i.e. GET /api/plans — has no note field. src/config.rs's Plan struct does not declare one, and [[plans]] in config.example.toml has never declared one (git log -S note -- config/config.example.toml is empty across all history).

So in the only reachable state, pl.note is always undefined, (pl.note ? … : "") always takes the empty branch, and the hint silently shows only the paygo/subscription text. This removes the dead read and the now-unused share.plan.note key, so the code, the language packs and ui/README.md stop promising a hint that cannot appear.

The read became dead in a2e40f2 ("fix(integration): 3 browser-found bugs — plans data source …"), which switched the plan source from the data.js fallback to GET /api/plans (Live.plans || D.PLANS) without carrying note across. 44a3040 later removed the sibling UI-only field keyPrefix — read site, fallback field and i18n key together — but deliberately kept note, since note had never had a config counterpart to drop. This is the same cleanup for note, now that /api/plans is the single source of truth.

Related Issue

None — no issue exists for this; the change is small and self-contained, so it goes straight to a PR per CONTRIBUTING ("请先开 Issue 讨论" applies to large changes such as new modules or architectural shifts).

Changes

  • ui/js/app.js — showPlanHint() no longer reads pl.note; the hint keeps only the paygo/subscription label. A comment records why the suffix is gone, so it is not "restored" later.
  • ui/js/i18n.js — removed share.plan.note from both packs (zh and en), keeping the two key sets identical so the i18n_pack parity gate stays green.
  • ui/README.md — the sharing bullet claimed "选 Plan 后显示专属端点提示"; corrected to "显示 Plan 类型(按量 / 订阅)", which is what the form actually shows.
  • ui/index.html — cache-bust ?v=20260912-2 → ?v=20260912-3 (5 refs).
  • src/i18n_pack.rs — the maintained control values follow the extraction: 786→785 keys, 538→537 call sites, 431→430 distinct. Each value was read from the gate's own failure output, not computed by hand.
  • No config/data-structure change. The note values in ui/js/data.js's fallback PLANS are left in place: they are now inert (no reader) and document each plan's real endpoint conventions, so surfacing them properly would mean promoting them into config [[plans]] — a separate, product-level change rather than a cleanup.

Tests

  • cargo test — 165 passed / 0 failed
  • cargo fmt --check — clean
  • cargo clippy --all-targets -- -D warnings — clean
  • New/updated unit tests — the i18n_pack gates already cover this change and fired three times in sequence (key parity, then call sites, then distinct literals), which is the intended maintained-contract behaviour; every value was taken from the failure output.

Verification of the fix (A/B, same generator, real pre-change source as baseline)

A runtime harness evaluates the real showPlanHint — extracted from git show HEAD:ui/js/app.js (BEFORE) and from the working tree (AFTER) — against the real language packs loaded from ui/js/i18n.js, in both languages, with two plan sources: the GET /api/plans shape (no note; the reachable path) and the data.js PLANS fallback (which still carries note).

assertion BEFORE AFTER
pl.note present in the function source yes no
reachable path renders · <note> no (dead) no
reachable-path text, zh / en 按量计价的 key / Pay-as-you-go key identical
fallback path renders · <note> yes, with the old key present n/a (reader removed)

The reachable-path text is byte-identical before and after — the suffix never rendered, so no user-visible change occurs; the change removes a dead read and a dead key. A positive control proves the harness is able to detect a suffix when one genuinely renders (with the old source and the old pack, the fallback path produces 按量计价的 key · 无订阅 plan,仅按量;OpenAI/Anthropic/Responses 端点), so the negative assertion is not vacuous. 12/12 assertions pass.

Checklist

  • 分支命名符合约定 (fix/)
  • Commit message 使用 Conventional Commits 格式 (fix(ui): …)
  • 单一职责,改动最小化 — one dead read + its key + the doc line that described it

`showPlanHint()` appended ` · {note}` from the selected plan, but the only
reachable plan source (`Live.plans`, i.e. `GET /api/plans`) never returns a
`note` field: `src/config.rs`'s `Plan` struct has none and `[[plans]]` in
`config.example.toml` declares none (verified across all history). So for a
logged-in user the expression `pl.note` is always undefined, the ternary never
fires, and the suffix never renders — the hint keeps only the paygo/subscription
text.

The read became dead in `a2e40f2` ("fix(integration): 3 browser-found bugs"),
which switched the plan source from the `data.js` fallback to `GET /api/plans`
without carrying `note` across. `44a3040` cleaned up the sibling UI-only field
`keyPrefix` (read + i18n key + fallback field) but left `note` behind, because
at that point `note` had never had a config counterpart.

This removes the dead read and the now-unused `share.plan.note` key from both
language packs (its only call site was here), and corrects the `ui/README.md`
line that promised an endpoint hint the form can no longer show. The `note`
values in `ui/js/data.js`'s fallback `PLANS` are left in place: they are inert
(no longer referenced) and describe each plan's real endpoint conventions, so
surfacing them properly would mean promoting them to config `[[plans]]` — a
separate, product-level change.

No production Rust behaviour changes; the i18n gate control values follow the
extraction (786→785 keys, 538→537 call sites, 431→430 distinct).
@argszero
argszero merged commit 92946b7 into main Sep 12, 2026
1 check passed
@argszero
argszero deleted the fix/share-plan-hint-dead-note branch September 12, 2026 05:08
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