commit 28fd2dd0a2cf7a6a3fb372add49c601429376930
parent 837df38629f229a8569cee836c87e6ac5b65329a
Author: Narcis Beleuzu <nbeleuzu@mozilla.com>
Date: Tue, 7 Oct 2025 01:24:13 +0300
Revert "Bug 1990881 - basic intent ask vs search vs navigate heuristic r=Mardak,firefox-ai-ml-reviewers" for causing lint failure on smart-assist.mjs
This reverts commit 77b6142c6c32aaa04bae0946f7d197ef9c67aca8.
Diffstat:
3 files changed, 5 insertions(+), 84 deletions(-)
diff --git a/browser/components/genai/SmartAssistEngine.sys.mjs b/browser/components/genai/SmartAssistEngine.sys.mjs
@@ -210,31 +210,4 @@ export const SmartAssistEngine = {
convo = [...convo, assistantToolMsg, ...toolResultMessages];
}
},
-
- /**
- *
- * @param {string} prompt
- * @returns {string} "search" | "chat"
- */
- async getPromptIntent(prompt) {
- // TODO : this is mock logic to determine if the user wants to search or chat
- // We will eventually want to use a model to determine this intent
- const searchKeywords = [
- "search",
- "find",
- "look",
- "query",
- "locate",
- "explore",
- ];
- const formattedPrompt = prompt.toLowerCase();
-
- const intent = searchKeywords.some(keyword =>
- formattedPrompt.includes(keyword)
- )
- ? "search"
- : "chat";
-
- return intent;
- },
};
diff --git a/browser/components/genai/content/smart-assist.mjs b/browser/components/genai/content/smart-assist.mjs
@@ -29,7 +29,6 @@ export class SmartAssist extends MozLitElement {
mode: { type: String }, // "tab" | "sidebar"
overrideNewTab: { type: Boolean },
showLog: { type: Boolean },
- actionKey: { type: String }, // "chat" | "search"
};
constructor() {
@@ -46,20 +45,6 @@ export class SmartAssist extends MozLitElement {
this.overrideNewTab = Services.prefs.getBoolPref(
"browser.ml.smartAssist.overrideNewTab"
);
- this.actionKey = "chat";
-
- this._actions = {
- chat: {
- label: "Submit",
- icon: "chrome://global/skin/icons/arrow-right.svg",
- run: this._actionChat,
- },
- search: {
- label: "Search",
- icon: "chrome://global/skin/icons/search-glass.svg",
- run: this._actionSearch,
- },
- };
}
connectedCallback() {
@@ -85,28 +70,12 @@ export class SmartAssist extends MozLitElement {
this.logState = [...this.logState, entryWithDate];
};
- _handlePromptInput = async e => {
+ _handlePromptInput = e => {
const value = e.target.value;
this.userPrompt = value;
-
- // Determine intent based on keywords in the prompt
- this.actionKey = await lazy.SmartAssistEngine.getPromptIntent(value);
- };
-
- /**
- * Returns the current action object based on the actionKey
- */
-
- get inputAction() {
- return this._actions[this.actionKey];
- }
-
- _actionSearch = () => {
- // TODO: Implement search functionality
};
- _actionChat = async () => {
- console.log("this", this);
+ _handleSubmit = async () => {
const formattedPrompt = (this.userPrompt || "").trim();
if (!formattedPrompt) {
return;
@@ -157,7 +126,7 @@ export class SmartAssist extends MozLitElement {
* Mock Functionality to open full page UX
*
* @param {boolean} enable
- * Whether or not to override the new tab page.
+ * Whether or not to override the new tab page.
*/
_applyNewTabOverride(enable) {
try {
@@ -254,14 +223,12 @@ export class SmartAssist extends MozLitElement {
@input=${e => this._handlePromptInput(e)}
></textarea>
<moz-button
- iconSrc=${this.inputAction.icon}
id="submit-user-prompt-btn"
type="primary"
size="small"
- @click=${this.inputAction.run}
- iconPosition="end"
+ @click=${this._handleSubmit}
>
- ${this.inputAction.label}
+ Submit
</moz-button>
<!-- Footer - New Tab Override -->
diff --git a/browser/components/genai/tests/xpcshell/test_smart_assist_engine.js b/browser/components/genai/tests/xpcshell/test_smart_assist_engine.js
@@ -177,22 +177,3 @@ add_task(async function test_fetchWithHistory_propagates_stream_error() {
sb.restore();
}
});
-
-add_task(async function test_getPromptIntent_basic() {
- const cases = [
- { prompt: "please search for news on firefox", expected: "search" },
- { prompt: "Can you FIND me the docs for PageAssist?", expected: "search" }, // case-insensitive
- { prompt: "look up the best pizza in SF", expected: "search" },
- { prompt: "hello there, how are you?", expected: "chat" },
- { prompt: "tell me a joke", expected: "chat" },
- ];
-
- for (const { prompt, expected } of cases) {
- const intent = await SmartAssistEngine.getPromptIntent(prompt);
- Assert.equal(
- intent,
- expected,
- `getPromptIntent("${prompt}") should return "${expected}"`
- );
- }
-});