Skip to content
Closed
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
f8186a5
cmux-next: keep each painting's subject clear of the sidebar and agen…
teamleaderleo Oct 18, 2026
837bbac
cmux-next: report the art's covering columns from the sidebar and lay…
teamleaderleo Oct 18, 2026
b709d5f
cmux-next: add your own background from a link, and manage your images
teamleaderleo Oct 18, 2026
601ca9d
cmux-next: reveal your images in Finder off the main thread
teamleaderleo Oct 18, 2026
32991c5
cmux-next: measure whether art keeps its subject; slide past the cove…
teamleaderleo Oct 18, 2026
2b2fbaf
cmux-next: link downloads stream under a cap, stay https, and keep th…
teamleaderleo Oct 18, 2026
af13e15
Merge remote-tracking branch 'origin/leo/next-art-subject-crop' into …
teamleaderleo Oct 18, 2026
93f4995
cmux-next: place a background picture by hand (drag, zoom, reset)
teamleaderleo Oct 18, 2026
048cc79
cmux-next: link downloads are Sendable by a lock, safe to cancel befo…
teamleaderleo Oct 18, 2026
236a5d0
Merge remote-tracking branch 'origin/leo/next-own-backgrounds' into l…
teamleaderleo Oct 18, 2026
cd9818b
cmux-next: the slide regression test uses Böcklin's own subject box
teamleaderleo Oct 18, 2026
d5e5402
cmux-next: placing a background by hand is one overlay, in the worksp…
teamleaderleo Oct 18, 2026
79606b3
Merge remote-tracking branch 'origin/feat-cmux-next' into leo/next-pl…
teamleaderleo Oct 18, 2026
8afeb67
cmux-next: collages: arrange several pictures as one background
teamleaderleo Oct 18, 2026
a620250
cmux-next: a drag moves the placed picture the right way, and the win…
teamleaderleo Oct 18, 2026
eeccaaf
cmux-next: the backgrounds page provider imports what it uses
teamleaderleo Oct 18, 2026
0dbd438
Merge remote-tracking branch 'origin/leo/next-own-backgrounds' into l…
teamleaderleo Oct 18, 2026
d82adbd
cmux-next: an edited collage's old files go only after the background…
teamleaderleo Oct 18, 2026
cb0e8c2
cmux-next: collages save without deleting, list without a slow expres…
teamleaderleo Oct 18, 2026
fe8dc91
Merge remote-tracking branch 'origin/leo/next-place-background' into …
teamleaderleo Oct 18, 2026
4e6e0bd
cmux-next: the provider's default reveal uses a public import
teamleaderleo Oct 18, 2026
c57ce7b
Merge remote-tracking branch 'origin/leo/next-own-backgrounds' into l…
teamleaderleo Oct 18, 2026
c372da3
Merge remote-tracking branch 'origin/leo/next-place-background' into …
teamleaderleo Oct 18, 2026
f50b8fc
cmux-next: the collage edit test keeps the old drawing until it is re…
teamleaderleo Oct 18, 2026
5c875bb
cmux-next: an unreadable workspace backgrounds file refuses removal
teamleaderleo Oct 18, 2026
e5c03bd
cmux-next: the adjust test names the art by its selection id and comp…
teamleaderleo Oct 18, 2026
52c2992
Merge remote-tracking branch 'origin/leo/next-place-background' into …
teamleaderleo Oct 18, 2026
c336581
Regenerate settings exports
teamleaderleo Oct 18, 2026
f2ac0d7
webviews: a gallery variant for Add from a Link
teamleaderleo Oct 18, 2026
83234a0
Merge remote-tracking branch 'origin/leo/next-own-backgrounds' into l…
teamleaderleo Oct 18, 2026
a04503d
Merge remote-tracking branch 'origin/feat-cmux-next' into leo/next-co…
teamleaderleo Oct 18, 2026
ae26a6a
Merge remote-tracking branch 'origin/leo/next-place-background' into …
teamleaderleo Oct 18, 2026
b904613
chore(next): PR autofix at ae26a6a8249c
Oct 18, 2026
6befedf
cmux-next: your images' usage runs off the main actor
teamleaderleo Oct 18, 2026
78e3864
Merge remote-tracking branch 'origin/leo/next-own-backgrounds' into l…
teamleaderleo Oct 18, 2026
72806d9
Merge remote-tracking branch 'origin/leo/next-own-backgrounds' into l…
teamleaderleo Oct 18, 2026
9693122
cmux-next: the backgrounds page reads its files off the main actor
teamleaderleo Oct 18, 2026
7d675dd
cmux-next: a link's name drops its extension at the last dot
teamleaderleo Oct 19, 2026
c1d7f6d
cmux-next: placing fades new views on window updates
teamleaderleo Oct 19, 2026
631b4d7
Merge remote-tracking branch 'origin/leo/next-own-backgrounds' into l…
teamleaderleo Oct 19, 2026
69087b8
Merge remote-tracking branch 'origin/leo/next-own-backgrounds' into l…
teamleaderleo Oct 19, 2026
bd42aa5
Merge remote-tracking branch 'origin/leo/next-place-background' into …
teamleaderleo Oct 19, 2026
d63ae5e
Merge remote-tracking branch 'origin/feat-cmux-next' into leo/next-co…
teamleaderleo Oct 19, 2026
c5790d2
chore(next): PR autofix at d63ae5eb29b4
Oct 19, 2026
4392c51
Merge remote-tracking branch 'origin/feat-cmux-next' into leo/next-co…
teamleaderleo Oct 19, 2026
881d683
chore(next): PR autofix at 4392c51b6a39
Oct 19, 2026
d840a6a
Merge feat-cmux-next into leo/next-collages
teamleaderleo Oct 20, 2026
5cd262e
Merge branch 'feat-cmux-next' into leo/next-collages
teamleaderleo Oct 20, 2026
d8619aa
chore(next): PR autofix at 5cd262e7909e
Oct 20, 2026
f9d9393
Merge branch 'feat-cmux-next' into leo/next-collages
teamleaderleo Oct 20, 2026
5fe4622
Merge branch 'feat-cmux-next' into leo/next-collages
teamleaderleo Oct 20, 2026
64212dd
Merge branch 'feat-cmux-next' into leo/next-collages
teamleaderleo Oct 20, 2026
14e29d3
Merge branch 'feat-cmux-next' into leo/next-collages
teamleaderleo Oct 20, 2026
ddaeb13
Merge branch 'feat-cmux-next' into leo/next-collages
teamleaderleo Oct 20, 2026
226b1b6
Merge branch 'feat-cmux-next' into leo/next-collages
teamleaderleo Oct 20, 2026
85baf35
chore(next): PR autofix at 226b1b66af9e
Oct 20, 2026
df6ed35
Merge branch 'feat-cmux-next' into leo/next-collages
teamleaderleo Oct 20, 2026
de6d12f
Merge branch 'feat-cmux-next' into leo/next-collages
teamleaderleo Oct 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ struct PageFactory {
// Your own backgrounds from a link, removed or revealed (BackdropImagesPageProvider).
let images = provider.backdropImages.map { images in
BackdropImagesPageProvider(images: images.images, use: { [weak provider] in try await provider?.useBackdropImage($0) ?? "" },
inUse: { [weak services] in services?.settings?.snapshot.backdropSelection })
inUse: { [weak services] in services?.settings?.snapshot.backdropSelection },
adjust: { [weak services] in BackdropAdjustOverlay.begin(in: services?.windows.active?.window) })
}
let routes = [PageRoute(prefix: "cmux.settings.", provider: provider), PageRoute(prefix: "cmux.app.", provider: native),
// Agents > Chiefs: the same Chief editor routes as Home (ChiefProfilePageRelay, AgentHarnessCenter).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
public import AppKit
import CmuxNextWakeups

/// Placing a background by hand (backgrounds plan phase 6): over the window, with its content
/// faded so the art shows, a drag moves the picture, scrolling or pinching zooms it, Reset goes
/// back to the automatic framing and Done (or Escape, or Return) ends. The arrow keys nudge it
/// (Shift: further), + and - zoom, 0 resets. Each change is saved in ``BackdropPlacementStore``
/// at once, so every window showing the picture follows. One overlay at a time, app-wide; it
/// ends by itself when its window shows another background.
@MainActor
public final class BackdropAdjustOverlay: NSView {
private let backdrop: WindowMaterialView
private let id: String
private let imageSize: CGSize
private var placement: BackdropUserPlacement
private var lastDrag: NSPoint?
/// The window's content views this faded, and their opacity before.
private var faded: [(NSView, CGFloat)] = []
/// Fades views the window adds while placing (a page, a toast): AppKit sends no change for
/// `subviews`, so each window update (after every event it handles) looks for new ones.
private var updateObserver: NSObjectProtocol?
/// The one overlay placing now, in any window.
private static weak var active: BackdropAdjustOverlay?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P0 Windows share hidden overlay state

BackdropAdjustOverlay.active keeps app-wide mutable state on the view type. Opening an overlay in one window closes another through this hidden reference. This violates the repository's requirement that runtime state belong to a constructable, injected owner. Move the active overlay to a coordinator owned by the app's window services.

Rule Used: Flag new ambient global state in production Swift: a top-level (file-scope) func used as API, a top-level mutable var or a stub class/struct holding a global flag/once-token, a caseless enum/empty struct used purely as a static func/static let namesp... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

private let bar = NSVisualEffectView()

/// The content fades to this while placing, so the art shows through.
static let fadedContentAlpha: CGFloat = 0.12

/// Starts placing the picture `window` shows; false when it shows none it can place (no
/// picture, a video). A second call while placing keeps the first.
@discardableResult
public static func begin(in window: NSWindow?) -> Bool {
guard let window, let content = window.contentView, let backdrop = WindowMaterialView.backdrop(of: window),
let adjustable = backdrop.adjustable else { return false }
if let active, active.window === window, active.id == adjustable.id { return true }
active?.done()
let overlay = BackdropAdjustOverlay(backdrop: backdrop, id: adjustable.id, imageSize: adjustable.imageSize,
placement: adjustable.current, frame: content.bounds)
for view in content.subviews where view !== backdrop { overlay.fade(view) }
content.addSubview(overlay, positioned: .above, relativeTo: nil)
overlay.updateObserver = NotificationCenter.default.addObserver(forName: NSWindow.didUpdateNotification, object: window,
queue: .main) { [weak overlay] _ in
MainActor.assumeIsolated { overlay?.fadeAdded() } // main-proof: observer on queue: .main
}
// Brought forward: from a separate Settings window, the keys and pointer come here.
window.makeKeyAndOrderFront(nil)
window.makeFirstResponder(overlay)
active = overlay
Comment on lines +46 to +48

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Placement loses keyboard focus

BackdropAdjustOverlay.begin(in:) gives the overlay keyboard focus without telling the window's focus owner that an overlay opened. In an app window, ShellWindow.makeFirstResponder immediately reports this view as windowOrNone. The focus owner then puts focus back on the selected page or terminal.

The overlay stays visible, but arrow keys, zoom keys and Escape reach the content underneath instead. Register and close this overlay through the window's focus owner, as the palette does.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

return true
}

private func fade(_ view: NSView) {
guard view !== self, view !== backdrop, !faded.contains(where: { $0.0 === view }) else { return }
faded.append((view, view.alphaValue))
view.alphaValue = Self.fadedContentAlpha
}

/// Fades the window's views that came in since.
private func fadeAdded() {
guard let content = superview else { return }
for view in content.subviews { fade(view) }
}

/// The overlay `window` shows, if it is placing (tests).
public static func current(in window: NSWindow?) -> BackdropAdjustOverlay? {
window?.contentView?.subviews.lazy.compactMap { $0 as? BackdropAdjustOverlay }.first
}

init(backdrop: WindowMaterialView, id: String, imageSize: CGSize, placement: BackdropUserPlacement, frame: NSRect) {
self.backdrop = backdrop
self.id = id
self.imageSize = imageSize
self.placement = placement
super.init(frame: frame)
autoresizingMask = [.width, .height]
setAccessibilityRole(.group)
setAccessibilityLabel(Self.hint)
bar.material = .hudWindow
bar.state = .active
bar.wantsLayer = true
bar.layer?.cornerRadius = 12
let hint = ThemedLabel(labelWithString: Self.hint)
let reset = ThemedBezelButton(title: Self.resetTitle, target: self, action: #selector(reset))
let done = ThemedBezelButton(title: Self.doneTitle, target: self, action: #selector(done))
done.keyEquivalent = "\r"
let row = NSStackView(views: [hint, reset, done])
row.spacing = 12
row.edgeInsets = NSEdgeInsets(top: 10, left: 16, bottom: 10, right: 12)
row.translatesAutoresizingMaskIntoConstraints = false
bar.addSubview(row)
bar.translatesAutoresizingMaskIntoConstraints = false
addSubview(bar)
NSLayoutConstraint.activate([
row.leadingAnchor.constraint(equalTo: bar.leadingAnchor), row.trailingAnchor.constraint(equalTo: bar.trailingAnchor),
row.topAnchor.constraint(equalTo: bar.topAnchor), row.bottomAnchor.constraint(equalTo: bar.bottomAnchor),
bar.centerXAnchor.constraint(equalTo: centerXAnchor), bar.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -24),
])
}

@available(*, unavailable)
required init?(coder: NSCoder) { nil }

override public var acceptsFirstResponder: Bool { true }

/// The picture's size on screen at the current zoom.
private var shownSize: CGSize {
let view = backdrop.bounds.size
guard imageSize.width > 0, imageSize.height > 0 else { return .zero }
let scale = max(view.width / imageSize.width, view.height / imageSize.height) * placement.zoom
return CGSize(width: imageSize.width * scale, height: imageSize.height * scale)
}

/// Moves the picture by `dx`, `dy` points (y up), as a drag does. The center stays where the
/// picture still covers the window, so a drag past an edge has no dead travel to undo.
public func move(dx: CGFloat, dy: CGFloat) {
let size = shownSize, view = backdrop.bounds.size
guard size.width > 0, size.height > 0 else { return }
// The picture follows the pointer: the point at the center moves the other way.
let middleX = backdrop.visibleMiddle, middleY = view.height / 2
// Covering keeps the image's origin in [view - size, 0], so the center point lies in
// [middle / size, (middle - view + size) / size].
let x = min(max(placement.centerX - dx / size.width, middleX / size.width), (middleX - view.width + size.width) / size.width)
let y = min(max(placement.centerY + dy / size.height, middleY / size.height), (middleY - view.height + size.height) / size.height)
save(BackdropUserPlacement(centerX: x, centerY: y, zoom: placement.zoom))
}

/// Zooms by `factor` (above 1 closer), as a pinch or a scroll does.
public func zoom(by factor: CGFloat) {
guard factor.isFinite, factor > 0 else { return }
save(BackdropUserPlacement(centerX: placement.centerX, centerY: placement.centerY, zoom: placement.zoom * factor))
}

private func save(_ new: BackdropUserPlacement) {
// The window shows another background now: nothing of this one to save.
guard backdrop.adjustable?.id == id else { return done() }
placement = new
backdrop.placements.set(new, for: id)
}

override public func keyDown(with event: NSEvent) {
let step: CGFloat = event.modifierFlags.contains(.shift) ? 50 : 10
switch event.specialKey {
case .leftArrow?: move(dx: -step, dy: 0)
case .rightArrow?: move(dx: step, dy: 0)
case .upArrow?: move(dx: 0, dy: step)
case .downArrow?: move(dx: 0, dy: -step)
default:
switch event.charactersIgnoringModifiers {
case "+", "=": zoom(by: 1.1)
case "-", "_": zoom(by: 1 / 1.1)
case "0": reset()
default: super.keyDown(with: event)
}
}
}

override public func mouseDown(with event: NSEvent) { lastDrag = event.locationInWindow }

override public func mouseDragged(with event: NSEvent) {
let point = event.locationInWindow
defer { lastDrag = point }
guard let last = lastDrag else { return }
move(dx: point.x - last.x, dy: point.y - last.y)
}

override public func mouseUp(with event: NSEvent) { lastDrag = nil }

override public func scrollWheel(with event: NSEvent) {
let delta = event.hasPreciseScrollingDeltas ? event.scrollingDeltaY : event.scrollingDeltaY * 8
zoom(by: 1 + delta / 200)
}

override public func magnify(with event: NSEvent) { zoom(by: 1 + event.magnification) }

override public func cancelOperation(_ sender: Any?) { done() }

/// Back to the automatic framing (the picture's subject clear of the panes).
@objc public func reset() {
backdrop.placements.set(nil, for: id)
if let current = backdrop.adjustable?.current { placement = current }
}

/// Ends placing: the content comes back and the placement stays saved.
@objc public func done() {
if let updateObserver { NotificationCenter.default.removeObserver(updateObserver) }
updateObserver = nil
for (view, alpha) in faded { view.alphaValue = alpha }
faded = []
if Self.active === self { Self.active = nil }
let window = window
removeFromSuperview()
window?.makeFirstResponder(window?.contentView)
}

static var hint: String {
String(localized: "backdrop.adjust.hint", defaultValue: "Drag to move the picture. Scroll or pinch to zoom.", bundle: .module)
}
static var resetTitle: String { String(localized: "backdrop.adjust.reset", defaultValue: "Reset", bundle: .module) }
static var doneTitle: String { String(localized: "backdrop.adjust.done", defaultValue: "Done", bundle: .module) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ extension BackdropArtMetadata {
/// The image at `scale` with its top-left corner at `origin` (top-left view coordinates).
/// Whether the subject is kept is measured on the result, never assumed: its box must lie in
/// the visible span across and in the window top to bottom.
private nonisolated func place(scale: Double, origin: CGPoint, viewSize: CGSize, imageSize: CGSize,
nonisolated func place(scale: Double, origin: CGPoint, viewSize: CGSize, imageSize: CGSize,
check: (box: BackdropSubjectBox, span: ClosedRange<Double>, height: Double)) -> BackdropArtPlacement {
let image = CGRect(x: origin.x, y: origin.y, width: Double(imageSize.width) * scale, height: Double(imageSize.height) * scale)
let slack = 0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ public nonisolated struct BackdropCatalog: Sendable {
let apple = wallpapers.pictures(assets: assets, fileManager: fileManager)
appleWallpapers = Dictionary(apple.map { ($0.path, $0) }, uniquingKeysWith: { first, _ in first })
let yours = userImages?.list(fileManager: fileManager) ?? []
// Collages live beside the person's own images (backgrounds plan phase 7).
let collages = userImages.map { BackdropCollages(folder: $0.folder.appendingPathComponent("Collages", isDirectory: true)) }?
.list(fileManager: fileManager) ?? []
let moving = wallpapers.videos(fileManager: fileManager)
choices = Self.bundled + yours.filter { !$0.isVideo } + [.desktop] + apple.map { BackdropSelection.system(path: $0.path) }
choices = Self.bundled + yours.filter { !$0.isVideo } + collages + [.desktop] + apple.map { BackdropSelection.system(path: $0.path) }
+ moving + yours.filter(\.isVideo)
}
}
Loading