feat: Add learning for omnibox commands, p=#10564

This commit is contained in:
mr. m
2025-09-27 00:53:25 +02:00
committed by GitHub
parent df1e759c8d
commit 403d5ae92e
24 changed files with 419 additions and 349 deletions

View File

@@ -1,8 +1,8 @@
diff --git a/browser/components/sessionstore/TabState.sys.mjs b/browser/components/sessionstore/TabState.sys.mjs
index 82721356d191055bec0d4b0ca49e481221988801..9c8a2b1791e780e0fcd3a9bfc7efdadf35d52165 100644
index 82721356d191055bec0d4b0ca49e481221988801..1ea5c394c704da295149443d7794961a12f2060b 100644
--- a/browser/components/sessionstore/TabState.sys.mjs
+++ b/browser/components/sessionstore/TabState.sys.mjs
@@ -85,6 +85,18 @@ class _TabState {
@@ -85,7 +85,22 @@ class _TabState {
tabData.groupId = tab.group.id;
}
@@ -19,5 +19,9 @@ index 82721356d191055bec0d4b0ca49e481221988801..9c8a2b1791e780e0fcd3a9bfc7efdadf
+ tabData.zenIsGlance = tab.hasAttribute("zen-glance-tab");
+
tabData.searchMode = tab.ownerGlobal.gURLBar.getSearchMode(browser, true);
+ if (tabData.searchMode?.source === tab.ownerGlobal.UrlbarUtils.RESULT_SOURCE.ZEN_ACTIONS) {
+ delete tabData.searchMode;
+ }
tabData.userContextId = tab.userContextId || 0;

View File

@@ -1,13 +1,13 @@
diff --git a/browser/components/urlbar/UrlbarController.sys.mjs b/browser/components/urlbar/UrlbarController.sys.mjs
index 36e3ab4a5a153230bb488b66dda7e3e7c763ca23..28b59c7c3a95febafc3f2a6e0ac3493b9785ff1a 100644
index 36e3ab4a5a153230bb488b66dda7e3e7c763ca23..81f2944b939ac0963c129f86aab0b55817349401 100644
--- a/browser/components/urlbar/UrlbarController.sys.mjs
+++ b/browser/components/urlbar/UrlbarController.sys.mjs
@@ -411,7 +411,7 @@ export class UrlbarController {
// When there's no search string and no view selection, we want to focus
// the next toolbar item instead, for accessibility reasons.
let allowTabbingThroughResults =
- this.input.focusedViaMousedown ||
+ true ||
this.input.searchMode?.isPreview ||
this.input.searchMode?.source ==
lazy.UrlbarUtils.RESULT_SOURCE.ACTIONS ||
@@ -434,6 +434,8 @@ export class UrlbarController {
});
}
event.preventDefault();
+ } else {
+ this.browserWindow.gZenUIManager.enableCommandsMode(event);
}
break;
}

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/urlbar/UrlbarInput.sys.mjs b/browser/components/urlbar/UrlbarInput.sys.mjs
index 1c447bd31de854d1522dbcfb5d7ad557c84f1388..2341d04c5afee303ce4150c3c2c563851ae89385 100644
index 1c447bd31de854d1522dbcfb5d7ad557c84f1388..1dc520f63b240cccda7be074346d2079774eed27 100644
--- a/browser/components/urlbar/UrlbarInput.sys.mjs
+++ b/browser/components/urlbar/UrlbarInput.sys.mjs
@@ -74,6 +74,13 @@ ChromeUtils.defineLazyGetter(lazy, "logger", () =>
@@ -184,7 +184,20 @@ index 1c447bd31de854d1522dbcfb5d7ad557c84f1388..2341d04c5afee303ce4150c3c2c56385
let controller =
this.document.commandDispatcher.getControllerForCommand("cmd_paste");
@@ -4130,6 +4195,7 @@ export class UrlbarInput {
@@ -3836,7 +3901,11 @@ export class UrlbarInput {
if (!engineName && !source && !this.hasAttribute("searchmode")) {
return;
}
-
+ this.window.dispatchEvent(
+ new CustomEvent("Zen:UrlbarSearchModeChanged", {
+ detail: { searchMode },
+ })
+ );
this._searchModeIndicatorTitle.textContent = "";
this._searchModeIndicatorTitle.removeAttribute("data-l10n-id");
@@ -4130,6 +4199,7 @@ export class UrlbarInput {
this.document.l10n.setAttributes(
this.inputField,
@@ -192,7 +205,7 @@ index 1c447bd31de854d1522dbcfb5d7ad557c84f1388..2341d04c5afee303ce4150c3c2c56385
l10nId,
l10nId == "urlbar-placeholder-with-name" ? { name } : undefined
);
@@ -4241,6 +4307,11 @@ export class UrlbarInput {
@@ -4241,6 +4311,11 @@ export class UrlbarInput {
}
_on_click(event) {
@@ -204,7 +217,7 @@ index 1c447bd31de854d1522dbcfb5d7ad557c84f1388..2341d04c5afee303ce4150c3c2c56385
if (
event.target == this.inputField ||
event.target == this._inputContainer
@@ -4311,7 +4382,7 @@ export class UrlbarInput {
@@ -4311,7 +4386,7 @@ export class UrlbarInput {
}
}
@@ -213,7 +226,7 @@ index 1c447bd31de854d1522dbcfb5d7ad557c84f1388..2341d04c5afee303ce4150c3c2c56385
this.view.autoOpen({ event });
} else {
if (this._untrimOnFocusAfterKeydown) {
@@ -4351,9 +4422,16 @@ export class UrlbarInput {
@@ -4351,9 +4426,16 @@ export class UrlbarInput {
}
_on_mousedown(event) {
@@ -231,7 +244,7 @@ index 1c447bd31de854d1522dbcfb5d7ad557c84f1388..2341d04c5afee303ce4150c3c2c56385
if (
event.target != this.inputField &&
@@ -4364,6 +4442,10 @@ export class UrlbarInput {
@@ -4364,6 +4446,10 @@ export class UrlbarInput {
this.focusedViaMousedown = !this.focused;
this._preventClickSelectsAll = this.focused;
@@ -242,7 +255,7 @@ index 1c447bd31de854d1522dbcfb5d7ad557c84f1388..2341d04c5afee303ce4150c3c2c56385
// Keep the focus status, since the attribute may be changed
// upon calling this.focus().
@@ -4399,7 +4481,7 @@ export class UrlbarInput {
@@ -4399,7 +4485,7 @@ export class UrlbarInput {
}
// Don't close the view when clicking on a tab; we may want to keep the
// view open on tab switch, and the TabSelect event arrived earlier.
@@ -251,3 +264,12 @@ index 1c447bd31de854d1522dbcfb5d7ad557c84f1388..2341d04c5afee303ce4150c3c2c56385
break;
}
@@ -4716,7 +4802,7 @@ export class UrlbarInput {
// When we are in actions search mode we can show more results so
// increase the limit.
let maxResults =
- this.searchMode?.source != lazy.UrlbarUtils.RESULT_SOURCE.ACTIONS
+ this.searchMode?.source != lazy.UrlbarUtils.RESULT_SOURCE.ZEN_ACTIONS
? lazy.UrlbarPrefs.get("maxRichResults")
: UNLIMITED_MAX_RESULTS;
let options = {

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/urlbar/UrlbarMuxerStandard.sys.mjs b/browser/components/urlbar/UrlbarMuxerStandard.sys.mjs
index cdc476a3eb2ee2cb6193d215513b65ed375f6153..a2b106916d6cca25096d37b80bea45f016ad82a5 100644
index cdc476a3eb2ee2cb6193d215513b65ed375f6153..bc66d9651e521bda75a3bb9e7f1e4b3bb325be90 100644
--- a/browser/components/urlbar/UrlbarMuxerStandard.sys.mjs
+++ b/browser/components/urlbar/UrlbarMuxerStandard.sys.mjs
@@ -855,6 +855,7 @@ class MuxerUnifiedComplete extends UrlbarMuxer {
@@ -10,3 +10,13 @@ index cdc476a3eb2ee2cb6193d215513b65ed375f6153..a2b106916d6cca25096d37b80bea45f0
// Discard the result if a tab-to-search result was added already.
if (!state.canAddTabToSearch) {
return false;
@@ -1501,7 +1502,9 @@ class MuxerUnifiedComplete extends UrlbarMuxer {
usedLimits.maxResultCount++;
}
+ if (!(result.heuristic && result.source == UrlbarUtils.RESULT_SOURCE.ZEN_ACTIONS)) {
state.usedResultSpan += span;
+ }
this._updateStatePostAdd(result, state);
return true;

View File

@@ -1,12 +1,12 @@
diff --git a/browser/components/urlbar/UrlbarPrefs.sys.mjs b/browser/components/urlbar/UrlbarPrefs.sys.mjs
index 3c179db3b310c43f8c6c06b1ecbcf5ed59feefe6..693bef15401cd4428c8a0222de57b83b78564194 100644
index 3c179db3b310c43f8c6c06b1ecbcf5ed59feefe6..d9d2ce116ebcee8d403e165066c3a569bb952cd2 100644
--- a/browser/components/urlbar/UrlbarPrefs.sys.mjs
+++ b/browser/components/urlbar/UrlbarPrefs.sys.mjs
@@ -719,6 +719,7 @@ function makeResultGroups({ showSearchSuggestionsFirst }) {
*/
let rootGroup = {
children: [
+ { group: lazy.UrlbarUtils.RESULT_GROUP.ZEN_ACTION },
+ { children: [{ group: lazy.UrlbarUtils.RESULT_GROUP.ZEN_ACTION }] },
// heuristic
{
maxResultCount: 1,

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/urlbar/UrlbarUtils.sys.mjs b/browser/components/urlbar/UrlbarUtils.sys.mjs
index 0bc15c02f56dd8f46a21fed02b4e21a741f27f41..b69a4d34f700637bd352620c520b989cf00fa39f 100644
index 0bc15c02f56dd8f46a21fed02b4e21a741f27f41..40da868f68f21d8411107fb8a95e2d0b74337b51 100644
--- a/browser/components/urlbar/UrlbarUtils.sys.mjs
+++ b/browser/components/urlbar/UrlbarUtils.sys.mjs
@@ -75,6 +75,7 @@ export var UrlbarUtils = {
@@ -10,12 +10,20 @@ index 0bc15c02f56dd8f46a21fed02b4e21a741f27f41..b69a4d34f700637bd352620c520b989c
}),
// Defines provider types.
@@ -576,6 +577,8 @@ export var UrlbarUtils = {
return this.RESULT_GROUP.INPUT_HISTORY;
case "UrlbarProviderQuickSuggest":
return this.RESULT_GROUP.GENERAL_PARENT;
+ case "ZenUrlbarProviderGlobalActions":
+ return this.RESULT_GROUP.ZEN_ACTION;
default:
break;
}
@@ -134,6 +135,7 @@ export var UrlbarUtils = {
OTHER_NETWORK: 6,
ADDON: 7,
ACTIONS: 8,
+ ZEN_ACTIONS: 9,
}),
// Per-result exposure telemetry.
@@ -553,6 +555,8 @@ export var UrlbarUtils = {
return this.RESULT_GROUP.HEURISTIC_SEARCH_TIP;
case "HistoryUrlHeuristic":
return this.RESULT_GROUP.HEURISTIC_HISTORY_URL;
+ case "ZenUrlbarProviderGlobalActions":
+ return this.RESULT_GROUP.ZEN_ACTION;
default:
if (result.providerName.startsWith("TestProvider")) {
return this.RESULT_GROUP.HEURISTIC_TEST;

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/urlbar/UrlbarView.sys.mjs b/browser/components/urlbar/UrlbarView.sys.mjs
index fdbab8806fd320f4aacec46a42c8ef953580d00c..e23fae0d7e0b71d74899c11c229359864cd7e427 100644
index fdbab8806fd320f4aacec46a42c8ef953580d00c..031a615ad09274c578184b129434bbd93b49353d 100644
--- a/browser/components/urlbar/UrlbarView.sys.mjs
+++ b/browser/components/urlbar/UrlbarView.sys.mjs
@@ -613,7 +613,7 @@ export class UrlbarView {
@@ -11,39 +11,7 @@ index fdbab8806fd320f4aacec46a42c8ef953580d00c..e23fae0d7e0b71d74899c11c22935986
// Try to reuse the cached top-sites context. If it's not cached, then
// there will be a gap of time between when the input is focused and
// when the view opens that can be perceived as flicker.
@@ -824,6 +824,31 @@ export class UrlbarView {
// still associated with the first result.
this.input.setResultForCurrentValue(firstResult);
}
+ if (queryContext.results[0].payload.zenAction) {
+ this.#selectElement(this.getFirstSelectableElement(), {
+ updateInput: false,
+ setAccessibleFocus:
+ this.controller._userSelectionBehavior == "arrow",
+ });
+ this.window.setTimeout(() => {
+ this.window.setTimeout(() => {
+ this.#selectElement(this.getFirstSelectableElement(), {
+ updateInput: false,
+ setAccessibleFocus:
+ this.controller._userSelectionBehavior == "arrow",
+ });
+ });
+ });
+ }
+ this.window.setTimeout(() => {
+ if (queryContext.results[0].payload.zenAction) {
+ this.#selectElement(this.getFirstSelectableElement(), {
+ updateInput: false,
+ setAccessibleFocus:
+ this.controller._userSelectionBehavior == "arrow",
+ });
+ }
+ }, 220);
}
// Announce tab-to-search results to screen readers as the user types.
@@ -2706,6 +2731,8 @@ export class UrlbarView {
@@ -2706,6 +2706,8 @@ export class UrlbarView {
if (row?.hasAttribute("row-selectable")) {
row?.toggleAttribute("selected", true);
}
@@ -52,7 +20,7 @@ index fdbab8806fd320f4aacec46a42c8ef953580d00c..e23fae0d7e0b71d74899c11c22935986
if (element != row) {
row?.toggleAttribute("descendant-selected", true);
}
@@ -3189,7 +3216,7 @@ export class UrlbarView {
@@ -3189,7 +3191,7 @@ export class UrlbarView {
}
#enableOrDisableRowWrap() {