context_drop 0.3.2 → 0.3.4
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/context_drop/context_drop.js +152 -11
- data/app/javascript/context_drop/__tests__/widget.test.ts +229 -18
- data/app/javascript/context_drop/styles.ts +16 -0
- data/app/javascript/context_drop/widget.ts +136 -11
- data/lib/context_drop/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bafb19959bf7ef41bfd4825d64d21ef117a9bf2f3828a70f6d90d4f154fc838c
|
|
4
|
+
data.tar.gz: 9c9daf6ea6de9189b7b064f37e84cd3f4b89abdd47f005dfa3bc40a4b01c98a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 392551e1428b9ffb7f2a506a193fe9a5827ebd055d39568a2a17ec8e09e9d61b5a40a2fc2f8572aa2557b3c0af9a41116b57ccecd39262c15ae6e7d54ab4edd5
|
|
7
|
+
data.tar.gz: d8ac287732bd6d58657a7ad5a05157e319fd856c1dfca8703938edff58e4914bb453ba95b8db0dcae0f443a084aa8422f3fb99f6bbd69111e430db0408176ff3
|
|
@@ -1208,6 +1208,13 @@
|
|
|
1208
1208
|
box-sizing: border-box;
|
|
1209
1209
|
}
|
|
1210
1210
|
|
|
1211
|
+
.cd-form-shell {
|
|
1212
|
+
display: contents;
|
|
1213
|
+
margin: 0;
|
|
1214
|
+
padding: 0;
|
|
1215
|
+
border: 0;
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1211
1218
|
::selection {
|
|
1212
1219
|
background: var(--cd-pin-soft);
|
|
1213
1220
|
color: var(--cd-ink);
|
|
@@ -2535,6 +2542,15 @@
|
|
|
2535
2542
|
font-size: 11.5px;
|
|
2536
2543
|
}
|
|
2537
2544
|
|
|
2545
|
+
.cd-input.is-masked-secret {
|
|
2546
|
+
-webkit-text-security: disc;
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
.cd-input.is-masked-secret:placeholder-shown,
|
|
2550
|
+
.cd-input.is-masked-secret:disabled {
|
|
2551
|
+
-webkit-text-security: none;
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2538
2554
|
.cd-drawer-actions {
|
|
2539
2555
|
display: flex;
|
|
2540
2556
|
align-items: center;
|
|
@@ -6363,6 +6379,7 @@
|
|
|
6363
6379
|
this.setCornerPosition(partial.position);
|
|
6364
6380
|
}
|
|
6365
6381
|
const nowAgentEnabled = Boolean(this.config.agent?.enabled);
|
|
6382
|
+
this.syncAgentSidebarMount();
|
|
6366
6383
|
if (nowAgentEnabled && !wasAgentEnabled) {
|
|
6367
6384
|
this.surfaceMode = "agent";
|
|
6368
6385
|
if (this.isOpen) {
|
|
@@ -7581,9 +7598,95 @@
|
|
|
7581
7598
|
}
|
|
7582
7599
|
}
|
|
7583
7600
|
|
|
7601
|
+
clearAgentSidebarRefs() {
|
|
7602
|
+
this.agentSidebarEl = null;
|
|
7603
|
+
this.sidebarPinBtn = null;
|
|
7604
|
+
this.sidebarEnvPillEl = null;
|
|
7605
|
+
this.sidebarThemeToggleBtn = null;
|
|
7606
|
+
this.sidebarPushBtn = null;
|
|
7607
|
+
this.keyDotEl = null;
|
|
7608
|
+
this.providerPillLabelEl = null;
|
|
7609
|
+
this.keysToggleBtn = null;
|
|
7610
|
+
this.feedbacksToggleBtn = null;
|
|
7611
|
+
this.byokDrawerEl = null;
|
|
7612
|
+
this.byokProviderSelect = null;
|
|
7613
|
+
this.byokModelInput = null;
|
|
7614
|
+
this.byokModelPresetsSelect = null;
|
|
7615
|
+
this.byokBaseUrlField = null;
|
|
7616
|
+
this.byokBaseUrlInput = null;
|
|
7617
|
+
this.byokKeySourceBadge = null;
|
|
7618
|
+
this.byokKeyInput = null;
|
|
7619
|
+
this.feedbacksDrawerEl = null;
|
|
7620
|
+
this.feedbacksTabsEl = null;
|
|
7621
|
+
this.feedbacksListEl = null;
|
|
7622
|
+
this.agentStreamEl = null;
|
|
7623
|
+
this.agentTrayEl = null;
|
|
7624
|
+
this.agentStatusEl = null;
|
|
7625
|
+
this.agentTextareaEl = null;
|
|
7626
|
+
this.agentSendBtn = null;
|
|
7627
|
+
}
|
|
7628
|
+
|
|
7629
|
+
syncAgentSidebarMount() {
|
|
7630
|
+
const enabled = Boolean(this.config.agent?.enabled);
|
|
7631
|
+
if (enabled) {
|
|
7632
|
+
if (!this.agentSidebarEl && this.shadow) {
|
|
7633
|
+
const sidebar = this.buildAgentSidebarDom();
|
|
7634
|
+
sidebar.setAttribute("data-theme", this.currentTheme);
|
|
7635
|
+
if (
|
|
7636
|
+
this.bookCornerBtn &&
|
|
7637
|
+
this.bookCornerBtn.parentNode === this.shadow &&
|
|
7638
|
+
typeof this.shadow.insertBefore === "function"
|
|
7639
|
+
) {
|
|
7640
|
+
this.shadow.insertBefore(sidebar, this.bookCornerBtn);
|
|
7641
|
+
} else {
|
|
7642
|
+
this.shadow.appendChild(sidebar);
|
|
7643
|
+
}
|
|
7644
|
+
}
|
|
7645
|
+
return;
|
|
7646
|
+
}
|
|
7647
|
+
|
|
7648
|
+
this.isByokDrawerOpen = false;
|
|
7649
|
+
this.isFeedbacksDrawerOpen = false;
|
|
7650
|
+
if (this.agentSidebarEl) {
|
|
7651
|
+
this.agentSidebarEl.parentNode?.removeChild(this.agentSidebarEl);
|
|
7652
|
+
}
|
|
7653
|
+
this.clearAgentSidebarRefs();
|
|
7654
|
+
}
|
|
7655
|
+
|
|
7656
|
+
buildFormShell() {
|
|
7657
|
+
const form = document.createElement("form");
|
|
7658
|
+
form.className = "cd-form-shell";
|
|
7659
|
+
form.autocomplete = "off";
|
|
7660
|
+
form.setAttribute("autocomplete", "off");
|
|
7661
|
+
form.noValidate = true;
|
|
7662
|
+
form.setAttribute("novalidate", "");
|
|
7663
|
+
form.setAttribute("data-1p-ignore", "true");
|
|
7664
|
+
form.setAttribute("data-lpignore", "true");
|
|
7665
|
+
form.setAttribute("data-bwignore", "true");
|
|
7666
|
+
form.setAttribute("data-form-type", "other");
|
|
7667
|
+
form.addEventListener("submit", (ev) => {
|
|
7668
|
+
ev.preventDefault();
|
|
7669
|
+
});
|
|
7670
|
+
return form;
|
|
7671
|
+
}
|
|
7672
|
+
|
|
7673
|
+
applyByokAutofillIgnore(control ) {
|
|
7674
|
+
control.autocomplete = "off";
|
|
7675
|
+
control.setAttribute("autocomplete", "off");
|
|
7676
|
+
control.spellcheck = false;
|
|
7677
|
+
control.setAttribute("spellcheck", "false");
|
|
7678
|
+
control.setAttribute("autocorrect", "off");
|
|
7679
|
+
control.setAttribute("autocapitalize", "off");
|
|
7680
|
+
control.setAttribute("data-1p-ignore", "true");
|
|
7681
|
+
control.setAttribute("data-lpignore", "true");
|
|
7682
|
+
control.setAttribute("data-bwignore", "true");
|
|
7683
|
+
control.setAttribute("data-form-type", "other");
|
|
7684
|
+
}
|
|
7685
|
+
|
|
7584
7686
|
renderShadowDom() {
|
|
7585
7687
|
if (!this.shadow) return;
|
|
7586
7688
|
this.shadow.innerHTML = "";
|
|
7689
|
+
this.clearAgentSidebarRefs();
|
|
7587
7690
|
|
|
7588
7691
|
const styleEl = document.createElement("style");
|
|
7589
7692
|
styleEl.textContent = WIDGET_SHADOW_STYLES;
|
|
@@ -7603,9 +7706,11 @@
|
|
|
7603
7706
|
|
|
7604
7707
|
this.shadow.appendChild(root);
|
|
7605
7708
|
|
|
7606
|
-
// 3. Docked Local BYOK Agentic Coding Sidebar (
|
|
7607
|
-
|
|
7608
|
-
|
|
7709
|
+
// 3. Docked Local BYOK Agentic Coding Sidebar (mounted only when local agent is enabled)
|
|
7710
|
+
if (Boolean(this.config.agent?.enabled)) {
|
|
7711
|
+
const sidebar = this.buildAgentSidebarDom();
|
|
7712
|
+
this.shadow.appendChild(sidebar);
|
|
7713
|
+
}
|
|
7609
7714
|
|
|
7610
7715
|
// 4. Book-Corner Fold Launcher (flush at viewport corner, peels into pushpin on drag)
|
|
7611
7716
|
const bookCorner = document.createElement("button");
|
|
@@ -7865,8 +7970,13 @@
|
|
|
7865
7970
|
this.statusEl = status;
|
|
7866
7971
|
composer.appendChild(status);
|
|
7867
7972
|
|
|
7973
|
+
const composerForm = this.buildFormShell();
|
|
7974
|
+
|
|
7868
7975
|
const fileInput = document.createElement("input");
|
|
7869
7976
|
fileInput.type = "file";
|
|
7977
|
+
fileInput.setAttribute("type", "file");
|
|
7978
|
+
fileInput.autocomplete = "off";
|
|
7979
|
+
fileInput.setAttribute("autocomplete", "off");
|
|
7870
7980
|
fileInput.multiple = true;
|
|
7871
7981
|
fileInput.accept = this.config.limits.allowed_content_types.join(",");
|
|
7872
7982
|
fileInput.hidden = true;
|
|
@@ -7877,7 +7987,7 @@
|
|
|
7877
7987
|
}
|
|
7878
7988
|
});
|
|
7879
7989
|
this.fileInputEl = fileInput;
|
|
7880
|
-
|
|
7990
|
+
composerForm.appendChild(fileInput);
|
|
7881
7991
|
|
|
7882
7992
|
const promptShell = document.createElement("div");
|
|
7883
7993
|
promptShell.className = "cd-prompt-shell";
|
|
@@ -7909,6 +8019,12 @@
|
|
|
7909
8019
|
|
|
7910
8020
|
const textarea = document.createElement("textarea");
|
|
7911
8021
|
textarea.className = "cd-textarea";
|
|
8022
|
+
textarea.autocomplete = "off";
|
|
8023
|
+
textarea.setAttribute("autocomplete", "off");
|
|
8024
|
+
textarea.setAttribute("data-1p-ignore", "true");
|
|
8025
|
+
textarea.setAttribute("data-lpignore", "true");
|
|
8026
|
+
textarea.setAttribute("data-bwignore", "true");
|
|
8027
|
+
textarea.setAttribute("data-form-type", "other");
|
|
7912
8028
|
textarea.placeholder = this.config.placeholder;
|
|
7913
8029
|
textarea.setAttribute("aria-label", "Feedback description");
|
|
7914
8030
|
textarea.addEventListener("keydown", (ev) => {
|
|
@@ -7951,7 +8067,8 @@
|
|
|
7951
8067
|
toolbar.appendChild(actions);
|
|
7952
8068
|
toolbar.appendChild(submitBtn);
|
|
7953
8069
|
promptShell.appendChild(toolbar);
|
|
7954
|
-
|
|
8070
|
+
composerForm.appendChild(promptShell);
|
|
8071
|
+
composer.appendChild(composerForm);
|
|
7955
8072
|
|
|
7956
8073
|
return composer;
|
|
7957
8074
|
}
|
|
@@ -8208,11 +8325,19 @@
|
|
|
8208
8325
|
this.agentStatusEl = agentStatus;
|
|
8209
8326
|
sidebar.appendChild(agentStatus);
|
|
8210
8327
|
|
|
8328
|
+
const agentPromptForm = this.buildFormShell();
|
|
8329
|
+
|
|
8211
8330
|
const promptShell = document.createElement("div");
|
|
8212
8331
|
promptShell.className = "cd-prompt-shell";
|
|
8213
8332
|
|
|
8214
8333
|
const textarea = document.createElement("textarea");
|
|
8215
8334
|
textarea.className = "cd-textarea";
|
|
8335
|
+
textarea.autocomplete = "off";
|
|
8336
|
+
textarea.setAttribute("autocomplete", "off");
|
|
8337
|
+
textarea.setAttribute("data-1p-ignore", "true");
|
|
8338
|
+
textarea.setAttribute("data-lpignore", "true");
|
|
8339
|
+
textarea.setAttribute("data-bwignore", "true");
|
|
8340
|
+
textarea.setAttribute("data-form-type", "other");
|
|
8216
8341
|
textarea.placeholder =
|
|
8217
8342
|
"Ask the local agent to inspect pinned DOM elements, read Rails views, or propose a fix...";
|
|
8218
8343
|
textarea.setAttribute("aria-label", "Agent prompt");
|
|
@@ -8245,7 +8370,8 @@
|
|
|
8245
8370
|
|
|
8246
8371
|
toolbar.appendChild(sendBtn);
|
|
8247
8372
|
promptShell.appendChild(toolbar);
|
|
8248
|
-
|
|
8373
|
+
agentPromptForm.appendChild(promptShell);
|
|
8374
|
+
sidebar.appendChild(agentPromptForm);
|
|
8249
8375
|
|
|
8250
8376
|
this.syncProviderControls();
|
|
8251
8377
|
return sidebar;
|
|
@@ -8262,6 +8388,8 @@
|
|
|
8262
8388
|
securityNote.innerHTML = `${ICON_SHIELD}<span>Keys stay encrypted on disk in <code>tmp/context_drop_byok.enc</code> (AES-256-GCM) or read from server ENV—never stored in browser storage.</span>`;
|
|
8263
8389
|
drawer.appendChild(securityNote);
|
|
8264
8390
|
|
|
8391
|
+
const byokForm = this.buildFormShell();
|
|
8392
|
+
|
|
8265
8393
|
const grid = document.createElement("div");
|
|
8266
8394
|
grid.className = "cd-form-grid";
|
|
8267
8395
|
|
|
@@ -8274,6 +8402,7 @@
|
|
|
8274
8402
|
const provSelect = document.createElement("select");
|
|
8275
8403
|
provSelect.className = "cd-select";
|
|
8276
8404
|
provSelect.setAttribute("aria-label", "LLM Provider");
|
|
8405
|
+
this.applyByokAutofillIgnore(provSelect);
|
|
8277
8406
|
provSelect.addEventListener("change", () => {
|
|
8278
8407
|
this.selectedVaultProviderId = provSelect.value;
|
|
8279
8408
|
this.syncByokDrawerFields();
|
|
@@ -8292,6 +8421,7 @@
|
|
|
8292
8421
|
const presetSelect = document.createElement("select");
|
|
8293
8422
|
presetSelect.className = "cd-select";
|
|
8294
8423
|
presetSelect.setAttribute("aria-label", "Model preset");
|
|
8424
|
+
this.applyByokAutofillIgnore(presetSelect);
|
|
8295
8425
|
presetSelect.addEventListener("change", () => {
|
|
8296
8426
|
if (this.byokModelInput && presetSelect.value) {
|
|
8297
8427
|
this.byokModelInput.value = presetSelect.value;
|
|
@@ -8310,8 +8440,10 @@
|
|
|
8310
8440
|
modelLabel.textContent = "Model ID";
|
|
8311
8441
|
const modelInput = document.createElement("input");
|
|
8312
8442
|
modelInput.type = "text";
|
|
8443
|
+
modelInput.setAttribute("type", "text");
|
|
8313
8444
|
modelInput.className = "cd-input is-mono";
|
|
8314
8445
|
modelInput.setAttribute("aria-label", "Model identifier");
|
|
8446
|
+
this.applyByokAutofillIgnore(modelInput);
|
|
8315
8447
|
this.byokModelInput = modelInput;
|
|
8316
8448
|
modelField.appendChild(modelLabel);
|
|
8317
8449
|
modelField.appendChild(modelInput);
|
|
@@ -8326,16 +8458,19 @@
|
|
|
8326
8458
|
baseUrlLabel.textContent = "OpenAI-Compatible Base URL";
|
|
8327
8459
|
const baseUrlInput = document.createElement("input");
|
|
8328
8460
|
baseUrlInput.type = "url";
|
|
8461
|
+
baseUrlInput.setAttribute("type", "url");
|
|
8329
8462
|
baseUrlInput.className = "cd-input is-mono";
|
|
8330
8463
|
baseUrlInput.placeholder = "https://openrouter.ai/api/v1 or http://localhost:11434/v1";
|
|
8331
8464
|
baseUrlInput.setAttribute("aria-label", "Custom OpenAI-compatible Base URL");
|
|
8465
|
+
this.applyByokAutofillIgnore(baseUrlInput);
|
|
8332
8466
|
this.byokBaseUrlInput = baseUrlInput;
|
|
8333
8467
|
baseUrlField.appendChild(baseUrlLabel);
|
|
8334
8468
|
baseUrlField.appendChild(baseUrlInput);
|
|
8335
8469
|
this.byokBaseUrlField = baseUrlField;
|
|
8336
8470
|
grid.appendChild(baseUrlField);
|
|
8337
8471
|
|
|
8338
|
-
// API Key field
|
|
8472
|
+
// API Key field — uses CSS-masked type="text" rather than type="password" so Chromium/browser
|
|
8473
|
+
// password managers never classify preceding or host-page inputs as login username fields.
|
|
8339
8474
|
const keyField = document.createElement("div");
|
|
8340
8475
|
keyField.className = "cd-field is-full";
|
|
8341
8476
|
const keyLabel = document.createElement("label");
|
|
@@ -8350,17 +8485,20 @@
|
|
|
8350
8485
|
keyLabel.appendChild(keyBadge);
|
|
8351
8486
|
|
|
8352
8487
|
const keyInput = document.createElement("input");
|
|
8353
|
-
keyInput.type = "
|
|
8354
|
-
keyInput.
|
|
8355
|
-
keyInput.className = "cd-input is-mono";
|
|
8488
|
+
keyInput.type = "text";
|
|
8489
|
+
keyInput.setAttribute("type", "text");
|
|
8490
|
+
keyInput.className = "cd-input is-mono is-masked-secret";
|
|
8356
8491
|
keyInput.placeholder = "Paste API key (leave blank to keep existing key)";
|
|
8357
8492
|
keyInput.setAttribute("aria-label", "Provider API Key");
|
|
8493
|
+
keyInput.disabled = !this.isByokDrawerOpen;
|
|
8494
|
+
this.applyByokAutofillIgnore(keyInput);
|
|
8358
8495
|
this.byokKeyInput = keyInput;
|
|
8359
8496
|
keyField.appendChild(keyLabel);
|
|
8360
8497
|
keyField.appendChild(keyInput);
|
|
8361
8498
|
grid.appendChild(keyField);
|
|
8362
8499
|
|
|
8363
|
-
|
|
8500
|
+
byokForm.appendChild(grid);
|
|
8501
|
+
drawer.appendChild(byokForm);
|
|
8364
8502
|
|
|
8365
8503
|
const actions = document.createElement("div");
|
|
8366
8504
|
actions.className = "cd-drawer-actions";
|
|
@@ -9277,6 +9415,9 @@
|
|
|
9277
9415
|
if (this.byokDrawerEl) {
|
|
9278
9416
|
this.byokDrawerEl.hidden = !this.isByokDrawerOpen;
|
|
9279
9417
|
}
|
|
9418
|
+
if (this.byokKeyInput) {
|
|
9419
|
+
this.byokKeyInput.disabled = !this.isByokDrawerOpen;
|
|
9420
|
+
}
|
|
9280
9421
|
if (this.keysToggleBtn) {
|
|
9281
9422
|
this.keysToggleBtn.classList.toggle("is-active", this.isByokDrawerOpen);
|
|
9282
9423
|
}
|
|
@@ -487,20 +487,22 @@ class MockDomElement {
|
|
|
487
487
|
public parentNode: MockDomElement | null = null;
|
|
488
488
|
public childNodes: MockDomElement[] = [];
|
|
489
489
|
public hidden: boolean = false;
|
|
490
|
-
public type: string = "";
|
|
491
490
|
public title: string = "";
|
|
492
491
|
public textContent: string = "";
|
|
493
492
|
public placeholder: string = "";
|
|
494
493
|
public value: string = "";
|
|
495
494
|
public disabled: boolean = false;
|
|
496
495
|
public selected: boolean = false;
|
|
497
|
-
public
|
|
496
|
+
public noValidate: boolean = false;
|
|
497
|
+
public spellcheck: boolean = true;
|
|
498
498
|
public multiple: boolean = false;
|
|
499
499
|
public accept: string = "";
|
|
500
500
|
public src: string = "";
|
|
501
501
|
public alt: string = "";
|
|
502
502
|
public scrollTop: number = 0;
|
|
503
503
|
public scrollHeight: number = 0;
|
|
504
|
+
private _type: string = "";
|
|
505
|
+
private _autocomplete: string = "";
|
|
504
506
|
private rawHtml: string = "";
|
|
505
507
|
private attrs: Map<string, string> = new Map();
|
|
506
508
|
private listeners: Map<string, MockListenerEntry[]> = new Map();
|
|
@@ -543,10 +545,39 @@ class MockDomElement {
|
|
|
543
545
|
}
|
|
544
546
|
}
|
|
545
547
|
|
|
548
|
+
public get type(): string {
|
|
549
|
+
return this._type;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
public set type(val: string) {
|
|
553
|
+
this._type = val;
|
|
554
|
+
this.attrs.set("type", val);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
public get autocomplete(): string {
|
|
558
|
+
return this._autocomplete;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
public set autocomplete(val: string) {
|
|
562
|
+
this._autocomplete = val;
|
|
563
|
+
this.attrs.set("autocomplete", val);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
public get form(): MockDomElement | null {
|
|
567
|
+
if (["INPUT", "TEXTAREA", "SELECT", "BUTTON"].includes(this.tagName)) {
|
|
568
|
+
return this.closest("form");
|
|
569
|
+
}
|
|
570
|
+
return null;
|
|
571
|
+
}
|
|
572
|
+
|
|
546
573
|
public setAttribute(name: string, value: string): void {
|
|
547
574
|
this.attrs.set(name, value);
|
|
548
575
|
if (name === "class") {
|
|
549
576
|
this.classList.syncFromString(value);
|
|
577
|
+
} else if (name === "type") {
|
|
578
|
+
this._type = value;
|
|
579
|
+
} else if (name === "autocomplete") {
|
|
580
|
+
this._autocomplete = value;
|
|
550
581
|
}
|
|
551
582
|
}
|
|
552
583
|
|
|
@@ -567,12 +598,32 @@ class MockDomElement {
|
|
|
567
598
|
}
|
|
568
599
|
|
|
569
600
|
public appendChild(child: MockDomElement): MockDomElement {
|
|
601
|
+
if (child.parentNode && child.parentNode !== this) {
|
|
602
|
+
child.parentNode.removeChild(child);
|
|
603
|
+
}
|
|
570
604
|
child.parentElement = this;
|
|
571
605
|
child.parentNode = this;
|
|
572
606
|
this.childNodes.push(child);
|
|
573
607
|
return child;
|
|
574
608
|
}
|
|
575
609
|
|
|
610
|
+
public insertBefore(newChild: MockDomElement, refChild: MockDomElement | null): MockDomElement {
|
|
611
|
+
if (!refChild) {
|
|
612
|
+
return this.appendChild(newChild);
|
|
613
|
+
}
|
|
614
|
+
const idx = this.childNodes.indexOf(refChild);
|
|
615
|
+
if (idx === -1) {
|
|
616
|
+
return this.appendChild(newChild);
|
|
617
|
+
}
|
|
618
|
+
if (newChild.parentNode) {
|
|
619
|
+
newChild.parentNode.removeChild(newChild);
|
|
620
|
+
}
|
|
621
|
+
newChild.parentElement = this;
|
|
622
|
+
newChild.parentNode = this;
|
|
623
|
+
this.childNodes.splice(idx, 0, newChild);
|
|
624
|
+
return newChild;
|
|
625
|
+
}
|
|
626
|
+
|
|
576
627
|
public removeChild(child: MockDomElement): MockDomElement {
|
|
577
628
|
const idx = this.childNodes.indexOf(child);
|
|
578
629
|
if (idx !== -1) {
|
|
@@ -593,18 +644,52 @@ class MockDomElement {
|
|
|
593
644
|
}
|
|
594
645
|
|
|
595
646
|
public matches(selector: string): boolean {
|
|
596
|
-
if (selector.
|
|
597
|
-
return
|
|
647
|
+
if (selector.includes(",")) {
|
|
648
|
+
return selector
|
|
649
|
+
.split(",")
|
|
650
|
+
.map((part) => part.trim())
|
|
651
|
+
.filter(Boolean)
|
|
652
|
+
.some((part) => this.matchesSingleSelector(part));
|
|
598
653
|
}
|
|
599
|
-
|
|
600
|
-
|
|
654
|
+
return this.matchesSingleSelector(selector.trim());
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
private matchesSingleSelector(sel: string): boolean {
|
|
658
|
+
if (!sel) return false;
|
|
659
|
+
let rest = sel;
|
|
660
|
+
|
|
661
|
+
const tagMatch = rest.match(/^[a-zA-Z][a-zA-Z0-9_-]*/);
|
|
662
|
+
if (tagMatch) {
|
|
663
|
+
if (this.tagName.toLowerCase() !== tagMatch[0].toLowerCase()) return false;
|
|
664
|
+
rest = rest.slice(tagMatch[0].length);
|
|
601
665
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
if (
|
|
605
|
-
|
|
666
|
+
|
|
667
|
+
while (rest.length > 0) {
|
|
668
|
+
if (rest.startsWith(".")) {
|
|
669
|
+
const clsMatch = rest.match(/^\.([a-zA-Z0-9_-]+)/);
|
|
670
|
+
if (!clsMatch) return false;
|
|
671
|
+
if (!this.classList.contains(clsMatch[1])) return false;
|
|
672
|
+
rest = rest.slice(clsMatch[0].length);
|
|
673
|
+
} else if (rest.startsWith("#")) {
|
|
674
|
+
const idMatch = rest.match(/^#([a-zA-Z0-9_-]+)/);
|
|
675
|
+
if (!idMatch) return false;
|
|
676
|
+
if (this.getAttribute("id") !== idMatch[1]) return false;
|
|
677
|
+
rest = rest.slice(idMatch[0].length);
|
|
678
|
+
} else if (rest.startsWith("[")) {
|
|
679
|
+
const attrMatch = rest.match(/^\[([a-zA-Z0-9_-]+)(?:(\^=|=)['"]?([^'"\]]*)['"]?)?\]/);
|
|
680
|
+
if (!attrMatch) return false;
|
|
681
|
+
const [, attrName, op, expected] = attrMatch;
|
|
682
|
+
if (!this.hasAttribute(attrName)) return false;
|
|
683
|
+
const actual = this.getAttribute(attrName) ?? "";
|
|
684
|
+
if (op === "=" && actual !== expected) return false;
|
|
685
|
+
if (op === "^=" && !actual.startsWith(expected)) return false;
|
|
686
|
+
rest = rest.slice(attrMatch[0].length);
|
|
687
|
+
} else {
|
|
688
|
+
return false;
|
|
689
|
+
}
|
|
606
690
|
}
|
|
607
|
-
|
|
691
|
+
|
|
692
|
+
return true;
|
|
608
693
|
}
|
|
609
694
|
|
|
610
695
|
public closest(selector: string): MockDomElement | null {
|
|
@@ -625,6 +710,20 @@ class MockDomElement {
|
|
|
625
710
|
return null;
|
|
626
711
|
}
|
|
627
712
|
|
|
713
|
+
public querySelectorAll(selector: string): MockDomElement[] {
|
|
714
|
+
const results: MockDomElement[] = [];
|
|
715
|
+
const walk = (node: MockDomElement): void => {
|
|
716
|
+
for (const child of node.childNodes) {
|
|
717
|
+
if (child.matches(selector)) {
|
|
718
|
+
results.push(child);
|
|
719
|
+
}
|
|
720
|
+
walk(child);
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
walk(this);
|
|
724
|
+
return results;
|
|
725
|
+
}
|
|
726
|
+
|
|
628
727
|
public getBoundingClientRect(): {
|
|
629
728
|
x: number;
|
|
630
729
|
y: number;
|
|
@@ -824,11 +923,11 @@ describe("ContextDrop v0.2 Book-Corner Peel-to-Pin & Agentic Sidebar", () => {
|
|
|
824
923
|
const sidebar = shadowRoot.querySelector(".cd-agent-sidebar");
|
|
825
924
|
const compactBar = shadowRoot.querySelector(".cd-compact-bar");
|
|
826
925
|
|
|
827
|
-
assert.ok(bookCorner && composer &&
|
|
926
|
+
assert.ok(bookCorner && composer && compactBar);
|
|
927
|
+
assert.equal(sidebar, null, "Agent sidebar must not mount when agent.enabled is false");
|
|
828
928
|
assert.equal(bookCorner.hidden, false);
|
|
829
929
|
assert.equal(bookCorner.classList.contains("corner-bottom_right"), true);
|
|
830
930
|
assert.equal(composer.hidden, true);
|
|
831
|
-
assert.equal(sidebar.hidden, true);
|
|
832
931
|
assert.equal(compactBar.hidden, true);
|
|
833
932
|
|
|
834
933
|
// Pointer click without drag opens normal floating feedback composer
|
|
@@ -1582,11 +1681,12 @@ describe("ContextDrop v0.2 Book-Corner Peel-to-Pin & Agentic Sidebar", () => {
|
|
|
1582
1681
|
async ({ widget, shadowRoot }) => {
|
|
1583
1682
|
const bookCorner = shadowRoot.querySelector(".cd-book-corner");
|
|
1584
1683
|
const composer = shadowRoot.querySelector(".cd-composer");
|
|
1585
|
-
const sidebar = shadowRoot.querySelector(".cd-agent-sidebar");
|
|
1586
1684
|
const modeSwitch = composer ? composer.querySelector(".cd-composer-mode-switch-wrap") : null;
|
|
1587
|
-
assert.ok(bookCorner && composer &&
|
|
1685
|
+
assert.ok(bookCorner && composer && modeSwitch);
|
|
1588
1686
|
|
|
1589
|
-
// When agent is disabled
|
|
1687
|
+
// When agent is disabled, no agent sidebar or BYOK drawer exists in shadowRoot:
|
|
1688
|
+
assert.equal(shadowRoot.querySelector(".cd-agent-sidebar"), null);
|
|
1689
|
+
assert.equal(shadowRoot.querySelector(".cd-byok-drawer"), null);
|
|
1590
1690
|
assert.equal(widget.isAgentModeActive(), false);
|
|
1591
1691
|
assert.equal(widget.isSmartSelectionMode(), false); // verbose mode
|
|
1592
1692
|
assert.equal(modeSwitch.hidden, true);
|
|
@@ -1594,13 +1694,20 @@ describe("ContextDrop v0.2 Book-Corner Peel-to-Pin & Agentic Sidebar", () => {
|
|
|
1594
1694
|
// Clicking the book corner opens the floating verbose composer
|
|
1595
1695
|
bookCorner.dispatchEvent(new MockUiEvent("click"));
|
|
1596
1696
|
assert.equal(composer.hidden, false);
|
|
1597
|
-
assert.equal(sidebar
|
|
1697
|
+
assert.equal(shadowRoot.querySelector(".cd-agent-sidebar"), null);
|
|
1598
1698
|
|
|
1599
|
-
// Opting into agent enables agent mode
|
|
1699
|
+
// Opting into agent dynamically mounts sidebar and enables agent mode
|
|
1600
1700
|
widget.setWidgetConfig({ agent: { enabled: true } });
|
|
1701
|
+
const sidebar = shadowRoot.querySelector(".cd-agent-sidebar");
|
|
1702
|
+
assert.ok(sidebar);
|
|
1601
1703
|
assert.equal(widget.isAgentModeActive(), true);
|
|
1602
1704
|
assert.equal(sidebar.hidden, false);
|
|
1603
1705
|
assert.equal(composer.hidden, true);
|
|
1706
|
+
|
|
1707
|
+
// Disabling agent again unmounts the sidebar cleanly
|
|
1708
|
+
widget.setWidgetConfig({ agent: { enabled: false } });
|
|
1709
|
+
assert.equal(shadowRoot.querySelector(".cd-agent-sidebar"), null);
|
|
1710
|
+
assert.equal(shadowRoot.querySelector(".cd-byok-drawer"), null);
|
|
1604
1711
|
},
|
|
1605
1712
|
{
|
|
1606
1713
|
"data-config": JSON.stringify({
|
|
@@ -1613,6 +1720,110 @@ describe("ContextDrop v0.2 Book-Corner Peel-to-Pin & Agentic Sidebar", () => {
|
|
|
1613
1720
|
);
|
|
1614
1721
|
});
|
|
1615
1722
|
|
|
1723
|
+
it("does not mount .cd-agent-sidebar, .cd-byok-drawer, or input[type='password'] when agent.enabled is false", async () => {
|
|
1724
|
+
await withMountedWidget(
|
|
1725
|
+
({ shadowRoot }) => {
|
|
1726
|
+
assert.equal(shadowRoot.querySelector(".cd-agent-sidebar"), null);
|
|
1727
|
+
assert.equal(shadowRoot.querySelector(".cd-byok-drawer"), null);
|
|
1728
|
+
assert.equal(shadowRoot.querySelector('input[type="password"]'), null);
|
|
1729
|
+
assert.equal(shadowRoot.querySelector("[aria-label='Provider API Key']"), null);
|
|
1730
|
+
|
|
1731
|
+
// Even feedback composer controls must have an owning <form autocomplete="off"> so nothing leaks into Chromium's synthetic unowned form
|
|
1732
|
+
const controls = shadowRoot.querySelectorAll("input, textarea, select");
|
|
1733
|
+
assert.ok(controls.length >= 2, "Expected composer file input and textarea");
|
|
1734
|
+
for (const control of controls) {
|
|
1735
|
+
assert.notEqual(
|
|
1736
|
+
control.form,
|
|
1737
|
+
null,
|
|
1738
|
+
`Expected <${control.tagName.toLowerCase()}> to have an owning <form>`
|
|
1739
|
+
);
|
|
1740
|
+
assert.equal(control.form?.getAttribute("autocomplete"), "off");
|
|
1741
|
+
}
|
|
1742
|
+
},
|
|
1743
|
+
{
|
|
1744
|
+
"data-config": JSON.stringify({
|
|
1745
|
+
enabled: true,
|
|
1746
|
+
environment: "production",
|
|
1747
|
+
position: "bottom_right",
|
|
1748
|
+
agent: { enabled: false }
|
|
1749
|
+
})
|
|
1750
|
+
}
|
|
1751
|
+
);
|
|
1752
|
+
});
|
|
1753
|
+
|
|
1754
|
+
it("wraps all shadowRoot form controls in <form autocomplete='off'> and avoids input[type='password'] when agent.enabled is true", async () => {
|
|
1755
|
+
await withMountedWidget(
|
|
1756
|
+
({ shadowRoot }) => {
|
|
1757
|
+
const sidebar = shadowRoot.querySelector(".cd-agent-sidebar");
|
|
1758
|
+
const byokDrawer = shadowRoot.querySelector(".cd-byok-drawer");
|
|
1759
|
+
const byokBtn = shadowRoot.querySelector("[aria-label='Open BYOK API key settings']");
|
|
1760
|
+
const keyInput = shadowRoot.querySelector("[aria-label='Provider API Key']");
|
|
1761
|
+
assert.ok(sidebar && byokDrawer && byokBtn && keyInput);
|
|
1762
|
+
|
|
1763
|
+
// Never mounts any <input type="password"> (uses CSS-masked type="text" instead)
|
|
1764
|
+
assert.equal(shadowRoot.querySelector('input[type="password"]'), null);
|
|
1765
|
+
assert.equal(keyInput.type, "text");
|
|
1766
|
+
assert.equal(keyInput.getAttribute("type"), "text");
|
|
1767
|
+
assert.equal(keyInput.classList.contains("is-masked-secret"), true);
|
|
1768
|
+
assert.equal(keyInput.disabled, true, "BYOK key input stays disabled while drawer is closed");
|
|
1769
|
+
|
|
1770
|
+
// Verify stylesheet masks .cd-input.is-masked-secret with -webkit-text-security: disc
|
|
1771
|
+
const styleEl = shadowRoot.querySelector("style");
|
|
1772
|
+
assert.ok(styleEl);
|
|
1773
|
+
assert.equal(styleEl.textContent.includes("-webkit-text-security: disc"), true);
|
|
1774
|
+
|
|
1775
|
+
// Opening BYOK drawer enables keyInput while still keeping zero input[type="password"]
|
|
1776
|
+
byokBtn.dispatchEvent(new MockUiEvent("click"));
|
|
1777
|
+
assert.equal(byokDrawer.hidden, false);
|
|
1778
|
+
assert.equal(keyInput.disabled, false);
|
|
1779
|
+
assert.equal(shadowRoot.querySelector('input[type="password"]'), null);
|
|
1780
|
+
|
|
1781
|
+
// Every BYOK control has explicit autofill & password-manager extension ignore attributes
|
|
1782
|
+
const byokControls = byokDrawer.querySelectorAll("input, select");
|
|
1783
|
+
assert.equal(byokControls.length, 5);
|
|
1784
|
+
for (const byokCtrl of byokControls) {
|
|
1785
|
+
assert.equal(byokCtrl.getAttribute("autocomplete"), "off");
|
|
1786
|
+
assert.equal(byokCtrl.getAttribute("spellcheck"), "false");
|
|
1787
|
+
assert.equal(byokCtrl.getAttribute("data-1p-ignore"), "true");
|
|
1788
|
+
assert.equal(byokCtrl.getAttribute("data-lpignore"), "true");
|
|
1789
|
+
assert.equal(byokCtrl.getAttribute("data-bwignore"), "true");
|
|
1790
|
+
assert.equal(byokCtrl.getAttribute("data-form-type"), "other");
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
// Every <input>, <textarea>, and <select> across shadowRoot has an owning <form autocomplete="off">
|
|
1794
|
+
const allControls = shadowRoot.querySelectorAll("input, textarea, select");
|
|
1795
|
+
assert.equal(allControls.length, 8);
|
|
1796
|
+
for (const control of allControls) {
|
|
1797
|
+
assert.notEqual(
|
|
1798
|
+
control.form,
|
|
1799
|
+
null,
|
|
1800
|
+
`Expected <${control.tagName.toLowerCase()}> (${control.getAttribute("aria-label") || control.type}) to be owned by a <form>`
|
|
1801
|
+
);
|
|
1802
|
+
assert.equal(control.form?.getAttribute("autocomplete"), "off");
|
|
1803
|
+
assert.notEqual(control.type, "password");
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
// Every owning <form> prevents default navigation on submit
|
|
1807
|
+
const forms = shadowRoot.querySelectorAll("form");
|
|
1808
|
+
assert.ok(forms.length >= 3);
|
|
1809
|
+
for (const form of forms) {
|
|
1810
|
+
assert.equal(form.getAttribute("autocomplete"), "off");
|
|
1811
|
+
const submitEv = new MockUiEvent("submit");
|
|
1812
|
+
form.dispatchEvent(submitEv);
|
|
1813
|
+
assert.equal(submitEv.defaultPrevented, true);
|
|
1814
|
+
}
|
|
1815
|
+
},
|
|
1816
|
+
{
|
|
1817
|
+
"data-config": JSON.stringify({
|
|
1818
|
+
enabled: true,
|
|
1819
|
+
environment: "development",
|
|
1820
|
+
position: "bottom_right",
|
|
1821
|
+
agent: { enabled: true }
|
|
1822
|
+
})
|
|
1823
|
+
}
|
|
1824
|
+
);
|
|
1825
|
+
});
|
|
1826
|
+
|
|
1616
1827
|
it("loads own feedbacks on open, edits message + context inline with draft restoration, and emits context-drop:update", async () => {
|
|
1617
1828
|
const g = globalThis as Record<string, unknown>;
|
|
1618
1829
|
const prevFetch = g.fetch;
|
|
@@ -173,6 +173,13 @@ export const WIDGET_SHADOW_STYLES = `
|
|
|
173
173
|
box-sizing: border-box;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
+
.cd-form-shell {
|
|
177
|
+
display: contents;
|
|
178
|
+
margin: 0;
|
|
179
|
+
padding: 0;
|
|
180
|
+
border: 0;
|
|
181
|
+
}
|
|
182
|
+
|
|
176
183
|
::selection {
|
|
177
184
|
background: var(--cd-pin-soft);
|
|
178
185
|
color: var(--cd-ink);
|
|
@@ -1500,6 +1507,15 @@ select:focus-visible {
|
|
|
1500
1507
|
font-size: 11.5px;
|
|
1501
1508
|
}
|
|
1502
1509
|
|
|
1510
|
+
.cd-input.is-masked-secret {
|
|
1511
|
+
-webkit-text-security: disc;
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
.cd-input.is-masked-secret:placeholder-shown,
|
|
1515
|
+
.cd-input.is-masked-secret:disabled {
|
|
1516
|
+
-webkit-text-security: none;
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1503
1519
|
.cd-drawer-actions {
|
|
1504
1520
|
display: flex;
|
|
1505
1521
|
align-items: center;
|
|
@@ -569,6 +569,7 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
569
569
|
this.setCornerPosition(partial.position);
|
|
570
570
|
}
|
|
571
571
|
const nowAgentEnabled = Boolean(this.config.agent?.enabled);
|
|
572
|
+
this.syncAgentSidebarMount();
|
|
572
573
|
if (nowAgentEnabled && !wasAgentEnabled) {
|
|
573
574
|
this.surfaceMode = "agent";
|
|
574
575
|
if (this.isOpen) {
|
|
@@ -1787,9 +1788,95 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
1787
1788
|
}
|
|
1788
1789
|
}
|
|
1789
1790
|
|
|
1791
|
+
private clearAgentSidebarRefs(): void {
|
|
1792
|
+
this.agentSidebarEl = null;
|
|
1793
|
+
this.sidebarPinBtn = null;
|
|
1794
|
+
this.sidebarEnvPillEl = null;
|
|
1795
|
+
this.sidebarThemeToggleBtn = null;
|
|
1796
|
+
this.sidebarPushBtn = null;
|
|
1797
|
+
this.keyDotEl = null;
|
|
1798
|
+
this.providerPillLabelEl = null;
|
|
1799
|
+
this.keysToggleBtn = null;
|
|
1800
|
+
this.feedbacksToggleBtn = null;
|
|
1801
|
+
this.byokDrawerEl = null;
|
|
1802
|
+
this.byokProviderSelect = null;
|
|
1803
|
+
this.byokModelInput = null;
|
|
1804
|
+
this.byokModelPresetsSelect = null;
|
|
1805
|
+
this.byokBaseUrlField = null;
|
|
1806
|
+
this.byokBaseUrlInput = null;
|
|
1807
|
+
this.byokKeySourceBadge = null;
|
|
1808
|
+
this.byokKeyInput = null;
|
|
1809
|
+
this.feedbacksDrawerEl = null;
|
|
1810
|
+
this.feedbacksTabsEl = null;
|
|
1811
|
+
this.feedbacksListEl = null;
|
|
1812
|
+
this.agentStreamEl = null;
|
|
1813
|
+
this.agentTrayEl = null;
|
|
1814
|
+
this.agentStatusEl = null;
|
|
1815
|
+
this.agentTextareaEl = null;
|
|
1816
|
+
this.agentSendBtn = null;
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
private syncAgentSidebarMount(): void {
|
|
1820
|
+
const enabled = Boolean(this.config.agent?.enabled);
|
|
1821
|
+
if (enabled) {
|
|
1822
|
+
if (!this.agentSidebarEl && this.shadow) {
|
|
1823
|
+
const sidebar = this.buildAgentSidebarDom();
|
|
1824
|
+
sidebar.setAttribute("data-theme", this.currentTheme);
|
|
1825
|
+
if (
|
|
1826
|
+
this.bookCornerBtn &&
|
|
1827
|
+
this.bookCornerBtn.parentNode === this.shadow &&
|
|
1828
|
+
typeof this.shadow.insertBefore === "function"
|
|
1829
|
+
) {
|
|
1830
|
+
this.shadow.insertBefore(sidebar, this.bookCornerBtn);
|
|
1831
|
+
} else {
|
|
1832
|
+
this.shadow.appendChild(sidebar);
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
return;
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
this.isByokDrawerOpen = false;
|
|
1839
|
+
this.isFeedbacksDrawerOpen = false;
|
|
1840
|
+
if (this.agentSidebarEl) {
|
|
1841
|
+
this.agentSidebarEl.parentNode?.removeChild(this.agentSidebarEl);
|
|
1842
|
+
}
|
|
1843
|
+
this.clearAgentSidebarRefs();
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
private buildFormShell(): HTMLFormElement {
|
|
1847
|
+
const form = document.createElement("form");
|
|
1848
|
+
form.className = "cd-form-shell";
|
|
1849
|
+
form.autocomplete = "off";
|
|
1850
|
+
form.setAttribute("autocomplete", "off");
|
|
1851
|
+
form.noValidate = true;
|
|
1852
|
+
form.setAttribute("novalidate", "");
|
|
1853
|
+
form.setAttribute("data-1p-ignore", "true");
|
|
1854
|
+
form.setAttribute("data-lpignore", "true");
|
|
1855
|
+
form.setAttribute("data-bwignore", "true");
|
|
1856
|
+
form.setAttribute("data-form-type", "other");
|
|
1857
|
+
form.addEventListener("submit", (ev) => {
|
|
1858
|
+
ev.preventDefault();
|
|
1859
|
+
});
|
|
1860
|
+
return form;
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
private applyByokAutofillIgnore(control: HTMLInputElement | HTMLSelectElement): void {
|
|
1864
|
+
control.autocomplete = "off";
|
|
1865
|
+
control.setAttribute("autocomplete", "off");
|
|
1866
|
+
control.spellcheck = false;
|
|
1867
|
+
control.setAttribute("spellcheck", "false");
|
|
1868
|
+
control.setAttribute("autocorrect", "off");
|
|
1869
|
+
control.setAttribute("autocapitalize", "off");
|
|
1870
|
+
control.setAttribute("data-1p-ignore", "true");
|
|
1871
|
+
control.setAttribute("data-lpignore", "true");
|
|
1872
|
+
control.setAttribute("data-bwignore", "true");
|
|
1873
|
+
control.setAttribute("data-form-type", "other");
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1790
1876
|
private renderShadowDom(): void {
|
|
1791
1877
|
if (!this.shadow) return;
|
|
1792
1878
|
this.shadow.innerHTML = "";
|
|
1879
|
+
this.clearAgentSidebarRefs();
|
|
1793
1880
|
|
|
1794
1881
|
const styleEl = document.createElement("style");
|
|
1795
1882
|
styleEl.textContent = WIDGET_SHADOW_STYLES;
|
|
@@ -1809,9 +1896,11 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
1809
1896
|
|
|
1810
1897
|
this.shadow.appendChild(root);
|
|
1811
1898
|
|
|
1812
|
-
// 3. Docked Local BYOK Agentic Coding Sidebar (
|
|
1813
|
-
|
|
1814
|
-
|
|
1899
|
+
// 3. Docked Local BYOK Agentic Coding Sidebar (mounted only when local agent is enabled)
|
|
1900
|
+
if (Boolean(this.config.agent?.enabled)) {
|
|
1901
|
+
const sidebar = this.buildAgentSidebarDom();
|
|
1902
|
+
this.shadow.appendChild(sidebar);
|
|
1903
|
+
}
|
|
1815
1904
|
|
|
1816
1905
|
// 4. Book-Corner Fold Launcher (flush at viewport corner, peels into pushpin on drag)
|
|
1817
1906
|
const bookCorner = document.createElement("button");
|
|
@@ -2071,8 +2160,13 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
2071
2160
|
this.statusEl = status;
|
|
2072
2161
|
composer.appendChild(status);
|
|
2073
2162
|
|
|
2163
|
+
const composerForm = this.buildFormShell();
|
|
2164
|
+
|
|
2074
2165
|
const fileInput = document.createElement("input");
|
|
2075
2166
|
fileInput.type = "file";
|
|
2167
|
+
fileInput.setAttribute("type", "file");
|
|
2168
|
+
fileInput.autocomplete = "off";
|
|
2169
|
+
fileInput.setAttribute("autocomplete", "off");
|
|
2076
2170
|
fileInput.multiple = true;
|
|
2077
2171
|
fileInput.accept = this.config.limits.allowed_content_types.join(",");
|
|
2078
2172
|
fileInput.hidden = true;
|
|
@@ -2083,7 +2177,7 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
2083
2177
|
}
|
|
2084
2178
|
});
|
|
2085
2179
|
this.fileInputEl = fileInput;
|
|
2086
|
-
|
|
2180
|
+
composerForm.appendChild(fileInput);
|
|
2087
2181
|
|
|
2088
2182
|
const promptShell = document.createElement("div");
|
|
2089
2183
|
promptShell.className = "cd-prompt-shell";
|
|
@@ -2115,6 +2209,12 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
2115
2209
|
|
|
2116
2210
|
const textarea = document.createElement("textarea");
|
|
2117
2211
|
textarea.className = "cd-textarea";
|
|
2212
|
+
textarea.autocomplete = "off";
|
|
2213
|
+
textarea.setAttribute("autocomplete", "off");
|
|
2214
|
+
textarea.setAttribute("data-1p-ignore", "true");
|
|
2215
|
+
textarea.setAttribute("data-lpignore", "true");
|
|
2216
|
+
textarea.setAttribute("data-bwignore", "true");
|
|
2217
|
+
textarea.setAttribute("data-form-type", "other");
|
|
2118
2218
|
textarea.placeholder = this.config.placeholder;
|
|
2119
2219
|
textarea.setAttribute("aria-label", "Feedback description");
|
|
2120
2220
|
textarea.addEventListener("keydown", (ev) => {
|
|
@@ -2157,7 +2257,8 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
2157
2257
|
toolbar.appendChild(actions);
|
|
2158
2258
|
toolbar.appendChild(submitBtn);
|
|
2159
2259
|
promptShell.appendChild(toolbar);
|
|
2160
|
-
|
|
2260
|
+
composerForm.appendChild(promptShell);
|
|
2261
|
+
composer.appendChild(composerForm);
|
|
2161
2262
|
|
|
2162
2263
|
return composer;
|
|
2163
2264
|
}
|
|
@@ -2414,11 +2515,19 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
2414
2515
|
this.agentStatusEl = agentStatus;
|
|
2415
2516
|
sidebar.appendChild(agentStatus);
|
|
2416
2517
|
|
|
2518
|
+
const agentPromptForm = this.buildFormShell();
|
|
2519
|
+
|
|
2417
2520
|
const promptShell = document.createElement("div");
|
|
2418
2521
|
promptShell.className = "cd-prompt-shell";
|
|
2419
2522
|
|
|
2420
2523
|
const textarea = document.createElement("textarea");
|
|
2421
2524
|
textarea.className = "cd-textarea";
|
|
2525
|
+
textarea.autocomplete = "off";
|
|
2526
|
+
textarea.setAttribute("autocomplete", "off");
|
|
2527
|
+
textarea.setAttribute("data-1p-ignore", "true");
|
|
2528
|
+
textarea.setAttribute("data-lpignore", "true");
|
|
2529
|
+
textarea.setAttribute("data-bwignore", "true");
|
|
2530
|
+
textarea.setAttribute("data-form-type", "other");
|
|
2422
2531
|
textarea.placeholder =
|
|
2423
2532
|
"Ask the local agent to inspect pinned DOM elements, read Rails views, or propose a fix...";
|
|
2424
2533
|
textarea.setAttribute("aria-label", "Agent prompt");
|
|
@@ -2451,7 +2560,8 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
2451
2560
|
|
|
2452
2561
|
toolbar.appendChild(sendBtn);
|
|
2453
2562
|
promptShell.appendChild(toolbar);
|
|
2454
|
-
|
|
2563
|
+
agentPromptForm.appendChild(promptShell);
|
|
2564
|
+
sidebar.appendChild(agentPromptForm);
|
|
2455
2565
|
|
|
2456
2566
|
this.syncProviderControls();
|
|
2457
2567
|
return sidebar;
|
|
@@ -2468,6 +2578,8 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
2468
2578
|
securityNote.innerHTML = `${ICON_SHIELD}<span>Keys stay encrypted on disk in <code>tmp/context_drop_byok.enc</code> (AES-256-GCM) or read from server ENV—never stored in browser storage.</span>`;
|
|
2469
2579
|
drawer.appendChild(securityNote);
|
|
2470
2580
|
|
|
2581
|
+
const byokForm = this.buildFormShell();
|
|
2582
|
+
|
|
2471
2583
|
const grid = document.createElement("div");
|
|
2472
2584
|
grid.className = "cd-form-grid";
|
|
2473
2585
|
|
|
@@ -2480,6 +2592,7 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
2480
2592
|
const provSelect = document.createElement("select");
|
|
2481
2593
|
provSelect.className = "cd-select";
|
|
2482
2594
|
provSelect.setAttribute("aria-label", "LLM Provider");
|
|
2595
|
+
this.applyByokAutofillIgnore(provSelect);
|
|
2483
2596
|
provSelect.addEventListener("change", () => {
|
|
2484
2597
|
this.selectedVaultProviderId = provSelect.value;
|
|
2485
2598
|
this.syncByokDrawerFields();
|
|
@@ -2498,6 +2611,7 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
2498
2611
|
const presetSelect = document.createElement("select");
|
|
2499
2612
|
presetSelect.className = "cd-select";
|
|
2500
2613
|
presetSelect.setAttribute("aria-label", "Model preset");
|
|
2614
|
+
this.applyByokAutofillIgnore(presetSelect);
|
|
2501
2615
|
presetSelect.addEventListener("change", () => {
|
|
2502
2616
|
if (this.byokModelInput && presetSelect.value) {
|
|
2503
2617
|
this.byokModelInput.value = presetSelect.value;
|
|
@@ -2516,8 +2630,10 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
2516
2630
|
modelLabel.textContent = "Model ID";
|
|
2517
2631
|
const modelInput = document.createElement("input");
|
|
2518
2632
|
modelInput.type = "text";
|
|
2633
|
+
modelInput.setAttribute("type", "text");
|
|
2519
2634
|
modelInput.className = "cd-input is-mono";
|
|
2520
2635
|
modelInput.setAttribute("aria-label", "Model identifier");
|
|
2636
|
+
this.applyByokAutofillIgnore(modelInput);
|
|
2521
2637
|
this.byokModelInput = modelInput;
|
|
2522
2638
|
modelField.appendChild(modelLabel);
|
|
2523
2639
|
modelField.appendChild(modelInput);
|
|
@@ -2532,16 +2648,19 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
2532
2648
|
baseUrlLabel.textContent = "OpenAI-Compatible Base URL";
|
|
2533
2649
|
const baseUrlInput = document.createElement("input");
|
|
2534
2650
|
baseUrlInput.type = "url";
|
|
2651
|
+
baseUrlInput.setAttribute("type", "url");
|
|
2535
2652
|
baseUrlInput.className = "cd-input is-mono";
|
|
2536
2653
|
baseUrlInput.placeholder = "https://openrouter.ai/api/v1 or http://localhost:11434/v1";
|
|
2537
2654
|
baseUrlInput.setAttribute("aria-label", "Custom OpenAI-compatible Base URL");
|
|
2655
|
+
this.applyByokAutofillIgnore(baseUrlInput);
|
|
2538
2656
|
this.byokBaseUrlInput = baseUrlInput;
|
|
2539
2657
|
baseUrlField.appendChild(baseUrlLabel);
|
|
2540
2658
|
baseUrlField.appendChild(baseUrlInput);
|
|
2541
2659
|
this.byokBaseUrlField = baseUrlField;
|
|
2542
2660
|
grid.appendChild(baseUrlField);
|
|
2543
2661
|
|
|
2544
|
-
// API Key field
|
|
2662
|
+
// API Key field — uses CSS-masked type="text" rather than type="password" so Chromium/browser
|
|
2663
|
+
// password managers never classify preceding or host-page inputs as login username fields.
|
|
2545
2664
|
const keyField = document.createElement("div");
|
|
2546
2665
|
keyField.className = "cd-field is-full";
|
|
2547
2666
|
const keyLabel = document.createElement("label");
|
|
@@ -2556,17 +2675,20 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
2556
2675
|
keyLabel.appendChild(keyBadge);
|
|
2557
2676
|
|
|
2558
2677
|
const keyInput = document.createElement("input");
|
|
2559
|
-
keyInput.type = "
|
|
2560
|
-
keyInput.
|
|
2561
|
-
keyInput.className = "cd-input is-mono";
|
|
2678
|
+
keyInput.type = "text";
|
|
2679
|
+
keyInput.setAttribute("type", "text");
|
|
2680
|
+
keyInput.className = "cd-input is-mono is-masked-secret";
|
|
2562
2681
|
keyInput.placeholder = "Paste API key (leave blank to keep existing key)";
|
|
2563
2682
|
keyInput.setAttribute("aria-label", "Provider API Key");
|
|
2683
|
+
keyInput.disabled = !this.isByokDrawerOpen;
|
|
2684
|
+
this.applyByokAutofillIgnore(keyInput);
|
|
2564
2685
|
this.byokKeyInput = keyInput;
|
|
2565
2686
|
keyField.appendChild(keyLabel);
|
|
2566
2687
|
keyField.appendChild(keyInput);
|
|
2567
2688
|
grid.appendChild(keyField);
|
|
2568
2689
|
|
|
2569
|
-
|
|
2690
|
+
byokForm.appendChild(grid);
|
|
2691
|
+
drawer.appendChild(byokForm);
|
|
2570
2692
|
|
|
2571
2693
|
const actions = document.createElement("div");
|
|
2572
2694
|
actions.className = "cd-drawer-actions";
|
|
@@ -3483,6 +3605,9 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
3483
3605
|
if (this.byokDrawerEl) {
|
|
3484
3606
|
this.byokDrawerEl.hidden = !this.isByokDrawerOpen;
|
|
3485
3607
|
}
|
|
3608
|
+
if (this.byokKeyInput) {
|
|
3609
|
+
this.byokKeyInput.disabled = !this.isByokDrawerOpen;
|
|
3610
|
+
}
|
|
3486
3611
|
if (this.keysToggleBtn) {
|
|
3487
3612
|
this.keysToggleBtn.classList.toggle("is-active", this.isByokDrawerOpen);
|
|
3488
3613
|
}
|
data/lib/context_drop/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: context_drop
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kemal Elmizan
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: actionpack
|