codex-copilot-dx 1.2.1 → 1.2.2

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.1/install.sh) (macOS/Linux) or [install.ps1](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.1/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.2/install.sh) (macOS/Linux) or [install.ps1](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.2/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
 
@@ -22,7 +22,7 @@ The [local control console](http://127.0.0.1:2026/) keeps indented Codex/Claude
22
22
 
23
23
  Startup shows bounded checks, sources with discovered model lists and Claude Code/App configuration. Prediction normally uses one summary line; `ccdx prediction status` retains recovery and environment details. After Ready, an interactive terminal shows current source/Claude state and a line-framed table of this process's returned usage and inference counters. Notices and activity each have their own line; individual requests do not scroll. Input includes reused input tokens. `ccdx --verbose` (also `--show-request-id`, or debug logging) retains detail output; optional file logging remains independently controlled. Source and Claude summaries wrap on narrow terminals. Failed reads show previous-data status and the last successful update time. Non-TTY, CI, dumb, or terminals too small for the full region use plain output (at least 40 columns / 16 rows are required). `Ready` only means the core service is available; discovered catalogs and configured clients do not prove inference access.
24
24
 
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. See the [control reference](docs/REFERENCE.md#control-console-and-online-settings).
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) or Klein blue. 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
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).
package/bin/cli.mjs CHANGED
@@ -452,7 +452,7 @@ try {
452
452
  const terminalAnimationTheme = terminalAnimationPreference().theme;
453
453
  terminalConsole = createTerminalConsole({ baseUrl: webUiUrl, verbose: CLI.verbose === true || CLI.showRequestId === true || LOGGING.level === "debug",
454
454
  snapshot: () => activeServer?.ccdxSnapshot?.() || {},
455
- preferences: () => { const { saved, theme } = serviceSettingsSnapshot();return { ...saved, theme }; } });
455
+ preferences: () => { const { saved, theme, color_theme } = serviceSettingsSnapshot();return { ...saved, theme, color_theme }; } });
456
456
  const serviceControl = createServiceControl({ providerRuntime, clientIntegration: earlyIntegration, terminal: terminalConsole });
457
457
  const codexModelCatalog = createCodexModelCatalog();
