codex-copilot-dx 1.2.24 → 1.2.26
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 +5 -5
- package/docs/ARCHITECTURE.md +31 -1
- package/docs/REFERENCE.md +84 -8
- package/package.json +1 -1
- package/src/access-settings.mjs +1 -1
- package/src/claude-gateway.mjs +3 -1
- package/src/cli-m365.mjs +3 -1
- package/src/connection-runtime.mjs +21 -6
- package/src/dashboard/animation.js +8 -0
- package/src/dashboard/connections.js +2 -2
- package/src/dashboard/console.js +18 -7
- package/src/dashboard/flow.js +11 -2
- package/src/dashboard/icons.js +1 -1
- package/src/dashboard/index.html +16 -0
- package/src/dashboard/language.js +45 -2
- package/src/dashboard/preferences.js +194 -0
- package/src/dashboard/status.js +34 -17
- package/src/dashboard/theme.js +10 -3
- package/src/dashboard/ui.css +21 -0
- package/src/dashboard/ui.js +26 -13
- package/src/dashboard-api.mjs +1 -1
- package/src/dashboard.mjs +1 -0
- package/src/http-transport.mjs +1 -1
- package/src/management-routes.mjs +3 -1
- package/src/optional-routes.mjs +1 -1
- package/src/provider-runtime.mjs +2 -1
- package/src/providers/api.mjs +4 -1
- package/src/providers/m365-endpoint.mjs +4 -0
- package/src/providers/m365-network.mjs +3 -3
- package/src/providers/m365.mjs +7 -5
- package/src/release-install.mjs +9 -3
- package/src/service-control.mjs +10 -2
- package/src/settings-preferences.mjs +76 -0
- package/src/startup-ui.mjs +1 -1
- package/src/status-summary.mjs +6 -0
- package/src/user-settings.mjs +3 -3
- package/src/windows-http-network.mjs +2 -1
- package/src/windows-prediction-network.cs +1 -1
package/src/dashboard/index.html
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
<script src="/updates.js" defer></script>
|
|
20
20
|
<script src="/animation.js" defer></script>
|
|
21
21
|
<script src="/ui.js" defer></script>
|
|
22
|
+
<script src="/preferences.js" defer></script>
|
|
22
23
|
<script src="/console.js" defer></script>
|
|
23
24
|
<script src="/tools.js" defer></script>
|
|
24
25
|
<script src="/connections.js" defer></script>
|
|
@@ -50,6 +51,7 @@
|
|
|
50
51
|
<section class="intro">
|
|
51
52
|
<h1><span id="page-title" data-i18n="overview">Overview</span></h1>
|
|
52
53
|
<p id="page-settings-note" class="hint" role="status"></p>
|
|
54
|
+
<div id="preferences-status" class="preferences-status" role="status" aria-live="polite" hidden></div>
|
|
53
55
|
</section>
|
|
54
56
|
|
|
55
57
|
|
|
@@ -311,6 +313,7 @@
|
|
|
311
313
|
<div class="panel-heading"><h2 data-i18n="request_flow">REQUEST FLOW</h2><span id="flow-state" role="status" aria-live="polite" data-i18n="flow_status_unknown">Status unavailable</span></div>
|
|
312
314
|
<div id="flow-network" class="flow-network" role="group" data-i18n-label="request_flow" aria-label="Request flow">
|
|
313
315
|
<svg id="flow-wires" class="flow-wires" aria-hidden="true"></svg>
|
|
316
|
+
<svg id="flow-active-wires" class="flow-wires flow-activity" aria-hidden="true" hidden></svg>
|
|
314
317
|
<div class="flow-column"><p class="flow-column-title" data-i18n="clients">Apps</p><div id="flow-apps" class="flow-apps"></div></div>
|
|
315
318
|
<div class="flow-hub-column"><button id="flow-hub" type="button" data-i18n-label="flow_show_all" aria-label="Show all requests"><b>CCDX</b></button></div>
|
|
316
319
|
<div class="flow-column"><p class="flow-column-title" data-i18n="flow_sources_models">Sources / models</p><div id="flow-models"></div></div>
|
|
@@ -414,6 +417,19 @@
|
|
|
414
417
|
<p id="install-windows-policy" class="hint" hidden data-i18n="update_windows_policy">If scripts are blocked, use your company’s approved installation method.</p>
|
|
415
418
|
</details><p id="update-copy-note" class="hint" role="status"></p>
|
|
416
419
|
</section>
|
|
420
|
+
<section class="panel dashboard-section" id="settings-preferences" aria-labelledby="preferences-heading">
|
|
421
|
+
<h2 id="preferences-heading" data-i18n="preferences_heading">SAVE & RESTORE</h2>
|
|
422
|
+
<div class="preferences-row"><div><label for="preferences-auto" data-i18n="preferences_auto">Save changes automatically</label><p class="hint" data-i18n="preferences_auto_hint">Valid changes on this page save automatically.</p></div><input id="preferences-auto" type="checkbox" role="switch" disabled checked></div>
|
|
423
|
+
<div class="preferences-row preferences-separator"><div><span data-i18n="preferences_reset_title">Restore default settings</span><p class="hint" data-i18n="preferences_reset_hint">Back up saved settings before restoring.</p></div><button id="preferences-reset" type="button" disabled data-i18n="preferences_reset">Restore defaults</button></div>
|
|
424
|
+
<div id="preferences-backup" class="preferences-row preferences-separator" hidden><div><span data-i18n="preferences_backup">Settings before restore</span><p id="preferences-backup-time" class="hint"></p></div><button id="preferences-restore" type="button" data-i18n="preferences_restore">Restore backup</button></div>
|
|
425
|
+
<div id="preferences-manual" class="preferences-row preferences-separator" hidden><span id="preferences-manual-note" class="hint"></span><div class="connection-actions"><button id="preferences-discard" type="button" data-i18n="preferences_discard">Discard changes</button><button id="preferences-save" type="button" data-i18n="preferences_save">Save changes</button></div></div>
|
|
426
|
+
<div class="section-actions"><button id="preferences-retry" type="button" hidden data-i18n="view_retry">Retry</button><p id="preferences-error" class="hint" role="alert"></p></div>
|
|
427
|
+
</section>
|
|
428
|
+
<dialog id="preferences-dialog" class="preferences-dialog" aria-labelledby="preferences-dialog-title">
|
|
429
|
+
<h2 id="preferences-dialog-title"></h2><p id="preferences-dialog-intro"></p>
|
|
430
|
+
<dl id="preferences-dialog-scope"><div><dt data-i18n="preferences_scope">Restore</dt><dd data-i18n="preferences_scope_value">Web and terminal appearance, animation, startup and update preferences.</dd></div><div><dt data-i18n="preferences_keep">Keep</dt><dd data-i18n="preferences_keep_value">Accounts and keys, models and sources, app connections, chats, usage, image and prediction access.</dd></div></dl>
|
|
431
|
+
<p id="preferences-dialog-note" class="hint"></p><div class="section-actions"><button id="preferences-dialog-cancel" type="button" data-i18n="cancel">Cancel</button><button id="preferences-dialog-confirm" type="button"></button></div>
|
|
432
|
+
</dialog>
|
|
417
433
|
</div>
|
|
418
434
|
</main>
|
|
419
435
|
<footer data-i18n="local_only_visible_page_updates">THIS COMPUTER ONLY / UPDATES WHILE VISIBLE</footer>
|
|
@@ -1,11 +1,54 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
const translations = {
|
|
3
|
+
"preferences_heading": ["SAVE & RESTORE", "保存与恢复"],
|
|
4
|
+
"preferences_auto": ["Save changes automatically", "自动保存设置"],
|
|
5
|
+
"preferences_auto_hint": ["Valid changes on this page save automatically.", "本页改动有效后自动保存。"],
|
|
6
|
+
"preferences_reset_title": ["Restore default settings", "恢复默认设置"],
|
|
7
|
+
"preferences_reset_hint": ["Back up saved settings before restoring.", "恢复前自动备份已保存设置。"],
|
|
8
|
+
"preferences_reset": ["Restore defaults", "恢复默认"],
|
|
9
|
+
"preferences_backup": ["Settings before restore", "恢复前的设置"],
|
|
10
|
+
"preferences_restore": ["Restore backup", "恢复备份"],
|
|
11
|
+
"preferences_discard": ["Discard changes", "放弃修改"],
|
|
12
|
+
"preferences_save": ["Save changes", "保存修改"],
|
|
13
|
+
"preferences_saved": ["Saved", "已保存"],
|
|
14
|
+
"preferences_manual": ["Manual saving is on", "手动保存已开启"],
|
|
15
|
+
"preferences_unsaved": ["{count} unsaved changes", "{count} 项未保存"],
|
|
16
|
+
"preferences_failed": ["Save failed. Your changes are kept. Try again.", "保存失败,改动已保留。请重试。"],
|
|
17
|
+
"preferences_changed": ["Settings changed elsewhere. Discard your draft to load the current settings.", "设置已在其他窗口修改。请放弃草稿后重试。"],
|
|
18
|
+
"preferences_conflict": ["Settings changed", "设置已变更"],
|
|
19
|
+
"preferences_appearance_preview": ["Preview only. Save to keep this choice.", "仅预览,保存后保留此选择。"],
|
|
20
|
+
"preferences_terminal_preview": ["Preview only. Save to update the terminal.", "仅预览,保存后更新终端。"],
|
|
21
|
+
"preferences_browser_changed": ["Browser appearance changed elsewhere. Discard your draft before saving.", "浏览器外观已在其他窗口修改。请先放弃草稿。"],
|
|
22
|
+
"preferences_browser_failed": ["Service settings saved; browser appearance was not saved. Retry to finish.", "服务设置已保存,浏览器外观未保存。请重试完成。"],
|
|
23
|
+
"preferences_browser_backup_invalid": ["The browser backup could not be saved or read. No restore was requested.", "浏览器备份无法保存或读取,尚未请求恢复。"],
|
|
24
|
+
"preferences_browser_backup_missing": ["This browser has no matching appearance backup. Service settings were kept.", "本浏览器没有对应的外观备份,服务设置已保留。"],
|
|
25
|
+
"preferences_scope": ["Restore", "将恢复"],
|
|
26
|
+
"preferences_scope_value": ["Web and terminal appearance, animation, startup and update preferences.", "网页与终端外观、终端动效、启动偏好和更新偏好。"],
|
|
27
|
+
"preferences_keep": ["Keep", "会保留"],
|
|
28
|
+
"preferences_keep_value": ["Accounts and keys, models and sources, app connections, chats, usage, image and prediction access.", "账号与密钥、模型与来源、应用接入、会话与用量、生图与预测开关。"],
|
|
29
|
+
"preferences_reset_question": ["Restore default settings?", "恢复默认设置?"],
|
|
30
|
+
"preferences_reset_intro": ["Restore settings on this page after backing up saved settings.", "恢复本页设置,并先备份已保存设置。"],
|
|
31
|
+
"preferences_reset_confirm": ["Back up & restore", "备份并恢复"],
|
|
32
|
+
"preferences_restore_question": ["Restore the backup?", "恢复备份设置?"],
|
|
33
|
+
"preferences_restore_intro": ["Replace this page's settings with those saved before the last reset.", "用上次恢复默认前的设置替换本页设置。"],
|
|
34
|
+
"preferences_restore_confirm": ["Restore backup", "恢复备份"],
|
|
35
|
+
"preferences_enable_question": ["Turn on automatic saving?", "开启自动保存?"],
|
|
36
|
+
"preferences_enable_intro": ["This also saves your {count} pending changes.", "同时保存当前 {count} 项修改。"],
|
|
37
|
+
"preferences_enable_confirm": ["Save & turn on", "开启并保存"],
|
|
38
|
+
"preferences_nightly_question": ["Turn on overnight updates?", "开启夜间自动更新?"],
|
|
39
|
+
"preferences_nightly_intro": ["CCDX updates and restarts while idle overnight. Conversations may be affected.", "CCDX 会在夜间空闲时更新并重启,可能影响会话继续。"],
|
|
40
|
+
"preferences_nightly_confirm": ["Turn on", "开启"],
|
|
41
|
+
"preferences_backup_latest": ["Only the latest pre-reset backup is kept.", "只保留最近一次恢复前备份。"],
|
|
42
|
+
"preferences_draft_discard": ["Unsaved changes will be discarded. The backup keeps saved settings.", "未保存的改动将放弃;备份保留已保存设置。"],
|
|
3
43
|
"request_access_blocked": ["Access blocked", "请求已拦截"],
|
|
44
|
+
"access_paused": ["Access paused", "接入已暂停"],
|
|
4
45
|
"not_applicable": ["Not applicable", "不适用"],
|
|
5
46
|
"model_owner": ["Model owner", "模型归属"],
|
|
6
47
|
"memory_extract_model": ["Memory extraction model", "记忆提取模型"],
|
|
7
48
|
"memory_extract_role": ["Memory extraction", "记忆提取"],
|
|
8
49
|
"memory_not_detected": ["Not detected", "未检测到"],
|
|
50
|
+
"memory_codex_default": ["Chosen by Codex", "由 Codex 选择"],
|
|
51
|
+
"memory_default_unknown": ["Default model ID not available.", "尚未取得默认型号。"],
|
|
9
52
|
"memory_basis_configured": ["Configured in Codex", "Codex 已配置"],
|
|
10
53
|
"memory_basis_observed": ["Recently observed", "最近检测到"],
|
|
11
54
|
"memory_model_on": ["Enabled", "已启用"],
|
|
@@ -41,7 +84,7 @@
|
|
|
41
84
|
"model_not_selected_message": ["This model is not selected for this app.", "此应用尚未选入该模型。"],
|
|
42
85
|
"model_ambiguous_message": ["This model name matches multiple sources. Select its source-specific entry.", "模型同名,请选择明确来源。"],
|
|
43
86
|
"model_catalog_unavailable_message": ["The selected model is not currently available in its source catalog.", "来源目录中暂时没有该模型。"],
|
|
44
|
-
"client_source_disabled_message": ["
|
|
87
|
+
"client_source_disabled_message": ["Access is paused. Enable the app and source, then select a model.", "接入已暂停。请启用应用和来源,并选择模型。"],
|
|
45
88
|
"local_validation_message": ["The request was rejected locally before an upstream call.", "本机校验未通过,未调用上游。"],
|
|
46
89
|
"count_endpoint_missing_message": ["The source's token-count endpoint returned HTTP 404. Message generation is separate.", "上游计数接口返回 404,回复另行处理。"],
|
|
47
90
|
"nightly_update": ["Update overnight", "夜间自动更新"],
|
|
@@ -213,7 +256,7 @@
|
|
|
213
256
|
"ccdx_source_in_use": ["Change the current source or pause its clients first.", "请先更换来源,或暂停相关客户端。"],
|
|
214
257
|
"ccdx_source_busy": ["A previous M365 request is still running. Let it finish before disabling.", "旧的 M365 请求仍在运行,请结束后关闭。"],
|
|
215
258
|
"ccdx_provider_environment_disabled": ["Microsoft 365 is disabled by CCDX_M365=0.", "Microsoft 365 已被环境设置关闭。"],
|
|
216
|
-
"ccdx_client_source_disabled": ["
|
|
259
|
+
"ccdx_client_source_disabled": ["Access is paused. Enable the app and source, then select a model.", "接入已暂停。请启用应用和来源,并选择模型。"],
|
|
217
260
|
"ccdx_client_source_mismatch": ["Save the selected source before changing its review model.", "请先保存来源,再修改审查模型。"],
|
|
218
261
|
"ccdx_conversation_source_changed": ["This history belongs to another source or key. Start a new conversation.", "此历史属于其他来源或 Key,请新建对话。"],
|
|
219
262
|
"ccdx_conversation_state_invalid": ["Conversation source records are unreadable. The existing file was kept.", "会话来源记录无法读取,原文件已保留。"],
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
function create({ element: el, api, applied, refreshAnimation, selectAnimation, time }) {
|
|
3
|
+
const label = (id, key, values) => globalThis.ccdxLanguage.set(el(id), key, values);
|
|
4
|
+
const theme = () => globalThis.ccdxDashboardTheme;
|
|
5
|
+
const backupKey = "ccdx.dashboard.preferences-backup";
|
|
6
|
+
const fields = { terminal_color_theme: "terminal-color-theme", terminal_animation_enabled: "setting-terminal_animation_enabled",
|
|
7
|
+
open_webui: "setting-open_webui", nightly_updates: "nightly-update" };
|
|
8
|
+
let base, draft = {}, appearance, appearanceBase, pending, timer, error = null, conflict = false, version = 0, dialog, dialogRevision, resetting = false, retrying = false, locks = {}, terminalMode;
|
|
9
|
+
const dirty = () => Object.keys(draft).length + (appearance ? 1 : 0);
|
|
10
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
11
|
+
const active = () => !el("settings-preferences").closest("[hidden]");
|
|
12
|
+
function browserBackup() {
|
|
13
|
+
const raw = localStorage.getItem(backupKey);if (raw === null) return { version: 1, entries: [] };
|
|
14
|
+
const value = JSON.parse(raw);
|
|
15
|
+
if (value?.version !== 1 || !Array.isArray(value.entries) || value.entries.length > 2 || value.entries.some(entry => typeof entry.id !== "string"
|
|
16
|
+
|| !["dark", "light"].includes(entry.values?.theme) || !["green", "klein", "pink"].includes(entry.values?.palette))) throw Error("preferences_browser_backup_invalid");
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
function render() {
|
|
20
|
+
el("preferences-status").hidden = !active();
|
|
21
|
+
if (!base) return;
|
|
22
|
+
const current = { ...base.values, ...draft }, count = dirty(), busy = Boolean(pending || retrying);
|
|
23
|
+
el("preferences-auto").checked = current.auto_save_settings;el("preferences-auto").disabled = busy || conflict;
|
|
24
|
+
for (const [key, id] of Object.entries(fields)) {
|
|
25
|
+
const node = el(id);if (node.type === "checkbox") node.checked = current[key];else node.value = current[key];
|
|
26
|
+
node.disabled = Boolean(locks[key] || resetting);
|
|
27
|
+
}
|
|
28
|
+
el("web-color-theme").disabled = resetting;
|
|
29
|
+
for (const row of document.querySelectorAll("#animation-options [data-theme]")) row.disabled = resetting;
|
|
30
|
+
el("terminal-color-sample").dataset.terminalPalette = current.terminal_color_theme;
|
|
31
|
+
el("animation-settings").dataset.terminalPalette = current.terminal_color_theme;
|
|
32
|
+
el("preferences-reset").disabled = busy;el("preferences-restore").disabled = busy;
|
|
33
|
+
el("preferences-backup").hidden = !base.backup;
|
|
34
|
+
el("preferences-backup-time").textContent = base.backup ? time(base.backup.created_at, { date: true }) : "";
|
|
35
|
+
el("preferences-manual").hidden = current.auto_save_settings && !conflict;
|
|
36
|
+
el("preferences-save").disabled = !count || busy || conflict;el("preferences-discard").disabled = (!count && !conflict) || busy;
|
|
37
|
+
label("preferences-manual-note", conflict ? "preferences_conflict" : count ? "preferences_unsaved" : "preferences_manual", { count });
|
|
38
|
+
globalThis.ccdxIcons.set(el("preferences-status"), busy ? "saving" : error ? "preferences_failed" : count ? "preferences_unsaved" : "preferences_saved",
|
|
39
|
+
error ? "warning" : busy || count ? "unknown" : "ok", { count });
|
|
40
|
+
el("preferences-retry").hidden = !error || conflict || busy;
|
|
41
|
+
el("preferences-error").parentElement.hidden = !error;
|
|
42
|
+
if (!error) el("preferences-error").textContent = "";
|
|
43
|
+
else label("preferences-error", error);
|
|
44
|
+
el("save-animation").hidden = true;
|
|
45
|
+
if (appearance) theme()?.preview(appearance);
|
|
46
|
+
if (appearance) label("web-color-note", "preferences_appearance_preview");
|
|
47
|
+
else theme()?.sync();
|
|
48
|
+
label("terminal-color-note", Object.hasOwn(draft, "terminal_color_theme") ? "preferences_terminal_preview"
|
|
49
|
+
: terminalMode === "status" ? "terminal_theme_applied" : "terminal_theme_unavailable");
|
|
50
|
+
if (draft.terminal_animation) {
|
|
51
|
+
for (const row of document.querySelectorAll("#animation-options [data-theme]")) row.setAttribute("aria-pressed", String(row.dataset.theme === draft.terminal_animation));
|
|
52
|
+
}
|
|
53
|
+
selectAnimation(current.terminal_animation);
|
|
54
|
+
}
|
|
55
|
+
function sync(data, { readVersion } = {}) {
|
|
56
|
+
if (!data.preferences) return;
|
|
57
|
+
terminalMode = data.terminal?.mode;
|
|
58
|
+
if (readVersion !== undefined && readVersion !== version || pending) { render();return; }
|
|
59
|
+
const next = data.preferences;
|
|
60
|
+
locks.terminal_animation_enabled = data.effective?.terminal_animation_enabled?.locked;
|
|
61
|
+
if (base) for (const key of Object.keys(draft)) {
|
|
62
|
+
if (next.values[key] === draft[key]) delete draft[key];
|
|
63
|
+
else if (next.values[key] !== base.values[key]) { conflict = true;error = "preferences_changed"; }
|
|
64
|
+
}
|
|
65
|
+
base = next;
|
|
66
|
+
if (!appearance) { try { appearanceBase = theme()?.read(); } catch { appearanceBase = theme()?.snapshot(); } }
|
|
67
|
+
try {
|
|
68
|
+
const backup = browserBackup(), retained = backup.entries.filter(entry => entry.id === base.backup?.id);
|
|
69
|
+
if (retained.length && backup.entries.length > 1) localStorage.setItem(backupKey, JSON.stringify({ version: 1, entries: retained }));
|
|
70
|
+
} catch { /* A damaged browser backup is reported if it is used, not erased. */ }
|
|
71
|
+
render();
|
|
72
|
+
}
|
|
73
|
+
function schedule() {
|
|
74
|
+
clearTimeout(timer);
|
|
75
|
+
if (base?.values.auto_save_settings && !error) timer = setTimeout(() => { void save(); }, 300);
|
|
76
|
+
}
|
|
77
|
+
function edit(key, value) {
|
|
78
|
+
if (!base) return;
|
|
79
|
+
if (value === base.values[key]) delete draft[key];else draft[key] = value;
|
|
80
|
+
if (!conflict) error = null;render();schedule();
|
|
81
|
+
}
|
|
82
|
+
async function commit(values, { local = appearance, action = "preferences", backup_id, revision = base?.revision } = {}) {
|
|
83
|
+
if (pending || !base || conflict) return;
|
|
84
|
+
clearTimeout(timer);
|
|
85
|
+
const captured = { ...values }, capturedLocal = local ? { ...local } : null;
|
|
86
|
+
resetting = action !== "preferences";
|
|
87
|
+
error = null;
|
|
88
|
+
const operation = (async () => {
|
|
89
|
+
try {
|
|
90
|
+
if (capturedLocal && appearanceBase && !same(theme().read(), appearanceBase)) throw Error("preferences_browser_changed");
|
|
91
|
+
const data = action !== "preferences" || Object.keys(captured).length
|
|
92
|
+
? await api({ action, revision, ...(action === "preferences" ? { values: captured } : { backup_id }) }) : null;
|
|
93
|
+
if (data) { base = data.preferences;version++; }
|
|
94
|
+
for (const [key, value] of Object.entries(captured)) if (draft[key] === value) delete draft[key];
|
|
95
|
+
if (capturedLocal) {
|
|
96
|
+
if (!theme().persist(capturedLocal)) throw Error("preferences_browser_failed");
|
|
97
|
+
appearanceBase = capturedLocal;
|
|
98
|
+
if (same(appearance, capturedLocal)) appearance = null;
|
|
99
|
+
}
|
|
100
|
+
if (data) applied(data);
|
|
101
|
+
if (Object.hasOwn(captured, "terminal_animation") || action !== "preferences") refreshAnimation();
|
|
102
|
+
return data || { preferences: base };
|
|
103
|
+
} catch (cause) {
|
|
104
|
+
error = cause.code === "ccdx_settings_changed" ? "preferences_changed"
|
|
105
|
+
: ["preferences_browser_failed", "preferences_browser_changed"].includes(cause.message) ? cause.message : "preferences_failed";
|
|
106
|
+
conflict = error === "preferences_changed" || error === "preferences_browser_changed";
|
|
107
|
+
}
|
|
108
|
+
})();
|
|
109
|
+
pending = operation;render();
|
|
110
|
+
try { return await operation; }
|
|
111
|
+
finally { pending = null;resetting = false;render();if (!error && dirty() && base.values.auto_save_settings) schedule(); }
|
|
112
|
+
}
|
|
113
|
+
function save() { if (dirty()) return commit(draft); }
|
|
114
|
+
async function discard() {
|
|
115
|
+
clearTimeout(timer);if (pending) return;
|
|
116
|
+
try {
|
|
117
|
+
const data = await api();draft = {};appearance = null;error = null;conflict = false;
|
|
118
|
+
appearanceBase = theme().read();theme().preview(appearanceBase);base = data.preferences;version++;applied(data);refreshAnimation();render();
|
|
119
|
+
} catch { error = "preferences_failed";render(); }
|
|
120
|
+
}
|
|
121
|
+
function open(kind) {
|
|
122
|
+
if (!base || pending) return;
|
|
123
|
+
dialog = kind;dialogRevision = base.revision;
|
|
124
|
+
label("preferences-dialog-title", `preferences_${kind}_question`);
|
|
125
|
+
label("preferences-dialog-intro", `preferences_${kind}_intro`, { count: dirty() });
|
|
126
|
+
label("preferences-dialog-confirm", `preferences_${kind}_confirm`);
|
|
127
|
+
el("preferences-dialog-scope").hidden = !["reset", "restore"].includes(kind);
|
|
128
|
+
if (kind === "reset") label("preferences-dialog-note", dirty() ? "preferences_draft_discard" : "preferences_backup_latest");
|
|
129
|
+
else { el("preferences-dialog-note").textContent = "";el("preferences-dialog-note").removeAttribute("data-i18n"); }
|
|
130
|
+
el("preferences-dialog").showModal();
|
|
131
|
+
}
|
|
132
|
+
async function confirmed() {
|
|
133
|
+
const kind = dialog;el("preferences-dialog").close();
|
|
134
|
+
if (kind === "enable") { draft.auto_save_settings = true;await save();return; }
|
|
135
|
+
if (kind === "nightly") { edit("nightly_updates", true);return; }
|
|
136
|
+
if (kind === "restore" || kind === "reset") {
|
|
137
|
+
let local, id = base.backup?.id;
|
|
138
|
+
try {
|
|
139
|
+
const backup = browserBackup();
|
|
140
|
+
if (kind === "reset") {
|
|
141
|
+
id = crypto.randomUUID();local = { theme: "dark", palette: "green" };
|
|
142
|
+
const previous = { id, values: theme().read() };
|
|
143
|
+
localStorage.setItem(backupKey, JSON.stringify({ version: 1, entries: [previous, ...backup.entries].slice(0, 2) }));
|
|
144
|
+
} else {
|
|
145
|
+
local = backup.entries.find(entry => entry.id === id)?.values;
|
|
146
|
+
if (!local) throw Error("preferences_browser_backup_missing");
|
|
147
|
+
}
|
|
148
|
+
} catch (cause) { error = cause.message === "preferences_browser_backup_missing" ? cause.message : "preferences_browser_backup_invalid";render();return; }
|
|
149
|
+
if (conflict) { error = "preferences_changed";render();return; }
|
|
150
|
+
const oldDraft = draft, oldAppearance = appearance;
|
|
151
|
+
draft = {};appearance = local;
|
|
152
|
+
const data = await commit({}, { action: `${kind === "reset" ? "reset" : "restore"}_preferences`, backup_id: id, local, revision: dialogRevision });
|
|
153
|
+
if (data) { theme().preview(local);appearance = null; }
|
|
154
|
+
else if (error === "preferences_browser_failed") appearance = local;
|
|
155
|
+
else { draft = oldDraft;appearance = oldAppearance; }
|
|
156
|
+
render();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
for (const [key, id] of Object.entries(fields)) el(id).addEventListener("change", () => {
|
|
160
|
+
const node = el(id), value = node.type === "checkbox" ? node.checked : node.value;
|
|
161
|
+
if (key === "nightly_updates" && value) { node.checked = false;open("nightly");return; }
|
|
162
|
+
edit(key, value);
|
|
163
|
+
});
|
|
164
|
+
function appearanceChanged() {
|
|
165
|
+
if (!base) return false;
|
|
166
|
+
appearance = same(theme().snapshot(), appearanceBase) ? null : theme().snapshot();
|
|
167
|
+
if (!conflict) error = null;render();schedule();return true;
|
|
168
|
+
}
|
|
169
|
+
el("preferences-auto").addEventListener("change", async () => {
|
|
170
|
+
if (el("preferences-auto").checked && dirty()) { el("preferences-auto").checked = false;open("enable");return; }
|
|
171
|
+
const value = el("preferences-auto").checked;
|
|
172
|
+
draft.auto_save_settings = value;
|
|
173
|
+
const result = await commit({ auto_save_settings: value }, { local: null });
|
|
174
|
+
if (!result) { delete draft.auto_save_settings;render(); }
|
|
175
|
+
});
|
|
176
|
+
el("preferences-save").addEventListener("click", () => { void save(); });
|
|
177
|
+
el("preferences-discard").addEventListener("click", () => { void discard(); });
|
|
178
|
+
el("preferences-retry").addEventListener("click", async () => {
|
|
179
|
+
if (retrying || pending) return;
|
|
180
|
+
const wasError = error;error = null;
|
|
181
|
+
retrying = true;render();
|
|
182
|
+
try { sync(await api());retrying = false;if (!conflict) await save(); } catch { error = wasError; }
|
|
183
|
+
finally { retrying = false;render(); }
|
|
184
|
+
});
|
|
185
|
+
el("preferences-reset").addEventListener("click", () => open("reset"));el("preferences-restore").addEventListener("click", () => open("restore"));
|
|
186
|
+
el("preferences-dialog-cancel").addEventListener("click", () => el("preferences-dialog").close());
|
|
187
|
+
el("preferences-dialog-confirm").addEventListener("click", () => { void confirmed(); });
|
|
188
|
+
globalThis.addEventListener("beforeunload", event => { if (dirty()) { event.preventDefault();event.returnValue = ""; } });
|
|
189
|
+
return { sync, render, appearanceChanged, selectAnimation: value => edit("terminal_animation", value),
|
|
190
|
+
externalAppearance() { if (!appearance) return false;conflict = true;error = "preferences_browser_changed";render();return true; },
|
|
191
|
+
get version() { return version; }, get busy() { return Boolean(pending || retrying); } };
|
|
192
|
+
}
|
|
193
|
+
globalThis.ccdxDashboardPreferences = { create };
|
|
194
|
+
})();
|
package/src/dashboard/status.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
function create({ time, element, phrase, localize, text, finite, number, mib, tableRow, emptyTable, document, navigator }) {
|
|
3
|
+
const visible = node => !node?.closest?.('[data-view]')?.hidden;
|
|
4
|
+
const writeText = text;
|
|
5
|
+
text = (id, ...args) => { if (visible(element(id))) writeText(id, ...args); };
|
|
3
6
|
let contextRequests = [];
|
|
4
7
|
let contextCompactions = {};
|
|
5
8
|
let failureSignature;
|
|
@@ -12,7 +15,7 @@
|
|
|
12
15
|
function renderProviders(data) {
|
|
13
16
|
const providers = data.providers || [];
|
|
14
17
|
const states = { saved: "saved_locally", authorized: "authorized", disabled: "disabled", unavailable: "unavailable_ca184",
|
|
15
|
-
unknown: "unknown", unconfigured: "not_configured", ready: "ready", checking: "checking", unsupported: "unsupported",
|
|
18
|
+
unknown: "unknown", paused: "access_paused", unconfigured: "not_configured", ready: "ready", checking: "checking", unsupported: "unsupported",
|
|
16
19
|
configured: "configured", default_unavailable: "cap_default_unavailable", preserved: "existing_settings_kept", partially_preserved: "existing_settings_kept",
|
|
17
20
|
restored: "settings_restored", not_installed: "not_installed", configuration_unavailable: "setup_unavailable", not_configured: "unknown", standby: "standby" };
|
|
18
21
|
const auth = element("provider-auth"), clients = element("provider-clients"), requests = element("provider-requests"), claudeClients = element("claude-clients");
|
|
@@ -51,7 +54,7 @@
|
|
|
51
54
|
}
|
|
52
55
|
for (const entries of applications.values()) {
|
|
53
56
|
const selected = entries.find(entry => entry.client.selected === true) || (entries.length === 1 ? entries[0] : null);
|
|
54
|
-
const client = selected?.client || { name: entries[0].client.name, state: "unknown" };
|
|
57
|
+
const client = selected?.client || { name: entries[0].client.name, state: entries.every(entry => entry.client.state === "paused") ? "paused" : "unknown" };
|
|
55
58
|
const row = tableRow([client.name, selected?.provider.name || "—", states[client.state] || "unknown",
|
|
56
59
|
client.gateway || "—", time(client.last_request_at)], { labels: [2, 3] });
|
|
57
60
|
if (client.reason) localize(row.children[2], "state_reason", { state: phrase(states[client.state] || "unknown"), reason: client.reason });
|
|
@@ -87,6 +90,7 @@
|
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
function renderFailures(recent, recentRequests = []) {
|
|
93
|
+
if (!visible(element("failures"))) return;
|
|
90
94
|
const signature = JSON.stringify([element("failure-kind")?.value, recent, recentRequests]);
|
|
91
95
|
if (signature === failureSignature) return;
|
|
92
96
|
failureSignature = signature;
|
|
@@ -200,6 +204,14 @@
|
|
|
200
204
|
}
|
|
201
205
|
|
|
202
206
|
function render(data) {
|
|
207
|
+
if (data.scope === "summary") {
|
|
208
|
+
globalThis.ccdxDashboardActivity?.update(data.model_activity);
|
|
209
|
+
text("version", `v${data.version || "?"}`);
|
|
210
|
+
text("uptime", "pid_pid_uptime_duration", { pid: number(data.pid), duration: duration(data.uptime_ms) });
|
|
211
|
+
renderRuntimeUsage(data);
|
|
212
|
+
text("updated", "snapshot_time", { time: time(Date.now()) });
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
203
215
|
for (const source of data.providers?.connections?.providers || []) sourceNames.set(source.id, source.name);
|
|
204
216
|
globalThis.ccdxConnections?.updateMemory?.(data.providers?.connections);
|
|
205
217
|
globalThis.ccdxDashboardActivity?.update(data.model_activity);
|
|
@@ -237,7 +249,7 @@
|
|
|
237
249
|
const used = Number(history.bytes || 0);
|
|
238
250
|
text("history", `${mib(used)} / ${mib(limit)}`);
|
|
239
251
|
text("history-detail", "entries_entries_trees_trees_misses_misses_evicted_evicted", { entries: number(history.entries), trees: number(history.tree_count), misses: number(history.lookup_misses), evicted: number(history.evicted_lookup_misses) });
|
|
240
|
-
element("history-meter").value = limit > 0 ? Math.min(100, Math.max(0, used / limit * 100)) : 0;
|
|
252
|
+
if (visible(element("history-meter"))) element("history-meter").value = limit > 0 ? Math.min(100, Math.max(0, used / limit * 100)) : 0;
|
|
241
253
|
|
|
242
254
|
const image = data.image_generation;
|
|
243
255
|
text("image", image ? "count_succeeded" : "not_initialized", { count: number(image?.succeeded) });
|
|
@@ -248,7 +260,7 @@
|
|
|
248
260
|
const claude = data.providers?.claude || data.providers?.m365?.claude, claudeMetrics = claude?.requests?.performance;
|
|
249
261
|
percentiles("claude-ttft-percentiles", claudeMetrics?.by_route?.messages?.ttft_ms);
|
|
250
262
|
const sourceBody = element("source-requests-body");
|
|
251
|
-
if (sourceBody) {
|
|
263
|
+
if (sourceBody && visible(sourceBody)) {
|
|
252
264
|
sourceBody.replaceChildren();
|
|
253
265
|
const routes = { ...data.stream_performance?.by_route, ...claudeMetrics?.by_route };
|
|
254
266
|
for (const [protocol, route] of Object.entries(routes)) for (const [source, stats] of Object.entries(route.by_provider || {})) {
|
|
@@ -269,7 +281,7 @@
|
|
|
269
281
|
const kind = element("failure-kind")?.value || "issues";
|
|
270
282
|
renderFailures(issueGroups[kind] || [], kind === "issues" ? recentRequests : []);
|
|
271
283
|
renderContext({ ...data.stream_performance, recent_requests: recentRequests });
|
|
272
|
-
if (element("claude-route")) {
|
|
284
|
+
if (element("claude-route") && visible(element("claude-route"))) {
|
|
273
285
|
element("claude-route").textContent = claude?.base_url || "—";
|
|
274
286
|
const clientState = value => ({ configured: "configured", restored: "settings_restored", preserved: "existing_settings_kept", partially_preserved: "existing_settings_kept",
|
|
275
287
|
not_installed: "not_installed", configuration_unavailable: "setup_unavailable" })[value] || "unknown";
|
|
@@ -280,27 +292,32 @@
|
|
|
280
292
|
text(id, metric?.samples > 0 ? `${Number(metric.avg).toFixed(1)} ${unit} / ${metric.samples}` : "—");
|
|
281
293
|
}
|
|
282
294
|
}
|
|
283
|
-
|
|
295
|
+
renderRuntimeUsage(data);
|
|
296
|
+
if (element("prediction-preference") && visible(element("prediction-preference"))) {
|
|
297
|
+
const prediction = data.client_integrations?.prediction;
|
|
298
|
+
text("prediction-preference", prediction ? prediction.configured ? "configured" : "not_configured" : "unknown");
|
|
299
|
+
text("prediction-bridge", ({ running: "running_f4cca", recovering: "recovering", stopped: "stopped", unavailable: "unavailable_ca184" })[prediction?.bridge] || "unknown");
|
|
300
|
+
text("prediction-route", prediction?.client_route === "observed" ? "observed" : "unknown");
|
|
301
|
+
text("prediction-candidate", "unknown");
|
|
302
|
+
const note = element("prediction-note");
|
|
303
|
+
if (note) note.textContent = prediction?.reason || "";
|
|
304
|
+
}
|
|
305
|
+
text("updated", "snapshot_time", { time: time(Date.now()) });
|
|
306
|
+
}
|
|
307
|
+
function renderRuntimeUsage(data) {
|
|
308
|
+
if (element("runtime-usage") && visible(element("runtime-usage"))) {
|
|
284
309
|
const usage = data.runtime_usage;
|
|
285
310
|
text("runtime-usage", usage ? "records_usage_records_input_input_cache_read_cached_output_outpu" : "—",
|
|
286
311
|
usage ? { records: number(usage.records), input: number(usage.input_tokens), cached: number(usage.cached_input_tokens), output: number(usage.output_tokens), partial: usage.partial_records ? " ~" : "" } : {});
|
|
287
312
|
const rate = usage?.cache_hit_rate;
|
|
288
313
|
text("runtime-cache-hit", Number.isFinite(rate) && rate >= 0 && rate <= 1 ? `${usage.cache_hit_rate_partial ? "~" : ""}${(rate * 100).toFixed(1)}%` : "—");
|
|
314
|
+
}
|
|
315
|
+
if (element("process-state") && visible(element("process-state"))) {
|
|
289
316
|
element("process-state").textContent = `PID ${data.pid || "—"} / ${globalThis.location?.origin || ""}`;
|
|
290
317
|
text("process-memory", "rss_rss_heap_heap", { rss: mib(data.process?.rss_bytes), heap: mib(data.process?.heap_used_bytes) });
|
|
291
318
|
text("process-queues", "codex_body_admission_active_active_queued_queued_queue_limit_lim", {
|
|
292
319
|
active: number(data.admission?.activeRequests), queued: number(data.admission?.queued), limit: number(data.admission?.maxQueued) });
|
|
293
320
|
}
|
|
294
|
-
if (element("prediction-preference")) {
|
|
295
|
-
const prediction = data.client_integrations?.prediction;
|
|
296
|
-
text("prediction-preference", prediction ? prediction.configured ? "configured" : "not_configured" : "unknown");
|
|
297
|
-
text("prediction-bridge", ({ running: "running_f4cca", recovering: "recovering", stopped: "stopped", unavailable: "unavailable_ca184" })[prediction?.bridge] || "unknown");
|
|
298
|
-
text("prediction-route", prediction?.client_route === "observed" ? "observed" : "unknown");
|
|
299
|
-
text("prediction-candidate", "unknown");
|
|
300
|
-
const note = element("prediction-note");
|
|
301
|
-
if (note) note.textContent = prediction?.reason || "";
|
|
302
|
-
}
|
|
303
|
-
text("updated", "snapshot_time", { time: time(Date.now()) });
|
|
304
321
|
}
|
|
305
322
|
|
|
306
323
|
function renderContext(performance) {
|
|
@@ -309,7 +326,7 @@
|
|
|
309
326
|
contextCompactions = performance?.by_route?.responses_compact?.terminal_outcomes?.totals || {};
|
|
310
327
|
}
|
|
311
328
|
const body = element("context-body");
|
|
312
|
-
if (!body) return;
|
|
329
|
+
if (!body || !visible(body)) return;
|
|
313
330
|
text("context-note", "20_latest_finished_requests_compactions_completed_completed_inco", {
|
|
314
331
|
completed: number(contextCompactions.completed), incomplete: number(contextCompactions.incomplete), failed: number(contextCompactions.failed),
|
|
315
332
|
});
|
package/src/dashboard/theme.js
CHANGED
|
@@ -24,10 +24,11 @@
|
|
|
24
24
|
document.getElementById("favicon").href = `data:image/svg+xml,${encodeURIComponent(svg)}`;
|
|
25
25
|
};
|
|
26
26
|
applyTheme();
|
|
27
|
-
function persist() {
|
|
28
|
-
try { localStorage.setItem(key, theme);localStorage.setItem(paletteKey, palette);saved = true; }
|
|
27
|
+
function persist(values = { theme, palette }) {
|
|
28
|
+
try { localStorage.setItem(key, values.theme);localStorage.setItem(paletteKey, values.palette);saved = true; }
|
|
29
29
|
catch { saved = false; }
|
|
30
30
|
sync();
|
|
31
|
+
return saved;
|
|
31
32
|
}
|
|
32
33
|
document.addEventListener("DOMContentLoaded", () => {
|
|
33
34
|
const button = document.getElementById("theme-toggle");
|
|
@@ -47,10 +48,16 @@
|
|
|
47
48
|
document.getElementById("web-color-theme")?.addEventListener("change", event => {
|
|
48
49
|
if (!valid(event.target.value)) return;
|
|
49
50
|
palette = event.target.value;applyTheme();
|
|
50
|
-
persist();
|
|
51
|
+
if (!globalThis.ccdxSettingsPreferences?.appearanceChanged()) persist();
|
|
51
52
|
});
|
|
53
|
+
globalThis.ccdxDashboardTheme = {
|
|
54
|
+
snapshot: () => ({ theme, palette }), persist, sync,
|
|
55
|
+
read: () => ({ theme: localStorage.getItem(key) === "light" ? "light" : "dark", palette: valid(localStorage.getItem(paletteKey)) ? localStorage.getItem(paletteKey) : "green" }),
|
|
56
|
+
preview(values) { if (["light", "dark"].includes(values.theme)) theme = values.theme;if (valid(values.palette)) palette = values.palette;applyTheme();updateLabel();sync(); },
|
|
57
|
+
};
|
|
52
58
|
globalThis.addEventListener?.("storage", event => {
|
|
53
59
|
if (event.key !== paletteKey && event.key !== key) return;
|
|
60
|
+
if (globalThis.ccdxSettingsPreferences?.externalAppearance()) return;
|
|
54
61
|
if (event.key === paletteKey) palette = valid(event.newValue) ? event.newValue : "green";
|
|
55
62
|
else theme = event.newValue === "light" ? "light" : "dark";
|
|
56
63
|
applyTheme();updateLabel();sync();
|
package/src/dashboard/ui.css
CHANGED
|
@@ -433,6 +433,8 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
|
433
433
|
|
|
434
434
|
.flow-network { position:relative;display:grid;grid-template-columns:minmax(130px,1fr) 70px minmax(170px,1fr);column-gap:clamp(36px,6vw,92px);align-items:stretch;min-height:236px;margin:26px 0 18px; }
|
|
435
435
|
.flow-wires { position:absolute;inset:0;width:100%;height:100%;pointer-events:none;overflow:visible; }
|
|
436
|
+
.flow-activity { will-change:transform; }
|
|
437
|
+
.flow-wires .flow-split { visibility:hidden;animation:none; }
|
|
436
438
|
.flow-column,.flow-hub-column { position:relative;min-width:0; }
|
|
437
439
|
.flow-column { display:flex;flex-direction:column; }
|
|
438
440
|
.flow-column-title { height:18px;line-height:18px;margin:0 0 18px;color:var(--muted);font-size:11px;text-align:center; }
|
|
@@ -551,3 +553,22 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
|
551
553
|
.memory-model-value .hint { margin:0; }
|
|
552
554
|
.memory-model-value { min-width:0;max-width:100%; }
|
|
553
555
|
.memory-model-value strong { min-width:0;overflow-wrap:anywhere; }
|
|
556
|
+
|
|
557
|
+
/* Settings-page preferences keep their own draft, save and recovery controls. */
|
|
558
|
+
.preferences-status { color:var(--muted); font-size:11px; }
|
|
559
|
+
.preferences-row { display:flex; align-items:center; justify-content:space-between; gap:20px; padding:20px 0; font-size:13px; }
|
|
560
|
+
.preferences-row:last-of-type { padding-bottom:0; }
|
|
561
|
+
.preferences-row .hint { margin-top:5px; }
|
|
562
|
+
.preferences-row input[role="switch"] { flex:none; }
|
|
563
|
+
.preferences-separator { border-top:1px solid var(--border); margin-top:14px; }
|
|
564
|
+
#preferences-backup-time { margin-bottom:0; }
|
|
565
|
+
#preferences-error { margin:0; color:var(--failed); }
|
|
566
|
+
#preferences-save, #preferences-dialog-confirm { background:var(--accent); color:var(--page); border-color:var(--accent); }
|
|
567
|
+
.preferences-dialog { width:480px; max-width:calc(100% - 32px); padding:25px; border:1px solid var(--border); border-radius:2px; background:var(--surface); color:var(--text); font:inherit; }
|
|
568
|
+
.preferences-dialog::backdrop { background:#0007; }
|
|
569
|
+
.preferences-dialog h2 { font-size:19px; margin:0 0 18px; color:var(--strong); }
|
|
570
|
+
.preferences-dialog p, .preferences-dialog dl { font-size:12px; line-height:1.8; }
|
|
571
|
+
.preferences-dialog dl > div { display:grid; grid-template-columns:80px minmax(0,1fr); gap:12px; margin-top:12px; }
|
|
572
|
+
.preferences-dialog dt { color:var(--muted); }.preferences-dialog dd { margin:0; }
|
|
573
|
+
.preferences-dialog .section-actions { justify-content:flex-end; margin-top:24px; }
|
|
574
|
+
@media(max-width:640px) { .preferences-row { gap:14px; flex-wrap:wrap; }.preferences-row > div:first-child { flex:1; min-width:150px; }.preferences-dialog { padding:20px; }.preferences-dialog dl > div { grid-template-columns:1fr; gap:3px; } }
|
package/src/dashboard/ui.js
CHANGED
|
@@ -23,7 +23,9 @@ const usageView = globalThis.ccdxViewBoundary.create("usage-analytics", () => gl
|
|
|
23
23
|
const { applyUsage, renderUsageState, renderAnalytics, renderUsageTable, selectUsageDay } = usageView;
|
|
24
24
|
const loadAuth = () => dashboardRefresh.refresh("auth", { force: true });
|
|
25
25
|
|
|
26
|
-
const
|
|
26
|
+
const statusResourceKey = () => ["codex", "claude", "models", "usage", "requests", "checks"].includes((globalThis.location?.hash || "").slice(1)) ? "status" : "status-summary";
|
|
27
|
+
const refreshStatus = () => dashboardRefresh.refresh(statusResourceKey(), { force: true });
|
|
28
|
+
const refresh = refreshStatus;
|
|
27
29
|
|
|
28
30
|
function animateRefresh() {
|
|
29
31
|
const icon = element("status-icon");
|
|
@@ -39,7 +41,7 @@ element("refresh").addEventListener("click", () => {
|
|
|
39
41
|
|
|
40
42
|
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
41
43
|
const animationView = globalThis.ccdxViewBoundary.create("animation-settings", () => globalThis.ccdxDashboardAnimation.create({ element, phrase, localize, text, reducedMotion,
|
|
42
|
-
getRefresh: () => dashboardRefresh, document }), ["apply", "load", "save", "sync", "stop"]);
|
|
44
|
+
getRefresh: () => dashboardRefresh, document }), ["apply", "load", "save", "sync", "stop", "select"]);
|
|
43
45
|
const { apply: applyAnimation, load: loadAnimation, save: saveAnimation, sync: syncAnimationPreview, stop: stopAnimationPreview } = animationView;
|
|
44
46
|
reducedMotion.addEventListener("change", () => { if (reducedMotion.matches) usageView.stopMotion(); });
|
|
45
47
|
document.addEventListener("visibilitychange", () => { if (document.visibilityState !== "visible") usageView.stopMotion(); });
|
|
@@ -234,6 +236,16 @@ for (const [key, ids] of [["auth", ["account-authorization", "client-features",
|
|
|
234
236
|
}
|
|
235
237
|
|
|
236
238
|
const updateView = globalThis.ccdxDashboardUpdates.create(viewHelpers);
|
|
239
|
+
function statusState(state) {
|
|
240
|
+
if (state.error || !state.value) globalThis.ccdxDashboardActivity?.unavailable();
|
|
241
|
+
if ((state.error || !state.value) && statusResourceKey() === "status") globalThis.ccdxDashboardFlow?.unavailable();
|
|
242
|
+
text("connection", state.pending && !state.value ? "reading" : state.error ? "unavailable_eb0be" : "service_reachable");
|
|
243
|
+
element("connection").className = `badge ${state.pending ? "neutral" : state.error ? "bad" : "good"}`;
|
|
244
|
+
globalThis.ccdxIcons?.set(element("connection"), state.pending && !state.value ? "reading" : state.error ? "unavailable_eb0be" : "service_reachable",
|
|
245
|
+
state.pending && !state.value ? "unknown" : state.error ? "unavailable" : "running");
|
|
246
|
+
if (state.error) refreshTime(element("updated"), state);
|
|
247
|
+
for (const node of timestamps.get("status")) refreshTime(node, state);
|
|
248
|
+
}
|
|
237
249
|
const dashboardRefresh = globalThis.ccdxRefresh.createController({
|
|
238
250
|
visible: () => document.visibilityState === "visible",
|
|
239
251
|
onState: ({ pendingKeys }) => {
|
|
@@ -250,23 +262,24 @@ const dashboardRefresh = globalThis.ccdxRefresh.createController({
|
|
|
250
262
|
state: updateView.state,
|
|
251
263
|
},
|
|
252
264
|
status: {
|
|
253
|
-
visible: () =>
|
|
265
|
+
visible: () => statusResourceKey() === "status",
|
|
254
266
|
load: async ({ signal }) => {
|
|
255
267
|
const data = await readDashboard("/_ccdx/status", { signal, timeout: 5000 });
|
|
256
268
|
if (data.ok !== true || data.name !== "codex-copilot-dx") throw new Error("Unexpected status response");
|
|
257
269
|
return data;
|
|
258
270
|
},
|
|
259
|
-
apply: render,
|
|
260
|
-
state: state => {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
for (const node of timestamps.get("status")) refreshTime(node, state);
|
|
271
|
+
apply: data => { if (statusResourceKey() === "status") render(data); },
|
|
272
|
+
state: state => { if (statusResourceKey() === "status") statusState(state); },
|
|
273
|
+
},
|
|
274
|
+
"status-summary": {
|
|
275
|
+
visible: () => statusResourceKey() === "status-summary",
|
|
276
|
+
load: async ({ signal }) => {
|
|
277
|
+
const data = await readDashboard("/_ccdx/status?scope=summary", { signal, timeout: 5000 });
|
|
278
|
+
if (data.ok !== true || data.name !== "codex-copilot-dx") throw new Error("Unexpected status response");
|
|
279
|
+
return data;
|
|
269
280
|
},
|
|
281
|
+
apply: data => { if (statusResourceKey() === "status-summary") render(data); },
|
|
282
|
+
state: state => { if (statusResourceKey() === "status-summary") statusState(state); },
|
|
270
283
|
},
|
|
271
284
|
auth: {
|
|
272
285
|
visible: () => true,
|
package/src/dashboard-api.mjs
CHANGED
|
@@ -221,7 +221,7 @@ export async function handleDashboardApi(req, res, pathname, {
|
|
|
221
221
|
if (!res.destroyed && !res.writableEnded) sendJson(res, 200, data);
|
|
222
222
|
} catch (error) {
|
|
223
223
|
sendJson(res, error.statusCode || (error.code?.startsWith("ccdx_cache_") ? 409 : 400), { error: safeText(error.message, 300),
|
|
224
|
-
...(/^m365_[a-z_]
|
|
224
|
+
...(/^(?:m365_[a-z_]+|ccdx_settings_[a-z_]+)$/.test(error.code || "") ? { code: error.code } : {}) });
|
|
225
225
|
} finally { abort.cleanup(); }
|
|
226
226
|
return;
|
|
227
227
|
}
|
package/src/dashboard.mjs
CHANGED
|
@@ -12,6 +12,7 @@ const ASSETS = new Map([
|
|
|
12
12
|
["/ui.js", ["./dashboard/ui.js", "text/javascript; charset=utf-8"]],
|
|
13
13
|
["/console.js", ["./dashboard/console.js", "text/javascript; charset=utf-8"]],
|
|
14
14
|
["/updates.js", ["./dashboard/updates.js", "text/javascript; charset=utf-8"]],
|
|
15
|
+
["/preferences.js", ["./dashboard/preferences.js", "text/javascript; charset=utf-8"]],
|
|
15
16
|
["/time.js", ["./dashboard/time.js", "text/javascript; charset=utf-8"]],
|
|
16
17
|
["/view-boundary.js", ["./dashboard/view-boundary.js", "text/javascript; charset=utf-8"]],
|
|
17
18
|
["/status.js", ["./dashboard/status.js", "text/javascript; charset=utf-8"]],
|
package/src/http-transport.mjs
CHANGED
|
@@ -322,7 +322,7 @@ export function isAbortLikeError(err) {
|
|
|
322
322
|
|
|
323
323
|
export function abortErrorStatusCode(reason) {
|
|
324
324
|
if (reason === "request_body_timeout") return 408;
|
|
325
|
-
if (["responses_prepare_timeout", "upstream_timeout", "stream_handshake_timeout", "stream_idle_timeout"].includes(reason)) return 504;
|
|
325
|
+
if (["responses_prepare_timeout", "messages_prepare_timeout", "upstream_timeout", "stream_handshake_timeout", "stream_idle_timeout"].includes(reason)) return 504;
|
|
326
326
|
if (reason === "client_aborted" || reason === "client_closed") return 499;
|
|
327
327
|
return 502;
|
|
328
328
|
}
|