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,36 +2,28 @@ 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).
|
||||
/// "Past sessions" window: every retained session, whose captures they were, and
|
||||
/// which PDF (if any) went out for them. Read-and-reveal only — the current session
|
||||
/// is started/closed from the menu-bar panel and the button on the row below.
|
||||
struct PastSubmissionsView: View {
|
||||
@Environment(AppModel.self) private var model
|
||||
@State private var searchText = ""
|
||||
|
||||
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)
|
||||
emptyState
|
||||
} else {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
ForEach(model.pastSessions) { session in
|
||||
PastSessionRow(session: session)
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(maxHeight: 320)
|
||||
searchField
|
||||
sessionList
|
||||
}
|
||||
Divider()
|
||||
footer
|
||||
}
|
||||
.padding(10)
|
||||
.frame(width: 420, alignment: .leading)
|
||||
.padding(12)
|
||||
.frame(width: 460, alignment: .leading)
|
||||
.controlSize(.small)
|
||||
.task {
|
||||
if let problem = await model.reloadFromSpool() {
|
||||
@@ -40,21 +32,34 @@ struct PastSubmissionsView: View {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Current session
|
||||
|
||||
private var currentSessionRow: some View {
|
||||
HStack(alignment: .center, spacing: 8) {
|
||||
HStack(alignment: .top, spacing: 8) {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text("Current session")
|
||||
HStack(spacing: 6) {
|
||||
Text("Current session")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
Spacer(minLength: 6)
|
||||
Text(SessionDisplay.fullLabel(for: model.session))
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.monospacedDigit()
|
||||
}
|
||||
Text(currentSessionSummary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
Text(contextSummary)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
Text(currentSessionSummary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
Spacer(minLength: 8)
|
||||
Button("Start new session") {
|
||||
Button("New session") {
|
||||
Task { await model.startNewSession() }
|
||||
}
|
||||
.disabled(!model.canStartNewSession)
|
||||
.help("Keeps these captures as a past session and starts a fresh one.")
|
||||
.help("Keeps these captures as a past session and starts a fresh one. Nothing is deleted.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,16 +71,101 @@ struct PastSubmissionsView: View {
|
||||
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).")
|
||||
private var contextSummary: String {
|
||||
let summary = model.sessionContext.summaryLine
|
||||
return summary.isEmpty ? "No lane or build recorded — add details in the menu panel." : summary
|
||||
}
|
||||
|
||||
// MARK: - List
|
||||
|
||||
private var emptyState: some View {
|
||||
Text("No past sessions yet. “New session” keeps the current captures and starts a fresh one.")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.vertical, 12)
|
||||
}
|
||||
|
||||
private var searchField: some View {
|
||||
HStack(spacing: 6) {
|
||||
Image(systemName: "magnifyingglass")
|
||||
.foregroundStyle(.secondary)
|
||||
TextField("Search lane, build, commit, reviewer or file name", text: $searchText)
|
||||
.textFieldStyle(.plain)
|
||||
.font(.caption)
|
||||
.onSubmit { }
|
||||
if !searchText.isEmpty {
|
||||
Button {
|
||||
searchText = ""
|
||||
} label: {
|
||||
Image(systemName: "xmark.circle.fill")
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.accessibilityLabel("Clear search")
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 6)
|
||||
.padding(.vertical, 4)
|
||||
.background(.quaternary.opacity(0.5), in: RoundedRectangle(cornerRadius: 5, style: .continuous))
|
||||
}
|
||||
|
||||
private var filteredSessions: [CaptureSession] {
|
||||
let needle = searchText.trimmingCharacters(in: .whitespaces).lowercased()
|
||||
guard !needle.isEmpty else { return model.pastSessions }
|
||||
return model.pastSessions.filter { session in
|
||||
let haystack = [
|
||||
session.context.lane,
|
||||
session.context.deployedVersion,
|
||||
session.context.commit,
|
||||
session.context.reviewer,
|
||||
session.context.note,
|
||||
session.pdfFileName ?? "",
|
||||
SessionDisplay.fullLabel(for: session),
|
||||
DubaiTime.stamp(session.createdAt),
|
||||
].joined(separator: " ").lowercased()
|
||||
return haystack.contains(needle)
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var sessionList: some View {
|
||||
let sessions = filteredSessions
|
||||
if sessions.isEmpty {
|
||||
Text("No session matches “\(searchText)”.")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
} else {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
ForEach(sessions) { session in
|
||||
PastSessionRow(session: session)
|
||||
Divider()
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(maxHeight: 340)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Footer
|
||||
|
||||
private var footer: some View {
|
||||
HStack(alignment: .center, spacing: 8) {
|
||||
VStack(alignment: .leading, spacing: 1) {
|
||||
Text(model.retentionSummary)
|
||||
.font(.caption)
|
||||
Text("Sent PDFs are never deleted.")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
Spacer(minLength: 8)
|
||||
Button("Open sessions folder") {
|
||||
Button("Sessions folder") {
|
||||
model.openSessionsFolder()
|
||||
}
|
||||
.help("Open the folder that holds every kept session")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,33 +175,49 @@ private struct PastSessionRow: View {
|
||||
let session: CaptureSession
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .center, spacing: 8) {
|
||||
HStack(alignment: .top, spacing: 10) {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(DubaiTime.stamp(session.createdAt))
|
||||
HStack(spacing: 6) {
|
||||
Text(DubaiTime.stamp(session.createdAt))
|
||||
.monospacedDigit()
|
||||
Text(SessionDisplay.fullLabel(for: session))
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.monospacedDigit()
|
||||
}
|
||||
Text(contextLine)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
Text(submissionLabel)
|
||||
.font(.caption)
|
||||
.foregroundStyle(session.pdfFileName == nil ? .secondary : .primary)
|
||||
.lineLimit(1)
|
||||
}
|
||||
Spacer(minLength: 8)
|
||||
Button("PDF") {
|
||||
model.revealSentPDF(session)
|
||||
VStack(alignment: .trailing, spacing: 4) {
|
||||
Button("Reveal PDF") {
|
||||
model.revealSentPDF(session)
|
||||
}
|
||||
.disabled(model.sentPDFURL(for: session) == nil)
|
||||
.help(pdfHelpText)
|
||||
Button("Captures") {
|
||||
model.revealSessionCaptures(session)
|
||||
}
|
||||
.help("Reveal this session's screenshots")
|
||||
}
|
||||
.disabled(model.sentPDFURL(for: session) == nil)
|
||||
.help(pdfHelpText)
|
||||
Button("Captures") {
|
||||
model.revealSessionCaptures(session)
|
||||
}
|
||||
.help("Reveal this session's screenshots")
|
||||
}
|
||||
.padding(.vertical, 6)
|
||||
}
|
||||
|
||||
private var pdfHelpText: String {
|
||||
guard let name = session.pdfFileName else { return "This session was never sent." }
|
||||
guard model.sentPDFURL(for: session) != nil else {
|
||||
return "The PDF \(name) is no longer in the output folder."
|
||||
}
|
||||
return "Reveal \(name)"
|
||||
/// Everything recorded for the session except the lane, which the row's label
|
||||
/// already shows: deployed build, commit, reviewer, note.
|
||||
private var contextLine: String {
|
||||
let context = session.context
|
||||
var parts: [String] = []
|
||||
if !context.deployedVersion.isEmpty { parts.append(context.deployedVersion) }
|
||||
if !context.commit.isEmpty { parts.append(context.commit) }
|
||||
if !context.reviewer.isEmpty { parts.append(context.reviewer) }
|
||||
if !context.note.isEmpty { parts.append("Note: \(context.note)") }
|
||||
return parts.isEmpty ? "No build or commit recorded" : parts.joined(separator: " · ")
|
||||
}
|
||||
|
||||
private var submissionLabel: String {
|
||||
@@ -121,6 +227,14 @@ private struct PastSessionRow: View {
|
||||
}
|
||||
return "\(pages) · sent as \(name)"
|
||||
}
|
||||
|
||||
private var pdfHelpText: String {
|
||||
guard let name = session.pdfFileName else { return "This session was never sent." }
|
||||
guard model.sentPDFURL(for: session) != nil else {
|
||||
return "The PDF \(name) is no longer in the output folder."
|
||||
}
|
||||
return "Reveal \(name)"
|
||||
}
|
||||
}
|
||||
|
||||
extension AppModel: SubmissionsWindowPresenting {
|
||||
@@ -134,7 +248,7 @@ extension AppModel: SubmissionsWindowPresenting {
|
||||
}
|
||||
let hosting = NSHostingController(rootView: PastSubmissionsView().environment(self))
|
||||
let window = NSWindow(contentViewController: hosting)
|
||||
window.title = "Redline — Past submissions"
|
||||
window.title = "Redline — Past sessions"
|
||||
window.styleMask = [.titled, .closable]
|
||||
window.isReleasedWhenClosed = false
|
||||
window.center()
|
||||
|
||||
Reference in New Issue
Block a user