458
458
  activeServer = await startAdapter(ADAPTER_PORT, ADAPTER_HOST, {
@@ -402,3 +402,9 @@ builds one npm tarball plus checksummed platform scripts/helper; the npm publish
402
402
  workflow and GitHub Release must deliver those same package bytes. WebUI source
403
403
  selection and Auto Review remain under Codex; M365 lifecycle stays in source
404
404
  management. CLI and UI share advertised effort filtering and preference writes.
405
+
406
+ ## Independent appearance settings (1.2.2)
407
+
408
+ Web color (`green` / `klein`) and dark/light mode are browser-local presentation state applied before CSS in `dashboard/theme.js`. CSS semantic roles keep errors/warnings separate from theme accents. Terminal color uses a distinct `terminal_color_theme` config field; animation continues to use `terminal_animation`. `terminal-colors.mjs` owns terminal color capability checks and escaping, while the existing layout runs on plain text first. The one-per-second coherent settings snapshot carries terminal color; animation frames introduce no additional settings reads. No inference, provider-routing or installer dependency is added.
409
+
410
+ The existing same-origin bounded settings action saves terminal color through the strict locked atomic writer, then applies it to the live console. Read or save failures retain existing files and controls revert to the last confirmed choice. Model-list check errors project only bounded public diagnostic fields; UI associates them with the selected source and its last successful snapshot. Existing generation checks, cancellation and deduplication prevent late results from replacing another source's data.
package/docs/REFERENCE.md CHANGED
@@ -787,7 +787,7 @@ not a guarantee that every browser will reuse an existing tab.
787
787
  The default TTY display uses wrapping source/Claude summaries, a line-framed usage/inference table, and separate notice/activity rows, without an alternate screen or raw keyboard input. It shows usage returned since this process began; pending
788
788
  usage is excluded, missing usage stays partial, and this is not an invoice.
789
789
  Business requests drive activity; status/catalog polling does not. Existing nine
790
- animation themes retain their timing/palette and cycle pauses. `--verbose`,
790
+ animation styles retain their timing and cycle pauses; the default green retains its original palette. `--verbose`,
791
791
  `--show-request-id` or `CCDX_LOG_LEVEL=debug` restore detailed terminal output.
792
792
  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
793
793
  are coalesced. File logging retains its existing explicit opt-in and redaction.
@@ -803,7 +803,9 @@ service preferences fail closed for optional calls rather than reopening them.
803
803
 
804
804
  | Control | Effective scope |
805
805
  | --- | --- |
806
- | Terminal theme/animation | Live supported status terminal; plain/verbose/environment-disabled modes are reported separately |
806
+ | Webpage color | Current browser, immediately; independent of the existing dark/light choice |
807
+ | Terminal color | Live supported status table and animation; startup logo on the next launch |
808
+ | Terminal animation | Live supported status terminal; plain/verbose/environment-disabled modes are reported separately |
807
809
  | Open WebUI | Next interactive desktop start |
808
810
  | Image calls | New local MCP calls; keeps provider credentials and allows an already-started call to finish |
809
811
  | Prediction adaptation | Subsequent configuration traffic on an already-provisioned bridge; keeps trust/route, and App caches can remain |
@@ -827,6 +829,18 @@ auto-refresh still permits manual refresh/settings retry. No history-log scan is
827
829
  performed at the status cadence. The atom moves on load/manual refresh only and
828
830
  respects reduced motion. Client attribution absent from older records stays unknown.
829
831
 
832
+ ### Color themes
833
+
834
+ Settings separates Web appearance and Terminal appearance. Each offers Classic green (default) and Klein blue. Green preserves the previous palette and terminal table's original text colors. Blue colors the terminal logo, full table and activity animation without changing glyphs, timing or metric definitions. Webpage color is independent of terminal color, and of the page header's dark/light switch.
835
+
836
+ Web choices use `ccdx.dashboard.palette` (`green` / `klein`) and the existing `ccdx.dashboard.theme` (`dark` / `light`) in browser local storage. They are applied before the stylesheet, including the atom favicon. Same-origin tabs receive storage updates; other browsers retain their own choices. If storage is blocked, the current tab still changes and explicitly reports that the choice was not saved. No service request is needed to change webpage colors.
837
+
838
+ Terminal color uses `terminal_color_theme: "klein"` in the normal CCDX user config. An absent value means `green`; choosing green removes the override. It does not change `terminal_animation` or any capability flag. The same bounded, strict settings read, file lock and atomic writer are reused. Invalid/unreadable existing config is not overwritten with defaults. A successful save applies to the supported live status table; the startup logo uses the saved choice next time. Previously printed terminal lines are not rewritten. Color codes are added after width calculation and clipping. Truecolor, 256-color and ANSI-blue fallbacks are supported; `NO_COLOR`, dumb terminals and redirected output preserve plain output. A terminal's own palette and background can affect the displayed blue.
839
+
840
+ The terminal sample in Settings is labeled Preview and uses sample numbers, not current usage. Existing nine animation previews and their save operation remain available beneath the color choice. Red errors and amber warnings keep their meaning across webpage themes.
841
+
842
+ Model-list failures name the selected source, retain its last successful list when available, and distinguish that list's timestamp from the failed check. Expand Check details for the bounded public reason, source, available HTTP status and check time. A retry time is shown only when the source supplies an actual retry delay; no new retry or automatic provider failover is added. Existing diagnostic redaction and size limits remain.
843
+
830
844
  ### Terminal animation
831
845
 
832
846
  Choose the terminal activity animation interactively:
@@ -971,7 +985,7 @@ Unknown support prevents an explicitly requested exception from starting.
971
985
  For an older updater that still requires Git, install the Release tarball directly:
972
986
 
973
987
  ```sh
974
- npm install -g https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.1/codex-copilot-dx-1.2.1.tgz
988
+ npm install -g https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.2/codex-copilot-dx-1.2.2.tgz
975
989
  # Windows PowerShell: use npm.cmd instead of npm.
976
990
  ```
977
991
 
@@ -1202,7 +1216,7 @@ Client cancellations remain in verbose/file diagnostics as informational records
1202
1216
  timeouts and actual failures remain notices. Non-TTY, CI, dumb and terminals under
1203
1217
  40 columns or 16 rows retain plain output. At 40×16 the compact table keeps all metrics and short source/Code/App states. Larger terminals wrap full state descriptions. No runtime terminal dependency is added.
1204
1218
 
1205
- Terminal appearance lives in System/settings, with a sidebar shortcut on wide
1219
+ Terminal appearance lives in Settings, with a sidebar shortcut on wide
1206
1220
  screens. Preview frames load on opening; closing, hiding the view/page or reduced
1207
1221
  motion stops preview timers. Saving changes the running supported status terminal.
1208
1222
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-copilot-dx",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Local Codex adapter and optional Microsoft 365 Claude gateway",
5
5
  "author": "Dale Xiao",
6
6
  "type": "module",
@@ -62,6 +62,12 @@
62
62
  window.addEventListener("ccdx:providers", () => { syncSources();if (current === "codex") void loadSourceModels(); });
63
63
  function applySettings(data) {
64
64
  settings = data;
65
+ el("terminal-color-theme").value = data.color_theme || "green";
66
+ el("terminal-color-theme").disabled = settingsPending;
67
+ el("terminal-color-sample").dataset.terminalPalette = data.color_theme || "green";
68
+ el("animation-settings").dataset.terminalPalette = data.color_theme || "green";
69
+ label(el("terminal-color-note"), data.terminal?.mode !== "status"
70
+ ? "terminal_theme_unavailable" : "terminal_theme_applied");
65
71
  for (const key of ["terminal_animation_enabled", "open_webui", "image_enabled", "prediction_enabled"]) {
66
72
  const input = el(`setting-${key}`), effective = data.effective[key];
67
73
  input.checked = data.saved[key];input.disabled = Boolean(effective.locked);
@@ -95,6 +101,7 @@
95
101
  async function loadSettings() {
96
102
  if (settingsPending) return;
97
103
  settingsPending = true;
104
+ el("terminal-color-theme").disabled = true;
98
105
  try { applySettings(await api());settingsReadAt = new Date().toLocaleTimeString(); }
99
106
  catch (error) {
100
107
  for (const id of ["settings-note", "page-settings-note"]) {
@@ -102,12 +109,12 @@
102
109
  el(id).title = error.message;
103
110
  }
104
111
  }
105
- finally { settingsPending = false;el("apply-source").disabled = !sourceReady();syncReviewButton(); }
112
+ finally { settingsPending = false;el("terminal-color-theme").disabled = !settings;el("apply-source").disabled = !sourceReady();syncReviewButton(); }
106
113
  }
107
114
  async function change(body, button) {
108
115
  if (settingsPending) return;
109
116
  settingsPending = true;
110
- 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, #m365-on, #m365-off")];
117
+ 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")];
111
118
  controls.forEach(input => { input.disabled = true; });
112
119
  label(el("settings-note"), "applying");
113
120
  if (button) button.setAttribute("aria-busy", "true");
@@ -117,10 +124,12 @@
117
124
  if (body.action === "provider" && body.operation === "auto-review") reviewDirty = false;
118
125
  if (body.action === "provider" && body.operation === "off") { sourceDirty = false;reviewDirty = false; }
119
126
  el("review-control-note").textContent = "";
120
- applySettings(data);await dashboardRefresh.refresh("status", { force: true });await dashboardRefresh.refresh("auth", { force: true });
127
+ applySettings(data);
128
+ if (body.action !== "color_theme") { await dashboardRefresh.refresh("status", { force: true });await dashboardRefresh.refresh("auth", { force: true }); }
121
129
  }
122
130
  catch (error) {
123
131
  if (settings) applySettings(settings);
132
+ if (body.action === "color_theme") { label(el("terminal-color-note"), "not_saved_error", { error: error.message });return; }
124
133
  el("settings-note").textContent = error.message;el("source-control-note").textContent = error.message;el("m365-control-note").textContent = error.message;el("review-control-note").textContent = error.message;el("effect-history").textContent = error.message;
125
134
  if (body.key) el(`effect-${body.key}`).textContent = error.message;
126
135
  } finally {
@@ -134,6 +143,7 @@
134
143
  for (const input of document.querySelectorAll("[role=switch]")) input.addEventListener("change", () => {
135
144
  void change({ action: "preference", key: input.id.slice("setting-".length), value: input.checked }, input);
136
145
  });
146
+ el("terminal-color-theme").addEventListener("change", () => void change({ action: "color_theme", theme: el("terminal-color-theme").value }, el("terminal-color-theme")));
137
147
  el("save-history").addEventListener("click", () => void change({ action: "history_limit", mib: Number(el("history-limit").value) }, el("save-history")));
138
148
  el("clean-history").addEventListener("click", () => {
139
149
  if (window.confirm(globalThis.ccdxLanguage.format("clear_inactive_codex_conversation_data_older_continuation_ids_ma"))) void change({ action: "history_clean" }, el("clean-history"));
@@ -133,6 +133,7 @@
133
133
  <div id="model-providers" class="provider-tabs" role="tablist" aria-label="Model providers" data-i18n-label="model_providers"></div>
134
134
  <div class="section-actions"><button id="refresh-models" type="button" data-i18n="refresh">Refresh</button></div>
135
135
  <p id="models-note" class="table-note" data-i18n="reading_provider_catalog">Loading model list…</p>
136
+ <details id="model-check-details" class="model-check-details" hidden><summary data-i18n="source_check_details">Check details</summary><dl id="model-check-fields" class="failure-detail"></dl><p class="hint" data-i18n="source_check_action">Use Refresh to check this source again.</p></details>
136
137
  <div class="table-wrap"><table><thead><tr><th scope="col" data-i18n="model">MODEL</th><th scope="col" data-i18n="vendor">MODEL MAKER</th><th scope="col" data-i18n="api">CONNECTION TYPE</th><th scope="col" data-i18n="client">APP</th><th scope="col" data-i18n="reasoning">THINKING LEVEL</th><th scope="col" data-i18n="state">STATE</th></tr></thead><tbody id="live-models-body" role="tabpanel"><tr><td colspan="6" data-i18n="loading">Loading…</td></tr></tbody></table></div>
137
138
  <p class="hint" data-i18n="catalog_listing_does_not_guarantee_inference_access">Listed does not mean your account can use it.</p>
138
139
  </details>
@@ -192,20 +193,67 @@ Missing data is unknown. This panel keeps no prompts or images.</p>
192
193
  </details>
193
194
  </div>
194
195
  <div data-view="system" hidden>
195
- <section class="panel dashboard-section"><h2 data-i18n="process_listener">LOCAL SERVICE</h2><p id="process-state" class="table-note"></p><p id="process-memory" class="hint"></p><p id="process-queues" class="hint"></p><p id="process-notice" class="hint" role="status"></p></section>
196
- <section class="overview client-overview"><article class="card"><h2 data-i18n="http_traffic">SERVICE REQUESTS</h2><strong id="requests">—</strong><p id="request-errors">—</p><p id="http-error-breakdown">—</p><p><span data-i18n="per_request_limits_active">Per-request limits</span><br><span id="body-limits">—</span></p></article></section>
196
+ <section class="panel dashboard-section" aria-labelledby="web-appearance-title">
197
+ <h2 id="web-appearance-title" data-i18n="appearance_web_appearance">网页外观</h2>
198
+ <div class="appearance-row">
199
+ <div class="appearance-label"><label for="web-color-theme" data-i18n="appearance_color_theme">颜色主题</label><p data-i18n="appearance_browser_scope">只影响当前浏览器。</p></div>
200
+ <select id="web-color-theme" class="appearance-select"><option value="green" data-i18n="appearance_classic_green">经典绿(默认)</option><option value="klein" data-i18n="appearance_klein_blue">克莱因蓝</option></select>
201
+ </div>
202
+ <p id="web-color-note" class="appearance-note" role="status" data-i18n="theme_saved_browser">选择后,网页立即换色。</p>
203
+ </section>
204
+
205
+ <section class="panel dashboard-section" id="terminal-appearance" aria-labelledby="terminal-appearance-title">
206
+ <h2 id="terminal-appearance-title" data-i18n="terminal_appearance">终端外观</h2>
207
+ <div class="appearance-row">
208
+ <div class="appearance-label"><label for="terminal-color-theme" data-i18n="appearance_color_theme">颜色主题</label><p data-i18n="appearance_terminal_scope">与网页主题分别设置。</p></div>
209
+ <select id="terminal-color-theme" disabled class="appearance-select"><option value="green" data-i18n="appearance_classic_green">经典绿(默认)</option><option value="klein" data-i18n="appearance_klein_blue">克莱因蓝</option></select>
210
+ </div>
211
+ <p id="terminal-color-note" class="appearance-note" role="status" data-i18n="appearance_terminal_effect">表格即时换色,启动 Logo 下次生效。</p>
212
+
213
+ <div id="terminal-color-sample" class="terminal-sample" data-terminal-palette="green" aria-label="Terminal color preview" data-i18n-label="terminal_color_preview">
214
+ <div class="terminal-caption"><span>CCDX · Terminal</span><span data-i18n="appearance_sample">Sample data</span></div>
215
+ <div class="terminal-brand">
216
+ <pre class="terminal-logo" aria-hidden="true"> ▄▀█▄ ▄█▀▄
217
+ █ ▄███▄ █
218
+ ▄▀▀█▀ ▄ ▀█▀▀▄
219
+ ▀▄▄█▄ ▀ ▄█▄▄▀
220
+ █ ▀███▀ █
221
+ ▀▄█▀ ▀█▄▀ </pre>
222
+ <div><strong>CCDX</strong><span>by Dale Xiao</span></div>
223
+ </div>
224
+ <pre class="terminal-table terminal-wide">┌─────────────────────┬───────────────────┐
225
+ │ Usage / this run │ Inference │
226
+ ├─────────────────────┼───────────────────┤
227
+ │ Input 1.7M │ Requests 57 │
228
+ │ Output 5.6K │ Active 2 │
229
+ └─────────────────────┴───────────────────┘</pre>
230
+ <pre class="terminal-table terminal-compact">┌──────────────┬──────────────┐
231
+ │ Usage │ Inference │
232
+ ├──────────────┼──────────────┤
233
+ │ Input 1.7M │ Requests 57 │
234
+ │ Output 5.6K │ Active 2 │
235
+ └──────────────┴──────────────┘</pre>
236
+ <pre class="terminal-notices">0 notices / details in WebUI</pre>
237
+ <pre class="terminal-motion"><span id="terminal-sample-frame">[ :::::::]</span> <span id="terminal-sample-status">Working</span></pre>
238
+ </div>
239
+
240
+ <div class="setting-row"><label for="setting-terminal_animation_enabled" data-i18n="terminal_animation">Terminal animation</label><input id="setting-terminal_animation_enabled" type="checkbox" role="switch" disabled><span id="effect-terminal_animation_enabled" class="hint" role="status"></span></div>
241
+ <details id="animation-settings" class="appearance-animation settings-panel">
242
+ <summary class="panel-heading"><h2 data-i18n="terminal_animation_9edf6">TERMINAL ANIMATION</h2><span id="animation-state" data-i18n="reading">READING</span></summary>
243
+ <div id="animation-options" class="animation-options" role="group" aria-label="Animation style" data-i18n-label="animation_theme"></div>
244
+ <div class="section-actions"><button id="save-animation" type="button" disabled data-i18n="save_selection">Save animation</button><span id="animation-note" role="status" data-i18n="applies_to_the_running_terminal">Updates the running terminal.</span></div>
245
+ </details>
246
+ </section>
247
+
197
248
  <section class="panel dashboard-section" aria-labelledby="settings-heading">
198
249
  <h2 id="settings-heading" data-i18n="service_settings">SERVICE SETTINGS</h2>
199
250
  <p class="hint" data-i18n="saved_preference_and_effective_state_are_separate_environment_ov">Saved choices and current behavior are shown separately. Startup overrides and required restarts are listed.</p>
200
- <div class="setting-row"><label for="setting-terminal_animation_enabled" data-i18n="terminal_animation">Terminal animation</label><input id="setting-terminal_animation_enabled" type="checkbox" role="switch" disabled><span id="effect-terminal_animation_enabled" class="hint" role="status"></span></div>
201
251
  <div class="setting-row"><label for="setting-open_webui" data-i18n="open_webui_at_startup">Open dashboard on startup</label><input id="setting-open_webui" type="checkbox" role="switch" disabled><span id="effect-open_webui" class="hint" role="status"></span></div>
202
252
  <p id="settings-note" class="hint" role="status" data-i18n="reading_settings">Reading settings…</p>
203
253
  </section>
204
- <details id="animation-settings" class="panel dashboard-section settings-panel">
205
- <summary class="panel-heading"><h2 data-i18n="terminal_animation_9edf6">TERMINAL ANIMATION</h2><span id="animation-state" data-i18n="reading">READING</span></summary>
206
- <div id="animation-options" class="animation-options" role="group" aria-label="Animation style" data-i18n-label="animation_theme"></div>
207
- <div class="section-actions"><button id="save-animation" type="button" disabled data-i18n="save_selection">Save animation</button><span id="animation-note" role="status" data-i18n="applies_to_the_running_terminal">Updates the running terminal.</span></div>
208
- </details>
254
+
255
+ <section class="panel dashboard-section"><h2 data-i18n="process_listener">LOCAL SERVICE</h2><p id="process-state" class="table-note"></p><p id="process-memory" class="hint"></p><p id="process-queues" class="hint"></p><p id="process-notice" class="hint" role="status"></p></section>
256
+ <section class="overview client-overview"><article class="card"><h2 data-i18n="http_traffic">SERVICE REQUESTS</h2><strong id="requests">—</strong><p id="request-errors">—</p><p id="http-error-breakdown">—</p><p><span data-i18n="per_request_limits_active">Per-request limits</span><br><span id="body-limits">—</span></p></article></section>
209
257
  </div>
210
258
  </main>
211
259
  <footer data-i18n="local_only_visible_page_updates">THIS COMPUTER ONLY / UPDATES WHILE VISIBLE</footer>
@@ -1,5 +1,28 @@
1
1
  (() => {
2
2
  const translations = {
3
+ "source_catalog_unavailable": ["Model list unavailable: {code}", "模型列表不可用:{code}"],
4
+ "terminal_color_preview": ["Terminal color preview", "终端配色预览"],
5
+ "source_retry_time": ["Can retry after {time}.", "可在 {time} 后重试。"],
6
+ "appearance_web_appearance": ["WEB APPEARANCE", "网页外观"],
7
+ "appearance_color_theme": ["Color theme", "颜色主题"],
8
+ "appearance_browser_scope": ["This browser only.", "只影响当前浏览器。"],
9
+ "appearance_classic_green": ["Classic green (default)", "经典绿(默认)"],
10
+ "appearance_klein_blue": ["Klein blue", "克莱因蓝"],
11
+ "appearance_terminal_scope": ["Independent of the webpage theme.", "与网页主题分别设置。"],
12
+ "appearance_terminal_effect": ["Table updates now. Startup logo changes next launch.", "表格即时换色,启动 Logo 下次生效。"],
13
+ "appearance_sample": ["Sample data", "示例数据"],
14
+ "theme_saved_browser": ["Saved in this browser. Changes apply now.", "保存在此浏览器,立即生效。"],
15
+ "theme_tab_only": ["This tab only. Browser storage is unavailable.", "本次有效,浏览器未能保存。"],
16
+ "terminal_theme_applied": ["Table updated. Startup logo changes next launch.", "表格已换色,启动 Logo 下次生效。"],
17
+ "terminal_theme_unavailable": ["Saved. Colored output is unavailable in this terminal mode.", "已保存,当前终端模式不显示配色。"],
18
+ "source_check_details": ["Check details", "检查详情"],
19
+ "source_check_failed": ["{source}: model list update failed.", "{source}:模型列表更新失败。"],
20
+ "source_check_previous": ["Showing the list from {time}.", "当前显示 {time} 的列表。"],
21
+ "source_check_none": ["No previous model list is available.", "暂无可用的旧模型列表。"],
22
+ "source_check_time": ["Last check", "本次检查"],
23
+ "source_check_reason": ["Reason", "失败原因"],
24
+ "source_check_action": ["Use Refresh to check this source again.", "点击刷新,重新检查此来源。"],
25
+ "source_failure_summary": ["{source} / {detail}", "{source} / {detail}"],
3
26
  "codex_body_admission_active_active_queued_queued_queue_limit_lim": ["Codex body admission: active {active} / queued {queued} / queue limit {limit}", "Codex请求体:进行中{active}\n排队{queued} / 队列上限{limit}"],
4
27
  "terminal_animation_unavailable_in_this_output_mode": ["Terminal animation unavailable in this output mode", "当前输出模式不播放终端动效"],
5
28
  "prediction_integration_setup": ["Suggestion setup", "建议设置"],
@@ -4,6 +4,7 @@
4
4
  let contextCompactions = {};
5
5
  let failureSignature;
6
6
  let contextSignature;
7
+ const sourceNames = new Map([["github", "GitHub Copilot"], ["m365", "Microsoft 365"]]);
7
8
 
8
9
  function renderProviders(data) {
9
10
  const providers = data.providers || [];
@@ -15,6 +16,7 @@
15
16
  auth.replaceChildren();clients.replaceChildren();requests.replaceChildren();
16
17
  const routes = [];
17
18
  for (const provider of providers) {
19
+ sourceNames.set(provider.id, provider.name);
18
20
  const identity = provider.auth || {};
19
21
  const authRow = tableRow([provider.name, identity.account || "—", states[identity.state] || "unknown",
20
22
  states[provider.state] || "unknown", identity.checked_at || "—", duration(identity.expires_in_ms)], { labels: [2, 3] });
@@ -83,15 +85,22 @@
83
85
  details.dataset.key = `${failure.at}/${failure.request_id || failure.response_id}/${failure.code}`;
84
86
  details.open = expanded.has(details.dataset.key);
85
87
  const title = document.createElement("summary");
86
- localize(title, "detail_retry", {
88
+ const summary = {
87
89
  detail: phrase("time_model_code", {
88
90
  time: failure.at ? String(failure.at) : phrase("unknown_time"),
89
91
  model: failure.model ? String(failure.model).slice(0, 80) : phrase("unknown_model"),
90
92
  code: failure.code ? String(failure.code).slice(0, 80) : phrase("unknown_error"),
91
93
  }),
92
94
  retry: phrase(failure.retried ? "retry_attempted" : "no_retry"),
93
- });
95
+ };
96
+ localize(title, "detail_retry", summary);
94
97
  const timeline = failure.timeline;
98
+ const provider = failure.provider || timeline?.provider;
99
+ if (provider) {
100
+ const source = sourceNames.get(provider) || provider;
101
+ const original = phrase("detail_retry", summary);
102
+ localize(title, "source_failure_summary", { source, detail: original });
103
+ }
95
104
  const timings = timeline?.timings_ms || {};
96
105
  const timingText = ["admission", "body", "history", "images", "serialization", "upstream_start", "upstream_headers", "first_output", "last_activity", "terminal", "finished"]
97
106
  .filter((key) => finite(timings[key])).map((key) => `${key}=${Number(timings[key]).toFixed(1)}`).join(" / ");
@@ -1,35 +1,58 @@
1
1
  (() => {
2
- const key = "ccdx.dashboard.theme";
3
- let theme = "dark";
2
+ const key = "ccdx.dashboard.theme", paletteKey = "ccdx.dashboard.palette";
3
+ const valid = value => value === "green" || value === "klein";
4
+ let theme = "dark", palette = "green", saved = true;
4
5
  try {
5
6
  if (localStorage.getItem(key) === "light") theme = "light";
6
- } catch { /* Private browsing may disable storage. */ }
7
+ const value = localStorage.getItem(paletteKey);if (valid(value)) palette = value;
8
+ } catch { saved = false; }
9
+ const label = (node, message) => {
10
+ if (!node) return;
11
+ if (globalThis.ccdxLanguage) globalThis.ccdxLanguage.set(node, message);
12
+ else node.textContent = message;
13
+ };
14
+ function sync() {
15
+ const select = document.getElementById("web-color-theme");if (select) select.value = palette;
16
+ label(document.getElementById("web-color-note"), saved ? "theme_saved_browser" : "theme_tab_only");
17
+ }
7
18
  const applyTheme = () => {
8
19
  document.documentElement.dataset.theme = theme;
9
- const color = theme === "dark" ? "#a6f5a8" : "#176b3a";
20
+ document.documentElement.dataset.palette = palette;
21
+ const color = palette === "klein" ? theme === "dark" ? "#789aff" : "#002fa7" : theme === "dark" ? "#a6f5a8" : "#176b3a";
10
22
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><g fill="none" stroke="${color}" stroke-width="3" stroke-linecap="round"><ellipse cx="32" cy="32" rx="26" ry="10"/><ellipse cx="32" cy="32" rx="26" ry="10" transform="rotate(60 32 32)"/><ellipse cx="32" cy="32" rx="26" ry="10" transform="rotate(120 32 32)"/></g><circle cx="32" cy="32" r="4.5" fill="${color}"/></svg>`;
11
23
  document.getElementById("favicon").href = `data:image/svg+xml,${encodeURIComponent(svg)}`;
12
24
  };
13
25
  applyTheme();
14
-
26
+ function persist() {
27
+ try { localStorage.setItem(key, theme);localStorage.setItem(paletteKey, palette);saved = true; }
28
+ catch { saved = false; }
29
+ sync();
30
+ }
15
31
  document.addEventListener("DOMContentLoaded", () => {
16
32
  const button = document.getElementById("theme-toggle");
17
33
  const updateLabel = () => {
18
- const label = `Switch to ${theme === "dark" ? "light" : "dark"} mode`;
34
+ const value = `Switch to ${theme === "dark" ? "light" : "dark"} mode`;
19
35
  if (globalThis.ccdxLanguage) {
20
- globalThis.ccdxLanguage.set(button, label, {}, "aria-label");
21
- globalThis.ccdxLanguage.set(button, label, {}, "title");
22
- } else {
23
- button.setAttribute("aria-label", label);
24
- button.title = label;
25
- }
36
+ globalThis.ccdxLanguage.set(button, value, {}, "aria-label");
37
+ globalThis.ccdxLanguage.set(button, value, {}, "title");
38
+ } else { button.setAttribute("aria-label", value);button.title = value; }
26
39
  };
27
- updateLabel();
40
+ updateLabel();sync();
28
41
  button.addEventListener("click", () => {
29
- theme = theme === "dark" ? "light" : "dark";
30
- applyTheme();
31
- try { localStorage.setItem(key, theme); } catch { /* Keep the current selection. */ }
42
+ theme = theme === "dark" ? "light" : "dark";applyTheme();
43
+ persist();
32
44
  updateLabel();
33
45
  });
46
+ document.getElementById("web-color-theme")?.addEventListener("change", event => {
47
+ if (!valid(event.target.value)) return;
48
+ palette = event.target.value;applyTheme();
49
+ persist();
50
+ });
51
+ globalThis.addEventListener?.("storage", event => {
52
+ if (event.key !== paletteKey && event.key !== key) return;
53
+ if (event.key === paletteKey) palette = valid(event.newValue) ? event.newValue : "green";
54
+ else theme = event.newValue === "light" ? "light" : "dark";
55
+ applyTheme();updateLabel();sync();
56
+ });
34
57
  });
35
58
  })();
@@ -202,3 +202,61 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
202
202
  .section-actions > label { flex: 1 1 180px; }
203
203
  .section-actions select { max-width: 100%; }
204
204
  }
205
+
206
+ /* Independent color palettes; green remains the unchanged default. */
207
+ :root[data-palette="klein"][data-theme="light"] {
208
+ color-scheme: light;
209
+ --page:#F3F6FF; --surface:#ffffff; --text:#19354F; --strong:#102E4C;
210
+ --muted:#4b607a; --badge:#4b607a; --subtle:#4f6681; --quiet:#5d718b; --footer:#5d718b;
211
+ --border:#C5CFEA; --top-border:#B8C6E6; --accent:#002FA7; --accent-soft:#002FA7; --heading:#002FA7;
212
+ --button-border:#819AD4; --button-bg:#EDF2FF; --button-fg:#002FA7; --button-hover:#DAE4FF;
213
+ --selected-bg:#E3EAFF; --option-hover:#EBF0FF; --table-text:#24405E; --preview:#586f8b;
214
+ --ansi-white:#0752A6; --ansi-159:#002FA7; --ansi-123:#1678FF; --ansi-87:#2493FF;
215
+ --ansi-51:#47B6FF; --ansi-45:#438FFF; --ansi-39:#547AFF; --ansi-33:#5D6CDB;
216
+ --bad:#a33625; --failed:#a33625; --incomplete:#835600;
217
+ }
218
+ :root[data-palette="klein"]:not([data-theme="light"]) {
219
+ color-scheme:dark;
220
+ --page:#081625; --surface:#0F2236; --text:#dde7f4; --strong:#eff6ff;
221
+ --muted:#9caec6; --badge:#adbed4; --subtle:#91a8c5; --quiet:#829bb9; --footer:#829bb9;
222
+ --border:#244663; --top-border:#244663; --accent:#789AFF; --accent-soft:#89A7FF; --heading:#93ADFF;
223
+ --button-border:#526CA9; --button-bg:#1B2B4C; --button-fg:#A5BBFF; --button-hover:#273D68;
224
+ --selected-bg:#1C315C; --option-hover:#14334F; --table-text:#d1dfef; --preview:#8da7c9;
225
+ --ansi-white:#edf5ff; --ansi-159:#acd6ff; --ansi-123:#91c7ff; --ansi-87:#7bb9f4;
226
+ --ansi-51:#68a9e5; --ansi-45:#6095d1; --ansi-39:#678ac4; --ansi-33:#707eb1;
227
+ --bad:#ff947e; --failed:#ff9f91; --incomplete:#e3c77c;
228
+ }
229
+
230
+ .appearance-row { display:grid; grid-template-columns:minmax(0,1fr) 200px; align-items:center; gap:18px; margin-top:20px; }
231
+ .appearance-label { min-width:0; }
232
+ .appearance-label label { display:block; font-size:13px; color:var(--text); line-height:1.65; }
233
+ .appearance-label p { margin:4px 0 0; font-size:12px; color:var(--subtle); line-height:1.7; }
234
+ .appearance-select { width:100%; max-width:100%; min-width:0; height:36px; box-sizing:border-box; border-radius:2px; padding:0 10px; font-size:12px; }
235
+ .appearance-note { color:var(--subtle); margin:17px 0 0; font-size:12px; line-height:1.7; }
236
+ .appearance-animation { margin-top:22px; border-top:1px solid var(--border); padding-top:18px; }
237
+ .appearance-animation > summary { color:var(--heading); font-size:12px; font-weight:700; }
238
+ .terminal-sample { --sample-bg:#0F151D; --sample-text:#DFE7F2; --sample-muted:#A2B0C2; --sample-line:#304054; --sample-logo:#A6F5A8; --sample-table:#DFE7F2; --sample-motion:#84E99E; padding:16px; margin-top:20px; border:1px solid var(--sample-line); border-radius:2px; background:var(--sample-bg); color:var(--sample-text); }
239
+ .terminal-sample[data-terminal-palette="klein"] { --sample-logo:#4C9FFF; --sample-table:#4C9FFF; --sample-motion:#4C9FFF; }
240
+ .terminal-caption { display:flex; justify-content:space-between; flex-wrap:wrap; gap:8px; color:var(--sample-muted); font-size:11px; line-height:1.6; margin-bottom:16px; }
241
+ .terminal-brand { display:flex; align-items:center; flex-wrap:wrap; gap:14px; margin-bottom:15px; }
242
+ .terminal-brand strong { color:var(--sample-text); display:block; font-size:12px; font-weight:500; line-height:1.7; }
243
+ .terminal-brand div>span { display:block; color:var(--sample-muted); font-size:11px; line-height:1.7; }
244
+ .terminal-sample pre { font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace; padding:0; margin:0; background:transparent; border:0; border-radius:0; letter-spacing:0; }
245
+ .terminal-sample .terminal-logo { color:var(--sample-logo); font-size:12px; line-height:1.15; white-space:pre; }
246
+ .terminal-sample .terminal-table { color:var(--sample-table); font-size:11px; line-height:1.45; white-space:pre; }
247
+ .terminal-sample .terminal-notices { margin-top:10px; font-size:11px; line-height:1.6; white-space:pre-wrap; color:var(--sample-muted); }
248
+ .terminal-sample .terminal-motion { color:var(--sample-text); font-size:11px; line-height:1.6; white-space:pre-wrap; }
249
+ #terminal-sample-frame { color:var(--sample-motion); }
250
+ .terminal-compact { display:none; }
251
+ @media(max-width:700px) { .appearance-row { grid-template-columns:minmax(0,1fr) 180px; gap:12px; } }
252
+ @media(max-width:480px) { .appearance-row { grid-template-columns:minmax(0,1fr) auto; gap:12px; } .appearance-row:has(select) { grid-template-columns:minmax(0,1fr); } .appearance-select { width:100%; } .terminal-wide { display:none; } .terminal-compact { display:block; } .terminal-sample { padding:12px 9px; } .terminal-sample .terminal-table { font-size:11px; } }
253
+ @media(pointer:coarse) { .appearance-select { min-height:44px; font-size:16px; } }
254
+ .model-check-details { margin:14px 0; color:var(--text); }
255
+ .model-check-details > summary { color:var(--heading); font-size:12px; }
256
+ #models-note p { margin:4px 0; }
257
+
258
+ :root:not([data-theme="light"]) #animation-settings { --ansi-white:#f5fff5;--ansi-159:#9af5e9;--ansi-123:#75e4d9;--ansi-87:#5ad0d4;--ansi-51:#42b9d8;--ansi-45:#3ca2d0;--ansi-39:#4389c2;--ansi-33:#4775b2; }
259
+ :root:not([data-theme="light"]) #animation-settings[data-terminal-palette="klein"] { --ansi-white:#789aff;--ansi-159:#789aff;--ansi-123:#789aff;--ansi-87:#789aff;--ansi-51:#789aff;--ansi-45:#789aff;--ansi-39:#789aff;--ansi-33:#789aff; }
260
+
261
+ :root[data-theme="light"] #animation-settings { --ansi-white:#234231;--ansi-159:#116b64;--ansi-123:#0d7771;--ansi-87:#116b75;--ansi-51:#14697e;--ansi-45:#1a6183;--ansi-39:#265f8d;--ansi-33:#365a8d; }
262
+ :root[data-theme="light"] #animation-settings[data-terminal-palette="klein"] { --ansi-white:#002fa7;--ansi-159:#002fa7;--ansi-123:#002fa7;--ansi-87:#002fa7;--ansi-51:#002fa7;--ansi-45:#002fa7;--ansi-39:#002fa7;--ansi-33:#002fa7; }
@@ -340,7 +340,9 @@ async function readDashboard(url, { signal, timeout = 15000, source } = {}) {
340
340
  const response = await fetch(url, { cache: "no-store", headers: { "X-CCDX-Dashboard": "1", Accept: "application/json" },
341
341
  signal: AbortSignal.any([signal, AbortSignal.timeout(timeout)]) });
342
342
  const data = await response.json();
343
- if (!response.ok || (source && !(Array.isArray(source) ? source : [source]).includes(data.source))) throw new Error(data.error || `HTTP ${response.status}`);
343
+ if (!response.ok || (source && !(Array.isArray(source) ? source : [source]).includes(data.source))) {
344
+ throw Object.assign(new Error(data.error || `HTTP ${response.status}`), { diagnostic: data.diagnostic });
345
+ }
344
346
  return data;
345
347
  }
346
348
 
@@ -410,11 +412,35 @@ const dashboardRefresh = globalThis.ccdxRefresh.createController({
410
412
  state: state => {
411
413
  element("refresh-models").disabled = Boolean(state.pending);
412
414
  text("models-state", state.pending ? "checking_live" : state.error ? "live_lookup_failed" : state.value?.source === "catalog" ? "catalog_snapshot" : "live_snapshot");
415
+ element("model-check-details").hidden = !state.error;
413
416
  if (state.error) {
414
417
  const message = String(state.error.message || state.error).slice(0, 240);
415
418
  const httpError = /^Live model lookup failed \(HTTP (\d{3})\)\. Run ccdx models for details\.$/.exec(message);
416
419
  if (httpError) text("models-note", "live_model_lookup_failed_http_status_run_ccdx_models_for_details", { status: httpError[1] });
417
420
  else text("models-note", message);
421
+ const sourceReason = /^Model catalog unavailable \/ (m365_[a-z0-9_]+)$/.exec(message);
422
+ const reason = httpError ? phrase("live_model_lookup_failed_http_status_run_ccdx_models_for_details", { status: httpError[1] })
423
+ : sourceReason ? phrase("source_catalog_unavailable", { code: sourceReason[1] }) : phrase(message);
424
+ const source = providerEntries.find(entry => entry.id === selectedProvider)?.name || selectedProvider;
425
+ const previous = modelSnapshots.get(selectedProvider);
426
+ element("models-note").replaceChildren();
427
+ const summary = document.createElement("span"), kept = document.createElement("span");
428
+ localize(summary, "source_check_failed", { source });
429
+ localize(kept, previous?.checked_at ? "source_check_previous" : "source_check_none", { time: previous?.checked_at ? new Date(previous.checked_at).toLocaleTimeString() : "" });
430
+ element("models-note").append(summary, document.createElement("br"), kept);
431
+ const fields = element("model-check-fields");fields.replaceChildren();
432
+ const diagnostic = state.error.diagnostic || {};
433
+ for (const [key, value] of [["source", source], ["source_check_time", diagnostic.checked_at], ["source_check_reason", reason], ["http_status", diagnostic.http_status]]) {
434
+ if (value === null || value === undefined || value === "") continue;
435
+ const term = document.createElement("dt"), detail = document.createElement("dd");localize(term, key);
436
+ if (value?.key) localize(detail, value.key, value.values);else detail.textContent = String(value).slice(0, 300);
437
+ fields.append(term, detail);
438
+ }
439
+ if (Number.isFinite(diagnostic.retry_after_ms) && diagnostic.retry_after_ms > 0) {
440
+ const term = document.createElement("dt"), detail = document.createElement("dd");localize(term, "retry");
441
+ const checked = Date.parse(diagnostic.checked_at);
442
+ if (Number.isFinite(checked)) { localize(detail, "source_retry_time", { time: new Date(checked + diagnostic.retry_after_ms).toLocaleTimeString() });fields.append(term, detail); }
443
+ }
418
444
  }
419
445
  if (state.error && !modelSnapshots.has(selectedProvider)) emptyTable("live-models-body", 6, "no_catalog_available");
420
446
  for (const node of timestamps.get("models")) refreshTime(node, state);
@@ -249,8 +249,8 @@ export async function handleDashboardApi(req, res, pathname, {
249
249
 
250
250
  if (pathname === MODELS_PATH && req.method === "GET") {
251
251
  const abort = createRequestAbort(req, res);
252
+ const provider = new URL(req.url, "http://localhost").searchParams.get("provider") || "";
252
253
  try {
253
- const provider = new URL(req.url, "http://localhost").searchParams.get("provider") || "";
254
254
  if (provider && (!isProviderId(provider) || !dashboardProviders(providerStateFn, authStatusFn).some(entry => entry.id === provider))) {
255
255
  sendJson(res, 400, { error: "Select a registered provider" });return;
256
256
  }
@@ -280,7 +280,11 @@ export async function handleDashboardApi(req, res, pathname, {
280
280
  })),
281
281
  });
282
282
  } catch (error) {
283
- if (!res.destroyed && !res.writableEnded) sendJson(res, error.statusCode || 502, { error: /^m365_[a-z0-9_]+$/.test(error.code || "") ? `Model catalog unavailable / ${error.code}` : liveModelError(error) });
283
+ const message = /^m365_[a-z0-9_]+$/.test(error.code || "") ? `Model catalog unavailable / ${error.code}` : liveModelError(error);
284
+ if (!res.destroyed && !res.writableEnded) sendJson(res, error.statusCode || 502, { error: message,
285
+ diagnostic: { provider: provider || null, checked_at: new Date().toISOString(), message,
286
+ http_status: Number(/\bHTTP (\d{3})\b/.exec(message)?.[1]) || finite(error.statusCode),
287
+ retry_after_ms: finite(error.retryAfterMs) } });
284
288
  } finally { abort.cleanup(); }
285
289
  return;
286
290
  }
@@ -1,5 +1,5 @@
1
1
  import { serviceSettingsSnapshot, servicePreferences, writeServicePreference,
2
- writeTerminalAnimationTheme, responseHistoryLimitPreference, writeResponseHistoryLimitMib } from "./user-settings.mjs";
2
+ writeTerminalAnimationTheme, writeTerminalColorTheme, responseHistoryLimitPreference, writeResponseHistoryLimitMib } from "./user-settings.mjs";
3
3
  import { readImageProviderConfig } from "./image-provider-config.mjs";
4
4
  import { readPredictionSettings } from "./native-prediction-profile.mjs";
5
5
  import { cacheRuntimeSnapshot, cleanRuntimeCaches, setHistoryCacheLimit } from "./cache-control.mjs";
@@ -10,11 +10,11 @@ export function createServiceControl({ env = process.env, home, providerRuntime,
10
10
  const options = { env, home };
11
11
  let serial = Promise.resolve();
12
12
  function snapshot() {
13
- const { saved, theme, historyLimit } = serviceSettingsSnapshot(options), prediction = clientIntegration?.snapshot().prediction;
13
+ const { saved, theme, color_theme, historyLimit } = serviceSettingsSnapshot(options), prediction = clientIntegration?.snapshot().prediction;
14
14
  let imageConfigured = false, predictionConfigured = false;
15
15
  try { imageConfigured = Boolean(readImages()); } catch {}
16
16
  try { predictionConfigured = readPrediction().enabled === true; } catch {}
17
- return { source: "service_settings", saved, theme,
17
+ return { source: "service_settings", saved, theme, color_theme,
18
18
  effective: {
19
19
  terminal_animation_enabled: { value: terminal?.enabled === true && saved.terminal_animation_enabled && !/^(0|false|no|off)$/i.test(env.CCDX_TERMINAL_ANIMATION || ""),
20
20
  state: terminal?.enabled === true ? "immediate" : "terminal_unavailable", locked: /^(0|false|no|off)$/i.test(env.CCDX_TERMINAL_ANIMATION || "") },
@@ -27,7 +27,7 @@ export function createServiceControl({ env = process.env, home, providerRuntime,
27
27
  }
28
28
  async function apply(input) {
29
29
  if (!input || typeof input !== "object" || Array.isArray(input)) throw new Error("Invalid setting action");
30
- const allowed = { preference: ["action", "key", "value"], animation: ["action", "theme"],
30
+ const allowed = { preference: ["action", "key", "value"], animation: ["action", "theme"], color_theme: ["action", "theme"],
31
31
  history_limit: ["action", "mib"], history_clean: ["action"], prediction_fix: ["action"],
32
32
  provider: ["action", "operation", "provider", "model", "auto_review_model", "auto_review_effort"] }[input.action];
33
33
  if (!allowed || Object.keys(input).some(key => !allowed.includes(key))) throw new Error("Unknown setting action or field");
@@ -35,6 +35,8 @@ export function createServiceControl({ env = process.env, home, providerRuntime,
35
35
  writeServicePreference(input.key, input.value, options);
36
36
  if (input.key === "prediction_enabled") clientIntegration?.setPredictionActive(input.value);
37
37
  terminal?.apply?.({ ...servicePreferences(options) });
38
+ } else if (input.action === "color_theme") {
39
+ writeTerminalColorTheme(input.theme, options);terminal?.apply?.({ color_theme: input.theme });
38
40
  } else if (input.action === "animation") {
39
41
  if (!isTerminalAnimationTheme(input.theme)) throw new Error("Select a listed animation theme");
40
42
  writeTerminalAnimationTheme(input.theme, options);terminal?.apply?.({ theme: input.theme });
@@ -1,5 +1,7 @@
1
1
  import { status } from "./status.mjs";
2
2
  import { terminalCell } from "./terminal-text.mjs";
3
+ import { colorTerminalText } from "./terminal-colors.mjs";
4
+ import { terminalColorPreference } from "./user-settings.mjs";
3
5
 
4
6
  // The favicon's three ellipses, rasterized as terminal half-blocks. No runtime
5
7
  // graphics library or terminal cursor control is needed.
@@ -12,12 +14,13 @@ const ATOM = [
12
14
  " ▀▄█▀ ▀█▄▀ ",
13
15
  ];
14
16
 
15
- export function startupBanner({ commandName = "ccdx", version, stream = process.stdout, env = process.env } = {}) {
17
+ export function startupBanner({ commandName = "ccdx", version, stream = process.stdout, env = process.env, home, colorTheme } = {}) {
16
18
  const title = `${terminalCell(commandName)} v${terminalCell(version)} by Dale Xiao`;
17
19
  const color = stream.isTTY === true && !Object.hasOwn(env, "NO_COLOR") && env.TERM !== "dumb";
18
20
  if (!color || Number(stream.columns || 80) < 72) return `${title}\nLocal model services for Codex and Claude`;
19
21
  const labels = new Map([[1, `${terminalCell(commandName).toUpperCase()} v${terminalCell(version)}`], [2, "by Dale Xiao"], [4, "Codex + Claude / local services"]]);
20
- return ATOM.map((line, i) => `\x1b[38;2;166;245;168m${line}\x1b[0m${labels.has(i) ? ` ${labels.get(i)}` : ""}`).join("\n");
22
+ const theme = colorTheme || terminalColorPreference({ env, home });
23
+ return ATOM.map((line, i) => `${colorTerminalText(line, theme, { output: stream, env })}${labels.has(i) ? ` ${labels.get(i)}` : ""}`).join("\n");
21
24
  }
22
25
 
23
26
  export function startupCheck(kind, name, detail) {
@@ -0,0 +1,20 @@
1
+ export const isColorTheme = value => value === "green" || value === "klein";
2
+
3
+ export function terminalColorCode(theme, { output = process.stdout, env = process.env } = {}) {
4
+ if (output.isTTY !== true || Object.hasOwn(env, "NO_COLOR") || env.TERM === "dumb") return "";
5
+ // Preserve the original green exactly. Blue also supports ordinary ANSI terminals.
6
+ if (theme !== "klein") return "\x1b[38;2;166;245;168m";
7
+ const depth = output.getColorDepth?.(env) || (/truecolor|24bit/i.test(env.COLORTERM || "") ? 24 : 4);
8
+ return depth >= 24 ? "\x1b[38;2;76;159;255m" : depth >= 8 ? "\x1b[38;5;75m" : "\x1b[94m";
9
+ }
10
+
11
+ export function colorTerminalText(text, theme, options) {
12
+ const code = terminalColorCode(theme, options);
13
+ return code ? `${code}${text}\x1b[0m` : text;
14
+ }
15
+
16
+ export function colorTerminalMotion(frame, theme, options) {
17
+ if (theme !== "klein") return frame;
18
+ const code = terminalColorCode(theme, options);
19
+ return frame.replace(/\x1b\[(?:38;5;\d+|97)m/g, code);
20
+ }
@@ -5,6 +5,7 @@ import { DEFAULT_TERMINAL_ANIMATION_THEME, TERMINAL_ANIMATION_THEMES, isTerminal
5
5
  getTerminalAnimationCycleLength, getTerminalAnimationFrameDelay } from "./terminal-animation.mjs";
6
6
  import { displayWidth } from "./cli-table.mjs";
7
7
  import { providerStartupSummary } from "./startup-ui.mjs";
8
+ import { colorTerminalText, colorTerminalMotion } from "./terminal-colors.mjs";
8
9
 
9
10
  const clear = "\r\x1b[2K";
10
11
  const flagOff = value => /^(0|false|no|off)$/i.test(String(value || ""));
@@ -16,7 +17,7 @@ export function createTerminalConsole({ output = process.stdout, errorOutput = p
16
17
  let running = false, timer = null, lines = 0, active = 0, frame = 0, lastRead = 0, data = {};
17
18
  let notices = 0, lastNotice = "", lastPrintedNotice = "", previous = [];
18
19
  let content = [], dirty = true, readFailed = false, updatedAt = null, fits = true;
19
- let current = { theme: DEFAULT_TERMINAL_ANIMATION_THEME, terminal_animation_enabled: true };
20
+ let current = { theme: DEFAULT_TERMINAL_ANIMATION_THEME, color_theme: "green", terminal_animation_enabled: true };
20
21
  let frameDelay = 1000;
21
22
  const tty = output.isTTY === true && errorOutput.isTTY === true && (!env.CI || flagOff(env.CI)) && env.TERM !== "dumb";
22
23
  const supported = () => tty && (Number(output.columns) || 80) >= 40 && (Number(output.rows) || 24) >= 16;
@@ -66,6 +67,7 @@ export function createTerminalConsole({ output = process.stdout, errorOutput = p
66
67
  frame %= getTerminalAnimationCycleLength(current.theme);
67
68
  const metadata = TERMINAL_ANIMATION_THEMES.find(theme => theme.id === current.theme), index = metadata.startFrame + frame;
68
69
  motion = renderTerminalAnimationFrame(current.theme, index);
70
+ motion = colorTerminalMotion(motion, current.color_theme, { output, env });
69
71
  if (Object.hasOwn(env, "NO_COLOR")) motion = stripVTControlCharacters(motion);
70
72
  frame = (frame + 1) % getTerminalAnimationCycleLength(current.theme);
71
73
  frameDelay = getTerminalAnimationFrameDelay(current.theme, index) + (frame === 0 ? metadata.loopPauseMs : 0);
@@ -92,7 +94,9 @@ export function createTerminalConsole({ output = process.stdout, errorOutput = p
92
94
  }
93
95
  dirty = false;
94
96
  }
95
- const body = [...content, `${motion} ${active ? "Working" : "Idle"}`];
97
+ // Apply color after clipping/layout so escape sequences never consume columns.
98
+ const body = [...content.map(line => current.color_theme === "klein" && /^[┌│├└]/.test(line)
99
+ ? colorTerminalText(line, current.color_theme, { output, env }) : line), `${motion} ${active ? "Working" : "Idle"}`];
96
100
  fits = body.length < (Number(output.rows) || 24);
97
101
  if (!fits) { frameDelay = 1000;return; }
98
102
  // Animation ticks update only the final line; data stays on its 1s cadence.
@@ -3,6 +3,7 @@ import os from "node:os";
3
3
  import path from "node:path";
4
4
  import { atomicWriteFileIfChangedSync } from "./atomic-file.mjs";
5
5
  import { withFileLockSync } from "./lock.mjs";
6
+ import { isColorTheme } from "./terminal-colors.mjs";
6
7
  import { AUTO_REVIEW_REASONING_EFFORTS, DEFAULT_CODEX_AUTO_REVIEW_MODEL } from "./models.mjs";
7
8
  import { loadRuntimeConfig, RUNTIME_DEFAULTS } from "./runtime-config.mjs";
8
9
  import {
@@ -50,6 +51,10 @@ export function readUserSettings({ env = process.env, home = os.homedir(), stric
50
51
  delete parsed[key];
51
52
  }
52
53
  }
54
+ if (Object.hasOwn(parsed, "terminal_color_theme") && !isColorTheme(parsed.terminal_color_theme)) {
55
+ if (strict) throw invalidSettings(filePath, "terminal_color_theme must be green or klein");
56
+ delete parsed.terminal_color_theme;
57
+ }
53
58
  if (Object.hasOwn(parsed, AUTO_REVIEW_MODEL_KEY)) {
54
59
  const value = parsed[AUTO_REVIEW_MODEL_KEY];
55
60
  if (typeof value !== "string" || !value.trim()) {
@@ -123,10 +128,26 @@ const serviceFlags = settings => Object.fromEntries(SERVICE_FLAGS.map(key => [ke
123
128
  // One strict read gives each status update a coherent view; no stale cache.
124
129
  export function serviceSettingsSnapshot(options = {}) {
125
130
  const settings = readUserSettings({ ...options, strict: true });
126
- return { saved: serviceFlags(settings), theme: animationPreference(settings).theme,
131
+ return { saved: serviceFlags(settings), theme: animationPreference(settings).theme, color_theme: settings.terminal_color_theme || "green",
127
132
  historyLimit: historyLimitPreference(settings, options.env || process.env) };
128
133
  }
129
134
 
135
+ export function terminalColorPreference(options = {}) {
136
+ return readUserSettings(options).terminal_color_theme || "green";
137
+ }
138
+
139
+ export function writeTerminalColorTheme(theme, options = {}) {
140
+ if (!isColorTheme(theme)) throw new Error("Choose green or klein for the terminal color theme");
141
+ return withFileLockSync(`${userSettingsPath(options)}.lock`, () => {
142
+ const settings = readUserSettings({ ...options, strict: true });
143
+ const next = { ...settings };
144
+ if (theme === "green") delete next.terminal_color_theme;
145
+ else next.terminal_color_theme = theme;
146
+ const changed = atomicWriteFileIfChangedSync(userSettingsPath(options), `${JSON.stringify(next, null, 2)}\n`, { mode: 0o600 });
147
+ return { changed, color_theme: theme };
148
+ });
149
+ }
150
+
130
151
  export function writeServicePreference(key, value, options = {}) {
131
152
  if (!SERVICE_FLAGS.includes(key) || typeof value !== "boolean") throw new Error("Unknown service setting or invalid boolean");
132
153
  return withFileLockSync(`${userSettingsPath(options)}.lock`, () => {