codex-copilot-dx 1.2.9 → 1.2.10

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.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).
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 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).
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
@@ -441,3 +442,22 @@ The existing CSS grid reserves explicit header/body/footer tracks; the body owns
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.
package/docs/REFERENCE.md CHANGED
@@ -808,6 +808,31 @@ In-memory usage still updates when `CCDX_DISABLE_USAGE=1` disables persistence.
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.10/codex-copilot-dx-1.2.10.tgz
1016
1041
  # Windows PowerShell: use npm.cmd instead of npm.
1017
1042
  ```
1018
1043
 
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.10",
4
4
  "description": "Local Codex adapter and optional Microsoft 365 Claude gateway",
5
5
  "author": "Dale Xiao",
6
6
  "type": "module",
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
+ })();
@@ -42,6 +42,8 @@
42
42
  function navigate() {
43
43
  const route = location.hash.slice(1), next = Object.hasOwn(titles, route) ? route : "overview";
44
44
  current = next;
45
+ if (next !== "codex") sourceGeneration++;
46
+ if (!["codex", "models"].includes(next) && dashboardRefresh.state("models").pending) dashboardRefresh.invalidate("models");
45
47
  for (const view of document.querySelectorAll("[data-view]")) view.hidden = view.dataset.view !== next;
46
48
  globalThis.ccdxDashboardActivity?.visibilityChanged();
47
49
  for (const item of document.querySelectorAll("[data-route]")) {
@@ -49,11 +51,12 @@
49
51
  }
50
52
  label(el("page-title"), titles[next]);
51
53
  label(el("page-description"), descriptions[next]);
54
+ el("page-description").hidden = ["models", "system"].includes(next);
52
55
  el("page-settings-note").textContent = "";
53
56
  window.scrollTo(0, 0);
54
57
  el("main-content").focus({ preventScroll: true });
55
58
  if (settingsViews.includes(next)) void loadSettings();
56
- if (next === "models") { void dashboardRefresh.refresh("models");void dashboardRefresh.refresh("auth"); }
59
+ if (next === "models") { void refreshCatalog();void dashboardRefresh.refresh("auth"); }
57
60
  if (next === "usage") { void dashboardRefresh.refresh("usage");usageView.revealChart(); } else usageView.stopMotion();
58
61
  if (next === "requests") renderContext();
59
62
  if (next === "system") { void dashboardRefresh.refresh("animation");void dashboardRefresh.refresh("updates"); }
@@ -111,7 +114,7 @@
111
114
  for (const key of ["terminal_animation_enabled", "open_webui", "image_enabled", "prediction_enabled"]) {
112
115
  const input = el(`setting-${key}`), effective = data.effective[key];
113
116
  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", {
117
+ label(el(`effect-${key}`), data.saved[key] === effective.value && !effective.locked ? "preference_effect" : "saved_saved_effective_effective_state", {
115
118
  saved: { key: data.saved[key] ? "on" : "off" }, effective: { key: effective.value ? "on" : "off" },
116
119
  state: { key: effective.locked ? "controlled_by_environment" : states[effective.state] || effective.state } });
117
120
  }
@@ -119,10 +122,22 @@
119
122
  el("history-limit").disabled = data.history.source === "environment";
120
123
  el("save-history").disabled = data.history.source === "environment";
121
124
  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");
125
+ el("settings-note").textContent = "";
123
126
  el("page-settings-note").textContent = "";
124
127
  const state = data.providers;
128
+ el("m365-enabled").checked = state?.m365?.enabled === true;
129
+ el("m365-enabled").disabled = settingsPending;
130
+ label(el("m365-source-effect"), state?.m365?.enabled ? "enabled" : "disabled");
125
131
  const account = state?.m365?.account;
132
+ el("m365-account-name").textContent = account?.login || "—";
133
+ const sourceState = state?.m365;
134
+ globalThis.ccdxIcons.set(el("m365-signin-state"), sourceState?.token_cached ? "authorized" : !sourceState?.enabled ? "disabled" : "tools_not_checked",
135
+ sourceState?.token_cached ? "ok" : "unknown");
136
+ const catalogFailed = Boolean(sourceState?.catalog_diagnostic) || sourceState?.state === "unavailable";
137
+ 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",
138
+ catalogFailed ? "warning" : sourceState?.models?.refreshed_at ? "ok" : "unknown");
139
+ const last = Object.values(sourceState?.claude?.observed_clients || {}).filter(value => typeof value === "string").sort().at(-1);
140
+ el("m365-last-request").textContent = last ? time(last) : "—";
126
141
  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
142
  else label(el("m365-account-current"), "company_account_none");
128
143
  if (accountReasons.has(state?.m365?.reason)) label(el("m365-account-note"), state.m365.reason);
@@ -136,6 +151,9 @@
136
151
  const status = { ready: "ready", checking: "checking", disabled: "disabled", unsupported: "unsupported", idle: "unknown", unavailable: "unavailable" }[state.m365?.state] || "unknown";
137
152
  label(m365, "microsoft_365_state", { state: { key: status } });
138
153
  el("source-control-note").replaceChildren(source);el("m365-control-note").append(m365);
154
+ if (state.m365?.catalog_diagnostic) {
155
+ const cause = document.createElement("p");label(cause, `catalog_cause_${state.m365.catalog_diagnostic.cause_code}`);el("m365-control-note").append(cause);
156
+ }
139
157
  if (state.m365?.reason) {
140
158
  const detail = document.createElement("details"), summary = document.createElement("summary"), code = document.createElement("code");
141
159
  label(summary, "message");code.textContent = state.m365.reason;detail.append(summary, code);el("m365-control-note").append(detail);
@@ -148,20 +166,20 @@
148
166
  settingsPending = true;
149
167
  el("terminal-color-theme").disabled = true;
150
168
  syncAccountControls();
151
- try { applySettings(await api());settingsReadAt = new Date().toLocaleTimeString(); }
169
+ try { applySettings(await api());settingsReadAt = time(Date.now()); }
152
170
  catch (error) {
153
171
  for (const id of ["settings-note", ...(settingsViews.includes(current) ? ["page-settings-note"] : [])]) {
154
172
  label(el(id), settingsReadAt ? "showing_previous_data_updated_time" : "could_not_read_settings", { time: settingsReadAt });
155
173
  el(id).title = error.message;
156
174
  }
157
175
  }
158
- finally { settingsPending = false;el("terminal-color-theme").disabled = !settings;el("apply-source").disabled = !sourceReady();syncReviewButton();syncAccountControls(); }
176
+ finally { settingsPending = false;el("m365-enabled").disabled = !settings;el("terminal-color-theme").disabled = !settings;el("apply-source").disabled = !sourceReady();syncReviewButton();syncAccountControls(); }
159
177
  }
160
178
  async function change(body, button) {
161
179
  if (settingsPending) return;
162
180
  settingsPending = true;
163
181
  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")];
182
+ 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
183
  controls.forEach(input => { input.disabled = true; });
166
184
  const note = el(body.key ? `effect-${body.key}` : body.action === "color_theme" ? "terminal-color-note"
167
185
  : body.action.startsWith("history_") ? "effect-history" : body.action === "prediction_fix" ? "prediction-note"
@@ -177,6 +195,7 @@
177
195
  el("review-control-note").textContent = "";
178
196
  applySettings(data);
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;