feat(sessions): keep every session, record review details, name and stamp the PDF
Sessions are now the unit of the product instead of an implicit capture run. - Nothing is deleted by default: the fixed 10-session cap is gone. An age limit (Never / 7 / 14 / 30 / 90 / 180 / 365 days) is chosen in Settings > Sessions and applied on launch, after archiving, and by "Clean up now". Sent PDFs are never touched. - Each session carries review details: lane, deployed version, commit, reviewer (pre-filled with the Mac user) and a free note. They persist in session.json and are inherited by the next session, so a review run is typed once. - PDF file names are Redline-<yyyyMMdd-HHmm>-<LANE>-<SHORTID>.pdf, and every page carries a two-line reference footer (tool, build time, session / lane, deployed build, commit, reviewer, note). The PDF document info carries the same values in Author and Keywords. - Verification: 159 tests, a headless panel self-test, and a LaunchServices-driven end-to-end run that types and clicks the real panel.
This commit is contained in:
@@ -2,27 +2,41 @@ import AppKit
|
||||
import SwiftUI
|
||||
import ShotdeckCore
|
||||
|
||||
/// The menu-bar panel. Hierarchy: what is being worked on first, the three core
|
||||
/// verbs second, recent sessions third, housekeeping last.
|
||||
struct MenuBarView: View {
|
||||
@Environment(AppModel.self) private var model
|
||||
/// Snapshot-only: opens the details editor on first render.
|
||||
private let startsWithDetailsOpen: Bool
|
||||
@State private var showsDetails = false
|
||||
|
||||
init(showsContextEditor: Bool = false) {
|
||||
self.startsWithDetailsOpen = showsContextEditor
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
VStack(alignment: .leading, spacing: 10) {
|
||||
statusRow
|
||||
SessionStrip()
|
||||
sessionBlock
|
||||
Divider()
|
||||
actionsList
|
||||
recentSessionsBlock
|
||||
Divider()
|
||||
secondaryActions
|
||||
if !model.allReturns.isEmpty {
|
||||
Divider()
|
||||
returnsBlock
|
||||
}
|
||||
Divider()
|
||||
updateFooter
|
||||
footer
|
||||
}
|
||||
.padding(10)
|
||||
.frame(width: 320, alignment: .leading)
|
||||
.controlSize(.small)
|
||||
.onAppear { showsDetails = startsWithDetailsOpen }
|
||||
}
|
||||
|
||||
// MARK: - Status
|
||||
|
||||
@ViewBuilder
|
||||
private var statusRow: some View {
|
||||
if !model.screenRecordingGranted {
|
||||
@@ -41,26 +55,26 @@ struct MenuBarView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Text(model.statusLine ?? defaultStatusText)
|
||||
} else if let status = model.statusLine {
|
||||
Text(status)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.primary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
} else {
|
||||
Text(defaultStatusText)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
}
|
||||
|
||||
private var defaultStatusText: String {
|
||||
guard let region = model.region else {
|
||||
return "No region yet — press \(model.hotkeyDisplayString) to pick one."
|
||||
return "No area selected yet — press \(model.hotkeyDisplayString) to pick one."
|
||||
}
|
||||
let w = Int(region.rect.width)
|
||||
let h = Int(region.rect.height)
|
||||
let display = displayName(for: region)
|
||||
if model.session.isEmpty {
|
||||
return "Region \(w) × \(h) on \(display) · Nothing captured yet."
|
||||
}
|
||||
let count = model.session.captures.count
|
||||
return "\(count) captures · region \(w) × \(h) on \(display)"
|
||||
return "Capturing \(w) × \(h) on \(displayName(for: region))"
|
||||
}
|
||||
|
||||
private func displayName(for region: CaptureRegion) -> String {
|
||||
@@ -74,7 +88,127 @@ struct MenuBarView: View {
|
||||
return "Display 1"
|
||||
}
|
||||
|
||||
private var actionsList: some View {
|
||||
// MARK: - Current session
|
||||
|
||||
private var sessionBlock: some View {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
HStack(alignment: .firstTextBaseline, spacing: 6) {
|
||||
Text("Current session")
|
||||
.font(.caption.weight(.semibold))
|
||||
Spacer(minLength: 6)
|
||||
Text(captureCountText)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.monospacedDigit()
|
||||
}
|
||||
|
||||
HStack(alignment: .firstTextBaseline, spacing: 6) {
|
||||
Text(contextSummary)
|
||||
.font(.caption)
|
||||
.foregroundStyle(model.sessionContext.summaryLine.isEmpty ? .secondary : .primary)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
.help(contextSummary)
|
||||
Spacer(minLength: 4)
|
||||
// A bordered control, not a link: in a menu panel the row of text is
|
||||
// the value, and the thing you press has to look pressable.
|
||||
Button {
|
||||
showsDetails.toggle()
|
||||
} label: {
|
||||
HStack(spacing: 2) {
|
||||
Text(showsDetails ? "Hide" : "Details")
|
||||
Image(systemName: showsDetails ? "chevron.up" : "chevron.down")
|
||||
.font(.system(size: 9, weight: .semibold))
|
||||
}
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.accessibilityLabel(showsDetails ? "Hide details" : "Show details")
|
||||
}
|
||||
|
||||
if showsDetails {
|
||||
SessionContextEditor()
|
||||
}
|
||||
|
||||
SessionStrip()
|
||||
|
||||
HStack(spacing: 6) {
|
||||
Button("Capture") {
|
||||
Task { await model.captureNow() }
|
||||
}
|
||||
.disabled(model.isCapturing)
|
||||
|
||||
Button(model.transport == .oneDrive ? "Send to OneDrive" : "Send…") {
|
||||
guard let sender = model as? SendCapable else {
|
||||
model.setStatus("Send is not available in this build.")
|
||||
return
|
||||
}
|
||||
let anchor = NSApp.keyWindow?.contentView
|
||||
Task { await sender.send(anchor: anchor) }
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.disabled(model.session.isEmpty || model.isSending)
|
||||
|
||||
Button("New session") {
|
||||
Task { await model.startNewSession() }
|
||||
}
|
||||
.disabled(!model.canStartNewSession)
|
||||
.help("Keeps these captures as a past session and starts a fresh one. Nothing is deleted.")
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
|
||||
private var captureCountText: String {
|
||||
let count = model.session.captures.count
|
||||
if count == 0 { return "empty" }
|
||||
return "\(count) capture\(count == 1 ? "" : "s")"
|
||||
}
|
||||
|
||||
private var contextSummary: String {
|
||||
let summary = model.sessionContext.summaryLine
|
||||
return summary.isEmpty ? "No lane or build recorded — add details" : summary
|
||||
}
|
||||
|
||||
// MARK: - Recent sessions
|
||||
|
||||
private var recentSessionsBlock: some View {
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
HStack(alignment: .firstTextBaseline, spacing: 6) {
|
||||
Text("Recent sessions")
|
||||
.font(.caption.weight(.semibold))
|
||||
if !model.pastSessions.isEmpty {
|
||||
Text("\(model.pastSessions.count)")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.monospacedDigit()
|
||||
}
|
||||
Spacer(minLength: 6)
|
||||
Button("Show all…") {
|
||||
if let presenter = model as? SubmissionsWindowPresenting {
|
||||
presenter.presentSubmissionsWindow()
|
||||
} else {
|
||||
model.setStatus("Past sessions are not available in this build.")
|
||||
}
|
||||
}
|
||||
.buttonStyle(.link)
|
||||
}
|
||||
|
||||
if model.pastSessions.isEmpty {
|
||||
Text("Nothing yet. “New session” keeps this one and starts a fresh one.")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
} else {
|
||||
ForEach(model.pastSessions.prefix(4)) { session in
|
||||
RecentSessionRow(session: session)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Secondary actions
|
||||
|
||||
private var secondaryActions: some View {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
if let update = model.updateAvailable {
|
||||
Button {
|
||||
@@ -85,13 +219,6 @@ struct MenuBarView: View {
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
model.checkForUpdates()
|
||||
} label: {
|
||||
actionLabel(model.isCheckingForUpdates ? "Checking…" : "Check for updates")
|
||||
}
|
||||
.disabled(model.isCheckingForUpdates)
|
||||
|
||||
if let previous = model.previousVersion {
|
||||
Button {
|
||||
model.revertToPreviousVersion()
|
||||
@@ -100,18 +227,6 @@ struct MenuBarView: View {
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
let anchor = NSApp.keyWindow?.contentView
|
||||
if let sender = model as? SendCapable {
|
||||
Task { await sender.send(anchor: anchor) }
|
||||
} else {
|
||||
model.setStatus("Send is not available in this build.")
|
||||
}
|
||||
} label: {
|
||||
actionLabel(model.transport == .oneDrive ? "Send to OneDrive" : "Send…")
|
||||
}
|
||||
.disabled(model.session.isEmpty || model.isSending)
|
||||
|
||||
Button {
|
||||
model.revealLastPDF()
|
||||
} label: {
|
||||
@@ -119,39 +234,6 @@ struct MenuBarView: View {
|
||||
}
|
||||
.disabled(!model.canRevealLastPDF)
|
||||
|
||||
Button {
|
||||
Task { await model.startNewSession() }
|
||||
} label: {
|
||||
actionLabel("Start new session")
|
||||
}
|
||||
.disabled(!model.canStartNewSession)
|
||||
|
||||
Button {
|
||||
if let presenter = model as? SubmissionsWindowPresenting {
|
||||
presenter.presentSubmissionsWindow()
|
||||
} else {
|
||||
model.setStatus("Past submissions are not available in this build.")
|
||||
}
|
||||
} label: {
|
||||
actionLabel(
|
||||
"Past submissions…",
|
||||
trailing: model.pastSessions.isEmpty ? nil : "\(model.pastSessions.count)"
|
||||
)
|
||||
}
|
||||
|
||||
Button {
|
||||
Task { await model.captureNow() }
|
||||
} label: {
|
||||
actionLabel("Capture now", trailing: model.hotkeyDisplayString)
|
||||
}
|
||||
.disabled(model.isCapturing)
|
||||
|
||||
Button {
|
||||
Task { await model.rePickRegion() }
|
||||
} label: {
|
||||
actionLabel("Re-select area")
|
||||
}
|
||||
|
||||
Button {
|
||||
Task { await model.copyCommentedLinks() }
|
||||
} label: {
|
||||
@@ -163,26 +245,17 @@ struct MenuBarView: View {
|
||||
.disabled(model.commentedReturns.isEmpty)
|
||||
|
||||
Button {
|
||||
model.openSpoolFolder()
|
||||
Task { await model.rePickRegion() }
|
||||
} label: {
|
||||
actionLabel("Open spool folder")
|
||||
actionLabel("Re-select area")
|
||||
}
|
||||
|
||||
Button {
|
||||
if let presenter = model as? SettingsWindowPresenting {
|
||||
presenter.presentSettingsWindow()
|
||||
} else {
|
||||
model.setStatus("Settings is not available in this build.")
|
||||
}
|
||||
Task { await model.captureNow() }
|
||||
} label: {
|
||||
actionLabel("Settings…")
|
||||
}
|
||||
|
||||
Button {
|
||||
NSApp.terminate(nil)
|
||||
} label: {
|
||||
actionLabel("Quit Redline")
|
||||
actionLabel("Capture now", trailing: model.hotkeyDisplayString)
|
||||
}
|
||||
.disabled(model.isCapturing)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
@@ -209,9 +282,8 @@ struct MenuBarView: View {
|
||||
} else {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text("Came back from your device")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
ForEach(newestReturns.prefix(8)) { doc in
|
||||
.font(.caption.weight(.semibold))
|
||||
ForEach(newestReturns.prefix(6)) { doc in
|
||||
HStack(spacing: 8) {
|
||||
Text(doc.fileURL.lastPathComponent)
|
||||
.lineLimit(1)
|
||||
@@ -231,11 +303,34 @@ struct MenuBarView: View {
|
||||
model.allReturns.sorted { $0.detectedAt > $1.detectedAt }
|
||||
}
|
||||
|
||||
private var updateFooter: some View {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text("Redline \(model.appVersion)")
|
||||
// MARK: - Footer
|
||||
|
||||
private var footer: some View {
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
HStack(spacing: 6) {
|
||||
Button("Settings…") {
|
||||
if let presenter = model as? SettingsWindowPresenting {
|
||||
presenter.presentSettingsWindow()
|
||||
} else {
|
||||
model.setStatus("Settings is not available in this build.")
|
||||
}
|
||||
}
|
||||
.buttonStyle(.link)
|
||||
Button("Check for updates") {
|
||||
model.checkForUpdates()
|
||||
}
|
||||
.buttonStyle(.link)
|
||||
.disabled(model.isCheckingForUpdates)
|
||||
Spacer(minLength: 6)
|
||||
Button("Quit") {
|
||||
NSApp.terminate(nil)
|
||||
}
|
||||
.buttonStyle(.link)
|
||||
}
|
||||
Text("Redline \(model.appVersion) · \(model.retentionSummary)")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
if let message = model.updateStatusMessage {
|
||||
Text(message)
|
||||
.font(.caption)
|
||||
@@ -245,3 +340,70 @@ struct MenuBarView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One row of the panel's recent-sessions list: timestamp, readable session label,
|
||||
/// page count and sent state. Clicking reveals the sent PDF when there is one,
|
||||
/// otherwise that session's captures.
|
||||
private struct RecentSessionRow: View {
|
||||
@Environment(AppModel.self) private var model
|
||||
let session: CaptureSession
|
||||
@State private var hovering = false
|
||||
|
||||
var body: some View {
|
||||
Button {
|
||||
if model.sentPDFURL(for: session) != nil {
|
||||
model.revealSentPDF(session)
|
||||
} else {
|
||||
model.revealSessionCaptures(session)
|
||||
}
|
||||
} label: {
|
||||
HStack(spacing: 6) {
|
||||
Text(DubaiTime.shortStamp(session.createdAt))
|
||||
.font(.caption)
|
||||
.monospacedDigit()
|
||||
.foregroundStyle(.secondary)
|
||||
Text(SessionDisplay.label(for: session))
|
||||
.font(.caption)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
Spacer(minLength: 6)
|
||||
Text(session.pdfFileName == nil ? "Not sent" : "Sent")
|
||||
.font(.caption)
|
||||
.foregroundStyle(session.pdfFileName == nil ? .secondary : .primary)
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.vertical, 2)
|
||||
.contentShape(Rectangle())
|
||||
.background(hovering ? AnyShapeStyle(.quaternary) : AnyShapeStyle(.clear))
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.onHover { hovering = $0 }
|
||||
.help(helpText)
|
||||
}
|
||||
|
||||
private var helpText: String {
|
||||
let pages = "\(session.captures.count) page\(session.captures.count == 1 ? "" : "s")"
|
||||
let context = session.context.summaryLine
|
||||
let detail = context.isEmpty ? pages : "\(pages) · \(context)"
|
||||
if let name = session.pdfFileName {
|
||||
return "\(detail)\nSent as \(name)"
|
||||
}
|
||||
return "\(detail)\nNever sent — opens the captures"
|
||||
}
|
||||
}
|
||||
|
||||
/// Readable labels for sessions, shared by the panel and the Past sessions window.
|
||||
///
|
||||
/// The label is what the user typed plus the session's short id — never the
|
||||
/// upper-cased file-name slug, which is for filesystems, not people.
|
||||
enum SessionDisplay {
|
||||
static func label(for session: CaptureSession) -> String {
|
||||
let lane = session.context.lane
|
||||
return lane.isEmpty ? session.shortID : lane
|
||||
}
|
||||
|
||||
static func fullLabel(for session: CaptureSession) -> String {
|
||||
let lane = session.context.lane
|
||||
return lane.isEmpty ? session.shortID : "\(lane) · \(session.shortID)"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user