oficina / base Public

Bound the menu panel's waiting jobs, and let them scroll

Astra's Task 16 finding 6: every waiting job and its open cards stood
in a non-scrolling stack above Ask in the fixed 410 by 560 panel; with
several, they pushed the header, the composer and the foot out of it.
They now take at most 200 points and scroll inside that, under a rule,
so the header with Open Base, the conversation and the composer stay in
reach (the field still takes focus when the panel opens). MenuPanelTests
measures the region with six waiting jobs; base-mac's menubar-many
snapshot draws five in the panel's fixed size.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 472d909b8e355f6c21ddc5a65a62c92f78bf54ef parent 9e6c882
8 files changed, +61 −7
  • native/apple/Sources/BaseKit/Mac/MenuPanel.swift +23 −7
  • native/apple/Tests/BaseKitTests/StatusPanelTests.swift +20 −0
  • native/apple/Tests/BaseSnapshots/AskSnapshots.swift +12 −0
  • native/apple/Tests/BaseSnapshots/MacSnapshots.swift +6 −0
  • native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/menubar-dark-default.png binary
  • native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/menubar-light-default.png binary
  • native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/menubar-many-dark-default.png binary
  • native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/menubar-many-light-default.png binary
diff --git a/native/apple/Sources/BaseKit/Mac/MenuPanel.swift b/native/apple/Sources/BaseKit/Mac/MenuPanel.swift
index 92fee5e..97fad85 100644
--- a/native/apple/Sources/BaseKit/Mac/MenuPanel.swift
+++ b/native/apple/Sources/BaseKit/Mac/MenuPanel.swift
@@ -68,24 +68,40 @@ public struct MenuPanel: View {
}
/// The panel's top: the jobs waiting on the person (asking, stopped), each
-/// with its open cards, so a question can be answered without scrolling.
+/// with its open cards, so a question can be answered without scrolling
+/// the conversation. However many there are, they take at most
+/// `maxHeight` and scroll inside it, so the header, the conversation, the
+/// composer and Open Base stay in reach.
struct WaitingJobs: View {
let ask: AskModel
let timeZone: TimeZone?
+ static let maxHeight: CGFloat = 200
+ @Environment(\.colorScheme) private var scheme
+
var body: some View {
let jobs: [AskModel.Job] = ask.entries.compactMap {
if case .job(let j) = $0, j.state == .asking || j.state == .stopped { return j }
return nil
}
if !jobs.isEmpty {
- VStack(alignment: .leading, spacing: 8) {
- ForEach(jobs, id: \.card.id) { job in
- JobPill(job: job, busy: ask.answering, timeZone: timeZone) { card, option in Task { await ask.answer(card, option) } }
- }
+ ViewThatFits(in: .vertical) {
+ list(jobs)
+ ScrollView { list(jobs) }.scrollIndicators(.visible)
+ }
+ .frame(maxHeight: Self.maxHeight)
+ // A rule between them and the conversation.
+ .overlay(alignment: .bottom) { Rectangle().fill(Palette(scheme)[.rule]).frame(height: 1) }
+ }
+ }
+
+ private func list(_ jobs: [AskModel.Job]) -> some View {
+ VStack(alignment: .leading, spacing: 8) {
+ ForEach(jobs, id: \.card.id) { job in
+ JobPill(job: job, busy: ask.answering, timeZone: timeZone) { card, option in Task { await ask.answer(card, option) } }
}
- .padding(.horizontal, 12).padding(.top, 12)
- .frame(maxWidth: .infinity, alignment: .leading)
}
+ .padding(.horizontal, 12).padding(.vertical, 12)
+ .frame(maxWidth: .infinity, alignment: .leading)
}
}
#endif
diff --git a/native/apple/Tests/BaseKitTests/StatusPanelTests.swift b/native/apple/Tests/BaseKitTests/StatusPanelTests.swift
index 4f07fd0..45ac68d 100644
--- a/native/apple/Tests/BaseKitTests/StatusPanelTests.swift
+++ b/native/apple/Tests/BaseKitTests/StatusPanelTests.swift
@@ -42,3 +42,23 @@ import XCTest
}
}
#endif
+
+#if os(macOS)
+/// Astra's Task 16 finding 6: however many jobs wait, the panel's top
+/// takes at most its bound, and the composer still has room under it.
+@MainActor final class MenuPanelTests: XCTestCase {
+ func testWaitingJobsAreBoundedAndScroll() {
+ let m = AskModel(client: BaseClient(transport: GatedTransport()) {}, schedule: { _, _ in })
+ for n in 1...6 {
+ m.apply(.card(AskCard(id: "w\(n)", revision: 1, kind: "job", state: "asking", question: "Job \(n)", result: "One question for you")))
+ m.apply(.card(AskCard(id: "c\(n)", revision: 1, kind: "confirm", state: "open", question: "Go ahead?",
+ options: [.init(value: "y", label: "Go ahead")], job: "w\(n)")))
+ }
+ let host = NSHostingView(rootView: WaitingJobs(ask: m, timeZone: nil).frame(width: 390))
+ host.frame = NSRect(x: 0, y: 0, width: 390, height: 2000)
+ host.layoutSubtreeIfNeeded()
+ XCTAssertLessThanOrEqual(host.fittingSize.height, WaitingJobs.maxHeight + 0.5)
+ XCTAssertLessThan(WaitingJobs.maxHeight, StatusPanelController.size.height / 2, "the conversation and composer keep most of the panel")
+ }
+}
+#endif
diff --git a/native/apple/Tests/BaseSnapshots/AskSnapshots.swift b/native/apple/Tests/BaseSnapshots/AskSnapshots.swift
index a238224..5ce7eea 100644
--- a/native/apple/Tests/BaseSnapshots/AskSnapshots.swift
+++ b/native/apple/Tests/BaseSnapshots/AskSnapshots.swift
@@ -122,6 +122,18 @@ struct AskFrame<Content: View>: View {
return m
}
+ /// Five jobs waiting on the person, each with a decision under it.
+ static func manyWaiting() -> AskModel {
+ let m = thread()
+ for n in 1...5 {
+ m.apply(.card(AskCard(id: "w\(n)", revision: 1, kind: "job", state: n % 2 == 0 ? "stopped" : "asking",
+ question: "Waiting job \(n)", result: n % 2 == 0 ? "Stopped: needs you" : "One question for you")))
+ m.apply(.card(AskCard(id: "wc\(n)", revision: 1, kind: "confirm", state: "open", question: "Go ahead with job \(n)?",
+ options: [.init(value: "yes", label: "Go ahead"), .init(value: "no", label: "Not yet")], job: "w\(n)")))
+ }
+ return m
+ }
+
static let longJob = AskModel.Job(card: job.card, open: [], ended: (1...6).map { n in
AskCard(id: "e\(n)", kind: "confirm", state: "answered", question: "Decision \(n): use the autumn menu's prices for the Christmas boxes?",
result: n % 2 == 0 ? "You said yes" : "You said no", job: "j2")
diff --git a/native/apple/Tests/BaseSnapshots/MacSnapshots.swift b/native/apple/Tests/BaseSnapshots/MacSnapshots.swift
index ad6f98b..d1b2176 100644
--- a/native/apple/Tests/BaseSnapshots/MacSnapshots.swift
+++ b/native/apple/Tests/BaseSnapshots/MacSnapshots.swift
@@ -25,6 +25,12 @@ final class MacSnapshots: XCTestCase {
SnapshotScreen("menubar", mac: .fixed(width: 410, height: 560), iphone: nil) {
MenuPanel(me: HomeFixtures.me, ask: AskFixtures.thread(), shortcut: "⌃Space", openBase: {}, actions: .none).skyFrozen()
},
+ // Astra's Task 16 finding 6: many jobs waiting, in the panel's
+ // fixed size: they scroll in their own region; the header, the
+ // conversation, the composer and the foot stay.
+ SnapshotScreen("menubar-many", mac: .fixed(width: 410, height: 560), iphone: nil) {
+ MenuPanel(me: HomeFixtures.me, ask: AskFixtures.manyWaiting(), shortcut: "⌃Space", openBase: {}, actions: .none).skyFrozen()
+ },
SnapshotScreen("settings-general", mac: .width(560), iphone: nil) { settings(.general) },
SnapshotScreen("settings-account", mac: .width(560), iphone: nil) { settings(.account) },
SnapshotScreen("settings-ask", mac: .width(560), iphone: nil) { settings(.ask) },
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/menubar-dark-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/menubar-dark-default.png
index 2fd3227..555ee7b 100644
Binary files a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/menubar-dark-default.png and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/menubar-dark-default.png differ
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/menubar-light-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/menubar-light-default.png
index c338f13..4848032 100644
Binary files a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/menubar-light-default.png and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/menubar-light-default.png differ
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/menubar-many-dark-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/menubar-many-dark-default.png
new file mode 100644
index 0000000..48c3a5a
Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/menubar-many-dark-default.png differ
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/menubar-many-light-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/menubar-many-light-default.png
new file mode 100644
index 0000000..940965f
Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/menubar-many-light-default.png differ