Skip to content

[Partitioned Tabs] Add PartitionedTabVisualData #29408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

sangwoo108
Copy link
Collaborator

@sangwoo108 sangwoo108 commented Jun 5, 2025

PartitionedTabVisualData will be used to represent PartionedStorage tabs.

It'll be retrieved through TabInterface and set via TabModel,
following the upstream's tabs architecture.

Resolves brave/brave-browser#46592

@sangwoo108 sangwoo108 force-pushed the sko/partition branch 5 times, most recently from 77aaea9 to 20f9bdf Compare June 5, 2025 13:53
@github-actions github-actions bot added CI/run-network-audit Run network-audit CI/run-audit-deps Check for known npm/cargo vulnerabilities (audit_deps) CI/storybook-url Deploy storybook and provide a unique URL for each build CI/run-upstream-tests Run upstream unit and browser tests on Linux and Windows (otherwise only on Linux) feature/web3/wallet feature/web3/wallet/core labels Jun 5, 2025
@sangwoo108 sangwoo108 changed the base branch from sko/unittest to master June 5, 2025 14:04
@sangwoo108 sangwoo108 changed the title Add PartitionedTabVisualData [Partitioned Tabs] Add PartitionedTabVisualData Jun 6, 2025
@sangwoo108 sangwoo108 marked this pull request as ready for review June 6, 2025 21:51
@sangwoo108 sangwoo108 requested review from a team and bridiver as code owners June 6, 2025 21:51
@sangwoo108 sangwoo108 requested review from goodov and petemill June 6, 2025 21:51

#include "chrome/browser/ui/tabs/tab_model.h"

#include "brave/components/containers/core/common/features.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everything related to containers should be under BUILDFLAG(ENABLE_CONTAINERS), but I don't think you should mention the containers feature here at all. Just keep partitioned_tab_visual_data_ getters/setter and remove CHECK calls.

std::optional<PartitionedTabVisualData>
TabInterface::GetPartitionedTabVisualData() const {
return std::nullopt;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you did here and I think this is interesting, but I'd rather have these default implementations in brave/chromium_src override for consistency as we have in other places where we add new functions to chromium classes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's what I'd love to do, but tab_interface.cc doesn't exist in Chromium, as they conist of pure virtual methods. As you already know, inlining non-emptybody isn't allowed by the chromium-style.

There're several derived classes, I tried to make these new methods have default implementation in this way. Off the top of my head, it might be possible to make "BraveTabInterface" that extends TabInterface and make others extends BraveTabInterface instead of TabInterface, but could be a little bit complex than the current implementation. Do you think it's worth trying to make BraveTabInterface?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I see now. Thanks for the details!

I'd say having BraveTabInterface would be a nice touch here, but if it will require a lot of changes in different places, then we might stick with tab_interface.cc as you currently have it implemented.

Another take here - declare our methods with = 0 and implement them where required in Chromium (tab_model.cc, tab_android.cc). Maybe even declare them only on desktop (via buildflag guard) and implement only in tab_model.cc for now.

}

void TabModel::SetPartitionedTabVisualData(
const std::optional<PartitionedTabVisualData>& data) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::optional<PartitionedTabVisualData> data and partitioned_tab_visual_data_ = std::move(data);

#include "components/tabs/public/tab_interface.h"

// Extends to support getter and setter for partitioned tabs.
#if BUILDFLAG(ENABLE_CONTAINERS)
Copy link
Member

@goodov goodov Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls replace containers reference with #if !BUILDFLAG(IS_ANDROID).

this will also be used by Leo, so it should just be bound to "desktop" platform. again, no need to pull "containers" into this tab model extension.

this PR should not add any use of //brave/components/containers files.

@@ -54,4 +55,13 @@ source_set("unit_tests") {
"//testing/gmock",
"//testing/gtest",
]

