(config)
| 273 | } |
| 274 | |
| 275 | function createChatUi(config) { |
| 276 | const headerButtons = document.querySelector('.header-buttons'); |
| 277 | if (!headerButtons) return null; |
| 278 | ensureAiChatStyles(); |
| 279 | |
| 280 | const btn = makeEl('button', { |
| 281 | id: 'aiChatBtn', |
| 282 | title: 'AI Chat (Pro)' |
| 283 | }, '<i class="material-icons">smart_toy</i>'); |
| 284 | |
| 285 | const overlay = makeEl('div', { |
| 286 | id: 'aiChatOverlay', |
| 287 | style: 'position:fixed;inset:0;background:rgba(0,0,0,0.45);z-index:12000;display:none;' |
| 288 | }); |
| 289 | |
| 290 | const card = makeEl('div', { |
| 291 | id: 'aiChatCard', |
| 292 | style: 'position:absolute;right:20px;top:60px;width:min(760px,calc(100vw - 24px));height:min(84vh,820px);background:var(--card-bg,#fff);color:var(--text-color,#111);border:1px solid rgba(0,0,0,.12);border-radius:20px;box-shadow:0 22px 60px rgba(15,23,42,.24);display:flex;flex-direction:column;overflow:hidden;' |
| 293 | }); |
| 294 | const dataEgress = (config?.settings?.dataEgress && typeof config.settings.dataEgress === 'object') |
| 295 | ? config.settings.dataEgress |
| 296 | : {}; |
| 297 | const dataEgressEnabled = !!dataEgress.enabled; |
| 298 | const dataEgressMessage = String(dataEgress.message || '').trim(); |
| 299 | |
| 300 | card.innerHTML = ` |
| 301 | <div data-ai-chat-section="head" style="display:flex;justify-content:space-between;align-items:flex-start;padding:10px 14px 8px;border-bottom:1px solid rgba(0,0,0,.08);gap:10px;"> |
| 302 | <div style="display:flex;flex-direction:column;gap:3px;min-width:0;flex:1;"> |
| 303 | <div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap;"> |
| 304 | <div style="font-weight:700;font-size:14px;line-height:1.1;">AI Chat</div> |
| 305 | <div style="font-size:11px;opacity:.66;line-height:1.1;">ACL-scoped, audited</div> |
| 306 | </div> |
| 307 | <div id="aiChatMeta" style="font-size:10px;opacity:.68;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"></div> |
| 308 | </div> |
| 309 | <span id="aiChatClose" class="editor-close-btn" role="button" aria-label="Close" title="Close">×</span> |
| 310 | </div> |
| 311 | ${dataEgressEnabled ? ` |
| 312 | <div data-ai-chat-section="egress" style="padding:7px 14px;border-bottom:1px solid rgba(0,0,0,.08);font-size:11px;line-height:1.35;background:rgba(245,158,11,.10);color:inherit;"> |
| 313 | <strong>External AI data egress:</strong> ${escapeHTML(dataEgressMessage || 'Enabled external AI providers may send prompts and visible file excerpts to third-party services.')} |
| 314 | </div> |
| 315 | ` : ''} |
| 316 | <div data-ai-chat-section="scope" style="display:flex;gap:8px;padding:7px 14px;border-bottom:1px solid rgba(0,0,0,.08);flex-wrap:wrap;"> |
| 317 | <div style="display:flex;justify-content:space-between;align-items:center;gap:8px;width:100%;min-width:0;"> |
| 318 | <div id="aiChatScopeSummary" style="font-size:11px;opacity:.78;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;"></div> |
| 319 | <button type="button" id="aiChatToggleScope" class="btn btn-sm btn-light" style="border-radius:999px;padding:3px 8px;font-size:10px;line-height:1.1;flex:0 0 auto;">Show scope</button> |
| 320 | </div> |
| 321 | <div id="aiChatScopeFields" style="display:none;gap:10px;flex-wrap:wrap;width:100%;"> |
| 322 | <div style="display:flex;justify-content:flex-end;width:100%;"> |
| 323 | <button type="button" id="aiChatUseCurrent" class="btn btn-sm btn-light" style="border-radius:999px;padding:4px 10px;font-size:11px;line-height:1.2;">Scope chat here</button> |
| 324 | </div> |
| 325 | <label style="margin:0;display:flex;flex-direction:column;font-size:11px;gap:4px;min-width:130px;text-transform:uppercase;letter-spacing:.04em;opacity:.82;"> |
| 326 | <span>Work In Source</span> |
| 327 | <input id="aiChatSource" class="form-control form-control-sm" value="local" /> |
| 328 | </label> |
| 329 | <label style="margin:0;display:flex;flex-direction:column;font-size:11px;gap:4px;min-width:190px;flex:1;text-transform:uppercase;letter-spacing:.04em;opacity:.82;"> |
| 330 | <span>Folder Scope</span> |
| 331 | <input id="aiChatRoot" class="form-control form-control-sm" value="root" /> |
| 332 | </label> |
no test coverage detected