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.
⌘Return opens a background tab from the command bar; closed folders keep the open tab in sight (#85) (#100)
Victor Kildahl93a719f3add1
diff --git a/Packages/CraCore/Sources/CraCore/FolderPeek.swift b/Packages/CraCore/Sources/CraCore/FolderPeek.swiftnew file mode 100644index 0000000..8adc767--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/FolderPeek.swift@@ -0,0 +1,48 @@+/// Arc keeps the open tab in sight when it sits in a closed folder (GitHub #85). Arc 1.171, 2 Nov+/// 2026: picking such a tab (from the command bar, say) leaves the folders closed and lists the+/// tab one level under the outermost closed one, whose glyph gets three dots; Arc's window state+/// keeps it as `expandedItems: [folder: .peeked([tab ids])]`. Opening that folder shows all of it+/// again; closing it keeps only the open tab in sight, as a closed folder always does.+public enum FolderPeek {+ /// The folder a tab is listed under while it is open: the outermost closed one among its+ /// folders, which run from the outermost in. Nil when they are all open.+ public static func host<ID: Hashable>(folders: [ID], isExpanded: (ID) -> Bool) -> ID? {+ folders.first { !isExpanded($0) }+ }++ /// The peeks once `tab` is open; tabs already peeked stay, as in Arc.+ public static func opening<ID: Hashable>(_ tab: ID, folders: [ID], isExpanded: (ID) -> Bool,+ peeks: [ID: [ID]]) -> [ID: [ID]] {+ guard let host = host(folders: folders, isExpanded: isExpanded), peeks[host]?.contains(tab) != true else { return peeks }+ var out = peeks+ out[host, default: []].append(tab)+ return out+ }++ /// The peeks once `folder` opens (nothing to keep in sight) or closes (only the open tab,+ /// when it is inside).+ public static func expanding<ID: Hashable>(_ folder: ID, _ expanded: Bool, openTabInside: ID?,+ peeks: [ID: [ID]]) -> [ID: [ID]] {+ var out = peeks+ out[folder] = expanded ? nil : openTabInside.map { [$0] }+ return out+ }++ /// The peeks once `tab` closes (⌘W) or leaves the sidebar.+ public static func removing<ID: Hashable>(_ tab: ID, peeks: [ID: [ID]]) -> [ID: [ID]] {+ var out: [ID: [ID]] = [:]+ for (folder, tabs) in peeks {+ let kept = tabs.filter { $0 != tab }+ if !kept.isEmpty { out[folder] = kept }+ }+ return out+ }++ /// The rows a closed folder lists under itself: its peeked tabs that are still inside it,+ /// in sidebar order (`tabsInside`, nested folders included).+ public static func listed<ID: Hashable>(in folder: ID, peeks: [ID: [ID]], tabsInside: [ID]) -> [ID] {+ guard let peeked = peeks[folder], !peeked.isEmpty else { return [] }+ let wanted = Set(peeked)+ return tabsInside.filter(wanted.contains)+ }+}diff --git a/Packages/CraCore/Sources/CraCore/KeyChord.swift b/Packages/CraCore/Sources/CraCore/KeyChord.swiftindex 263f68c..3fd8b59 100644--- a/Packages/CraCore/Sources/CraCore/KeyChord.swift+++ b/Packages/CraCore/Sources/CraCore/KeyChord.swift@@ -22,6 +22,13 @@ public struct KeyChord: Codable, Hashable {public var keys: Modifiers { Modifiers(rawValue: modifiers) }+ /// Return or the keypad's Enter (key codes 36, 76) with ⌘ and no other modifier: the command+ /// bar opens the row in a background tab (Arc, GitHub #85). A text field has no key binding+ /// for it and reports noop:, so the bar reads the event with this.+ public static func isCommandReturn(keyCode: UInt16, modifiers: UInt) -> Bool {+ [36, 76].contains(keyCode) && Modifiers(rawValue: modifiers).intersection([.shift, .control, .option, .command]) == .command+ }+public static let tab = "\t"// AppKit's function-key characters (NSLeftArrowFunctionKey...).public static let left = "\u{F702}"diff --git a/Packages/CraCore/Sources/CraCore/SidebarModel.swift b/Packages/CraCore/Sources/CraCore/SidebarModel.swiftindex 1958d31..6ea93bb 100644--- a/Packages/CraCore/Sources/CraCore/SidebarModel.swift+++ b/Packages/CraCore/Sources/CraCore/SidebarModel.swift@@ -524,6 +524,8 @@ public struct WindowPrefs: Codable, Equatable {public var sidebarWidth: Double = 328public var expandedFolders: Set<UUID> = []public var collapsedPinnedSpaces: Set<UUID> = []+ /// Closed folders that keep tabs in sight (FolderPeek): folder → its peeked tabs.+ public var peekedFolders: [UUID: [UUID]] = [:]/// Open browser windows, restored at launch. Never empty.public var windows: [WindowSession] = [WindowSession()]@@ -537,10 +539,11 @@ public struct WindowPrefs: Codable, Equatable {public var littleWindowSize: String?public init(sidebarWidth: Double = 328, expandedFolders: Set<UUID> = [], collapsedPinnedSpaces: Set<UUID> = [],- windows: [WindowSession] = [WindowSession()], littleWindowSize: String? = nil) {+ peekedFolders: [UUID: [UUID]] = [:], windows: [WindowSession] = [WindowSession()], littleWindowSize: String? = nil) {self.sidebarWidth = sidebarWidthself.expandedFolders = expandedFoldersself.collapsedPinnedSpaces = collapsedPinnedSpaces+ self.peekedFolders = peekedFoldersself.windows = windowsself.littleWindowSize = littleWindowSize}@@ -633,6 +636,7 @@ extension WindowPrefs {sidebarWidth = try c.decodeIfPresent(Double.self, forKey: .sidebarWidth) ?? 328expandedFolders = try c.decodeIfPresent(Set<UUID>.self, forKey: .expandedFolders) ?? []collapsedPinnedSpaces = try c.decodeIfPresent(Set<UUID>.self, forKey: .collapsedPinnedSpaces) ?? []+ peekedFolders = (try? c.decodeIfPresent([UUID: [UUID]].self, forKey: .peekedFolders)) ?? [:]if let saved = try? c.decodeIfPresent([WindowSession].self, forKey: .windows), !saved.isEmpty {windows = saved} else {diff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/windows.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/windows.jsonindex e314bcd..468b3d3 100644--- a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/windows.json+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/windows.json@@ -1,5 +1,6 @@{"sidebarWidth": 280, "expandedFolders": ["D0000000-0000-0000-0000-000000000002"], "collapsedPinnedSpaces": ["A0000000-0000-0000-0000-000000000002"],+ "peekedFolders": ["D0000000-0000-0000-0000-000000000005", ["D0000000-0000-0000-0000-000000000004"]],"littleWindowSize": "{480, 640}","windows": [{"id": "F0000000-0000-0000-0000-000000000001", "focusedSpaceID": "A0000000-0000-0000-0000-000000000001",diff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/windows.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/windows.jsonindex 75e6d6d..6cf9dbe 100644--- a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/windows.json+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/windows.json@@ -6,6 +6,12 @@"D0000000-0000-0000-0000-000000000002"],"littleWindowSize" : "{480, 640}",+ "peekedFolders" : [+ "D0000000-0000-0000-0000-000000000005",+ [+ "D0000000-0000-0000-0000-000000000004"+ ]+ ],"sidebarWidth" : 280,"windows" : [{diff --git a/Packages/CraCore/Tests/CraCoreTests/FolderPeekTests.swift b/Packages/CraCore/Tests/CraCoreTests/FolderPeekTests.swiftnew file mode 100644index 0000000..31e992a--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/FolderPeekTests.swift@@ -0,0 +1,49 @@+import CraCore+import Testing++/// A closed folder keeps its open tab in sight (Arc 1.171, GitHub #85).+struct FolderPeekTests {+ // Pinned: outer ▸ inner ▸ tab, both closed unless a test opens them.+ let outer = "outer", inner = "inner", tab = "tab", other = "other"++ @Test func outermostClosedFolderHostsTheTab() {+ #expect(FolderPeek.host(folders: [outer, inner], isExpanded: { _ in false }) == outer)+ #expect(FolderPeek.host(folders: [outer, inner], isExpanded: { $0 == outer }) == inner)+ #expect(FolderPeek.host(folders: [outer, inner], isExpanded: { _ in true }) == nil)+ #expect(FolderPeek.host(folders: [String](), isExpanded: { _ in false }) == nil)+ }++ @Test func openingATabInClosedFoldersPeeksItUnderTheOutermost() {+ let peeks = FolderPeek.opening(tab, folders: [outer, inner], isExpanded: { _ in false }, peeks: [:])+ #expect(peeks == [outer: [tab]])+ // Again: nothing changes. Another tab joins the same peek, the first one stays (Arc).+ #expect(FolderPeek.opening(tab, folders: [outer, inner], isExpanded: { _ in false }, peeks: peeks) == peeks)+ #expect(FolderPeek.opening(other, folders: [outer], isExpanded: { _ in false }, peeks: peeks) == [outer: [tab, other]])+ }++ @Test func openingATabInOpenFoldersPeeksNothing() {+ #expect(FolderPeek.opening(tab, folders: [outer, inner], isExpanded: { _ in true }, peeks: [:]).isEmpty)+ #expect(FolderPeek.opening(tab, folders: [String](), isExpanded: { _ in false }, peeks: [:]).isEmpty)+ }++ @Test func openingTheFolderDropsItsPeekClosingKeepsTheOpenTab() {+ let peeks = [outer: [tab, other]]+ #expect(FolderPeek.expanding(outer, true, openTabInside: tab, peeks: peeks).isEmpty)+ #expect(FolderPeek.expanding(outer, false, openTabInside: tab, peeks: [:]) == [outer: [tab]])+ #expect(FolderPeek.expanding(outer, false, openTabInside: nil, peeks: peeks).isEmpty)+ // Other folders' peeks are left alone.+ #expect(FolderPeek.expanding(inner, true, openTabInside: nil, peeks: peeks) == peeks)+ }++ @Test func closingATabDropsItFromEveryPeek() {+ let peeks = [outer: [tab, other], inner: [tab]]+ #expect(FolderPeek.removing(tab, peeks: peeks) == [outer: [other]])+ #expect(FolderPeek.removing(other, peeks: [outer: [other]]).isEmpty)+ }++ @Test func listedRowsFollowTheSidebarAndSkipTabsThatLeft() {+ let peeks = [outer: [other, tab, "moved away"]]+ #expect(FolderPeek.listed(in: outer, peeks: peeks, tabsInside: ["a", tab, other]) == [tab, other])+ #expect(FolderPeek.listed(in: inner, peeks: peeks, tabsInside: [tab]).isEmpty)+ }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/KeyChordTests.swift b/Packages/CraCore/Tests/CraCoreTests/KeyChordTests.swiftindex 5022ca7..beed7ad 100644--- a/Packages/CraCore/Tests/CraCoreTests/KeyChordTests.swift+++ b/Packages/CraCore/Tests/CraCoreTests/KeyChordTests.swift@@ -33,4 +33,19 @@ struct KeyChordTests {let chord = KeyChord(key: "s", modifiers: Self.command | KeyChord.Modifiers.shift.rawValue)#expect(chord.keys == KeyChord.Modifiers([.command, .shift]))}++ /// ⌘Return opens the command bar's row in a background tab (GitHub #85).+ @Test(arguments: [+ (UInt16(36), command, true), // ⌘Return+ (76, command, true), // ⌘Enter on the keypad+ (36, command | 0x10000 | 0x800000, true), // Caps Lock and the function-key bit don't count+ (36, 0, false), // Return+ (36, command | KeyChord.Modifiers.shift.rawValue, false),+ (36, command | KeyChord.Modifiers.option.rawValue, false),+ (36, KeyChord.Modifiers.control.rawValue, false),+ (37, command, false), // ⌘L+ ])+ func commandReturn(keyCode: UInt16, modifiers: UInt, matches: Bool) {+ #expect(KeyChord.isCommandReturn(keyCode: keyCode, modifiers: modifiers) == matches)+ }}diff --git a/Sources/Cra/Services/SidebarStore.swift b/Sources/Cra/Services/SidebarStore.swiftindex 0beb0e0..b3c7411 100644--- a/Sources/Cra/Services/SidebarStore.swift+++ b/Sources/Cra/Services/SidebarStore.swift@@ -426,6 +426,10 @@ final class SidebarStore {split.data = .split(s)items[p] = split}+ // In a closed folder the tab shows under the outermost closed one (Arc, GitHub #85).+ let peeks = FolderPeek.opening(id, folders: folderChain(of: id), isExpanded: { self._prefs.expandedFolders.contains($0) },+ peeks: _prefs.peekedFolders)+ if peeks != _prefs.peekedFolders { prefs.peekedFolders = peeks }if !isIncognito(space: sid) {var dates = ranking.recentlySwitchedToTabs[id] ?? []dates.append(clock.now)@@ -498,6 +502,9 @@ final class SidebarStore {t.url = t.savedURLit.data = .tab(t)items[id] = it+ // Closed, it no longer shows under a closed folder (Arc).+ let peeks = FolderPeek.removing(id, peeks: _prefs.peekedFolders)+ if peeks != _prefs.peekedFolders { prefs.peekedFolders = peeks }touch()return t.savedURL}@@ -1056,6 +1063,26 @@ final class SidebarStore {return _prefs.expandedFolders.contains(id)}+ /// The tabs a closed folder lists under itself (FolderPeek), in sidebar order.+ func peekedTabs(in folder: UUID) -> [SidebarItem] {+ items.observe(folder)+ guard _prefs.peekedFolders[folder] != nil else { return [] }+ let inside = tabs(under: folder)+ let listed = Set(FolderPeek.listed(in: folder, peeks: _prefs.peekedFolders, tabsInside: inside.map(\.id)))+ return inside.filter { listed.contains($0.id) }+ }++ /// The folders an item sits in, outermost first.+ private func folderChain(of id: UUID) -> [UUID] {+ var out: [UUID] = []+ var p = items[id]?.parentID+ while let pid = p, let parent = items[pid] {+ if parent.isFolder { out.insert(pid, at: 0) }+ p = parent.parentID+ }+ return out+ }+/// Whether `id` is the open tab of the window's focused space, or of `space`.func isSelected(_ id: UUID, inSpace space: UUID? = nil, window: UUID?) -> Bool {items.observe(id)@@ -1076,6 +1103,9 @@ final class SidebarStore {private func notifyItemReaders(of old: WindowPrefs) {for id in old.expandedFolders.symmetricDifference(prefs.expandedFolders) { items.notify(id) }for id in old.collapsedPinnedSpaces.symmetricDifference(prefs.collapsedPinnedSpaces) { items.notify(id) }+ for id in Set(old.peekedFolders.keys).union(prefs.peekedFolders.keys) where old.peekedFolders[id] != prefs.peekedFolders[id] {+ items.notify(id)+ }let first = spaceOrder.firstfor w in prefs.windows {let was = old.windows.first { $0.id == w.id }@@ -1090,7 +1120,12 @@ final class SidebarStore {}}func setExpanded(_ id: UUID, _ expanded: Bool) {- if expanded { prefs.expandedFolders.insert(id) } else { prefs.expandedFolders.remove(id) }+ var p = prefs+ if expanded { p.expandedFolders.insert(id) } else { p.expandedFolders.remove(id) }+ // Open, it shows everything; closed again, only the open tab stays in sight (Arc).+ let open = selectedTabID.flatMap { folderChain(of: $0).contains(id) ? $0 : nil }+ p.peekedFolders = FolderPeek.expanding(id, expanded, openTabInside: open, peeks: p.peekedFolders)+ if p != prefs { prefs = p }}/// Arc's spacesWithCollapsedPinnedSections: clicking the space name hides its pinned tabs.diff --git a/Sources/Cra/UI/CommandBar/CommandBarController.swift b/Sources/Cra/UI/CommandBar/CommandBarController.swiftindex 5d11a42..1881fd2 100644--- a/Sources/Cra/UI/CommandBar/CommandBarController.swift+++ b/Sources/Cra/UI/CommandBar/CommandBarController.swift@@ -38,7 +38,9 @@ final class CommandBarController {unowned let engine: SuggestionEngineunowned let store: SidebarStore- var onCommit: (Suggestion?, String, CommandBarMode, Bool) -> Void = { _, _, _, _ in }+ var onCommit: (Suggestion?, String, CommandBarMode) -> Void = { _, _, _ in }+ /// Opens the row in a background tab; false when it has no page to open there.+ var onOpenInBackground: (Suggestion?, String) -> Bool = { _, _ in false }var onClose: () -> Void = {}init(engine: SuggestionEngine, store: SidebarStore) {@@ -185,20 +187,35 @@ final class CommandBarController {return true}- func commit(forceNewTab: Bool) {+ func commit() {+ guard let (selected, typed) = committed() else { return }+ close()+ onCommit(selected, typed, mode)+ }++ /// ⌘Return (Arc): the row's page opens in a new background tab and the bar stays open with+ /// what was typed, so the next ⌘Return opens another. Rows that open no page, and hosts with+ /// no tabs to open (a Little Window), take it as Return.+ func commitInBackground() {+ guard let (selected, typed) = committed() else { return }+ if onOpenInBackground(selected, typed) { return }+ close()+ onCommit(selected, typed, mode)+ }++ private func committed() -> (Suggestion?, String)? {let selected = result.items.indices.contains(selectedIndex) ? result.items[selectedIndex] : nil// No tab matched: Return has nowhere to go, and the tabs scope never searches the web.- if scope == .tabs, selected == nil { return }+ if scope == .tabs, selected == nil { return nil }var typed = query// Enter on the typed row with an inline completion goes to the completion.if selectedIndex == 0, let c = result.inlineCompletion, selected?.id == "typed" { typed = c }- close()- onCommit(selected, typed, mode, forceNewTab)+ return (selected, typed)}func commit(_ suggestion: Suggestion) {close()- onCommit(suggestion, query, mode, false)+ onCommit(suggestion, query, mode)}func close() {diff --git a/Sources/Cra/UI/CommandBar/CommandTextField.swift b/Sources/Cra/UI/CommandBar/CommandTextField.swiftindex 1870ca9..1c80086 100644--- a/Sources/Cra/UI/CommandBar/CommandTextField.swift+++ b/Sources/Cra/UI/CommandBar/CommandTextField.swift@@ -107,6 +107,13 @@ final class CommandTextField {suppressChange = false}+ /// If a completion suffix is selected, Enter means "go there".+ private func acceptSelectedCompletion(_ textView: NSTextView) {+ guard pendingCompletion != nil, textView.selectedRange.length > 0 else { return }+ lastTyped = textView.string+ controller.update(query: textView.string, allowCompletion: false)+ }+func controlTextDidChange(_ obj: Notification) {guard !suppressChange, let field else { return }let text = field.stringValue@@ -123,13 +130,14 @@ final class CommandTextField {case #selector(NSResponder.moveUp(_:)):controller.moveSelection(by: -1); return truecase #selector(NSResponder.insertNewline(_:)):- let cmd = NSApp.currentEvent?.modifierFlags.contains(.command) ?? false- // If a completion suffix is selected, Enter means "go there".- if pendingCompletion != nil, textView.selectedRange.length > 0 {- lastTyped = textView.string- controller.update(query: textView.string, allowCompletion: false)- }- controller.commit(forceNewTab: cmd)+ acceptSelectedCompletion(textView)+ controller.commit()+ return true+ // The key bindings have nothing for ⌘Return, so the field editor sends noop:, never+ // insertNewline: (GitHub #85).+ case Selector(("noop:")) where NSApp.currentEvent.map { $0.type == .keyDown && Shortcut.isCommandReturn(keyCode: $0.keyCode, modifiers: $0.modifierFlags.rawValue) } == true:+ acceptSelectedCompletion(textView)+ controller.commitInBackground()return truecase #selector(NSResponder.cancelOperation(_:)):if controller.scope != nil { controller.cancelScope() } else { controller.close() }diff --git a/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swift b/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swiftindex d0f19e2..a63b1fd 100644--- a/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swift+++ b/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swift@@ -397,6 +397,8 @@ final class FolderGlyphView: NSView {private let fill = NSImageView()private let outline = NSImageView()private let mark = NSImageView()+ /// Arc's peeked folder (FolderPeek): three 2 pt dots on a 4 pt pitch in the closed body.+ private let dots = CAShapeLayer()override init(frame: NSRect) {super.init(frame: frame)@@ -411,6 +413,8 @@ final class FolderGlyphView: NSView {mark.image = GitHubMark.imagemark.imageScaling = .scaleProportionallyUpOrDownaddSubview(mark)+ wantsLayer = true+ layer?.addSublayer(dots)}required init?(coder: NSCoder) { fatalError() }@@ -418,18 +422,29 @@ final class FolderGlyphView: NSView {override var isFlipped: Bool { true }override func hitTest(_ point: NSPoint) -> NSView? { nil }- func show(expanded: Bool, live: Bool, tint: NSColor, fillColor: NSColor) {+ func show(expanded: Bool, peeked: Bool = false, live: Bool, tint: NSColor, fillColor: NSColor) {fill.isHidden = expandedfill.contentTintColor = fillColoroutline.contentTintColor = tintmark.isHidden = !livemark.contentTintColor = tint+ dots.isHidden = !peeked || expanded || live+ dots.fillColor = tint.cgColorneedsLayout = true}override func layout() {super.layout()mark.frame = NSRect(x: (bounds.width - 7) / 2, y: (bounds.height - 7) / 2 + 1.5, width: 7, height: 7)+ CATransaction.begin()+ CATransaction.setDisableActions(true)+ dots.frame = bounds+ let path = CGMutablePath()+ // On whole points, so each dot is two pixels square at 1x.+ let y = (bounds.height / 2 + 1.5).rounded(.down) - 1+ for i in -1...1 { path.addEllipse(in: CGRect(x: (bounds.width / 2).rounded(.down) + CGFloat(i) * 4 - 1, y: y, width: 2, height: 2)) }+ dots.path = path+ CATransaction.commit()}}@@ -998,6 +1013,8 @@ struct FolderRowModel: Equatable {var renameText: Stringvar editing: Boolvar expanded: Bool+ /// Closed with tabs kept in sight under it (FolderPeek): Arc draws three dots in the glyph.+ var peeked: Boolvar live: Boolvar tint: NSColorvar fill: NSColor@@ -1030,7 +1047,7 @@ final class FolderRowView: SidebarRowView, NSTextFieldDelegate {func apply(_ m: FolderRowModel) {guard m != model else { return }model = m- glyph.show(expanded: m.expanded, live: m.live, tint: m.tint, fillColor: m.fill)+ glyph.show(expanded: m.expanded, peeked: m.peeked, live: m.live, tint: m.tint, fillColor: m.fill)titleLabel.stringValue = m.titletitleLabel.textColor = colors.textPrimarysetAccessibilityLabel(m.title)diff --git a/Sources/Cra/UI/Sidebar/List/SpaceListView.swift b/Sources/Cra/UI/Sidebar/List/SpaceListView.swiftindex fe10b7f..024227f 100644--- a/Sources/Cra/UI/Sidebar/List/SpaceListView.swift+++ b/Sources/Cra/UI/Sidebar/List/SpaceListView.swift@@ -248,17 +248,25 @@ final class SpaceListView: NSView, NSDraggingSource {var row = Row(key: .item(item.id), content: .newTab(active: false), decor: decor(item.id), itemID: item.id, parent: parent, index: index, depth: depth)if item.isFolder {let expanded = store.isExpanded(item.id)+ let peeked = expanded ? [] : store.peekedTabs(in: item.id)let glyph = palette.folderColors(item.folderIcon)row.content = .folder(FolderRowModel(id: item.id, depth: depth, title: item.title ?? "Folder", renameText: item.title ?? "",- editing: renaming == item.id, expanded: expanded, live: item.isLiveFolder,+ editing: renaming == item.id, expanded: expanded, peeked: !peeked.isEmpty, live: item.isLiveFolder,tint: NSColor(glyph.tint), fill: NSColor(glyph.fill),tabCount: expanded ? 0 : store.tabs(under: item.id).count,liveBusy: refreshing.contains(item.id), liveError: item.liveFolder.flatMap(LiveFolderText.warning)?.help,liveSignInURL: item.liveFolder.flatMap(LiveFolderText.warning)?.signInURL,liveHelp: LiveFolderText.refreshHelp(item.liveFolder)))out.append(row)- guard expanded else { return }+ guard expanded else {+ // Arc keeps the open tab of a closed folder in sight, one level in (FolderPeek).+ for t in peeked {+ let index = t.parentID.flatMap { store.item($0)?.children.firstIndex(of: t.id) } ?? 0+ add(t, depth: depth + 1, pinned: pinned, parent: t.parentID ?? item.id, index: index)+ }+ return+ }let kids = item.childrenfor c in store.children(of: item.id) {add(c, depth: depth + 1, pinned: pinned, parent: item.id, index: kids.firstIndex(of: c.id) ?? 0)diff --git a/Sources/Cra/UI/Windows/BackgroundTabToast.swift b/Sources/Cra/UI/Windows/BackgroundTabToast.swiftnew file mode 100644index 0000000..5c8b091--- /dev/null+++ b/Sources/Cra/UI/Windows/BackgroundTabToast.swift@@ -0,0 +1,152 @@+import AppKit+import QuartzCore++/// Arc's "New Tab Created" toast (Toasts.ShinyToastView, the `backgroundTabCreated` toast), shown+/// when ⌘Return in the command bar opens a tab the sidebar can't show because it is hidden+/// (GitHub #85). Arc 1.171, measured 2 Nov 2026 at 1x: a 42 pt pill 8 pt below the top of the+/// page and 9 pt in from its right edge, 14 pt medium black text with 12 pt either side, a fill+/// from the space's colours with a 1 pt darker outline. It springs in from its top centre+/// (≈0.3 s response, 4 % overshoot), stays 4.85 s and shrinks back into its top in 80 ms.+@MainActor+final class BackgroundTabToast {+ static let height: CGFloat = 42+ static let topInset: CGFloat = 8+ static let trailingInset: CGFloat = 9+ static let padding: CGFloat = 12+ static let cornerRadius: CGFloat = 10+ /// Room around the pill in its panel, so the spring's overshoot isn't clipped.+ static let margin: CGFloat = 8+ static let font = NSFont.systemFont(ofSize: 14, weight: .medium)+ /// How long the toast stays up after the last tab it announced.+ static let visibleFor: TimeInterval = 4.85++ private let panel: NSPanel+ private let pill = CALayer()+ private let label = CATextLayer()+ private var hide: DispatchWorkItem?++ init() {+ panel = NSPanel(contentRect: NSRect(x: 0, y: 0, width: 140, height: Self.height),+ styleMask: [.borderless, .nonactivatingPanel], backing: .buffered, defer: false)+ panel.isOpaque = false+ panel.backgroundColor = .clear+ panel.hasShadow = false+ panel.ignoresMouseEvents = true+ panel.hidesOnDeactivate = false+ let view = NSView(frame: panel.contentLayoutRect)+ view.wantsLayer = true+ panel.contentView = view+ pill.cornerRadius = Self.cornerRadius+ pill.cornerCurve = .continuous+ pill.borderWidth = 1+ label.font = Self.font+ label.fontSize = Self.font.pointSize+ label.alignmentMode = .center+ label.foregroundColor = NSColor.black.cgColor+ pill.addSublayer(label)+ view.layer?.addSublayer(pill)+ }++ var isShown: Bool { panel.parent != nil }++ /// Shows `text` at the top right of `page` (window coordinates) over `window`'s pages.+ func show(_ text: String, page: NSRect, in window: NSWindow, theme: SpaceTheme) {+ let width = ceil((text as NSString).size(withAttributes: [.font: Self.font]).width) + 2 * Self.padding+ let local = NSRect(x: page.maxX - Self.trailingInset - width, y: page.maxY - Self.topInset - Self.height,+ width: width, height: Self.height)+ panel.setFrame(window.convertToScreen(local.insetBy(dx: -Self.margin, dy: -Self.margin)), display: false)+ let scale = window.backingScaleFactor+ let colors = Self.colors(theme)+ CATransaction.begin()+ CATransaction.setDisableActions(true)+ // Anchored at the top centre, where Arc's toast grows from.+ pill.anchorPoint = CGPoint(x: 0.5, y: 1)+ pill.bounds = CGRect(x: 0, y: 0, width: width, height: Self.height)+ pill.position = CGPoint(x: Self.margin + width / 2, y: Self.margin + Self.height)+ pill.backgroundColor = colors.fill.cgColor+ pill.borderColor = colors.outline.cgColor+ label.contentsScale = scale+ label.string = text+ let lineHeight = ceil(Self.font.ascender - Self.font.descender)+ label.frame = CGRect(x: 0, y: (Self.height - lineHeight) / 2, width: width, height: lineHeight)+ CATransaction.commit()+ if !isShown {+ // Opening the tab's page holds the main thread for ~0.1 s, so the toast waits for the+ // next turn, invisible: started now, its first frame showed it most of the way in.+ setOpacity(0)+ window.addChildWindow(panel, ordered: .above)+ DispatchQueue.main.async { [weak self] in self?.springIn() }+ } else {+ if panel.parent !== window { window.addChildWindow(panel, ordered: .above) }+ setOpacity(1)+ }+ hide?.cancel()+ let work = DispatchWorkItem { [weak self] in self?.dismiss() }+ hide = work+ DispatchQueue.main.asyncAfter(deadline: .now() + Self.visibleFor, execute: work)+ }++ private func springIn() {+ guard isShown else { return }+ let spring = CASpringAnimation(keyPath: "transform.scale")+ spring.fromValue = 0.4+ spring.toValue = 1+ // ω = 2π / 0.3 s, damping ratio 0.67: Arc's 4 % overshoot ~0.2 s in, settled by 0.4 s.+ spring.mass = 1+ spring.stiffness = 440+ spring.damping = 28+ spring.duration = spring.settlingDuration+ // A new child window reaches the screen a frame or two late; hold the start until then.+ // No fade: Arc's first frame is the small pill at full colour (0.41 of its width).+ spring.beginTime = CACurrentMediaTime() + 0.03+ spring.fillMode = .backwards+ pill.add(spring, forKey: "appear")+ setOpacity(1)+ }++ /// The model value only; the explicit animations above are the ones that show.+ private func setOpacity(_ value: Float) {+ CATransaction.begin()+ CATransaction.setDisableActions(true)+ pill.opacity = value+ CATransaction.commit()+ }++ func dismiss() {+ hide?.cancel()+ hide = nil+ guard isShown else { return }+ CATransaction.begin()+ CATransaction.setCompletionBlock { [weak self] in+ MainActor.assumeIsolated {+ guard let self, self.hide == nil else { return }+ self.panel.parent?.removeChildWindow(self.panel)+ self.panel.orderOut(nil)+ }+ }+ let shrink = CABasicAnimation(keyPath: "transform.scale")+ shrink.fromValue = 1+ shrink.toValue = 0.4+ let fade = CABasicAnimation(keyPath: "opacity")+ fade.fromValue = 1+ fade.toValue = 0+ let group = CAAnimationGroup()+ group.animations = [shrink, fade]+ group.duration = 0.08+ pill.add(group, forKey: "fade")+ setOpacity(0)+ CATransaction.commit()+ }++ /// Arc builds it from the window's background (ShinyToastBackgroundBasedPalette). Fitted to one+ /// theme (a yellow/green one, fill ≈ 214/222/174 sRGB mid-height): the theme colours' mean 70 %+ /// of the way to white, 8 % darker, and the outline at 69 % of that.+ static func colors(_ theme: SpaceTheme) -> (fill: NSColor, outline: NSColor) {+ let comps = theme.colors.compactMap(HexColor.components)+ guard !comps.isEmpty else { return (NSColor(white: 0.9, alpha: 1), NSColor(white: 0.62, alpha: 1)) }+ let n = Double(comps.count)+ func channel(_ v: Double) -> Double { (v / n + (1 - v / n) * 0.7) * 0.92 }+ let r = channel(comps.reduce(0) { $0 + $1.r }), g = channel(comps.reduce(0) { $0 + $1.g }), b = channel(comps.reduce(0) { $0 + $1.b })+ return (NSColor(srgbRed: r, green: g, blue: b, alpha: 1), NSColor(srgbRed: r * 0.69, green: g * 0.69, blue: b * 0.69, alpha: 1))+ }+}diff --git a/Sources/Cra/UI/Windows/LittleWindowController.swift b/Sources/Cra/UI/Windows/LittleWindowController.swiftindex a0117f3..bb10614 100644--- a/Sources/Cra/UI/Windows/LittleWindowController.swift+++ b/Sources/Cra/UI/Windows/LittleWindowController.swift@@ -193,7 +193,7 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @precocommandHost = CommandBarView(controller: commandBar, favicons: app.favicons)commandPanel.contentView = commandHostcommandPanel.delegate = self- commandBar.onCommit = { [weak self] s, typed, mode, force in self?.handleCommit(s, typed: typed, mode: mode, forceNewTab: force) }+ commandBar.onCommit = { [weak self] s, typed, mode in self?.handleCommit(s, typed: typed, mode: mode) }commandBar.onClose = { [weak self] in self?.hideCommandPanel() }commandBar.spaceName = { [weak self] id in self?.store.space(id)?.title ?? "" }@@ -407,7 +407,7 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @precofocusPage()}- private func handleCommit(_ s: Suggestion?, typed: String, mode: CommandBarMode, forceNewTab: Bool) {+ private func handleCommit(_ s: Suggestion?, typed: String, mode: CommandBarMode) {let query = commandBar.queryfunc open(_ url: String) {store.recordQuerySelection(query: query, url: url)diff --git a/Sources/Cra/UI/Windows/MainWindowController.swift b/Sources/Cra/UI/Windows/MainWindowController.swiftindex b0bf2a5..5712d0b 100644--- a/Sources/Cra/UI/Windows/MainWindowController.swift+++ b/Sources/Cra/UI/Windows/MainWindowController.swift@@ -47,6 +47,7 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserMprivate var lastSidebarWidth: CGFloat = 0private var commandBarOpenedAt = Date.distantPastprivate var commandBarClosingClick = DismissingClick()+ private let backgroundTabToast = BackgroundTabToast()private var commandObserving = false/// Closed for good (another window stayed open): it no longer follows the store.private var isTornDown = false@@ -293,7 +294,8 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserMself?.app.perform(id)}}- commandBar.onCommit = { [weak self] s, typed, mode, force in self?.handleCommit(s, typed: typed, mode: mode, forceNewTab: force) }+ commandBar.onCommit = { [weak self] s, typed, mode in self?.handleCommit(s, typed: typed, mode: mode) }+ commandBar.onOpenInBackground = { [weak self] s, typed in self?.openInBackground(s, typed: typed) ?? false }commandBar.onClose = { [weak self] in self?.hideCommandPanel() }commandBar.spaceName = { [weak self] id in self?.store.space(id)?.title ?? "" }}@@ -2125,12 +2127,12 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserMcurrentBrowser?.setFocused(true)}- private func handleCommit(_ s: Suggestion?, typed: String, mode: CommandBarMode, forceNewTab: Bool) {+ private func handleCommit(_ s: Suggestion?, typed: String, mode: CommandBarMode) {let query = commandBar.queryfunc open(_ url: String) {store.recordQuerySelection(query: query, url: url)let fillsEmptyPane = selectedTab?.isEmptyTab == true- if (mode == .editURL || fillsEmptyPane) && !forceNewTab, selectedTabID != nil {+ if mode == .editURL || fillsEmptyPane, selectedTabID != nil {loadInSelectedTab(url)} else {store.createTab(url: url, window: windowID)@@ -2165,6 +2167,38 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM}}+ /// ⌘Return in the bar (Arc): the row's page in a new background tab, the current tab staying+ /// in front; an open tab's row opens its address again rather than switching (GitHub #85).+ private func openInBackground(_ s: Suggestion?, typed: String) -> Bool {+ let url: String?+ switch s?.kind {+ case nil:+ url = typed.isEmpty ? nil : SuggestionEngine.looksLikeURL(typed) ? SuggestionEngine.urlFromInput(typed) : store.settings.searchEngine.searchURL(typed)+ case .navigate?:+ url = typed == commandBar.query ? (s?.url ?? SuggestionEngine.urlFromInput(typed)) : SuggestionEngine.urlFromInput(typed)+ case .search?:+ url = s?.url ?? store.settings.searchEngine.searchURL(typed)+ case .switchToTab?, .archived?, .history?, .topDomain?:+ url = s?.url+ default:+ url = nil+ }+ guard let url, !url.isEmpty else { return false }+ store.recordQuerySelection(query: commandBar.query, url: url)+ let tab = store.createTab(url: url, select: false, window: windowID)+ store.markUnread(tab.id, false) // Arc saves these read, unlike a link opened in the background+ // Creating the page takes key from the bar; it takes key back and stays open, as while+ // opening (windowDidResignKey).+ commandBarOpenedAt = Date()+ browsers.ensureRuntime(for: tab.id) // load it so the title and favicon fill in+ // With the sidebar out the new row shows there; hidden, Arc says so in a toast.+ if !sidebarVisible, let window {+ let page = shell.webContainer.convert(shell.webContainer.bounds, to: nil)+ backgroundTabToast.show("New Tab Created", page: page, in: window, theme: focusedSpace.theme)+ }+ return true+ }+/// Navigate the focused tab (an empty split pane gets its first page here).func loadInSelectedTab(_ url: String) {guard let id = selectedTabID else { return }diff --git a/Tests/StoreTests.swift b/Tests/StoreTests.swiftindex 6738fa8..ea86f8f 100644--- a/Tests/StoreTests.swift+++ b/Tests/StoreTests.swift@@ -28,6 +28,7 @@ enum StoreTests {incognitoStaysOffDisk()pinnedURL()moveTabToSpace()+ folderPeek()print("Store: \(checks) checks passed")}@@ -394,6 +395,45 @@ enum StoreTests {expect(store.integrityProblems().isEmpty, "the sidebar stays sound")}+ /// A closed folder keeps its open tab in sight (Arc, GitHub #85): picking a tab two closed+ /// folders down lists it under the outer one without opening either.+ @MainActor+ private static func folderPeek() {+ let store = AppComposition(clock: ManualScheduler()).store+ let outer = store.createFolder(named: "Outer", in: store.focusedSpace.pinnedContainerID)+ let inner = store.createFolder(named: "Inner", in: outer.id)+ let tab = store.createTab(url: "https://example.org/", pinned: true, select: false, parent: inner.id)+ let sibling = store.createTab(url: "https://example.org/sibling", pinned: true, select: false, parent: inner.id)+ let elsewhere = store.createTab(url: "https://example.net/", select: true)+ store.setExpanded(outer.id, false)+ store.setExpanded(inner.id, false)+ expect(store.peekedTabs(in: outer.id).isEmpty, "a closed folder shows nothing to begin with")++ store.selectTab(tab.id)+ expect(!store.isExpanded(outer.id) && !store.isExpanded(inner.id), "picking the tab leaves both folders closed")+ expect(store.peekedTabs(in: outer.id).map(\.id) == [tab.id] && store.peekedTabs(in: inner.id).isEmpty,+ "and lists it under the outer one")+ store.selectTab(elsewhere.id)+ expect(store.peekedTabs(in: outer.id).map(\.id) == [tab.id], "it stays there when another tab is picked")++ store.setExpanded(outer.id, true)+ expect(store.peekedTabs(in: outer.id).isEmpty && store.prefs.peekedFolders[outer.id] == nil, "opening the folder drops the peek")+ store.selectTab(tab.id)+ expect(store.peekedTabs(in: inner.id).map(\.id) == [tab.id], "with the outer one open, the inner one hosts it")+ store.setExpanded(outer.id, false)+ expect(store.peekedTabs(in: outer.id).map(\.id) == [tab.id], "closing a folder keeps the open tab in sight")+ store.selectTab(sibling.id)+ expect(store.peekedTabs(in: outer.id).map(\.id) == [tab.id, sibling.id], "a second tab joins, in sidebar order")++ store.saveAll()+ let restored = AppComposition(clock: ManualScheduler()).store+ expect(restored.peekedTabs(in: outer.id).map(\.id) == [tab.id, sibling.id], "the peek reads back after a relaunch")++ _ = store.resetPinnedTab(sibling.id)+ expect(store.peekedTabs(in: outer.id).map(\.id) == [tab.id], "closing a tab (⌘W) takes it out")+ expect(store.integrityProblems().isEmpty, "and the sidebar stays sound")+ }+private static func expect(_ condition: @autoclosure () -> Bool, _ message: String) {guard condition() else {FileHandle.standardError.write(Data("FAIL: \(message)\n".utf8))diff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.mdindex 791b997..b4ea3fc 100644--- a/docs/arc-reverse-engineering.md+++ b/docs/arc-reverse-engineering.md@@ -2166,3 +2166,31 @@ Two new Arc windows, both with View ▸ Hide Sidebar and a tab selected, capture(⌃⌘1–9, Cra's own: ⌘ added to Go to Space N; neither Arc nor macOS binds ⌃⌘ + a digit). A pane brings its split.The sidebar menu's Move to Space follows when it moves the open tab or its split; another tab moves on its own. Whatever moves, a window that had it open in theold space opens the next tab there, picked as on close.++## ⌘Return in the command bar and closed folders that keep their tab (Arc 1.171, 2 Nov 2026, issue #85)++Victor's Arc, a window of my own (File ▸ New Window over AX, closed afterwards), keys posted to Arc's pid while it+was frontmost, 1x region captures and 100 fps recordings; test tabs archived afterwards.++- [O] ⌘Return in the URL editor (⌘L, a page open) or the new-tab bar (⌘T): the highlighted row opens in a new tab at+ the top of Today, the current tab stays in front and the bar stays open with what was typed; each ⌘Return opens+ one more (two ⌘Returns, two tabs). A "Switch to Tab" row opens its address again as a new tab rather than switching;+ a search row opens the search. The tabs are saved read (`isUnread` false). Cra: the field editor reports ⌘Return as+ `noop:`, never `insertNewline:` (KeyChord.isCommandReturn), CommandBarController.commitInBackground,+ MainWindowController.openInBackground.+- [O] Arc only says so when the sidebar is hidden: "New Tab Created" (`backgroundTabCreated`, Toasts.ShinyToastView;+ "New Tab Created in %@" exists for another space). With the sidebar out, only the new row appears in Today. The toast:+ 138 × 42 pt at 1x, 8 pt below the top of the page area (below the toolbar; with the inline URL editor open, below+ its input row) and 9 pt in from its right edge; 14 pt medium black text, 12 pt either side; ~10 pt corners; a+ 1 pt outline at ~69 % of the fill; fill 220/226/184 at the top to 208/218/163 at the bottom over a dark page on a+ yellow/green theme (`ShinyToastBackgroundBasedPalette`). It springs in from its top centre (width 0.41 → 1.04 at+ ~0.2 s → 1.0 by ~0.4 s, i.e. ≈0.3 s response, damping 0.67), stays ~4.85 s and shrinks into its top while fading in+ ~80 ms. [U] Whether a second ⌘Return restarts its timer; the fill on other themes. Cra: BackgroundTabToast.+- [O] Return on a "Switch to Tab" row for a pinned tab two closed folders down (Netfinder ▸ Endpoints ▸ tab): no folder+ opens. The tab is listed one level under the outermost closed folder (its row slides in, ~0.15 s), Endpoints stays+ hidden, and the folder's glyph gets three dots (2 pt, 4 pt pitch). StorableWindows.json keeps it per window as+ `expandedItems: [folder, {"peeked": {"_0": [tab ids]}}]`; the tab stays listed after another tab is picked. The bar+ lists only the window's space's tabs; a typed URL puts the typed row first and the "Switch to Tab" row second.+ Arc also has Tabs ▸ Reveal Tab in Sidebar (`revealTabInSidebar`). Cra: FolderPeek (CraCore),+ WindowPrefs.peekedFolders, SidebarStore.peekedTabs/setExpanded, FolderGlyphView's dots. [U] What a click on a+ peeked folder does in Arc (Cra opens it and drops the peek; closing it again keeps the open tab listed).