feat(sessions): past submissions list + start-new-session with 10-session retention
MMDB-2925. Two new menu functions in the Redline app: - "Start new session" keeps the current screenshots as a past session (moved into the single archive/ folder — never deleted on close) and opens a fresh empty session. Sessions closed without ever sending keep pdfFileName nil and show as "Not sent" in the list. - "Past submissions…" opens a window listing every retained session (timestamp, page count, what was sent) with actions to reveal the sent PDF and the session's screenshot folder. Retention (Ben's rule 2026-10-11: "retain the past 10 sessions"): both archive paths (send and close) keep the newest 10 archived session folders in archive/ and remove the rest. Any PDF a pruned session produced is untouched — it lives in the outbox/OneDrive folder. archivedSessions() ordering now tie-breaks same-second sessions by the session folder's creation date, so listing and pruning are deterministic (manifest timestamps are whole-second ISO8601 — format pinned in AtomicFileTests). Tests: 6 core tests in SessionRetentionTests (close/keep/reconcile, sent-vs-unsent, retention of 10, explicit prune, send-path retention) and 3 app-target tests in SessionWorkflowTests driving the real AppModel menu actions through AppDelegate.makeLaunchModel(). PanelSnapshot renders the new window as panel-06b-past-submissions.png.
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
import ShotdeckCore
|
||||
|
||||
/// "Past submissions…" window: every retained session and what was sent for it.
|
||||
/// Read-and-reveal only — keeping/starting sessions is driven from the menu rows
|
||||
/// (and the button on the current-session row below).
|
||||
struct PastSubmissionsView: View {
|
||||
@Environment(AppModel.self) private var model
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
currentSessionRow
|
||||
Divider()
|
||||
if model.pastSessions.isEmpty {
|
||||
Text("No past sessions yet. Use “Start new session” to keep the current captures.")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
} else {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
ForEach(model.pastSessions) { session in
|
||||
PastSessionRow(session: session)
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(maxHeight: 320)
|
||||
}
|
||||
Divider()
|
||||
footer
|
||||
}
|
||||
.padding(10)
|
||||
.frame(width: 420, alignment: .leading)
|
||||
.controlSize(.small)
|
||||
.task {
|
||||
if let problem = await model.reloadFromSpool() {
|
||||
model.setStatus(problem)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var currentSessionRow: some View {
|
||||
HStack(alignment: .center, spacing: 8) {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text("Current session")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
Text(currentSessionSummary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
Spacer(minLength: 8)
|
||||
Button("Start new session") {
|
||||
Task { await model.startNewSession() }
|
||||
}
|
||||
.disabled(!model.canStartNewSession)
|
||||
.help("Keeps these captures as a past session and starts a fresh one.")
|
||||
}
|
||||
}
|
||||
|
||||
private var currentSessionSummary: String {
|
||||
let count = model.session.captures.count
|
||||
if count == 0 {
|
||||
return "Nothing captured yet."
|
||||
}
|
||||
return "\(count) capture\(count == 1 ? "" : "s") · started \(DubaiTime.stamp(model.session.createdAt))"
|
||||
}
|
||||
|
||||
private var footer: some View {
|
||||
HStack(spacing: 8) {
|
||||
Text("Sessions are kept in one folder — the newest \(SpoolStore.defaultRetainedSessionCount).")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
Spacer(minLength: 8)
|
||||
Button("Open sessions folder") {
|
||||
model.openSessionsFolder()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct PastSessionRow: View {
|
||||
@Environment(AppModel.self) private var model
|
||||
let session: CaptureSession
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .center, spacing: 8) {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(DubaiTime.stamp(session.createdAt))
|
||||
Text(submissionLabel)
|
||||
.font(.caption)
|
||||
.foregroundStyle(session.pdfFileName == nil ? .secondary : .primary)
|
||||
.lineLimit(1)
|
||||
}
|
||||
Spacer(minLength: 8)
|
||||
Button("PDF") {
|
||||
model.revealSentPDF(session)
|
||||
}
|
||||
.disabled(model.sentPDFURL(for: session) == nil)
|
||||
.help(session.pdfFileName.map { "Reveal \($0)" } ?? "This session was never sent.")
|
||||
Button("Captures") {
|
||||
model.revealSessionCaptures(session)
|
||||
}
|
||||
.help("Reveal this session's screenshots")
|
||||
}
|
||||
}
|
||||
|
||||
private var submissionLabel: String {
|
||||
let pages = "\(session.captures.count) page\(session.captures.count == 1 ? "" : "s")"
|
||||
guard let name = session.pdfFileName else {
|
||||
return "\(pages) · not sent"
|
||||
}
|
||||
return "\(pages) · sent as \(name)"
|
||||
}
|
||||
}
|
||||
|
||||
extension AppModel: SubmissionsWindowPresenting {
|
||||
private static var submissionsWindowController: NSWindowController?
|
||||
|
||||
public func presentSubmissionsWindow() {
|
||||
if let existing = Self.submissionsWindowController {
|
||||
existing.window?.makeKeyAndOrderFront(nil)
|
||||
NSApp.activate()
|
||||
return
|
||||
}
|
||||
let hosting = NSHostingController(rootView: PastSubmissionsView().environment(self))
|
||||
let window = NSWindow(contentViewController: hosting)
|
||||
window.title = "Redline — Past submissions"
|
||||
window.styleMask = [.titled, .closable]
|
||||
window.isReleasedWhenClosed = false
|
||||
window.center()
|
||||
let controller = NSWindowController(window: window)
|
||||
Self.submissionsWindowController = controller
|
||||
controller.showWindow(nil)
|
||||
NSApp.activate()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user