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:
Claude Fable 5
2026-10-11 13:35:38 +04:00
parent eb1af5bf18
commit 6ab398c3f2
8 changed files with 790 additions and 18 deletions
+38 -3
View File
@@ -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)
@@ -157,6 +171,27 @@ enum PanelSnapshot {
try renderMenuBar(model: model, to: directory, name: "09-captures-present-onedrive")
}
@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(
@@ -166,9 +201,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))
@@ -196,7 +231,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)