By default we will keep the same conversation open across active tab changes and page navigations. Even if the tabs are linked within the same session (Tab B opened via Tab A). - If I select another conversation, then show the back button - back button goes to the conversation I was on (stored client side) _In other words, don't use any of the tab-related GetConversationForAssociatedContent AIChatService stuff._ This version of global conversation per-panel will have the following UX: - Every time I close and open the panel it will be a new conversation - Each window will have a different conversation Optional in-between (perhaps put behind an additional flag): If I have an active conversation that has tabs attached to it, and then I go to a new tab and explicitly click the new conversation button, when I go back to a Tab that has an active conversation with it attached then I should switch to that. Also if I go back to a tab that had a conversation without any tabs associated to it, then I should show that conversation by default. Optional additional: Have a concept of stale-ness for a conversation. Don't switch to the conversation when switching active tab if the conversation is stale. Staleness could be decided by: - age of conversation - whether it has the page attached or not - number of turns Future - Maybe have the LLM decide whether the conversation is tab-associated or not ### Tasks #### Initial version - [x] Feature flag - [X] Panel stays open across navigations and active tab, to the same conversation - https://github.com/brave/brave-core/issues/30720 - [x] Active tab is automatically attached, and changed whenever active tab changes or navigates - https://github.com/brave/brave-browser/issues/53533 - [x] "Active conversation" is initial conversation, not Service-provided conversation keyed via Page. This fixes the back arrow to the _current_ conversation. - https://github.com/brave/brave-browser/issues/55399 - [x] https://github.com/brave/brave-browser/issues/55702 - [x] Enable by default (hard-coded, ride trains) - https://github.com/brave/brave-core/pull/36785 #### Follow-ups - [ ] Placeholder is sent to LLM instead of full page contents, possibly only for active tab (though could be useful for all tabs as large tool output is stripped). - [ ] Create a tool, `get_tab_content` which returns entire content for an attachment that was sent as a placeholder - [ ] https://github.com/brave/brave-browser/issues/53417 - as a follow up to the above, we should only remove automatically staged content when changing tabs/navigating. - [ ] Tool for LLM to query all tabs and ask user permission to attach some of them ### Test Plan 1. Send a message to Leo in the sidebar 2. Navigate the current tab 3. The conversation should persist 4. Change the active tab 5. The conversation should persist 6. The input box should get the new tab attached 7. Navigate to a different tab 8. The input box should have the newly navigated tab in it Essentially: 1. The input box should always have the current tab in it (unless the tab has already been sent) 2. The conversation should persist across navigations/tab switches