commit b2ffc3c765af4e6c2431c94a7704dd6b44c32cd4
parent 2a1ce8fc5cd3af7de9af3c17457c60e2b6cbb254
Author: Florian Zia <fzia@mozilla.com>
Date: Wed, 31 Dec 2025 21:26:44 +0000
Bug 2003063 - Part 3: Add smartbar to sidebar for dev r=mak,ai-frontend-reviewers
Integrates SmartbarInput into the AI Window sidebar for development and testing purposes. This provides a working environment for iterating on multiline behavior and unblocks frontend work on chat interactions.
Differential Revision: https://phabricator.services.mozilla.com/D276457
Diffstat:
2 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/browser/components/genai/content/smart-assist.mjs b/browser/components/genai/content/smart-assist.mjs
@@ -277,18 +277,16 @@ export class SmartAssist extends MozLitElement {
*/
_getOrCreateBrowser(chromeDoc, box) {
- // Find existing browser, or create it the first time we open the sidebar.
- let browser = chromeDoc.getElementById("ai-window-browser");
-
- if (!browser) {
- const stack =
- box.querySelector(".ai-window-browser-stack") ||
- chromeDoc.createXULElement("stack");
-
+ let stack = box.querySelector(".ai-window-browser-stack");
+ if (!stack) {
+ stack = chromeDoc.createXULElement("stack");
stack.className = "ai-window-browser-stack";
stack.setAttribute("flex", "1");
box.appendChild(stack);
+ }
+ let browser = stack.querySelector("#ai-window-browser");
+ if (!browser) {
browser = chromeDoc.createXULElement("browser");
browser.setAttribute("id", "ai-window-browser");
browser.setAttribute("flex", "1");
@@ -303,15 +301,16 @@ export class SmartAssist extends MozLitElement {
stack.appendChild(browser);
}
+ return stack;
}
/**
* Helper method to get or create the smartbar element
*
* @param {Document} chromeDoc - The chrome document
- * @param {Element} box - The container element
+ * @param {Element} container - The container element
*/
- _getOrCreateSmartbar(chromeDoc, box) {
+ _getOrCreateSmartbar(chromeDoc, container) {
// Find existing Smartbar, or create it the first time we open the sidebar.
let smartbar = chromeDoc.getElementById("ai-window-smartbar");
@@ -322,7 +321,7 @@ export class SmartAssist extends MozLitElement {
smartbar.setAttribute("pageproxystate", "invalid");
smartbar.setAttribute("popover", "manual");
smartbar.classList.add("smartbar", "urlbar");
- box.append(smartbar);
+ container.append(smartbar);
}
return smartbar;
}
@@ -336,8 +335,8 @@ export class SmartAssist extends MozLitElement {
return;
}
- this._getOrCreateBrowser(chromeDoc, box);
- this._getOrCreateSmartbar(chromeDoc, box);
+ const stack = this._getOrCreateBrowser(chromeDoc, box);
+ this._getOrCreateSmartbar(chromeDoc, stack);
// Toggle visibility
const opening = box.hidden;
diff --git a/browser/components/urlbar/content/SmartbarInput.mjs b/browser/components/urlbar/content/SmartbarInput.mjs
@@ -5384,6 +5384,19 @@ export class SmartbarInput extends HTMLElement {
return;
}
+ if (
+ this.#isSmartbarMode &&
+ event.keyCode === KeyEvent.DOM_VK_RETURN &&
+ event.shiftKey
+ ) {
+ event.preventDefault();
+ return;
+ }
+
+ if (!this.controller) {
+ return;
+ }
+
// Repeated KeyboardEvents can easily cause subtle bugs in this logic, if
// not properly handled, so let's first handle things that should not be
// evaluated repeatedly.