| Bug 2047002 - Mock and wire NL tab grouping tool-call flows r=omarg,yjamora
Authored by ngrato on Tue, Jun 16, 9:49 PM. - Reviewers
-
- Group Reviewers
-
- Bugzilla Bug ID
- 2047002
Event Timeline| browser/components/aiwindow/ui/modules/ToolUI.sys.mjs |
| 128 | just moving to "public API" section |
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 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. |
Comment ActionsSummary
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 marked 7 inline comments as done. Comment ActionsCode 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. | Path | Size |
|---|
| | | | | 180 lines | | | 22 lines | | | 6 lines | | 6 lines | | 259 lines | | 316 lines | | | | 323 lines | | 2 lines | | | 380 lines | | | 43 lines |
| Commit | Tree | Parents | Author | Summary | Date |
|---|
| 32cd6befec70 | dadbf4cc1102 | 54a6ea010124 | nickgrato | Bug 2047002 - Mock and wire NL tab grouping tool-call flows r=omarg,yjamora (Show More…) | Tue, Jun 16, 9:49 PM |
- Wed, Jun 17, 6:11 PM2026-06-17 18:11:32 (UTC+0)
- Tue, Jun 16, 11:59 PM2026-06-16 23:59:16 (UTC+0)
- Tue, Jun 16, 11:54 PM2026-06-16 23:54:50 (UTC+0)
- Tue, Jun 16, 11:51 PM2026-06-16 23:51:27 (UTC+0)
- Tue, Jun 16, 7:06 PM2026-06-16 19:06:04 (UTC+0)
- Mon, Jun 15, 12:19 PM2026-06-15 12:19:38 (UTC+0)
- Thu, Jun 11, 11:09 PM2026-06-11 23:09:42 (UTC+0)
- Thu, Jun 11, 4:15 PM2026-06-11 16:15:11 (UTC+0)
- Mon, Jun 8, 3:18 PM2026-06-08 15:18:02 (UTC+0)
browser/components/aiwindow/ui/components/ai-chat-content/ai-chat-content.mjsbrowser/components/aiwindow/ui/components/ai-website-confirmation/ai-website-confirmation.mjsbrowser/components/aiwindow/ui/modules/ChatConversation.sys.mjsbrowser/components/aiwindow/ui/modules/ChatStore.sys.mjsbrowser/components/aiwindow/ui/modules/TabManagementService.sys.mjsbrowser/components/aiwindow/ui/modules/ToolUI.sys.mjsbrowser/components/aiwindow/ui/test/browser/browser_aiwindow_chat_tool_ui.jsbrowser/components/aiwindow/ui/test/browser/browser_aiwindow_tab_close_integration.jsbrowser/components/aiwindow/ui/test/xpcshell/test_TabManagementService.jsbrowser/locales-preview/aiWindowContent.ftl |