Skip to content

armgit / cra

Public Imported from GitHub
0

The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.

A Peek waits on its tab and comes back with it, as in Arc (#242)

Victor5e777bf37090
diff --git a/Packages/CraCore/Sources/CraCore/PeekPresence.swift b/Packages/CraCore/Sources/CraCore/PeekPresence.swift
new file mode 100644
index 0000000..40f7cde
--- /dev/null
+++ b/Packages/CraCore/Sources/CraCore/PeekPresence.swift
@@ -0,0 +1,22 @@
+import Foundation
+
+/// Whether a Peek is on screen. Arc keeps a Peek per tab: its window contents hold
+/// `modalByWindowContent` (WindowContents/WindowContentState, Arc 1.172.1), and a Peek left by
+/// opening a tab from inside it was there again, same page and scroll, back on its pinned tab
+/// (GitHub #242, the reporter on Arc 1.172). So a Peek shows while the tab it came from is on
+/// screen, waits hidden while another tab is, and goes when its tab closes.
+public enum PeekPresence: Equatable, Sendable {
+ case shown
+ /// Hidden with its page alive, until its tab is on screen again.
+ case parked
+ /// Its tab is gone: the Peek closes.
+ case dropped
+
+ /// `source` is the tab the Peek came from (nil: none, the Peek stays as it is); `onScreen`
+ /// the window's panes, the selected tab or its split.
+ public static func of(peekFrom source: UUID?, onScreen: [UUID], tabExists: Bool) -> PeekPresence {
+ guard let source else { return .shown }
+ guard tabExists else { return .dropped }
+ return onScreen.contains(source) ? .shown : .parked
+ }
+}
diff --git a/Packages/CraCore/Sources/CraCore/PeekTrigger.swift b/Packages/CraCore/Sources/CraCore/PeekTrigger.swift
index 6f1b624..86b79df 100644
--- a/Packages/CraCore/Sources/CraCore/PeekTrigger.swift
+++ b/Packages/CraCore/Sources/CraCore/PeekTrigger.swift
@@ -20,9 +20,10 @@ public enum PeekTrigger {
}
/// A link clicked inside the Peek that asks for a new tab (target=_blank, window.open without
- /// features) leaves the Peek: Arc 1.171 (6 Nov 2026, GitHub #202) closed the Peek and opened
+ /// features) leaves the Peek: Arc 1.171 (6 Nov 2026, GitHub #202) took the Peek away and opened
/// the page as a selected Today tab in the space, below the tab the Peek came from, with no
- /// second Little Arc. A Shift-click still loads in the Peek. Only pages a tab can show: an
+ /// second Little Arc. The Peek waits on its tab for the next link (PeekPresence, #242). A
+ /// Shift-click still loads in the Peek. Only pages a tab can show: an
/// about:blank a script fills in later needs its opener, so it stays a popup.
public static func leavesPeek(_ url: String, shiftClick: Bool, newTab: Bool) -> Bool {
guard newTab, !shiftClick, let scheme = URL(string: url)?.scheme?.lowercased() else { return false }
diff --git a/Packages/CraCore/Tests/CraCoreTests/PeekPresenceTests.swift b/Packages/CraCore/Tests/CraCoreTests/PeekPresenceTests.swift
new file mode 100644
index 0000000..55182dd
--- /dev/null
+++ b/Packages/CraCore/Tests/CraCoreTests/PeekPresenceTests.swift
@@ -0,0 +1,31 @@
+import CraCore
+import Foundation
+import Testing
+
+/// A Peek belongs to the tab it came from (Arc's `modalByWindowContent`, GitHub #242).
+struct PeekPresenceTests {
+ static let pinned = UUID(), linked = UUID(), other = UUID()
+
+ @Test(.bug("https://github.com/VictorKildahl/cra/issues/242"))
+ func aPeekWaitsWhileAnotherTabIsOpenAndComesBackWithItsTab() {
+ // A link from inside the Peek opened a tab: the Peek waits on the pinned tab.
+ #expect(PeekPresence.of(peekFrom: Self.pinned, onScreen: [Self.linked], tabExists: true) == .parked)
+ // Back on the pinned tab, it is there again.
+ #expect(PeekPresence.of(peekFrom: Self.pinned, onScreen: [Self.pinned], tabExists: true) == .shown)
+ }
+
+ @Test(.bug("https://github.com/VictorKildahl/cra/issues/242"))
+ func aPeekGoesWithItsTab() {
+ #expect(PeekPresence.of(peekFrom: Self.pinned, onScreen: [Self.linked], tabExists: false) == .dropped)
+ #expect(PeekPresence.of(peekFrom: Self.pinned, onScreen: [Self.pinned], tabExists: false) == .dropped)
+ }
+
+ @Test func aPeekFromAPaneShowsWhileItsSplitIsOnScreen() {
+ #expect(PeekPresence.of(peekFrom: Self.pinned, onScreen: [Self.other, Self.pinned], tabExists: true) == .shown)
+ #expect(PeekPresence.of(peekFrom: Self.pinned, onScreen: [], tabExists: true) == .parked)
+ }
+
+ @Test func aPeekFromNoTabStaysWhereItIs() {
+ #expect(PeekPresence.of(peekFrom: nil, onScreen: [Self.linked], tabExists: false) == .shown)
+ }
+}
diff --git a/Packages/CraCore/Tests/CraCoreTests/PeekVeilTests.swift b/Packages/CraCore/Tests/CraCoreTests/PeekVeilTests.swift
index 51d3d8f..50b71f5 100644
--- a/Packages/CraCore/Tests/CraCoreTests/PeekVeilTests.swift
+++ b/Packages/CraCore/Tests/CraCoreTests/PeekVeilTests.swift
@@ -16,6 +16,16 @@ struct PeekVeilTests {
#expect(!veil.isOn)
}
+ /// A Peek waiting on its tab lets the page go and veils it again when its tab is back (#242).
+ @Test(.bug("https://github.com/VictorKildahl/cra/issues/242"))
+ func aPeekBackWithItsTabVeilsThePageAgain() {
+ var veil = PeekVeil()
+ _ = veil.show(for: a)
+ do { let changed = veil.hide(for: a); #expect(changed) }
+ do { let changed = veil.show(for: a); #expect(changed) }
+ #expect(veil.owner == a)
+ }
+
/// Expand, Add To Split or a close in the 30 ms before the open's veil starts: the Peek is gone
/// first, and the late show used to leave the page faded and shrunk with no Peek over it.
@Test func aPeekThatHasEndedNeverVeilsThePage() {
diff --git a/Sources/Cra/App/AppDelegate.swift b/Sources/Cra/App/AppDelegate.swift
index d7eabc6..6f08482 100644
--- a/Sources/Cra/App/AppDelegate.swift
+++ b/Sources/Cra/App/AppDelegate.swift
@@ -690,12 +690,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
/// Chrome-style page window, which is a child).
var keyLittleWindow: LittleWindowController? {
if let key = NSApp.keyWindow {
- return littleWindows.first { $0.window === key || $0.window === key.parent }
+ return littleWindows.first { !$0.isParked && ($0.window === key || $0.window === key.parent) }
}
// No key window while the app is inactive (e.g. during a cra:// handoff from a
// second launch): the frontmost window stands in for it.
guard let front = NSApp.orderedWindows.first(where: { $0.isVisible && !($0 is NSPanel) }) else { return nil }
- return littleWindows.first { $0.window === front || $0.window === front.parent }
+ return littleWindows.first { !$0.isParked && ($0.window === front || $0.window === front.parent) }
}
/// Creates a little window without showing it (`url` nil = popup host).
@@ -714,19 +714,22 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
}
/// Arc's Peek: a Little Window over `parent` that closes when a click lands past it.
+ /// One per tab (#242): a Peek another tab left waiting stays.
func openPeek(url: String, over parent: MainWindowController, fromTab tabID: UUID? = nil) {
- for p in littleWindows where p.peekParent === parent { p.closeWindow() }
+ for p in littleWindows where p.peekParent === parent && (!p.isParked || p.peekSourceTab == tabID) { p.closeWindow() }
let w = LittleWindowController(app: self, url: url, peekOver: parent, fromTab: tabID)
littleWindows.append(w)
- // Arc badges the tab the Peek came from with the peeked page's favicon (modalIcon).
- parent.sidebarUI.peekBadge = tabID.map { .init(tabID: $0, iconKey: FaviconKey.key(for: url)) }
+ // Arc badges the tab the Peek came from with the peeked page's favicon (modalIcon), also
+ // while the Peek waits on it.
+ if let tabID { parent.sidebarUI.peekBadges[tabID] = .init(iconKey: FaviconKey.key(for: url)) }
w.showAsPeek(fromTab: tabID)
}
func removeLittleWindow(_ w: LittleWindowController) {
littleWindows.removeAll { $0 === w }
if inMenuBar { DispatchQueue.main.async { [weak self] in self?.settleDockIcon() } }
- if let parent = w.peekParent, !littleWindows.contains(where: { $0.peekParent === parent }) { parent.sidebarUI.peekBadge = nil }
+ if let parent = w.peekParent, let tab = w.peekSourceTab,
+ !littleWindows.contains(where: { $0.peekParent === parent && $0.peekSourceTab == tab }) { parent.sidebarUI.peekBadges[tab] = nil }
}
private func archiveIdleLittleWindows() {
@@ -983,6 +986,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
for m in mainWindows { NSLog("Cra peek shown %@: %@", label, m.peekBackdropShown()) }
return
}
+ // peeks=<label>: each window's Peeks, on screen or waiting on their tab, and their pages (#242).
+ if let label = dict["peeks"] {
+ for m in mainWindows { NSLog("Cra peeks %@: %@", label, m.peeksShown()) }
+ return
+ }
if dict["relaunch"] != nil { relaunch(); return }
// quit=1 quits for real, as the menu bar item's Quit; quit=menu is ⌘Q (#231).
if let q = dict["quit"] { q == "menu" ? NSApp.terminate(nil) : quitFromMenuBar(); return }
diff --git a/Sources/Cra/UI/Sidebar/List/SpaceListView.swift b/Sources/Cra/UI/Sidebar/List/SpaceListView.swift
index 16b5800..747f18b 100644
--- a/Sources/Cra/UI/Sidebar/List/SpaceListView.swift
+++ b/Sources/Cra/UI/Sidebar/List/SpaceListView.swift
@@ -307,7 +307,7 @@ final class SpaceListView: NSView, NSDraggingSource {
navigatedAway: navigatedAway,
focusRing: focusID == item.id, developerMode: developerMode, peeked: peeked,
homeIcon: homeImg, homeFlipIcon: homeFlip,
- peekIcon: ui.peekBadge?.tabID == item.id ? icon(ui.peekBadge?.iconKey).0 : nil,
+ peekIcon: ui.peekBadges[item.id].flatMap { icon($0.iconKey).0 },
tidyRename: tidyRename, gitlabMark: liveSource == .gitlab))
out.append(row)
} else if item.isSplit {
diff --git a/Sources/Cra/UI/SidebarUIState.swift b/Sources/Cra/UI/SidebarUIState.swift
index b8df9c7..72ef2b8 100644
--- a/Sources/Cra/UI/SidebarUIState.swift
+++ b/Sources/Cra/UI/SidebarUIState.swift
@@ -117,10 +117,10 @@ final class SidebarUIState {
}
/// Tabs picked with ⌘/⇧-click; closing acts on all of them.
var multiSelection: Set<UUID> = []
- /// The tab an open Peek came from and the peeked page's favicon, which its row shows.
- var peekBadge: PeekBadge?
+ /// The tabs with a Peek, open or waiting on them (#242), and the peeked page's favicon, which
+ /// their rows show.
+ var peekBadges: [UUID: PeekBadge] = [:]
struct PeekBadge: Equatable {
- let tabID: UUID
let iconKey: String?
}
/// Where the next ⇧-click range starts.
diff --git a/Sources/Cra/UI/Windows/LittleWindowController.swift b/Sources/Cra/UI/Windows/LittleWindowController.swift
index f7711ec..113f301 100644
--- a/Sources/Cra/UI/Windows/LittleWindowController.swift
+++ b/Sources/Cra/UI/Windows/LittleWindowController.swift
@@ -139,8 +139,11 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @preco
private(set) weak var peekParent: MainWindowController?
/// This Peek to its window's veil (MainWindowController.showPeekVeil).
private let peekID = UUID()
- /// The tab the Peek came from: links that leave the Peek open as tabs placed from it.
- private let peekSourceTab: UUID?
+ /// The tab the Peek came from: links that leave the Peek open as tabs placed from it, and
+ /// the Peek waits on it while another tab is on screen (#242).
+ let peekSourceTab: UUID?
+ /// Another tab is on screen: the Peek is out of sight, its page alive, until its tab is back.
+ private(set) var isParked = false
private var dim: PeekDimPanel?
private var controls: PeekControlsPanel?
/// The Peek is on its way out (closePeekAnimated).
@@ -320,7 +323,9 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @preco
}
// CEF hands the page window over at its own small frame: shown during a Peek's open it
// flashed as a black block in the corner.
- if openingPeek { w.contentView?.isHidden = true }
+ // A Peek waiting on its tab shows it when it is back (unparkPeek).
+ if openingPeek || isParked { w.contentView?.isHidden = true }
+ w.ignoresMouseEvents = isParked
window.addChildWindow(w, ordered: .above)
ChromiumChildFocus.attach(w)
positionHostWindow(shell.convert(shell.page.frame, to: nil))
@@ -421,7 +426,7 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @preco
// MARK: Peek
/// The click catcher, the Peek and its buttons, in their order above the parent's other children.
- var peekWindows: [NSWindow] { [dim, window, controls].compactMap { $0 } }
+ var peekWindows: [NSWindow] { isParked ? [] : [dim, window, controls].compactMap { $0 } }
/// Arc's Peek: the card grows out of the link clicked in `tabID`'s page (without one, from the
/// whole area right of the sidebar) to its own frame, its buttons riding its corner, while the
@@ -467,9 +472,11 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @preco
// Next turn, with the panel on its way to the screen.
DispatchQueue.main.async { [weak self, weak t] in
guard let self, let t, self.transition === t, !self.closingPeek else { return }
- // A Peek gone by then (Expand, Add To Split, a close) never veils the page.
+ // A Peek gone by then (Expand, Add To Split, a close) never veils the page, nor
+ // one waiting on its tab.
let peek = self.peekID
- DispatchQueue.main.asyncAfter(deadline: .now() + PeekTransition.lead) { [weak parent] in
+ DispatchQueue.main.asyncAfter(deadline: .now() + PeekTransition.lead) { [weak self, weak parent] in
+ guard self?.isParked != true else { return }
parent?.showPeekVeil(for: peek)
}
self.landPeek(t)
@@ -492,6 +499,77 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @preco
}
}
+ /// Another tab came on screen in the window (#242): Arc keeps a Peek per tab
+ /// (`modalByWindowContent`), so it waits out of sight, its page as it was, until its tab is
+ /// back (PeekPresence). The page behind comes back at once, as the tab switch is.
+ func parkPeek() {
+ guard isPeek, !isParked, !closingPeek, let window, let parent = peekParent else { return }
+ isParked = true
+ openingPeek = false
+ transition?.remove()
+ transition = nil
+ tooltipTimer?.invalidate(); hideTooltip()
+ closePopup()
+ commandBar.close()
+ for w in [dim, controls].compactMap({ $0 }) {
+ w.parent?.removeChildWindow(w)
+ w.orderOut(nil)
+ }
+ // The card and its page window stay ordered in, invisible and letting clicks through to the
+ // tab under them: ordered out and back, Chromium scrolled the page to the top, and the
+ // reporter comes back for the next link where they left it. The page hidden, not
+ // transparent: Chromium sets its window's alpha back.
+ window.alphaValue = 0
+ window.ignoresMouseEvents = true
+ (window as? LittleWindow)?.isParked = true
+ if let host = browser?.hostWindow, host.parent === window {
+ host.contentView?.isHidden = true
+ host.ignoresMouseEvents = true
+ }
+ parent.parkPeekVeil(for: peekID)
+ // The keyboard goes back to the window (also in the background, where actions follow the key window).
+ if let pw = parent.window { if NSApp.isActive { pw.makeKeyAndOrderFront(nil) } else { pw.makeKey() } }
+ parent.currentBrowser?.setFocused(true)
+ }
+
+ /// Its tab is on screen again: the Peek is back where it was, over the page faded behind it.
+ func unparkPeek() {
+ guard isParked, let window, let parent = peekParent, let pw = parent.window else { return }
+ isParked = false
+ // Parked while it was still opening: it lands now, without the motion.
+ window.alphaValue = 1
+ window.ignoresMouseEvents = false
+ (window as? LittleWindow)?.isParked = false
+ if let host = browser?.hostWindow, host.parent === window {
+ host.contentView?.isHidden = false
+ host.alphaValue = 1
+ host.ignoresMouseEvents = false
+ }
+ controls?.alphaValue = 1
+ // The click catcher under the card, the buttons over it, all above the window's other children.
+ window.parent?.removeChildWindow(window)
+ for w in [dim, window, controls].compactMap({ $0 }) {
+ pw.addChildWindow(w, ordered: .above)
+ w.orderFront(nil)
+ }
+ repositionPeek()
+ rejoinPage()
+ if NSApp.isActive { window.makeKeyAndOrderFront(nil) }
+ if hasPage || isPopupHost { focusPage() }
+ parent.showPeekVeil(for: peekID, animated: false)
+ }
+
+ /// The tab the Peek waits on is gone (#242): the Peek goes with it, unseen and not offered
+ /// back by ⇧⌘T, which reopens the tab.
+ func dropPeek() {
+ guard isPeek, let window, !closingPeek else { return }
+ closingPeek = true
+ transition?.remove()
+ transition = nil
+ guard windowShouldClose(window) else { return }
+ window.close()
+ }
+
func repositionPeek() {
guard let window, let parent = peekParent, let pw = parent.window, !closingPeek else { return }
dim?.reposition(covering: pw)
@@ -968,13 +1046,18 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @preco
/// ⌘W / Close Window: the same path as the close button. (performClose is
/// skipped: it refuses to act while the standard buttons are dimmed.)
func closeWindow() {
- guard let window, window.isVisible else { return }
+ guard let window, window.isVisible || isParked else { return }
if isPeek, !closingPeek {
if hasPage, !promoted, let parent = peekParent {
- parent.closedPeek = (currentURL, parent.sidebarUI.peekBadge?.tabID, store.clock.now)
+ parent.closedPeek = (currentURL, peekSourceTab, store.clock.now)
+ }
+ // Out of sight (its window closing, ⌘Q to the menu bar): nothing to animate.
+ if isParked {
+ closingPeek = true
+ } else {
+ closePeekAnimated { [weak self] in self?.closeWindow() }
+ return
}
- closePeekAnimated { [weak self] in self?.closeWindow() }
- return
}
guard windowShouldClose(window) else { return }
window.close()
@@ -1129,13 +1212,12 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @preco
}
/// Arc 1.171 (#202): a link from a Peek that asks for a new tab is a Today tab in the space,
- /// placed as a link from the tab under the Peek would be, and the Peek closes for it. A
- /// background one (⌘-click) leaves the Peek open, as the click left the page in a tab.
+ /// placed as a link from the tab under the Peek would be, and selected. The Peek waits on its
+ /// own tab, as it does for any other tab (parkPeek, #242), for the next link. A background
+ /// one (⌘-click) leaves the Peek on screen.
private func openTabFromPeek(_ url: String, inBackground background: Bool) {
guard let parent = peekParent else { return }
parent.browsers.openLinkTab(url, from: peekSourceTab, inBackground: background)
- // Not from inside Chromium's popup callback: the Peek's page closes a turn later.
- if !background { DispatchQueue.main.async { [weak self] in self?.closeWindow() } }
}
/// A popup that needs its opener (a sign-in window) stays a Little Window, over a Peek too:
@@ -1335,8 +1417,10 @@ final class LittleWindow: NSPanel {
func hasActiveAppearance(forStandardWindowButton type: UInt) -> Bool { true }
/// Arc's open animation: ~120 ms from a small rectangle to the full frame.
override func animationResizeTime(_ newFrame: NSRect) -> TimeInterval { LittleMetrics.openDuration }
- /// A Peek is borderless (Arc's card has no title bar) but still takes the keyboard.
- override var canBecomeKey: Bool { true }
+ /// A Peek is borderless (Arc's card has no title bar) but still takes the keyboard, unless it
+ /// waits on its tab out of sight (#242).
+ var isParked = false
+ override var canBecomeKey: Bool { !isParked }
/// A panel never becomes main; a titled window did, and the browser window's active look
/// and the page's hover state follow the main window.
override var canBecomeMain: Bool { styleMask.contains(.titled) }
diff --git a/Sources/Cra/UI/Windows/MainWindowController.swift b/Sources/Cra/UI/Windows/MainWindowController.swift
index bee4180..1b6fed9 100644
--- a/Sources/Cra/UI/Windows/MainWindowController.swift
+++ b/Sources/Cra/UI/Windows/MainWindowController.swift
@@ -488,6 +488,7 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
browsers.show(live, focused: liveFocus, focus: !commandBar.isOpen)
}
shell.layoutContentChildren()
+ syncPeeks(onScreen: panes)
syncRingPanel()
syncSidebarUI()
window?.title = selectedTab?.displayTitle ?? space.title
@@ -1643,10 +1644,17 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
/// one whose close already fades it back doesn't snap that fade.
private var peekVeil = PeekVeil()
- /// `peek` is opening over this window.
- func showPeekVeil(for peek: UUID) {
+ /// `peek` is opening over this window, or back with its tab (`animated` false, #242).
+ func showPeekVeil(for peek: UUID, animated: Bool = true) {
guard peekVeil.show(for: peek) else { return }
- applyPeekVeil(duration: PeekLayout.openVeilDuration, timing: PeekTransition.easeOutCubic)
+ if animated { applyPeekVeil(duration: PeekLayout.openVeilDuration, timing: PeekTransition.easeOutCubic) } else { applyPeekVeil(duration: 0) }
+ }
+
+ /// `peek` waits on its tab while another is on screen (#242): the page snaps back, and the
+ /// Peek can veil it again.
+ func parkPeekVeil(for peek: UUID) {
+ guard peekVeil.hide(for: peek) else { return }
+ applyPeekVeil(duration: 0)
}
/// `peek` is closing: the page comes back over Arc's 0.2 s while the card lands.
@@ -1708,6 +1716,29 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
private var peeks: [LittleWindowController] { app.littleWindows.filter { $0.peekParent === self } }
+ /// Arc keeps a Peek per tab (#242): each shows while its tab is on screen here, waits out of
+ /// sight while another is, and goes with its tab (PeekPresence).
+ private func syncPeeks(onScreen panes: [UUID]) {
+ for p in peeks {
+ switch PeekPresence.of(peekFrom: p.peekSourceTab, onScreen: panes, tabExists: p.peekSourceTab.map { store.item($0) != nil } ?? false) {
+ case .shown: p.unparkPeek()
+ case .parked: p.parkPeek()
+ case .dropped: p.dropPeek()
+ }
+ }
+ }
+
+ /// `tab`'s page closed (a pinned tab's ⌘W keeps its row): its Peek goes with it (#242).
+ func dropPeeks(from tab: UUID) {
+ for p in peeks where p.peekSourceTab == tab { p.dropPeek() }
+ }
+
+ /// cra://debug?peeks: this window's Peeks, on screen or not, and their pages (#242).
+ func peeksShown() -> String {
+ let list = peeks.map { p in "\(p.window.map { $0.isVisible && $0.alphaValue > 0 } == true ? "shown" : "hidden") \(p.currentURL)" }
+ return list.isEmpty ? "none" : list.joined(separator: ", ")
+ }
+
/// The Peek closed last over this window and the tab it came from: Arc's ⇧⌘T brings it back
/// when nothing was archived after it.
var closedPeek: (url: String, tabID: UUID?, at: Date)?
@@ -1747,7 +1778,7 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
let wasSelected = selectedTabID.map(panes.contains) ?? false
for p in panes {
_ = store.resetPinnedTab(p)
- for w in app.mainWindows { w.browsers.unload(p) }
+ for w in app.mainWindows { w.browsers.unload(p); w.dropPeeks(from: p) }
}
// Arc goes back to the tab shown before this one if its page is still loaded, and
// otherwise shows nothing (CloseSuccessor). The panes were just unloaded, so they
diff --git a/Tests/Scenarios/peek-per-tab.scenario b/Tests/Scenarios/peek-per-tab.scenario
new file mode 100644
index 0000000..5fd4535
--- /dev/null
+++ b/Tests/Scenarios/peek-per-tab.scenario
@@ -0,0 +1,54 @@
+# A Peek belongs to the tab it came from, as Arc's (modalByWindowContent). A new-tab link inside the
+# Peek opens a tab (#202), and the Peek waits, hidden, on its pinned tab; back on that tab it is
+# there again with the same page. It goes when its tab goes (GitHub #242).
+# promise: #242
+budget rss=900 stalls50=40
+pace 0.5
+seed settings.json {"hasSeenImportPrompt": true, "toolbarDefaultMigrated": true, "showToolbar": false, "peekInEveryTab": true}
+
+cra://open?url=${PAGE}?n=hub
+expect-log loaded 127\.0\.0\.1 \(HTTP 200\)
+wait 1
+cra://action/pinTab
+wait 0.5
+cra://debug?cdp=Runtime.evaluate&params={"expression":"String(!!window.open('${PAGE}?n=peek'))","userGesture":true}
+expect-log peek: from
+wait 1.5
+cra://debug?peeks=open
+expect-log Cra peeks open: shown \S+n=peek$
+
+cra://debug?target=little&cdp=Runtime.evaluate&params={"expression":"document.body.style.height='4000px'; scrollTo(0, 1234); 'scrolled=' + scrollY"}
+expect-log "value":"scrolled=1234"
+
+# The link the reporter pulls out of the Peek: a tab, selected, and the Peek out of the way.
+cra://debug?target=little&cdp=Runtime.evaluate&params={"expression":"String(!!window.open('${PAGE}?n=link'))","userGesture":true}
+wait 1.5
+cra://debug?peeks=left
+expect-log Cra peeks left: hidden \S+n=peek$
+cra://debug?peekShown=left
+expect-log Cra peek shown left: veiled=0 alpha=1\.00 scale=1\.000
+
+# Back on the pinned tab: the same Peek, over the page faded behind it.
+cra://action/previousTab
+wait 1
+cra://debug?peeks=back
+expect-log Cra peeks back: shown \S+n=peek$
+cra://debug?peekShown=back
+expect-log Cra peek shown back: veiled=1 alpha=0\.28
+# Where the reporter left it.
+cra://debug?target=little&cdp=Runtime.evaluate&params={"expression":"'kept=' + scrollY"}
+expect-log "value":"kept=1234"
+
+# A Peek from a Today tab goes when Clear Today archives its tab; the pinned tab's waits on.
+cra://open?url=${PAGE}?n=today
+wait 1
+cra://debug?cdp=Runtime.evaluate&params={"expression":"String(!!window.open('${PAGE}?n=second'))","userGesture":true}
+wait 1.5
+cra://debug?target=little&cdp=Runtime.evaluate&params={"expression":"String(!!window.open('${PAGE}?n=link2'))","userGesture":true}
+wait 1.5
+cra://debug?peeks=two
+expect-log Cra peeks two: hidden \S+n=peek, hidden \S+n=second$
+cra://action/clearToday
+wait 1
+cra://debug?peeks=cleared
+expect-log Cra peeks cleared: hidden \S+n=peek$
diff --git a/Tests/promises.lock b/Tests/promises.lock
index 5bcb9e3..6bf04bc 100644
--- a/Tests/promises.lock
+++ b/Tests/promises.lock
@@ -367,5 +367,9 @@
#241 Packages/CraCore/Tests/CraCoreTests/PageViewInsetsTests.swift::placesTheViewBelowTheBarInTheCard 7ba2374d493e
#241 Packages/CraCore/Tests/CraCoreTests/PageViewInsetsTests.swift::readsTheBarAboveThePageInEitherSuperview 548a9473598d
#241 Tests/Scenarios/debugger-infobar.scenario 189c93dc5b96
+#242 Packages/CraCore/Tests/CraCoreTests/PeekPresenceTests.swift::aPeekGoesWithItsTab 883c18835e90
+#242 Packages/CraCore/Tests/CraCoreTests/PeekPresenceTests.swift::aPeekWaitsWhileAnotherTabIsOpenAndComesBackWithItsTab 176a47b35b61
+#242 Packages/CraCore/Tests/CraCoreTests/PeekVeilTests.swift::aPeekBackWithItsTabVeilsThePageAgain b7239be288df
+#242 Tests/Scenarios/peek-per-tab.scenario 985d0534cd4f
#243 Packages/CraCore/Tests/CraCoreTests/TabRowTrailingTests.swift::hoveredNameRunsToTheCloseButton 0a8658ede567
#243 Packages/CraCore/Tests/CraCoreTests/TabRowTrailingTests.swift::restingTailIsUnchanged f479053f4258
diff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.md
index dda17af..d36c37d 100644
--- a/docs/arc-reverse-engineering.md
+++ b/docs/arc-reverse-engineering.md
@@ -3047,6 +3047,16 @@ event with `shiftClickModalEntryPointEnabled` set for the run, AX frames and 60
from a pinned tab the top of Today). Not observed in Arc: a ⌘-click inside the Peek (Cra: a background tab,
the Peek stays) and window.open with features (Cra: still a Little Window over the Peek, which keeps the
opener alive for sign-ins).
+- [O static + reported, 8 Nov, GitHub #242] A Peek belongs to its tab. Arc 1.172.1's
+ WindowContents/WindowContentState keeps `modalByWindowContent` (next to `presentationState`,
+ `sourceToWindowContentMap` and `windowContentSidebarItemMap`), a modal per window content, and the
+ reporter (Arc 1.172, daily use) sees the Peek a target=_blank link "closed" there again, same page and
+ scroll, back on its pinned tab. So the 6 Nov run above saw the Peek go out of sight, not end. Cra:
+ PeekPresence (CraCore), MainWindowController.syncPeeks → LittleWindowController.parkPeek /
+ unparkPeek / dropPeek; the tab's row keeps the peeked favicon while the Peek waits (modalIcon).
+ Not observed live: whether a sidebar click with the Peek on screen (the 4 Nov run: "closed the Peek")
+ also only hides it, whether the Peek comes back with a motion (Cra: at once, the page veiled at once),
+ and what a pinned tab's ⌘W does to a Peek waiting on it (Cra: the Peek goes with the page).
### Peek grows out of the link (Arc 1.171, 6 Nov 2026, GitHub #204, offline Arc)
The reporter recorded Arc 1.172.1 growing the card out of the clicked link. 1.172.0/1.172.1 only moved Chromium
diff --git a/docs/release-checklist.md b/docs/release-checklist.md
index 5cd0676..58dea3f 100644
--- a/docs/release-checklist.md
+++ b/docs/release-checklist.md
@@ -74,7 +74,11 @@ built release app with a test profile. Note anything that fails in the release's
the grey picture and the lens follow. With another app full screen, ⌥⌘N opens a Little
Window over it, and doesn't when Settings ▸ Tabs ▸ Links is off.
- **#202:** in a Peek, ⌘-click a `target=_blank` link: a background tab opens and the Peek
- stays. A plain click on it closes the Peek and selects the new tab below the source tab.
+ stays. A plain click on it takes the Peek away and selects the new tab below the source tab.
+- **#242:** Peek a link from a pinned tab, scroll the Peek, click a `target=_blank` link in it: the
+ new tab shows with no Peek and the pinned row keeps the peeked page's favicon. Click the pinned
+ row: the same Peek is back at the same scroll, the page behind faded, and clicks in it work.
+ (Which Peek shows when is the peek-per-tab scenario; this is the look and the scroll.)
- **PR #222:** with a Peek open, the browser window keeps its full shadow and coloured traffic
lights, also after a click in the Peek, as in Arc. A drag from every edge and corner resizes the
window with the Peek open and the card follows; a click on the background 4 pt or more inside