codex-copilot-dx 1.2.9 → 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.8/install.sh) (macOS/Linux) or [install.ps1](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.8/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. 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 |
@@ -268,7 +268,7 @@ settlement for two seconds; no successful plaintext cache or transcript index ex
268
268
 
269
269
  `cli-web.mjs` provides an unauthenticated management bootstrap. It opens an existing compatible listener or composes the management listener and provider controls without app writes/launch, prediction setup or automatic M365 start. It is deliberately separate from normal launcher side effects; normal app startup follows after stopping this management-only process. CLI feature pause/resume delegates to the existing preference gates; full removal/setup remains in the original integration commands.
270
270
 
271
- `provider-runtime.mjs` composes read-only Provider descriptors separately from
271
+ `provider-descriptors.mjs` projects plain source/client evidence without transport, configuration writes or lifecycle ownership. `provider-runtime.mjs` supplies its existing snapshots and composes these descriptors separately from
272
272
  source-selection actions. `provider-metadata.mjs` projects bounded model metadata
273
273
  without transport or credential dependencies. `dashboard-api.mjs` sanitizes public
274
274
  fields and keeps local credential validity separate from authorization evidence.
@@ -276,13 +276,14 @@ A requested catalog Provider must be registered; unavailable sources never fall
276
276
  through to another source. The unchanged CLI model selector retains its GPT scope.
277
277
 
278
278
  `dashboard/refresh.js` owns one visible-page timer, in-flight deduplication,
279
- freshness, cancellation and last-good snapshots. `ui.js` generates Provider tabs
279
+ freshness, cancellation and last-good snapshots. `animation.js` owns terminal animation selection, preview timing and saving, with injected view helpers and the shared refresh controller; it does not select providers. `time.js` formats local 24-hour timestamps in both UI languages.
280
+ `ui.js` generates Provider tabs
280
281
  and source filters from descriptors and retained history, with per-tab snapshots
281
282
  invalidated on profile generation/account changes. It cancels obsolete reads and
282
283
  prevents stale apply across tabs. `status.js` renders source-neutral authorization
283
284
  and client evidence; `usage.js` renders usage and date selection. View state remains
284
285
  page-local; only existing preferences and the viewed model Provider are saved in
285
- the browser. Expanded sections read on demand. There is no Node data watcher.
286
+ the browser. Expanded sections read on demand. The directory and Codex selectors share the same catalog resource, freshness and single-flight read. Changing sources cancels an obsolete waiter; generation checks reject late results. Account changes clear old-source drafts and snapshots; ordinary refreshes retain pending choices. There is no Node data watcher.
286
287
  The sidebar controller reads small process-local status snapshots every two seconds
287
288
  while visible/automatic, and source/settings evidence every eight status ticks.
288
289
  Catalog and retained-log reads retain their slower, view-scoped policy. Animation
@@ -436,8 +437,63 @@ The Claude gateway still relays original native SSE bytes. `stream-performance.m
436
437
 
437
438
  ## Dashboard layout and information scopes (1.2.9)
438
439
 
439
- 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.
440
441
 
441
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.
442
443
 
443
444
  HTML owns grouping: Codex buffer maintenance is separate from request performance, usage filters sit with the data they actually control, Requests prioritizes recent records and folds bounded technical fields into each row, and Checks & repairs owns runtime diagnostics. Settings owns preferences and updates. Request expansion is preserved by bounded request keys, and literal upstream values still use text nodes. Existing settings transactions, same-origin protections and confirmations remain in use; action failures target the affected controls. No framework, runtime dependency, endpoint, log scan, model call or installer policy is added.
445
+
446
+ ## Catalog failure evidence and controls (1.2.10)
447
+
448
+ `providers/m365-catalog-diagnostic.mjs` classifies model-list HTTP failures using
449
+ fixed causes. The one known Entra-disabled message is recognized exactly; other
450
+ 403 responses mean access denied, without inferring tenant-policy changes. Only
451
+ cause, HTTP status, check/last-success timestamps and a bounded service request ID
452
+ survive. The server body, credentials and account details are not retained in that
453
+ diagnostic. CLI and protected dashboard routes share its projection. Successful
454
+ refresh clears both source and composition failure state; delayed closed-source
455
+ results cannot clear a newer source's state. Discovery still sends no inference.
456
+
457
+ The eight WebUI views retain their scope, palettes, atom and circle status icons.
458
+ Selection uses an opaque theme fill and centered text, without a check or radio
459
+ mark; hover retains the selection. Native selects use square borders and retain a
460
+ visible square keyboard focus outline. Model names and metadata use readable text
461
+ roles rather than accent colors. The catalog's technical fields remain available
462
+ in per-model details. Usage trends and summaries are peer panels, still loaded on
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,10 +804,35 @@ 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
 
811
+ The source page groups account/access checks and the model list under the selected
812
+ source. Selecting a source tab only browses it; application routing is changed from
813
+ the application page. Model names remain in the main table; maker, protocol,
814
+ reasoning levels, listing state and context limit are in each model's details.
815
+ The Codex choices and source table share one catalog read with freshness,
816
+ cancellation and account-generation checks. Explicit Refresh still checks again.
817
+
818
+ Selection uses a solid theme fill with centered text, without a preceding check.
819
+ Model-list text uses the normal text color. Selects have square borders and a
820
+ visible keyboard focus indicator. Settings groups webpage appearance, independent
821
+ terminal color/animation, startup and updates. The terminal preview is expandable;
822
+ choosing an animation previews it, while Save applies it to the running terminal.
823
+ Usage trends are separate from the model summary and remain on demand. Request
824
+ rows show an observed HTTP failure separately from the model's terminal result;
825
+ request IDs and attempt counts are available in the same bounded details. List
826
+ timestamps use local 24-hour time in both UI languages.
827
+
828
+ M365 catalog refusals expose a fixed reason, HTTP status, check/last-success time
829
+ and service request ID when available. `entra_access_disabled` means the server
830
+ reported that Copilot CLI Entra access is not enabled for that account; a generic
831
+ 403 does not establish why access changed. Sign-in, discovery and successful
832
+ inference remain separate evidence. Failed discovery keeps the account-bound
833
+ last-good list. A successful refresh clears old failure evidence. No automatic
834
+ relogin, model call, source switch or policy exception is added.
835
+
811
836
  The settings API is local, requires the dashboard header, bounded JSON and
812
837
  same-origin POST. It invokes the same Provider, cache and integration operations;
813
838
  it does not spawn a CLI or generic shell command. Settings reads do not reveal
@@ -1012,7 +1037,7 @@ Unknown support prevents an explicitly requested exception from starting.
1012
1037
  For an older updater that still requires Git, install the Release tarball directly:
1013
1038
 
1014
1039
  ```sh
1015
- npm install -g https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.8/codex-copilot-dx-1.2.8.tgz
1040
+ npm install -g https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.11/codex-copilot-dx-1.2.11.tgz
1016
1041
  # Windows PowerShell: use npm.cmd instead of npm.
1017
1042
  ```
1018
1043
 
@@ -1563,3 +1588,39 @@ From a source checkout, `node scripts/codex-message-id-replay.mjs --codex /absol
1563
1588
  ## License
1564
1589
 
1565
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.9",
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;
package/src/cli-m365.mjs CHANGED
@@ -10,6 +10,7 @@ import { readBoundedResponseText } from "./upstream-body.mjs";
10
10
  import { parseAdapterAddressOptions } from "./cli-options.mjs";
11
11
  import { autoReviewReasoningEfforts } from "./models.mjs";
12
12
  import { m365AccountMessage } from "./providers/m365-accounts.mjs";
13
+ import { m365CatalogDiagnostic, m365CatalogMessage } from "./providers/m365-catalog-diagnostic.mjs";
13
14
  import { m365NetworkDiagnostic, m365NetworkMessage } from "./providers/m365-network-diagnostic.mjs";
14
15
 
15
16
  export async function fetchActiveProviderModels({ control = providerControl, ...options } = {}) {
@@ -35,6 +36,7 @@ export async function providerControl({ host = "127.0.0.1", port = 2026, action,
35
36
  export function formatM365Status(state) {
36
37
  const m = state.m365 || {}, claude = m.claude || {}, models = m.models || {};
37
38
  const network = m365NetworkDiagnostic(m.network_diagnostic);
39
+ const catalog = m365CatalogDiagnostic(m.catalog_diagnostic);
38
40
  return [
39
41
  `Microsoft 365: ${terminalCell(m.state || "not running")}${m.reason ? ` (${terminalCell(m.reason)})` : ""}`,
40
42
  ...(m.account?.login ? [`Account: ${terminalCell(m.account.login)}`] : []),
@@ -42,6 +44,9 @@ export function formatM365Status(state) {
42
44
  ...(network ? [`Network: ${network.source} / ${network.stage} / ${network.cause_code}`, m365NetworkMessage(network)] : m.reason ? [m365AccountMessage(m.reason)] : []),
43
45
  `Models: ${models.claude || 0} Claude / ${models.gpt || 0} GPT (${models.source || "unavailable"})`,
44
46
  `Claude gateway: ${claude.gateway || "not running"}${claude.base_url ? ` / ${claude.base_url}` : ""}`,
47
+ ...(catalog ? [`Catalog: ${m365CatalogMessage(catalog)} (HTTP ${catalog.http_status})`,
48
+ `Checked: ${catalog.checked_at || "unknown"} / Last success: ${catalog.last_success_at || "unknown"}`,
49
+ ...(catalog.request_id ? [`Service request: ${catalog.request_id}`] : [])] : []),
45
50
  ...(claude.reason ? [`Claude detail: ${terminalCell(claude.reason)}`] : []),
46
51
  ...(claude.requests ? [`Claude requests: ${claude.requests.completed} completed / ${claude.requests.incomplete} incomplete / ${claude.requests.failed} failed / ${claude.requests.active} active`] : []),
47
52
  `Claude Code: ${claude.clients?.code || "unknown"}; Claude App: ${claude.clients?.app || "unknown"}`,
@@ -0,0 +1,186 @@
1
+ (() => {
2
+ function create({ element, phrase, localize, text, reducedMotion, getRefresh, document }) {
3
+ const animationRows = new Map();
4
+ const animationLabels = new Map();
5
+ let animationTimelines = [];
6
+ let savedAnimation = "";
7
+ let selectedAnimation = "";
8
+ let previewDisabledByEnvironment = false;
9
+ let previewVisible = false;
10
+ let previewTimer = null;
11
+ let previewStarted = 0;
12
+ let animationSaving = false;
13
+ let animationFramesLoaded = false;
14
+
15
+ function renderAnsiFrame(target, frame) {
16
+ const fragments = String(frame).split(/\u001b\[([0-9;]+)m/);
17
+ const content = document.createDocumentFragment();
18
+ let color = "";
19
+ for (let index = 0; index < fragments.length; index += 2) {
20
+ if (fragments[index]) {
21
+ const span = document.createElement("span");
22
+ span.className = color;
23
+ span.textContent = fragments[index];
24
+ content.append(span);
25
+ }
26
+ const code = fragments[index + 1];
27
+ color = code === "97" ? "ansi-white"
28
+ : /^38;5;(159|123|87|51|45|39|33)$/.test(code || "") ? `ansi-${code.slice(5)}` : "";
29
+ }
30
+ target.replaceChildren(content);
31
+ }
32
+
33
+ function renderAnimationFrames(elapsed) {
34
+ for (const timeline of animationTimelines) {
35
+ const position = timeline.id === selectedAnimation ? elapsed % timeline.duration : 0;
36
+ const frameIndex = timeline.frames.findIndex(({ until }) => position < until);
37
+ if (frameIndex === timeline.lastFrame) continue;
38
+ timeline.lastFrame = frameIndex;
39
+ renderAnsiFrame(timeline.target, frameIndex < 0 ? `[${" ".repeat(20)}]` : timeline.frames[frameIndex].ansi);
40
+ }
41
+ }
42
+
43
+ function stopAnimationPreview() {
44
+ if (previewTimer !== null) clearTimeout(previewTimer);
45
+ previewTimer = null;
46
+ }
47
+
48
+ function tickAnimationPreview() {
49
+ previewTimer = null;
50
+ if (!animationTimelines.length || !element("animation-settings").open || element("animation-settings").closest("[hidden]") || !previewVisible || document.visibilityState !== "visible" || reducedMotion.matches || previewDisabledByEnvironment) return;
51
+ renderAnimationFrames(performance.now() - previewStarted);
52
+ previewTimer = setTimeout(tickAnimationPreview, 32);
53
+ }
54
+
55
+ function syncAnimationPreview() {
56
+ stopAnimationPreview();
57
+ if (!animationTimelines.length || !element("animation-settings").open || element("animation-settings").closest("[hidden]") || !previewVisible || document.visibilityState !== "visible" || reducedMotion.matches || previewDisabledByEnvironment) {
58
+ for (const timeline of animationTimelines) timeline.lastFrame = -2;
59
+ renderAnimationFrames(0);
60
+ return;
61
+ }
62
+ previewStarted = performance.now();
63
+ tickAnimationPreview();
64
+ }
65
+
66
+ new IntersectionObserver(([entry]) => {
67
+ previewVisible = entry.isIntersecting;
68
+ syncAnimationPreview();
69
+ }).observe(element("animation-options"));
70
+ document.addEventListener("visibilitychange", syncAnimationPreview);
71
+ reducedMotion.addEventListener("change", syncAnimationPreview);
72
+
73
+ function buildAnimationOptions(data) {
74
+ const container = element("animation-options");
75
+ container.replaceChildren();
76
+ animationRows.clear();
77
+ animationTimelines = [];
78
+ savedAnimation = data.theme;
79
+ selectedAnimation = data.theme;
80
+ previewDisabledByEnvironment = data.disabled_by_environment === true;
81
+ for (const [index, theme] of data.themes.entries()) {
82
+ animationLabels.set(theme.id, theme.label);
83
+ const option = document.createElement("button");
84
+ option.type = "button";
85
+ option.className = "theme-option";
86
+ option.dataset.theme = theme.id;
87
+ option.setAttribute("aria-pressed", String(theme.id === data.theme));
88
+ option.addEventListener("click", () => {
89
+ selectedAnimation = theme.id;
90
+ for (const [id, row] of animationRows) row.setAttribute("aria-pressed", String(id === theme.id));
91
+ element("save-animation").disabled = selectedAnimation === savedAnimation;
92
+ updateAnimationState();
93
+ syncAnimationPreview();
94
+ });
95
+ const name = document.createElement("span");
96
+ name.className = "theme-name";
97
+ const label = document.createElement("span");
98
+ localize(label, "index_theme", { index: String(index + 1).padStart(2, "0"), theme: phrase(theme.label) });
99
+ name.append(label);
100
+ if (theme.default) {
101
+ const marker = document.createElement("small");
102
+ localize(marker, "default");
103
+ name.append(marker);
104
+ }
105
+ const preview = document.createElement("span");
106
+ preview.className = "theme-preview";
107
+ preview.setAttribute("aria-hidden", "true");
108
+ option.append(name, preview);
109
+ container.append(option);
110
+ animationRows.set(theme.id, option);
111
+ let until = 0;
112
+ const frames = theme.frames.map((frame) => {
113
+ until += frame.delay_ms;
114
+ return { ansi: frame.ansi, until };
115
+ });
116
+ animationTimelines.push({ id: theme.id, target: preview, frames, duration: until + theme.loop_pause_ms, lastFrame: -2 });
117
+ }
118
+ element("save-animation").disabled = true;
119
+ syncAnimationPreview();
120
+ }
121
+
122
+ function animationNote(data) {
123
+ return data.disabled_by_environment
124
+ ? "disabled_by_ccdx_terminal_animation_saved_choice_applies_after_o"
125
+ : "saved_choice_applies_to_the_running_terminal";
126
+ }
127
+
128
+ function loadAnimation(options) {
129
+ if (!animationSaving) return getRefresh().refresh("animation", options);
130
+ }
131
+
132
+ function applyAnimation(data, { changed } = {}) {
133
+ if (changed === false) { updateAnimationState(); return; }
134
+ if (!animationFramesLoaded && data.themes.some(theme => theme.frames)) {
135
+ buildAnimationOptions(data);
136
+ animationFramesLoaded = true;
137
+ } else {
138
+ const dirty = selectedAnimation && selectedAnimation !== savedAnimation;
139
+ savedAnimation = data.theme;
140
+ if (!dirty) selectedAnimation = data.theme;
141
+ previewDisabledByEnvironment = data.disabled_by_environment === true;
142
+ for (const [id, row] of animationRows) row.setAttribute("aria-pressed", String(id === selectedAnimation));
143
+ element("save-animation").disabled = selectedAnimation === savedAnimation;
144
+ syncAnimationPreview();
145
+ }
146
+ updateAnimationState();
147
+ text("animation-note", animationNote(data));
148
+ }
149
+
150
+ function updateAnimationState() {
151
+ text("animation-state", "current_theme_unsaved", { theme: phrase(animationLabels.get(savedAnimation) || savedAnimation), unsaved: selectedAnimation !== savedAnimation ? phrase("unsaved") : "" });
152
+ }
153
+
154
+ async function saveAnimation() {
155
+ const button = element("save-animation");
156
+ if (!selectedAnimation || selectedAnimation === savedAnimation) return;
157
+ animationSaving = true;
158
+ getRefresh().invalidate("animation");
159
+ button.disabled = true;
160
+ text("animation-note", "saving");
161
+ try {
162
+ const response = await fetch("/_ccdx/ui/animation", {
163
+ method: "POST",
164
+ headers: { "Content-Type": "application/json", "X-CCDX-Dashboard": "1" },
165
+ body: JSON.stringify({ theme: selectedAnimation }),
166
+ signal: AbortSignal.timeout(8000),
167
+ });
168
+ const data = await response.json();
169
+ if (!response.ok) throw new Error(data.error || `HTTP ${response.status}`);
170
+ savedAnimation = data.theme;
171
+ updateAnimationState();
172
+ text("animation-note", animationNote(data));
173
+ } catch (error) {
174
+ text("animation-note", "not_saved_error", { error: String(error.message || error).slice(0, 150) });
175
+ } finally {
176
+ animationSaving = false;
177
+ button.disabled = selectedAnimation === savedAnimation;
178
+ loadAnimation({ force: true });
179
+ }
180
+ }
181
+
182
+ return { apply: applyAnimation, load: loadAnimation, save: saveAnimation, sync: syncAnimationPreview, stop: stopAnimationPreview,
183
+ get saving() { return animationSaving; }, get framesLoaded() { return animationFramesLoaded; } };
184
+ }
185
+ globalThis.ccdxDashboardAnimation = { create };
186
+ })();
@@ -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;
@@ -42,18 +41,20 @@
42
41
  function navigate() {
43
42
  const route = location.hash.slice(1), next = Object.hasOwn(titles, route) ? route : "overview";
44
43
  current = next;
44
+ if (next !== "codex") sourceGeneration++;
45
+ if (!["codex", "models"].includes(next) && dashboardRefresh.state("models").pending) dashboardRefresh.invalidate("models");
45
46
  for (const view of document.querySelectorAll("[data-view]")) view.hidden = view.dataset.view !== next;
46
47
  globalThis.ccdxDashboardActivity?.visibilityChanged();
48
+ globalThis.ccdxDashboardFlow?.visibilityChanged();
47
49
  for (const item of document.querySelectorAll("[data-route]")) {
48
50
  if (item.dataset.route === next) item.setAttribute("aria-current", "page");else item.removeAttribute("aria-current");
49
51
  }
50
52
  label(el("page-title"), titles[next]);
51
- label(el("page-description"), descriptions[next]);
52
53
  el("page-settings-note").textContent = "";
53
54
  window.scrollTo(0, 0);
54
55
  el("main-content").focus({ preventScroll: true });
55
56
  if (settingsViews.includes(next)) void loadSettings();
56
- if (next === "models") { void dashboardRefresh.refresh("models");void dashboardRefresh.refresh("auth"); }
57
+ if (next === "models") { void refreshCatalog();void dashboardRefresh.refresh("auth"); }
57
58
  if (next === "usage") { void dashboardRefresh.refresh("usage");usageView.revealChart(); } else usageView.stopMotion();
58
59
  if (next === "requests") renderContext();
59
60
  if (next === "system") { void dashboardRefresh.refresh("animation");void dashboardRefresh.refresh("updates"); }
@@ -111,7 +112,7 @@
111
112
  for (const key of ["terminal_animation_enabled", "open_webui", "image_enabled", "prediction_enabled"]) {
112
113
  const input = el(`setting-${key}`), effective = data.effective[key];
113
114
  input.checked = data.saved[key];input.disabled = Boolean(effective.locked);
114
- label(el(`effect-${key}`), effective.state === "next_start" ? "saved_saved_state" : "saved_saved_effective_effective_state", {
115
+ label(el(`effect-${key}`), data.saved[key] === effective.value && !effective.locked ? "preference_effect" : "saved_saved_effective_effective_state", {
115
116
  saved: { key: data.saved[key] ? "on" : "off" }, effective: { key: effective.value ? "on" : "off" },
116
117
  state: { key: effective.locked ? "controlled_by_environment" : states[effective.state] || effective.state } });
117
118
  }
@@ -119,10 +120,22 @@
119
120
  el("history-limit").disabled = data.history.source === "environment";
120
121
  el("save-history").disabled = data.history.source === "environment";
121
122
  label(el("effect-history"), data.history.source === "environment" ? "controlled_by_environment" : "applies_to_new_calls");
122
- label(el("settings-note"), "settings_read_from_the_running_service");
123
+ el("settings-note").textContent = "";
123
124
  el("page-settings-note").textContent = "";
124
125
  const state = data.providers;
126
+ el("m365-enabled").checked = state?.m365?.enabled === true;
127
+ el("m365-enabled").disabled = settingsPending;
128
+ label(el("m365-source-effect"), state?.m365?.enabled ? "enabled" : "disabled");
125
129
  const account = state?.m365?.account;
130
+ el("m365-account-name").textContent = account?.login || "—";
131
+ const sourceState = state?.m365;
132
+ globalThis.ccdxIcons.set(el("m365-signin-state"), sourceState?.token_cached ? "authorized" : !sourceState?.enabled ? "disabled" : "tools_not_checked",
133
+ sourceState?.token_cached ? "ok" : "unknown");
134
+ const catalogFailed = Boolean(sourceState?.catalog_diagnostic) || sourceState?.state === "unavailable";
135
+ globalThis.ccdxIcons.set(el("m365-catalog-state"), catalogFailed ? "live_lookup_failed" : sourceState?.models?.refreshed_at ? sourceState.models.source === "cache" ? "catalog_snapshot" : "live_snapshot" : "tools_not_checked",
136
+ catalogFailed ? "warning" : sourceState?.models?.refreshed_at ? "ok" : "unknown");
137
+ const last = Object.values(sourceState?.claude?.observed_clients || {}).filter(value => typeof value === "string").sort().at(-1);
138
+ el("m365-last-request").textContent = last ? time(last) : "—";
126
139
  if (account) label(el("m365-account-current"), "company_account_current", { login: account.login, tenant: account.tenant || "—", source: { key: `account_source_${account.selection_source || "legacy"}` } });
127
140
  else label(el("m365-account-current"), "company_account_none");
128
141
  if (accountReasons.has(state?.m365?.reason)) label(el("m365-account-note"), state.m365.reason);
@@ -136,6 +149,9 @@
136
149
  const status = { ready: "ready", checking: "checking", disabled: "disabled", unsupported: "unsupported", idle: "unknown", unavailable: "unavailable" }[state.m365?.state] || "unknown";
137
150
  label(m365, "microsoft_365_state", { state: { key: status } });
138
151
  el("source-control-note").replaceChildren(source);el("m365-control-note").append(m365);
152
+ if (state.m365?.catalog_diagnostic) {
153
+ const cause = document.createElement("p");label(cause, `catalog_cause_${state.m365.catalog_diagnostic.cause_code}`);el("m365-control-note").append(cause);
154
+ }
139
155
  if (state.m365?.reason) {
140
156
  const detail = document.createElement("details"), summary = document.createElement("summary"), code = document.createElement("code");
141
157
  label(summary, "message");code.textContent = state.m365.reason;detail.append(summary, code);el("m365-control-note").append(detail);
@@ -148,25 +164,26 @@
148
164
  settingsPending = true;
149
165
  el("terminal-color-theme").disabled = true;
150
166
  syncAccountControls();
151
- try { applySettings(await api());settingsReadAt = new Date().toLocaleTimeString(); }
167
+ try { applySettings(await api());settingsReadAt = time(Date.now()); }
152
168
  catch (error) {
153
169
  for (const id of ["settings-note", ...(settingsViews.includes(current) ? ["page-settings-note"] : [])]) {
154
170
  label(el(id), settingsReadAt ? "showing_previous_data_updated_time" : "could_not_read_settings", { time: settingsReadAt });
155
171
  el(id).title = error.message;
156
172
  }
157
173
  }
158
- finally { settingsPending = false;el("terminal-color-theme").disabled = !settings;el("apply-source").disabled = !sourceReady();syncReviewButton();syncAccountControls(); }
174
+ finally { settingsPending = false;el("m365-enabled").disabled = !settings;el("terminal-color-theme").disabled = !settings;el("apply-source").disabled = !sourceReady();syncReviewButton();syncAccountControls(); }
159
175
  }
160
176
  async function change(body, button) {
161
177
  if (settingsPending) return;
162
178
  settingsPending = true;
163
179
  syncAccountControls();
164
- const controls = [...document.querySelectorAll("[role=switch], #save-history, #clean-history, #fix-prediction, #apply-source, #save-review, #source-provider, #source-model, #source-review, #source-review-effort, #terminal-color-theme, #m365-on, #m365-off")];
180
+ const controls = [...document.querySelectorAll("[role=switch], #save-history, #clean-history, #fix-prediction, #apply-source, #save-review, #source-provider, #source-model, #source-review, #source-review-effort, #terminal-color-theme, #m365-enabled")];
165
181
  controls.forEach(input => { input.disabled = true; });
166
182
  const note = el(body.key ? `effect-${body.key}` : body.action === "color_theme" ? "terminal-color-note"
167
183
  : body.action.startsWith("history_") ? "effect-history" : body.action === "prediction_fix" ? "prediction-note"
168
184
  : body.operation === "switch" ? "source-control-note" : body.operation === "auto-review" ? "review-control-note"
169
185
  : body.operation === "account" ? "m365-account-note" : "m365-control-note");
186
+ const initialSourceSave = body.operation === "switch" && Boolean(body.auto_review_model);
170
187
  label(note, "applying");
171
188
  if (button) button.setAttribute("aria-busy", "true");
172
189
  try {
@@ -176,7 +193,9 @@
176
193
  if (body.action === "provider" && body.operation === "off") { sourceDirty = false;reviewDirty = false; }
177
194
  el("review-control-note").textContent = "";
178
195
  applySettings(data);
196
+ if (initialSourceSave) label(el("source-control-note"), "source_initial_review_saved");
179
197
  if (body.operation === "account") {
198
+ sourceDirty = false;reviewDirty = false;sourceGeneration++;
180
199
  modelsPreference = null;modelsSource = null;
181
200
  dashboardRefresh.invalidate("models", { clear: true });
182
201
  label(el("m365-account-note"), "company_account_checked");
@@ -197,7 +216,7 @@
197
216
  button?.removeAttribute("aria-busy");
198
217
  }
199
218
  }
200
- for (const input of document.querySelectorAll("[role=switch]")) input.addEventListener("change", () => {
219
+ for (const input of document.querySelectorAll('[role=switch][id^="setting-"]')) input.addEventListener("change", () => {
201
220
  void change({ action: "preference", key: input.id.slice("setting-".length), value: input.checked }, input);
202
221
  });
203
222
  el("terminal-color-theme").addEventListener("change", () => void change({ action: "color_theme", theme: el("terminal-color-theme").value }, el("terminal-color-theme")));
@@ -206,9 +225,12 @@
206
225
  if (window.confirm(globalThis.ccdxLanguage.format("clear_inactive_codex_conversation_data_older_continuation_ids_ma"))) void change({ action: "history_clean" }, el("clean-history"));
207
226
  });
208
227
  el("fix-prediction").addEventListener("click", () => void change({ action: "prediction_fix" }, el("fix-prediction")));
209
- for (const operation of ["on", "off"]) el(`m365-${operation}`).addEventListener("click", () => {
210
- if (operation === "off" && !window.confirm(globalThis.ccdxLanguage.format("confirm_disable_m365"))) return;
211
- void change({ action: "provider", operation }, el(`m365-${operation}`));
228
+ el("m365-enabled").addEventListener("change", () => {
229
+ const operation = el("m365-enabled").checked ? "on" : "off";
230
+ if (operation === "off" && !window.confirm(globalThis.ccdxLanguage.format("confirm_disable_m365"))) {
231
+ el("m365-enabled").checked = settings?.providers?.m365?.enabled === true;return;
232
+ }
233
+ void change({ action: "provider", operation }, el("m365-enabled"));
212
234
  });
213
235
  async function loadSourceModels() {
214
236
  const generation = ++sourceGeneration;
@@ -222,8 +244,7 @@
222
244
  el("apply-source").disabled = settingsPending || Boolean(needsModels);
223
245
  label(el("review-control-note"), "model_choices_loading");
224
246
  try {
225
- const response = await fetch(`/_ccdx/ui/models/live?provider=${encodeURIComponent(source.id)}`, { headers: { "X-CCDX-Dashboard": "1" }, cache: "no-store", signal: AbortSignal.timeout(15000) });
226
- const data = await response.json();if (!response.ok || !Array.isArray(data.models)) throw new Error(data.error || "Invalid model list");
247
+ const data = await readModelCatalog(source.id);
227
248
  if (generation !== sourceGeneration) return;
228
249
  const models = data.models.filter(model => model.selectable && model.clients.includes("codex"));
229
250
  sourceModels = models;