opencode-quota-gui 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -30
- package/dist/bin/opencode-quota-gui.js +0 -0
- package/dist/contracts/analytics-entity.d.ts +6 -1
- package/dist/contracts/analytics-entity.js +27 -10
- package/dist/contracts/build-identity.js +1 -1
- package/dist/contracts/card-visibility.d.ts +21 -0
- package/dist/contracts/card-visibility.js +19 -0
- package/dist/contracts/dashboard.d.ts +27 -0
- package/dist/contracts/dashboard.js +2 -0
- package/dist/contracts/dto-guards.d.ts +24 -0
- package/dist/contracts/dto-guards.js +592 -0
- package/dist/contracts/provider-failure.d.ts +18 -0
- package/dist/contracts/provider-failure.js +25 -0
- package/dist/gui/config.d.ts +20 -3
- package/dist/gui/config.js +42 -3
- package/dist/gui/dashboard-errors.d.ts +32 -0
- package/dist/gui/dashboard-errors.js +97 -0
- package/dist/gui/lifecycle.d.ts +44 -11
- package/dist/gui/lifecycle.js +214 -36
- package/dist/gui/primary-quota-windows.d.ts +28 -0
- package/dist/gui/primary-quota-windows.js +147 -0
- package/dist/gui/provider-cards.d.ts +1 -1
- package/dist/gui/provider-cards.js +40 -16
- package/dist/gui/quota-notification-detector.d.ts +151 -0
- package/dist/gui/quota-notification-detector.js +284 -0
- package/dist/gui/quota-notification-observer.d.ts +55 -0
- package/dist/gui/quota-notification-observer.js +363 -0
- package/dist/gui/rpc.d.ts +59 -0
- package/dist/gui/rpc.js +302 -0
- package/dist/gui/server.d.ts +15 -27
- package/dist/gui/server.js +23 -121
- package/dist/gui/snapshot-service.d.ts +31 -4
- package/dist/gui/snapshot-service.js +177 -54
- package/dist/gui/sources.d.ts +1 -1
- package/dist/gui-experimental.cjs +1756 -0
- package/dist/lib/anthropic.d.ts +5 -0
- package/dist/lib/anthropic.js +18 -1
- package/dist/lib/chutes.js +19 -2
- package/dist/lib/config.d.ts +5 -1
- package/dist/lib/config.js +48 -0
- package/dist/lib/copilot.js +42 -14
- package/dist/lib/dashboard-web-policy.d.ts +35 -0
- package/dist/lib/dashboard-web-policy.js +24 -0
- package/dist/lib/deepseek.js +12 -1
- package/dist/lib/display-sanitize.js +2 -0
- package/dist/lib/entries.d.ts +3 -0
- package/dist/lib/format-utils.d.ts +1 -1
- package/dist/lib/format-utils.js +2 -2
- package/dist/lib/glm-coding-plan.js +14 -4
- package/dist/lib/google-agy.js +59 -14
- package/dist/lib/google-gemini-cli.js +58 -14
- package/dist/lib/init-installer.js +25 -4
- package/dist/lib/kilo.js +29 -40
- package/dist/lib/kimi.js +13 -1
- package/dist/lib/mimo.d.ts +2 -0
- package/dist/lib/mimo.js +9 -1
- package/dist/lib/nanogpt.d.ts +2 -0
- package/dist/lib/nanogpt.js +24 -3
- package/dist/lib/ollama-cloud.js +9 -0
- package/dist/lib/openai.js +6 -2
- package/dist/lib/opencode-auth.d.ts +3 -2
- package/dist/lib/opencode-auth.js +8 -1
- package/dist/lib/opencode-go.js +24 -3
- package/dist/lib/opencode-version.d.ts +21 -0
- package/dist/lib/opencode-version.js +53 -5
- package/dist/lib/opencode-zen.d.ts +9 -1
- package/dist/lib/opencode-zen.js +27 -7
- package/dist/lib/quota-providers-remote.d.ts +2 -0
- package/dist/lib/quota-providers-remote.js +78 -19
- package/dist/lib/quota-reset-notifications.d.ts +17 -0
- package/dist/lib/quota-reset-notifications.js +11 -2
- package/dist/lib/quota-state-codec.js +3 -1
- package/dist/lib/synthetic.js +8 -0
- package/dist/lib/types.d.ts +18 -0
- package/dist/lib/types.js +3 -0
- package/dist/lib/xai.js +16 -2
- package/dist/plugin.d.ts +4 -3
- package/dist/plugin.js +33 -4
- package/dist/providers/alibaba-coding-plan.js +3 -1
- package/dist/providers/alibaba-token-plan.js +17 -0
- package/dist/providers/anthropic.js +12 -3
- package/dist/providers/copilot.js +10 -2
- package/dist/providers/glm-coding-plan-provider.d.ts +2 -0
- package/dist/providers/glm-coding-plan-provider.js +5 -1
- package/dist/providers/google-account-format.js +1 -0
- package/dist/providers/google-agy.js +12 -2
- package/dist/providers/google-gemini-cli.js +12 -2
- package/dist/providers/kilo.js +9 -1
- package/dist/providers/kimi-code.js +11 -6
- package/dist/providers/mimo.js +8 -2
- package/dist/providers/minimax-coding-plan.js +28 -5
- package/dist/providers/nanogpt.js +3 -0
- package/dist/providers/ollama-cloud.js +3 -0
- package/dist/providers/openai.js +1 -0
- package/dist/providers/opencode-go.js +8 -1
- package/dist/providers/opencode-zen.js +30 -3
- package/dist/providers/openrouter.js +3 -0
- package/dist/providers/quota-providers.js +30 -4
- package/dist/providers/result-helpers.d.ts +4 -0
- package/dist/providers/result-helpers.js +16 -2
- package/dist/rpc.d.ts +327 -4
- package/dist/rpc.js +315 -2
- package/dist/ui/assets/index-DLHeXYff.js +9 -0
- package/dist/ui/assets/{index-Cs-nrywz.css → index-cDd9jUVY.css} +1 -1
- package/dist/ui/assets/{popover-DKRrwr_K.js → popover-BGkgv9s0.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/package.json +49 -40
- package/dist/bin/opencode-quota-gui.d.ts.map +0 -1
- package/dist/bin/opencode-quota-gui.js.map +0 -1
- package/dist/contracts/analytics-entity.d.ts.map +0 -1
- package/dist/contracts/analytics-entity.js.map +0 -1
- package/dist/contracts/analytics-temporal.d.ts.map +0 -1
- package/dist/contracts/analytics-temporal.js.map +0 -1
- package/dist/contracts/build-identity.d.ts.map +0 -1
- package/dist/contracts/card-order.d.ts.map +0 -1
- package/dist/contracts/card-order.js.map +0 -1
- package/dist/contracts/collision-safe-key.d.ts.map +0 -1
- package/dist/contracts/collision-safe-key.js.map +0 -1
- package/dist/contracts/dashboard.d.ts.map +0 -1
- package/dist/contracts/dashboard.js.map +0 -1
- package/dist/contracts/guards.d.ts.map +0 -1
- package/dist/contracts/guards.js.map +0 -1
- package/dist/contracts/identity.d.ts.map +0 -1
- package/dist/contracts/identity.js.map +0 -1
- package/dist/contracts/openai-quota.d.ts.map +0 -1
- package/dist/contracts/openai-quota.js.map +0 -1
- package/dist/contracts/ranges.d.ts.map +0 -1
- package/dist/contracts/ranges.js.map +0 -1
- package/dist/contracts/settings.d.ts.map +0 -1
- package/dist/contracts/settings.js.map +0 -1
- package/dist/contracts/temporal.d.ts.map +0 -1
- package/dist/contracts/temporal.js.map +0 -1
- package/dist/contracts/time-zone.d.ts.map +0 -1
- package/dist/contracts/time-zone.js.map +0 -1
- package/dist/gui/aggregation.d.ts.map +0 -1
- package/dist/gui/aggregation.js.map +0 -1
- package/dist/gui/analytics-bridge.d.ts.map +0 -1
- package/dist/gui/analytics-bridge.js.map +0 -1
- package/dist/gui/analytics-engine.d.ts.map +0 -1
- package/dist/gui/analytics-engine.js.map +0 -1
- package/dist/gui/analytics-indexes.d.ts.map +0 -1
- package/dist/gui/analytics-indexes.js.map +0 -1
- package/dist/gui/analytics-model.d.ts.map +0 -1
- package/dist/gui/analytics-model.js.map +0 -1
- package/dist/gui/analytics-pricing-revision.d.ts.map +0 -1
- package/dist/gui/analytics-pricing-revision.js.map +0 -1
- package/dist/gui/analytics-protocol.d.ts.map +0 -1
- package/dist/gui/analytics-protocol.js.map +0 -1
- package/dist/gui/analytics-reader.d.ts.map +0 -1
- package/dist/gui/analytics-reader.js.map +0 -1
- package/dist/gui/analytics-service.d.ts.map +0 -1
- package/dist/gui/analytics-service.js.map +0 -1
- package/dist/gui/analytics-state.d.ts.map +0 -1
- package/dist/gui/analytics-state.js.map +0 -1
- package/dist/gui/analytics-worker-runtime.d.ts.map +0 -1
- package/dist/gui/analytics-worker-runtime.js.map +0 -1
- package/dist/gui/analytics-worker.d.ts.map +0 -1
- package/dist/gui/analytics-worker.js.map +0 -1
- package/dist/gui/config.d.ts.map +0 -1
- package/dist/gui/config.js.map +0 -1
- package/dist/gui/identity.d.ts.map +0 -1
- package/dist/gui/identity.js.map +0 -1
- package/dist/gui/lifecycle.d.ts.map +0 -1
- package/dist/gui/lifecycle.js.map +0 -1
- package/dist/gui/log.d.ts.map +0 -1
- package/dist/gui/log.js.map +0 -1
- package/dist/gui/provider-cards.d.ts.map +0 -1
- package/dist/gui/provider-cards.js.map +0 -1
- package/dist/gui/server.d.ts.map +0 -1
- package/dist/gui/server.js.map +0 -1
- package/dist/gui/settings-file-opener.d.ts.map +0 -1
- package/dist/gui/settings-file-opener.js.map +0 -1
- package/dist/gui/snapshot-service.d.ts.map +0 -1
- package/dist/gui/snapshot-service.js.map +0 -1
- package/dist/gui/sources.d.ts.map +0 -1
- package/dist/gui/sources.js.map +0 -1
- package/dist/gui/sse.d.ts.map +0 -1
- package/dist/gui/sse.js.map +0 -1
- package/dist/gui/temporal-quota-policy-data.d.ts.map +0 -1
- package/dist/gui/temporal-quota-policy-data.js.map +0 -1
- package/dist/gui/temporal-quota-policy.d.ts.map +0 -1
- package/dist/gui/temporal-quota-policy.js.map +0 -1
- package/dist/gui/temporal-status.d.ts.map +0 -1
- package/dist/gui/temporal-status.js.map +0 -1
- package/dist/gui/time-zone.d.ts.map +0 -1
- package/dist/gui/time-zone.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/accounting-format.d.ts.map +0 -1
- package/dist/lib/accounting-format.js.map +0 -1
- package/dist/lib/alibaba-auth.d.ts.map +0 -1
- package/dist/lib/alibaba-auth.js.map +0 -1
- package/dist/lib/alibaba-coding-plan-local-quota.d.ts.map +0 -1
- package/dist/lib/alibaba-coding-plan-local-quota.js.map +0 -1
- package/dist/lib/alibaba-token-plan.d.ts.map +0 -1
- package/dist/lib/alibaba-token-plan.js.map +0 -1
- package/dist/lib/anthropic-auth.d.ts.map +0 -1
- package/dist/lib/anthropic-auth.js.map +0 -1
- package/dist/lib/anthropic.d.ts.map +0 -1
- package/dist/lib/anthropic.js.map +0 -1
- package/dist/lib/api-key-resolver.d.ts.map +0 -1
- package/dist/lib/api-key-resolver.js.map +0 -1
- package/dist/lib/atomic-json.d.ts.map +0 -1
- package/dist/lib/atomic-json.js.map +0 -1
- package/dist/lib/chutes-config.d.ts.map +0 -1
- package/dist/lib/chutes-config.js.map +0 -1
- package/dist/lib/chutes.d.ts.map +0 -1
- package/dist/lib/chutes.js.map +0 -1
- package/dist/lib/cli-reports.d.ts.map +0 -1
- package/dist/lib/cli-reports.js.map +0 -1
- package/dist/lib/cli-show.d.ts.map +0 -1
- package/dist/lib/cli-show.js.map +0 -1
- package/dist/lib/cli-status.d.ts.map +0 -1
- package/dist/lib/cli-status.js.map +0 -1
- package/dist/lib/command-parsing.d.ts.map +0 -1
- package/dist/lib/command-parsing.js.map +0 -1
- package/dist/lib/config-file-utils.d.ts.map +0 -1
- package/dist/lib/config-file-utils.js.map +0 -1
- package/dist/lib/config-write-target.d.ts.map +0 -1
- package/dist/lib/config-write-target.js.map +0 -1
- package/dist/lib/config.d.ts.map +0 -1
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/copilot.d.ts.map +0 -1
- package/dist/lib/copilot.js.map +0 -1
- package/dist/lib/cursor-detection.d.ts.map +0 -1
- package/dist/lib/cursor-detection.js.map +0 -1
- package/dist/lib/cursor-pricing.d.ts.map +0 -1
- package/dist/lib/cursor-pricing.js.map +0 -1
- package/dist/lib/cursor-usage.d.ts.map +0 -1
- package/dist/lib/cursor-usage.js.map +0 -1
- package/dist/lib/dashboard-visibility.d.ts.map +0 -1
- package/dist/lib/dashboard-visibility.js.map +0 -1
- package/dist/lib/deepseek-auth.d.ts.map +0 -1
- package/dist/lib/deepseek-auth.js.map +0 -1
- package/dist/lib/deepseek.d.ts.map +0 -1
- package/dist/lib/deepseek.js.map +0 -1
- package/dist/lib/display-sanitize.d.ts.map +0 -1
- package/dist/lib/display-sanitize.js.map +0 -1
- package/dist/lib/entries.d.ts.map +0 -1
- package/dist/lib/entries.js.map +0 -1
- package/dist/lib/env-template.d.ts.map +0 -1
- package/dist/lib/env-template.js.map +0 -1
- package/dist/lib/format-utils.d.ts.map +0 -1
- package/dist/lib/format-utils.js.map +0 -1
- package/dist/lib/format.d.ts.map +0 -1
- package/dist/lib/format.js.map +0 -1
- package/dist/lib/glm-coding-plan.d.ts.map +0 -1
- package/dist/lib/glm-coding-plan.js.map +0 -1
- package/dist/lib/google-agy-companion.d.ts.map +0 -1
- package/dist/lib/google-agy-companion.js.map +0 -1
- package/dist/lib/google-agy.d.ts.map +0 -1
- package/dist/lib/google-agy.js.map +0 -1
- package/dist/lib/google-companion-credentials.d.ts.map +0 -1
- package/dist/lib/google-companion-credentials.js.map +0 -1
- package/dist/lib/google-gemini-cli-companion.d.ts.map +0 -1
- package/dist/lib/google-gemini-cli-companion.js.map +0 -1
- package/dist/lib/google-gemini-cli.d.ts.map +0 -1
- package/dist/lib/google-gemini-cli.js.map +0 -1
- package/dist/lib/google-token-cache.d.ts.map +0 -1
- package/dist/lib/google-token-cache.js.map +0 -1
- package/dist/lib/grouped-entry-normalization.d.ts.map +0 -1
- package/dist/lib/grouped-entry-normalization.js.map +0 -1
- package/dist/lib/grouped-header-format.d.ts.map +0 -1
- package/dist/lib/grouped-header-format.js.map +0 -1
- package/dist/lib/gui-config-target.d.ts.map +0 -1
- package/dist/lib/gui-config-target.js.map +0 -1
- package/dist/lib/home-dir-display.d.ts.map +0 -1
- package/dist/lib/home-dir-display.js.map +0 -1
- package/dist/lib/http.d.ts.map +0 -1
- package/dist/lib/http.js.map +0 -1
- package/dist/lib/init-installer.d.ts.map +0 -1
- package/dist/lib/init-installer.js.map +0 -1
- package/dist/lib/jsonc.d.ts.map +0 -1
- package/dist/lib/jsonc.js.map +0 -1
- package/dist/lib/kilo-config.d.ts.map +0 -1
- package/dist/lib/kilo-config.js.map +0 -1
- package/dist/lib/kilo.d.ts.map +0 -1
- package/dist/lib/kilo.js.map +0 -1
- package/dist/lib/kimi-auth.d.ts.map +0 -1
- package/dist/lib/kimi-auth.js.map +0 -1
- package/dist/lib/kimi-endpoints.d.ts.map +0 -1
- package/dist/lib/kimi-endpoints.js.map +0 -1
- package/dist/lib/kimi.d.ts.map +0 -1
- package/dist/lib/kimi.js.map +0 -1
- package/dist/lib/maintainer-announcements.d.ts.map +0 -1
- package/dist/lib/maintainer-announcements.js.map +0 -1
- package/dist/lib/map-with-concurrency.d.ts.map +0 -1
- package/dist/lib/map-with-concurrency.js.map +0 -1
- package/dist/lib/markdown-table.d.ts.map +0 -1
- package/dist/lib/markdown-table.js.map +0 -1
- package/dist/lib/mimo-config.d.ts.map +0 -1
- package/dist/lib/mimo-config.js.map +0 -1
- package/dist/lib/mimo.d.ts.map +0 -1
- package/dist/lib/mimo.js.map +0 -1
- package/dist/lib/minimax-auth.d.ts.map +0 -1
- package/dist/lib/minimax-auth.js.map +0 -1
- package/dist/lib/minimax-endpoints.d.ts.map +0 -1
- package/dist/lib/minimax-endpoints.js.map +0 -1
- package/dist/lib/modelsdev-pricing.d.ts.map +0 -1
- package/dist/lib/modelsdev-pricing.js.map +0 -1
- package/dist/lib/modelsdev-temporal.d.ts.map +0 -1
- package/dist/lib/modelsdev-temporal.js.map +0 -1
- package/dist/lib/nanogpt-config.d.ts.map +0 -1
- package/dist/lib/nanogpt-config.js.map +0 -1
- package/dist/lib/nanogpt.d.ts.map +0 -1
- package/dist/lib/nanogpt.js.map +0 -1
- package/dist/lib/ollama-cloud-config.d.ts.map +0 -1
- package/dist/lib/ollama-cloud-config.js.map +0 -1
- package/dist/lib/ollama-cloud.d.ts.map +0 -1
- package/dist/lib/ollama-cloud.js.map +0 -1
- package/dist/lib/openai.d.ts.map +0 -1
- package/dist/lib/openai.js.map +0 -1
- package/dist/lib/opencode-auth-sqlite.d.ts.map +0 -1
- package/dist/lib/opencode-auth-sqlite.js.map +0 -1
- package/dist/lib/opencode-auth.d.ts.map +0 -1
- package/dist/lib/opencode-auth.js.map +0 -1
- package/dist/lib/opencode-config-editor.d.ts.map +0 -1
- package/dist/lib/opencode-config-editor.js.map +0 -1
- package/dist/lib/opencode-config-providers.d.ts.map +0 -1
- package/dist/lib/opencode-config-providers.js.map +0 -1
- package/dist/lib/opencode-config-read.d.ts.map +0 -1
- package/dist/lib/opencode-config-read.js.map +0 -1
- package/dist/lib/opencode-console-auth.d.ts.map +0 -1
- package/dist/lib/opencode-console-auth.js.map +0 -1
- package/dist/lib/opencode-db-path.d.ts.map +0 -1
- package/dist/lib/opencode-db-path.js.map +0 -1
- package/dist/lib/opencode-go-auth.d.ts.map +0 -1
- package/dist/lib/opencode-go-auth.js.map +0 -1
- package/dist/lib/opencode-go.d.ts.map +0 -1
- package/dist/lib/opencode-go.js.map +0 -1
- package/dist/lib/opencode-runtime-paths.d.ts.map +0 -1
- package/dist/lib/opencode-runtime-paths.js.map +0 -1
- package/dist/lib/opencode-sqlite.d.ts.map +0 -1
- package/dist/lib/opencode-sqlite.js.map +0 -1
- package/dist/lib/opencode-storage.d.ts.map +0 -1
- package/dist/lib/opencode-storage.js.map +0 -1
- package/dist/lib/opencode-version.d.ts.map +0 -1
- package/dist/lib/opencode-version.js.map +0 -1
- package/dist/lib/opencode-zen.d.ts.map +0 -1
- package/dist/lib/opencode-zen.js.map +0 -1
- package/dist/lib/openrouter.d.ts.map +0 -1
- package/dist/lib/openrouter.js.map +0 -1
- package/dist/lib/private-state-paths.d.ts.map +0 -1
- package/dist/lib/private-state-paths.js.map +0 -1
- package/dist/lib/provider-add-command.d.ts.map +0 -1
- package/dist/lib/provider-add-command.js.map +0 -1
- package/dist/lib/provider-add-json-v1-questionnaire.d.ts.map +0 -1
- package/dist/lib/provider-add-json-v1-questionnaire.js.map +0 -1
- package/dist/lib/provider-add.d.ts.map +0 -1
- package/dist/lib/provider-add.js.map +0 -1
- package/dist/lib/provider-availability.d.ts.map +0 -1
- package/dist/lib/provider-availability.js.map +0 -1
- package/dist/lib/provider-metadata.d.ts.map +0 -1
- package/dist/lib/provider-metadata.js.map +0 -1
- package/dist/lib/provider-model-matching.d.ts.map +0 -1
- package/dist/lib/provider-model-matching.js.map +0 -1
- package/dist/lib/provider-registration.d.ts.map +0 -1
- package/dist/lib/provider-registration.js.map +0 -1
- package/dist/lib/quota-accounting-projection.d.ts.map +0 -1
- package/dist/lib/quota-accounting-projection.js.map +0 -1
- package/dist/lib/quota-columns.d.ts.map +0 -1
- package/dist/lib/quota-columns.js.map +0 -1
- package/dist/lib/quota-command-format.d.ts.map +0 -1
- package/dist/lib/quota-command-format.js.map +0 -1
- package/dist/lib/quota-dialog-command-specs.d.ts.map +0 -1
- package/dist/lib/quota-dialog-command-specs.js.map +0 -1
- package/dist/lib/quota-dialog-commands.d.ts.map +0 -1
- package/dist/lib/quota-dialog-commands.js.map +0 -1
- package/dist/lib/quota-entry-display.d.ts.map +0 -1
- package/dist/lib/quota-entry-display.js.map +0 -1
- package/dist/lib/quota-exhaustion-projection.d.ts.map +0 -1
- package/dist/lib/quota-exhaustion-projection.js.map +0 -1
- package/dist/lib/quota-export-types.d.ts.map +0 -1
- package/dist/lib/quota-export-types.js.map +0 -1
- package/dist/lib/quota-export.d.ts.map +0 -1
- package/dist/lib/quota-export.js.map +0 -1
- package/dist/lib/quota-format-style.d.ts.map +0 -1
- package/dist/lib/quota-format-style.js.map +0 -1
- package/dist/lib/quota-providers-local.d.ts.map +0 -1
- package/dist/lib/quota-providers-local.js.map +0 -1
- package/dist/lib/quota-providers-remote.d.ts.map +0 -1
- package/dist/lib/quota-providers-remote.js.map +0 -1
- package/dist/lib/quota-providers.d.ts.map +0 -1
- package/dist/lib/quota-providers.js.map +0 -1
- package/dist/lib/quota-render-data.d.ts.map +0 -1
- package/dist/lib/quota-render-data.js.map +0 -1
- package/dist/lib/quota-report-message.d.ts.map +0 -1
- package/dist/lib/quota-report-message.js.map +0 -1
- package/dist/lib/quota-reset-notifications.d.ts.map +0 -1
- package/dist/lib/quota-reset-notifications.js.map +0 -1
- package/dist/lib/quota-retry-wait.d.ts.map +0 -1
- package/dist/lib/quota-retry-wait.js.map +0 -1
- package/dist/lib/quota-runtime-context.d.ts.map +0 -1
- package/dist/lib/quota-runtime-context.js.map +0 -1
- package/dist/lib/quota-state-codec.d.ts.map +0 -1
- package/dist/lib/quota-state-codec.js.map +0 -1
- package/dist/lib/quota-state.d.ts.map +0 -1
- package/dist/lib/quota-state.js.map +0 -1
- package/dist/lib/quota-stats-format.d.ts.map +0 -1
- package/dist/lib/quota-stats-format.js.map +0 -1
- package/dist/lib/quota-stats.d.ts.map +0 -1
- package/dist/lib/quota-stats.js.map +0 -1
- package/dist/lib/quota-status.d.ts.map +0 -1
- package/dist/lib/quota-status.js.map +0 -1
- package/dist/lib/quota-surface-data.d.ts.map +0 -1
- package/dist/lib/quota-surface-data.js.map +0 -1
- package/dist/lib/quota-telemetry.d.ts.map +0 -1
- package/dist/lib/quota-telemetry.js.map +0 -1
- package/dist/lib/report-document.d.ts.map +0 -1
- package/dist/lib/report-document.js.map +0 -1
- package/dist/lib/resolved-auth-identity.d.ts.map +0 -1
- package/dist/lib/resolved-auth-identity.js.map +0 -1
- package/dist/lib/runtime-provider-ids.d.ts.map +0 -1
- package/dist/lib/runtime-provider-ids.js.map +0 -1
- package/dist/lib/scoped-query-chunks.d.ts.map +0 -1
- package/dist/lib/scoped-query-chunks.js.map +0 -1
- package/dist/lib/scoped-update-migration.d.ts.map +0 -1
- package/dist/lib/scoped-update-migration.js.map +0 -1
- package/dist/lib/scoped-update.d.ts.map +0 -1
- package/dist/lib/scoped-update.js.map +0 -1
- package/dist/lib/session-tokens-format.d.ts.map +0 -1
- package/dist/lib/session-tokens-format.js.map +0 -1
- package/dist/lib/session-tokens.d.ts.map +0 -1
- package/dist/lib/session-tokens.js.map +0 -1
- package/dist/lib/synthetic-config.d.ts.map +0 -1
- package/dist/lib/synthetic-config.js.map +0 -1
- package/dist/lib/synthetic.d.ts.map +0 -1
- package/dist/lib/synthetic.js.map +0 -1
- package/dist/lib/toast-format-grouped.d.ts.map +0 -1
- package/dist/lib/toast-format-grouped.js.map +0 -1
- package/dist/lib/token-buckets.d.ts.map +0 -1
- package/dist/lib/token-buckets.js.map +0 -1
- package/dist/lib/token-cost.d.ts.map +0 -1
- package/dist/lib/token-cost.js.map +0 -1
- package/dist/lib/tui-compact-format.d.ts.map +0 -1
- package/dist/lib/tui-compact-format.js.map +0 -1
- package/dist/lib/tui-panel-state.d.ts.map +0 -1
- package/dist/lib/tui-panel-state.js.map +0 -1
- package/dist/lib/tui-prompt-bar-format.d.ts.map +0 -1
- package/dist/lib/tui-prompt-bar-format.js.map +0 -1
- package/dist/lib/tui-sidebar-format.d.ts.map +0 -1
- package/dist/lib/tui-sidebar-format.js.map +0 -1
- package/dist/lib/types.d.ts.map +0 -1
- package/dist/lib/types.js.map +0 -1
- package/dist/lib/usage-ownership.d.ts.map +0 -1
- package/dist/lib/usage-ownership.js.map +0 -1
- package/dist/lib/version.d.ts.map +0 -1
- package/dist/lib/version.js.map +0 -1
- package/dist/lib/xai.d.ts.map +0 -1
- package/dist/lib/xai.js.map +0 -1
- package/dist/lib/zai-auth.d.ts.map +0 -1
- package/dist/lib/zai-auth.js.map +0 -1
- package/dist/lib/zai.d.ts.map +0 -1
- package/dist/lib/zai.js.map +0 -1
- package/dist/lib/zhipu-auth.d.ts.map +0 -1
- package/dist/lib/zhipu-auth.js.map +0 -1
- package/dist/lib/zhipu.d.ts.map +0 -1
- package/dist/lib/zhipu.js.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plugin.js.map +0 -1
- package/dist/providers/accounting-decimal.d.ts.map +0 -1
- package/dist/providers/accounting-decimal.js.map +0 -1
- package/dist/providers/alibaba-coding-plan.d.ts.map +0 -1
- package/dist/providers/alibaba-coding-plan.js.map +0 -1
- package/dist/providers/alibaba-token-plan.d.ts.map +0 -1
- package/dist/providers/alibaba-token-plan.js.map +0 -1
- package/dist/providers/anthropic.d.ts.map +0 -1
- package/dist/providers/anthropic.js.map +0 -1
- package/dist/providers/cache-policies.d.ts.map +0 -1
- package/dist/providers/cache-policies.js.map +0 -1
- package/dist/providers/chutes.d.ts.map +0 -1
- package/dist/providers/chutes.js.map +0 -1
- package/dist/providers/copilot.d.ts.map +0 -1
- package/dist/providers/copilot.js.map +0 -1
- package/dist/providers/cursor.d.ts.map +0 -1
- package/dist/providers/cursor.js.map +0 -1
- package/dist/providers/deepseek.d.ts.map +0 -1
- package/dist/providers/deepseek.js.map +0 -1
- package/dist/providers/glm-coding-plan-provider.d.ts.map +0 -1
- package/dist/providers/glm-coding-plan-provider.js.map +0 -1
- package/dist/providers/google-account-format.d.ts.map +0 -1
- package/dist/providers/google-account-format.js.map +0 -1
- package/dist/providers/google-agy.d.ts.map +0 -1
- package/dist/providers/google-agy.js.map +0 -1
- package/dist/providers/google-gemini-cli.d.ts.map +0 -1
- package/dist/providers/google-gemini-cli.js.map +0 -1
- package/dist/providers/kilo.d.ts.map +0 -1
- package/dist/providers/kilo.js.map +0 -1
- package/dist/providers/kimi-code.d.ts.map +0 -1
- package/dist/providers/kimi-code.js.map +0 -1
- package/dist/providers/mimo.d.ts.map +0 -1
- package/dist/providers/mimo.js.map +0 -1
- package/dist/providers/minimax-coding-plan.d.ts.map +0 -1
- package/dist/providers/minimax-coding-plan.js.map +0 -1
- package/dist/providers/nanogpt.d.ts.map +0 -1
- package/dist/providers/nanogpt.js.map +0 -1
- package/dist/providers/ollama-cloud.d.ts.map +0 -1
- package/dist/providers/ollama-cloud.js.map +0 -1
- package/dist/providers/openai.d.ts.map +0 -1
- package/dist/providers/openai.js.map +0 -1
- package/dist/providers/opencode-go.d.ts.map +0 -1
- package/dist/providers/opencode-go.js.map +0 -1
- package/dist/providers/opencode-zen.d.ts.map +0 -1
- package/dist/providers/opencode-zen.js.map +0 -1
- package/dist/providers/openrouter.d.ts.map +0 -1
- package/dist/providers/openrouter.js.map +0 -1
- package/dist/providers/quota-providers.d.ts.map +0 -1
- package/dist/providers/quota-providers.js.map +0 -1
- package/dist/providers/registry.d.ts.map +0 -1
- package/dist/providers/registry.js.map +0 -1
- package/dist/providers/result-helpers.d.ts.map +0 -1
- package/dist/providers/result-helpers.js.map +0 -1
- package/dist/providers/synthetic.d.ts.map +0 -1
- package/dist/providers/synthetic.js.map +0 -1
- package/dist/providers/xai.d.ts.map +0 -1
- package/dist/providers/xai.js.map +0 -1
- package/dist/providers/zai.d.ts.map +0 -1
- package/dist/providers/zai.js.map +0 -1
- package/dist/providers/zhipu.d.ts.map +0 -1
- package/dist/providers/zhipu.js.map +0 -1
- package/dist/rpc.d.ts.map +0 -1
- package/dist/rpc.js.map +0 -1
- package/dist/ui/assets/index-D9lFKhSN.js +0 -9
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Owns computation, caching, single-flight, viewer-scoped polling and
|
|
5
5
|
* invalidation. Cache keys are `(kind, resourceId, range)`; quota is its own
|
|
6
6
|
* key. Failures serve the last good snapshot with `stale: true` when one
|
|
7
|
-
* exists. Pollers run only while at least one
|
|
8
|
-
* never overlap within a kind.
|
|
7
|
+
* exists. Pollers run only while at least one transport viewer (SSE or RPC) is
|
|
8
|
+
* attached and ticks never overlap within a kind.
|
|
9
9
|
*
|
|
10
10
|
* Quota and analytics poll on independent timers: quota uses the existing
|
|
11
11
|
* positive `minIntervalMs` configuration (default 60000), analytics defaults
|
|
@@ -32,6 +32,12 @@
|
|
|
32
32
|
* newer one). A load on a closed service still computes for its caller but
|
|
33
33
|
* never touches tracking, registration, or cache.
|
|
34
34
|
*
|
|
35
|
+
* An owner/source handoff uses a source generation: entries retain the
|
|
36
|
+
* generation that produced them and old entries are last-good only. A
|
|
37
|
+
* pre-handoff result is marked stale when the DTO supports it, or failed when
|
|
38
|
+
* it does not (`SessionSnapshot`), so the previous owner's data is never
|
|
39
|
+
* presented as fresh.
|
|
40
|
+
*
|
|
35
41
|
* No TTL, sequence, watermark, or budget machinery exists (R9).
|
|
36
42
|
*/
|
|
37
43
|
import { encodeAnalyticsGroupQueryKey } from "../contracts/analytics-entity.js";
|
|
@@ -130,13 +136,27 @@ function payloadIsStale(snapshot) {
|
|
|
130
136
|
return false;
|
|
131
137
|
return staleFlag(snapshot.usage);
|
|
132
138
|
}
|
|
139
|
+
/** True when the contract carries the top-level `stale` marker. */
|
|
140
|
+
function hasStaleMarker(snapshot) {
|
|
141
|
+
return typeof snapshot === "object" && snapshot !== null && "stale" in snapshot;
|
|
142
|
+
}
|
|
133
143
|
/** Session snapshots have no `stale` field; they are served as-is. */
|
|
134
144
|
function markStale(snapshot) {
|
|
135
|
-
if (
|
|
145
|
+
if (!hasStaleMarker(snapshot))
|
|
136
146
|
return snapshot;
|
|
137
|
-
}
|
|
138
147
|
return { ...snapshot, stale: true };
|
|
139
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* A source handoff completed while a load that cannot carry the `stale` marker
|
|
151
|
+
* was still in flight. Failing is safer than returning the previous owner's
|
|
152
|
+
* payload as fresh; the transport maps it like any other snapshot failure.
|
|
153
|
+
*/
|
|
154
|
+
class SnapshotSourceChangedError extends Error {
|
|
155
|
+
constructor() {
|
|
156
|
+
super("Snapshot source changed before the snapshot completed");
|
|
157
|
+
this.name = "SnapshotSourceChangedError";
|
|
158
|
+
}
|
|
159
|
+
}
|
|
140
160
|
/** Safe log label: an allowlisted-shape code, never a raw message. */
|
|
141
161
|
function failureLabel(error) {
|
|
142
162
|
if (error !== null && typeof error === "object" && "code" in error) {
|
|
@@ -157,11 +177,24 @@ export function createSnapshotService(options) {
|
|
|
157
177
|
const tracked = new Map();
|
|
158
178
|
let versionCounter = 0;
|
|
159
179
|
let viewers = 0;
|
|
180
|
+
/**
|
|
181
|
+
* Scoped viewers are real consumers with their own active surface. Legacy
|
|
182
|
+
* (HTTP/SSE) viewers stay unscoped and vote through `viewScope`; the effective
|
|
183
|
+
* scope below aggregates both instead of letting the last signal win.
|
|
184
|
+
*/
|
|
185
|
+
const scopedViewers = new Map();
|
|
186
|
+
let nextScopedViewerId = 1;
|
|
160
187
|
/**
|
|
161
188
|
* Bumped when the viewer session ends (last disconnect or close). It disowns
|
|
162
189
|
* in-flight poll ticks and any HTTP cache commit started before that point.
|
|
163
190
|
*/
|
|
164
191
|
let viewerEpoch = 0;
|
|
192
|
+
/**
|
|
193
|
+
* Bumped when the active source identity changes (owner handoff). The cache
|
|
194
|
+
* remains as last-good fallback, but pre-handoff commits and poll results must
|
|
195
|
+
* not freshen it, and a new request must not join a pre-handoff task.
|
|
196
|
+
*/
|
|
197
|
+
let sourceGeneration = 0;
|
|
165
198
|
let viewScope = "analytics";
|
|
166
199
|
/** Explicit UI signal outranks read-request inference for this viewer session. */
|
|
167
200
|
let viewScopeExplicit = false;
|
|
@@ -222,6 +255,45 @@ export function createSnapshotService(options) {
|
|
|
222
255
|
function analyticsIntervalMs() {
|
|
223
256
|
return readInterval(options.analyticsIntervalMs, DEFAULT_ANALYTICS_INTERVAL_MS);
|
|
224
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* True when any real consumer still needs analytics. A scoped analytics
|
|
260
|
+
* viewer always wins, so a quota signal from a concurrent window cannot stop
|
|
261
|
+
* another window's refresh. Legacy viewers vote through `viewScope`; with no
|
|
262
|
+
* legacy viewer only scoped interests count.
|
|
263
|
+
*/
|
|
264
|
+
function analyticsViewActive() {
|
|
265
|
+
for (const scope of scopedViewers.values()) {
|
|
266
|
+
if (scope === "analytics")
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
const legacyViewers = viewers - scopedViewers.size;
|
|
270
|
+
return legacyViewers > 0 && viewScope === "analytics";
|
|
271
|
+
}
|
|
272
|
+
function retainViewer() {
|
|
273
|
+
if (closed)
|
|
274
|
+
return;
|
|
275
|
+
viewers += 1;
|
|
276
|
+
if (viewers === 1)
|
|
277
|
+
startPollers();
|
|
278
|
+
}
|
|
279
|
+
function releaseViewer() {
|
|
280
|
+
if (closed)
|
|
281
|
+
return;
|
|
282
|
+
viewers = Math.max(0, viewers - 1);
|
|
283
|
+
if (viewers === 0) {
|
|
284
|
+
stopPollers();
|
|
285
|
+
// End the viewer session: abandoned ticks poll no further keys, a
|
|
286
|
+
// reconnect starts with no stale poll interests, and pages are only
|
|
287
|
+
// polled again after an actual load re-registers them. Scope signals are
|
|
288
|
+
// viewer-scoped and reset with it.
|
|
289
|
+
viewerEpoch += 1;
|
|
290
|
+
viewScope = "analytics";
|
|
291
|
+
viewScopeExplicit = false;
|
|
292
|
+
scopedViewers.clear();
|
|
293
|
+
computes.clear();
|
|
294
|
+
dirty();
|
|
295
|
+
}
|
|
296
|
+
}
|
|
225
297
|
function emit(event) {
|
|
226
298
|
// Copy before calling out: a listener may unsubscribe while it runs.
|
|
227
299
|
for (const listener of Array.from(listeners)) {
|
|
@@ -276,6 +348,7 @@ export function createSnapshotService(options) {
|
|
|
276
348
|
}
|
|
277
349
|
function load(key, compute) {
|
|
278
350
|
const epoch = viewerEpoch;
|
|
351
|
+
const generation = sourceGeneration;
|
|
279
352
|
// A closed service does not track, register, or cache: the caller still
|
|
280
353
|
// gets its computation, but a probe (or a late request) cannot repopulate
|
|
281
354
|
// state that close() released.
|
|
@@ -283,23 +356,24 @@ export function createSnapshotService(options) {
|
|
|
283
356
|
if (!closed)
|
|
284
357
|
computes.set(key, compute);
|
|
285
358
|
const existing = cache.get(key);
|
|
286
|
-
if (existing && !existing.stale) {
|
|
359
|
+
if (existing && !existing.stale && existing.sourceGeneration === sourceGeneration) {
|
|
287
360
|
// SAFETY: `load<T>` is only called with a key built from `(kind, resourceId,
|
|
288
361
|
// range)`, and the entry under this key was stored by a compute of that key.
|
|
289
362
|
return Promise.resolve(existing.snapshot);
|
|
290
363
|
}
|
|
291
364
|
const pending = inflight.get(key);
|
|
292
|
-
if (pending && pending.epoch === epoch) {
|
|
293
|
-
// The key was requested again in the same viewer session
|
|
294
|
-
// was still pending: preserve single-flight
|
|
365
|
+
if (pending && pending.epoch === epoch && pending.sourceGeneration === generation) {
|
|
366
|
+
// The key was requested again in the same viewer session and source
|
|
367
|
+
// generation while its compute was still pending: preserve single-flight
|
|
368
|
+
// and let it cache again.
|
|
295
369
|
if (!closed)
|
|
296
370
|
pending.version = version;
|
|
297
371
|
// SAFETY: same key contract as the cache above; the inflight task was created
|
|
298
372
|
// by a `load<T>` call for this exact key.
|
|
299
373
|
return pending.promise;
|
|
300
374
|
}
|
|
301
|
-
// A pending task from an ended viewer session
|
|
302
|
-
//
|
|
375
|
+
// A pending task from an ended viewer session or a previous source identity
|
|
376
|
+
// is disowned: this caller runs its own compute instead.
|
|
303
377
|
let computation;
|
|
304
378
|
try {
|
|
305
379
|
computation = compute();
|
|
@@ -307,13 +381,42 @@ export function createSnapshotService(options) {
|
|
|
307
381
|
catch (error) {
|
|
308
382
|
computation = Promise.reject(error);
|
|
309
383
|
}
|
|
310
|
-
const task = {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
384
|
+
const task = {
|
|
385
|
+
epoch,
|
|
386
|
+
sourceGeneration: generation,
|
|
387
|
+
promise: Promise.resolve(),
|
|
388
|
+
version,
|
|
389
|
+
};
|
|
390
|
+
const attempt = (async () => {
|
|
391
|
+
let snapshot;
|
|
392
|
+
try {
|
|
393
|
+
snapshot = await computation;
|
|
394
|
+
}
|
|
395
|
+
catch (error) {
|
|
396
|
+
const fallback = tracked.get(key) === task.version ? cache.get(key) : undefined;
|
|
397
|
+
if (!fallback)
|
|
398
|
+
throw error;
|
|
399
|
+
// A previous owner's last-good entry may be served only when the DTO
|
|
400
|
+
// can carry the stale marker. Session snapshots cannot, so their
|
|
401
|
+
// failure is surfaced rather than presented as fresh old-owner data.
|
|
402
|
+
if (fallback.sourceGeneration !== sourceGeneration && !hasStaleMarker(fallback.snapshot)) {
|
|
403
|
+
throw error;
|
|
404
|
+
}
|
|
405
|
+
if (!closed && task.epoch === viewerEpoch && task.sourceGeneration === sourceGeneration) {
|
|
406
|
+
fallback.stale = true;
|
|
407
|
+
logger.warn("snapshot compute failed; serving last good snapshot", failureLabel(error));
|
|
408
|
+
}
|
|
409
|
+
// SAFETY: the cached entry under this key is a previous successful compute
|
|
410
|
+
// of the same `(kind, resourceId, range)` key, so it is a T snapshot.
|
|
411
|
+
return markStale(fallback.snapshot);
|
|
412
|
+
}
|
|
413
|
+
// A commit belongs to the viewer session and source identity that started
|
|
414
|
+
// the load: a disconnect or owner handoff already dirtied the entries, so
|
|
415
|
+
// an old result never re-freshens them.
|
|
416
|
+
if (!closed &&
|
|
417
|
+
task.epoch === viewerEpoch &&
|
|
418
|
+
task.sourceGeneration === sourceGeneration &&
|
|
419
|
+
tracked.get(key) === task.version) {
|
|
317
420
|
cache.set(key, {
|
|
318
421
|
snapshot,
|
|
319
422
|
substantive: substantiveOf(snapshot),
|
|
@@ -321,23 +424,21 @@ export function createSnapshotService(options) {
|
|
|
321
424
|
// for this caller; the next read must recompute rather than serve
|
|
322
425
|
// stale data as fresh until the next poll.
|
|
323
426
|
stale: payloadIsStale(snapshot),
|
|
427
|
+
sourceGeneration: task.sourceGeneration,
|
|
324
428
|
});
|
|
429
|
+
return snapshot;
|
|
325
430
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
fallback.stale = true;
|
|
334
|
-
logger.warn("snapshot compute failed; serving last good snapshot", failureLabel(error));
|
|
431
|
+
if (task.sourceGeneration !== sourceGeneration) {
|
|
432
|
+
// A handoff happened while this load was in flight. Never present the
|
|
433
|
+
// previous owner's payload as fresh: mark it when the contract supports
|
|
434
|
+
// it, otherwise fail like a post-handoff read would.
|
|
435
|
+
if (!hasStaleMarker(snapshot))
|
|
436
|
+
throw new SnapshotSourceChangedError();
|
|
437
|
+
return markStale(snapshot);
|
|
335
438
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
})
|
|
340
|
-
.finally(() => {
|
|
439
|
+
return snapshot;
|
|
440
|
+
})();
|
|
441
|
+
task.promise = attempt.finally(() => {
|
|
341
442
|
// Never delete a newer task that replaced this one after reconnect.
|
|
342
443
|
if (inflight.get(key) === task)
|
|
343
444
|
inflight.delete(key);
|
|
@@ -350,6 +451,7 @@ export function createSnapshotService(options) {
|
|
|
350
451
|
* the service closed and the tick must stop.
|
|
351
452
|
*/
|
|
352
453
|
async function pollOne(key, compute, epoch, changed) {
|
|
454
|
+
const generation = sourceGeneration;
|
|
353
455
|
if (closed || viewerEpoch !== epoch || viewers === 0)
|
|
354
456
|
return false;
|
|
355
457
|
if (computes.get(key) !== compute)
|
|
@@ -365,10 +467,12 @@ export function createSnapshotService(options) {
|
|
|
365
467
|
}
|
|
366
468
|
catch (error) {
|
|
367
469
|
// A key evicted (or re-loaded) while the poll was pending must not be
|
|
368
|
-
// marked current by this late result; an ended viewer session
|
|
369
|
-
// be updated or logged for at all.
|
|
470
|
+
// marked current by this late result; an ended viewer session or a
|
|
471
|
+
// previous source identity must not be updated or logged for at all.
|
|
370
472
|
if (closed || viewerEpoch !== epoch || viewers === 0)
|
|
371
473
|
return false;
|
|
474
|
+
if (sourceGeneration !== generation)
|
|
475
|
+
return false;
|
|
372
476
|
if (tracked.get(key) === version && computes.get(key) === compute) {
|
|
373
477
|
const entry = cache.get(key);
|
|
374
478
|
if (entry)
|
|
@@ -378,15 +482,18 @@ export function createSnapshotService(options) {
|
|
|
378
482
|
return true;
|
|
379
483
|
}
|
|
380
484
|
// Late poll results never resurrect an evicted key, overwrite a key loaded
|
|
381
|
-
// again mid-poll,
|
|
485
|
+
// again mid-poll, land in a viewer session that has ended, or cross a
|
|
486
|
+
// source-identity handoff.
|
|
382
487
|
if (closed || viewerEpoch !== epoch || viewers === 0)
|
|
383
488
|
return false;
|
|
489
|
+
if (sourceGeneration !== generation)
|
|
490
|
+
return false;
|
|
384
491
|
if (tracked.get(key) !== version || computes.get(key) !== compute)
|
|
385
492
|
return true;
|
|
386
493
|
const substantive = substantiveOf(snapshot);
|
|
387
494
|
const entry = cache.get(key);
|
|
388
495
|
const changedNow = entry === undefined || entry.stale || entry.substantive !== substantive;
|
|
389
|
-
cache.set(key, { snapshot, substantive, stale: false });
|
|
496
|
+
cache.set(key, { snapshot, substantive, stale: false, sourceGeneration: generation });
|
|
390
497
|
if (changedNow)
|
|
391
498
|
changed.add(topicFor(key));
|
|
392
499
|
return true;
|
|
@@ -426,9 +533,10 @@ export function createSnapshotService(options) {
|
|
|
426
533
|
}
|
|
427
534
|
if (closed || viewers === 0)
|
|
428
535
|
return;
|
|
429
|
-
// Visited once is not an active interest:
|
|
430
|
-
// analytics refresh or range derivation runs even
|
|
431
|
-
|
|
536
|
+
// Visited once is not an active interest: while every live viewer is on
|
|
537
|
+
// the quota surface, no analytics refresh or range derivation runs even
|
|
538
|
+
// though keys are loaded.
|
|
539
|
+
if (!analyticsViewActive())
|
|
432
540
|
return;
|
|
433
541
|
const epoch = viewerEpoch;
|
|
434
542
|
// Analytics interests are exactly the loaded home/project/session keys.
|
|
@@ -530,27 +638,31 @@ export function createSnapshotService(options) {
|
|
|
530
638
|
addViewer() {
|
|
531
639
|
if (closed)
|
|
532
640
|
return () => { };
|
|
533
|
-
|
|
534
|
-
if (viewers === 1)
|
|
535
|
-
startPollers();
|
|
641
|
+
retainViewer();
|
|
536
642
|
let released = false;
|
|
537
643
|
return () => {
|
|
538
644
|
if (released || closed)
|
|
539
645
|
return;
|
|
540
646
|
released = true;
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
647
|
+
releaseViewer();
|
|
648
|
+
};
|
|
649
|
+
},
|
|
650
|
+
addScopedViewer(scope) {
|
|
651
|
+
if (closed)
|
|
652
|
+
return { release: () => { } };
|
|
653
|
+
const id = nextScopedViewerId;
|
|
654
|
+
nextScopedViewerId += 1;
|
|
655
|
+
scopedViewers.set(id, scope);
|
|
656
|
+
retainViewer();
|
|
657
|
+
let released = false;
|
|
658
|
+
return {
|
|
659
|
+
release: () => {
|
|
660
|
+
if (released || closed)
|
|
661
|
+
return;
|
|
662
|
+
released = true;
|
|
663
|
+
scopedViewers.delete(id);
|
|
664
|
+
releaseViewer();
|
|
665
|
+
},
|
|
554
666
|
};
|
|
555
667
|
},
|
|
556
668
|
notifySettingsChanged(settingsOptions) {
|
|
@@ -580,6 +692,16 @@ export function createSnapshotService(options) {
|
|
|
580
692
|
if (origin === "signal")
|
|
581
693
|
viewScopeExplicit = true;
|
|
582
694
|
},
|
|
695
|
+
sourceChanged() {
|
|
696
|
+
if (closed)
|
|
697
|
+
return;
|
|
698
|
+
// The cached payloads remain useful as last-good fallback, but they must
|
|
699
|
+
// never be served as fresh data from the previous owner.
|
|
700
|
+
sourceGeneration += 1;
|
|
701
|
+
dirty();
|
|
702
|
+
emit({ topic: "quota.changed", at: now() });
|
|
703
|
+
emit({ topic: "sessions.changed", at: now() });
|
|
704
|
+
},
|
|
583
705
|
close() {
|
|
584
706
|
if (closed)
|
|
585
707
|
return;
|
|
@@ -595,6 +717,7 @@ export function createSnapshotService(options) {
|
|
|
595
717
|
cache.clear();
|
|
596
718
|
inflight.clear();
|
|
597
719
|
tracked.clear();
|
|
720
|
+
scopedViewers.clear();
|
|
598
721
|
},
|
|
599
722
|
};
|
|
600
723
|
}
|
package/dist/gui/sources.d.ts
CHANGED
|
@@ -76,7 +76,7 @@ export type DashboardReadSource = Pick<DashboardDataSource, "home" | "quota" | "
|
|
|
76
76
|
refreshAnalytics?(): Promise<void>;
|
|
77
77
|
/** Worker background-generation notifications (lazy; never starts analytics). */
|
|
78
78
|
subscribeAnalytics?(listener: () => void): () => void;
|
|
79
|
-
/** Final
|
|
79
|
+
/** Final host-dispose cleanup; closes the analytics worker. */
|
|
80
80
|
close?(): Promise<void>;
|
|
81
81
|
};
|
|
82
82
|
/**
|