|
1 | 1 | (function registerAcbModalShell() { |
2 | | - const SETTINGS_FIELDS = [ |
| 2 | + const NETWORK_FIELDS = [ |
3 | 3 | { label: "Host", id: "setting-host", type: "text" }, |
4 | 4 | { label: "Port", id: "setting-port", type: "number" }, |
| 5 | + ]; |
| 6 | + |
| 7 | + const AGENT_FIELDS = [ |
5 | 8 | { |
6 | 9 | label: "Agent Heartbeat Timeout (s)", |
7 | 10 | id: "setting-heartbeat", |
|
13 | 16 |
|
14 | 17 | const MINIMAP_KEY = "acb-minimap-enabled"; |
15 | 18 |
|
16 | | - function renderSettingsFields() { |
17 | | - return SETTINGS_FIELDS.map((field) => { |
| 19 | + function renderFields(fields) { |
| 20 | + return fields.map((field) => { |
18 | 21 | const noteHtml = field.note |
19 | | - ? `<div style="font-size:11px;color:var(--text-3);margin-top:-12px;margin-bottom:16px;line-height:1.4;">${field.note}</div>` |
| 22 | + ? `<div class="settings-field-note">${field.note}</div>` |
20 | 23 | : ""; |
21 | 24 | return ` |
22 | | - <label style="display:block;font-size:13px;color:var(--text-2);margin-bottom:6px;">${field.label}</label> |
23 | | - <input id="${field.id}" type="${field.type}" |
24 | | - style="width:100%;background:var(--bg-input);border:1px solid var(--border-light);color:var(--text-1);border-radius:10px;padding:10px 14px;font-size:14px;font-family:inherit;margin-bottom:${field.note ? "8px" : "16px"};" /> |
25 | | - ${noteHtml}`; |
| 25 | + <div class="settings-field"> |
| 26 | + <label>${field.label}</label> |
| 27 | + <input id="${field.id}" type="${field.type}" /> |
| 28 | + ${noteHtml} |
| 29 | + </div>`; |
26 | 30 | }).join("\n"); |
27 | 31 | } |
28 | 32 |
|
29 | 33 | function renderUiPreferences() { |
30 | 34 | return ` |
31 | | - <div style="border-top:1px solid var(--border-light);margin:4px 0 16px;padding-top:16px;"> |
32 | | - <div style="font-size:12px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;color:var(--text-2);margin-bottom:12px;">UI Preferences</div> |
33 | | - <label style="display:flex;align-items:center;gap:10px;font-size:13px;color:var(--text-1);cursor:pointer;user-select:none;"> |
34 | | - <input id="setting-minimap" type="checkbox" style="width:15px;height:15px;cursor:pointer;accent-color:var(--accent);" /> |
35 | | - <span>Message minimap (navigation sidebar)</span> |
36 | | - </label> |
37 | | - <div style="font-size:11px;color:var(--text-2);margin-top:4px;padding-left:25px;">Scrollable anchor list on the right — toggle without restart.</div> |
38 | | - </div>`; |
| 35 | + <div class="settings-field settings-field-row"> |
| 36 | + <label for="setting-minimap">Message minimap (Navigation sidebar)</label> |
| 37 | + <div class="toggle-switch"> |
| 38 | + <input id="setting-minimap" type="checkbox" /> |
| 39 | + <span class="toggle-slider"></span> |
| 40 | + </div> |
| 41 | + </div> |
| 42 | + <div class="settings-field-note" style="margin-top: 4px;">Scrollable anchor list on the right — toggle without restart.</div> |
| 43 | + `; |
39 | 44 | } |
40 | 45 |
|
| 46 | + window.switchSettingsTab = function (tabId) { |
| 47 | + document.querySelectorAll('.settings-nav-item').forEach(el => el.classList.remove('active')); |
| 48 | + document.querySelectorAll('.settings-tab-pane').forEach(el => el.classList.remove('active')); |
| 49 | + |
| 50 | + const navItem = document.getElementById('nav-' + tabId); |
| 51 | + if (navItem) navItem.classList.add('active'); |
| 52 | + |
| 53 | + const pane = document.getElementById('pane-' + tabId); |
| 54 | + if (pane) pane.classList.add('active'); |
| 55 | + }; |
| 56 | + |
41 | 57 | class AcbModalShell extends HTMLElement { |
42 | 58 | connectedCallback() { |
43 | 59 | if (this.childElementCount > 0) return; |
|
63 | 79 |
|
64 | 80 | <div id="settings-modal-overlay" onclick="closeSettingsModal(event)" |
65 | 81 | style="display:none;position:fixed;inset:0;background:rgba(0,0,0,.7);align-items:center;justify-content:center;z-index:100;animation:fade-in .15s ease;"> |
66 | | - <div id="settings-modal" |
67 | | - style="background:var(--bg-card);border:1px solid var(--border-light);border-radius:14px;padding:28px;width:440px;max-width:90vw;box-shadow:var(--shadow);animation:modal-in .2s ease;" |
68 | | - onclick="event.stopPropagation()"> |
69 | | - <h3 style="font-size:16px;font-weight:600;margin-bottom:18px;color:var(--text-1)">⚙️ MCP Server Settings</h3> |
70 | | - ${renderSettingsFields()} |
71 | | - ${renderUiPreferences()} |
72 | | - <div id="settings-message" style="font-size:12px;color:var(--green);margin-bottom:16px;display:none;"></div> |
73 | | - <div class="modal-actions"> |
74 | | - <button class="btn-secondary" onclick="closeSettingsModal()">Cancel</button> |
| 82 | + <div id="settings-modal" class="settings-modal-container" onclick="event.stopPropagation()"> |
| 83 | + <div class="settings-modal-header"> |
| 84 | + <h3>Settings - AgentChatBus</h3> |
| 85 | + <button class="settings-close-btn" onclick="closeSettingsModal()"> |
| 86 | + <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg> |
| 87 | + </button> |
| 88 | + </div> |
| 89 | + <div class="settings-modal-body"> |
| 90 | + <div class="settings-sidebar"> |
| 91 | + <div id="nav-agent" class="settings-nav-item active" onclick="switchSettingsTab('agent')">Agent</div> |
| 92 | + <div id="nav-network" class="settings-nav-item" onclick="switchSettingsTab('network')">Network</div> |
| 93 | + <div id="nav-ui" class="settings-nav-item" onclick="switchSettingsTab('ui')">UI</div> |
| 94 | + </div> |
| 95 | + <div class="settings-content"> |
| 96 | + <div id="pane-agent" class="settings-tab-pane active"> |
| 97 | + <div class="settings-section-title">TIMEOUTS</div> |
| 98 | + <div class="settings-card"> |
| 99 | + ${renderFields(AGENT_FIELDS)} |
| 100 | + </div> |
| 101 | + </div> |
| 102 | + <div id="pane-network" class="settings-tab-pane"> |
| 103 | + <div class="settings-section-title">LISTENING</div> |
| 104 | + <div class="settings-card"> |
| 105 | + ${renderFields(NETWORK_FIELDS)} |
| 106 | + </div> |
| 107 | + </div> |
| 108 | + <div id="pane-ui" class="settings-tab-pane"> |
| 109 | + <div class="settings-section-title">PREFERENCES</div> |
| 110 | + <div class="settings-card"> |
| 111 | + ${renderUiPreferences()} |
| 112 | + </div> |
| 113 | + </div> |
| 114 | + </div> |
| 115 | + </div> |
| 116 | + <div class="settings-modal-footer"> |
| 117 | + <div id="settings-message" style="font-size:13px;color:var(--green);display:none;"></div> |
| 118 | + <div style="flex:1"></div> |
75 | 119 | <button class="btn-primary" id="btn-settings-save" onclick="submitSettings()">Save (Requires Restart)</button> |
76 | 120 | </div> |
77 | 121 | </div> |
|
0 commit comments