Skip to content

fix(ui): resync the fallback catalog in data.js with config.example.toml - #172

Merged
argszero merged 1 commit into
mainfrom
fix/datajs-catalog-sync
Sep 12, 2026
Merged

argszero merged 1 commit into
mainfrom
fix/datajs-catalog-sync

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

ui/js/data.js documents its two fallback tables as "对齐 config.toml [[models]] 官方价" (aligned with the official prices in config.toml), but they had drifted from the single source of truth (config/config.example.toml), and the drift broke a cross-reference that the code itself relies on.

This PR resyncs the guest/fallback catalog so ui/js/data.js matches config.example.toml again.

What was wrong

(A) A phantom model. gemini-3.5-flash-lite existed only in ui/js/data.js. It is not in any tracked config, not in any untracked config, nothing in src/, and not in the models table of a live database. Its provenance confirms it was a mistake: commit ce6d0db (the 2026-08-20 price refresh) announced adding it in its commit message, but git log -S flash-lite -- config/ is empty at every revision — it was only ever written into this JS fallback.

(B) The guest MARKET table named models that no longer exist. ce6d0db renamed glm-5.2 → glm-5.3, gpt-5.5-pro → gpt-5.6-sol and claude-opus-4.7 → claude-opus-5 in MODELS, but left MARKET untouched. deepseek-v4-flash also still carried a 7.2x-scaled USD price (1.008 / 2.016) instead of the official CNY price, and glm-5.3 kept a stale peak: true flag even though it has no peak price in config.

Why (B) is a real defect and not a matter of taste: ui/js/app.js:737-739 resolves a guest row's max-token cell by model name:

const md = (!m.live) ? D.MODELS.find((x) => x.model === m.model) : null;

The two tables are designed to agree on names. With the names renamed away, that lookup missed for three of the seven guest rows and the cell fell back to "not published" instead of the max output. Guest mode is reachable from the login page ("先逛逛市场" → guest browse → #view-marketplace, which is rendered from D.MARKET because /api/models is only fetched inside loadSession()).

Changes

  • Delete the gemini-3.5-flash-lite row from MODELS — it exists nowhere else.
  • Add the missing deepseek-v4-flash-vision-exp row (present in config and seeded into the database, absent from this fallback) with its config pricing and max_output.
  • Resync the guest MARKET rows: 3 renamed models and the deepseek-v4-flash price.
  • Drive the peak columns from the config peak prices (3.0 / 9.0) rather than the derived 2.016 / 4.032, and drop the stale peak flag from glm-5.3.
  • Bump the cache-bust in ui/index.html (?v=20260911-14 → ?v=20260911-15, 5 refs) so the changed file is refetched.

All values are derived from config/config.example.toml, converting USD prices with CNY_PER_USD (src/billing.rs:22). The 13 other MODELS rows were already exact and are untouched; PLANS is unchanged (its 12 ids already match config).

Related Issue

None — no issue is open for this. It was found by comparing the two tables directly.

Tests

  • cargo test — 155 passed, 0 failed
  • cargo fmt --check — clean
  • cargo clippy --all-targets -- -D warnings — clean
  • node --check ui/js/data.js — the edited file still parses
  • No new test added. This project has no JS toolchain (ui/package.json does not exist), so a guard for this table-to-config correspondence would have to be hand-written in Rust, as src/i18n_pack.rs does for the language packs. I deliberately kept this PR to the data fix; adding such a gate is a separate, larger change (and a gate must not land while the data it checks is still wrong).

Verification (beyond the suite)

Two independent checks, both run against the real files:

  1. Structural probe comparing both tables to config.example.toml as sets and as fields: MODELS set difference empty, 0 field drifts, all 7 MARKET rows matching on name and price, peak values matching config, and no peak flag on a model without peak pricing.
  2. Runtime check that loads the real ui/js/data.js in a vm and executes the exact lookup app.js:737-739 uses. Result: 5 failures before this change → 0 after.

The probes are proven able to fail, not merely green: re-injecting the phantom model, restoring the stale MARKET price, and restoring a renamed-away model each turned the check red, and the file was then restored with cp and verified by md5.

Checklist

  • Branch naming follows the convention (fix/)
  • Commit message uses Conventional Commits (fix(ui): …)
  • Single responsibility, minimal change (data resync only — no logic, no refactor)

`ui/js/data.js` documents its tables as "对齐 config.toml [[models]] 官方价", but
they had drifted, and the drift broke a cross-reference the code itself relies on.

- Delete `gemini-3.5-flash-lite` from MODELS: it exists only in this file. It is not
  in any config, nothing in src/, and not in the models table of a live DB. The
  commit that announced adding it (ce6d0db) only ever wrote it here.
- Add `deepseek-v4-flash-vision-exp` (present in config and seeded into the DB, but
  missing from this fallback) with its config pricing and max_output.
- Resync the guest MARKET table: `glm-5.2`/`gpt-5.5-pro`/`claude-opus-4.7` were
  renamed to `glm-5.3`/`gpt-5.6-sol`/`claude-opus-5`, and `deepseek-v4-flash` still
  carried a 7.2x-scaled USD price (1.008/2.016) instead of the CNY official price.
- Drive the peak columns from the config peak prices (3.0/9.0, not the derived
  2.016/4.032) and drop the stale `peak: true` flag from `glm-5.3`, which has no
  peak price in config.

Why it matters: `app.js:737-739` resolves a guest row's max-token cell by model
NAME (`D.MODELS.find((x) => x.model === m.model)`), so the three renamed rows were
rendering "not published" instead of their max output.

All values are derived from config/config.example.toml (USD prices x CNY_PER_USD
= 7.2, src/billing.rs:22). Cache-bust bumped so the changed file is refetched.

Verified: 155 tests pass, fmt/clippy clean; the MARKET -> MODELS cross-reference
resolves for all 7 guest rows (was 4/7); a runtime check that reads the real
module reports 5 failures before this change and 0 after.
@argszero
argszero merged commit fa67974 into main Sep 12, 2026
1 check passed
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