Merge pull request 'Redline: past submissions list + start-new-session with 10-session retention (MMDB-2925)' (#29) from feat/redline-sessions-history-20261011 into main
This commit was merged in pull request #29.
This commit is contained in:
@@ -14,6 +14,11 @@ public protocol SettingsWindowPresenting: AnyObject {
|
||||
func presentSettingsWindow()
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public protocol SubmissionsWindowPresenting: AnyObject {
|
||||
func presentSubmissionsWindow()
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public protocol ReturnsSectionProviding: AnyObject {
|
||||
@ViewBuilder func returnsSection() -> AnyView
|
||||
@@ -27,10 +32,17 @@ public final class AppModel {
|
||||
public private(set) var screenRecordingGranted: Bool
|
||||
public private(set) var allReturns: [ReturnedDocument] = []
|
||||
public private(set) var commentedReturns: [ReturnedDocument] = []
|
||||
/// Retained past sessions (newest first) — what the Past submissions window lists.
|
||||
public private(set) var pastSessions: [CaptureSession] = []
|
||||
public private(set) var statusLine: String?
|
||||
public private(set) var updateStatus: String?
|
||||
public private(set) var isCapturing: Bool = false
|
||||
public private(set) var isSending: Bool = false
|
||||
/// True while "Start new session" is between its guard and its store call — the
|
||||
/// synchronous flag both this action and send() check BEFORE their first await, so
|
||||
/// the two can never interleave a session close with an in-flight compose (a
|
||||
/// SwiftUI `.disabled` render-time guard alone does not stop a queued Task).
|
||||
public private(set) var isStartingNewSession: Bool = false
|
||||
public private(set) var outboxDisplayName: String
|
||||
public private(set) var watchFolderDisplayName: String
|
||||
/// Live transport choice; WP-onedrive reads this to pick the send path and to drive
|
||||
@@ -126,6 +138,9 @@ public final class AppModel {
|
||||
func setStatus(_ text: String?) { statusLine = text }
|
||||
func setUpdateStatus(_ text: String?) { updateStatus = text }
|
||||
func setSending(_ value: Bool) { isSending = value }
|
||||
/// Fixture seam (same family as setSending): lets tests/PanelSnapshot stage the
|
||||
/// in-flight-start state that production only ever reaches inside startNewSession().
|
||||
func setStartingNewSession(_ value: Bool) { isStartingNewSession = value }
|
||||
func setCapturing(_ value: Bool) { isCapturing = value }
|
||||
func replaceSession(_ new: CaptureSession) { session = new }
|
||||
func replaceRegion(_ new: CaptureRegion?) { region = new }
|
||||
@@ -133,6 +148,7 @@ public final class AppModel {
|
||||
allReturns = all
|
||||
commentedReturns = commented
|
||||
}
|
||||
func setPastSessions(_ value: [CaptureSession]) { pastSessions = value }
|
||||
func setFolderDisplayNames(outbox: String, watch: String) {
|
||||
outboxDisplayName = outbox
|
||||
watchFolderDisplayName = watch
|
||||
@@ -226,6 +242,12 @@ public final class AppModel {
|
||||
// Empty ledger on first run is not an error.
|
||||
}
|
||||
|
||||
do {
|
||||
setPastSessions(try await spool.archivedSessions())
|
||||
} catch {
|
||||
setStatus((error as? ShotdeckError)?.errorDescription ?? "Could not load past sessions.")
|
||||
}
|
||||
|
||||
// OneDrive mode: outbox == watch folder, so a freshly written, unmarked PDF must
|
||||
// never show up as a return; only a document that already carries a mark does.
|
||||
// Also make sure the resolved OneDrive folder actually exists before the
|
||||
@@ -388,6 +410,100 @@ public final class AppModel {
|
||||
}
|
||||
}
|
||||
|
||||
/// True when "Start new session" applies: there is something to keep and neither a
|
||||
/// send nor another session start is in flight.
|
||||
public var canStartNewSession: Bool {
|
||||
!session.isEmpty && !isSending && !isStartingNewSession
|
||||
}
|
||||
|
||||
/// Menu "Start new session": keeps the current screenshots as a past session
|
||||
/// (moved into the single archive folder — never deleted) and opens a fresh empty
|
||||
/// session. Session retention (newest 10 kept) is applied inside the store, on
|
||||
/// this path and on the send path alike.
|
||||
public func startNewSession() async {
|
||||
// Re-checked here on the main actor, synchronously, before the first await:
|
||||
// the menu's `.disabled` state cannot stop a Task that was queued just before
|
||||
// a send started.
|
||||
guard !isSending, !isStartingNewSession else {
|
||||
setStatus(isSending ? "Finish the current send first." : "A new session is already being started.")
|
||||
return
|
||||
}
|
||||
isStartingNewSession = true
|
||||
defer { isStartingNewSession = false }
|
||||
|
||||
var message: String
|
||||
do {
|
||||
if let archived = try await spool.closeCurrentSession() {
|
||||
let count = archived.captures.count
|
||||
message = "New session — \(count) capture\(count == 1 ? "" : "s") kept as a past session."
|
||||
} else {
|
||||
message = "New session started."
|
||||
}
|
||||
} catch {
|
||||
message = (error as? ShotdeckError)?.errorDescription ?? "Could not start a new session."
|
||||
}
|
||||
if let refreshProblem = await reloadFromSpool() {
|
||||
message += " \(refreshProblem)"
|
||||
}
|
||||
setStatus(message)
|
||||
}
|
||||
|
||||
/// Re-reads the open session and the past-session list from the store. Returns a
|
||||
/// problem description when either read failed (the caller decides how to surface
|
||||
/// it), nil when everything was refreshed — never silently substitutes stale state.
|
||||
func reloadFromSpool() async -> String? {
|
||||
var problems: [String] = []
|
||||
do {
|
||||
replaceSession(try await spool.currentSession())
|
||||
} catch {
|
||||
problems.append(
|
||||
"Could not reload the current session: \((error as? ShotdeckError)?.errorDescription ?? error.localizedDescription)")
|
||||
}
|
||||
do {
|
||||
setPastSessions(try await spool.archivedSessions())
|
||||
} catch {
|
||||
problems.append(
|
||||
"Could not load past sessions: \((error as? ShotdeckError)?.errorDescription ?? error.localizedDescription)")
|
||||
}
|
||||
return problems.isEmpty ? nil : problems.joined(separator: " ")
|
||||
}
|
||||
|
||||
/// Where a past session's sent PDF lives now (the outbox in AirDrop mode, the
|
||||
/// OneDrive folder in OneDrive mode), or nil when it was never sent / is gone.
|
||||
public func sentPDFURL(for session: CaptureSession) -> URL? {
|
||||
guard let name = session.pdfFileName else { return nil }
|
||||
let url = outboxURL.appendingPathComponent(name)
|
||||
return FileManager.default.fileExists(atPath: url.path) ? url : nil
|
||||
}
|
||||
|
||||
/// "PDF" action on a past-submission row: reveals the exact PDF that was sent.
|
||||
public func revealSentPDF(_ session: CaptureSession) {
|
||||
guard session.pdfFileName != nil else {
|
||||
setStatus("That session was never sent.")
|
||||
return
|
||||
}
|
||||
guard let url = sentPDFURL(for: session) else {
|
||||
setStatus("The PDF is no longer in \(outboxDisplayName).")
|
||||
return
|
||||
}
|
||||
NSWorkspace.shared.activateFileViewerSelecting([url])
|
||||
}
|
||||
|
||||
/// "Captures" action on a past-submission row: reveals that session's folder.
|
||||
public func revealSessionCaptures(_ session: CaptureSession) {
|
||||
let dir = paths.archiveDirectory(session.id)
|
||||
guard FileManager.default.fileExists(atPath: dir.path) else {
|
||||
setStatus("That past session is no longer on disk.")
|
||||
return
|
||||
}
|
||||
NSWorkspace.shared.activateFileViewerSelecting([dir])
|
||||
}
|
||||
|
||||
/// The single folder every retained session lives in.
|
||||
public func openSessionsFolder() {
|
||||
NSWorkspace.shared.open(paths.archive)
|
||||
}
|
||||
|
||||
public func copyCommentedLinks() async {
|
||||
do {
|
||||
let text = try await ledger.clipboardText()
|
||||
|
||||
@@ -119,6 +119,26 @@ 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: {
|
||||
|
||||
@@ -46,6 +46,11 @@ enum PanelSnapshot {
|
||||
|
||||
let region = sampleRegion()
|
||||
|
||||
// Two real past sessions through the REAL store paths (one sent with a PDF in
|
||||
// the outbox, one closed without ever sending) so panel-06b has the exact two
|
||||
// states the Past submissions window must distinguish.
|
||||
try await seedPastSessions(to: model)
|
||||
|
||||
// 01 — Screen Recording missing (no public mutator; snapshot-only seam).
|
||||
model.snapshotSetScreenRecordingGranted(false)
|
||||
model.replaceRegion(nil)
|
||||
@@ -74,6 +79,15 @@ enum PanelSnapshot {
|
||||
to: directory.appendingPathComponent("panel-06-settings.png")
|
||||
)
|
||||
|
||||
// 06b — Past submissions window against the same isolated model: the two
|
||||
// seeded past sessions plus the live session's three captures from panel 04.
|
||||
model.setPastSessions(try await model.spool.archivedSessions())
|
||||
try render(
|
||||
PastSubmissionsView().environment(model),
|
||||
to: directory.appendingPathComponent("panel-06b-past-submissions.png"),
|
||||
width: 440
|
||||
)
|
||||
|
||||
// 07/08/09 — OneDrive-mode Settings + menu bar, on a SEPARATE isolated model so
|
||||
// this transport switch never bleeds into the AirDrop-mode panels above.
|
||||
try await captureOneDrivePanels(to: directory)
|
||||
@@ -188,6 +202,27 @@ enum PanelSnapshot {
|
||||
try renderMenuBar(model: updateModel, to: directory, name: "14-update-revert")
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private static func seedPastSessions(to model: AppModel) async throws {
|
||||
_ = try await model.spool.append(
|
||||
pngData: try makePNGData(width: 192, height: 108, red: 0.55, green: 0.35, blue: 0.85),
|
||||
pixelWidth: 192, pixelHeight: 108, scale: 2.0, capturedAt: Date())
|
||||
_ = try await model.spool.append(
|
||||
pngData: try makePNGData(width: 192, height: 108, red: 0.25, green: 0.7, blue: 0.6),
|
||||
pixelWidth: 192, pixelHeight: 108, scale: 2.0, capturedAt: Date())
|
||||
let sentName = "Redline-\(DubaiTime.fileStamp(Date())).pdf"
|
||||
_ = try await model.spool.archiveCurrent(pdfFileName: sentName)
|
||||
// The real send writes the PDF to the outbox; the fixture does the same so the
|
||||
// row's PDF action is genuinely live in the snapshot.
|
||||
try Data("%PDF-1.4\n% snapshot fixture\n".utf8).write(
|
||||
to: model.paths.outbox.appendingPathComponent(sentName))
|
||||
|
||||
_ = try await model.spool.append(
|
||||
pngData: try makePNGData(width: 160, height: 90, red: 0.9, green: 0.55, blue: 0.2),
|
||||
pixelWidth: 160, pixelHeight: 90, scale: 2.0, capturedAt: Date())
|
||||
_ = try await model.spool.closeCurrentSession()
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private static func renderMenuBar(model: AppModel, to directory: URL, name: String) throws {
|
||||
try render(
|
||||
@@ -197,9 +232,9 @@ enum PanelSnapshot {
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private static func render(_ view: some View, to url: URL) throws {
|
||||
private static func render(_ view: some View, to url: URL, width: CGFloat = panelWidth) throws {
|
||||
let wrapped = view
|
||||
.frame(width: panelWidth, alignment: .topLeading)
|
||||
.frame(width: width, alignment: .topLeading)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.background(Color(nsColor: .windowBackgroundColor))
|
||||
|
||||
@@ -227,7 +262,7 @@ enum PanelSnapshot {
|
||||
size.height = hosting.intrinsicContentSize.height
|
||||
}
|
||||
if size.height < 1 { size.height = 240 }
|
||||
size.width = panelWidth
|
||||
size.width = width
|
||||
size.height = ceil(size.height)
|
||||
|
||||
hosting.setFrameSize(size)
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
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(pdfHelpText)
|
||||
Button("Captures") {
|
||||
model.revealSessionCaptures(session)
|
||||
}
|
||||
.help("Reveal this session's screenshots")
|
||||
}
|
||||
}
|
||||
|
||||
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)"
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
}
|
||||
@@ -241,7 +241,10 @@ enum PickerSelfTest {
|
||||
sendTruthFail("fail path status missing 'nothing was sent': \(model.statusLine ?? "nil")")
|
||||
}
|
||||
|
||||
await model.handleDidShareItems(fileName: pending.fileName, pageCount: pending.pageCount)
|
||||
let pageWord = pending.pageCount == 1 ? "page" : "pages"
|
||||
await model.handleDidShareItems(
|
||||
fileName: pending.fileName,
|
||||
sentSummary: "Sent — \(pending.pageCount) \(pageWord).")
|
||||
let fresh = try await model.spool.currentSession()
|
||||
guard fresh.isEmpty, fresh.id != openID, fresh.state == .open else {
|
||||
sendTruthFail("success path did not mint a fresh empty session")
|
||||
@@ -592,6 +595,38 @@ enum PickerSelfTest {
|
||||
return true
|
||||
}
|
||||
|
||||
/// Entry point for running ONLY the SEND-TRUTH phase, bypassing the on-screen picker
|
||||
/// chain entirely — the chain's REGION-PERSIST phase needs an active display
|
||||
/// (CGDisplayIsActive) and exits before SEND-TRUTH in headless/remote sessions.
|
||||
/// Escape hatch: `REDLINE_SELFTEST_PHASE=sendtruth`.
|
||||
static func runSendTruthOnlyIfRequested() {
|
||||
guard ProcessInfo.processInfo.environment["REDLINE_SELFTEST_PHASE"] == "sendtruth" else {
|
||||
return
|
||||
}
|
||||
// Same hop as runOneDriveOnlyIfRequested(): a plain main-queue turn after NSApp
|
||||
// starts, so AppKit/PDFKit calls inside the phase are not racing app launch.
|
||||
DispatchQueue.main.async {
|
||||
MainActor.assumeIsolated {
|
||||
runSendTruthAndExit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static func runSendTruthAndExit() {
|
||||
Task { @MainActor in
|
||||
do {
|
||||
try await executeSendTruth()
|
||||
print("SEND-TRUTH PASS")
|
||||
fflush(stdout)
|
||||
exit(0)
|
||||
} catch {
|
||||
print("SEND-TRUTH FAIL \(error)")
|
||||
fflush(stdout)
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Entry point for running ONLY this phase, bypassing the on-screen picker chain
|
||||
/// entirely. The harness has no other per-phase selector, so this is the escape
|
||||
/// hatch: `REDLINE_SELFTEST_PHASE=onedrive`.
|
||||
|
||||
@@ -14,6 +14,13 @@ struct ComposedSend: Sendable {
|
||||
extension AppModel: SendCapable {
|
||||
public func send(anchor: NSView?) async {
|
||||
guard !session.isEmpty, !isSending else { return }
|
||||
// Same synchronous guard as AppModel.startNewSession(): refuse while a session
|
||||
// start is mid-flight, instead of composing from a session directory that is
|
||||
// being renamed into the archive.
|
||||
guard !isStartingNewSession else {
|
||||
setStatus("Finish starting the new session first.")
|
||||
return
|
||||
}
|
||||
setSending(true)
|
||||
|
||||
// Wait for any IN-FLIGHT transport/folder reconcile (chooseTransport/
|
||||
@@ -88,10 +95,10 @@ extension AppModel: SendCapable {
|
||||
case .oneDrive:
|
||||
// No AirDrop, no anchor needed — the PDF is already in the watched
|
||||
// OneDrive folder. Archive immediately; the iPad marks it up in place.
|
||||
await handleDidShareItems(fileName: pending.fileName, pageCount: pending.pageCount)
|
||||
let pageWord = pending.pageCount == 1 ? "page" : "pages"
|
||||
setStatus(
|
||||
"Saved to OneDrive — \(pending.pageCount) \(pageWord). Open it in Files on your iPad."
|
||||
await handleDidShareItems(
|
||||
fileName: pending.fileName,
|
||||
sentSummary: "Saved to OneDrive — \(pending.pageCount) \(pageWord). Open it in Files on your iPad."
|
||||
)
|
||||
setSending(false)
|
||||
|
||||
@@ -106,9 +113,10 @@ extension AppModel: SendCapable {
|
||||
try Sharing.airDrop(fileURL: pending.fileURL, from: anchor) { [weak self] success in
|
||||
guard let self else { return }
|
||||
if success {
|
||||
let pageWord = pending.pageCount == 1 ? "page" : "pages"
|
||||
await self.handleDidShareItems(
|
||||
fileName: pending.fileName,
|
||||
pageCount: pending.pageCount
|
||||
sentSummary: "Sent — \(pending.pageCount) \(pageWord)."
|
||||
)
|
||||
} else {
|
||||
self.handleDidFailToShareItems(fileName: pending.fileName)
|
||||
@@ -187,17 +195,26 @@ extension AppModel: SendCapable {
|
||||
)
|
||||
}
|
||||
|
||||
/// `NSSharingServiceDelegate.sharingService(_:didShareItems:)` seam.
|
||||
func handleDidShareItems(fileName: String, pageCount: Int) async {
|
||||
/// `NSSharingServiceDelegate.sharingService(_:didShareItems:)` seam — also the
|
||||
/// OneDrive completion path. Composes ONE truthful status from the caller's success
|
||||
/// summary (the share itself DID complete) plus, when they happened, the archive
|
||||
/// error and any state-refresh problem — nothing is overwritten or hidden.
|
||||
func handleDidShareItems(fileName: String, sentSummary: String) async {
|
||||
guard !session.isEmpty else { return }
|
||||
var message = sentSummary
|
||||
do {
|
||||
_ = try await spool.archiveCurrent(pdfFileName: fileName)
|
||||
replaceSession(try await spool.currentSession())
|
||||
let pageWord = pageCount == 1 ? "page" : "pages"
|
||||
setStatus("Sent — \(pageCount) \(pageWord).")
|
||||
} catch {
|
||||
setStatus((error as? ShotdeckError)?.errorDescription ?? "Could not archive the session.")
|
||||
message += " \((error as? ShotdeckError)?.errorDescription ?? "Could not archive the session.")"
|
||||
}
|
||||
// Refresh model state from the store on BOTH paths: after a successful archive
|
||||
// the current session and the past-submissions list are stale until reloaded,
|
||||
// and after a failure the store (not this model) knows whether the session
|
||||
// actually moved. Any refresh problem is appended to the status, never hidden.
|
||||
if let refreshProblem = await reloadFromSpool() {
|
||||
message += " \(refreshProblem)"
|
||||
}
|
||||
setStatus(message)
|
||||
}
|
||||
|
||||
/// `NSSharingServiceDelegate.sharingService(_:didFailToShareItems:error:)` seam,
|
||||
|
||||
@@ -10,6 +10,9 @@ if ProcessInfo.processInfo.environment["SHOTDECK_SNAPSHOT_DIR"] != nil {
|
||||
if ProcessInfo.processInfo.environment["REDLINE_SELFTEST_PHASE"] == "onedrive" {
|
||||
MainActor.assumeIsolated { PickerSelfTest.runOneDriveOnlyIfRequested() }
|
||||
}
|
||||
if ProcessInfo.processInfo.environment["REDLINE_SELFTEST_PHASE"] == "sendtruth" {
|
||||
MainActor.assumeIsolated { PickerSelfTest.runSendTruthOnlyIfRequested() }
|
||||
}
|
||||
if ProcessInfo.processInfo.environment["SHOTDECK_PICKER_SELFTEST"] != nil {
|
||||
MainActor.assumeIsolated { PickerSelfTest.runIfRequested() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user