codex-copilot-dx 0.9.28 → 0.9.30
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 +2 -2
- package/docs/ARCHITECTURE.md +19 -2
- package/docs/README.md +2 -0
- package/docs/REFERENCE.md +39 -11
- package/package.json +1 -1
- package/src/adapter.mjs +1 -1
- package/src/cli-options.mjs +1 -1
- package/src/dashboard/index.html +4 -2
- package/src/dashboard/language.js +10 -0
- package/src/dashboard/refresh.js +103 -0
- package/src/dashboard/theme.js +1 -1
- package/src/dashboard/ui.css +3 -1
- package/src/dashboard/ui.js +203 -117
- package/src/dashboard.mjs +1 -0
- package/src/http-transport.mjs +4 -135
- package/src/launcher.mjs +51 -3
- package/src/live-models.mjs +6 -9
- package/src/native-prediction.mjs +12 -6
- package/src/responses-proxy.mjs +3 -1
- package/src/upstream-body.mjs +137 -0
- package/src/upstream-headers.mjs +6 -0
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ enabled. The configured `dummy` API key is a placeholder, not a credential.
|
|
|
23
23
|
|
|
24
24
|
Open [the local dashboard](http://127.0.0.1:2026/) for status, model discovery,
|
|
25
25
|
usage, cache/limits, recent failures, request context and animation settings.
|
|
26
|
-
|
|
26
|
+
Auto refresh runs every 30 minutes while visible and can be switched off. Hidden pages pause; opening sections and manual refresh still work.
|
|
27
27
|
|
|
28
28
|
## Commands
|
|
29
29
|
|
|
@@ -56,7 +56,7 @@ The dashboard does not poll in the background; refresh when needed.
|
|
|
56
56
|
Codex, run `ccdx doctor`; fully quit the App (**Command-Q** on macOS) before reopening.
|
|
57
57
|
CCDX does not claim it can verify the App's internal model cache externally.
|
|
58
58
|
- After a package upgrade, restart the running CCDX adapter. Choosing a model or
|
|
59
|
-
effort on a current adapter takes effect on its next Auto-review request.
|
|
59
|
+
effort on a current adapter takes effect on its next Auto-review request. Native prediction ports persist on macOS/Windows; an older random route may need one full App quit. A busy saved port disables only predictions.
|
|
60
60
|
- `0.9.28` adds verified local plaintext recovery after connection-owned compaction rejection; see the reference for strict source and safety limits. Request-body bytes, local-history bytes and the model's token window are
|
|
61
61
|
different limits. Request-context figures are observed metadata, not exact
|
|
62
62
|
live session occupancy. Prompts and images are not retained by that panel.
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -42,8 +42,13 @@ TLS trust. Its private, credit-based pipes stream data without transcript files.
|
|
|
42
42
|
The App PAC delegates unrelated URLs to the company script; Node never executes
|
|
43
43
|
that script. This worker is not a shared inference/image network backend and is
|
|
44
44
|
not started for disabled predictions or static/direct configurations.
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
Bridge-port ownership is shared across macOS and Windows in the existing
|
|
46
|
+
prediction lifecycle, with locked first-start persistence and no replacement
|
|
47
|
+
on conflict. OS process inspection stays in the launcher/platform boundary;
|
|
48
|
+
it runs only for explicit prediction-enabled launch/reuse, not per model request.
|
|
49
|
+
macOS uses bounded system `ps` reads and Windows retains its existing registered
|
|
50
|
+
process checks. No process is stopped, no permanent watcher or dependency is
|
|
51
|
+
added. Core inference keeps its existing service port and lifecycle.
|
|
47
52
|
|
|
48
53
|
Connection-ownership replay rejection is a provider-owned retry policy. It
|
|
49
54
|
removes only unavailable reasoning once, preserving visible history and tools.
|
|
@@ -59,6 +64,18 @@ Without a complete verified local source, rejection still returns
|
|
|
59
64
|
metadata cannot reconstruct unavailable encrypted memory. LAN/browser callers
|
|
60
65
|
and referenced/split histories do not gain filesystem recovery access.
|
|
61
66
|
|
|
67
|
+
## Dashboard reads
|
|
68
|
+
|
|
69
|
+
`dashboard/refresh.js` owns the browser-only read lifecycle: one visible-page
|
|
70
|
+
timer, per-group in-flight deduplication, attempt freshness, cancellation and
|
|
71
|
+
last-good snapshots. `ui.js` owns rendering and user selections. Models, usage,
|
|
72
|
+
status/account and animation metadata remain independent resources; no timer
|
|
73
|
+
or data watcher is added to the Node service. Animation frames load once per
|
|
74
|
+
page when opened, and read refresh does not overwrite an unsaved choice.
|
|
75
|
+
`upstream-body.mjs` is the shared bounded response reader. The transport retains
|
|
76
|
+
its existing exports; live model lookup uses the same 8 MiB catalog limit as
|
|
77
|
+
core model discovery, without importing the request lifecycle or UI layer.
|
|
78
|
+
|
|
62
79
|
## Configuration ownership
|
|
63
80
|
|
|
64
81
|
`CODEX_HOME` selects Codex configuration. App profile/trust paths have their own
|
package/docs/README.md
CHANGED
|
@@ -17,6 +17,8 @@ These reports record a specific release and test environment. Their version,
|
|
|
17
17
|
test counts, timings, live-provider observations, and limitations remain
|
|
18
18
|
historical facts rather than current guarantees.
|
|
19
19
|
|
|
20
|
+
- [0.9.30: persistent prediction routes and verified macOS launch](RELEASE_0.9.30.md)
|
|
21
|
+
- [0.9.29: visible-page refresh, atom favicon and safe reasoning declarations](RELEASE_0.9.29.md)
|
|
20
22
|
- [0.9.28: verified local plaintext recovery and validation boundaries](RELEASE_0.9.28.md)
|
|
21
23
|
- [0.9.27: Windows certificate setup without Git/OpenSSL](RELEASE_0.9.27.md)
|
|
22
24
|
- [0.9.26: Windows native predictions, safe ownership recovery and dashboard disclosures](RELEASE_0.9.26.md)
|
package/docs/REFERENCE.md
CHANGED
|
@@ -82,15 +82,29 @@ profile override is preserved and the optional launch is skipped. There is no
|
|
|
82
82
|
shell, account replacement, new profile, `CODEX_HOME` change or forced App exit. Disabled predictions
|
|
83
83
|
add no Windows probe or launch. `CCDX_AUTO_LAUNCH=0` is still respected.
|
|
84
84
|
|
|
85
|
-
Windows
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
Since `0.9.30`, macOS and Windows remember their own loopback bridge port after
|
|
86
|
+
the first successful bridge start and reuse it across service restarts and
|
|
87
|
+
package updates. Windows already used this policy in `0.9.26`. Each user setup
|
|
88
|
+
gets its own port, not a shared fixed port. A busy saved port is not stolen or
|
|
89
|
+
silently replaced; only the optional prediction bridge becomes unavailable,
|
|
90
|
+
and core inference and enabled image tools can still start. Port settings are
|
|
91
|
+
committed under the existing file lock; a concurrent preference change aborts
|
|
92
|
+
and closes the uncommitted bridge. Restarting with a saved port does not rewrite
|
|
93
|
+
the preference or rotate certificates. Before launch, CCDX checks only verified App main-process route
|
|
88
94
|
metadata. A running App with an old/unreadable PAC receives an explicit quit and
|
|
89
95
|
relaunch instruction; it is not killed or reported as newly connected. The first
|
|
90
|
-
upgrade from an ephemeral-port
|
|
96
|
+
upgrade from an ephemeral-port version may require one full App quit. Successful
|
|
91
97
|
process creation is not proof of configuration traffic. A bounded post-launch
|
|
92
98
|
main-process check verifies retained PAC arguments; adapter readiness is reported
|
|
93
|
-
separately from App route readiness.
|
|
99
|
+
separately from App route readiness. macOS reads exact App main-process metadata
|
|
100
|
+
using the system `ps`, never prints complete process arguments, and polls only
|
|
101
|
+
for a bounded interval after a new launch, not while ordinary inference runs.
|
|
102
|
+
Matching running Apps are reused without relaunch. Unreadable or mismatched
|
|
103
|
+
routes get a warning, never a forced exit or an unverified success message.
|
|
104
|
+
The stable address prevents port-change failures; it does not replay interrupted
|
|
105
|
+
requests, clear App configuration caches or guarantee immediate gray suggestions
|
|
106
|
+
after every restart. Network-policy changes and App compatibility checks still
|
|
107
|
+
have the separate restart/setup requirements described below.
|
|
94
108
|
|
|
95
109
|
```bash
|
|
96
110
|
# Fully quit Codex App first.
|
|
@@ -162,8 +176,10 @@ trust removal is deferred; quit it and run `prediction off` again. Only the exac
|
|
|
162
176
|
owned certificate record is removed, never the whole store. Failed activation
|
|
163
177
|
rolls back newly added trust; certificate replacement keeps old trust until the
|
|
164
178
|
new preference is committed. If the bridge stops, new connections can fall back
|
|
165
|
-
to the original route; already-interrupted requests are not replayed.
|
|
166
|
-
|
|
179
|
+
to the original route; already-interrupted requests are not replayed. An App
|
|
180
|
+
already using the saved address need not be relaunched just because CCDX restarts.
|
|
181
|
+
If its route is missing or differs, fully quit Codex and run `ccdx` to attach it.
|
|
182
|
+
`CCDX_AUTO_LAUNCH=0` keeps
|
|
167
183
|
automatic launch disabled and does not attach the route to a manually opened App.
|
|
168
184
|
Optional prediction failures never prevent the core adapter or image service from
|
|
169
185
|
starting. `prediction status` reports the saved preference and, when a compatible
|
|
@@ -244,6 +260,18 @@ plaintext. Cross-machine/LAN recovery is intentionally unavailable. A full
|
|
|
244
260
|
plaintext replay can still exceed the upstream context window; this recovery
|
|
245
261
|
does not silently truncate it or add chunked re-compaction.
|
|
246
262
|
|
|
263
|
+
### Reasoning usage declaration
|
|
264
|
+
|
|
265
|
+
Native Responses success replies preserve `X-Reasoning-Included: true` only
|
|
266
|
+
when the upstream explicitly returns a case-insensitive literal `true`.
|
|
267
|
+
Missing, false or other values are not forwarded: current Codex treats header
|
|
268
|
+
presence as a declaration that historical reasoning is already counted.
|
|
269
|
+
CCDX does not infer that declaration from `output_tokens_details`, invent it,
|
|
270
|
+
add it to Chat-converted replies or HTTP/JSON failures, or change token totals.
|
|
271
|
+
Streaming headers describe the upstream declaration, not a guarantee that the
|
|
272
|
+
stream will later complete. This is compatibility metadata, not proof of lower
|
|
273
|
+
context use, faster inference or fewer compactions on every client.
|
|
274
|
+
|
|
247
275
|
### Fast and Standard modes
|
|
248
276
|
|
|
249
277
|
Codex can select Standard or Fast without changing CCDX configuration. When the client requests a model with `service_tier: "priority"`, CCDX uses its exact `-fast` model only when the live Copilot catalog advertises that variant as enabled, selectable, OpenAI-owned, and Responses-only. Standard mode continues to use the base model; CCDX does not invent Fast availability when the upstream catalog does not provide it. This retains the established `gpt-5.6-sol` / `gpt-5.6-sol-fast` mapping and applies the same exact-match rule to future models.
|
|
@@ -522,19 +550,19 @@ JSON reply to a streaming request is still not silently converted to SSE.
|
|
|
522
550
|
|
|
523
551
|
After starting `ccdx`, open [http://127.0.0.1:2026/](http://127.0.0.1:2026/) in a browser. If `ADAPTER_PORT` is customized, use that port instead. The dashboard shares the existing adapter listener; CCDX does not open a browser automatically or start another service. The page and its assets require both a loopback connection and a loopback Host header, even when LAN binding is enabled.
|
|
524
552
|
|
|
525
|
-
The dashboard loads local status, a live GitHub Copilot model directory, and a summary of local usage metadata once when opened.
|
|
553
|
+
The dashboard loads local status, a live GitHub Copilot model directory, and a summary of local usage metadata once when opened. The top Refresh updates status/account and expanded data groups; model and usage sections retain their own Refresh controls. Auto refresh is on by default, saved only in this browser, and updates status/account plus expanded groups every 30 minutes while the page is visible. Opening a data section updates its group unless it was attempted within 30 seconds. Hidden pages pause; returning after 30 minutes catches up once, without replaying missed intervals. Turning automatic updates off retains manual and open-section refresh. No server background task is added. In-flight reads are shared per group; failures retain the prior snapshot and success timestamp. Unchanged model rows and charts are retained rather than rebuilt. The appearance button switches between the default dark terminal theme (sun icon) and a light theme (moon icon); the choice is stored only in that browser. The Requests card shows the running adapter's active raw and decoded per-request body limits, not request-body usage; Local History shows its in-memory Responses history use and active limit. Limit changes remain CLI-only (`ccdx limits` and `ccdx cache`). The live model table uses the same fresh account validation and selectable GPT filtering as `ccdx models`, never labels cached fallback data as online, and makes no inference request. A catalog listing does not guarantee inference access. The Model Usage table combines the current and rotated local usage logs, shows totals and up to 100 model rows, and contains no prompt, response body, or credential fields. The animation selector previews the existing themes and saves through the same settings writer as `ccdx animation`; changes take effect on the next adapter start, and `CCDX_TERMINAL_ANIMATION=off` still disables terminal motion. Dashboard data requests require a custom header that cross-site simple requests cannot send; animation writes also require a matching same-origin `Origin`. The dashboard does not initialize the optional image handler. The overview's known-model count is the adapter's current in-memory catalog, not the live table. A missing image-generation status does not prove the feature is disabled: use `ccdx image-status` to check setup. Recent upstream error prose may contain sensitive details, so review the page before sharing screenshots.
|
|
526
554
|
|
|
527
555
|
The dashboard labels the upstream token cache hit metric **Reuse Rate** and cached input **Reused Input**, separate from **Local History**. Chinese uses short functional names such as “对话暂存”, “重用输入” and “重用比例”. English and Chinese preserve model IDs, commands, units, HTTP status codes and raw diagnostic values. Animation display names translate in place; theme IDs and CLI parameters do not change.
|
|
528
556
|
|
|
529
|
-
The transparent, single-color
|
|
557
|
+
The transparent, single-color atom-orbit favicon follows the dashboard's saved light/dark choice without a separate network request.
|
|
530
558
|
|
|
531
|
-
The saved GitHub Copilot account appears immediately to the left of the Status updated time. It uses the same local credentials and fingerprint-bound identity metadata as `ccdx auth status`, with username (or numeric ID fallback) and a `SAVED` label; this is not an online entitlement check. Missing, invalid, unidentified, or unreadable credentials are shown explicitly. The account read runs
|
|
559
|
+
The saved GitHub Copilot account appears immediately to the left of the Status updated time. It uses the same local credentials and fingerprint-bound identity metadata as `ccdx auth status`, with username (or numeric ID fallback) and a `SAVED` label; this is not an online entitlement check. Missing, invalid, unidentified, or unreadable credentials are shown explicitly. The account read runs on page load, top Refresh and visible-page automatic updates, independently of adapter status and without upstream authentication calls. Its timestamp is in the account tooltip; failed updates retain the prior account and explicitly label the failure. Its loopback-only, custom-header-protected API exposes no token, fingerprint, credential path, or raw metadata. The general status endpoint retains its existing identity-free contract.
|
|
532
560
|
|
|
533
561
|
Account names containing underscores are supported, including `dingxiao_microsoft`. A numeric ID is a fallback, not a replacement for an available, safely displayable username; the existing length bounds and credential-shaped text suppression still apply.
|
|
534
562
|
|
|
535
563
|
The language button immediately right of the appearance button switches between English and Simplified Chinese. English remains the default; the choice is saved only in the current browser, separately from light/dark mode. Switching translates the existing page in place: it does not fetch API data, rebuild charts, change selected filters, discard unsaved animation choices, or reset expanded failure details. Static labels, live status text, chart tooltips and accessibility labels follow the selected language. Model IDs, account names, dates, numeric values and upstream diagnostic prose stay unchanged; copied diagnostic fields retain their original names and values. The local translation asset adds no dependency, external service, polling or inference-path work.
|
|
536
564
|
|
|
537
|
-
Usage Trends is collapsed by default. Opening it adds daily input/output token bars (7/30/90 days) and a 365-day calendar of recorded usage calls or tokens, grouped in the browser's time zone. Cache-read tokens are already part of input and are not added again. Model and range filters use the current snapshot without additional requests; selecting a day shows its filtered model totals in the Model Usage table, and Show all restores the original table. Analytics shares the existing current/rotated-log scan and exposes only bounded metadata (365 days, up to 100 model filters). Days before retained history are hatched, not presented as zero; the oldest retained day may be partial. Counts describe retained usage records, not messages, session time, or all HTTP requests.
|
|
565
|
+
Usage Trends is collapsed by default. Opening it adds daily input/output token bars (7/30/90 days) and a 365-day calendar of recorded usage calls or tokens, grouped in the browser's time zone. Cache-read tokens are already part of input and are not added again. Model and range filters use the current snapshot without additional requests; selecting a day shows its filtered model totals in the Model Usage table, and Show all restores the original table. Analytics shares the existing current/rotated-log scan and exposes only bounded metadata (365 days, up to 100 model filters). Days before retained history are hatched, not presented as zero; the oldest retained day may be partial. Counts describe retained usage records, not messages, session time, or all HTTP requests. Open-section, manual and visible-page automatic refresh update the snapshot. Analytics are requested only while expanded inside the open usage section or while a day filter needs them. Filters and selected dates survive refresh; a closed unfiltered chart reuses its displayed data until reopened. There is no server background collection.
|
|
538
566
|
|
|
539
567
|
Terminal Animation is collapsed at the bottom of the page, with an Animation shortcut in the header. Preview frames load only when opened; closing it, hiding the page, or requesting reduced motion stops the preview timer. Unsaved choices survive folding and reopening. Recent response failures expand to diagnostic fields (time, model, code, message, response/request IDs, and retry policy) with a Copy details control. The view combines the last 10 retained `response.failed` events with failures from the 20 most recently finished Responses/compact requests, showing at most 10 entries. Matching local request IDs attach the final outcome and timing metadata, so a recovered event can show `completed`; an uncorrelated retry attempt does not prove recovery. Transport failures and incomplete/cancelled requests can appear without a `response.failed` event. These are bounded runtime observations, not complete session histories. Diagnostic prose is redacted by the existing recorder but can still contain sensitive context: review before copying or sharing.
|
|
540
568
|
|
package/package.json
CHANGED
package/src/adapter.mjs
CHANGED
|
@@ -63,7 +63,7 @@ export {
|
|
|
63
63
|
} from "./responses-request.mjs";
|
|
64
64
|
|
|
65
65
|
const ADAPTER_RUNTIME_CONFIG = loadRuntimeConfig();
|
|
66
|
-
const DASHBOARD_PATHS = new Set(["/", "/ui.css", "/theme.js", "/language.js", "/ui.js"]);
|
|
66
|
+
const DASHBOARD_PATHS = new Set(["/", "/ui.css", "/theme.js", "/language.js", "/refresh.js", "/ui.js"]);
|
|
67
67
|
const DASHBOARD_API_PATHS = new Set(["/_ccdx/ui/animation", "/_ccdx/ui/models/live", "/_ccdx/ui/usage", "/_ccdx/ui/auth"]);
|
|
68
68
|
|
|
69
69
|
export function requestPath(reqUrl) {
|
package/src/cli-options.mjs
CHANGED
|
@@ -372,7 +372,7 @@ function topicHelp(name, topic) {
|
|
|
372
372
|
"image-status": `Usage:\n ${name} image-status\n\nShows provider configuration and locally advertised generation/editing tools without generating an image or exposing its API key.`,
|
|
373
373
|
"auto-review-model": `Usage:\n ${name} auto-review-model\n\nSelect a Responses model, then an advertised reasoning effort. Enter keeps the default/current choice; q cancels both steps without saving. Effort 0 follows the client (low when omitted). Settings apply only to Auto-review on the next request; no client patch or restart is required for adapters running 0.9.13 or newer.`,
|
|
374
374
|
"suggestion": `The CCDX prediction panel has been retired. Run ${name} suggestion off to safely remove unchanged CCDX registrations. This cleanup does not change native predictions; see ${name} prediction --help for that separate opt-in feature.`,
|
|
375
|
-
prediction: `Usage:\n ${name} prediction [status|on|off]\n\nOptional native next-message predictions; off by default. macOS and Windows
|
|
375
|
+
prediction: `Usage:\n ${name} prediction [status|on|off]\n\nOptional native next-message predictions; off by default. macOS and Windows. Windows requires the registered official MSIX App, an initialized profile, Windows PowerShell and .NET Framework 4.7.2+; Git/OpenSSL is not required for prediction setup. Quit Codex before on/off, then restart ccdx. On adds private App-profile certificate trust and an App-only route for chatgpt.com and ab.chatgpt.com. HTTPS on those hosts is decrypted locally; only prediction configuration is changed. No client program files, OS trust, account permissions, MCP or Hooks are changed. Static HTTP/HTTPS/SOCKS5 proxies and bypass rules are preserved. Windows supports company PAC/WPAD; macOS dynamic PAC/WPAD and CIDR bypass rules are reported as unsupported. The bridge port persists across restarts/updates; a busy saved port disables only predictions. Launch/reuse checks the App's actual route; an older random or missing route may require one full App quit. Official prediction configuration is preserved; the conversation's model is used. App updates require another compatibility check. Status distinguishes saved preference and observed config traffic from unverified candidate visibility.`,
|
|
376
376
|
update: `Usage:\n ${name} update [npm|github]\n\nUpdates the global package from the configured npm registry or the latest stable GitHub release. With no source, an interactive terminal prompts for one.`,
|
|
377
377
|
version: `Usage:\n ${name} --version`,
|
|
378
378
|
};
|
package/src/dashboard/index.html
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
<script src="/language.js"></script>
|
|
9
9
|
<script src="/theme.js"></script>
|
|
10
10
|
<link rel="stylesheet" href="/ui.css">
|
|
11
|
+
<script src="/refresh.js" defer></script>
|
|
11
12
|
<script src="/ui.js" defer></script>
|
|
12
13
|
<title data-i18n>CCDX · Local dashboard</title>
|
|
13
14
|
</head>
|
|
@@ -15,7 +16,7 @@
|
|
|
15
16
|
<div class="shell">
|
|
16
17
|
<header class="topbar">
|
|
17
18
|
<div class="brand">CCDX <span class="brand-detail" data-i18n>/ LOCAL STATUS</span></div>
|
|
18
|
-
<div class="topbar-actions"><span id="connection" class="badge neutral" role="status" data-i18n>READING</span><button id="theme-toggle" class="icon-button" type="button" aria-label="Switch to light mode" title="Switch to light mode"><svg class="icon-sun" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="4"/><path d="M12 2v2m0 16v2M4.93 4.93l1.42 1.42m11.3 11.3 1.42 1.42M2 12h2m16 0h2M4.93 19.07l1.42-1.42m11.3-11.3 1.42-1.42"/></svg><svg class="icon-moon" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false"><path d="M12 3A9 9 0 1 0 21 12 7 7 0 0 1 12 3Z"/></svg></button><button id="language-toggle" class="icon-button language-button" type="button" aria-label="Switch to Chinese" title="Switch to Chinese">中文</button><button id="open-animation" type="button" aria-controls="animation-settings" aria-expanded="false" data-i18n>Animation</button><button id="refresh" type="button" data-i18n>Refresh</button></div>
|
|
19
|
+
<div class="topbar-actions"><span id="connection" class="badge neutral" role="status" data-i18n>READING</span><button id="theme-toggle" class="icon-button" type="button" aria-label="Switch to light mode" title="Switch to light mode"><svg class="icon-sun" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="4"/><path d="M12 2v2m0 16v2M4.93 4.93l1.42 1.42m11.3 11.3 1.42 1.42M2 12h2m16 0h2M4.93 19.07l1.42-1.42m11.3-11.3 1.42-1.42"/></svg><svg class="icon-moon" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false"><path d="M12 3A9 9 0 1 0 21 12 7 7 0 0 1 12 3Z"/></svg></button><button id="language-toggle" class="icon-button language-button" type="button" aria-label="Switch to Chinese" title="Switch to Chinese">中文</button><button id="open-animation" type="button" aria-controls="animation-settings" aria-expanded="false" data-i18n>Animation</button><button id="auto-refresh" type="button" aria-pressed="true" data-i18n data-i18n-title title="Every 30 minutes while visible. Open sections update on demand.">Auto refresh</button><button id="refresh" type="button" data-i18n>Refresh</button></div>
|
|
19
20
|
</header>
|
|
20
21
|
|
|
21
22
|
<main>
|
|
@@ -86,6 +87,7 @@
|
|
|
86
87
|
<label><span data-i18n>Activity</span> <select id="analytics-metric"><option value="requests" data-i18n>Calls</option><option value="tokens" data-i18n>Tokens</option></select></label>
|
|
87
88
|
</div>
|
|
88
89
|
<p id="analytics-note" class="table-note" role="status" data-i18n>Open to read retained usage history.</p>
|
|
90
|
+
<p id="analytics-updated" class="refresh-time"></p>
|
|
89
91
|
<div class="chart-heading"><h3 data-i18n>DAILY TOKENS</h3><span data-i18n>INPUT + OUTPUT / CACHE INCLUDED IN INPUT</span></div>
|
|
90
92
|
<div id="daily-bars" class="daily-bars" aria-label="Daily token usage" data-i18n-label></div>
|
|
91
93
|
<div class="daily-axis"><span id="daily-from"></span><span id="daily-to"></span></div>
|
|
@@ -109,7 +111,7 @@
|
|
|
109
111
|
</details>
|
|
110
112
|
</main>
|
|
111
113
|
|
|
112
|
-
<footer data-i18n>LOCAL ONLY /
|
|
114
|
+
<footer data-i18n>LOCAL ONLY / VISIBLE PAGE UPDATES</footer>
|
|
113
115
|
</div>
|
|
114
116
|
</body>
|
|
115
117
|
</html>
|
|
@@ -23,6 +23,16 @@
|
|
|
23
23
|
"LOCAL OK": ["LOCAL OK", "本机正常"],
|
|
24
24
|
"UNAVAILABLE": ["UNAVAILABLE", "无法读取"],
|
|
25
25
|
"Refresh": ["Refresh", "刷新"],
|
|
26
|
+
"Auto refresh": ["Auto refresh", "自动更新"],
|
|
27
|
+
"Auto refresh / ON": ["Auto refresh · ON", "自动更新 · 开"],
|
|
28
|
+
"Auto refresh / OFF": ["Auto refresh · OFF", "自动更新 · 关"],
|
|
29
|
+
"Every 30 minutes while visible. Open sections update on demand.": ["Every 30 minutes while visible. Opening a section updates it.", "可见时每30分钟更新。\n展开区域也会更新。"],
|
|
30
|
+
"LOCAL ONLY / VISIBLE PAGE UPDATES": ["LOCAL ONLY / UPDATES WHILE VISIBLE", "仅限本机 / 页面可见时更新"],
|
|
31
|
+
"Updated {time}": ["Updated {time}", "更新于{time}"],
|
|
32
|
+
"Saved account / updated {time}": ["Saved account only / updated {time}", "本机保存账号 / 更新于{time}"],
|
|
33
|
+
"Update failed / last {time}": ["Update failed / last {time}", "更新失败 / 上次{time}"],
|
|
34
|
+
"Update failed": ["Update failed", "更新失败"],
|
|
35
|
+
"GitHub / {account} / UPDATE FAILED": ["GitHub / {account} / UPDATE FAILED", "GitHub / {account} / 更新失败"],
|
|
26
36
|
"Animation": ["Animation", "动效"],
|
|
27
37
|
"Switch to light mode": ["Light mode", "白天模式"],
|
|
28
38
|
"Switch to dark mode": ["Dark mode", "夜间模式"],
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
const interval = 30 * 60 * 1000;
|
|
3
|
+
const freshness = 30 * 1000;
|
|
4
|
+
|
|
5
|
+
function createController({ resources, visible, now = Date.now, setTimer = setTimeout, clearTimer = clearTimeout }) {
|
|
6
|
+
const states = new Map(Object.keys(resources).map(key => [key, {
|
|
7
|
+
value: undefined, signature: undefined, variant: undefined, pending: null,
|
|
8
|
+
updatedAt: null, attemptedAt: null, error: null, generation: 0, abort: null,
|
|
9
|
+
}]));
|
|
10
|
+
let timer = null;
|
|
11
|
+
let active = true;
|
|
12
|
+
let automatic = true;
|
|
13
|
+
const state = key => states.get(key);
|
|
14
|
+
const stopTimer = () => { if (timer !== null) clearTimer(timer); timer = null; };
|
|
15
|
+
const notify = key => resources[key].state?.(state(key));
|
|
16
|
+
|
|
17
|
+
function schedule() {
|
|
18
|
+
stopTimer();
|
|
19
|
+
if (!active || !automatic || !visible()) return;
|
|
20
|
+
timer = setTimer(() => {
|
|
21
|
+
timer = null;
|
|
22
|
+
refreshVisible();
|
|
23
|
+
schedule();
|
|
24
|
+
}, interval);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function refresh(key, { force = false } = {}) {
|
|
28
|
+
if (!active) return;
|
|
29
|
+
const resource = resources[key];
|
|
30
|
+
const entry = state(key);
|
|
31
|
+
const variant = resource.variant?.() || "";
|
|
32
|
+
if (entry.pending) {
|
|
33
|
+
const pending = entry.pending;
|
|
34
|
+
const generation = entry.generation;
|
|
35
|
+
if (entry.pendingVariant === variant) return pending;
|
|
36
|
+
await pending;
|
|
37
|
+
if (!active || generation !== entry.generation) return entry.pending;
|
|
38
|
+
return refresh(key, { force: true });
|
|
39
|
+
}
|
|
40
|
+
if (!force && entry.attemptVariant === variant && entry.attemptedAt !== null && now() - entry.attemptedAt < freshness) return entry.value;
|
|
41
|
+
const generation = ++entry.generation;
|
|
42
|
+
const abort = new AbortController();
|
|
43
|
+
entry.abort = abort;
|
|
44
|
+
entry.attemptedAt = now();
|
|
45
|
+
entry.attemptVariant = variant;
|
|
46
|
+
entry.pendingVariant = variant;
|
|
47
|
+
entry.error = null;
|
|
48
|
+
entry.pending = Promise.resolve().then(async () => {
|
|
49
|
+
try {
|
|
50
|
+
const value = await resource.load({ variant, signal: abort.signal });
|
|
51
|
+
if (!active || generation !== entry.generation) return;
|
|
52
|
+
const signature = JSON.stringify(resource.project ? resource.project(value) : value);
|
|
53
|
+
const changed = signature !== entry.signature;
|
|
54
|
+
resource.apply(value, { changed });
|
|
55
|
+
entry.value = value;
|
|
56
|
+
entry.signature = signature;
|
|
57
|
+
entry.variant = variant;
|
|
58
|
+
entry.updatedAt = now();
|
|
59
|
+
return value;
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (active && generation === entry.generation) entry.error = error;
|
|
62
|
+
} finally {
|
|
63
|
+
if (generation === entry.generation) {
|
|
64
|
+
entry.pending = null;
|
|
65
|
+
entry.abort = null;
|
|
66
|
+
notify(key);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
notify(key);
|
|
71
|
+
return entry.pending;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function refreshVisible({ force = false } = {}) {
|
|
75
|
+
if (!active || !visible()) return Promise.resolve([]);
|
|
76
|
+
return Promise.all(Object.keys(resources).filter(key => resources[key].visible())
|
|
77
|
+
.filter(key => force || state(key).attemptedAt === null || now() - state(key).attemptedAt >= interval)
|
|
78
|
+
.map(key => refresh(key, { force })));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function invalidate(key) {
|
|
82
|
+
const entry = state(key);
|
|
83
|
+
entry.generation += 1;
|
|
84
|
+
entry.abort?.abort();
|
|
85
|
+
entry.pending = null;
|
|
86
|
+
entry.abort = null;
|
|
87
|
+
entry.attemptedAt = null;
|
|
88
|
+
entry.variant = undefined;
|
|
89
|
+
notify(key);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
refresh, refreshVisible, state, invalidate,
|
|
94
|
+
setAutomatic(value) { automatic = value === true; if (automatic) refreshVisible(); schedule(); },
|
|
95
|
+
visibilityChanged() { if (automatic && visible()) refreshVisible(); schedule(); },
|
|
96
|
+
resume() { active = true; if (automatic) refreshVisible(); schedule(); },
|
|
97
|
+
suspend() { active = false; stopTimer(); for (const key of states.keys()) if (state(key).pending) invalidate(key); },
|
|
98
|
+
get automatic() { return automatic; },
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
globalThis.ccdxRefresh = { createController };
|
|
103
|
+
})();
|
package/src/dashboard/theme.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
const applyTheme = () => {
|
|
8
8
|
document.documentElement.dataset.theme = theme;
|
|
9
9
|
const color = theme === "dark" ? "#a6f5a8" : "#176b3a";
|
|
10
|
-
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><
|
|
10
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><g fill="none" stroke="${color}" stroke-width="3" stroke-linecap="round"><ellipse cx="32" cy="32" rx="26" ry="10"/><ellipse cx="32" cy="32" rx="26" ry="10" transform="rotate(60 32 32)"/><ellipse cx="32" cy="32" rx="26" ry="10" transform="rotate(120 32 32)"/></g><circle cx="32" cy="32" r="4.5" fill="${color}"/></svg>`;
|
|
11
11
|
document.getElementById("favicon").href = `data:image/svg+xml,${encodeURIComponent(svg)}`;
|
|
12
12
|
};
|
|
13
13
|
applyTheme();
|
package/src/dashboard/ui.css
CHANGED
|
@@ -129,7 +129,9 @@ select { max-width: 260px; padding: 5px; font: inherit; color: var(--text); back
|
|
|
129
129
|
.calendar-day[data-level="3"] { background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); }
|
|
130
130
|
.calendar-day[data-level="4"] { background: var(--accent-soft); }
|
|
131
131
|
.calendar-day:disabled, .daily-bar:disabled { background: repeating-linear-gradient(135deg, transparent, transparent 3px, var(--border) 3px, var(--border) 4px); opacity: .5; cursor: default; }
|
|
132
|
-
footer { color: var(--footer); font-size: 10px; letter-spacing: .05em; padding: 22px 0 30px; }
|
|
132
|
+
footer { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; color: var(--footer); font-size: 10px; letter-spacing: .05em; padding: 22px 0 30px; }
|
|
133
|
+
#auto-refresh[aria-pressed="false"] { background: transparent; color: var(--muted); border-color: var(--border); }
|
|
134
|
+
.refresh-time { display: block; margin: 10px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
|
|
133
135
|
@media (max-width: 1000px) { .animation-options { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
|
134
136
|
@media (max-width: 900px) { .overview { grid-template-columns: repeat(2, minmax(0, 1fr)); } .details { grid-template-columns: repeat(2, minmax(0, 1fr)); } .details .panel:last-child { grid-column: 1 / -1; } }
|
|
135
137
|
@media (max-width: 680px) { .animation-options { grid-template-columns: 1fr; } }
|