codex-copilot-dx 1.2.10 → 1.2.11

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 CHANGED
@@ -14,7 +14,7 @@ npm install -g codex-copilot-dx@latest
14
14
  ccdx
15
15
  ```
16
16
 
17
- No Node or Git? Download [install.sh](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.10/install.sh) (macOS/Linux) or [install.ps1](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.10/install.ps1) (Windows), then run `sh install.sh` or `./install.ps1` under your current shell policy. The bootstrap reuses compatible Node/npm or installs verified official Node 24.22.0 privately for CCDX. It adds no Git, compiler or system package manager. It keeps registry/proxy/certificate policy, verifies the Release package and installed runtime, and restores the prior CCDX package if installation fails. Dependencies still need your configured registry. See [installation limits and private command paths](docs/REFERENCE.md#install-without-node-or-git).
17
+ No Node or Git? Download [install.sh](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.11/install.sh) (macOS/Linux) or [install.ps1](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.11/install.ps1) (Windows), then run `sh install.sh` or `./install.ps1` under your current shell policy. The bootstrap reuses compatible Node/npm or installs verified official Node 24.22.0 privately for CCDX. It adds no Git, compiler or system package manager. It keeps registry/proxy/certificate policy, verifies the Release package and installed runtime, and restores the prior CCDX package if installation fails. Dependencies still need your configured registry. See [installation limits and private command paths](docs/REFERENCE.md#install-without-node-or-git).
18
18
 
19
19
  CCDX reuses a compatible local credential or starts GitHub Device Flow, listens on `127.0.0.1:2026`, configures Codex, and opens the App. Interactive desktop starts also open the local WebUI once; use `ccdx --no-browser` or disable this in WebUI settings. No client binary patch is needed. On Windows, open the App manually unless native prediction setup is enabled. In restricted Windows PowerShell, use `npm.cmd` to install and `ccdx.cmd` for the first launch, or run `ccdx.cmd doctor --fix`. Startup, updates and explicit repair remove only CCDX's exact npm-generated `.ps1` launchers so later calls can use `ccdx`. The npm package adds no install hook or policy change; custom launchers are preserved. npm's own script is untouched. The configured `dummy` API key is a placeholder, not a credential.
20
20
 
@@ -25,7 +25,7 @@ Startup shows bounded checks, sources with discovered model lists and Claude Cod
25
25
  WebUI settings apply animation choices live, pause/resume configured image calls and prediction adaptation without removing credentials/trust, change the Codex source explicitly, and manage the conversation-buffer limit. Saved preference and effective state are separate; browser opening is labeled for the next start. Clearing the conversation buffer clears **all** buffered continuations. Busy cleanup is refused; retry after active requests finish. Saved Codex transcripts are retained. First-time image/prediction setup still uses the existing CLI; trust, client routing and cached client capabilities may require a normal App relaunch. Busy M365 requests must finish before disabling that provider. Settings also offers independent webpage/terminal colors: classic green (default), Klein blue or Soft pink. Web colors stay in this browser; terminal colors persist locally. Failed saves are reported. See the [control reference](docs/REFERENCE.md#control-console-and-online-settings).
26
26
 
27
27
  While visible and auto-refresh is on, the console reads the small status snapshot about every two seconds and source/settings evidence about every 16 seconds. Catalogs and retained usage are fetched on demand and at most once per 30-minute refresh interval while their view is open. Hidden pages stop scheduled reads. First output uses **ms**, estimated speed **token/s**, and each protocol has its own samples. HTTP traffic includes catalog and routing requests; it is not a conversation count.
28
- The **Requests by source** section and `ccdx status` separate request outcomes by source and protocol. Process-local returned usage also retains bounded source totals; missing usage remains partial. Configuration, sign-in, discovery and a completed reply remain separate evidence. CLI text stays English; WebUI stays bilingual. WebUI uses solid selected controls and independent webpage/terminal appearance. See the [copy inventory](https://github.com/DaleXiao/codex-copilot-dx/blob/main/docs/UX_COPY.md) and [1.2.0 verification](https://github.com/DaleXiao/codex-copilot-dx/blob/main/docs/RELEASE_1.2.0.md).
28
+ The **Requests** view shows live app/source/model flow above the source summary and finished records. Motion follows observed output; waiting, retries, idle and expired status stay distinct. Name selections filter active details only. Unmarked clients remain unspecified. Codex/Claude performance includes approximate first-output P50/P95 with sample counts. CLI stays English; WebUI keeps both languages and the existing palettes. See [1.2.11 changes and verification](https://github.com/DaleXiao/codex-copilot-dx/blob/main/docs/RELEASE_1.2.11.md) and the [copy inventory](https://github.com/DaleXiao/codex-copilot-dx/blob/main/docs/UX_COPY.md).
29
29
 
30
30
  ## Commands
31
31
  | Command | Purpose |
@@ -437,7 +437,7 @@ The Claude gateway still relays original native SSE bytes. `stream-performance.m
437
437
 
438
438
  ## Dashboard layout and information scopes (1.2.9)
439
439
 
440
- The existing CSS grid reserves explicit header/body/footer tracks; the body owns spare space from the full-height sidebar. The header uses an opaque themed sticky surface, stable action slots and a deliberate compact toolbar. Scrollbar space is stable, with an always-scroll fallback for older engines. `console.js` owns route titles/descriptions, scroll reset and main-content focus; refresh code does not navigate or reset scroll.
440
+ The existing CSS grid reserves explicit header/body/footer tracks; the body owns spare space from the full-height sidebar. The header uses an opaque themed sticky surface, stable action slots and a deliberate compact toolbar. Scrollbar space is stable, with an always-scroll fallback for older engines. `console.js` owns route titles, scroll reset and main-content focus; refresh code does not navigate or reset scroll.
441
441
 
442
442
  The eight existing views remain. `status.js` groups Overview clients by application using explicit selected-source evidence, retains all registered sources and projects separate Claude setup rows without inventing per-app Messages metrics. Account controls, catalog and access rows share the selected source in `ui.js`; source-management shortcuts browse without switching inference routes. Existing resource generations, cancellation, last-good snapshots and refresh cadence remain unchanged. Timestamps follow their own status/source/catalog/usage resources. Animation reads also check that Settings is visible.
443
443
 
@@ -461,3 +461,39 @@ visible square keyboard focus outline. Model names and metadata use readable tex
461
461
  roles rather than accent colors. The catalog's technical fields remain available
462
462
  in per-model details. Usage trends and summaries are peer panels, still loaded on
463
463
  demand. Saved/effective preference differences are shown only when relevant.
464
+
465
+
466
+ ## Active request projection and restrained motion (1.2.11)
467
+
468
+ `stream-performance.mjs` remains the timing/outcome owner. Each metrics instance
469
+ retains at most 64 active snapshot closures; `finish` removes them idempotently.
470
+ The exact active total and omitted-detail count remain separate. Snapshots copy
471
+ only allowlisted application/source/model labels, request IDs, phase, elapsed
472
+ values and up to three attempt records. No body, headers, credentials or account
473
+ identity enters this projection. Existing recent records remain capped at 20.
474
+ `request-application.mjs` shares pure presentation-only hint normalization between
475
+ the adapter and Claude gateway. Hints are not authenticated identity or routing
476
+ inputs. Unmarked Claude traffic is not assigned to a specific Claude app.
477
+
478
+ The existing status snapshot carries this metadata; `dashboard/flow.js` adds no
479
+ poller, model call or routing controller. It groups up to 128 active detail rows
480
+ from the two metrics instances, initially shows at most 12 model groups, and
481
+ keeps counts outside name selections. Selection filters only active details;
482
+ source totals and finished records retain their scope. Rounded SVG path geometry
483
+ is rebuilt only for meaningful group/state/layout changes. CSS packets indicate
484
+ observed first output, waiting attempts are static, and idle has one breathing
485
+ lamp. Hidden views pause motion, reduced-motion stays static, and six seconds
486
+ without a fresh snapshot stops animation and labels retained data as last observed.
487
+ There is no perpetual JavaScript animation loop.
488
+
489
+ P50/P95 reuse existing fixed histograms. Estimates use the nearest-rank bucket
490
+ upper bound capped by the observed maximum; the open-ended bucket uses that
491
+ maximum. Empty histograms return null. Samples and the approximation label remain
492
+ visible; partial-output failures are included in first-output timing. No raw
493
+ sample list, new scoring, automatic failover or affinity policy is introduced.
494
+
495
+ The eight views keep their established palettes and controls. Page-opening
496
+ instructions are removed; operation scope, effect timing and privacy remain near
497
+ the relevant controls or in details. Tables retain header/interior separators;
498
+ the last row and following details use whitespace. Programmatic main-content
499
+ focus has no frame; interactive keyboard focus remains visible.
package/docs/REFERENCE.md CHANGED
@@ -804,7 +804,7 @@ animation styles retain their timing and cycle pauses; the default green retains
804
804
  `--show-request-id` or `CCDX_LOG_LEVEL=debug` restore detailed terminal output.
805
805
  Failed reads show previous-data status and the last successful update time, or that no data has been received. Narrow summaries wrap rather than hiding Claude App/Code state. Non-TTY/CI/dumb/too-small terminals use plain output; repeated identical notices
806
806
  are coalesced. File logging retains its existing explicit opt-in and redaction.
807
- In-memory usage still updates when `CCDX_DISABLE_USAGE=1` disables persistence. `runtime_usage.by_provider` separates returned process-local usage by source. The Requests view contains Requests by source, recent failures and request context; `ccdx status` also lists source/protocol outcomes. Unknown outcomes and partial usage remain distinct. CLI remains English; WebUI keeps English/Chinese.
807
+ In-memory usage still updates when `CCDX_DISABLE_USAGE=1` disables persistence. `runtime_usage.by_provider` separates returned process-local usage by source. The Requests view contains live Request flow, Requests by source, recent failures and request context; `ccdx status` also lists source/protocol outcomes. Unknown outcomes and partial usage remain distinct. CLI remains English; WebUI keeps English/Chinese.
808
808
 
809
809
  The Clear conversation buffer action clears all process-local conversation continuation data. If image optimization or conversation history is active, cleanup is refused; retry after current requests finish. Old chats may fail to continue; saved Codex transcripts remain. It invokes the existing image-transform/history cleanup operation, rather than an inactive-only selector.
810
810
 
@@ -1037,7 +1037,7 @@ Unknown support prevents an explicitly requested exception from starting.
1037
1037
  For an older updater that still requires Git, install the Release tarball directly:
1038
1038
 
1039
1039
  ```sh
1040
- npm install -g https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.10/codex-copilot-dx-1.2.10.tgz
1040
+ npm install -g https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.11/codex-copilot-dx-1.2.11.tgz
1041
1041
  # Windows PowerShell: use npm.cmd instead of npm.
1042
1042
  ```
1043
1043
 
