codex-copilot-dx 1.2.10 → 1.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/docs/ARCHITECTURE.md +64 -1
- package/docs/REFERENCE.md +65 -2
- package/package.json +1 -1
- package/src/adapter.mjs +2 -1
- package/src/claude-gateway.mjs +2 -1
- package/src/dashboard/console.js +3 -3
- package/src/dashboard/flow.js +170 -0
- package/src/dashboard/index.html +34 -22
- package/src/dashboard/language.js +77 -41
- package/src/dashboard/status.js +10 -1
- package/src/dashboard/ui.css +70 -18
- package/src/dashboard/ui.js +2 -1
- package/src/dashboard.mjs +1 -0
- package/src/optional-routes.mjs +1 -1
- package/src/request-application.mjs +21 -0
- package/src/stream-performance.mjs +33 -2
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.
|
|
17
|
+
No Node or Git? Download [install.sh](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.12/install.sh) (macOS/Linux) or [install.ps1](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.12/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
|
|
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. Single routes stay straight; concurrent counts sit beside names. Name selections filter active details only. Codex client hints are recognized conservatively; unknown apps stay unidentified. 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.12 changes and verification](https://github.com/DaleXiao/codex-copilot-dx/blob/main/docs/RELEASE_1.2.12.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 |
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -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
|
|
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,66 @@ 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.
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
## Flow layout and client-hint correction (1.2.12)
|
|
503
|
+
|
|
504
|
+
`request-application.mjs` normalizes bounded scalar hints using an explicit map.
|
|
505
|
+
The map now recognizes `Codex Desktop`, observed in local desktop session metadata
|
|
506
|
+
and replayed through the bundled official app-server, as well as existing compact
|
|
507
|
+
names. A bounded, anchored, versioned Codex User-Agent is a fallback only. Generic
|
|
508
|
+
Codex evidence maps to a new `codex` family label; the existing `api` value remains
|
|
509
|
+
the unknown fallback. No raw hint is stored, and this classification does not
|
|
510
|
+
participate in routing, security, credentials or provider affinity.
|
|
511
|
+
|
|
512
|
+
Flow sources/status notes sit outside the name's layout height; both node columns
|
|
513
|
+
share the same header track. The hub shares that track offset. SVG anchors use
|
|
514
|
+
measured name-button centers, replacing fixed pixel assumptions. This keeps single
|
|
515
|
+
and shared concurrent routes straight across locale/wrapping changes. Branches
|
|
516
|
+
reuse the existing rounded-path geometry. Model counts are inline siblings of the
|
|
517
|
+
name, with reserved narrow-layout space; singleton counts and duplicate hub totals
|
|
518
|
+
are removed. Existing caps, freshness, pause/reduced-motion behavior, selection
|
|
519
|
+
scope and global summary semantics are unchanged.
|
|
520
|
+
|
|
521
|
+
The toolbar measures its longer localized on/off text with an inaccessible,
|
|
522
|
+
visually hidden grid sibling; only its visible label is localized dynamically.
|
|
523
|
+
Language controls have intrinsic width and no-wrap/no-shrink. Shared button-link
|
|
524
|
+
styling keeps the M365 navigation link semantically a link while matching the
|
|
525
|
+
existing GitHub shortcut; wording describes navigation rather than a silent check.
|
|
526
|
+
No new polling, framework, runtime dependency, setting or endpoint is introduced.
|
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.
|
|
1040
|
+
npm install -g https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.12/codex-copilot-dx-1.2.12.tgz
|
|
1041
1041
|
# Windows PowerShell: use npm.cmd instead of npm.
|
|
1042
1042
|
```
|
|
1043
1043
|
|
|
@@ -1588,3 +1588,66 @@ 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, including the actual
|
|
1601
|
+
`Codex Desktop` spelling. Explicit client hints take precedence, followed by known
|
|
1602
|
+
originators, then known versioned Codex User-Agent prefixes. A generic `codex`
|
|
1603
|
+
prefix identifies only the Codex family, not App versus CLI. Unknown clients are
|
|
1604
|
+
shown as Unidentified app (the existing `api` metadata ID is retained); unmarked
|
|
1605
|
+
Messages requests remain Claude (app unspecified). These are client-reported
|
|
1606
|
+
presentation hints, never verified identities, authorization or routing inputs.
|
|
1607
|
+
Only bounded scalar strings are inspected; no User-Agent/header text is retained.
|
|
1608
|
+
An unrelated agent containing the word Codex does not match.
|
|
1609
|
+
|
|
1610
|
+
Only observed first output starts moving dots. A started attempt without output
|
|
1611
|
+
is waiting, a subsequent attempt is retrying, and terminal evidence awaiting
|
|
1612
|
+
connection completion is finishing. No fresh status for six seconds means unknown,
|
|
1613
|
+
not idle or successful. Auto refresh off therefore expires the view. Hidden pages
|
|
1614
|
+
pause animation; reduced-motion uses static dots. Idle retains bounded last-known
|
|
1615
|
+
nodes with zero counts; unknown retained counts are dashes. Initially up to 12
|
|
1616
|
+
model groups are visible, with an explicit show-more control. Snapshots retain up
|
|
1617
|
+
to 64 details per metrics instance; exact active totals may be higher and omitted
|
|
1618
|
+
details are reported. With omitted details, observed group counts use ≥; retained
|
|
1619
|
+
nodes with no current detail use dashes, even while the exact total is active. Short requests between two status reads can appear only in
|
|
1620
|
+
the finished table; the diagram does not fabricate or replay them.
|
|
1621
|
+
|
|
1622
|
+
A single app/source-model route has aligned name/hub anchors and straight paths,
|
|
1623
|
+
even when multiple requests share that route. Branches alone use rounded curves.
|
|
1624
|
+
Known singleton and idle-zero node counts are hidden. Concurrent counts read
|
|
1625
|
+
“2 requests” beside the name and outside its selected area; lower bounds retain ≥
|
|
1626
|
+
and missing/stale counts remain dashes. The exact active total appears once in
|
|
1627
|
+
the flow header, not again below the logo.
|
|
1628
|
+
|
|
1629
|
+
Clicking an app or model name filters only active details. Counts, source totals,
|
|
1630
|
+
all five terminal outcomes (including unknown), last 20 finished requests and
|
|
1631
|
+
issues remain available. No prompt/image/credential is added to active telemetry.
|
|
1632
|
+
The existing local-dashboard host/origin protections apply to the new flow asset.
|
|
1633
|
+
|
|
1634
|
+
Codex and Claude request-performance panels show approximate first-output P50/P95
|
|
1635
|
+
in milliseconds with sample counts. Values come from existing histogram buckets,
|
|
1636
|
+
not raw samples; the highest bucket uses the observed maximum. These are the
|
|
1637
|
+
upstream first-output observations already used for the mean, include failures
|
|
1638
|
+
after partial output, and do not measure user-perceived completion or promise a
|
|
1639
|
+
routing improvement. No samples displays a dash.
|
|
1640
|
+
|
|
1641
|
+
|
|
1642
|
+
### Account shortcuts and compact toolbar (1.2.12)
|
|
1643
|
+
|
|
1644
|
+
Checks & repairs offers equal-height GitHub account / M365 account shortcuts.
|
|
1645
|
+
Both open the corresponding model-source page; neither starts a connection check,
|
|
1646
|
+
account enumeration, login or model call. Actual checks stay on that source page.
|
|
1647
|
+
The M365 shortcut retains link semantics and the shared button appearance.
|
|
1648
|
+
|
|
1649
|
+
Auto refresh has content-based width, sized for the longer localized on/off label
|
|
1650
|
+
so toggling it does not shift nearby controls. The language control has a 40px
|
|
1651
|
+
minimum width, cannot flex-shrink and keeps 中文 / EN on one line. Compact toolbars
|
|
1652
|
+
wrap when required rather than compressing text; header position remains stable
|
|
1653
|
+
between modules in the same language and viewport.
|
package/package.json
CHANGED
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 {
|
package/src/claude-gateway.mjs
CHANGED
|
@@ -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;
|
package/src/dashboard/console.js
CHANGED
|
@@ -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,170 @@
|
|
|
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", "codex", "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", "codex", "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
|
+
for (const group of groups) {
|
|
46
|
+
let node = cache.get(group.id);
|
|
47
|
+
if (!node) {
|
|
48
|
+
node = entry("div", "flow-node");
|
|
49
|
+
const button = entry("button", "flow-choice"), count = entry("span", "flow-count"), note = entry("span", "flow-note");button.type = "button";
|
|
50
|
+
button.addEventListener("click", () => {
|
|
51
|
+
selected = selected?.type === type && selected.id === group.id ? null : { type, id: group.id };
|
|
52
|
+
el("flow-active").open = Boolean(selected);lastSignature = "";render();
|
|
53
|
+
});
|
|
54
|
+
node.append(button, count, note);
|
|
55
|
+
if (type === "models") node.append(entry("span", "flow-source"));
|
|
56
|
+
cache.set(group.id, node);
|
|
57
|
+
}
|
|
58
|
+
const [button, count, note] = node.children;
|
|
59
|
+
button.textContent = type === "apps" ? appName(group.id) : modelName(group.model);
|
|
60
|
+
button.setAttribute("aria-pressed", String(selected?.type === type && selected.id === group.id));
|
|
61
|
+
count.hidden = fresh && omitted === 0 && group.rows.length < 2;
|
|
62
|
+
if (fresh && (group.rows.length || total === 0)) label(count, omitted ? "flow_count_lower" : "flow_count", { count: group.rows.length.toLocaleString() });
|
|
63
|
+
else count.textContent = "—";
|
|
64
|
+
if (type === "models") node.children[3].textContent = sourceName(group.provider);
|
|
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 ? group.rows.length === 1 ? "flow_responding" : "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-caption"), !fresh ? "flow_status_unknown" : omitted ? "flow_omitted" : selected ? "flow_related_count" : total ? "flow_group_scope" : "flow_no_active",
|
|
106
|
+
{ count: rows.filter(related).length, omitted, apps: apps.length, models: allModels.length });
|
|
107
|
+
el("flow-clear").hidden = !selected;
|
|
108
|
+
el("flow-more").hidden = models.length <= 12;
|
|
109
|
+
label(el("flow-more"), expanded ? "flow_fewer_models" : "flow_more_models", { count: Math.max(0, models.length - 12) });
|
|
110
|
+
project("apps", shownApps);
|
|
111
|
+
project("models", expanded ? models : models.slice(0, 12));
|
|
112
|
+
geometry = "";draw();
|
|
113
|
+
}
|
|
114
|
+
function rounded(x0, y0, x1, y1) {
|
|
115
|
+
if (Math.abs(y1 - y0) < 2) return `M${x0} ${y0}H${x1}`;
|
|
116
|
+
const middle = (x0 + x1) / 2, radius = Math.min(14, (x1 - x0) / 4, Math.abs(y1 - y0) / 2), sign = Math.sign(y1 - y0);
|
|
117
|
+
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}`;
|
|
118
|
+
}
|
|
119
|
+
function draw() {
|
|
120
|
+
if (!visible()) return;
|
|
121
|
+
const network = el("flow-network"), rect = network.getBoundingClientRect(), hub = el("flow-hub").getBoundingClientRect(), edges = [];
|
|
122
|
+
const inset = rect.width < 500 ? 2 : 6;
|
|
123
|
+
if (!rect.width) return;
|
|
124
|
+
for (const type of ["apps", "models"]) for (const [id, node] of nodes[type]) {
|
|
125
|
+
if (!node.isConnected) continue;
|
|
126
|
+
const box = node.getBoundingClientRect(), button = node.children[0].getBoundingClientRect(), left = type === "apps";
|
|
127
|
+
const x0 = (left ? box.right : hub.right) - rect.left + inset, y0 = (left ? button.top + button.height / 2 : hub.top + hub.height / 2) - rect.top;
|
|
128
|
+
const x1 = (left ? hub.left : box.left) - rect.left - inset, y1 = (left ? hub.top + hub.height / 2 : button.top + button.height / 2) - rect.top;
|
|
129
|
+
if (x1 <= x0) continue;
|
|
130
|
+
const matches = rows.filter(row => (left ? row.application : modelKey(row)) === id && related(row));
|
|
131
|
+
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 });
|
|
132
|
+
}
|
|
133
|
+
const next = JSON.stringify([rect.width, rect.height, edges]);if (next === geometry) return;geometry = next;
|
|
134
|
+
const wires = el("flow-wires");wires.setAttribute("viewBox", `0 0 ${rect.width} ${rect.height}`);wires.replaceChildren();
|
|
135
|
+
for (const edge of edges) {
|
|
136
|
+
wires.append(svg("path", { d: edge.d, class: `flow-wire${edge.dim ? " flow-dim" : edge.active ? " flow-live" : ""}` }));
|
|
137
|
+
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); }
|
|
138
|
+
else if (edge.active) wires.append(svg("circle", { cx: edge.x, cy: edge.y, r: 2.4, class: "flow-wait" }));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function unavailable() { clearTimeout(expiry);expiry = null;fresh = false;deadline = 0;render(); }
|
|
142
|
+
function visibilityChanged() { if (deadline && Date.now() >= deadline) { unavailable();return; }render();draw(); }
|
|
143
|
+
el("flow-clear").addEventListener("click", () => { selected = null;render(); });
|
|
144
|
+
el("flow-hub").addEventListener("click", () => { selected = null;render(); });
|
|
145
|
+
el("flow-more").addEventListener("click", () => { expanded = !expanded;render(); });
|
|
146
|
+
el("flow-active").addEventListener("toggle", details);
|
|
147
|
+
document.addEventListener("visibilitychange", visibilityChanged);
|
|
148
|
+
globalThis.addEventListener("pagehide", () => { root.dataset.paused = "true"; });
|
|
149
|
+
globalThis.addEventListener("pageshow", visibilityChanged);
|
|
150
|
+
new ResizeObserver(draw).observe(el("flow-network"));
|
|
151
|
+
new MutationObserver(() => { lastSignature = "";render(); }).observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] });
|
|
152
|
+
globalThis.ccdxDashboardFlow = {
|
|
153
|
+
update(data) {
|
|
154
|
+
const parts = [data?.stream_performance, data?.providers?.m365?.claude?.requests?.performance].filter(Boolean);
|
|
155
|
+
if (!parts.length || parts.some(part => !integer(part.active_total) || !Array.isArray(part.active_requests))) { unavailable();return; }
|
|
156
|
+
const values = parts.flatMap(part => part.active_requests).slice(0, 128);
|
|
157
|
+
rows = values.filter(row => row && typeof row.model === "string" && integer(row.upstream_attempts) && Number.isFinite(row.elapsed_ms) && row.elapsed_ms >= 0).map(row => ({
|
|
158
|
+
request_id: typeof row.request_id === "string" ? row.request_id.slice(0, 80) : null,
|
|
159
|
+
application: clients.has(row.application) ? row.application : "api", provider: ["github", "m365"].includes(row.provider) ? row.provider : "unknown",
|
|
160
|
+
model: row.model.slice(0, 100), phase: String(row.phase || "").slice(0, 40), elapsed_ms: row.elapsed_ms,
|
|
161
|
+
upstream_attempts: row.upstream_attempts, first_output_ms: Number.isFinite(row.first_output_ms) && row.first_output_ms >= 0 ? row.first_output_ms : null,
|
|
162
|
+
terminal_outcome: ["completed", "incomplete", "failed", "cancelled", "unknown"].includes(row.terminal_outcome) ? row.terminal_outcome : null,
|
|
163
|
+
}));
|
|
164
|
+
total = parts.reduce((sum, part) => sum + part.active_total, 0);
|
|
165
|
+
if (!integer(total) || total < rows.length) { unavailable();return; }
|
|
166
|
+
omitted = total - rows.length;fresh = true;known = true;
|
|
167
|
+
clearTimeout(expiry);deadline = Date.now() + 6000;expiry = setTimeout(unavailable, 6000);render();
|
|
168
|
+
}, unavailable, visibilityChanged,
|
|
169
|
+
};
|
|
170
|
+
})();
|