VOOZH about

URL: https://phabricator.services.mozilla.com/D307140

⇱ ⚙ D307140 Bug 2047002 - Mock and wire NL tab grouping tool-call flows r=omarg,yjamora


Bug 2047002 - Mock and wire NL tab grouping tool-call flows r=omarg,yjamora
Needs ReviewPublic

Authored by ngrato on Tue, Jun 16, 9:49 PM.

Details

Reviewers
omarg
yjamora
Group Reviewers
Restricted Project
Bugzilla Bug ID
2047002

Diff Detail

Repository
rFIREFOXAUTOLAND firefox-autoland
Branch
HEAD

Event Timeline

ngrato created this revision.
phab-bot changed the visibility from "Custom Policy" to "Public (No Login Required)".Tue, Jun 16, 9:49 PM
phab-bot changed the edit policy from "Custom Policy" to "Restricted Project (Project)".
phab-bot removed a project: secure-revision.
browser/components/aiwindow/ui/modules/ToolUI.sys.mjs
128

just moving to "public API" section

ngrato updated this revision to Diff 1302630.
ngrato updated this revision to Diff 1302699.
ngrato retitled this revision from WIP: Bug 2047002 - Mock and wire NL tab grouping tool-call flows r=omarg,yjamora to Bug 2047002 - Mock and wire NL tab grouping tool-call flows r=omarg,yjamora.
flod requested changes to this revision.Wed, Jun 17, 6:04 PM
flod added a subscriber: flod.
flod added inline comments.
browser/components/aiwindow/ui/components/ai-chat-content/ai-chat-content.mjs
1184

Can you explain the reasoning here? Not sure I understand singular/plural, when the string for plural has a variant.

browser/locales-preview/aiWindowContent.ftl
107

Is this a verb or a noun? Please add a comment to clarify.

126

All these plurals should use full sentences for each variant

smart-window-grouped-tabs-summary = 
{ $count } { $count ->
 [one] Created tab group "{ $label }" with { $count } tab
 *[other] Created tab group "{ $label }" with { $count } tabs
}
143

Is this coming from content/UX? doesn't seem very clear.

This revision now requires changes to proceed.Wed, Jun 17, 6:04 PM
Comment Actions

Summary

Intent

The changes implement the UI and service layer for a new "natural language tab grouping" feature in Firefox's AI Window. This extends the existing tab closing flow to also support grouping tabs via AI-assisted conversation. Users can ask the AI to group tabs, confirm which tabs to group, see the result, and undo the grouping (which ungroups the tabs). The feature follows the same tool-call pattern already established for closing tabs.

Solution

Service Layer ():

  • Added a method that validates candidate tabs (filtering out pinned, already-grouped, and closing tabs), picks an unused color from a predefined palette (with random fallback when all colors are used), and delegates to .
  • Added an method that finds a group by ID, iterates through its tabs calling , and returns metadata about the ungrouped tabs.
  • Added a static constant and private helpers (, ) for color selection and tab validation.

Orchestration Layer ():

  • Introduced new UI type () and update types (, ) for the tab grouping flow.
  • Added handler methods (creates a group, records telemetry, transitions to action result) and (ungroups tabs, records undo telemetry, updates UI).
  • Refactored by extracting common tab verification logic into a shared method, reused by the new method on .
  • Introduced array and to generalize the cancellation/retry flow across both website-confirmation and tab-group-confirmation UIs, replacing hardcoded checks against a single UI type.
  • The cancel handler now passes the and the retry flow selects the correct localized retry message based on the cancelled UI type.

Chat Content Component ():

  • Added rendering for the UI type, reusing the component with different confirm button labels ("Group" instead of "Close") and passing the and properties.
  • Added data-formatting methods (, ) and a dispatcher () to render action results for grouped and ungrouped tabs.
  • The undo button now dispatches the correct update type based on using a mapping object ().
  • The retry component now uses a dynamic Fluent L10n ID from properties rather than a hardcoded one.