@@ -1588,3 +1588,39 @@ From a source checkout, `node scripts/codex-message-id-replay.mjs --codex /absol
1588
1588
  ## License
1589
1589
 
1590
1590
  MIT
1591
+
1592
+
1593
+ ### Live request flow and timing estimates
1594
+
1595
+ Request flow is a read-only view of active Responses, Responses compaction and
1596
+ Claude Messages requests observed by CCDX; it excludes image-MCP, token counting,
1597
+ catalog and management calls. It groups
1598
+ apps and source/model pairs; a model used through two sources stays separate.
1599
+ `X-CCDX-Client` recognizes `codex-app`, `codex-cli`, `claude-app`, `claude-code`;
1600
+ known Codex `originator` values also provide labels. These are presentation hints,
1601
+ not verified identities. Unknown clients remain API client; unmarked Messages
1602
+ requests remain Claude (app unspecified). No user-agent inference is used.
1603
+
1604
+ Only observed first output starts moving dots. A started attempt without output
1605
+ is waiting, a subsequent attempt is retrying, and terminal evidence awaiting
1606
+ connection completion is finishing. No fresh status for six seconds means unknown,
1607
+ not idle or successful. Auto refresh off therefore expires the view. Hidden pages
1608
+ pause animation; reduced-motion uses static dots. Idle retains bounded last-known
1609
+ nodes with zero counts; unknown retained counts are dashes. Initially up to 12
1610
+ model groups are visible, with an explicit show-more control. Snapshots retain up
1611
+ to 64 details per metrics instance; exact active totals may be higher and omitted
1612
+ details are reported. With omitted details, observed group counts use ≥; retained
1613
+ nodes with no current detail use dashes, even while the exact total is active. Short requests between two status reads can appear only in
1614
+ the finished table; the diagram does not fabricate or replay them.
1615
+
1616
+ Clicking an app or model name filters only active details. Counts, source totals,
1617
+ all five terminal outcomes (including unknown), last 20 finished requests and
1618
+ issues remain available. No prompt/image/credential is added to active telemetry.
1619
+ The existing local-dashboard host/origin protections apply to the new flow asset.
1620
+
1621
+ Codex and Claude request-performance panels show approximate first-output P50/P95
1622
+ in milliseconds with sample counts. Values come from existing histogram buckets,
1623
+ not raw samples; the highest bucket uses the observed maximum. These are the
1624
+ upstream first-output observations already used for the mean, include failures
1625
+ after partial output, and do not measure user-perceived completion or promise a
1626
+ routing improvement. No samples displays a dash.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-copilot-dx",
3
- "version": "1.2.10",
3
+ "version": "1.2.11",
4
4
  "description": "Local Codex adapter and optional Microsoft 365 Claude gateway",
5
5
  "author": "Dale Xiao",
6
6
  "type": "module",
package/src/adapter.mjs CHANGED
@@ -9,6 +9,7 @@ import {
9
9
  runtimeStatusPayload,
10
10
  } from "./observability.mjs";
11
11
  import { createRequestId, runWithRequestContext, currentRequestContext } from "./request-context.mjs";
12
+ import { requestApplication } from "./request-application.mjs";
12
13
  import { createStreamPerformanceMetrics } from "./stream-performance.mjs";
13
14
  import { status } from "./status.mjs";
14
15
  import { createTerminalActivityIndicator } from "./terminal-activity.mjs";
@@ -380,7 +381,7 @@ export function createAdapterHandler(options = {}) {
380
381
  && !((req.method === "GET" || req.method === "HEAD") && DASHBOARD_PATHS.has(pathname));
381
382
  const routeName = classifyAdapterRoute(req.method, pathname);
382
383
  const complete = trackRequest ? requestMetrics.begin(routeName) : () => {};
383
- const streamPerformance = trackRequest ? streamPerformanceMetrics.begin(routeName, { requestId }) : null;
384
+ const streamPerformance = trackRequest ? streamPerformanceMetrics.begin(routeName, { requestId, application: requestApplication(req.headers) }) : null;
384
385
  let finishTerminalActivity = () => {};
385
386
  if (trackRequest && ["responses", "responses_compact", "messages", "image_mcp"].includes(routeName)) {
386
387
  try {
@@ -13,6 +13,7 @@ import { buildMessagesUsageRecord, recordUsage } from "./usage-store.mjs";
13
13
  import { redactDiagnosticText } from "./diagnostic-text.mjs";
14
14
  import { decodedBodyLimitPreference } from "./user-settings.mjs";
15
15
  import { operationErrorDetails } from "./operation-error.mjs";
16
+ import { requestApplication } from "./request-application.mjs";
16
17
 
17
18
  function send(res, code, value) {
18
19
  if (res.destroyed || res.writableEnded) return;
@@ -81,7 +82,7 @@ export function createClaudeGatewayHandler({ provider, apiKey, log = () => {}, o
81
82
  const parent = currentRequestContext();
82
83
  if (parent) parent.provider = provider.id;
83
84
  const countTokens = pathname.endsWith("/count_tokens"), requestId = parent?.requestId || randomUUID();
84
- const tracker = countTokens ? null : performance.begin("messages", { requestId });
85
+ const tracker = countTokens ? null : performance.begin("messages", { requestId, application: requestApplication(req.headers, "claude") });
85
86
  tracker?.setProvider(provider.id);
86
87
  const abort = createRequestAbort(req, res);
87
88
  let release = () => {}, outcome = "failed", model = null, responseId = null, usage = null, stopReason = null, streamed = false, sawStop = false, failedEvent = false;
@@ -2,7 +2,6 @@
2
2
  const el = id => document.getElementById(id);
3
3
  const label = (node, key, values = {}) => globalThis.ccdxLanguage.set(node, key, values);
4
4
  const titles = { overview: "overview", codex: "Codex", claude: "Claude", models: "model_services", usage: "usage_and_diagnostics", requests: "request_records", checks: "tools_checks_title", system: "system_and_settings" };
5
- const descriptions = { overview: "page_overview_description", codex: "page_codex_description", claude: "page_claude_description", models: "page_models_description", usage: "page_usage_description", requests: "page_requests_description", checks: "page_checks_description", system: "page_settings_description" };
6
5
  const settingsViews = ["codex", "models", "system", "checks"];
7
6
  let current = "overview", settings = null, settingsPending = false, stopped = false, timer = null, ticks = 0;
8
7
  let sourceDirty = false, reviewDirty = false, sourceModels = [], modelsPreference = null, sourceGeneration = 0, modelsSource = null;
@@ -46,12 +45,11 @@
46
45
  if (!["codex", "models"].includes(next) && dashboardRefresh.state("models").pending) dashboardRefresh.invalidate("models");
47
46
  for (const view of document.querySelectorAll("[data-view]")) view.hidden = view.dataset.view !== next;
48
47
  globalThis.ccdxDashboardActivity?.visibilityChanged();
48
+ globalThis.ccdxDashboardFlow?.visibilityChanged();
49
49
  for (const item of document.querySelectorAll("[data-route]")) {
50
50
  if (item.dataset.route === next) item.setAttribute("aria-current", "page");else item.removeAttribute("aria-current");
51
51
  }
52
52
  label(el("page-title"), titles[next]);
53
- label(el("page-description"), descriptions[next]);
54
- el("page-description").hidden = ["models", "system"].includes(next);
55
53
  el("page-settings-note").textContent = "";
56
54
  window.scrollTo(0, 0);
57
55
  el("main-content").focus({ preventScroll: true });
@@ -185,6 +183,7 @@
185
183
  : body.action.startsWith("history_") ? "effect-history" : body.action === "prediction_fix" ? "prediction-note"
186
184
  : body.operation === "switch" ? "source-control-note" : body.operation === "auto-review" ? "review-control-note"
187
185
  : body.operation === "account" ? "m365-account-note" : "m365-control-note");
186
+ const initialSourceSave = body.operation === "switch" && Boolean(body.auto_review_model);
188
187
  label(note, "applying");
189
188
  if (button) button.setAttribute("aria-busy", "true");
190
189
  try {
@@ -194,6 +193,7 @@
194
193
  if (body.action === "provider" && body.operation === "off") { sourceDirty = false;reviewDirty = false; }
195
194
  el("review-control-note").textContent = "";
196
195
  applySettings(data);
196
+ if (initialSourceSave) label(el("source-control-note"), "source_initial_review_saved");
197
197
  if (body.operation === "account") {
198
198
  sourceDirty = false;reviewDirty = false;sourceGeneration++;
199
199
  modelsPreference = null;modelsSource = null;
@@ -0,0 +1,171 @@
1
+ (() => {
2
+ const root = document.getElementById("request-flow");
3
+ if (!root) return;
4
+ const el = id => document.getElementById(id), ns = "http://www.w3.org/2000/svg";
5
+ const clients = new Set(["codex_app", "codex_cli", "claude_app", "claude_code", "claude", "api"]);
6
+ const label = (node, key, values = {}) => globalThis.ccdxLanguage.set(node, key, values);
7
+ const format = (key, values = {}) => globalThis.ccdxLanguage.format(key, values);
8
+ const nodes = { apps: new Map(), models: new Map() };
9
+ let rows = [], total = null, omitted = 0, fresh = false, deadline = 0, expiry = null;
10
+ let selected = null, expanded = false, lastSignature = "", geometry = "", known = false;
11
+ let lastApps = [], lastModels = [];
12
+ const visible = () => document.visibilityState === "visible" && !root.closest("[hidden]");
13
+ const integer = value => Number.isSafeInteger(value) && value >= 0;
14
+ const appName = id => format(`flow_app_${id}`);
15
+ const sourceName = id => id === "github" ? "GitHub Copilot" : id === "m365" ? "Microsoft 365" : format("flow_source_unknown");
16
+ const modelName = id => !id || id === "other" ? format("flow_model_unknown") : id;
17
+ const modelKey = row => JSON.stringify([row.provider, row.model]);
18
+ const related = row => !selected || (selected.type === "apps" ? row.application === selected.id : modelKey(row) === selected.id);
19
+ const responding = row => row.first_output_ms !== null && !row.terminal_outcome;
20
+ function status(row) {
21
+ if (row.terminal_outcome) return "flow_finishing";
22
+ if (responding(row)) return "flow_responding";
23
+ if (row.upstream_attempts > 1) return "flow_retrying";
24
+ return row.upstream_attempts ? "flow_waiting" : "flow_preparing";
25
+ }
26
+ function entry(tag, className) { const node = document.createElement(tag);if (className) node.className = className;return node; }
27
+ function svg(tag, values) { const node = document.createElementNS(ns, tag);for (const [key, value] of Object.entries(values)) node.setAttribute(key, value);return node; }
28
+ const logo = el("status-icon")?.cloneNode(true);
29
+ if (logo) { logo.removeAttribute("id");logo.setAttribute("class", "flow-logo");el("flow-hub").prepend(logo); }
30
+
31
+ function group(type) {
32
+ const map = new Map();
33
+ for (const row of rows) {
34
+ const id = type === "apps" ? row.application : modelKey(row);
35
+ if (!map.has(id)) map.set(id, { id, provider: row.provider, model: row.model, rows: [] });
36
+ map.get(id).rows.push(row);
37
+ }
38
+ const order = ["codex_app", "codex_cli", "claude_code", "claude_app", "claude", "api"];
39
+ return [...map.values()].sort((a, b) => type === "apps" ? order.indexOf(a.id) - order.indexOf(b.id) : a.id.localeCompare(b.id));
40
+ }
41
+ function project(type, groups) {
42
+ const target = el(type === "apps" ? "flow-apps" : "flow-models"), cache = nodes[type], fragments = [];
43
+ const ids = new Set(groups.map(group => group.id));
44
+ for (const [id, node] of cache) if (!ids.has(id)) { node.remove();cache.delete(id); }
45
+ let priorSource = null;
46
+ for (const group of groups) {
47
+ if (type === "models" && group.provider !== priorSource) {
48
+ const heading = entry("div", "flow-source");heading.textContent = sourceName(group.provider);fragments.push(heading);priorSource = group.provider;
49
+ }
50
+ let node = cache.get(group.id);
51
+ if (!node) {
52
+ node = entry("div", "flow-node");
53
+ const button = entry("button", "flow-choice"), count = entry("span", "flow-count"), note = entry("span", "flow-note");button.type = "button";
54
+ button.addEventListener("click", () => {
55
+ selected = selected?.type === type && selected.id === group.id ? null : { type, id: group.id };
56
+ el("flow-active").open = Boolean(selected);lastSignature = "";render();
57
+ });
58
+ node.append(button, count, note);cache.set(group.id, node);
59
+ }
60
+ const [button, count, note] = node.children;
61
+ button.textContent = type === "apps" ? appName(group.id) : modelName(group.model);
62
+ button.setAttribute("aria-pressed", String(selected?.type === type && selected.id === group.id));
63
+ count.textContent = fresh && (group.rows.length || total === 0)
64
+ ? `${omitted && group.rows.length ? "≥" : ""}${group.rows.length.toLocaleString()}` : "—";
65
+ const output = group.rows.filter(responding).length;
66
+ const phase = group.rows.every(row => row.terminal_outcome) ? "flow_finishing"
67
+ : group.rows.every(row => row.upstream_attempts > 1) ? "flow_retrying" : "flow_waiting";
68
+ label(note, !fresh || total && !group.rows.length ? "flow_last_observed" : !group.rows.length ? "flow_idle" : output ? "flow_group_response" : phase, { count: output });
69
+ node.dataset.related = String(!selected || group.rows.some(related));fragments.push(node);
70
+ }
71
+ // Keep existing buttons and their focus when counts or phases change.
72
+ const wanted = new Set(fragments);
73
+ for (const node of [...target.children]) if (!wanted.has(node)) node.remove();
74
+ fragments.forEach((node, index) => { if (target.children[index] !== node) target.insertBefore(node, target.children[index] || null); });
75
+ }
76
+ function details() {
77
+ label(el("flow-active-title"), fresh ? "flow_active_count" : "flow_last_count", { count: rows.filter(related).length });
78
+ if (!el("flow-active").open) return;
79
+ const body = el("flow-active-body"), records = rows.filter(related);body.replaceChildren();
80
+ for (const row of records) {
81
+ const tr = entry("tr");
82
+ for (const value of [appName(row.application), sourceName(row.provider), modelName(row.model), format(fresh ? status(row) : "flow_last_observed"), `${(row.elapsed_ms / 1000).toFixed(1)} s`, row.upstream_attempts.toLocaleString()]) {
83
+ const td = entry("td");td.textContent = value;tr.append(td);
84
+ }
85
+ body.append(tr);
86
+ }
87
+ if (!records.length) { const tr = entry("tr"), td = entry("td");td.colSpan = 6;label(td, known ? "flow_no_active" : "flow_status_unknown");tr.append(td);body.append(tr); }
88
+ }
89
+ function render() {
90
+ if (!visible()) { root.dataset.paused = "true";return; }
91
+ root.dataset.paused = "false";
92
+ const apps = group("apps"), allModels = group("models");
93
+ if (fresh && rows.length) { lastApps = apps;lastModels = allModels; }
94
+ if (fresh && !rows.length) { for (const groups of [lastApps, lastModels]) for (const group of groups) group.rows = []; }
95
+ const shownApps = apps.length ? apps : lastApps, models = allModels.length ? allModels : lastModels;
96
+ if (selected && !rows.some(related)) selected = null;
97
+ const signature = JSON.stringify([fresh, total, omitted, selected, expanded, rows.map(row => [row.request_id, row.application, row.provider, row.model, row.phase, row.upstream_attempts, row.first_output_ms !== null, row.terminal_outcome])]);
98
+ details();
99
+ if (signature === lastSignature) return;
100
+ lastSignature = signature;
101
+ root.dataset.state = !fresh ? "unknown" : total ? "active" : "idle";
102
+ const state = el("flow-state");
103
+ if (fresh && total === 0) label(state, "flow_idle");
104
+ else globalThis.ccdxIcons?.set(state, !fresh ? "flow_status_unknown" : "flow_total", !fresh ? "unavailable" : "running", { count: total });
105
+ label(el("flow-total"), fresh ? "flow_total" : "flow_last_observed", { count: total });
106
+ label(el("flow-caption"), !fresh ? "flow_status_unknown" : omitted ? "flow_omitted" : selected ? "flow_related_count" : total ? "flow_group_scope" : "flow_no_active",
107
+ { count: rows.filter(related).length, omitted, apps: apps.length, models: allModels.length });
108
+ el("flow-clear").hidden = !selected;
109
+ el("flow-more").hidden = models.length <= 12;
110
+ label(el("flow-more"), expanded ? "flow_fewer_models" : "flow_more_models", { count: Math.max(0, models.length - 12) });
111
+ project("apps", shownApps);
112
+ project("models", expanded ? models : models.slice(0, 12));
113
+ geometry = "";draw();
114
+ }
115
+ function rounded(x0, y0, x1, y1) {
116
+ if (Math.abs(y1 - y0) < 2) return `M${x0} ${y0}H${x1}`;
117
+ const middle = (x0 + x1) / 2, radius = Math.min(14, (x1 - x0) / 4, Math.abs(y1 - y0) / 2), sign = Math.sign(y1 - y0);
118
+ return `M${x0} ${y0}H${middle - radius}Q${middle} ${y0} ${middle} ${y0 + sign * radius}V${y1 - sign * radius}Q${middle} ${y1} ${middle + radius} ${y1}H${x1}`;
119
+ }
120
+ function draw() {
121
+ if (!visible()) return;
122
+ const network = el("flow-network"), rect = network.getBoundingClientRect(), hub = el("flow-hub").getBoundingClientRect(), edges = [];
123
+ const inset = rect.width < 500 ? 2 : 6;
124
+ if (!rect.width) return;
125
+ for (const type of ["apps", "models"]) for (const [id, node] of nodes[type]) {
126
+ if (!node.isConnected) continue;
127
+ const box = node.getBoundingClientRect(), left = type === "apps";
128
+ const x0 = (left ? box.right : hub.right) - rect.left + inset, y0 = (left ? box.top + 17 : hub.top + hub.height / 2) - rect.top;
129
+ const x1 = (left ? hub.left : box.left) - rect.left - inset, y1 = (left ? hub.top + hub.height / 2 : box.top + 17) - rect.top;
130
+ if (x1 <= x0) continue;
131
+ const matches = rows.filter(row => (left ? row.application : modelKey(row)) === id && related(row));
132
+ edges.push({ d: rounded(x0, y0, x1, y1), active: fresh && matches.length > 0, moving: fresh && matches.some(responding), dim: node.dataset.related === "false", x: left ? x0 : x1, y: left ? y0 : y1, left });
133
+ }
134
+ const next = JSON.stringify([rect.width, rect.height, edges]);if (next === geometry) return;geometry = next;
135
+ const wires = el("flow-wires");wires.setAttribute("viewBox", `0 0 ${rect.width} ${rect.height}`);wires.replaceChildren();
136
+ for (const edge of edges) {
137
+ wires.append(svg("path", { d: edge.d, class: `flow-wire${edge.dim ? " flow-dim" : edge.active ? " flow-live" : ""}` }));
138
+ if (edge.moving) { const dot = svg("circle", { r: 2.4, class: "flow-packet" });dot.style.offsetPath = `path('${edge.d}')`;dot.style.animationDelay = edge.left ? "-.9s" : "0s";wires.append(dot); }
139
+ else if (edge.active) wires.append(svg("circle", { cx: edge.x, cy: edge.y, r: 2.4, class: "flow-wait" }));
140
+ }
141
+ }
142
+ function unavailable() { clearTimeout(expiry);expiry = null;fresh = false;deadline = 0;render(); }
143
+ function visibilityChanged() { if (deadline && Date.now() >= deadline) { unavailable();return; }render();draw(); }
144
+ el("flow-clear").addEventListener("click", () => { selected = null;render(); });
145
+ el("flow-hub").addEventListener("click", () => { selected = null;render(); });
146
+ el("flow-more").addEventListener("click", () => { expanded = !expanded;render(); });
147
+ el("flow-active").addEventListener("toggle", details);
148
+ document.addEventListener("visibilitychange", visibilityChanged);
149
+ globalThis.addEventListener("pagehide", () => { root.dataset.paused = "true"; });
150
+ globalThis.addEventListener("pageshow", visibilityChanged);
151
+ new ResizeObserver(draw).observe(el("flow-network"));
152
+ new MutationObserver(() => { lastSignature = "";render(); }).observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] });
153
+ globalThis.ccdxDashboardFlow = {
154
+ update(data) {
155
+ const parts = [data?.stream_performance, data?.providers?.m365?.claude?.requests?.performance].filter(Boolean);
156
+ if (!parts.length || parts.some(part => !integer(part.active_total) || !Array.isArray(part.active_requests))) { unavailable();return; }
157
+ const values = parts.flatMap(part => part.active_requests).slice(0, 128);
158
+ rows = values.filter(row => row && typeof row.model === "string" && integer(row.upstream_attempts) && Number.isFinite(row.elapsed_ms) && row.elapsed_ms >= 0).map(row => ({
159
+ request_id: typeof row.request_id === "string" ? row.request_id.slice(0, 80) : null,
160
+ application: clients.has(row.application) ? row.application : "api", provider: ["github", "m365"].includes(row.provider) ? row.provider : "unknown",
161
+ model: row.model.slice(0, 100), phase: String(row.phase || "").slice(0, 40), elapsed_ms: row.elapsed_ms,
162
+ upstream_attempts: row.upstream_attempts, first_output_ms: Number.isFinite(row.first_output_ms) && row.first_output_ms >= 0 ? row.first_output_ms : null,
163
+ terminal_outcome: ["completed", "incomplete", "failed", "cancelled", "unknown"].includes(row.terminal_outcome) ? row.terminal_outcome : null,
164
+ }));
165
+ total = parts.reduce((sum, part) => sum + part.active_total, 0);
166
+ if (!integer(total) || total < rows.length) { unavailable();return; }
167
+ omitted = total - rows.length;fresh = true;known = true;
168
+ clearTimeout(expiry);deadline = Date.now() + 6000;expiry = setTimeout(unavailable, 6000);render();
169
+ }, unavailable, visibilityChanged,
170
+ };
171
+ })();
@@ -13,6 +13,7 @@
13
13
  <script src="/time.js" defer></script>
14
14
  <script src="/status.js" defer></script>
15
15
  <script src="/activity.js" defer></script>
16
+ <script src="/flow.js" defer></script>
16
17
  <script src="/usage.js" defer></script>
17
18
  <script src="/updates.js" defer></script>
18
19
  <script src="/animation.js" defer></script>
@@ -46,7 +47,6 @@
46
47
  <main id="main-content" tabindex="-1">
47
48
  <section class="intro">
48
49
  <h1><span id="page-title" data-i18n="overview">Overview</span></h1>
49
- <p id="page-description" class="page-description" data-i18n="page_overview_description">Service, app connections and usage this run.</p>
50
50
  <p id="page-settings-note" class="hint" role="status"></p>
51
51
  </section>
52
52
 
@@ -89,20 +89,22 @@
89
89
  <details class="panel dashboard-section" id="prediction-settings" open>
90
90
  <summary class="panel-heading"><h2 data-i18n="codex_input_predictions">INPUT SUGGESTIONS</h2><span data-i18n="codex_only">CODEX ONLY</span></summary>
91
91
  <div class="setting-row"><label for="setting-prediction_enabled" data-i18n="allow_prediction_configuration">Allow suggestion updates</label><input id="setting-prediction_enabled" type="checkbox" role="switch" disabled><span id="effect-prediction_enabled" class="hint" role="status"></span></div>
92
+ <p class="hint" data-i18n="pause_keeps_the_existing_trust_and_route_codex_may_retain_cached">Pause keeps existing trust and routing. Cached suggestions may still appear. First quit Codex, then run ccdx prediction on.</p>
92
93
  <details class="tool-details"><summary data-i18n="status_and_repair">Status and repair</summary>
93
94
  <dl class="stats"><div><dt data-i18n="prediction_integration_setup">Suggestion setup</dt><dd id="prediction-preference">—</dd></div><div><dt data-i18n="local_bridge">Local service</dt><dd id="prediction-bridge">—</dd></div><div><dt data-i18n="client_route">App settings requests</dt><dd id="prediction-route">—</dd></div><div><dt data-i18n="visible_candidate">Suggestion displayed</dt><dd id="prediction-candidate">—</dd></div></dl>
94
95
  <p id="prediction-note" class="hint">—</p>
95
96
  <p class="hint" data-i18n="configured_does_not_mean_displayed_use_ccdx_prediction_status_fo">Enabled does not mean a suggestion appeared. Details: ccdx prediction status.</p>
96
97
 
97
98
  <div class="section-actions"><button id="fix-prediction" type="button" data-i18n="check_and_repair">Check and repair</button></div>
98
- <p class="hint" data-i18n="pause_keeps_the_existing_trust_and_route_codex_may_retain_cached">Pause keeps existing trust and routing. Cached suggestions may still appear. First quit Codex, then run ccdx prediction on.</p>
99
+ <p class="hint" data-i18n="prediction_first_setup">Quit Codex before first setup: ccdx prediction on</p>
99
100
  </details>
100
101
  </details>
101
102
  <details class="panel dashboard-section" id="additional-capabilities">
102
103
  <summary class="panel-heading"><h2 data-i18n="codex_image_generation">IMAGE GENERATION</h2><span data-i18n="codex_only">CODEX ONLY</span></summary>
103
104
  <strong id="image">—</strong><p id="image-detail" class="hint">—</p>
104
105
  <div class="setting-row"><label for="setting-image_enabled" data-i18n="allow_new_image_calls">Allow image requests</label><input id="setting-image_enabled" type="checkbox" role="switch" disabled><span id="effect-image_enabled" class="hint" role="status"></span></div>
105
- <p class="hint" data-i18n="pause_keeps_the_provider_configuration_running_calls_can_finish_">Pause keeps your setup. Running image requests can finish. First setup: ccdx enable-image.</p>
106
+ <p class="hint" data-i18n="pause_keeps_the_provider_configuration_running_calls_can_finish_">Existing image requests can finish after pausing.</p>
107
+ <details class="tool-details"><summary data-i18n="status_and_repair">Status and repair</summary><p class="hint" data-i18n="image_first_setup">First setup: ccdx enable-image</p></details>
106
108
  </details>
107
109
  <details class="panel dashboard-section" id="runtime-resources">
108
110
  <summary data-i18n="codex_conversation_buffer">CONVERSATION BUFFER</summary>
@@ -116,9 +118,9 @@
116
118
  <details class="panel dashboard-section" id="codex-performance">
117
119
  <summary data-i18n="request_performance">REQUEST PERFORMANCE</summary>
118
120
  <dl class="stats"><div><dt data-i18n="completed">Completed</dt><dd id="completed">—</dd></div><div><dt data-i18n="incomplete">Incomplete</dt><dd id="incomplete">—</dd></div><div><dt data-i18n="failed">Failed</dt><dd id="failed">—</dd></div><div><dt data-i18n="cancelled">Cancelled</dt><dd id="cancelled">—</dd></div></dl>
119
- <p class="hint" data-i18n="http_2xx_model_completed">HTTP success does not mean a complete reply.</p>
120
121
  <dl class="stats timing-stats"><div><dt data-i18n="first_output">First output</dt><dd id="ttft">—</dd></div><div><dt data-i18n="output_speed">Output speed</dt><dd id="tpot">—</dd></div></dl>
121
122
  <p class="hint" data-i18n="codex_responses_timing_since_startup_output_speed_is_estimated">Codex Responses timing since startup. Speed is estimated.</p>
123
+ <dl class="stats timing-stats"><div><dt data-i18n="estimated_percentiles" data-i18n-title="percentile_basis">Approx. first-output P50 / P95</dt><dd id="ttft-percentiles">—</dd></div></dl>
122
124
  <a class="section-link" href="#requests" data-i18n="view_request_details">View request details</a>
123
125
  </details>
124
126
  </div>
@@ -127,7 +129,7 @@
127
129
  <h2 data-i18n="client_connections">APP SETUP</h2>
128
130
  <div class="table-wrap"><table><thead><tr><th data-i18n="client">APP</th><th data-i18n="connection_setup" data-i18n-title="configured_not_successful">Setup</th><th data-i18n="local_bridge">Local service</th><th data-i18n="last_request">LAST REQUEST</th></tr></thead><tbody id="claude-clients"></tbody></table></div>
129
131
  <p id="claude-client-state" class="hint"></p>
130
- <p class="hint" data-i18n="local_service_not_app">Local service status does not confirm the app is open.</p>
132
+
131
133
  </section>
132
134
  <section class="panel dashboard-section">
133
135
  <h2 data-i18n="source">Source</h2><p class="table-note">Microsoft 365</p>
@@ -138,14 +140,16 @@
138
140
  <section class="panel dashboard-section" id="claude-performance">
139
141
  <div class="panel-heading"><h2 data-i18n="request_performance">REQUEST PERFORMANCE</h2><span data-i18n="messages_combined_since_start">MESSAGES COMBINED / SINCE STARTUP</span></div>
140
142
  <dl class="stats"><div><dt data-i18n="completed">Completed</dt><dd id="claude-completed">—</dd></div><div><dt data-i18n="incomplete">Incomplete</dt><dd id="claude-incomplete">—</dd></div><div><dt data-i18n="failed">Failed</dt><dd id="claude-failed">—</dd></div><div><dt data-i18n="cancelled">Cancelled</dt><dd id="claude-cancelled">—</dd></div><div><dt data-i18n="first_output">First output</dt><dd id="claude-ttft">—</dd></div><div><dt data-i18n="output_speed">Output speed</dt><dd id="claude-speed">—</dd></div></dl>
141
- <p class="hint" data-i18n="claude_metrics_combined">These metrics are not separated by Claude app.</p>
142
- <p class="hint" data-i18n="since_this_service_started_configuration_authorization_model_dis">Counts start with this service. Setup, sign-in, listed models and successful requests are separate checks.</p>
143
+
144
+
145
+ <dl class="stats timing-stats"><div><dt data-i18n="estimated_percentiles" data-i18n-title="percentile_basis">Approx. first-output P50 / P95</dt><dd id="claude-ttft-percentiles">—</dd></div></dl>
143
146
  <a class="section-link" href="#requests" data-i18n="view_request_details">View request details</a>
144
147
  </section>
145
148
  </div>
146
149
  <div data-view="models" hidden>
150
+ <p class="table-note" data-i18n="tools_source_browse">Browse source</p>
147
151
  <div id="model-providers" class="provider-tabs" role="tablist" aria-label="Model providers" data-i18n-label="model_providers"></div>
148
- <p class="hint source-browse-note" data-i18n="tools_source_browse">Browsing a source does not change app settings.</p>
152
+
149
153
  <div id="source-account-panel" role="tabpanel">
150
154
  <p id="source-status-note" class="hint" role="status"></p>
151
155
  <section class="panel dashboard-section" id="github-account">
@@ -163,11 +167,11 @@
163
167
  </section>
164
168
  <p id="github-account-note" class="hint" role="status" aria-live="polite"></p>
165
169
  <details class="tool-details"><summary data-i18n="tools_details">Check details</summary><dl class="failure-detail"><dt data-i18n="tools_storage">Saved sign-in</dt><dd id="github-store">—</dd><dt data-i18n="tools_error_code">Error code</dt><dd id="github-check-code">—</dd><dt>HTTP</dt><dd id="github-check-http">—</dd><dt data-i18n="tools_github_identity">GitHub identity</dt><dd id="github-identity-detail">—</dd><dt data-i18n="last_verified">Last checked</dt><dd id="github-checked-at">—</dd></dl></details>
166
- <details class="tool-details"><summary data-i18n="tools_more_actions">More actions</summary><div class="section-actions"><button id="github-logout" type="button" data-i18n="tools_logout">Sign out of CCDX</button></div><p class="hint" data-i18n="tools_logout_scope">Other apps stay signed in.</p></details>
170
+ <details class="tool-details"><summary data-i18n="tools_more_actions">More actions</summary><div class="section-actions"><button id="github-logout" type="button" data-i18n="tools_logout">Sign out of CCDX</button></div></details>
167
171
  </section>
168
172
  <section class="panel dashboard-section" id="m365-source-access" hidden aria-labelledby="source-access-heading">
169
173
  <h2 id="source-access-heading" data-i18n="account_access">Account &amp; access</h2>
170
- <p class="hint" data-i18n="m365_source_access">Provides models for Codex and Claude on supported devices.</p>
174
+
171
175
  <div class="setting-row"><label for="m365-enabled" data-i18n="enable_service">Enable source</label><input id="m365-enabled" type="checkbox" role="switch" disabled><span id="m365-source-effect" class="hint" role="status"></span></div>
172
176
  <div id="m365-control-note" class="hint" role="status"></div>
173
177
  <h3 data-i18n="company_account">Company account</h3>
@@ -185,13 +189,13 @@
185
189
  <summary class="panel-heading"><h2 data-i18n="model_catalog">MODEL LIST</h2><span id="models-state" data-i18n="checking_live">CHECKING</span></summary>
186
190
  <div class="section-actions"><button id="refresh-models" type="button" data-i18n="refresh">Refresh</button></div>
187
191
  <p id="models-note" class="table-note" data-i18n="reading_provider_catalog">Loading model list…</p>
188
- <details id="model-check-details" class="model-check-details" hidden><summary data-i18n="source_check_details">Check details</summary><dl id="model-check-fields" class="failure-detail"></dl><p class="hint" data-i18n="source_check_action">Use Refresh to check this source again.</p></details>
192
+ <details id="model-check-details" class="model-check-details" hidden><summary data-i18n="source_check_details">Check details</summary><dl id="model-check-fields" class="failure-detail"></dl></details>
189
193
  <div class="table-wrap"><table><thead><tr><th scope="col" data-i18n="model">MODEL</th><th scope="col" data-i18n="client">APP</th><th scope="col" data-i18n="tools_details">Details</th></tr></thead><tbody id="live-models-body" role="tabpanel"><tr><td colspan="3" data-i18n="loading">Loading…</td></tr></tbody></table></div>
190
- <p class="hint" data-i18n="catalog_listing_does_not_guarantee_inference_access">Listed does not mean your account can use it.</p>
194
+ <details class="tool-details"><summary data-i18n="tools_details">Details</summary><p class="hint" data-i18n="catalog_listing_does_not_guarantee_inference_access">Models listed; inference access not verified.</p></details>
191
195
  </details>
192
196
  <details class="panel dashboard-section" id="account-authorization">
193
197
  <summary data-i18n="source_access_details">SOURCE ACCESS DETAILS</summary>
194
- <p class="hint" data-i18n="saved_credentials_authorization_model_access_and_client_requests">Saved sign-in, access, models and app requests are separate checks.</p>
198
+
195
199
  <div class="table-wrap"><table><thead><tr><th data-i18n="source">Source</th><th data-i18n="account">ACCOUNT</th><th data-i18n="authorization">AUTHORIZATION</th><th data-i18n="service">SERVICE</th><th data-i18n="last_verified">LAST VERIFIED</th><th data-i18n="time_left">Time left</th></tr></thead><tbody id="provider-auth"></tbody></table></div>
196
200
  </details>
197
201
  </div>
@@ -205,7 +209,7 @@
205
209
  <div class="table-wrap"><table class="checks-table"><thead><tr><th data-i18n="tools_check_item">Check</th><th data-i18n="state">State</th><th data-i18n="tools_details">Details</th></tr></thead><tbody id="checks-body"></tbody></table></div>
206
210
  </section>
207
211
  <section class="panel dashboard-section">
208
- <h2 data-i18n="account_access">ACCOUNT AND ACCESS</h2><p class="hint" data-i18n="account_management_location">Manage sign-in, accounts and models under Model sources.</p>
212
+ <h2 data-i18n="account_access">ACCOUNT AND ACCESS</h2>
209
213
  <div class="section-actions"><button id="check-account-link" type="button" data-i18n="check_github_connection">Check GitHub connection</button><a class="section-link" href="#models" data-source-link="m365" data-i18n="view_m365_account">View M365 account</a></div>
210
214
  </section>
211
215
  <section class="panel dashboard-section">
@@ -231,10 +235,10 @@
231
235
  <div class="analytics-controls">
232
236
  <label><span data-i18n="model_both_charts">Model / both charts</span> <select id="analytics-model"><option value="" data-i18n="all_models">All models</option></select></label>
233
237
  </div>
234
- <p id="analytics-note" class="table-note" role="status" data-i18n="open_to_read_retained_usage_history">Open to view usage trends.</p>
238
+ <p id="analytics-note" class="table-note" role="status" data-i18n="open_to_read_retained_usage_history">Loading usage trends…</p>
235
239
  <p id="analytics-updated" class="refresh-time"></p>
236
240
  <div class="chart-heading"><h3 data-i18n="daily_tokens">DAILY USAGE</h3><div class="analytics-controls"><label><span data-i18n="daily_range">Date range</span> <select id="analytics-range"><option value="7" data-i18n="7_days">Last 7 days</option><option value="30" selected data-i18n="30_days">Last 30 days</option><option value="90" data-i18n="90_days">Last 90 days</option></select></label>
237
- <label><span data-i18n="chart_view">Chart view</span> <select id="analytics-view"><option value="bars" selected data-i18n="bar_chart">Bar chart</option><option value="line" data-i18n="line_chart">Line chart</option></select></label></div></div><p class="hint" data-i18n="input_output_cache_included_in_input">INPUT + OUTPUT / REUSED INPUT IS PART OF INPUT</p>
241
+ <label><span data-i18n="chart_view">Chart view</span> <select id="analytics-view"><option value="bars" selected data-i18n="bar_chart">Bar chart</option><option value="line" data-i18n="line_chart">Line chart</option></select></label></div></div>
238
242
  <div id="daily-bars" class="daily-bars" aria-label="Daily usage in Token" data-i18n-label="daily_token_usage"></div>
239
243
  <div class="daily-axis"><span id="daily-from"></span><span id="daily-to"></span></div>
240
244
  <div class="chart-legend"><span class="legend-input" data-i18n="input_36ecb">Input usage</span><span class="legend-output" data-i18n="output_b2439">Output usage</span></div>
@@ -253,6 +257,17 @@
253
257
  </details>
254
258
  </div>
255
259
  <div data-view="requests" hidden>
260
+ <section class="panel dashboard-section" id="request-flow" data-state="unknown">
261
+ <div class="panel-heading"><h2 data-i18n="request_flow">REQUEST FLOW</h2><span id="flow-state" role="status" aria-live="polite" data-i18n="flow_status_unknown">Status unavailable</span></div>
262
+ <div id="flow-network" class="flow-network" role="group" data-i18n-label="request_flow" aria-label="Request flow">
263
+ <svg id="flow-wires" class="flow-wires" aria-hidden="true"></svg>
264
+ <div class="flow-column"><p class="flow-column-title" data-i18n="clients">Apps</p><div id="flow-apps" class="flow-apps"></div></div>
265
+ <div class="flow-hub-column"><button id="flow-hub" type="button" data-i18n-label="flow_show_all" aria-label="Show all requests"><b>CCDX</b><small id="flow-total">—</small></button></div>
266
+ <div class="flow-column"><p class="flow-column-title" data-i18n="flow_sources_models">Sources / models</p><div id="flow-models"></div></div>
267
+ </div>
268
+ <div class="flow-caption"><span id="flow-caption" data-i18n="flow_status_unknown">Status unavailable</span><button id="flow-clear" type="button" data-i18n="flow_show_all" hidden>Show all</button><button id="flow-more" type="button" hidden>More models</button></div>
269
+ <details id="flow-active" class="tool-details"><summary id="flow-active-title" data-i18n="flow_active_requests">Active requests</summary><div class="table-wrap"><table><thead><tr><th data-i18n="client">App</th><th data-i18n="source">Source</th><th data-i18n="model">Model</th><th data-i18n="state">State</th><th data-i18n="flow_elapsed">Elapsed</th><th data-i18n="attempts">Attempts</th></tr></thead><tbody id="flow-active-body"></tbody></table></div></details>
270
+ </section>
256
271
  <details class="panel dashboard-section" id="source-requests" open>
257
272
  <summary data-i18n="requests_by_source">REQUESTS BY SOURCE</summary>
258
273
  <p class="hint" data-i18n="results_since_startup_partial_usage_is_marked_separately">Results since startup. Partial usage is marked separately.</p>
@@ -263,14 +278,11 @@
263
278
  <summary data-i18n="recent_request_context">RECENT REQUESTS</summary>
264
279
  <p id="context-note" class="table-note">—</p>
265
280
  <div class="table-wrap"><table><thead><tr><th scope="col" data-i18n="time">Time</th><th scope="col" data-i18n="source">Source</th><th scope="col" data-i18n="model">MODEL</th><th scope="col" data-i18n="outcome">RESULT</th><th scope="col" data-i18n="input_tokens">INPUT USAGE</th><th scope="col" data-i18n="tools_details">Details</th></tr></thead><tbody id="context-body"><tr><td colspan="6" data-i18n="no_observed_request_metadata">No request records yet.</td></tr></tbody></table></div>
266
- <p class="hint" data-i18n="recent_upstream_request_metadata_not_exact_live_session_occupanc">Size: MiB. Usage: Token.
267
- Request records do not show exact current-chat usage.
268
- Missing data is unknown. This panel keeps no prompts or images.</p>
281
+ <details class="tool-details"><summary data-i18n="record_scope">Record scope</summary><p class="hint" data-i18n="recent_upstream_request_metadata_not_exact_live_session_occupanc">No prompts or images are stored. — means unavailable data.</p><p class="hint" data-i18n="http_2xx_model_completed">HTTP status and model outcome are recorded separately.</p></details>
269
282
  </details>
270
283
  <details class="lower" id="recent-failures" open>
271
284
  <summary class="panel-heading"><h2 data-i18n="recent_inference_http_failures">RECENT REQUEST ISSUES</h2><span id="failure-count">requests + events</span></summary>
272
285
  <ol id="failures"><li class="empty" data-i18n="reading_874bf">Reading…</li></ol>
273
- <p class="hint" data-i18n="upstream_messages_may_contain_sensitive_text">Error details may include private data.</p>
274
286
  </details>
275
287
  </div>
276
288
  <div data-view="system" hidden>
@@ -1,5 +1,44 @@
1
1
  (() => {
2
2
  const translations = {
3
+ "prediction_first_setup": ["Quit Codex before first setup: ccdx prediction on", "首次配置前请退出 Codex:ccdx prediction on"],
4
+ "image_first_setup": ["First setup: ccdx enable-image", "首次配置:ccdx enable-image"],
5
+ "record_scope": ["Record scope", "记录范围"],
6
+ "estimated_percentiles": ["Approx. first-output P50 / P95", "首个输出 P50 / P95(约)"],
7
+ "percentile_values": ["{p50} / {p95} ms · {samples} samples", "{p50} / {p95} ms · {samples} 次样本"],
8
+ "percentile_basis": ["Estimated from histogram buckets since startup; includes partial-output failures.", "按本次运行的耗时分布估算,包含已有输出的失败请求。"],
9
+ "source_initial_review_saved": ["Source and initial review settings saved. Applies to new requests.", "来源及初始审查设置已保存,用于新的请求。"],
10
+
11
+ "request_flow": ["REQUEST FLOW", "请求流向"],
12
+ "flow_sources_models": ["Sources / models", "来源 / 模型"],
13
+ "flow_show_all": ["Show all", "显示全部"],
14
+ "flow_status_unknown": ["Waiting for a fresh status", "状态待更新"],
15
+ "flow_total": ["{count} active requests", "{count} 个请求进行中"],
16
+ "flow_idle": ["Idle", "空闲"],
17
+ "flow_no_active": ["Waiting for the next request", "等待下一次请求"],
18
+ "flow_last_observed": ["Last observed", "上次记录"],
19
+ "flow_active_requests": ["Active requests", "进行中的请求"],
20
+ "flow_active_count": ["Active requests · {count}", "进行中 · {count}"],
21
+ "flow_last_count": ["Last observed · {count}", "上次记录 · {count}"],
22
+ "flow_related_count": ["{count} related requests", "{count} 个相关请求"],
23
+ "flow_group_scope": ["{apps} apps · {models} models", "{apps} 个应用 · {models} 个模型"],
24
+ "flow_omitted": ["Showing {count} requests; {omitted} more have no detail", "显示 {count} 个请求,另有 {omitted} 个暂无详情"],
25
+ "flow_more_models": ["Show {count} more models", "显示其余 {count} 个模型"],
26
+ "flow_fewer_models": ["Show fewer models", "收起模型"],
27
+ "flow_app_codex_app": ["Codex App", "Codex App"],
28
+ "flow_app_codex_cli": ["Codex CLI", "Codex CLI"],
29
+ "flow_app_claude_app": ["Claude App", "Claude App"],
30
+ "flow_app_claude_code": ["Claude Code", "Claude Code"],
31
+ "flow_app_claude": ["Claude (app unspecified)", "Claude(未区分应用)"],
32
+ "flow_app_api": ["API client", "API 客户端"],
33
+ "flow_source_unknown": ["Source unknown", "来源未知"],
34
+ "flow_model_unknown": ["Model not identified", "未识别模型"],
35
+ "flow_responding": ["Responding", "响应中"],
36
+ "flow_group_response": ["{count} responding", "{count} 个响应中"],
37
+ "flow_waiting": ["Waiting for response", "等待响应"],
38
+ "flow_preparing": ["Preparing", "准备中"],
39
+ "flow_retrying": ["Retrying", "正在重试"],
40
+ "flow_finishing": ["Finishing delivery", "正在完成交付"],
41
+ "flow_elapsed": ["Elapsed", "已持续"],
3
42
  "sign_in_status": ["Sign-in", "登录状态"],
4
43
  "account_details": ["Account details", "账号详情"],
5
44
  "preference_effect": ["{saved} · {state}", "{saved} · {state}"],
@@ -14,14 +53,6 @@
14
53
  "catalog_cause_rate_limited": ["Model-list checks are limited. Try again later.", "模型列表检查过于频繁,请稍后再试。"],
15
54
  "catalog_cause_service_unavailable": ["Microsoft 365 could not serve the model list.", "Microsoft 365 暂时无法提供模型列表。"],
16
55
  "catalog_cause_catalog_rejected": ["Microsoft 365 rejected the model-list request.", "Microsoft 365 拒绝了模型列表请求。"],
17
- "page_overview_description": ["Service, app connections and usage this run.", "查看服务、应用和本次用量。"],
18
- "page_codex_description": ["Set up Codex connections and features.", "配置 Codex 接入与专属功能。"],
19
- "page_claude_description": ["Claude app connections and request performance.", "查看 Claude 接入与请求表现。"],
20
- "page_models_description": ["Accounts, access checks and model lists.", "管理账号、访问权限和模型列表。"],
21
- "page_usage_description": ["Usage totals, daily trends and annual activity.", "查看用量汇总、趋势与年度活动。"],
22
- "page_requests_description": ["Recent requests, outcomes and issues.", "查看最近请求、处理结果和异常。"],
23
- "page_checks_description": ["Check this computer and review connection repairs.", "检查本机环境,排查接入问题。"],
24
- "page_settings_description": ["Appearance, terminal, startup and version.", "调整外观、启动行为和版本。"],
25
56
  "current_source": ["Current source", "当前来源"],
26
57
  "connection_setup": ["Setup", "接入配置"],
27
58
  "configured_not_successful": ["Configured does not mean a request succeeded.", "已配置,不代表请求已成功。"],
@@ -30,15 +61,15 @@
30
61
  "request_performance": ["REQUEST PERFORMANCE", "请求表现"],
31
62
  "status_and_repair": ["Status and repair", "状态与修复"],
32
63
  "local_service_not_app": ["Local service status does not confirm the app is open.", "本地服务运行,不代表应用已打开。"],
33
- "claude_shared_source": ["Account and source settings apply to both Claude apps.", "账号与来源设置供两个应用共用。"],
64
+ "claude_shared_source": ["Shared by Claude Code and Claude App.", "Claude Code 与 Claude App 共用此来源。"],
34
65
  "manage_source_account": ["Manage source and account", "管理来源与账号"],
35
66
  "connection_details": ["Connection details", "连接详情"],
36
- "messages_combined_since_start": ["MESSAGES COMBINED / SINCE STARTUP", "Messages 合计 / 本次启动"],
37
- "claude_metrics_combined": ["These metrics are not separated by Claude app.", "当前统计不区分两个 Claude 应用。"],
67
+ "messages_combined_since_start": ["Both Claude apps · This service run", "两款应用合计 · 本次运行"],
68
+ "claude_metrics_combined": ["Both Claude apps", "两款应用合计"],
38
69
  "source_access_details": ["SOURCE ACCESS DETAILS", "来源访问详情"],
39
70
  "account_access": ["Account & access", "账号与访问"],
40
71
  "account_management_location": ["Manage sign-in, accounts and models under Model sources.", "登录、账号和模型在来源页管理。"],
41
- "check_github_connection": ["Open GitHub checks", "前往 GitHub 检查"],
72
+ "check_github_connection": ["Check GitHub connection", "检查 GitHub 连接"],
42
73
  "view_m365_account": ["View M365 account", "查看 M365 账号"],
43
74
  "more_checks_reports": ["MORE CHECKS AND REPORTS", "更多检查与报告"],
44
75
  "diagnostic_report": ["Diagnostic report", "诊断报告"],
@@ -53,7 +84,7 @@
53
84
  "request_metadata": ["Request metadata", "请求技术信息"],
54
85
  "cancel": ["Cancel", "取消"],
55
86
  "tools_checks_title": ["Checks & repairs", "检查与修复"],
56
- "tools_source_browse": ["Browsing a source does not change app settings.", "切换标签只查看来源,不改变应用设置。"],
87
+ "tools_source_browse": ["Browse source", "查看来源"],
57
88
  "tools_saved_account": ["Saved GitHub sign-in", "已保存 GitHub 登录"],
58
89
  "tools_not_signed_in": ["Not signed in", "尚未登录"],
59
90
  "tools_signin_invalid": ["Sign-in invalid", "登录已失效"],
@@ -74,7 +105,7 @@
74
105
  "tools_logout": ["Sign out of CCDX", "退出 CCDX 登录"],
75
106
  "tools_logout_scope": ["Other apps stay signed in.", "不会退出其他应用的登录。"],
76
107
  "tools_logout_confirm": ["Sign out of CCDX? New requests will need a sign-in. Other apps stay signed in.", "退出 CCDX 登录?新请求需要重新登录。其他应用不受影响。"],
77
- "tools_no_inference": ["Checks access and models. No chat request is sent.", "只检查权限和模型,不发送对话。"],
108
+ "tools_no_inference": ["No model calls", "不调用模型"],
78
109
  "tools_waiting": ["Waiting for GitHub", "等待 GitHub 授权"],
79
110
  "tools_verifying": ["Verifying account and models", "正在检查账号和模型"],
80
111
  "tools_device_instructions": ["Open GitHub, enter this code, and authorize CCDX.", "打开 GitHub,输入代码并授权。"],
@@ -91,10 +122,10 @@
91
122
  "tools_reauth_hint": ["GitHub rejected this sign-in. Sign in again.", "GitHub 拒绝了当前登录,请重新登录。"],
92
123
  "tools_access_denied": ["GitHub sign-in is valid. Check your Copilot access or company policy.", "GitHub 登录有效。请检查 Copilot 权限或公司策略。"],
93
124
  "tools_network_hint": ["Connection could not be verified. Check network settings; saved sign-in is kept.", "连接未能验证。请检查网络,原登录已保留。"],
94
- "tools_local_scope": ["Local checks do not contact external services.", "本机检查不访问外部服务。"],
125
+ "tools_local_scope": ["Local checks only", "仅检查本机"],
95
126
  "tools_check_local": ["Check this computer", "本机检查"],
96
127
  "tools_export_report": ["Export report", "导出报告"],
97
- "tools_checks_empty": ["Run a check to see the results.", "运行本机检查后显示结果。"],
128
+ "tools_checks_empty": ["Run a local check to see results.", "运行本机检查后查看结果。"],
98
129
  "tools_checks_completed": ["Local checks completed at {time}.", "本机检查完成于 {time}。"],
99
130
  "tools_check_item": ["Check", "检查项"],
100
131
  "tools_github_signin": ["GitHub sign-in", "GitHub 登录"],
@@ -104,7 +135,7 @@
104
135
  "tools_needs_attention": ["Needs attention", "需要处理"],
105
136
  "tools_observed": ["Recorded", "已记录"],
106
137
  "tools_codex_connection": ["Codex connection", "Codex 连接"],
107
- "tools_config_scope": ["Review CCDX-managed fields before repair. Other settings are preserved.", "先查看 CCDX 管理的字段,再决定是否修复。其他设置保留。"],
138
+ "tools_config_scope": ["Review changes before repairing.", "先预览改动,再决定是否修复。"],
108
139
  "tools_review_repair": ["Review repair", "查看修复"],
109
140
  "tools_repair_preview": ["Repair preview", "修复预览"],
110
141
  "tools_managed_fields": ["Managed fields", "管理字段"],
@@ -116,8 +147,8 @@
116
147
  "tools_network_check": ["Network settings", "网络设置"],
117
148
  "tools_network_read_only": ["Network settings read. Proxy and certificate policies are unchanged.", "已读取网络设置,代理和证书策略保持不变。"],
118
149
  "tools_compatibility": ["Model compatibility", "模型兼容性"],
119
- "tools_compatibility_scope": ["This test sends model requests and uses quota. Run it explicitly in your terminal:", "此检查会调用模型并产生用量。请在终端明确执行:"],
120
- "tools_report_scope": ["Reports omit credentials, account details and chat content.", "报告不含凭据、账号详情和对话内容。"],
150
+ "tools_compatibility_scope": ["Sends model requests and uses quota. Run in your terminal.", "会调用模型并消耗额度,请在终端执行。"],
151
+ "tools_report_scope": ["Excludes credentials, account details and chat content.", "不含凭据、账号详情和对话内容。"],
121
152
  "tools_report_saved": ["Report exported. Share it only with people you trust.", "报告已导出,请仅分享给可信的人。"],
122
153
  "tools_read_failed": ["Could not read tool status. Restart the updated CCDX service.", "无法读取工具状态,请重启新版 CCDX。"],
123
154
  "tools_action_failed": ["Could not complete the action. Existing settings were preserved where possible.", "操作未完成,请查看当前状态。"],
@@ -161,15 +192,15 @@
161
192
  "update_attempted_time": ["Last attempt: {time}", "最近尝试:{time}"],
162
193
  "update_install_help": ["Update failed? View full installation commands", "更新遇到问题?查看完整安装指令"],
163
194
  "installation_platform": ["Installation platform", "安装平台"],
164
- "update_install_hint": ["Download the official installer. No Git required.", "下载官方安装器,无需 Git。"],
165
- "update_install_policy": ["Reuses compatible Node/npm or installs a private runtime. Keeps your registry, proxy, certificates and shell policy.", "复用可用的 Node/npm,否则安装专用运行环境。\n保留镜像、代理、证书和脚本策略。"],
166
- "update_windows_policy": ["If scripts are blocked, use your company’s approved installation method.", "若公司禁止运行脚本,请使用公司批准的安装方式。"],
195
+ "update_install_hint": ["Full installation commands · No Git required", "完整安装指令 · 无需 Git"],
196
+ "update_install_policy": ["Installs a private runtime if Node/npm is missing. Keeps registry, proxy, certificates and script policy.", "缺少 Node/npm 时安装专用运行环境。\n保留镜像、代理、证书和脚本策略。"],
197
+ "update_windows_policy": ["If scripts are blocked, use your company-approved installation method.", "脚本受限时,请使用公司批准的安装方式。"],
167
198
  "update_copy_unavailable": ["Clipboard unavailable. Select the command and copy it.", "无法自动复制,请选中指令复制。"],
168
199
  "company_account": ["Company account", "公司账号"],
169
200
  "check_accounts": ["Check accounts", "检查账号"],
170
201
  "choose_company_account": ["Choose a company account", "选择公司账号"],
171
202
  "use_this_account": ["Use this account", "使用此账号"],
172
- "company_account_scope": ["Applies to Microsoft 365 in Codex and Claude. Start a new conversation after changing accounts.", "影响 Codex 和 Claude 的 M365 服务。\n更换账号后请新建对话。"],
203
+ "company_account_scope": ["Shared by Codex and Claude. Start a new conversation after switching.", "供 Codex 和 Claude 共用。切换后请新建对话。"],
173
204
  "company_account_current": ["{login} · Tenant {tenant} · {source}", "{login}\n租户:{tenant} · {source}"],
174
205
  "account_source_windows": ["Windows sign-in", "Windows 登录账号"],
175
206
  "account_source_single": ["Only company account", "唯一公司账号"],
@@ -204,7 +235,7 @@
204
235
  "appearance_terminal_scope": ["Independent of the webpage theme.", "与网页主题分别设置。"],
205
236
  "appearance_terminal_effect": ["Table updates now. Startup logo changes next launch.", "表格即时换色,启动 Logo 下次生效。"],
206
237
  "appearance_sample": ["Sample data", "示例数据"],
207
- "theme_saved_browser": ["This browser only. Applies now.", "仅此浏览器,立即生效。"],
238
+ "theme_saved_browser": ["This browser only. Applies immediately.", "仅当前浏览器,立即生效。"],
208
239
  "theme_tab_only": ["This tab only. Browser storage is unavailable.", "本次有效,浏览器未能保存。"],
209
240
  "terminal_theme_applied": ["Table updated. Startup logo changes next launch.", "表格已换色,启动 Logo 下次生效。"],
210
241
  "terminal_theme_unavailable": ["Saved. Colored output is unavailable in this terminal mode.", "已保存,当前终端模式不显示配色。"],
@@ -236,11 +267,11 @@
236
267
  "prediction_integration_setup": ["Suggestion setup", "建议设置"],
237
268
  "visible_status_updates_every_2_seconds_catalogs_and_retained_usa": ["Visible status updates every 2 seconds. Catalogs and retained usage refresh on demand or every 30 minutes while open.", "可见状态每2秒更新。\n列表和留存用量按需更新,\n展开时每30分钟刷新。"],
238
269
  "request_records": ["Requests", "请求记录"],
239
- "source_changes_new_requests": ["Changes apply to later Codex requests.", "保存后用于新的 Codex 请求。"],
270
+ "source_changes_new_requests": ["Applies to new requests after saving.", "保存后用于新的请求。"],
240
271
  "conversation_model": ["Conversation model", "对话模型"],
241
272
  "github_model_in_codex": ["Choose your conversation model in Codex.", "在 Codex 中选择对话模型。"],
242
273
  "auto_review_settings": ["AUTO REVIEW", "自动审查"],
243
- "review_uses_selected_source": ["Reviews use the source above. First source setup saves the initial review choices; later review changes save separately.", "审查使用上方所选来源。首次切入时一并保存初始审查设置,之后分别保存。"],
274
+ "review_uses_selected_source": ["Uses the selected source above.", "使用上方选定的来源。"],
244
275
  "thinking_level": ["Thinking level", "思考强度"],
245
276
  "follow_client": ["Follow Codex (low if omitted)", "跟随 Codex(未指定时用 low)"],
246
277
  "save_review": ["Save review settings", "保存审查设置"],
@@ -266,12 +297,12 @@
266
297
  "allow_new_image_calls": ["Allow image requests", "图片生成"],
267
298
  "allow_prediction_configuration": ["Allow suggestion updates", "建议更新"],
268
299
  "check_and_repair": ["Check and repair", "检查修复"],
269
- "temporary_local_data_for_responses_continuation_not_a_conversati": ["Keeps temporary data to continue replies. Does not save a chat archive.", "临时保留续聊数据。\n不作为聊天归档。"],
300
+ "temporary_local_data_for_responses_continuation_not_a_conversati": ["Temporary reply continuation, not a chat archive.", "用于续接回复,不是聊天归档。"],
270
301
  "buffer_limit_mib": ["Buffer limit (MiB)", "暂存上限 MiB"],
271
302
  "apply_limit": ["Save limit", "保存上限"],
272
303
  "clear_inactive_buffer": ["Clear conversation buffer", "清空暂存"],
273
- "pause_keeps_the_provider_configuration_running_calls_can_finish_": ["Pause keeps your setup. Running image requests can finish. First setup: ccdx enable-image.", "暂停后保留图片设置。\n已开始的生成可继续完成。\n首次设置:\nccdx enable-image"],
274
- "pause_keeps_the_existing_trust_and_route_codex_may_retain_cached": ["Pause keeps existing trust and routing. Cached suggestions may still appear. First quit Codex, then run ccdx prediction on.", "暂停后保留信任与连接设置。\n已有建议可能仍会显示。\n首次设置前请退出 Codex。\nccdx prediction on"],
304
+ "pause_keeps_the_provider_configuration_running_calls_can_finish_": ["Existing image requests can finish after pausing.", "关闭后,已开始的生成仍会完成。"],
305
+ "pause_keeps_the_existing_trust_and_route_codex_may_retain_cached": ["Pausing keeps setup; cached suggestions may remain.", "暂停保留设置;已有建议仍可能显示。"],
275
306
  "service_settings": ["SERVICE SETTINGS", "服务设置"],
276
307
  "saved_preference_and_effective_state_are_separate_environment_ov": ["Saved choices and current behavior are shown separately. Startup overrides and required restarts are listed.", "已保存与已生效分别显示。\n启动限制与重启要求会注明。"],
277
308
  "terminal_animation": ["Terminal animation", "终端动效"],
@@ -287,10 +318,10 @@
287
318
  "process_listener": ["LOCAL SERVICE", "本机服务"],
288
319
  "http_traffic": ["SERVICE REQUESTS", "服务请求"],
289
320
  "this_run_usage": ["THIS RUN", "本次用量"],
290
- "updated_from_returned_usage_not_a_live_bill_pending_usage_is_not": ["Counts returned usage only. Pending usage is not included. This is not a live bill.", "仅统计已返回的用量。\n不含尚未返回的数据。\n不代表实时账单。"],
321
+ "updated_from_returned_usage_not_a_live_bill_pending_usage_is_not": ["Returned usage only.", "仅统计已返回用量。"],
291
322
  "applies_to_the_running_terminal": ["Updates the running terminal.", "保存后更新当前终端。"],
292
323
  "recent_inference_http_failures": ["RECENT REQUEST ISSUES", "近期异常"],
293
- "codex_responses_timing_since_startup_output_speed_is_estimated": ["Codex Responses timing since startup. Speed is estimated.", "记录本次 Codex 耗时。\n输出速度为估计值。"],
324
+ "codex_responses_timing_since_startup_output_speed_is_estimated": ["This service run · Estimated output speed", "本次运行 · 输出速度为估算"],
294
325
  "service_reachable": ["CONNECTED LOCALLY", "已连本机"],
295
326
  "saved_choice_applies_to_the_running_terminal": ["Saving updates the running terminal.", "保存后更新当前终端。"],
296
327
  "effective_now": ["Active now", "已生效"],
@@ -353,7 +384,7 @@
353
384
  "local_bridge": ["Local service", "本机服务"],
354
385
  "client_route": ["App settings requests", "应用请求"],
355
386
  "visible_candidate": ["Suggestion displayed", "建议显示"],
356
- "configured_does_not_mean_displayed_use_ccdx_prediction_status_fo": ["Enabled does not mean a suggestion appeared. Details: ccdx prediction status.", "开启不代表建议已显示。\nccdx prediction status"],
387
+ "configured_does_not_mean_displayed_use_ccdx_prediction_status_fo": ["Check suggestion status: ccdx prediction status", "检查建议状态:ccdx prediction status"],
357
388
  "enabled": ["Enabled", "已开启"],
358
389
  "disabled": ["Disabled", "已关闭"],
359
390
  "running_f4cca": ["Running", "运行中"],
@@ -406,8 +437,8 @@
406
437
  "outcome": ["RESULT", "结果"],
407
438
  "unknown": ["Unknown", "未知状态"],
408
439
  "no_observed_request_metadata": ["No request records yet.", "暂未收到请求记录。"],
409
- "20_latest_finished_requests_compactions_completed_completed_inco": ["Last 20 finished requests.\nHistory compaction: {completed} completed · {incomplete} incomplete · {failed} failed", "最近20次已结束请求。\n压缩完成:{completed}次\n压缩未完成:{incomplete}次\n压缩失败:{failed}次"],
410
- "recent_upstream_request_metadata_not_exact_live_session_occupanc": ["Size: MiB. Usage: Token.\nRequest records do not show exact current-chat usage.\nMissing data is unknown. This panel keeps no prompts or images.", "大小单位:MiB。\n用量单位:Token。\n不代表当前对话的精确占用。\n缺失数据表示未知。\n此面板不保存提问或图片。"],
440
+ "20_latest_finished_requests_compactions_completed_completed_inco": ["Last 20 finished requests · Compaction: {completed} completed · {incomplete} incomplete · {failed} failed", "最近 20 次已结束请求 · 上下文压缩:完成 {completed} · 未完成 {incomplete} · 失败 {failed}"],
441
+ "recent_upstream_request_metadata_not_exact_live_session_occupanc": ["No prompts or images are stored. — means unavailable data.", "不保存提问或图片。— 表示数据未知。"],
411
442
  "runtime_details": ["Runtime details", "运行详情"],
412
443
  "adapter": ["SERVICE", "服务状态"],
413
444
  "known_models": ["MODEL COUNT", "模型数量"],
@@ -418,7 +449,7 @@
418
449
  "incomplete": ["Incomplete", "未完成"],
419
450
  "failed": ["Failed", "失败"],
420
451
  "cancelled": ["Cancelled", "已取消"],
421
- "http_2xx_model_completed": ["HTTP success does not mean a complete reply.", "请求成功不代表回复完整。"],
452
+ "http_2xx_model_completed": ["HTTP status and model outcome are recorded separately.", "HTTP 状态与模型结果分别记录。"],
422
453
  "local_history": ["LOCAL HISTORY", "对话暂存"],
423
454
  "active_limit": ["STORAGE LIMIT", "暂存上限"],
424
455
  "history_cache_usage": ["Local history usage", "对话暂存"],
@@ -459,7 +490,7 @@
459
490
  "api": ["CONNECTION TYPE", "连接方式"],
460
491
  "flag": ["STAGE", "阶段"],
461
492
  "loading": ["Loading…", "加载中"],
462
- "catalog_listing_does_not_guarantee_inference_access": ["Listed does not mean your account can use it.", "列出不代表账号可使用。"],
493
+ "catalog_listing_does_not_guarantee_inference_access": ["Models listed; inference access not verified.", "模型已列出,推理权限尚未验证。"],
463
494
  "usage_by_model": ["Model usage", "模型用量"],
464
495
  "usage": ["MODEL USAGE", "模型用量"],
465
496
  "reading_log": ["COUNTING", "统计中"],
@@ -471,7 +502,7 @@
471
502
  "output": ["OUTPUT USAGE", "输出用量"],
472
503
  "total": ["TOTAL", "总用量"],
473
504
  "cache_hit": ["REUSE RATE", "复用比例"],
474
- "cache_hit_recorded_cached_input_tokens_incomplete_history_unavai": ["Unit: Token. Reused input is part of input.\n~ Partial records. — Unknown or invalid.", "用量单位:Token。\n复用部分已计入输入。\n~:记录不完整。\n—:数据未知或无效。"],
505
+ "cache_hit_recorded_cached_input_tokens_incomplete_history_unavai": ["Unit: Token. Reuse is included in input. ~ Partial; — Unknown.", "单位 Token;复用已计入输入。~ 为部分记录,— 为未知。"],
475
506
  "usage_analytics": ["USAGE TRENDS", "用量趋势"],
476
507
  "model_5e2c6": ["Model", "模型"],
477
508
  "all_models": ["All models", "全部模型"],
@@ -482,7 +513,7 @@
482
513
  "activity": ["Measure", "统计内容"],
483
514
  "calls_b73a5": ["Requests", "请求次数"],
484
515
  "tokens": ["Usage (Token)", "处理用量"],
485
- "open_to_read_retained_usage_history": ["Open to view usage trends.", "展开查看用量趋势。"],
516
+ "open_to_read_retained_usage_history": ["Loading usage trends…", "读取用量趋势中…"],
486
517
  "daily_tokens": ["DAILY USAGE", "每日用量"],
487
518
  "input_output_cache_included_in_input": ["INPUT + OUTPUT / REUSED INPUT IS PART OF INPUT", "输入与输出合计。\n复用部分已计入输入。"],
488
519
  "daily_token_usage": ["Daily usage in Token", "每日用量"],
@@ -490,12 +521,12 @@
490
521
  "output_b2439": ["Output usage", "输出用量"],
491
522
  "request_activity_365_days": ["ACTIVITY · LAST 365 DAYS", "活跃日历"],
492
523
  "daily_recorded_request_activity": ["Daily recorded activity over 365 days", "每日活跃"],
493
- "select_a_day_to_inspect_its_model_totals_no_history_is_distinct_": ["Select a day for its usage. No records does not mean zero requests.", "点击日期查看当天用量。\n没有记录不等于零次请求。"],
524
+ "select_a_day_to_inspect_its_model_totals_no_history_is_distinct_": ["Select a day for usage. Blank means no records.", "点击日期查看当天用量。空白表示无记录。"],
494
525
  "recent_failures": ["Recent issues", "异常记录"],
495
526
  "recent_response_failures": ["RECENT ISSUES", "异常记录"],
496
527
  "reading_874bf": ["Reading…", "读取中"],
497
528
  "reading_status": ["Reading status…", "读取中"],
498
- "upstream_messages_may_contain_sensitive_text": ["Error details may include private data.", "错误详情可能含隐私信息。"],
529
+ "upstream_messages_may_contain_sensitive_text": ["Review private information before sharing error details.", "分享错误详情前,请检查其中的隐私信息。"],
499
530
  "terminal_animation_9edf6": ["TERMINAL ANIMATION", "终端动效"],
500
531
  "animation_theme": ["Animation style", "动效样式"],
501
532
  "save_selection": ["Save animation", "保存动效"],
@@ -641,7 +672,7 @@
641
672
  "no_requests_observed": ["No requests observed.", "尚未收到请求。"],
642
673
  "protocol": ["Protocol", "请求接口"],
643
674
  "active": ["Active", "进行中"],
644
- "results_since_startup_partial_usage_is_marked_separately": ["Results since startup. Partial usage is marked separately.", "统计本次运行的请求。\n用量缺失会单独标明。"],
675
+ "results_since_startup_partial_usage_is_marked_separately": ["This service run", "本次运行"],
645
676
  "claude_code_code_claude_app_app": ["Claude Code: {code} / Claude App: {app}", "Claude Code:{code}\nClaude App:{app}"],
646
677
  };
647
678
  // Compatibility for runtime state names and server diagnostic messages.
@@ -173,7 +173,9 @@
173
173
  localize(copy, "copied");
174
174
  } catch { localize(copy, "copy_unavailable"); }
175
175
  });
176
- details.append(title, diagnostic, copy);
176
+ const privacy = document.createElement("p");privacy.className = "hint";
177
+ localize(privacy, "upstream_messages_may_contain_sensitive_text");
178
+ details.append(title, diagnostic, privacy, copy);
177
179
  item.append(details);
178
180
  list.append(item);
179
181
  }
@@ -181,6 +183,7 @@
181
183
 
182
184
  function render(data) {
183
185
  globalThis.ccdxDashboardActivity?.update(data.model_activity);
186
+ globalThis.ccdxDashboardFlow?.update(data);
184
187
  text("version", `v${data.version || "?"}`);
185
188
  text("uptime", "pid_pid_uptime_duration", { pid: number(data.pid), duration: duration(data.uptime_ms) });
186
189
 
@@ -199,6 +202,11 @@
199
202
  const outcomes = data.stream_performance?.by_route?.responses?.terminal_outcomes?.totals || {};
200
203
  for (const key of ["completed", "incomplete", "failed", "cancelled"]) text(key, number(outcomes[key]));
201
204
  const timing = data.stream_performance?.by_route?.responses || {};
205
+ function percentiles(id, metric) {
206
+ const valid = metric?.samples > 0 && metric.percentiles_estimated === true && finite(metric.p50) && finite(metric.p95);
207
+ text(id, valid ? "percentile_values" : "—", valid ? { p50: Number(metric.p50).toFixed(0), p95: Number(metric.p95).toFixed(0), samples: number(metric.samples) } : {});
208
+ }
209
+ percentiles("ttft-percentiles", timing.ttft_ms);
202
210
  for (const [id, metric, scale, unit] of [["ttft", timing.ttft_ms, 1, "ms"], ["tpot", timing.output_tokens_per_second, 1, "token/s"]]) {
203
211
  const value = metric?.samples > 0 && finite(metric.avg) ? `${(Number(metric.avg) / scale).toFixed(1)} ${unit}` : "—";
204
212
  text(id, "value_samples_samples", { value, samples: number(metric?.samples) });
@@ -218,6 +226,7 @@
218
226
  : "setup_state_unknown_ccdx_image_status", { active: number(image?.active), failed: number(image?.failed), delivery: number(image?.delivery_failures) });
219
227
 
220
228
  const claude = data.providers?.m365?.claude, claudeMetrics = claude?.requests?.performance;
229
+ percentiles("claude-ttft-percentiles", claudeMetrics?.by_route?.messages?.ttft_ms);
221
230
  const sourceBody = element("source-requests-body");
222
231
  if (sourceBody) {
223
232
  sourceBody.replaceChildren();
@@ -80,6 +80,7 @@ table { width: 100%; border-collapse: collapse; font-size: 11px; }
80
80
  th { color: var(--heading); text-align: left; font-weight: 700; letter-spacing: .05em; }
81
81
  th, td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--border); white-space: nowrap; }
82
82
  th:last-child, td:last-child { padding-right: 0; }
83
+ tbody tr:last-child td { border-bottom: 0; }
83
84
  td { color: var(--table-text); }
84
85
  .usage-table th:not(:first-child), .usage-table td:not(:first-child) { text-align: right; }
85
86
  .usage-table tr.total-row td { color: var(--accent); font-weight: 700; }
@@ -187,15 +188,15 @@ footer { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; color:
187
188
  .topbar-actions { gap: 12px; flex-wrap: nowrap; }
188
189
  .topbar-actions #connection { width: 154px; flex: none; }
189
190
  .topbar-actions #auto-refresh { width: 164px; flex: none; }
190
- .intro { display: block; padding: 32px 0 26px; min-height: 132px; }
191
- .intro .page-description { margin-top: 14px; line-height: 1.7; }
191
+ .intro { display: block; padding: 32px 0 26px; min-height: 98px; }
192
192
  main { align-self: start; }
193
+ #main-content:focus { outline: none; }
193
194
  .section-link { display: inline-block; color: var(--accent); font-size: 12px; text-underline-offset: 3px; }
194
195
  .section-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
195
196
  .model-summary strong { color: var(--strong); }
196
197
  .panel h3 { color: var(--heading); font-size: 12px; font-weight: 650; margin: 0; }
197
198
  .setting-row + .tool-details { border-top: 0; padding-top: 0; }
198
- .diagnostic-section + .diagnostic-section { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); }
199
+ .diagnostic-section + .diagnostic-section { margin-top: 26px; }
199
200
  .diagnostic-section > strong { display: block; color: var(--strong); font-size: 23px; margin-top: 16px; }
200
201
  .usage-source-controls { margin: 0 0 20px; }
201
202
  .chart-heading { flex-wrap: wrap; align-items: end; }
@@ -215,7 +216,7 @@ main { align-self: start; }
215
216
  .section-actions label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; max-width: 100%; }
216
217
  .section-actions input, .section-actions select { max-width: 100%; min-height: 36px; }
217
218
  input[type="number"] { width: 120px; font: inherit; color: var(--text); background: var(--page); border: 1px solid var(--border); padding: 7px; }
218
- .setting-row { display: grid; grid-template-columns: minmax(160px, 1fr) 44px minmax(0, 1.4fr); align-items: center; gap: 16px; padding: 20px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
219
+ .setting-row { display: grid; grid-template-columns: minmax(160px, 1fr) 44px minmax(0, 1.4fr); align-items: center; gap: 16px; padding: 20px 0; font-size: 13px; }
219
220
  .setting-row .hint { margin: 0; }
220
221
  input[role="switch"] { appearance: none; width: 38px; height: 22px; border: 1px solid var(--button-border); border-radius: 20px; background: var(--border); cursor: pointer; margin: 0; position: relative; }
221
222
  input[role="switch"]::before { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; border-radius: 50%; background: var(--muted); }
@@ -273,7 +274,7 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
273
274
  .appearance-label p { margin:4px 0 0; font-size:12px; color:var(--subtle); line-height:1.7; }
274
275
  .appearance-select { width:100%; max-width:100%; min-width:0; height:36px; box-sizing:border-box; border-radius:0; padding:0 30px 0 10px; font-size:12px; }
275
276
  .appearance-note { color:var(--subtle); margin:17px 0 0; font-size:12px; line-height:1.7; }
276
- .appearance-animation { margin-top:22px; border-top:1px solid var(--border); padding-top:18px; }
277
+ .appearance-animation { margin-top:22px; }
277
278
  .terminal-animation-toggle { border-bottom:0; }
278
279
  .sidebar nav a { display:flex; align-items:center; gap:10px; }
279
280
  .nav-icon { width:17px; height:17px; flex:none; fill:none; stroke:currentColor; stroke-width:1.5; stroke-linecap:round; stroke-linejoin:round; }
@@ -282,6 +283,7 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
282
283
  .version-heading h2 { margin:0; }
283
284
  .version-list { margin:18px 0 0; }
284
285
  .version-list > div { display:grid; grid-template-columns:minmax(110px,1fr) auto minmax(150px,1fr); align-items:baseline; gap:16px; padding:14px 0; border-bottom:1px solid var(--border); }
286
+ .version-list > div:last-child { border-bottom:0; }
285
287
  .version-list dt { font-size:12px; }
286
288
  .version-list dd { margin:0; }
287
289
  .version-list dd:nth-child(2) { font-size:18px; font-weight:650; color:var(--strong); }
@@ -377,12 +379,11 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
377
379
  .state-label.state-unavailable, .state-label.state-unknown { color:var(--muted); }
378
380
  .state-label > span { color:inherit; white-space:normal; }
379
381
  .badge:has(.state-label)::before { display:none; }
380
- .source-browse-note { margin:12px 0 20px; }
381
382
  .account-name { margin:18px 0 6px; font-size:19px; color:var(--strong); font-weight:650; overflow-wrap:anywhere; }
382
383
  .account-fields { display:grid; grid-template-columns:minmax(110px,150px) minmax(0,1fr); gap:10px 18px; margin:20px 0; font-size:12px; line-height:1.7; }
383
384
  .account-fields dt { color:var(--muted); }
384
385
  .account-fields dd { margin:0; min-width:0; }
385
- .tool-details, .tool-flow { margin-top:18px; padding-top:16px; border-top:1px solid var(--border); }
386
+ .tool-details, .tool-flow { margin-top:22px; }
386
387
  .tool-details summary, .tool-flow h3 { color:var(--heading); font-size:12px; }
387
388
  .device-code { display:block; color:var(--accent); font-size:23px; letter-spacing:.1em; margin:16px 0; }
388
389
  .tool-link { display:inline-flex; min-height:36px; align-items:center; color:var(--accent); margin-right:16px; }
@@ -400,3 +401,47 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
400
401
  .account-summary .state-label { gap: 6px; }
401
402
  .source-account-actions { margin-top: 18px; }
402
403
  @media(max-width:640px) { .account-summary { grid-template-columns:1fr; } }
404
+
405
+ .flow-network { position:relative;display:grid;grid-template-columns:minmax(130px,1fr) 100px minmax(170px,1.2fr);column-gap:clamp(36px,6vw,92px);align-items:center;min-height:216px;margin:26px 0 18px;padding:4px 0; }
406
+ .flow-wires { position:absolute;inset:0;width:100%;height:100%;pointer-events:none;overflow:visible; }
407
+ .flow-column,.flow-hub-column { position:relative;min-width:0; }
408
+ .flow-column-title { margin:0 0 20px;color:var(--muted);font-size:11px; }
409
+ .flow-node { display:grid;grid-template-columns:minmax(0,max-content) auto;align-items:center;gap:4px 10px;min-height:65px; }
410
+ .flow-choice { justify-self:start;max-width:100%;min-height:34px;padding:7px 9px;border-color:transparent;background:transparent;color:var(--text);font-size:12px;font-weight:600;text-transform:none;text-align:left;overflow-wrap:anywhere; }
411
+ .flow-choice:hover { background:var(--option-hover); }
412
+ .flow-choice[aria-pressed="true"],.flow-choice[aria-pressed="true"]:hover { color:var(--page);background:var(--accent);border-color:var(--accent); }
413
+ .flow-count { justify-self:end;color:var(--strong);font-size:12px;font-variant-numeric:tabular-nums; }
414
+ .flow-note { grid-column:1/-1;margin:0 0 14px 9px;color:var(--muted);font-size:10px; }
415
+ .flow-source { color:var(--muted);font-size:10px;margin:14px 0 10px 9px; }
416
+ .flow-source:first-child { margin-top:0; }
417
+ .flow-node[data-related="false"] { opacity:.5; }
418
+ #flow-hub { display:flex;flex-direction:column;align-items:center;gap:9px;width:100%;border:0;background:var(--surface);color:var(--text);padding:10px 0;text-transform:none; }
419
+ #flow-hub:hover { color:var(--accent); }
420
+ .flow-logo { width:34px;height:34px;color:var(--accent); }
421
+ #flow-hub small { font-size:10px;font-weight:400;color:var(--muted);white-space:normal; }
422
+ .flow-caption { display:flex;align-items:center;flex-wrap:wrap;gap:10px 16px;min-height:30px;font-size:11px;color:var(--muted); }
423
+ .flow-caption button { padding:5px 9px; }
424
+ .flow-wire { fill:none;stroke:var(--border);stroke-width:1;stroke-linecap:round;stroke-linejoin:round; }
425
+ .flow-live { stroke:var(--accent);opacity:.55; }
426
+ .flow-dim { opacity:.35; }
427
+ .flow-packet,.flow-wait { fill:var(--accent); }
428
+ .flow-packet { offset-distance:100%;animation:flow-travel 2.4s linear infinite; }
429
+ #request-flow[data-paused="true"] .flow-packet,#request-flow[data-paused="true"] #flow-state::before { animation-play-state:paused; }
430
+ #request-flow[data-state="idle"] #flow-state { display:inline-flex;align-items:center;gap:9px; }
431
+ #request-flow[data-state="idle"] #flow-state::before { content:"";width:4px;height:4px;border-radius:50%;background:var(--accent);box-shadow:0 0 10px 3px color-mix(in srgb,var(--accent) 25%,transparent);animation:flow-breathe 3.2s ease-in-out infinite; }
432
+ @keyframes flow-travel { from { offset-distance:100%; } to { offset-distance:0%; } }
433
+ @keyframes flow-breathe { 0%,100% { opacity:.45; } 50% { opacity:1; } }
434
+ @media(max-width:760px) {
435
+ .flow-network { grid-template-columns:minmax(105px,1fr) 66px minmax(120px,1fr);column-gap:18px; }
436
+ .flow-choice { font-size:11px;padding-inline:4px; }
437
+ .flow-node { column-gap:4px; }
438
+ .flow-source,.flow-note { margin-left:4px; }
439
+ }
440
+ @media(max-width:460px) {
441
+ .flow-network { grid-template-columns:minmax(80px,1fr) 48px minmax(100px,1fr);column-gap:12px; }
442
+ .flow-column-title,.flow-source,.flow-note,#flow-hub small { font-size:9px; }
443
+ .flow-node { grid-template-columns:minmax(0,1fr) auto; }
444
+ .flow-count { font-size:10px; }
445
+ .flow-logo { width:26px;height:26px; }
446
+ }
447
+ @media(prefers-reduced-motion:reduce) { .flow-packet,#request-flow[data-state="idle"] #flow-state::before { animation:none; } }
@@ -255,6 +255,7 @@ const dashboardRefresh = globalThis.ccdxRefresh.createController({
255
255
  apply: render,
256
256
  state: state => {
257
257
  if (state.error || !state.value) globalThis.ccdxDashboardActivity?.unavailable();
258
+ if (state.error || !state.value) globalThis.ccdxDashboardFlow?.unavailable();
258
259
  text("connection", state.pending && !state.value ? "reading" : state.error ? "unavailable_eb0be" : "service_reachable");
259
260
  element("connection").className = `badge ${state.pending ? "neutral" : state.error ? "bad" : "good"}`;
260
261
  globalThis.ccdxIcons?.set(element("connection"), state.pending && !state.value ? "reading" : state.error ? "unavailable_eb0be" : "service_reachable",
package/src/dashboard.mjs CHANGED
@@ -13,6 +13,7 @@ const ASSETS = new Map([
13
13
  ["/time.js", ["./dashboard/time.js", "text/javascript; charset=utf-8"]],
14
14
  ["/status.js", ["./dashboard/status.js", "text/javascript; charset=utf-8"]],
15
15
  ["/activity.js", ["./dashboard/activity.js", "text/javascript; charset=utf-8"]],
16
+ ["/flow.js", ["./dashboard/flow.js", "text/javascript; charset=utf-8"]],
16
17
  ["/usage.js", ["./dashboard/usage.js", "text/javascript; charset=utf-8"]],
17
18
  ["/refresh.js", ["./dashboard/refresh.js", "text/javascript; charset=utf-8"]],
18
19
  ["/icons.js", ["./dashboard/icons.js", "text/javascript; charset=utf-8"]],
@@ -1,4 +1,4 @@
1
- export const DASHBOARD_PATHS = new Set(["/", "/ui.css", "/theme.js", "/language.js", "/refresh.js", "/time.js", "/animation.js", "/status.js", "/activity.js", "/usage.js", "/ui.js", "/console.js", "/updates.js", "/icons.js", "/tools.js"]);
1
+ export const DASHBOARD_PATHS = new Set(["/", "/ui.css", "/theme.js", "/language.js", "/refresh.js", "/time.js", "/animation.js", "/status.js", "/activity.js", "/flow.js", "/usage.js", "/ui.js", "/console.js", "/updates.js", "/icons.js", "/tools.js"]);
2
2
  export const DASHBOARD_API_PATHS = new Set(["/_ccdx/ui/animation", "/_ccdx/ui/models/live", "/_ccdx/ui/usage", "/_ccdx/ui/auth", "/_ccdx/ui/providers", "/_ccdx/ui/settings", "/_ccdx/ui/m365/accounts", "/_ccdx/ui/updates", "/_ccdx/ui/account", "/_ccdx/ui/checks"]);
3
3
 
4
4
  export function isOptionalRoute(method, pathname) {
@@ -0,0 +1,15 @@
1
+ const APPLICATIONS = new Set(["codex_app", "codex_cli", "claude_app", "claude_code", "claude", "api"]);
2
+ const DECLARED = new Map([["codex-app", "codex_app"], ["codex-cli", "codex_cli"], ["claude-app", "claude_app"], ["claude-code", "claude_code"]]);
3
+ const ORIGINATORS = new Map([["codex_desktop", "codex_app"], ["codex_app", "codex_app"], ["codex_cli_rs", "codex_cli"]]);
4
+
5
+ export function requestApplication(headers = {}, fallback = "api") {
6
+ const declared = DECLARED.get(headers?.["x-ccdx-client"]);
7
+ if (declared) return declared;
8
+ // These are client-reported presentation hints, never routing or auth evidence.
9
+ const originator = ORIGINATORS.get(headers?.originator);
10
+ return originator || (APPLICATIONS.has(fallback) ? fallback : "api");
11
+ }
12
+
13
+ export function applicationLabel(value) {
14
+ return APPLICATIONS.has(value) ? value : "api";
15
+ }
@@ -1,6 +1,7 @@
1
1
  import { performance } from "node:perf_hooks";
2
2
  import { currentRequestContext } from "./request-context.mjs";
3
3
  import { isProviderId } from "./provider-metadata.mjs";
4
+ import { applicationLabel } from "./request-application.mjs";
4
5
 
5
6
  const PERFORMANCE_ROUTES = Object.freeze(["responses", "responses_compact"]);
6
7
  const PREPARATION_STAGES = Object.freeze(["admission", "body", "history", "images", "serialization"]);
@@ -12,6 +13,7 @@ const TERMINAL_ORIGINS = new Set([
12
13
  ]);
13
14
  const MAX_MODEL_OUTCOME_LABELS = 32;
14
15
  const MAX_RECENT_REQUESTS = 20;
16
+ const MAX_ACTIVE_REQUESTS = 64;
15
17
  const MAX_PROVIDER_LABELS = 16;
16
18
  const PREPARATION_EDGES_MS = Object.freeze([1, 2, 5, 10, 20, 50, 100, 250, 500, 1_000, 5_000, 30_000, 120_000]);
17
19
  const TTFT_EDGES_MS = Object.freeze([
@@ -119,11 +121,24 @@ function histogramSnapshot(histogram, unit) {
119
121
  return bucket;
120
122
  });
121
123
  buckets.push({ lower, upper: null, count: histogram.counts.at(-1) });
124
+ const percentile = fraction => {
125
+ if (!histogram.samples) return null;
126
+ const rank = Math.ceil(histogram.samples * fraction);
127
+ let count = 0;
128
+ for (const bucket of buckets) {
129
+ count += bucket.count;
130
+ if (count >= rank) return Math.min(bucket.upper ?? histogram.max, histogram.max);
131
+ }
132
+ return null;
133
+ };
122
134
  return {
123
135
  unit,
124
136
  samples: histogram.samples,
125
137
  avg: histogram.samples > 0 ? Number((histogram.total / histogram.samples).toFixed(1)) : 0,
126
138
  max: histogram.max,
139
+ p50: percentile(0.5),
140
+ p95: percentile(0.95),
141
+ percentiles_estimated: true,
127
142
  buckets,
128
143
  };
129
144
  }
@@ -199,12 +214,18 @@ function routeSnapshot(route) {
199
214
  export function createStreamPerformanceMetrics({ now = () => performance.now(), wallNow = () => new Date().toISOString(), routeNames = PERFORMANCE_ROUTES } = {}) {
200
215
  const routes = Object.fromEntries(routeNames.map((name) => [name, createRoutePerformance()]));
201
216
  const recentRequests = [];
217
+ const activeRequests = new Map();
218
+ let activeTotal = 0, activeSequence = 0;
202
219
 
203
220
  return {
204
- begin(routeName, { requestId } = {}) {
221
+ begin(routeName, { requestId, application } = {}) {
205
222
  const route = routes[routeName];
206
223
  if (!route) return null;
207
224
  const requestStartedAt = now();
225
+ const activeId = ++activeSequence;
226
+ const safeRequestId = typeof requestId === "string" && /^[a-zA-Z0-9_-]{1,80}$/.test(requestId) ? requestId : null;
227
+ const client = applicationLabel(application);
228
+ activeTotal++;
208
229
  let upstreamStartedAt = null;
209
230
  let firstOutputAt = null;
210
231
  let firstOutputSource = null;
@@ -229,6 +250,12 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
229
250
  let terminalAt = null;
230
251
  const context = { payload_bytes: null, images: null, input_tokens: null, context_window_tokens: null };
231
252
  const elapsed = (time) => time === null ? null : Number(Math.max(0, time - requestStartedAt).toFixed(1));
253
+ if (activeRequests.size < MAX_ACTIVE_REQUESTS) activeRequests.set(activeId, () => ({
254
+ request_id: safeRequestId, application: client, route: routeName, provider, model, phase,
255
+ started_at: at, elapsed_ms: elapsed(now()), first_output_ms: elapsed(firstOutputAt),
256
+ upstream_attempts: attempts, terminal_outcome: terminalOutcome,
257
+ attempts: attemptTimings.map(attempt => ({ ...attempt })),
258
+ }));
232
259
  const assignProvider = value => {
233
260
  if (finished || sourceStats || !isProviderId(value)) return;
234
261
  provider = value;
@@ -322,6 +349,7 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
322
349
  if (finished) return;
323
350
  if (!sourceStats) assignProvider("unknown");
324
351
  finished = true;
352
+ activeTotal--;activeRequests.delete(activeId);
325
353
  failed ||= finishFailed;
326
354
  const outcome = terminalOutcome || (aborted ? "cancelled" : "unknown");
327
355
  const emptyStreamCompletion = outcome === "completed" && upstreamStartedAt !== null
@@ -347,7 +375,7 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
347
375
  const finishedAt = now();
348
376
  // Only scalar, allowlisted metadata survives the request; never retain payloads.
349
377
  recentRequests.push({
350
- request_id: typeof requestId === "string" && /^[a-zA-Z0-9_-]{1,80}$/.test(requestId) ? requestId : null,
378
+ request_id: safeRequestId, application: client,
351
379
  at, route: routeName, model, outcome, origin, phase,
352
380
  ...(provider ? { provider } : {}),
353
381
  empty_stream_completion: emptyStreamCompletion,
@@ -394,6 +422,9 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
394
422
  snapshot() {
395
423
  return {
396
424
  by_route: Object.fromEntries(routeNames.map((name) => [name, routeSnapshot(routes[name])])),
425
+ active_requests: [...activeRequests.values()].map(snapshot => snapshot()),
426
+ active_total: activeTotal,
427
+ active_omitted: Math.max(0, activeTotal - activeRequests.size),
397
428
  recent_requests: recentRequests.map((entry) => ({ ...entry, attempts: entry.attempts.map(attempt => ({ ...attempt })), context: { ...entry.context }, timings_ms: { ...entry.timings_ms } })),
398
429
  };
399
430
  },