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:
Claude Fable 5
2026-10-31 11:32:54 +04:00
parent 542aad296b
commit 02fa791b78
26 changed files with 2780 additions and 279 deletions
+46 -3
View File
@@ -15,6 +15,12 @@ public struct PageLayout: Sendable, Equatable {
public let timestampText: String
public let timestampOrigin: CGPoint
/// Reference block under the image (up to two lines): who, when, which lane,
/// which deployed build and commit. Empty when the caller passes no lines.
public let footerRect: CGRect
public let footerLines: [String]
public let footerOrigins: [CGPoint]
public let passLabelOrigin: CGPoint
public let failLabelOrigin: CGPoint
public let passTickBox: CGRect
@@ -25,10 +31,13 @@ public struct PageLayout: Sendable, Equatable {
public var pageNumberFont: NSFont { NSFont.systemFont(ofSize: 9, weight: .semibold) }
public var timestampFont: NSFont { NSFont.systemFont(ofSize: 9, weight: .regular) }
public var tickLabelFont: NSFont { NSFont.systemFont(ofSize: 8, weight: .semibold) }
public var footerFont: NSFont { NSFont.systemFont(ofSize: 7.5, weight: .regular) }
private static let marginAll: CGFloat = 18
private static let headerHeight: CGFloat = 26
private static let headerImageGap: CGFloat = 10
private static let footerLineHeight: CGFloat = 9.5
private static let footerImageGap: CGFloat = 7
private static let tickBoxSize: CGFloat = 13
private static let tickGroupGap: CGFloat = 8
private static let portraitPage = CGSize(width: 595, height: 842)
@@ -36,10 +45,13 @@ public struct PageLayout: Sendable, Equatable {
/// `pageIndex` and `pageCount` are 1-based / total, over ACTUALLY-WRITTEN pages
/// (see SPEC decision D-D), not `capture.sequence` / `session.captures.count`.
public init(capture: Capture, pageIndex: Int, pageCount: Int) {
/// `footerLines` is the pre-truncated reference block; an empty array keeps the
/// image area exactly as it was before the footer existed.
public init(capture: Capture, pageIndex: Int, pageCount: Int, footerLines: [String] = []) {
let pageNumberFont = NSFont.systemFont(ofSize: 9, weight: .semibold)
let timestampFont = NSFont.systemFont(ofSize: 9, weight: .regular)
let tickLabelFont = NSFont.systemFont(ofSize: 8, weight: .semibold)
let footerLabelFont = NSFont.systemFont(ofSize: 7.5, weight: .regular)
isLandscape = capture.isLandscape
pageRect = CGRect(origin: .zero, size: isLandscape ? Self.landscapePage : Self.portraitPage)
@@ -59,11 +71,23 @@ public struct PageLayout: Sendable, Equatable {
height: Self.headerHeight
)
imageBoxRect = CGRect(
self.footerLines = footerLines
let footerHeight = footerLines.isEmpty
? 0
: CGFloat(footerLines.count) * Self.footerLineHeight
footerRect = CGRect(
x: contentMinX,
y: contentMinY,
width: contentWidth,
height: headerRect.minY - Self.headerImageGap - contentMinY
height: footerHeight
)
let imageBoxMinY = contentMinY + (footerLines.isEmpty ? 0 : footerHeight + Self.footerImageGap)
imageBoxRect = CGRect(
x: contentMinX,
y: imageBoxMinY,
width: contentWidth,
height: headerRect.minY - Self.headerImageGap - imageBoxMinY
)
let pointSize = CGSize(
@@ -91,6 +115,22 @@ public struct PageLayout: Sendable, Equatable {
let descent = CTFontGetDescent(metricsFont)
let baselineY = headerRect.minY + (headerRect.height - (ascent + descent)) / 2 + descent
// Footer baselines, top line first, using the footer font's own descent.
let footerMetrics = footerLabelFont as CTFont
let footerAscent = CTFontGetAscent(footerMetrics)
let footerDescent = CTFontGetDescent(footerMetrics)
let footerLeading = Self.footerLineHeight
var origins: [CGPoint] = []
origins.reserveCapacity(footerLines.count)
for index in footerLines.indices {
let lineBottom = footerRect.maxY - CGFloat(index + 1) * footerLeading
origins.append(CGPoint(
x: footerRect.minX,
y: lineBottom + max(0, (footerLeading - (footerAscent + footerDescent)) / 2) + footerDescent
))
}
footerOrigins = origins
pageNumberText = "\(pageIndex) / \(pageCount)"
pageNumberOrigin = CGPoint(x: headerRect.minX, y: baselineY)
@@ -135,6 +175,9 @@ public struct PageLayout: Sendable, Equatable {
&& lhs.pageNumberOrigin == rhs.pageNumberOrigin
&& lhs.timestampText == rhs.timestampText
&& lhs.timestampOrigin == rhs.timestampOrigin
&& lhs.footerRect == rhs.footerRect
&& lhs.footerLines == rhs.footerLines
&& lhs.footerOrigins == rhs.footerOrigins
&& lhs.passLabelOrigin == rhs.passLabelOrigin
&& lhs.failLabelOrigin == rhs.failLabelOrigin
&& lhs.passTickBox == rhs.passTickBox