Skip to content
Open
3 changes: 3 additions & 0 deletions .changes/unreleased/Changed-20261127-011006.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Changed
body: 'The menu bar''s Tab menu is now Tabs, with Clair''s own items: Pin Tab, Pin to Favorites, New Folder…, Next and Previous Tab, Split with Tab, Move to Space and Clear Unpinned Tabs. Tab menus in the sidebar are grouped into sections, and Edit Pinned Page offers Back to Pinned URL.'
time: 2026-11-27T01:10:06.636702-05:00
2 changes: 1 addition & 1 deletion .changes/unreleased/New-20261124-222859.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
kind: New
body: 'Folders in the pinned section, as in Arc: create them from the + menu, the Space''s menu or Tab › New Folder…, drag tabs into them, open and close them, and turn one into a Space.'
body: 'Folders in the pinned section, as in Arc: create them from the + menu, the Space''s menu or Tabs › New Folder…, drag tabs into them, open and close them, and turn one into a Space.'
time: 2026-11-24T22:28:59.296124-05:00
3 changes: 3 additions & 0 deletions .changes/unreleased/New-20261127-011005.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: New
body: 'Ctrl+Tab goes back to the tab you used last, as in Arc: hold Ctrl to see your five most recent tabs, across Spaces, with previews of their pages, and press Tab to choose another.'
time: 2026-11-27T01:10:05.615797-05:00
2 changes: 2 additions & 0 deletions docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ Check the Xcode that ungoogled-chromium-macos's CI builds that tag with (`BASE_X

Fix the Clair patches the comment lists from the top, using ungoogled-chromium-macos's and Helium's updates as references: a skipped patch can make a later one that builds on it fail too.

Clair deletes Chromium's Tab menu at start-up (`add-tab-switcher-and-tabs-menu` design D5), and Chromium's code that looks it up today handles its absence. On each update, grep the new Chromium for `IDC_TAB_MENU` (`chrome/browser/app_controller_mac.mm`, `chrome/browser/ui/cocoa/`): a new user that doesn't check for nil would crash when a window becomes main, which the patch check can't see.

To move the pin by hand instead, for a tag the bot doesn't follow (ungoogled-chromium-macos doesn't tag every version: of 157, it skipped `157.0.8103.38` and `157.0.8103.50`):

