Skip to content

Pr 10 - #11

Merged
Max-Samson merged 2 commits into
mainfrom
pr-10
Sep 19, 2026
Merged

Max-Samson merged 2 commits into
mainfrom
pr-10

Conversation

@Max-Samson

Copy link
Copy Markdown
Owner

Summary

Fixes a bug where custom pricing.json file overrides were never applied and the file change watcher never fired (PR #10), and bumps the release
version to 1.1.6:

  • User-visible change:

    • Restores custom pricing configuration: previously, /dsh-usage-chart/pricing reported source: "builtin" for every model even when a custom pricing.json was present and valid, and file edits
      never triggered automatic recalculation.
    • Fixes Cordis lifecycle timing in src/index.ts: ctx.effect(() => fileSource.dispose(), ...) invoked dispose() synchronously at plugin registration time while the fiber was being created and
      registered undefined as the disposer. This prematurely killed filePricingSource before its initial async read resolved and closed the directory watcher. Changing this to return a disposer function
      (ctx.effect(() => () => fileSource.dispose(), ...)) ensures the file source remains active throughout the fiber lifecycle and is released only when the plugin is unloaded.
    • Aligns test mocks in tests/core.test.mjs, tests/pricing.test.mjs, and tests/rounds.test.mjs with Cordis lifecycle semantics (collecting disposers and running them in after()).
    • Adds a dedicated regression test covering the /pricing route with user pricing.json overrides enabled.
    • Bumps version to 1.1.6 across package.json, package-lock.json, README.md, README_ZH.md, CHANGELOG.md, and CHANGELOG_ZH.md.
  • Why it belongs in this plugin:

    • Accurate token cost accounting relies on the single-source-of-truth resolution hierarchy: User pricing.json override → Built-in official pricing → Conservative fallback. Premature disposal
      broke the first and highest-priority tier entirely for users configuring custom or enterprise rates.

Verification

  • npm run verify (typecheck + 41/41 tests pass)
  • npm pack --dry-run (successfully built dsh-usage-chart-1.1.6.tgz with zero warnings)
  • Clean-profile DSH installation tested when bundle, inject, slot, or route behavior changed (verified /dsh-usage-chart/pricing correctly reports source: "file" and serves user-defined prices)
  • No API keys, account data, private sessions, logs, or generated lib/ files included
  • CHANGELOG.md updated for user-visible changes (both CHANGELOG.md and CHANGELOG_ZH.md updated under [1.1.6] - 2026-09-19)

rezon-aki and others added 2 commits September 18, 2026 23:46
…ly time

ctx.effect(() => fileSource.dispose(), ...) calls dispose while the fiber is
being built and registers undefined as the disposer: the file source is dead
before its first read, so pricing.json is never applied and the change watcher
never fires. Return a disposer instead.

Test mocks now follow cordis semantics (run setup, keep the returned disposer,
release it in after()) and a /pricing route regression test covers the override
path - it fails against the old form.
@Max-Samson
Max-Samson merged commit 45d0671 into main Sep 19, 2026
2 checks passed
Max-Samson added a commit that referenced this pull request Sep 23, 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.

2 participants