Confirmation Component ():

  • Added , , and properties to make the component reusable for both close and group actions.
  • The submit event now includes and the close event includes in their detail payloads.

Localization:

  • Added Fluent strings for the group action button, grouped/ungrouped result labels, summary messages, and a tab-group-specific retry message.

Persistence ():

  • Updated restored-from-DB logic to use the array instead of checking a single UI type, so tab-group confirmations are also correctly marked as restored.

Tests:

  • Added xpcshell tests for and covering success, invalid tabs (pinned, grouped, closing), empty input, invalid window, color assignment, and color exhaustion.
  • Updated existing browser tests to include in confirmed data payloads.
  • Added browser tests for rendering tab-group confirmation UI, action results for grouped/ungrouped tabs, and verifying that submit events carry the .
  • Extended mock helpers with , , , , and support.

Please use / reactions on inline comments to provide feedback. This will have a significant impact on the quality of future reviews.
browser/components/aiwindow/ui/components/ai-chat-content/ai-chat-content.mjs
1065

Bug: returns when is falsy, but the caller on line 1267 unconditionally accesses on the result, which will throw a TypeError. Pre-existing stored conversations from before this patch won't have in their . Change line 1055 to default the value:

1174

Mutating in-place during a render method is a side effect. Since Lit may re-render this component multiple times, and is part of the message data model, this mutation leaks outside the render boundary. Extract the and pass it to as a parameter instead of mutating the message object.

browser/components/aiwindow/ui/modules/ChatConversation.sys.mjs
1263

is identical to the already-exported from . Reuse (importing it via lazy getter) instead of duplicating the list.

browser/components/aiwindow/ui/modules/ToolUI.sys.mjs
802

Bug: The fallback Fluent ID does not exist in any FTL file. The correct ID is . This will result in a broken localization string if the fallback path is ever hit.

ngrato updated this revision to Diff 1302820.
ngrato marked 7 inline comments as done.
Comment Actions

Code analysis found 1 defect in diff 1302820:

  • 1 defect found by eslint (Mozlint)
IMPORTANT: Found 1 defect (error level) that must be fixed before landing.

You can run this analysis locally with:


If you see a problem in this automated review, please report it here.

You can view these defects in the Diff Detail section of Phabricator diff 1302820.

Revision Contents

PathSize
browser/
components/
aiwindow/
ui/
components/
ai-chat-content/
180 lines
ai-website-confirmation/
22 lines
modules/
6 lines
6 lines
259 lines
316 lines
test/
browser/
323 lines
2 lines
xpcshell/
380 lines
locales-preview/
43 lines
CommitTreeParentsAuthorSummaryDate
32cd6befec70dadbf4cc110254a6ea010124nickgrato
Bug 2047002 - Mock and wire NL tab grouping tool-call flows r=omarg,yjamora (Show More…)
Tue, Jun 16, 9:49 PM

Diff 1302820

browser/components/aiwindow/ui/components/ai-chat-content/ai-chat-content.mjs

Loading...

browser/components/aiwindow/ui/components/ai-website-confirmation/ai-website-confirmation.mjs

Loading...

browser/components/aiwindow/ui/modules/ChatConversation.sys.mjs

Loading...

browser/components/aiwindow/ui/modules/ChatStore.sys.mjs

Loading...

browser/components/aiwindow/ui/modules/TabManagementService.sys.mjs

Loading...

browser/components/aiwindow/ui/modules/ToolUI.sys.mjs

Loading...

browser/components/aiwindow/ui/test/browser/browser_aiwindow_chat_tool_ui.js

Loading...

browser/components/aiwindow/ui/test/browser/browser_aiwindow_tab_close_integration.js

Loading...

browser/components/aiwindow/ui/test/xpcshell/test_TabManagementService.js

Loading...

browser/locales-preview/aiWindowContent.ftl

Loading...