```sh
Expand Down
21 changes: 16 additions & 5 deletions docs/native-window.md

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions engine/overlay/chrome/browser/clair/window/clair_browser_bridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,42 @@ - (void)setMuted:(BOOL)muted forTab:(ClairTabID)tabID {
}
}

// --- ClairBrowser: the tab switcher (add-tab-switcher-and-tabs-menu D1, D4) ---

// A tab of any window, which the window decides whether it may show.
- (tabs::TabInterface*)anyTabWithID:(ClairTabID)tabID {
if (tabs::TabInterface* tab = [self tabWithID:tabID]) {
return tab;
}
return _browserWindow && tabID != ClairTabIDNone
? tabs::TabHandle(static_cast<int32_t>(tabID)).Get()
: nullptr;
}

- (void)showTab:(ClairTabID)tabID {
if (tabs::TabInterface* tab = [self anyTabWithID:tabID]) {
_browserWindow->ShowTab(tab);
}
}

- (void)requestPreviewOfTab:(ClairTabID)tabID
size:(NSSize)size
completion:(void (^)(NSImage*))completion {
if (!completion) {
return;
}
tabs::TabInterface* tab = [self anyTabWithID:tabID];
if (!tab || !ClairBrowserWindow::HolderOf(tab)) {
completion(nil);
return;
}
_browserWindow->RequestPreview(
tab, gfx::SizeF(size.width, size.height),
base::BindOnce(^(NSImage* preview) {
completion(preview);
}));
}

// --- ClairBrowser: Peek ---

// The Peeks of the window holding `tab`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "components/web_modal/web_contents_modal_dialog_host.h"
#include "ui/base/mojom/window_show_state.mojom.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size_f.h"
#include "ui/gfx/range/range.h"

#if !defined(__OBJC__)
Expand Down Expand Up @@ -339,7 +340,11 @@ class ClairBrowserWindow : public BrowserWindow {
// its member for that profile (add-profiles D3). With `again`, a member
// the group swaps in shows the Space even if it showed it already, as its
// active tab may be its placeholder.
void ShowSpace(const std::string& space, bool again = false);
// With `tab`, a row of `space` or a favorite of its profile, the window
// shows that tab instead (add-tab-switcher-and-tabs-menu D1).
void ShowSpace(const std::string& space,
bool again = false,
tabs::TabInterface* tab = nullptr);
// The tabs of the shown Space, in its order, whichever window of the
// profile holds them: with Peeks, or only the rows the sidebar lists. An
// incognito or guest window's are its own.
Expand Down Expand Up @@ -478,6 +483,17 @@ class ClairBrowserWindow : public BrowserWindow {
void FollowActiveTab();
// add-profiles D9: drops a take waiting for `tab`'s page copy.
void DropPendingTakeOf(const tabs::TabInterface* tab);
// add-tab-switcher-and-tabs-menu D1: shows `tab`, of any of the window's
// Spaces or a favorite, as selecting its row or tile does, taking it from
// another window if need be. Another profile's tab is shown by the window's
// group, which swaps to its member for that profile.
void ShowTab(tabs::TabInterface* tab);
// D4: hands `done` a preview of `tab`'s page, `size` in points: the page as
// it is now while a window shows it, else the copy kept when it was last
// hidden, or nil.
void RequestPreview(tabs::TabInterface* tab,
const gfx::SizeF& size,
base::OnceCallback<void(NSImage*)> done);
// D5: runs a tab command over the rows of the shown Space. Returns whether
// it ran; otherwise Chromium runs it.
bool ExecuteTabCommand(int command);
Expand Down Expand Up @@ -695,6 +711,11 @@ class ClairBrowserWindow : public BrowserWindow {
// D2: the copy of the still's page came after the tab left.
void SetStillImage(tabs::TabHandle handle, const SkBitmap& copy);
NSImage* StillImageFrom(const SkBitmap& copy) const;
// add-tab-switcher-and-tabs-menu D4: before `old_contents` and the pages
// shown with it are hidden, copies each one that stops being shown,
// `shown` being the pages shown from now on, and keeps it as its preview.
void KeepPreviews(content::WebContents* old_contents,
const std::set<content::WebContents*>& shown);
// D2: copies `row`'s page, waiting at most 250 ms, and hands `done` the
// copy, or an empty bitmap.
void CopyPage(tabs::TabInterface* row,
Expand Down
168 changes: 143 additions & 25 deletions engine/overlay/chrome/browser/clair/window/clair_browser_window.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import <AppKit/AppKit.h>

#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
Expand All @@ -21,6 +22,7 @@
#include "base/auto_reset.h"
#include "base/check.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
Expand All @@ -42,6 +44,7 @@
#import "chrome/browser/clair/window/clair_native_window.h"
#include "chrome/browser/clair/window/clair_peeks.h"
#include "chrome/browser/clair/window/clair_space_session.h"
#include "chrome/browser/clair/window/clair_tab_preview.h"
#include "chrome/browser/clair/window/clair_window_group.h"
#include "chrome/browser/clair/window/clair_window_hooks.h"
#include "chrome/browser/clair/clair_profiles.h"
Expand Down Expand Up @@ -1805,6 +1808,9 @@ void GiveBackToStill(tabs::TabHandle handle) {
CancelPendingTake();
if (content::WebContents* active =
browser_->tab_strip_model()->GetActiveWebContents()) {
// add-tab-switcher-and-tabs-menu D4: the pages leave without an active
// tab change; the switcher's previews are taken here too.
KeepPreviews(active, {});
for (content::WebContents* page : PagesShownWith(active)) {
page->UpdateWebContentsVisibility(content::Visibility::HIDDEN);
}
Expand Down Expand Up @@ -1961,7 +1967,116 @@ void GiveBackToStill(tabs::TabHandle handle) {
}
}

void ClairBrowserWindow::ShowSpace(const std::string& space, bool again) {
// --- The tab switcher (add-tab-switcher-and-tabs-menu D1, D4) ---

void ClairBrowserWindow::ShowTab(tabs::TabInterface* tab) {
ClairBrowserWindow* holder = HolderOf(tab);
if (!holder || ClairSpaceTabs::IsPlaceholder(tab->GetContents())) {
return;
}
// A Peek's row is its parent's; a split shows with its pane focused last.
tabs::TabInterface* row = RowOf(tab);
ClairSpaceTabs* lists = holder->space_tabs();
if (holder == this ||
(space_tabs_ && space_tabs_->is_regular() && lists == space_tabs_ &&
space_tabs_->IsListed(row))) {
// A tab of another Space shows that Space as it becomes active, ClairUI
// hearing of the Space first (OnActiveTabChanged).
ActivateRow(row);
return;
}
// add-profiles D3: another profile's tab; the group swaps to its member.
if (!space_tabs_ || !space_tabs_->is_regular() || !lists ||
!lists->is_regular() || !lists->IsListed(row)) {
return;
}
std::string space = lists->SpaceOf(row);
if (space.empty()) {
// A favorite belongs to its profile: the Space its window shows.
space = holder->shown_space();
}
ShowSpace(space, /*again=*/false, row);
}

void ClairBrowserWindow::RequestPreview(
tabs::TabInterface* tab,
const gfx::SizeF& size,
base::OnceCallback<void(NSImage*)> done) {
content::WebContents* contents = tab ? tab->GetContents() : nullptr;
if (!contents || contents->IsCrashed() || size.IsEmpty() ||
ClairSpaceTabs::IsPlaceholder(contents)) {
std::move(done).Run(nil);
return;
}
const CGFloat scale =
ns_window_.backingScaleFactor > 0 ? ns_window_.backingScaleFactor : 1;
const int width =
std::max(1, static_cast<int>(std::lround(size.width() * scale)));
// The copy, or else the preview kept, cut to the card, in points.
auto finish = [](tabs::TabHandle handle, gfx::SizeF size, int width,
base::OnceCallback<void(NSImage*)> done,
const SkBitmap& copy) {
tabs::TabInterface* tab = handle.Get();
const SkBitmap& source =
copy.drawsNothing() && tab ? ClairTabPreview::Get(tab->GetContents())
: copy;
const SkBitmap cut = ClairTabPreview::CutFromTop(source, size, width);
if (!tab || cut.drawsNothing()) {
std::move(done).Run(nil);
return;
}
NSImage* image = skia::SkBitmapToNSImage(cut);
image.size = NSMakeSize(size.width(),
size.width() * cut.height() / cut.width());
std::move(done).Run(image);
};
if (contents->GetVisibility() == content::Visibility::VISIBLE) {
// A page a window shows, as it is now.
CopyPage(tab, base::BindOnce(finish, tab->GetHandle(), size, width,
std::move(done)));
return;
}
finish(tab->GetHandle(), size, width, std::move(done), SkBitmap());
}

void ClairBrowserWindow::KeepPreviews(
content::WebContents* old_contents,
const std::set<content::WebContents*>& shown) {
if (!old_contents || ClairSpaceTabs::IsPlaceholder(old_contents) ||
!IsVisible()) {
return;
}
for (content::WebContents* page : PagesShownWith(old_contents)) {
tabs::TabInterface* tab = tabs::TabInterface::MaybeGetFromContents(page);
// Each pane of a split. A Peek's parent keeps its own page; the Peek,
// never a row, has none.
if (shown.contains(page) || !tab || page->IsCrashed() ||
ClairSpaceTabs::IsPlaceholder(page) ||
(peeks_ && peeks_->ParentOf(tab))) {
continue;
}
// Hidden, a page gives up its compositor, and viz never draws the
// surface the copy waits for. As Chromium's background thumbnails do, a
// hidden capture keeps it painting, the page told it's hidden, until the
// copy is back.
base::ScopedClosureRunner painting = page->IncrementCapturerCount(
gfx::Size(), /*stay_hidden=*/true, /*stay_awake=*/false,
/*is_activity=*/false);
CopyPage(tab, base::BindOnce(
[](tabs::TabHandle handle,
base::ScopedClosureRunner painting,
const SkBitmap& copy) {
if (tabs::TabInterface* tab = handle.Get()) {
ClairTabPreview::Keep(tab->GetContents(), copy);
}
},
tab->GetHandle(), std::move(painting)));
}
}

void ClairBrowserWindow::ShowSpace(const std::string& space,
bool again,
tabs::TabInterface* tab) {
clair::ClairSpaceStore* store = clair::ClairSpaceStore::Get();
if (!space_tabs_ || !space_tabs_->is_regular() || !store->Contains(space) ||
(space == shown_space_ && !again)) {
Expand All @@ -1971,10 +2086,24 @@ void GiveBackToStill(tabs::TabHandle handle) {
if (store->ProfileOf(space) !=
clair::ClairProfiles::IDOf(browser_->GetProfile())) {
if (ClairWindowGroup* group = ClairWindowGroup::Of(this)) {
group->ShowSpace(space);
group->ShowSpace(space, {},
tab ? tab->GetHandle() : tabs::TabHandle::Null());
}
return;
}
// add-tab-switcher-and-tabs-menu D1: the switcher's tab, a row of the Space
// or a favorite, shows in place of the one Clair would pick, so no other
// tab shows on the way.
if (tab && space_tabs_->IsListed(tab) &&
(space_tabs_->SpaceOf(tab) == space || space_tabs_->IsFavoriteTab(tab))) {
SetShownSpace(space);
// The group reveals this member right after: the tab moves here at once,
// a window that showed it getting its still's image when the copy comes.
ClairTakeOptions options;
options.wait_for_copy = false;
ActivateRow(RowOf(tab), std::move(options));
return;
}
// Shown again: the active tab stays if it's a row of the Space.
if (space == shown_space_) {
tabs::TabInterface* active = browser_->tab_strip_model()->GetActiveTab();
Expand Down Expand Up @@ -2029,10 +2158,9 @@ void GiveBackToStill(tabs::TabHandle handle) {
bool ClairBrowserWindow::ExecuteTabCommand(int command) {
const bool select_index =
command >= IDC_SELECT_TAB_0 && command <= IDC_SELECT_TAB_7;
// add-tab-switcher-and-tabs-menu D5a: Ctrl+Tab is ClairUI's switcher.
const bool step = command == IDC_SELECT_NEXT_TAB ||
command == IDC_SELECT_PREVIOUS_TAB ||
command == IDC_CYCLE_TO_NEXT_TAB ||
command == IDC_CYCLE_TO_PREV_TAB;
command == IDC_SELECT_PREVIOUS_TAB;
TabStripModel* strip = browser_->tab_strip_model();
tabs::TabInterface* active = strip->GetActiveTab();
// While the window shows a still, the still's row stands for the active
Expand Down Expand Up @@ -2089,8 +2217,7 @@ void GiveBackToStill(tabs::TabHandle handle) {
(slot.tab == active_row ||
ClairSplits::PartnerOf(slot.tab) == active_row);
});
const bool forward = command == IDC_SELECT_NEXT_TAB ||
command == IDC_CYCLE_TO_NEXT_TAB;
const bool forward = command == IDC_SELECT_NEXT_TAB;
// From a favorite, the first or last row.
const int position = it == slots.end()
? (forward ? -1 : count)
Expand Down Expand Up @@ -2158,22 +2285,6 @@ void GiveBackToStill(tabs::TabHandle handle) {
// a still, the still's row is the one closed.
CloseTab(still_tab_.Get() ? still_tab_.Get() : active);
return true;
case IDC_WINDOW_CLOSE_TABS_TO_RIGHT:
CloseTabsBelow(active_row);
return true;
case IDC_WINDOW_CLOSE_OTHER_TABS: {
std::vector<tabs::TabHandle> others;
for (tabs::TabInterface* row : Rows()) {
if (row != active_row) {
others.push_back(row->GetHandle());
}
}
// add-split-view: a split row closes both its panes.
for (const tabs::TabHandle& handle : others) {
CloseSplit(handle.Get());
}
return true;
}
default:
return false;
}
Expand Down Expand Up @@ -3119,11 +3230,18 @@ void GiveBackToStill(tabs::TabHandle handle) {
FROM_HERE, base::BindOnce(&GiveBackToStill, old_row->GetHandle()));
}
}
// A tab and its Peek show together (add-peek D4).
const std::set<content::WebContents*> shown = PagesShownWith(new_contents);
// add-tab-switcher-and-tabs-menu D4: the switcher's previews, while the
// pages leaving are still in the card: once ClairUI takes a page's view out
// of the window, its surface can't be copied.
if (old_contents) {
KeepPreviews(old_contents, shown);
}
// ClairUI swaps the page in the card now, before visibility changes.
[bridge_ activeTabChanged];
// As WebUIBrowserWindow: the old page reports hidden, the new one the
// window's visibility. A tab and its Peek show together (add-peek D4).
const std::set<content::WebContents*> shown = PagesShownWith(new_contents);
// window's visibility.
if (old_contents) {
for (content::WebContents* page : PagesShownWith(old_contents)) {
if (!shown.contains(page)) {
Expand Down
Loading
Loading