clay-server 5.1.0-beta.1 → 5.1.0-beta.3
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/LICENSES/README.md +4 -0
- package/LICENSES/dicebear-avatars.md +16 -0
- package/bin/cli.js +9 -91
- package/lib/builtin-mates.js +7 -7
- package/lib/daemon-project-access.js +7 -1
- package/lib/daemon-settings.js +11 -0
- package/lib/daemon.js +10 -37
- package/lib/dicebear-avatar.js +62 -0
- package/lib/knowledge-db-service.js +175 -0
- package/lib/knowledge-db-validation.js +0 -0
- package/lib/knowledge-document-index.js +49 -0
- package/lib/knowledge-draft-store.js +56 -0
- package/lib/knowledge-file-store.js +199 -0
- package/lib/knowledge-markdown.js +128 -0
- package/lib/linear-store.js +35 -8
- package/lib/mate-identity-file.js +39 -0
- package/lib/mate-knowledge-mcp-server.js +29 -6
- package/lib/mate-knowledge-service.js +23 -2
- package/lib/mate-knowledge-sync.js +37 -22
- package/lib/mate-ready-creation.js +2 -1
- package/lib/mate-workspace-color.js +4 -0
- package/lib/mates-identity.js +4 -4
- package/lib/mates-prompts.js +4 -3
- package/lib/mates.js +30 -11
- package/lib/os-users.js +5 -16
- package/lib/project-connection.js +36 -9
- package/lib/project-debate-proposal.js +6 -0
- package/lib/project-debate-workspace.js +43 -0
- package/lib/project-debate.js +4 -2
- package/lib/project-filesystem.js +21 -39
- package/lib/project-knowledge.js +315 -136
- package/lib/project-mate-creation-proposal.js +1 -0
- package/lib/project-mate-interaction.js +7 -6
- package/lib/project-server-settings.js +31 -0
- package/lib/project-sessions.js +92 -182
- package/lib/project-user-knowledge.js +60 -0
- package/lib/project.js +62 -21
- package/lib/public/app.js +79 -71
- package/lib/public/clay-studio-wordmark-bold.svg +20 -0
- package/lib/public/css/clay-workspace.css +105 -0
- package/lib/public/css/debates-workbench.css +47 -0
- package/lib/public/css/home-debate-live.css +26 -0
- package/lib/public/css/home-hub.css +3 -1
- package/lib/public/css/home-mate-model-picker.css +15 -131
- package/lib/public/css/home-mate-settings.css +168 -16
- package/lib/public/css/icon-strip.css +249 -32
- package/lib/public/css/input.css +3 -1
- package/lib/public/css/mate-conversation.css +176 -0
- package/lib/public/css/mate-knowledge-workbench.css +118 -0
- package/lib/public/css/mate-workspace-color.css +16 -0
- package/lib/public/css/mates.css +28 -28
- package/lib/public/css/menus.css +3 -0
- package/lib/public/css/messages.css +1 -114
- package/lib/public/css/mobile-nav.css +16 -16
- package/lib/public/css/overlays.css +15 -0
- package/lib/public/css/project-logs.css +7 -0
- package/lib/public/css/project-mate-creation.css +105 -0
- package/lib/public/css/project-settings-modal.css +56 -0
- package/lib/public/css/right-workbench.css +3 -3
- package/lib/public/css/server-settings-system.css +125 -0
- package/lib/public/css/session-folders.css +80 -21
- package/lib/public/css/session-github.css +25 -16
- package/lib/public/css/settings-ui.css +247 -22
- package/lib/public/css/shared-browser.css +7 -3
- package/lib/public/css/sidebar.css +183 -107
- package/lib/public/css/title-bar.css +156 -1
- package/lib/public/css/worker-delegation.css +47 -0
- package/lib/public/css/worker-proposal.css +72 -150
- package/lib/public/css/you.css +74 -0
- package/lib/public/index.html +206 -548
- package/lib/public/modules/account-island.js +232 -0
- package/lib/public/modules/admin-settings-email.js +197 -0
- package/lib/public/modules/admin-settings-invitations.js +183 -0
- package/lib/public/modules/admin-settings-projects.js +198 -0
- package/lib/public/modules/admin-settings-ui.js +100 -0
- package/lib/public/modules/admin-settings-users.js +331 -0
- package/lib/public/modules/admin.js +19 -949
- package/lib/public/modules/app-cursors.js +19 -43
- package/lib/public/modules/app-debate-ui.js +4 -3
- package/lib/public/modules/app-dm.js +0 -2
- package/lib/public/modules/app-header.js +106 -0
- package/lib/public/modules/app-message-router.js +12 -3
- package/lib/public/modules/app-messages.js +47 -61
- package/lib/public/modules/app-notifications.js +4 -7
- package/lib/public/modules/app-projects.js +5 -38
- package/lib/public/modules/app-rate-limit.js +70 -12
- package/lib/public/modules/app-rendering.js +12 -13
- package/lib/public/modules/avatar.js +30 -9
- package/lib/public/modules/chat-render-runtime.js +16 -4
- package/lib/public/modules/command-palette.js +2 -15
- package/lib/public/modules/context-sources.js +27 -18
- package/lib/public/modules/cursor-sharing-preference.js +3 -3
- package/lib/public/modules/debate-controls.js +299 -0
- package/lib/public/modules/debate.js +2 -0
- package/lib/public/modules/debates-workbench.js +339 -0
- package/lib/public/modules/default-ai.js +88 -65
- package/lib/public/modules/header-tui-font.js +10 -20
- package/lib/public/modules/home-debate-controls.js +18 -289
- package/lib/public/modules/home-mate-avatar-editor.js +228 -0
- package/lib/public/modules/home-mate-color-picker.js +66 -0
- package/lib/public/modules/home-mate-creation.js +1 -1
- package/lib/public/modules/home-mate-instructions.js +90 -0
- package/lib/public/modules/home-mate-model-picker.js +80 -271
- package/lib/public/modules/home-mate-profile-editor.js +72 -0
- package/lib/public/modules/home-mate-settings.js +118 -125
- package/lib/public/modules/home-shell.js +3 -0
- package/lib/public/modules/home-surface-boot.js +1 -9
- package/lib/public/modules/icon-strip-tooltip.js +95 -0
- package/lib/public/modules/knowledge-db-edit-state.js +35 -0
- package/lib/public/modules/knowledge-db-workbench.js +234 -0
- package/lib/public/modules/knowledge-history-state.js +55 -0
- package/lib/public/modules/knowledge-markdown-editor.js +57 -0
- package/lib/public/modules/knowledge-preview-links.js +70 -0
- package/lib/public/modules/knowledge-workbench-shell.js +21 -0
- package/lib/public/modules/linear-settings.js +3 -2
- package/lib/public/modules/markdown.js +5 -6
- package/lib/public/modules/mate-knowledge-workbench-state.js +174 -0
- package/lib/public/modules/mate-knowledge-workbench.js +500 -0
- package/lib/public/modules/mate-knowledge.js +11 -3
- package/lib/public/modules/mate-management.js +54 -10
- package/lib/public/modules/mate-sidebar.js +11 -1
- package/lib/public/modules/mate-workspace-color.js +33 -0
- package/lib/public/modules/mention.js +5 -13
- package/lib/public/modules/notification-settings.js +81 -0
- package/lib/public/modules/notifications.js +44 -28
- package/lib/public/modules/personal-settings-dialog.js +51 -0
- package/lib/public/modules/profile.js +66 -24
- package/lib/public/modules/project-chat-identity.js +79 -0
- package/lib/public/modules/project-debate-planning-workspace.js +250 -0
- package/lib/public/modules/project-debate-workspace.js +185 -0
- package/lib/public/modules/project-header-identity.js +127 -0
- package/lib/public/modules/project-logs-render.js +9 -4
- package/lib/public/modules/project-mate-creation-workspace.js +414 -0
- package/lib/public/modules/project-mate-navigation.js +238 -0
- package/lib/public/modules/project-session-navigation.js +29 -0
- package/lib/public/modules/project-settings-environment.js +106 -0
- package/lib/public/modules/project-settings.js +72 -628
- package/lib/public/modules/project-switcher.js +6 -8
- package/lib/public/modules/projects-hub-view.js +5 -6
- package/lib/public/modules/projects-hub.js +2 -6
- package/lib/public/modules/qrcode.js +27 -8
- package/lib/public/modules/search-clay-chat.js +8 -11
- package/lib/public/modules/server-settings-controls.js +316 -0
- package/lib/public/modules/server-settings-environment.js +194 -0
- package/lib/public/modules/server-settings-navigation.js +39 -0
- package/lib/public/modules/server-settings-state.js +54 -0
- package/lib/public/modules/server-settings.js +116 -788
- package/lib/public/modules/server-storage-settings.js +84 -0
- package/lib/public/modules/session-activity-tooltip.js +12 -0
- package/lib/public/modules/session-create-form.js +86 -14
- package/lib/public/modules/session-create.js +50 -7
- package/lib/public/modules/session-github.js +2 -1
- package/lib/public/modules/session-list-visibility.js +41 -0
- package/lib/public/modules/session-presence-ui.js +3 -0
- package/lib/public/modules/session-title-marquee.js +51 -0
- package/lib/public/modules/settings-env-values.js +34 -0
- package/lib/public/modules/settings-select.js +121 -0
- package/lib/public/modules/shared-browser.js +22 -12
- package/lib/public/modules/sidebar-mates.js +3 -50
- package/lib/public/modules/sidebar-mobile.js +63 -60
- package/lib/public/modules/sidebar-projects.js +84 -97
- package/lib/public/modules/sidebar-session-folders-ui.js +2 -2
- package/lib/public/modules/sidebar-session-hierarchy.js +149 -70
- package/lib/public/modules/sidebar-sessions.js +49 -50
- package/lib/public/modules/sidebar.js +11 -13
- package/lib/public/modules/stt-picker.js +14 -5
- package/lib/public/modules/terminal-prefs.js +22 -0
- package/lib/public/modules/theme.js +88 -52
- package/lib/public/modules/thinking-lifecycle.js +7 -6
- package/lib/public/modules/tool-palette-order.js +4 -3
- package/lib/public/modules/tool-palette.js +13 -3
- package/lib/public/modules/tools.js +22 -22
- package/lib/public/modules/user-settings-account.js +318 -0
- package/lib/public/modules/user-settings-appearance.js +55 -0
- package/lib/public/modules/user-settings-editors.js +24 -0
- package/lib/public/modules/user-settings-integrations.js +104 -0
- package/lib/public/modules/user-settings-layout.js +80 -0
- package/lib/public/modules/user-settings-preferences.js +48 -0
- package/lib/public/modules/user-settings-profile.js +53 -0
- package/lib/public/modules/user-settings-themes.js +38 -0
- package/lib/public/modules/user-settings-voice.js +75 -0
- package/lib/public/modules/user-settings.js +53 -480
- package/lib/public/modules/worker-proposal.js +42 -8
- package/lib/public/modules/worker-runtime-picker.js +115 -0
- package/lib/public/modules/you-activity.js +121 -0
- package/lib/public/modules/you.js +251 -0
- package/lib/public/style.css +20 -8
- package/lib/public/vendor/codemirror/LICENSE +21 -0
- package/lib/public/vendor/codemirror/codemirror.css +344 -0
- package/lib/public/vendor/codemirror/codemirror.js +9884 -0
- package/lib/public/vendor/codemirror/continuelist.js +101 -0
- package/lib/public/vendor/codemirror/markdown.js +886 -0
- package/lib/public/vendor/codemirror/show-hint.css +37 -0
- package/lib/public/vendor/codemirror/show-hint.js +523 -0
- package/lib/sdk-bridge.js +15 -3
- package/lib/sdk-message-processor.js +16 -4
- package/lib/sdk-quota-snapshot.js +37 -0
- package/lib/server-admin.js +11 -0
- package/lib/server-appearance-settings.js +71 -0
- package/lib/server-home-chat-events.js +1 -1
- package/lib/server-home-chat.js +25 -3
- package/lib/server-home-debate-planning.js +4 -1
- package/lib/server-home-debates.js +2 -0
- package/lib/server-home-mate-creation.js +4 -1
- package/lib/server-linear.js +14 -8
- package/lib/server-mate-instructions.js +44 -0
- package/lib/server-mates.js +14 -4
- package/lib/server-notification-settings.js +67 -0
- package/lib/server-palette.js +1 -1
- package/lib/server-settings.js +69 -1
- package/lib/server-storage.js +57 -0
- package/lib/server-user-knowledge.js +119 -0
- package/lib/server.js +31 -3
- package/lib/session-visibility.js +7 -2
- package/lib/sessions.js +35 -10
- package/lib/startup-projects.js +40 -0
- package/lib/storage-native-walk.js +85 -0
- package/lib/storage-usage.js +144 -0
- package/lib/user-knowledge-service.js +167 -0
- package/lib/users-permissions.js +7 -0
- package/lib/users-preferences.js +0 -74
- package/lib/users-project-mate-filter-preferences.js +39 -0
- package/lib/users.js +6 -4
- package/lib/workspace-query-access.js +4 -1
- package/lib/ws-schema.js +52 -4
- package/lib/yoke/acp-process-manager.js +2 -2
- package/lib/yoke/adapters/codex.js +12 -52
- package/lib/yoke/codex-app-server.js +2 -2
- package/lib/yoke/codex-model-catalog.js +52 -0
- package/lib/yoke/codex-rate-limits.js +26 -0
- package/package.json +12 -3
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { store } from './store.js';
|
|
2
|
+
import { getWs } from './ws-ref.js';
|
|
3
|
+
import { refreshIcons } from './icons.js';
|
|
4
|
+
import { parseEnvString, looksLikeEnv, serializeEnvValue } from './settings-env-values.js';
|
|
5
|
+
import { setSettingsDraft } from './server-settings-state.js';
|
|
6
|
+
// ===== Shared Environment Variables =====
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
function showSharedEnvSaveStatus(text) {
|
|
11
|
+
var el = document.getElementById('ss-env-save-status');
|
|
12
|
+
if (el) el.textContent = text;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function loadSharedEnv() {
|
|
16
|
+
if (store.get("serverEnvLoaded") || store.get("serverEnvBusy")) return;
|
|
17
|
+
showSharedEnvSaveStatus("Loading…");
|
|
18
|
+
|
|
19
|
+
var ws = getWs();
|
|
20
|
+
if (ws && ws.readyState === 1) {
|
|
21
|
+
store.set({ serverEnvBusy: true });
|
|
22
|
+
ws.send(JSON.stringify({ type: "get_shared_env" }));
|
|
23
|
+
setTimeout(function () {
|
|
24
|
+
if (!store.get('serverEnvLoaded') && store.get('serverEnvBusy')) {
|
|
25
|
+
store.set({ serverEnvBusy: false });
|
|
26
|
+
showSharedEnvSaveStatus('No response received. Reopen Environment to retry.');
|
|
27
|
+
}
|
|
28
|
+
}, 12000);
|
|
29
|
+
} else showSharedEnvSaveStatus("Disconnected. Reopen this page after reconnecting.");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function handleSharedEnv(msg) {
|
|
33
|
+
store.set({ serverEnvBusy: false });
|
|
34
|
+
if (store.get('serverEnvLoaded')) return;
|
|
35
|
+
if (msg.error) { showSharedEnvSaveStatus(msg.error); return; }
|
|
36
|
+
var list = document.getElementById("ss-env-list");
|
|
37
|
+
if (!list) return;
|
|
38
|
+
list.innerHTML = "";
|
|
39
|
+
|
|
40
|
+
var pairs = parseEnvString(msg.envrc || "");
|
|
41
|
+
for (var i = 0; i < pairs.length; i++) {
|
|
42
|
+
addSharedEnvRow(pairs[i].key, pairs[i].value, false);
|
|
43
|
+
}
|
|
44
|
+
store.set({ serverEnvLoaded: true, serverEnvSaved: buildSharedEnvString() });
|
|
45
|
+
document.getElementById('ss-env-add-btn').disabled = false;
|
|
46
|
+
showSharedEnvSaveStatus('Changes apply to new coding-agent processes after saving.');
|
|
47
|
+
refreshIcons();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function handleSharedEnvSaved(msg) {
|
|
51
|
+
store.set({ serverEnvBusy: false });
|
|
52
|
+
document.getElementById('ss-env-save').disabled = false;
|
|
53
|
+
if (msg.ok) {
|
|
54
|
+
store.set({ serverEnvSaved: store.get('serverEnvSubmitted') });
|
|
55
|
+
markEnvironmentDraft();
|
|
56
|
+
showSharedEnvSaveStatus(buildSharedEnvString() !== store.get('serverEnvSaved') ? 'Submitted values saved. Newer edits remain unsaved.' : (msg.timing || 'Saved.'));
|
|
57
|
+
} else {
|
|
58
|
+
showSharedEnvSaveStatus("Error: " + (msg.error || "Failed to save"), 5000);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function buildSharedEnvString() {
|
|
63
|
+
var list = document.getElementById("ss-env-list");
|
|
64
|
+
if (!list) return "";
|
|
65
|
+
var rows = list.querySelectorAll(".ps-env-row");
|
|
66
|
+
var lines = [];
|
|
67
|
+
for (var i = 0; i < rows.length; i++) {
|
|
68
|
+
var keyInput = rows[i].querySelector(".ps-env-key");
|
|
69
|
+
var valInput = rows[i].querySelector(".ps-env-val");
|
|
70
|
+
var key = keyInput ? keyInput.value.trim() : "";
|
|
71
|
+
var val = valInput ? valInput.value : "";
|
|
72
|
+
if (key) lines.push("export " + key + "=" + serializeEnvValue(val));
|
|
73
|
+
}
|
|
74
|
+
return lines.join("\n");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function addSharedEnvRow(key, value, focus) {
|
|
78
|
+
var list = document.getElementById("ss-env-list");
|
|
79
|
+
if (!list) return;
|
|
80
|
+
|
|
81
|
+
var row = document.createElement("div");
|
|
82
|
+
row.className = "ps-env-row";
|
|
83
|
+
|
|
84
|
+
var keyInput = document.createElement("input");
|
|
85
|
+
keyInput.type = "text";
|
|
86
|
+
keyInput.className = "ps-env-key";
|
|
87
|
+
keyInput.placeholder = "KEY";
|
|
88
|
+
keyInput.value = key;
|
|
89
|
+
keyInput.spellcheck = false;
|
|
90
|
+
keyInput.autocomplete = "off";
|
|
91
|
+
|
|
92
|
+
var valInput = document.createElement("input");
|
|
93
|
+
valInput.type = "password";
|
|
94
|
+
valInput.className = "ps-env-val";
|
|
95
|
+
valInput.placeholder = "value";
|
|
96
|
+
valInput.value = value;
|
|
97
|
+
valInput.spellcheck = false;
|
|
98
|
+
valInput.autocomplete = "off";
|
|
99
|
+
keyInput.setAttribute('aria-label', 'Variable name');
|
|
100
|
+
valInput.setAttribute('aria-label', 'Variable value');
|
|
101
|
+
var reveal = document.createElement('button'); reveal.type = 'button'; reveal.className = 'settings-btn-sm'; reveal.textContent = 'Show';
|
|
102
|
+
reveal.setAttribute('aria-label', 'Show variable value'); reveal.setAttribute('aria-pressed', 'false');
|
|
103
|
+
reveal.onclick = function () { var visible = valInput.type === 'password'; valInput.type = visible ? 'text' : 'password'; reveal.textContent = visible ? 'Hide' : 'Show'; reveal.setAttribute('aria-pressed', String(visible)); };
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
var delBtn = document.createElement("button");
|
|
107
|
+
delBtn.className = "ps-env-del";
|
|
108
|
+
delBtn.title = "Remove variable";
|
|
109
|
+
delBtn.setAttribute("aria-label", "Remove variable");
|
|
110
|
+
delBtn.innerHTML = '<i data-lucide="x"></i>';
|
|
111
|
+
|
|
112
|
+
delBtn.addEventListener("click", function () {
|
|
113
|
+
row.remove();
|
|
114
|
+
markEnvironmentDraft();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
keyInput.addEventListener("input", function () { markEnvironmentDraft(); });
|
|
118
|
+
valInput.addEventListener("input", function () { markEnvironmentDraft(); });
|
|
119
|
+
|
|
120
|
+
// Paste detection
|
|
121
|
+
keyInput.addEventListener("paste", function (e) {
|
|
122
|
+
var text = (e.clipboardData || window.clipboardData).getData("text");
|
|
123
|
+
if (text && looksLikeEnv(text)) {
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
var pairs = parseEnvString(text);
|
|
126
|
+
if (pairs.length > 0) {
|
|
127
|
+
keyInput.value = pairs[0].key;
|
|
128
|
+
valInput.value = pairs[0].value;
|
|
129
|
+
for (var p = 1; p < pairs.length; p++) {
|
|
130
|
+
addSharedEnvRow(pairs[p].key, pairs[p].value, false);
|
|
131
|
+
}
|
|
132
|
+
markEnvironmentDraft();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
valInput.addEventListener("paste", function (e) {
|
|
138
|
+
var text = (e.clipboardData || window.clipboardData).getData("text");
|
|
139
|
+
if (text && text.indexOf("\n") !== -1 && text.indexOf("=") !== -1) {
|
|
140
|
+
e.preventDefault();
|
|
141
|
+
var pairs = parseEnvString(text);
|
|
142
|
+
if (pairs.length > 0) {
|
|
143
|
+
keyInput.value = pairs[0].key;
|
|
144
|
+
valInput.value = pairs[0].value;
|
|
145
|
+
for (var p = 1; p < pairs.length; p++) {
|
|
146
|
+
addSharedEnvRow(pairs[p].key, pairs[p].value, false);
|
|
147
|
+
}
|
|
148
|
+
markEnvironmentDraft();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
row.appendChild(keyInput);
|
|
154
|
+
row.appendChild(valInput);
|
|
155
|
+
row.appendChild(reveal);
|
|
156
|
+
row.appendChild(delBtn);
|
|
157
|
+
list.appendChild(row);
|
|
158
|
+
refreshIcons();
|
|
159
|
+
|
|
160
|
+
if (focus) keyInput.focus();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function markEnvironmentDraft() {
|
|
164
|
+
var draft = buildSharedEnvString();
|
|
165
|
+
store.set({ serverEnvDraft: draft });
|
|
166
|
+
var dirty = draft !== store.get('serverEnvSaved') || Array.from(document.querySelectorAll('#ss-env-list .ps-env-key')).some(function (input) { return !input.value.trim(); });
|
|
167
|
+
setSettingsDraft('environment', dirty);
|
|
168
|
+
document.getElementById('ss-env-save').disabled = !dirty || store.get('serverEnvBusy');
|
|
169
|
+
showSharedEnvSaveStatus(dirty ? 'Unsaved changes' : 'No unsaved changes');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function initServerEnvironment() {
|
|
173
|
+
document.getElementById('ss-env-add-btn').disabled = true;
|
|
174
|
+
document.getElementById('ss-env-add-btn').onclick = function () { addSharedEnvRow('', '', true); markEnvironmentDraft(); };
|
|
175
|
+
document.getElementById('ss-env-save').onclick = function () {
|
|
176
|
+
var ws = getWs();
|
|
177
|
+
if (!ws || ws.readyState !== 1) { showSharedEnvSaveStatus('Disconnected. Your draft is retained.'); return; }
|
|
178
|
+
var invalid = Array.from(document.querySelectorAll('#ss-env-list .ps-env-key')).some(function (input) {
|
|
179
|
+
return !/^[A-Za-z_][A-Za-z0-9_]*$/.test(input.value.trim());
|
|
180
|
+
});
|
|
181
|
+
if (invalid) { showSharedEnvSaveStatus('Each variable needs a valid name using letters, digits and underscores, starting with a letter or underscore.'); return; }
|
|
182
|
+
var draft = buildSharedEnvString();
|
|
183
|
+
store.set({ serverEnvBusy: true, serverEnvSubmitted: draft });
|
|
184
|
+
this.disabled = true;
|
|
185
|
+
ws.send(JSON.stringify({ type: 'set_shared_env', envrc: draft }));
|
|
186
|
+
showSharedEnvSaveStatus('Saving…');
|
|
187
|
+
setTimeout(function () {
|
|
188
|
+
if (!store.get('serverEnvBusy')) return;
|
|
189
|
+
store.set({ serverEnvBusy: false });
|
|
190
|
+
document.getElementById('ss-env-save').disabled = false;
|
|
191
|
+
showSharedEnvSaveStatus('No acknowledgement received. Your draft is retained; reconnect and retry.');
|
|
192
|
+
}, 12000);
|
|
193
|
+
};
|
|
194
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export var SERVER_SETTINGS_PAGES = [
|
|
2
|
+
{ id: 'overview', category: 'Service', label: 'Overview' },
|
|
3
|
+
{ id: 'network', category: 'Service', label: 'Network' },
|
|
4
|
+
{ id: 'storage', category: 'Service', label: 'Storage' },
|
|
5
|
+
{ id: 'security', category: 'Administration', label: 'Access & security' },
|
|
6
|
+
{ id: 'admin-users', category: 'Administration', label: 'Users', multiUser: true },
|
|
7
|
+
{ id: 'admin-projects', category: 'Administration', label: 'Project access', multiUser: true },
|
|
8
|
+
{ id: 'admin-smtp', category: 'Administration', label: 'Email delivery', multiUser: true },
|
|
9
|
+
{ id: 'environment', category: 'Agent configuration', label: 'Environment' },
|
|
10
|
+
{ id: 'operations', category: 'Maintenance', label: 'Operations' }
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
export function renderSettingsNavigation(multiUser, selectPage) {
|
|
14
|
+
var nav = document.getElementById('settings-page-nav');
|
|
15
|
+
var mobile = document.getElementById('settings-nav-dropdown');
|
|
16
|
+
nav.replaceChildren(); mobile.replaceChildren();
|
|
17
|
+
var category; var group;
|
|
18
|
+
SERVER_SETTINGS_PAGES.forEach(function (page) {
|
|
19
|
+
if (page.multiUser && !multiUser) return;
|
|
20
|
+
if (category !== page.category) {
|
|
21
|
+
category = page.category;
|
|
22
|
+
var heading = document.createElement('div'); heading.className = 'settings-nav-category'; heading.textContent = category; nav.appendChild(heading);
|
|
23
|
+
group = document.createElement('optgroup'); group.label = category; mobile.appendChild(group);
|
|
24
|
+
}
|
|
25
|
+
var button = document.createElement('button'); button.type = 'button'; button.className = 'settings-nav-item'; button.dataset.section = page.id; button.textContent = page.label;
|
|
26
|
+
button.onclick = function () { selectPage(page.id, true); }; nav.appendChild(button);
|
|
27
|
+
var option = document.createElement('option'); option.value = page.id; option.textContent = page.label; group.appendChild(option);
|
|
28
|
+
});
|
|
29
|
+
mobile.onchange = function () { selectPage(this.value, true); };
|
|
30
|
+
nav.onkeydown = function (event) {
|
|
31
|
+
if (['ArrowUp', 'ArrowDown', 'Home', 'End'].indexOf(event.key) < 0) return;
|
|
32
|
+
var items = Array.from(nav.querySelectorAll('button'));
|
|
33
|
+
var index = items.indexOf(document.activeElement);
|
|
34
|
+
if (index < 0) return;
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
index = event.key === 'Home' ? 0 : event.key === 'End' ? items.length - 1 : (index + (event.key === 'ArrowDown' ? 1 : -1) + items.length) % items.length;
|
|
37
|
+
items[index].focus();
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { store } from './store.js';
|
|
2
|
+
|
|
3
|
+
export function setSettingsDraft(key, dirty) {
|
|
4
|
+
var drafts = Object.assign({}, store.get('serverSettingsDrafts') || {});
|
|
5
|
+
drafts[key] = !!dirty;
|
|
6
|
+
store.set({ serverSettingsDrafts: drafts });
|
|
7
|
+
}
|
|
8
|
+
export function clearSettingsDraft(key) { setSettingsDraft(key, false); }
|
|
9
|
+
export function hasSettingsDrafts() {
|
|
10
|
+
var network = store.get('networkSettings');
|
|
11
|
+
var drafts = store.get('serverSettingsDrafts') || {};
|
|
12
|
+
return Object.keys(drafts).some(function (key) { return drafts[key]; }) ||
|
|
13
|
+
!!(network && network.loaded && network.draft !== network.saved);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function trapSettingsFocus(event, root) {
|
|
17
|
+
if (event.key !== 'Tab') return;
|
|
18
|
+
var items = Array.from(root.querySelectorAll('button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), a[href], [tabindex="0"]')).filter(function (el) { return el.getClientRects().length; });
|
|
19
|
+
if (!items.length) return;
|
|
20
|
+
var first = items[0]; var last = items[items.length - 1];
|
|
21
|
+
if (event.shiftKey && (document.activeElement === first || !root.contains(document.activeElement))) { event.preventDefault(); last.focus(); }
|
|
22
|
+
else if (!event.shiftKey && (document.activeElement === last || !root.contains(document.activeElement))) { event.preventDefault(); first.focus(); }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function isolateSettingsDialog(overlay) {
|
|
26
|
+
var entries = Array.from(document.body.children).filter(function (el) { return el !== overlay && el.tagName !== 'SCRIPT' && el.tagName !== 'STYLE'; }).map(function (el) {
|
|
27
|
+
var entry = { el: el, inert: el.inert, hidden: el.getAttribute('aria-hidden') };
|
|
28
|
+
el.inert = true; el.setAttribute('aria-hidden', 'true'); return entry;
|
|
29
|
+
});
|
|
30
|
+
return function () { entries.forEach(function (entry) { entry.el.inert = entry.inert; if (entry.hidden === null) entry.el.removeAttribute('aria-hidden'); else entry.el.setAttribute('aria-hidden', entry.hidden); }); };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function confirmSettingsAction(message, action, onConfirm) {
|
|
34
|
+
if (document.getElementById('settings-confirm')) return;
|
|
35
|
+
var previous = document.activeElement;
|
|
36
|
+
var overlay = document.createElement('div');
|
|
37
|
+
overlay.id = 'settings-confirm'; overlay.className = 'settings-confirm';
|
|
38
|
+
overlay.innerHTML = '<div role="dialog" aria-modal="true" aria-labelledby="settings-confirm-title"><h3 id="settings-confirm-title"></h3><p></p><div class="settings-confirm-actions"><button class="settings-btn-sm" data-cancel>Keep editing</button><button class="settings-btn-sm" data-confirm></button></div></div>';
|
|
39
|
+
overlay.querySelector('h3').textContent = action;
|
|
40
|
+
overlay.querySelector('p').textContent = message;
|
|
41
|
+
overlay.querySelector('[data-confirm]').textContent = action;
|
|
42
|
+
function close() { restore(); overlay.remove(); if (previous && previous.isConnected) previous.focus(); }
|
|
43
|
+
overlay.querySelector('[data-cancel]').onclick = close;
|
|
44
|
+
overlay.querySelector('[data-confirm]').onclick = function () { close(); onConfirm(); };
|
|
45
|
+
overlay.addEventListener('keydown', function (event) {
|
|
46
|
+
event.stopPropagation();
|
|
47
|
+
if (event.key === 'Escape') { event.preventDefault(); close(); }
|
|
48
|
+
trapSettingsFocus(event, overlay);
|
|
49
|
+
});
|
|
50
|
+
overlay.addEventListener('click', function (event) { if (event.target === overlay) close(); });
|
|
51
|
+
document.body.appendChild(overlay);
|
|
52
|
+
var restore = isolateSettingsDialog(overlay);
|
|
53
|
+
overlay.querySelector('[data-cancel]').focus();
|
|
54
|
+
}
|