if (enable_containers) {
Copy link
Member

@goodov goodov Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all mentions of containers should be removed from this PR. please use !is_android check everywhere.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think !is_android is appropriate here as this PR only touches desktop code

Copy link
Member

@bsclifton bsclifton Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's an old habit (not desktop = !android); but yeah, I think you meant:

if (!is_android && !is_ios) {

But I am a bit confused as a guest reading this PR. You're sharing a recommendation to use the OS check

all mentions of containers should be removed from this PR. please use !is_android check everywhere.

but then also you shared above:

everything related to containers should be under BUILDFLAG(ENABLE_CONTAINERS)

I also noticed your containers UI PR here is using #if BUILDFLAG(ENABLE_CONTAINERS).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're in Views so this is already desktop-only. So either we need to gate behind a flag or we leave this API in by default since it isn't being called (and we can gate the calls with a flag, higher up).

// Represents the visual data for a partitioned tab in the tab strip.
// There're two types of partition tabs:
// 1. Container tabs
// 2. Leo tabs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think everything should be using aichat now instead of leo?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also I think we should call these PartitionedStorageTabs so we're using consistent terminology.

#if !BUILDFLAG(IS_ANDROID)
#define IsActivated \
IsPartitionedTab() const override; \
void SetPartitionedTabVisualData( \
Copy link
Collaborator

@bridiver bridiver Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't seem like the right place for this, where would this be called from?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it probably makes sense to have SetPartitionedStorageTab(bool), but I'm concerned about how this is going to integrate with saved tab groups and whether we should have our own subclass of TabModel, but it doesn't seem like the TabModel should be where we store PartitionedTabVisualData

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually looking at this again, I'm not sure that it makes sense to have SetPartitionedStorageTab because that is what creates the need for PartitionedTabVisualData in the first place and seems to make things overly complicated when we know exactly what types of partitioned storage tabs exist in advance. Maybe SetPartitionedStorageTabType with an enum for CONTAINER, AICHAT and DISABLED and then based on that the UI code can display the correct icon, etc... without having to tell the tab model about it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after discussing with @petemill apparently each container tab can have a different icon so an enum doesn't really work, but then I'm also not sure that we should have a generic PartitionedStorageTab here at all. I think we should just gave SetContainerId (with kNone) or something like that and then the UI code can lookup the correct icon based on that. For aichat it would just be SetAIChatTab(bool)

Copy link
Member

@bsclifton bsclifton Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think each entry that a person adds can have its own icon (see #29230 for an example where you can add the new containers). Eventually, that listing (add/remove/edit containers) should look like the mock up in brave/brave-browser#46592

Copy link
Collaborator Author

@sangwoo108 sangwoo108 Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

etContainerId (with kNone) or something like that and then the UI code can lookup the correct icon based on that. For aichat it would just be SetAIChatTab(bool)

That'd be aligned to other methods like SetSplit() and SetGroup() in the model. Thanks.


Update: We're talking about if it'd be better to keep it as is so that we can work simultaneously.

#include "components/tabs/public/tab_interface.h"

// Extends to support getter and setter for partitioned tabs.
#if !BUILDFLAG(IS_ANDROID)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not necessary, this class is already desktop only

@bridiver
Copy link
Collaborator

bridiver commented Jun 9, 2025

The PR description should not be a duplicate of the issue, also this PR does not fully implement the issue, it only provides initial support for the tab model. The issue should be updated to describe only the parts you are implementing here and the PR description should just describe what you're doing, not include all the details from the issue.

Copy link
Contributor

Chromium major version is behind target branch (137.0.7151.68 vs 138.0.7204.25). Please rebase.

@github-actions github-actions bot added the chromium-version-mismatch The Chromium version on the PR branch does not match the version on the target branch label Jun 11, 2025
@github-actions github-actions bot removed the chromium-version-mismatch The Chromium version on the PR branch does not match the version on the target branch label Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/run-audit-deps Check for known npm/cargo vulnerabilities (audit_deps) CI/run-network-audit Run network-audit CI/run-upstream-tests Run upstream unit and browser tests on Linux and Windows (otherwise only on Linux) CI/storybook-url Deploy storybook and provide a unique URL for each build feature/web3/wallet/core feature/web3/wallet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Partitioned Storage Tab] Add data structure to represent partitioned storage tabs
5 participants