feat(ui): rebuild the UX around two surfaces — a glance popover and a session window

The menu-bar popover was being used as a session manager: status, five text fields,
thumbnails, three buttons, a history list and eight more flat rows in 320 pt. The
redesign splits the product by job, from a UX pass whose mockups are kept under
design/ux-rework/.

- Popover: only the current session. Review details as one line plus a pencil that
  opens the window with the Lane field focused, at most three thumbnails, a Capture
  and a Send row, a New Session and Open Redline row, one status line when something
  happened, and a footer with the send channel, the retention policy and a ... menu
  for Settings / updates / quit.
- Window: sidebar of sessions grouped Today / Yesterday / This week / by month with
  a Current tag and each session's state, the selected session's pages as cards
  (select, Delete or Remove Page, sent sessions read-only), and an inspector with
  editable review details, the PDF facts (file name, pages, channel, status) and the
  session facts (started, id, files). Past sessions show their details read-only.
- Settings: three labelled groups (Capture, Sending, Sessions) replacing the
  headings-plus-grid layout.
- Sessions list/search/grouping/state live on the model, so the window and the popover
  read the same truth (came-back-marked state comes from the return ledger).
- Verification: 159 tests, the headless panel self-test, and an end-to-end run against
  the active app (scripts/run-e2e-ui.sh) which opens the real window, types into the
  Lane field with key events and clicks New Session, reporting what the launch mode
  could and could not deliver.
This commit is contained in:
Claude Fable 5
2026-10-31 13:03:08 +04:00
parent 02fa791b78
commit 3061e45bcb
11 changed files with 2389 additions and 1273 deletions
+19 -5
View File
@@ -7,19 +7,33 @@ A macOS menu-bar app that captures a remembered screen region, builds a one-scre
- **⌥⇧1** — pick a new region, then capture it.
- **⌥⇧2** — capture the remembered region instantly (no picker).
## Where things live
Two surfaces, two jobs:
- **Menu-bar popover** — only the current session: its review details on one line, its
pages, then Capture, Send, New Session, Open Redline, and one status line when
something happened. Nothing else, so it never scrolls.
- **Redline window** (Open Redline) — the workspace: every session in a sidebar grouped
by day, the selected session's pages in the middle, and its review details, PDF facts
and session facts in the inspector. History, text entry and file facts live here
because they need room and a window that stays open.
- **Settings** (⌘, in the popover's … menu) — capture, sending, and the session age limit.
## Sessions
Every review is a session. Captures go into the open session; "New session" closes it
and keeps it in the Past sessions list, named and dated, whether or not it was sent.
Every review is a session. Captures go into the open session; "New Session" closes it
and keeps it in the sidebar, named and dated, whether or not it was sent.
- **Nothing is deleted by default.** A session is kept until you delete it.
- **Settings > Sessions > Delete after** sets an age limit (7 days … 1 year). Sessions
older than the limit are removed on the next launch and by **Clean up now**.
Only Redline's own saved screenshots are removed; a PDF that was already sent stays
in the folder it was sent to.
- **Details** on the current session records what is being reviewed: lane/environment,
the deployed build, the commit, the reviewer (pre-filled with this Mac's user) and a
free note. A new session inherits the previous session's details.
- **Review details** (inspector) record what is being reviewed: lane/environment, the
deployed build, the commit, the reviewer (pre-filled with this Mac's user) and a free
note. A new session inherits the previous session's details, and past sessions show
them read-only.
## Files and PDF metadata
+198 -4
View File
@@ -15,8 +15,8 @@ public protocol SettingsWindowPresenting: AnyObject {
}
@MainActor
public protocol SubmissionsWindowPresenting: AnyObject {
func presentSubmissionsWindow()
public protocol SessionsWindowPresenting: AnyObject {
func presentSessionsWindow(focusLane: Bool)
}
@MainActor
@@ -32,8 +32,13 @@ 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.
/// Retained past sessions (newest first) — what the sessions window lists.
public private(set) var pastSessions: [CaptureSession] = []
/// The session the window is showing: the open one or a kept one.
public private(set) var selectedSessionID: UUID?
/// Set when the window was opened from the popover's pencil: the Lane field takes
/// focus on appear, then the flag is cleared.
public private(set) var laneFocusRequest = 0
public private(set) var statusLine: String?
public private(set) var updateStatus: String?
/// The user's age limit for kept sessions (Settings > Sessions). `.never` until
@@ -159,7 +164,14 @@ public final class AppModel {
allReturns = all
commentedReturns = commented
}
func setPastSessions(_ value: [CaptureSession]) { pastSessions = value }
func setPastSessions(_ value: [CaptureSession]) {
pastSessions = value
if selectedSessionID == nil {
selectedSessionID = session.id
}
}
func setSelectedSessionID(_ value: UUID?) { selectedSessionID = value }
func requestLaneFocus() { laneFocusRequest += 1 }
func setFolderDisplayNames(outbox: String, watch: String) {
outboxDisplayName = outbox
watchFolderDisplayName = watch
@@ -178,6 +190,9 @@ public final class AppModel {
/// lets the LAST choice win instead of applying stale, superseded work. Not
/// `@Observable`-relevant state — pure internal bookkeeping, never read by a View.
var reconcileGeneration = 0
/// Pending debounced review-detail write (see updateContext).
private var pendingContextWrite: Task<Void, Never>?
/// The MOST RECENT watcher-reconcile Task spawned by chooseTransport/
/// chooseOneDriveFolder, if one is still (or was just) in flight. send() awaits
/// this BEFORE snapshotting transport/folder, so a toggle immediately followed by
@@ -218,6 +233,184 @@ public final class AppModel {
}
}
// MARK: - Session browsing (the sessions window)
/// What a session row says about itself in the list.
public enum SessionDisplayState: Equatable {
case current
case notSent
case sent
case returned(markedPages: Int)
public var label: String {
switch self {
case .current: return "not sent"
case .notSent: return "not sent"
case .sent: return "sent"
case .returned(let pages):
return pages == 1 ? "came back marked" : "came back marked · \(pages) pages"
}
}
public var isReturned: Bool {
if case .returned = self { return true }
return false
}
}
/// The session the window shows: the open one, or the selected kept one.
public var selectedSession: CaptureSession? {
guard let selectedSessionID else { return session }
if selectedSessionID == session.id { return session }
return pastSessions.first { $0.id == selectedSessionID } ?? session
}
public var selectedIsCurrent: Bool {
selectedSession?.id == session.id
}
public func selectSession(_ id: UUID?) {
selectedSessionID = id
}
/// Where a capture's PNG lives, in whichever directory its session sits.
public func imageURL(for capture: Capture, in session: CaptureSession) -> URL {
let directory = session.state == .open
? paths.sessionDirectory(session.id)
: paths.archiveDirectory(session.id)
return directory.appendingPathComponent(capture.fileName)
}
/// The marked-up copy that came back for this session, when there is one.
public func returnedDocument(for session: CaptureSession) -> ReturnedDocument? {
guard let fileName = session.pdfFileName else { return nil }
return allReturns.first { $0.fileURL.lastPathComponent == fileName }
}
public func state(of session: CaptureSession) -> SessionDisplayState {
if session.id == self.session.id, session.state == .open {
return .current
}
if let document = returnedDocument(for: session), document.isCommented {
return .returned(markedPages: document.annotatedPages.count)
}
return session.pdfFileName == nil ? .notSent : .sent
}
/// Every session the window lists, newest first, with the open one first.
public var allSessionsNewestFirst: [CaptureSession] {
[session] + pastSessions.filter { $0.id != session.id }
}
/// Text match over the fields a person would search by.
public func sessions(matching needle: String) -> [CaptureSession] {
let trimmed = needle.trimmingCharacters(in: .whitespaces).lowercased()
guard !trimmed.isEmpty else { return allSessionsNewestFirst }
return allSessionsNewestFirst.filter { candidate in
let haystack = [
candidate.context.lane,
candidate.context.deployedVersion,
candidate.context.commit,
candidate.context.reviewer,
candidate.context.note,
candidate.pdfFileName ?? "",
candidate.shortID,
DubaiTime.stamp(candidate.createdAt),
].joined(separator: " ").lowercased()
return haystack.contains(trimmed)
}
}
/// One sidebar section: a day bucket or a month bucket.
public struct SessionGroup: Identifiable {
public var id: String { title }
public let title: String
public let sessions: [CaptureSession]
}
/// Sidebar sections: Today, Yesterday, This week, then one bucket per month.
/// Empty sections are dropped so the list never shows a heading with nothing under it.
public func groupedSections(for sessions: [CaptureSession]) -> [SessionGroup] {
guard let dubai = TimeZone(identifier: "Asia/Dubai") else {
return [SessionGroup(title: "Sessions", sessions: sessions)]
}
var calendar = Calendar(identifier: .gregorian)
calendar.timeZone = dubai
let now = Date()
let startOfToday = calendar.startOfDay(for: now)
let startOfYesterday = calendar.date(byAdding: .day, value: -1, to: startOfToday) ?? startOfToday
let startOfWeek = calendar.date(byAdding: .day, value: -7, to: startOfToday) ?? startOfToday
let monthFormatter = DateFormatter()
monthFormatter.calendar = calendar
monthFormatter.timeZone = dubai
monthFormatter.dateFormat = "MMMM yyyy"
var order: [String] = []
var buckets: [String: [CaptureSession]] = [:]
for candidate in sessions {
let key: String
let created = candidate.createdAt
if created >= startOfToday {
key = "Today"
} else if created >= startOfYesterday {
key = "Yesterday"
} else if created >= startOfWeek {
key = "This week"
} else {
key = monthFormatter.string(from: created)
}
if buckets[key] == nil {
buckets[key] = []
order.append(key)
}
buckets[key]?.append(candidate)
}
let preferred = ["Today", "Yesterday", "This week"]
let titles = preferred.filter { buckets[$0] != nil } + order.filter { !preferred.contains($0) }
return titles.map { SessionGroup(title: $0, sessions: buckets[$0] ?? []) }
}
/// Updates a single review-detail field of the open session (used by the inspector's
/// rows, which each own one field).
public func updateContext(_ field: WritableKeyPath<ReviewContext, String>, _ value: String) {
var context = session.context
context[keyPath: field] = value
guard context != session.context else { return }
pendingContextWrite?.cancel()
pendingContextWrite = Task { [weak self] in
try? await Task.sleep(for: .milliseconds(180))
guard !Task.isCancelled, let self else { return }
await self.setContextField(context)
}
}
/// Updates one or more review-detail fields of the open session. Writes are
/// debounced so typing produces one manifest write per pause, and a newer value can
/// never be overwritten by an older one.
public func updateContext(
lane: String? = nil,
deployedVersion: String? = nil,
commit: String? = nil,
reviewer: String? = nil,
note: String? = nil
) {
let current = session.context
let next = ReviewContext(
lane: lane ?? current.lane,
deployedVersion: deployedVersion ?? current.deployedVersion,
commit: commit ?? current.commit,
reviewer: reviewer ?? current.reviewer,
note: note ?? current.note
)
guard next != current else { return }
pendingContextWrite?.cancel()
pendingContextWrite = Task { [weak self] in
try? await Task.sleep(for: .milliseconds(180))
guard !Task.isCancelled, let self else { return }
await self.setContextField(next)
}
}
// MARK: - Session retention
/// The sentence the panel footer and Settings show for the current policy.
@@ -547,6 +740,7 @@ public final class AppModel {
if let refreshProblem = await reloadFromSpool() {
message += " \(refreshProblem)"
}
selectSession(session.id)
setStatus(message)
}
+210 -324
View File
@@ -2,79 +2,125 @@ import AppKit
import SwiftUI
import ShotdeckCore
/// The menu-bar panel. Hierarchy: what is being worked on first, the three core
/// verbs second, recent sessions third, housekeeping last.
/// The menu-bar popover: the current session, and the two things you do with it.
///
/// Everything else — history, review details, PDF facts — lives in the Redline
/// window, which stays open and has room for it.
struct MenuBarView: View {
@Environment(AppModel.self) private var model
/// Snapshot-only: opens the details editor on first render.
private let startsWithDetailsOpen: Bool
@State private var showsDetails = false
init(showsContextEditor: Bool = false) {
self.startsWithDetailsOpen = showsContextEditor
}
var body: some View {
VStack(alignment: .leading, spacing: 10) {
VStack(alignment: .leading, spacing: 8) {
if model.screenRecordingGranted {
sessionHeader
thumbnailRow
statusRow
sessionBlock
actionRows
Divider()
recentSessionsBlock
Divider()
secondaryActions
if !model.allReturns.isEmpty {
Divider()
returnsBlock
}
footer
} else {
permissionBlock
Divider()
footer
}
}
.padding(10)
.frame(width: 320, alignment: .leading)
.frame(width: 340, alignment: .leading)
.controlSize(.small)
.onAppear { showsDetails = startsWithDetailsOpen }
}
// MARK: - Status
// MARK: - Header
@ViewBuilder
private var statusRow: some View {
if !model.screenRecordingGranted {
HStack(alignment: .top, spacing: 6) {
Image(systemName: "exclamationmark.triangle")
.foregroundStyle(.yellow)
VStack(alignment: .leading, spacing: 4) {
Text(
ShotdeckError.screenRecordingNotGranted.errorDescription
?? "Screen Recording is turned off."
)
.font(.caption)
.fixedSize(horizontal: false, vertical: true)
Button("Open Screen Recording settings") {
model.openScreenRecordingSettings()
private var sessionHeader: some View {
HStack(alignment: .top, spacing: 8) {
VStack(alignment: .leading, spacing: 1) {
HStack(spacing: 5) {
Text(laneTitle)
.font(.system(size: 13, weight: .semibold))
.lineLimit(1)
if let version = versionTitle {
Text(version)
.font(.system(size: 13))
.foregroundStyle(.secondary)
.lineLimit(1)
}
}
}
} else if let status = model.statusLine {
Text(status)
.font(.caption)
.foregroundStyle(.primary)
.fixedSize(horizontal: false, vertical: true)
} else {
Text(defaultStatusText)
Text(detailLine)
.font(.caption)
.foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
.lineLimit(1)
.truncationMode(.tail)
.help(detailLine)
}
Spacer(minLength: 4)
if !model.session.isEmpty {
Text("\(model.session.captures.count) page\(model.session.captures.count == 1 ? "" : "s")")
.font(.caption)
.foregroundStyle(.secondary)
.monospacedDigit()
.padding(.horizontal, 6)
.padding(.vertical, 2)
.background(.quaternary, in: Capsule())
}
Button {
presentWindow(focusLane: true)
} label: {
Image(systemName: "square.and.pencil")
.font(.system(size: 12, weight: .semibold))
}
.buttonStyle(.borderless)
.help("Edit review details")
.accessibilityLabel("Edit review details")
}
}
private var defaultStatusText: String {
guard let region = model.region else {
return "No area selected yet — press \(model.hotkeyDisplayString) to pick one."
private var laneTitle: String {
let lane = model.session.context.lane
return lane.isEmpty ? "No lane" : lane
}
let w = Int(region.rect.width)
let h = Int(region.rect.height)
return "Capturing \(w) × \(h) on \(displayName(for: region))"
private var versionTitle: String? {
let version = model.session.context.deployedVersion
return version.isEmpty ? nil : version
}
private var detailLine: String {
let context = model.session.context
var parts: [String] = []
if !context.commit.isEmpty { parts.append(context.commit) }
if !context.reviewer.isEmpty { parts.append(context.reviewer) }
let started = DubaiTime.checkTime(model.session.createdAt)
if parts.isEmpty {
return "No review details yet · started \(started)"
}
return parts.joined(separator: " · ") + " · started \(started)"
}
// MARK: - Body
@ViewBuilder
private var thumbnailRow: some View {
if model.session.isEmpty {
VStack(spacing: 2) {
Text("Nothing captured yet")
.font(.callout)
.foregroundStyle(.secondary)
Text(emptyHint)
.font(.caption)
.foregroundStyle(.tertiary)
}
.frame(maxWidth: .infinity, minHeight: 62)
.background(.quaternary.opacity(0.4), in: RoundedRectangle(cornerRadius: 6, style: .continuous))
} else {
SessionStrip(limit: 3)
}
}
private var emptyHint: String {
guard let region = model.region else {
return "\(model.hotkeyDisplayString) picks an area, then captures it"
}
return "\(model.hotkeyDisplayString) captures \(Int(region.rect.width)) × \(Int(region.rect.height)) on \(displayName(for: region))"
}
private func displayName(for region: CaptureRegion) -> String {
@@ -88,322 +134,162 @@ struct MenuBarView: View {
return "Display 1"
}
// MARK: - Current session
private var sessionBlock: some View {
VStack(alignment: .leading, spacing: 6) {
HStack(alignment: .firstTextBaseline, spacing: 6) {
Text("Current session")
.font(.caption.weight(.semibold))
Spacer(minLength: 6)
Text(captureCountText)
/// One line, only when there is something to say: the last action's result, or a
/// PDF that came back with marks.
@ViewBuilder
private var statusRow: some View {
if let status = model.statusLine, !status.isEmpty {
Text(status)
.font(.caption)
.foregroundStyle(.secondary)
.monospacedDigit()
.lineLimit(2)
.fixedSize(horizontal: false, vertical: true)
}
}
HStack(alignment: .firstTextBaseline, spacing: 6) {
Text(contextSummary)
.font(.caption)
.foregroundStyle(model.sessionContext.summaryLine.isEmpty ? .secondary : .primary)
.lineLimit(1)
.truncationMode(.tail)
.help(contextSummary)
Spacer(minLength: 4)
// A bordered control, not a link: in a menu panel the row of text is
// the value, and the thing you press has to look pressable.
Button {
showsDetails.toggle()
} label: {
HStack(spacing: 2) {
Text(showsDetails ? "Hide" : "Details")
Image(systemName: showsDetails ? "chevron.up" : "chevron.down")
.font(.system(size: 9, weight: .semibold))
}
}
.buttonStyle(.bordered)
.accessibilityLabel(showsDetails ? "Hide details" : "Show details")
}
if showsDetails {
SessionContextEditor()
}
SessionStrip()
private var actionRows: some View {
VStack(spacing: 6) {
HStack(spacing: 6) {
Button("Capture") {
Button {
Task { await model.captureNow() }
} label: {
HStack(spacing: 4) {
Image(systemName: "viewfinder")
Text(model.isCapturing ? "Capturing…" : "Capture")
Text(model.hotkeyDisplayString)
.foregroundStyle(.secondary)
}
.frame(maxWidth: .infinity)
}
.controlSize(.regular)
.disabled(model.isCapturing)
Button(model.transport == .oneDrive ? "Send to OneDrive" : "Send…") {
Button {
guard let sender = model as? SendCapable else {
model.setStatus("Send is not available in this build.")
return
}
let anchor = NSApp.keyWindow?.contentView
Task { await sender.send(anchor: anchor) }
} label: {
HStack(spacing: 4) {
Image(systemName: "paperplane.fill")
Text(sendTitle)
}
.frame(maxWidth: .infinity)
}
.buttonStyle(.borderedProminent)
.controlSize(.regular)
.disabled(model.session.isEmpty || model.isSending)
}
Button("New session") {
HStack(spacing: 6) {
Button {
Task { await model.startNewSession() }
} label: {
HStack(spacing: 4) {
Image(systemName: "plus.square.on.square")
Text("New Session")
}
.frame(maxWidth: .infinity)
}
.controlSize(.regular)
.disabled(!model.canStartNewSession)
.help("Keeps these captures as a past session and starts a fresh one. Nothing is deleted.")
.help("Keeps this session and starts a fresh one. Nothing is deleted.")
Button {
presentWindow(focusLane: false)
} label: {
HStack(spacing: 4) {
Image(systemName: "macwindow")
Text("Open Redline")
}
.frame(maxWidth: .infinity)
}
.buttonStyle(.bordered)
.controlSize(.regular)
}
.frame(maxWidth: .infinity, alignment: .leading)
}
}
private var captureCountText: String {
private var sendTitle: String {
let count = model.session.captures.count
if count == 0 { return "empty" }
return "\(count) capture\(count == 1 ? "" : "s")"
}
private var contextSummary: String {
let summary = model.sessionContext.summaryLine
return summary.isEmpty ? "No lane or build recorded — add details" : summary
}
// MARK: - Recent sessions
private var recentSessionsBlock: some View {
VStack(alignment: .leading, spacing: 3) {
HStack(alignment: .firstTextBaseline, spacing: 6) {
Text("Recent sessions")
.font(.caption.weight(.semibold))
if !model.pastSessions.isEmpty {
Text("\(model.pastSessions.count)")
.font(.caption)
.foregroundStyle(.secondary)
.monospacedDigit()
}
Spacer(minLength: 6)
Button("Show all…") {
if let presenter = model as? SubmissionsWindowPresenting {
presenter.presentSubmissionsWindow()
} else {
model.setStatus("Past sessions are not available in this build.")
}
}
.buttonStyle(.link)
}
if model.pastSessions.isEmpty {
Text("Nothing yet. “New session” keeps this one and starts a fresh one.")
.font(.caption)
.foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
} else {
ForEach(model.pastSessions.prefix(4)) { session in
RecentSessionRow(session: session)
}
}
}
}
// MARK: - Secondary actions
private var secondaryActions: some View {
VStack(alignment: .leading, spacing: 2) {
if let update = model.updateAvailable {
Button {
model.installUpdate()
} label: {
actionLabel("Update to \(update.version)")
.foregroundStyle(Color.accentColor)
}
}
if let previous = model.previousVersion {
Button {
model.revertToPreviousVersion()
} label: {
actionLabel("Revert to \(previous)")
}
}
Button {
model.revealLastPDF()
} label: {
actionLabel("Reveal last PDF")
}
.disabled(!model.canRevealLastPDF)
Button {
Task { await model.copyCommentedLinks() }
} label: {
actionLabel(
"Copy commented links",
trailing: model.commentedReturns.isEmpty ? nil : "\(model.commentedReturns.count)"
)
}
.disabled(model.commentedReturns.isEmpty)
Button {
Task { await model.rePickRegion() }
} label: {
actionLabel("Re-select area")
}
Button {
Task { await model.captureNow() }
} label: {
actionLabel("Capture now", trailing: model.hotkeyDisplayString)
}
.disabled(model.isCapturing)
}
.buttonStyle(.plain)
}
private func actionLabel(_ title: String, trailing: String? = nil) -> some View {
HStack(spacing: 8) {
Text(title)
Spacer(minLength: 8)
if let trailing {
Text(trailing)
.foregroundStyle(.secondary)
.monospacedDigit()
}
}
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
.padding(.vertical, 3)
}
@ViewBuilder
private var returnsBlock: some View {
if let provider = model as? ReturnsSectionProviding {
provider.returnsSection()
} else {
VStack(alignment: .leading, spacing: 4) {
Text("Came back from your device")
.font(.caption.weight(.semibold))
ForEach(newestReturns.prefix(6)) { doc in
HStack(spacing: 8) {
Text(doc.fileURL.lastPathComponent)
.lineLimit(1)
Spacer(minLength: 8)
Text(doc.isCommented
? "\(doc.annotatedPages.count) page\(doc.annotatedPages.count == 1 ? "" : "s") marked"
: "not marked")
.font(.caption)
.foregroundStyle(doc.isCommented ? .primary : .secondary)
}
}
}
}
}
private var newestReturns: [ReturnedDocument] {
model.allReturns.sorted { $0.detectedAt > $1.detectedAt }
guard count > 0 else { return "Send…" }
let pages = "\(count) page\(count == 1 ? "" : "s")"
return model.transport == .oneDrive ? "Save \(pages)…" : "Send \(pages)…"
}
// MARK: - Footer
private var footer: some View {
VStack(alignment: .leading, spacing: 3) {
HStack(spacing: 6) {
Button("Settings…") {
if let presenter = model as? SettingsWindowPresenting {
presenter.presentSettingsWindow()
} else {
model.setStatus("Settings is not available in this build.")
}
}
.buttonStyle(.link)
Button("Check for updates") {
model.checkForUpdates()
}
.buttonStyle(.link)
.disabled(model.isCheckingForUpdates)
Spacer(minLength: 6)
Button("Quit") {
NSApp.terminate(nil)
}
.buttonStyle(.link)
}
Text("Redline \(model.appVersion) · \(model.retentionSummary)")
Text("\(sendChannel) · \(model.retentionSummary)")
.font(.caption)
.foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
if let message = model.updateStatusMessage {
Text(message)
.font(.caption)
.foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
}
}
}
}
/// One row of the panel's recent-sessions list: timestamp, readable session label,
/// page count and sent state. Clicking reveals the sent PDF when there is one,
/// otherwise that session's captures.
private struct RecentSessionRow: View {
@Environment(AppModel.self) private var model
let session: CaptureSession
@State private var hovering = false
var body: some View {
Button {
if model.sentPDFURL(for: session) != nil {
model.revealSentPDF(session)
} else {
model.revealSessionCaptures(session)
}
} label: {
HStack(spacing: 6) {
Text(DubaiTime.shortStamp(session.createdAt))
.font(.caption)
.monospacedDigit()
.foregroundStyle(.secondary)
Text(SessionDisplay.label(for: session))
.font(.caption)
.lineLimit(1)
.truncationMode(.tail)
Spacer(minLength: 6)
Text(session.pdfFileName == nil ? "Not sent" : "Sent")
Spacer(minLength: 4)
Menu {
Button("Settings…") {
(model as? SettingsWindowPresenting)?.presentSettingsWindow()
}
.keyboardShortcut(",", modifiers: .command)
Button(model.isCheckingForUpdates ? "Checking for Updates…" : "Check for Updates…") {
model.checkForUpdates()
}
.disabled(model.isCheckingForUpdates)
if let update = model.updateAvailable {
Button("Update to \(update.version)") { model.installUpdate() }
}
if let previous = model.previousVersion {
Button("Revert to \(previous)") { model.revertToPreviousVersion() }
}
Divider()
Button("Quit Redline") { NSApp.terminate(nil) }
.keyboardShortcut("q", modifiers: .command)
} label: {
Image(systemName: "ellipsis.circle")
}
.menuStyle(.borderlessButton)
.menuIndicator(.hidden)
.fixedSize()
.help("More Redline actions")
.accessibilityLabel("More")
}
.overlay(alignment: .topTrailing) {
EmptyView()
}
}
private var sendChannel: String {
model.transport == .oneDrive ? "Saves to OneDrive" : "Sends via AirDrop"
}
// MARK: - Not granted
private var permissionBlock: some View {
HStack(alignment: .top, spacing: 6) {
Image(systemName: "exclamationmark.triangle")
.foregroundStyle(.yellow)
VStack(alignment: .leading, spacing: 6) {
Text(
ShotdeckError.screenRecordingNotGranted.errorDescription
?? "Screen Recording is turned off."
)
.font(.caption)
.foregroundStyle(session.pdfFileName == nil ? .secondary : .primary)
.fixedSize(horizontal: false, vertical: true)
Button("Open Screen Recording settings") {
model.openScreenRecordingSettings()
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.vertical, 2)
.contentShape(Rectangle())
.background(hovering ? AnyShapeStyle(.quaternary) : AnyShapeStyle(.clear))
}
.buttonStyle(.plain)
.onHover { hovering = $0 }
.help(helpText)
}
private var helpText: String {
let pages = "\(session.captures.count) page\(session.captures.count == 1 ? "" : "s")"
let context = session.context.summaryLine
let detail = context.isEmpty ? pages : "\(pages) · \(context)"
if let name = session.pdfFileName {
return "\(detail)\nSent as \(name)"
}
return "\(detail)\nNever sent — opens the captures"
}
}
/// Readable labels for sessions, shared by the panel and the Past sessions window.
///
/// The label is what the user typed plus the session's short id — never the
/// upper-cased file-name slug, which is for filesystems, not people.
enum SessionDisplay {
static func label(for session: CaptureSession) -> String {
let lane = session.context.lane
return lane.isEmpty ? session.shortID : lane
private func presentWindow(focusLane: Bool) {
guard let presenter = model as? SessionsWindowPresenting else {
model.setStatus("The Redline window is not available in this build.")
return
}
static func fullLabel(for session: CaptureSession) -> String {
let lane = session.context.lane
return lane.isEmpty ? session.shortID : "\(lane) · \(session.shortID)"
presenter.presentSessionsWindow(focusLane: focusLane)
}
}
File diff suppressed because it is too large Load Diff
+50 -16
View File
@@ -76,24 +76,31 @@ enum PanelSnapshot {
// 06 — SettingsView against the same isolated model.
try render(
SettingsView().environment(model),
to: directory.appendingPathComponent("panel-06-settings.png")
to: directory.appendingPathComponent("panel-06-settings.png"),
width: 460,
height: 560
)
// 06b — Past submissions window against the same isolated model: the two
// seeded past sessions plus the live session's three captures from panel 04.
// 06b — the sessions window: real sidebar, pages grid and inspector.
model.setPastSessions(try await model.spool.archivedSessions())
try render(
PastSubmissionsView().environment(model),
to: directory.appendingPathComponent("panel-06b-past-submissions.png"),
width: 480
SessionsWindowView().environment(model),
to: directory.appendingPathComponent("panel-06b-sessions-window.png"),
width: 1100,
height: 700
)
// 15 — the session details editor open, on the same real model: lane, deployed
// build, commit, reviewer and note are the values panel 04's session carries.
// 15 — the window with a kept past session selected (read-only inspector).
if let kept = model.pastSessions.first {
model.selectSession(kept.id)
try render(
MenuBarView(showsContextEditor: true).environment(model),
to: directory.appendingPathComponent("panel-15-session-details.png")
SessionsWindowView().environment(model),
to: directory.appendingPathComponent("panel-15-past-session.png"),
width: 1100,
height: 700
)
model.selectSession(model.session.id)
}
// A real PDF built by the production composer, so the reference footer and the
// document info can be inspected (and opened) rather than assumed.
@@ -153,7 +160,9 @@ enum PanelSnapshot {
model.setResolvedOneDriveFolder(resolvedFolder)
try render(
SettingsView().environment(model),
to: directory.appendingPathComponent("panel-07-settings-onedrive.png")
to: directory.appendingPathComponent("panel-07-settings-onedrive.png"),
width: 460,
height: 560
)
// 08 — no OneDrive folder found: a fake home with NO Library/CloudStorage at
@@ -172,7 +181,9 @@ enum PanelSnapshot {
model.setResolvedOneDriveFolder(nil)
try render(
SettingsView().environment(model),
to: directory.appendingPathComponent("panel-08-settings-onedrive-missing.png")
to: directory.appendingPathComponent("panel-08-settings-onedrive-missing.png"),
width: 460,
height: 560
)
// 09 — menu bar panel, 3 captures present, OneDrive mode ("Send to OneDrive").
@@ -278,10 +289,24 @@ enum PanelSnapshot {
}
@MainActor
private static func render(_ view: some View, to url: URL, width: CGFloat = panelWidth) throws {
let wrapped = view
private static func render(
_ view: some View,
to url: URL,
width: CGFloat = panelWidth,
height: CGFloat? = nil
) throws {
// A fixed-size render (a whole window) must fill its frame; a popover render
// sizes to its content. fixedSize on a split view collapses its columns.
let wrapped = Group {
if let height {
view.frame(width: width, height: height)
} else {
view
.frame(width: width, alignment: .topLeading)
.fixedSize(horizontal: false, vertical: true)
}
}
.frame(width: width, height: height, alignment: .topLeading)
.background(Color(nsColor: .windowBackgroundColor))
let hosting = NSHostingView(rootView: wrapped)
@@ -289,7 +314,7 @@ enum PanelSnapshot {
hosting.appearance = NSAppearance(named: .aqua)
let window = NSWindow(
contentRect: NSRect(x: -10_000, y: -10_000, width: panelWidth, height: 64),
contentRect: NSRect(x: -10_000, y: -10_000, width: width, height: 200),
styleMask: [.borderless],
backing: .buffered,
defer: false
@@ -304,17 +329,26 @@ enum PanelSnapshot {
hosting.layoutSubtreeIfNeeded()
var size = hosting.fittingSize
if let height {
size.height = height
} else {
if size.height < 1 {
size.height = hosting.intrinsicContentSize.height
}
if size.height < 1 { size.height = 240 }
}
size.width = width
size.height = ceil(size.height)
hosting.setFrameSize(size)
window.setContentSize(size)
hosting.layoutSubtreeIfNeeded()
RunLoop.current.run(until: Date(timeIntervalSinceNow: 0.05))
// A split view (sidebar + inspector) needs a real display cycle before its
// columns and list rows exist; a single layout pass renders blank columns.
window.displayIfNeeded()
RunLoop.current.run(until: Date(timeIntervalSinceNow: 0.35))
hosting.layoutSubtreeIfNeeded()
window.displayIfNeeded()
let bounds = hosting.bounds
guard let rep = hosting.bitmapImageRepForCachingDisplay(in: bounds) else {
-260
View File
@@ -1,260 +0,0 @@
import AppKit
import SwiftUI
import ShotdeckCore
/// "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 {
emptyState
} else {
searchField
sessionList
}
Divider()
footer
}
.padding(12)
.frame(width: 460, alignment: .leading)
.controlSize(.small)
.task {
if let problem = await model.reloadFromSpool() {
model.setStatus(problem)
}
}
}
// MARK: - Current session
private var currentSessionRow: some View {
HStack(alignment: .top, spacing: 8) {
VStack(alignment: .leading, spacing: 2) {
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)
.fixedSize(horizontal: false, vertical: true)
}
Spacer(minLength: 8)
Button("New session") {
Task { await model.startNewSession() }
}
.disabled(!model.canStartNewSession)
.help("Keeps these captures as a past session and starts a fresh one. Nothing is deleted.")
}
}
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 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("Sessions folder") {
model.openSessionsFolder()
}
.help("Open the folder that holds every kept session")
}
}
}
private struct PastSessionRow: View {
@Environment(AppModel.self) private var model
let session: CaptureSession
var body: some View {
HStack(alignment: .top, spacing: 10) {
VStack(alignment: .leading, spacing: 2) {
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)
}
Spacer(minLength: 8)
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")
}
}
.padding(.vertical, 6)
}
/// 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 {
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)"
}
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 {
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 sessions"
window.styleMask = [.titled, .closable]
window.isReleasedWhenClosed = false
window.center()
let controller = NSWindowController(window: window)
Self.submissionsWindowController = controller
controller.showWindow(nil)
NSApp.activate()
}
}
+7 -1
View File
@@ -210,8 +210,9 @@ extension AppModel: SendCapable {
func handleDidShareItems(fileName: String, sentSummary: String) async {
guard !session.isEmpty else { return }
var message = sentSummary
var archivedID: UUID?
do {
_ = try await spool.archiveCurrent(pdfFileName: fileName)
archivedID = try await spool.archiveCurrent(pdfFileName: fileName).id
} catch {
message += " \((error as? ShotdeckError)?.errorDescription ?? "Could not archive the session.")"
}
@@ -222,6 +223,11 @@ extension AppModel: SendCapable {
if let refreshProblem = await reloadFromSpool() {
message += " \(refreshProblem)"
}
// Leave the window on the session that was just sent: that is what the person
// is looking at when the PDF leaves.
if let archivedID {
selectSession(archivedID)
}
setStatus(message)
}
+16 -3
View File
@@ -2,22 +2,35 @@ import AppKit
import SwiftUI
import ShotdeckCore
/// The popover's page strip: at most `limit` thumbnails plus a "+N" tile, so the
/// popover never turns into a filmstrip of the whole session.
struct SessionStrip: View {
@Environment(AppModel.self) private var model
var limit: Int? = nil
var body: some View {
let captures = Array(model.session.captures.prefix(limit ?? model.session.captures.count))
let hidden = model.session.captures.count - captures.count
if model.session.captures.isEmpty {
Text("Nothing captured yet.")
.font(.caption)
.foregroundStyle(.secondary)
.frame(maxWidth: .infinity, minHeight: 64, alignment: .leading)
} else {
ScrollView(.horizontal, showsIndicators: false) {
HStack(alignment: .top, spacing: 6) {
ForEach(model.session.captures) { capture in
ForEach(captures) { capture in
SessionThumb(capture: capture)
}
if hidden > 0 {
Text("+\(hidden)")
.font(.system(size: 11, weight: .semibold))
.foregroundStyle(.secondary)
.frame(width: 52, height: 64)
.background(.quaternary.opacity(0.5), in: RoundedRectangle(cornerRadius: 4, style: .continuous))
.help("\(hidden) more page\(hidden == 1 ? "" : "s") — open Redline to see them")
}
Spacer(minLength: 0)
}
.frame(height: 64)
}
@@ -63,7 +76,7 @@ private struct SessionThumb: View {
@ViewBuilder
private var thumbnail: some View {
let url = model.paths.sessionDirectory(model.session.id).appendingPathComponent(capture.fileName)
let url = model.imageURL(for: capture, in: model.session)
if let image = NSImage(contentsOf: url) {
Image(nsImage: image)
.resizable()
+689
View File
@@ -0,0 +1,689 @@
import AppKit
import SwiftUI
import ShotdeckCore
/// The Redline window: every session on the left, the selected session's pages in the
/// middle, and that session's review details / PDF / session facts on the right.
/// This is where history, text entry and file facts live; the popover only glances at
/// the current session and fires the two main actions.
struct SessionsWindowView: View {
@Environment(AppModel.self) private var model
@State private var searchText = ""
@State private var selectedCaptureID: UUID?
@State private var showInspector = true
var body: some View {
// Three explicit columns rather than NavigationSplitView: the window has a
// fixed, always-visible inspector, and a plain split keeps the sidebar rows and
// the inspector rendering deterministically in every window state.
HStack(spacing: 0) {
sidebar
.frame(width: 230)
Divider()
detail
.frame(maxWidth: .infinity, maxHeight: .infinity)
if showInspector {
Divider()
SessionInspector(session: selectedSession)
.frame(width: 300)
}
}
.frame(minWidth: 900, minHeight: 560)
.controlSize(.regular)
.background(Color(nsColor: .windowBackgroundColor))
.onChange(of: model.selectedSessionID) { _, _ in
selectedCaptureID = nil
}
}
private var selectedSession: CaptureSession {
model.selectedSession ?? model.session
}
// MARK: - Sidebar
private var sidebar: some View {
VStack(spacing: 0) {
HStack(spacing: 6) {
Image(systemName: "magnifyingglass")
.foregroundStyle(.secondary)
TextField("Search sessions", text: $searchText)
.textFieldStyle(.plain)
if !searchText.isEmpty {
Button {
searchText = ""
} label: {
Image(systemName: "xmark.circle.fill")
.foregroundStyle(.secondary)
}
.buttonStyle(.plain)
.accessibilityLabel("Clear search")
}
}
.padding(.horizontal, 8)
.padding(.vertical, 5)
.background(.quaternary.opacity(0.5), in: RoundedRectangle(cornerRadius: 6, style: .continuous))
.padding(8)
List(selection: selection) {
ForEach(sections) { section in
Section(section.title) {
ForEach(section.sessions) { session in
SessionRow(session: session)
.tag(session.id)
}
}
}
}
.listStyle(.sidebar)
if sections.isEmpty {
Text(searchText.isEmpty ? "No sessions yet." : "No session matches “\(searchText)”.")
.font(.caption)
.foregroundStyle(.secondary)
.multilineTextAlignment(.center)
.padding(12)
}
}
.background(Color(nsColor: .controlBackgroundColor))
}
private var sections: [AppModel.SessionGroup] {
model.groupedSections(for: model.sessions(matching: searchText))
}
private var selection: Binding<UUID?> {
Binding(
get: { model.selectedSession?.id },
set: { model.selectSession($0) }
)
}
// MARK: - Detail
private var detail: some View {
VStack(alignment: .leading, spacing: 0) {
header
Divider()
if let document = model.returnedDocument(for: selectedSession), document.isCommented {
ReturnedBanner(document: document, session: selectedSession)
Divider()
}
pages
}
.background(Color(nsColor: .textBackgroundColor))
}
private var header: some View {
HStack(alignment: .center, spacing: 10) {
VStack(alignment: .leading, spacing: 1) {
HStack(spacing: 6) {
Text(laneTitle)
.font(.system(size: 15, weight: .semibold))
.lineLimit(1)
.truncationMode(.tail)
if model.selectedIsCurrent {
Text("Current")
.font(.system(size: 9, weight: .semibold))
.padding(.horizontal, 5)
.padding(.vertical, 1)
.background(.quaternary, in: Capsule())
}
}
Text(subtitle)
.font(.caption)
.foregroundStyle(.secondary)
.lineLimit(1)
}
.layoutPriority(0)
Spacer(minLength: 12)
Button {
showInspector.toggle()
} label: {
Image(systemName: "sidebar.right")
}
.buttonStyle(.borderless)
.help(showInspector ? "Hide the inspector" : "Show the inspector")
.accessibilityLabel(showInspector ? "Hide the inspector" : "Show the inspector")
Button {
Task { await model.startNewSession() }
} label: {
Label("New Session", systemImage: "plus.square.on.square")
}
.keyboardShortcut("n", modifiers: .command)
.disabled(!model.canStartNewSession)
.fixedSize()
.help("Keep this session and start a fresh one (⌘N)")
Button {
Task { await model.captureNow() }
} label: {
Label(model.isCapturing ? "Capturing…" : "Capture", systemImage: "viewfinder")
}
.disabled(model.isCapturing || !model.selectedIsCurrent)
.fixedSize()
Button {
guard let sender = model as? SendCapable else { return }
let anchor = NSApp.keyWindow?.contentView
Task { await sender.send(anchor: anchor) }
} label: {
Label(sendTitle, systemImage: "paperplane.fill")
}
.buttonStyle(.borderedProminent)
.layoutPriority(1)
.keyboardShortcut("s", modifiers: .command)
.disabled(!model.selectedIsCurrent || model.session.isEmpty || model.isSending)
.help(model.transport == .oneDrive
? "Save the PDF to the OneDrive folder (⌘S)"
: "AirDrop the PDF (⌘S)")
}
.padding(.horizontal, 16)
.padding(.vertical, 10)
}
private var laneTitle: String {
let lane = selectedSession.context.lane
if !lane.isEmpty { return lane }
return selectedSession.id == model.session.id ? "Current session" : selectedSession.shortID
}
private var subtitle: String {
let pages = selectedSession.captures.count
let pageWord = "\(pages) page\(pages == 1 ? "" : "s")"
return "\(pageWord) · \(model.state(of: selectedSession).label)"
}
private var sendTitle: String {
model.transport == .oneDrive ? "Save…" : "Send…"
}
// MARK: - Pages
@ViewBuilder
private var pages: some View {
if selectedSession.isEmpty {
emptyState
} else {
ScrollView {
VStack(alignment: .leading, spacing: 12) {
HStack(alignment: .firstTextBaseline, spacing: 8) {
Text("Pages")
.font(.headline)
Text(pagesCaption)
.font(.caption)
.foregroundStyle(.secondary)
Spacer(minLength: 8)
Button("Remove Page") {
removeSelectedPage()
}
.disabled(!model.selectedIsCurrent || selectedCaptureID == nil)
}
LazyVGrid(
columns: [GridItem(.adaptive(minimum: 200, maximum: 240), spacing: 16)],
alignment: .leading,
spacing: 18
) {
ForEach(selectedSession.captures) { capture in
PageCard(
capture: capture,
session: selectedSession,
isSelected: selectedCaptureID == capture.id,
canRemove: model.selectedIsCurrent
) {
selectedCaptureID = capture.id
}
}
}
}
.padding(16)
}
.onDeleteCommand { removeSelectedPage() }
}
}
private var pagesCaption: String {
model.selectedIsCurrent
? "In PDF order · Delete removes the selected page"
: "In the order they were sent"
}
private var emptyState: some View {
VStack(spacing: 10) {
Image(systemName: "viewfinder")
.font(.system(size: 28, weight: .light))
.foregroundStyle(.secondary)
Text("No pages in this session")
.font(.headline)
Text(emptyStateDetail)
.font(.caption)
.foregroundStyle(.secondary)
.multilineTextAlignment(.center)
.frame(maxWidth: 320)
HStack(spacing: 8) {
Button("Choose Area…") {
Task { await model.rePickRegion() }
}
Button("Capture \(model.hotkeyDisplayString)") {
Task { await model.captureNow() }
}
.buttonStyle(.borderedProminent)
}
.padding(.top, 4)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.padding(24)
}
private var emptyStateDetail: String {
if model.region == nil {
return "Choose the part of the screen you review, then capture it. Each capture becomes one page of the PDF."
}
return "Press \(model.hotkeyDisplayString) to capture the saved area. Each capture becomes one page of the PDF."
}
private func removeSelectedPage() {
guard model.selectedIsCurrent, let id = selectedCaptureID else { return }
selectedCaptureID = nil
Task { await model.removeCapture(id: id) }
}
}
// MARK: - Sidebar row
private struct SessionRow: View {
@Environment(AppModel.self) private var model
let session: CaptureSession
var body: some View {
let state = model.state(of: session)
VStack(alignment: .leading, spacing: 1) {
HStack(spacing: 5) {
Text(lane)
.lineLimit(1)
if state == .current {
Text("Current")
.font(.system(size: 9, weight: .semibold))
.padding(.horizontal, 5)
.padding(.vertical, 1)
.background(.quaternary, in: Capsule())
}
Spacer(minLength: 4)
Text(DubaiTime.checkTime(session.createdAt))
.font(.caption)
.foregroundStyle(.secondary)
.monospacedDigit()
}
Text(detail(state))
.font(.caption)
.foregroundStyle(state.isReturned ? AnyShapeStyle(.orange) : AnyShapeStyle(.secondary))
.lineLimit(1)
}
.padding(.vertical, 2)
.accessibilityElement(children: .combine)
.accessibilityLabel("\(lane), \(DubaiTime.checkTime(session.createdAt)), \(session.captures.count) pages, \(state.label)")
}
private var lane: String {
let lane = session.context.lane
return lane.isEmpty ? session.shortID : lane
}
private func detail(_ state: AppModel.SessionDisplayState) -> String {
let pages = "\(session.captures.count) page\(session.captures.count == 1 ? "" : "s")"
if case .returned(let marked) = state {
return "\(pages) · came back with \(marked) page\(marked == 1 ? "" : "s") marked"
}
return "\(pages) · \(state.label)"
}
}
// MARK: - Page card
private struct PageCard: View {
@Environment(AppModel.self) private var model
let capture: Capture
let session: CaptureSession
let isSelected: Bool
let canRemove: Bool
let select: () -> Void
@State private var hovering = false
var body: some View {
VStack(alignment: .leading, spacing: 5) {
ZStack(alignment: .topLeading) {
thumbnail
if hovering && canRemove {
Button("Remove") {
Task { await model.removeCapture(id: capture.id) }
}
.font(.caption2.weight(.semibold))
.buttonStyle(.plain)
.foregroundStyle(.white)
.padding(.horizontal, 6)
.padding(.vertical, 2)
.background(.black.opacity(0.65), in: Capsule())
.padding(6)
}
}
.overlay {
RoundedRectangle(cornerRadius: 5, style: .continuous)
.strokeBorder(isSelected ? Color.accentColor : .clear, lineWidth: 2)
}
.frame(maxWidth: 240, alignment: .leading)
.onHover { hovering = $0 }
.onTapGesture(perform: select)
HStack(spacing: 6) {
Text("Page \(capture.sequence)")
.font(.caption.weight(isSelected ? .semibold : .regular))
Spacer(minLength: 4)
Text(DubaiTime.checkTime(capture.capturedAt))
.font(.caption)
.foregroundStyle(.secondary)
.monospacedDigit()
}
}
}
@ViewBuilder
private var thumbnail: some View {
let url = model.imageURL(for: capture, in: session)
if let image = NSImage(contentsOf: url) {
Image(nsImage: image)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(maxWidth: .infinity)
.clipShape(RoundedRectangle(cornerRadius: 4, style: .continuous))
.overlay {
RoundedRectangle(cornerRadius: 4, style: .continuous)
.strokeBorder(.quaternary, lineWidth: 0.5)
}
} else {
RoundedRectangle(cornerRadius: 4, style: .continuous)
.fill(.quaternary)
.frame(height: 96)
.overlay {
Text("Image missing")
.font(.caption2)
.foregroundStyle(.secondary)
}
}
}
}
// MARK: - Returned banner
private struct ReturnedBanner: View {
@Environment(AppModel.self) private var model
let document: ReturnedDocument
let session: CaptureSession
var body: some View {
HStack(spacing: 8) {
Image(systemName: "pencil.and.outline")
.foregroundStyle(.orange)
Text(message)
.font(.callout)
Spacer(minLength: 8)
Button("Open PDF") {
NSWorkspace.shared.open(document.fileURL)
}
if model.sentPDFURL(for: session) != nil {
Button("Show Original") {
model.revealSentPDF(session)
}
}
}
.padding(.horizontal, 16)
.padding(.vertical, 8)
.background(.orange.opacity(0.1))
}
private var message: String {
let marked = document.annotatedPages.count
return "Came back with marks on \(marked) page\(marked == 1 ? "" : "s")."
}
}
// MARK: - Inspector
private struct SessionInspector: View {
@Environment(AppModel.self) private var model
let session: CaptureSession
var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: 16) {
reviewDetails
if !model.selectedIsCurrent {
Text("Past sessions are read-only: the PDF already carries these values.")
.font(.caption)
.foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
}
pdfFacts
sessionFacts
}
.padding(14)
}
.background(Color(nsColor: .windowBackgroundColor))
}
private var reviewDetails: some View {
VStack(alignment: .leading, spacing: 6) {
Text("Review details")
.font(.headline)
GroupBox {
VStack(spacing: 0) {
contextRow("Lane", prompt: "dev03, customer test lane…", \.lane, focusOnRequest: true)
RowDivider()
contextRow("Deployed", prompt: "build that is live", \.deployedVersion)
RowDivider()
contextRow("Commit", prompt: "git SHA", \.commit)
RowDivider()
contextRow("Reviewer", prompt: "who is reviewing", \.reviewer)
RowDivider()
contextRow("Note", prompt: "what this session covers", \.note)
}
}
Text("Printed on every page of the PDF. A new session starts with these values.")
.font(.caption)
.foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
}
}
@ViewBuilder
private func contextRow(
_ label: String,
prompt: String,
_ field: WritableKeyPath<ReviewContext, String>,
focusOnRequest: Bool = false
) -> some View {
if model.selectedIsCurrent {
EditableContextRow(label: label, prompt: prompt, field: field, focusOnRequest: focusOnRequest)
} else {
HStack(alignment: .firstTextBaseline, spacing: 8) {
Text(label)
.foregroundStyle(.secondary)
.frame(width: 74, alignment: .leading)
Text(displayValue(field))
.frame(maxWidth: .infinity, alignment: .leading)
.textSelection(.enabled)
}
.padding(.vertical, 5)
}
}
private func displayValue(_ field: KeyPath<ReviewContext, String>) -> String {
let value = session.context[keyPath: field]
return value.isEmpty ? "—" : value
}
private var pdfFacts: some View {
VStack(alignment: .leading, spacing: 6) {
Text("PDF")
.font(.headline)
GroupBox {
VStack(spacing: 0) {
FactRow(label: "File name", value: pdfFileName, selectable: true)
RowDivider()
FactRow(label: "Pages", value: "\(session.captures.count)")
RowDivider()
FactRow(
label: "Sends via",
value: model.transport == .oneDrive ? "OneDrive folder" : "AirDrop")
RowDivider()
FactRow(label: "Status", value: model.state(of: session).label)
}
}
}
}
private var pdfFileName: String {
if let name = session.pdfFileName { return name }
return model.selectedIsCurrent ? model.nextPDFFileNameHint : "—"
}
private var sessionFacts: some View {
VStack(alignment: .leading, spacing: 6) {
Text("Session")
.font(.headline)
GroupBox {
VStack(spacing: 0) {
FactRow(label: "Started", value: DubaiTime.stamp(session.createdAt))
RowDivider()
FactRow(label: "ID", value: session.shortID, monospaced: true)
RowDivider()
HStack {
Text("Files")
.foregroundStyle(.secondary)
Spacer(minLength: 8)
Button(model.selectedIsCurrent ? "Show Captures" : "Show in Finder") {
model.revealSessionCaptures(session)
}
.buttonStyle(.link)
}
.padding(.vertical, 5)
}
}
}
}
}
private struct RowDivider: View {
var body: some View {
Divider().padding(.leading, 0)
}
}
/// One editable review-detail row. The text lives in local state while typing and is
/// written through to the open session's manifest; it re-seeds whenever the session's
/// stored details change underneath it (a new session inheriting them, for example).
private struct EditableContextRow: View {
@Environment(AppModel.self) private var model
let label: String
let prompt: String
let field: WritableKeyPath<ReviewContext, String>
let focusOnRequest: Bool
@State private var text: String = ""
@State private var lastSynced: String = ""
@FocusState private var focused: Bool
var body: some View {
HStack(spacing: 8) {
Text(label)
.foregroundStyle(.secondary)
.frame(width: 74, alignment: .leading)
TextField(prompt, text: $text)
.textFieldStyle(.roundedBorder)
.controlSize(.small)
.focused($focused)
.accessibilityLabel(label)
.onSubmit { push() }
.onChange(of: text) { _, _ in push() }
}
.padding(.vertical, 5)
.onAppear { seed(from: stored) }
.onChange(of: model.session.context) { _, newValue in
let incoming = newValue[keyPath: field]
guard incoming != lastSynced else { return }
seed(from: incoming)
}
.onChange(of: model.session.id) { _, _ in
seed(from: stored)
}
.onChange(of: model.laneFocusRequest) { _, _ in
if focusOnRequest { focused = true }
}
}
private var stored: String {
model.session.context[keyPath: field]
}
private func seed(from value: String) {
text = value
lastSynced = value
}
private func push() {
guard text != lastSynced else { return }
lastSynced = text
model.updateContext(field, text)
}
}
private struct FactRow: View {
let label: String
let value: String
var monospaced: Bool = false
var selectable: Bool = false
var body: some View {
HStack(alignment: .firstTextBaseline, spacing: 8) {
Text(label)
.foregroundStyle(.secondary)
Spacer(minLength: 8)
Text(value)
.font(monospaced ? .system(.body, design: .monospaced) : .body)
.lineLimit(1)
.truncationMode(.middle)
.textSelection(.enabled)
.help(value)
}
.padding(.vertical, 5)
}
}
// MARK: - Window presentation
extension AppModel: SessionsWindowPresenting {
private static var sessionsWindowController: NSWindowController?
public func presentSessionsWindow(focusLane: Bool) {
if focusLane { requestLaneFocus() }
if let existing = Self.sessionsWindowController {
existing.window?.makeKeyAndOrderFront(nil)
NSApp.activate()
return
}
let hosting = NSHostingController(rootView: SessionsWindowView().environment(self))
let window = NSWindow(contentViewController: hosting)
window.title = "Redline"
window.styleMask = [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView]
window.titlebarAppearsTransparent = false
window.isReleasedWhenClosed = false
window.setContentSize(NSSize(width: 1240, height: 760))
window.minSize = NSSize(width: 1000, height: 600)
window.center()
window.setFrameAutosaveName("RedlineSessionsWindow")
let controller = NSWindowController(window: window)
Self.sessionsWindowController = controller
controller.showWindow(nil)
NSApp.activate()
}
}
+100 -145
View File
@@ -2,163 +2,156 @@ import AppKit
import SwiftUI
import ShotdeckCore
/// Settings: three labelled groups, every row "what it is" on the left and the control
/// on the right. Nothing here is needed while reviewing, which is why it is its own
/// window and not part of the session surfaces.
struct SettingsView: View {
@Environment(AppModel.self) private var model
@State private var isRecordingHotkey = false
@State private var recorder = HotkeyRecorderBox()
private let labelWidth: CGFloat = 104
var body: some View {
Grid(alignment: .leading, horizontalSpacing: 12, verticalSpacing: 10) {
GridRow {
Text("Hotkey")
.font(.headline)
.frame(maxWidth: .infinity, alignment: .leading)
.gridCellColumns(2)
}
GridRow(alignment: .center) {
fieldLabel("Capture")
HStack(spacing: 8) {
Form {
Section("Capture") {
LabeledContent("Capture shortcut") {
Button {
armHotkeyRecorder()
} label: {
Text(isRecordingHotkey ? "Press keys…" : model.hotkeyDisplayString)
.foregroundStyle(isRecordingHotkey ? .secondary : .primary)
.lineLimit(1)
.frame(minWidth: 54)
}
Spacer(minLength: 0)
}
.frame(minHeight: 22)
}
GridRow {
Text("Send via")
.font(.headline)
.frame(maxWidth: .infinity, alignment: .leading)
.gridCellColumns(2)
.padding(.top, 6)
LabeledContent("Area") {
HStack(spacing: 8) {
Text(areaSummary)
.foregroundStyle(.secondary)
Button("Choose…") {
Task { await model.rePickRegion() }
}
}
}
}
GridRow {
Picker("Send via", selection: transportBinding) {
Section("Sending") {
LabeledContent("Send with") {
Picker("Send with", selection: transportBinding) {
ForEach(SendTransport.allCases, id: \.self) { transport in
Text(transport.displayName).tag(transport)
}
}
.labelsHidden()
.pickerStyle(.segmented)
.gridCellColumns(2)
}
GridRow {
Text("Folders")
.font(.headline)
.frame(maxWidth: .infinity, alignment: .leading)
.gridCellColumns(2)
.padding(.top, 6)
.frame(maxWidth: 220)
}
if model.transport == .airDrop {
GridRow(alignment: .center) {
fieldLabel("Watch folder")
folderValue(path: model.watchFolderURL.path) {
model.chooseWatchFolder()
}
}
GridRow(alignment: .center) {
fieldLabel("Output folder")
folderValue(path: model.outboxURL.path) {
model.chooseOutboxFolder()
LabeledContent("Save PDFs to") {
folderRow(path: model.outboxURL.path) { model.chooseOutboxFolder() }
}
LabeledContent("Watch for returns in") {
folderRow(path: model.watchFolderURL.path) { model.chooseWatchFolder() }
}
} else {
GridRow(alignment: .center) {
fieldLabel("OneDrive folder")
if let folder = model.resolvedOneDriveFolder {
folderValue(path: folder.path) {
model.chooseOneDriveFolder()
LabeledContent("OneDrive folder") {
folderRow(path: oneDrivePath) { model.chooseOneDriveFolder() }
}
} else {
// One-line row, same shape as the normal path row: "Not found"
// where the path would be, Choose… stays live. The explanation
// moves to the caption below instead of wrapping this row.
folderValue(path: "Not found") {
model.chooseOneDriveFolder()
}
}
}
GridRow {
Text(
model.resolvedOneDriveFolder != nil
? "The PDF is saved here and this same folder is watched for the marked-up copy. On the iPad open it from Files > OneDrive."
: "No OneDrive folder found. Sign in to OneDrive, or choose a folder."
)
.font(.caption)
.foregroundStyle(.secondary)
.foregroundStyle(model.resolvedOneDriveFolder != nil ? .secondary : .primary)
.fixedSize(horizontal: false, vertical: true)
.gridCellColumns(2)
}
}
GridRow {
Text("Sessions")
.font(.headline)
.frame(maxWidth: .infinity, alignment: .leading)
.gridCellColumns(2)
.padding(.top, 6)
}
GridRow(alignment: .center) {
fieldLabel("Delete after")
Picker("Delete after", selection: retentionBinding) {
Section("Sessions") {
LabeledContent("Delete sessions older than") {
Picker("Delete sessions older than", selection: retentionBinding) {
ForEach(SessionRetention.presets, id: \.self) { preset in
Text(preset.displayName).tag(preset)
}
}
.labelsHidden()
.pickerStyle(.menu)
.frame(maxWidth: .infinity, alignment: .leading)
.frame(maxWidth: 150)
}
LabeledContent(keptSummary) {
Button("Clean Up Now…") {
Task { await model.cleanUpExpiredSessions() }
}
.disabled(model.retention == .never || model.expiredSessionCount == 0)
}
GridRow {
Text(retentionDetail)
.font(.caption)
.foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
.gridCellColumns(2)
}
GridRow {
HStack(spacing: 8) {
Button("Clean up now") {
Task { await model.cleanUpExpiredSessions() }
}
.disabled(model.retention == .never)
Spacer(minLength: 0)
Button("Sessions folder") { model.openSessionsFolder() }
}
.gridCellColumns(2)
.frame(maxWidth: .infinity, alignment: .leading)
}
GridRow {
Text("Only Redline's saved screenshots are removed. Sent PDFs are never touched.")
Text("Deleting removes Redline's own screenshots only. PDFs you sent stay where they are.")
.font(.caption)
.foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
.gridCellColumns(2)
}
}
.padding(16)
.frame(minWidth: 320, idealWidth: 360, maxWidth: 360, alignment: .leading)
.controlSize(.small)
.formStyle(.grouped)
.frame(width: 460, height: 520)
.controlSize(.regular)
.onDisappear { disarmHotkeyRecorder() }
}
// MARK: - Rows
private var areaSummary: String {
guard let region = model.region else { return "Not chosen" }
return "\(Int(region.rect.width)) × \(Int(region.rect.height))"
}
private var oneDrivePath: String {
model.resolvedOneDriveFolder?.path ?? "Not found"
}
private var keptSummary: String {
let count = model.pastSessions.count + 1
return "\(count) session\(count == 1 ? "" : "s") kept"
}
private func folderRow(path: String, choose: @escaping () -> Void) -> some View {
HStack(spacing: 8) {
Text(abbreviateHome(path))
.lineLimit(1)
.truncationMode(.middle)
.foregroundStyle(.secondary)
.frame(maxWidth: 150, alignment: .trailing)
.help(path)
Button("Choose…") { choose() }
}
}
private func abbreviateHome(_ path: String) -> String {
let home = FileManager.default.homeDirectoryForCurrentUser.path
guard path.hasPrefix(home) else { return path }
return "~" + path.dropFirst(home.count)
}
// MARK: - Detail text
private var retentionDetail: String {
guard model.retention != .never else {
return "All sessions are kept. Nothing is deleted automatically."
}
let count = model.expiredSessionCount
if count == 0 {
return "No kept session is older than \(model.retention.displayName) yet."
}
return "\(count) session\(count == 1 ? " is" : "s are") already older than \(model.retention.displayName) and will be removed on the next launch or cleanup."
}
// MARK: - Bindings
private var transportBinding: Binding<SendTransport> {
Binding(get: { model.transport }, set: { model.chooseTransport($0) })
}
@@ -169,18 +162,7 @@ struct SettingsView: View {
})
}
/// States what the chosen limit does right now, using the real count of sessions
/// that have already expired — never a guess.
private var retentionDetail: String {
guard model.retention != .never else {
return "All sessions are kept. Nothing is deleted automatically."
}
let count = model.expiredSessionCount
if count == 0 {
return "No kept session is older than \(model.retention.displayName) yet."
}
return "\(count) session\(count == 1 ? " is" : "s are") already older than \(model.retention.displayName) and will be removed on the next launch or cleanup."
}
// MARK: - Hotkey recorder
private func armHotkeyRecorder() {
guard !isRecordingHotkey else { return }
@@ -209,26 +191,6 @@ struct SettingsView: View {
recorder.onKey = nil
isRecordingHotkey = false
}
private func fieldLabel(_ title: String) -> some View {
Text(title)
.lineLimit(1)
.frame(width: labelWidth, alignment: .trailing)
.gridColumnAlignment(.trailing)
.frame(minHeight: 22, alignment: .trailing)
}
private func folderValue(path: String, choose: @escaping () -> Void) -> some View {
HStack(spacing: 8) {
Text(path)
.lineLimit(1)
.truncationMode(.middle)
.foregroundStyle(.secondary)
.frame(maxWidth: .infinity, alignment: .leading)
Button("Choose…") { choose() }
}
.frame(minHeight: 22)
}
}
/// Local keyDown monitor for the Settings capture-hotkey recorder. Callbacks hop onto the
@@ -274,6 +236,7 @@ extension AppModel: SettingsWindowPresenting {
window.title = "Redline Settings"
window.styleMask = [.titled, .closable]
window.isReleasedWhenClosed = false
window.setContentSize(NSSize(width: 460, height: 520))
window.center()
let controller = NSWindowController(window: window)
Self.settingsWindowController = controller
@@ -285,7 +248,7 @@ extension AppModel: SettingsWindowPresenting {
guard let url = chooseDirectory(startingAt: outboxURL) else { return }
FolderSettings.setOutbox(url)
setFolderURLs(outbox: url, watch: watchFolderURL)
setStatus("Output folder set to \(url.lastPathComponent).")
setStatus("PDFs are saved to \(url.lastPathComponent).")
}
func chooseWatchFolder() {
@@ -295,7 +258,7 @@ extension AppModel: SettingsWindowPresenting {
Task {
do {
try await watcher.updateWatchFolder(url)
setStatus("Watch folder set to \(url.lastPathComponent).")
setStatus("Watching \(url.lastPathComponent) for returns.")
} catch {
setStatus(
(error as? ShotdeckError)?.errorDescription ?? "Could not switch the watch folder."
@@ -304,21 +267,13 @@ extension AppModel: SettingsWindowPresenting {
}
}
/// Settings "Send via" picker action. Persists the choice, recomputes the effective
/// Settings "Send with" picker action. Persists the choice, recomputes the effective
/// outbox/watch folder for the new transport, creates the OneDrive folder if it
/// doesn't exist yet, and re-points the running watcher (folder + recordUncommented)
/// at the new state. Switching back to AirDrop restores its own stored overrides
/// untouched, since AirDrop and OneDrive folder settings are stored under separate keys.
/// Refuses while a send is in flight (send() snapshots its own folder/transport, but
/// switching mid-send is still confusing UX — nothing to gain by allowing it).
/// The async reconcile below is generation-guarded: `reconcileGeneration` is bumped
/// synchronously before the Task starts, and the Task checks its own snapshot against
/// the live value before every mutating step, so rapid toggling (this function or
/// chooseOneDriveFolder, in any order) always lets the LAST choice win instead of an
/// earlier, superseded call applying its stale folder/flag after a later one already won.
/// The Task's handle is stored in `pendingReconcileTask` so send() can await its
/// completion before snapshotting transport/folder — closing the OTHER race, where a
/// toggle is immediately followed by Send before this reconcile has settled.
/// at the new state. Refuses while a send is in flight.
/// The async reconcile below is generation-guarded so rapid toggling always lets the
/// LAST choice win; its handle is stored in `pendingReconcileTask` so send() can
/// await it before snapshotting transport/folder.
func chooseTransport(_ value: SendTransport) {
guard !isSending else {
setStatus("Finish the current send first.")
+480
View File
@@ -0,0 +1,480 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Redline UX Rework</title>
<meta name="description" content="From-scratch UX for Redline: a glance-and-act menu-bar popover, one main window for sessions, and a three-section Settings window. Light and dark, 1:1 sizes.">
<style>
/* Page chrome (the board the mockups sit on) */
:root{--page:#e9e7e2;--ink:#1d1d1f;--mut:rgba(0,0,0,.55);--rule:rgba(0,0,0,.1);--acc:#0a64d6}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){--page:#141416;--ink:#ececec;--mut:rgba(255,255,255,.6);--rule:rgba(255,255,255,.12)}}
:root[data-theme="dark"]{--page:#141416;--ink:#ececec;--mut:rgba(255,255,255,.6);--rule:rgba(255,255,255,.12)}
body{margin:0;background:var(--page);color:var(--ink);font:13px/1.4 -apple-system,BlinkMacSystemFont,"SF Pro Text","Helvetica Neue",sans-serif;-webkit-font-smoothing:antialiased}
a{color:var(--acc);text-decoration:none}a:hover{text-decoration:underline}
.mac a{color:var(--accent)}
header.board{padding:32px 40px 8px;max-width:1200px}
header.board h1{margin:0 0 6px;font-size:22px;font-weight:600}
header.board p{margin:0;color:var(--mut);max-width:760px}
section.turn{padding:28px 40px 36px;border-top:1px solid var(--rule)}
.thd{display:flex;align-items:baseline;gap:10px;margin:0 0 18px}
.tid{font:600 10px ui-monospace,Menlo,monospace;padding:3px 7px;background:var(--ink);color:var(--page);text-decoration:none}
.tname{font-weight:600}
.tnote{color:var(--mut);font-size:12px}
.row{display:flex;flex-wrap:wrap;gap:36px;align-items:flex-start}
.opt{display:flex;flex-direction:column;gap:10px;max-width:100%}
.olabel{font-size:12px;color:var(--mut);display:flex;gap:8px;align-items:baseline}
.oid{font:600 10.5px ui-monospace,Menlo,monospace;padding:3px 7px;background:var(--rule);color:var(--ink);text-decoration:none}
.scroller{max-width:100%;overflow-x:auto;padding:2px 2px 18px}
@media (max-width:600px){header.board,section.turn{padding-left:16px;padding-right:16px}}
/* ---------- macOS semantic tokens, per mock theme ---------- */
.mac{--win:#ececec;--content:#ffffff;--side:#e8e8e8;--side2:#dedede;--label:rgba(0,0,0,.88);--label2:rgba(0,0,0,.55);--label3:rgba(0,0,0,.3);
--sep:rgba(0,0,0,.1);--ctl:#ffffff;--ctlBorder:rgba(0,0,0,.16);--ctlShadow:0 .5px 1px rgba(0,0,0,.12);--fill:rgba(0,0,0,.05);--fill2:rgba(0,0,0,.08);
--accent:#0a64d6;--accentText:#ffffff;--selection:#0a64d6;--selText:#fff;--selMuted:rgba(0,0,0,.08);--red:#d70015;--green:#248a3d;--orange:#c45a00;
--pop:rgba(246,246,246,.96);--group:#ffffff;--groupBorder:rgba(0,0,0,.08);--thumbA:#d9ded9;--thumbB:#c9d3e1;--thumbC:#e3d6cc;
--shadow:0 0 0 .5px rgba(0,0,0,.22),0 18px 48px rgba(0,0,0,.22),0 4px 10px rgba(0,0,0,.08);
color:var(--label);font:13px/1.35 -apple-system,BlinkMacSystemFont,"SF Pro Text","Helvetica Neue",sans-serif;-webkit-font-smoothing:antialiased;letter-spacing:-.003em}
.mac.dark{--win:#2a2a2c;--content:#1e1e1e;--side:#2b2a2e;--side2:#353438;--label:rgba(255,255,255,.88);--label2:rgba(255,255,255,.55);--label3:rgba(255,255,255,.28);
--sep:rgba(255,255,255,.1);--ctl:#5c5c60;--ctlBorder:rgba(255,255,255,.08);--ctlShadow:0 .5px 1px rgba(0,0,0,.4);--fill:rgba(255,255,255,.06);--fill2:rgba(255,255,255,.1);
--accent:#0a7cff;--selection:#0a5fce;--selMuted:rgba(255,255,255,.1);--red:#ff453a;--green:#32d74b;--orange:#ff9f0a;
--pop:rgba(40,40,42,.97);--group:#252527;--groupBorder:rgba(255,255,255,.07);--thumbA:#3d4441;--thumbB:#38404d;--thumbC:#4a4038;
--shadow:0 0 0 .5px rgba(0,0,0,.9),0 0 0 1px rgba(255,255,255,.08) inset,0 18px 48px rgba(0,0,0,.55)}
/* ---------- controls ---------- */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:5px;height:22px;padding:0 10px;border-radius:6px;background:var(--ctl);color:var(--label);
box-shadow:var(--ctlShadow),0 0 0 .5px var(--ctlBorder);font:500 13px/1 inherit;font-family:inherit;white-space:nowrap;border:0}
.btn.sm{height:20px;font-size:12px;padding:0 9px;border-radius:5px}
.btn.lg{height:28px;font-size:13px;padding:0 14px;border-radius:7px}
.btn.primary{background:var(--accent);color:var(--accentText);box-shadow:0 .5px 1px rgba(0,0,0,.2)}
.btn.plain{background:transparent;box-shadow:none;color:var(--accent);padding:0 4px}
.btn.icon{width:24px;padding:0;background:transparent;box-shadow:none;color:var(--label2)}
.btn[disabled]{opacity:.42}
.kbd{font:500 11px/1 -apple-system,inherit;color:var(--label2);letter-spacing:.04em}
.primary .kbd{color:rgba(255,255,255,.75)}
.seg{display:inline-flex;background:var(--fill2);border-radius:6px;padding:1px;gap:1px}
.seg span{padding:2px 12px;border-radius:5px;font-size:12px;color:var(--label)}
.seg span.on{background:var(--ctl);box-shadow:var(--ctlShadow),0 0 0 .5px var(--ctlBorder)}
.field{height:22px;border-radius:5px;background:var(--ctl);box-shadow:0 0 0 .5px var(--ctlBorder) inset;display:flex;align-items:center;padding:0 7px;color:var(--label);font-size:13px}
.mac.dark .field{background:rgba(255,255,255,.06)}
.mac.dark .grow-row .field{background:transparent}
.mac.dark .grow-row .field.focus{background:rgba(255,255,255,.08)}
.field.ph{color:var(--label3)}
.field.focus{box-shadow:0 0 0 .5px var(--accent) inset,0 0 0 3px color-mix(in srgb,var(--accent) 35%,transparent)}
.popup{display:inline-flex;align-items:center;gap:8px;height:22px;padding:0 6px 0 9px;border-radius:5px;background:var(--ctl);box-shadow:var(--ctlShadow),0 0 0 .5px var(--ctlBorder);font-size:13px}
.popup i{display:inline-block;width:14px;height:16px;border-radius:4px;background:var(--accent);position:relative}
.popup i:before,.popup i:after{content:"";position:absolute;left:4px;border:3px solid transparent}
.popup i:before{top:2px;border-bottom-color:#fff;border-top:0}
.popup i:after{bottom:2px;border-top-color:#fff;border-bottom:0}
.mono{font-family:ui-monospace,"SF Mono",Menlo,monospace;font-size:12px}
.sec{color:var(--label2)}
.ter{color:var(--label3)}
.cap{font-size:11px;color:var(--label2)}
svg.sym{width:14px;height:14px;flex:none;stroke:currentColor;fill:none;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round}
svg.sym.sm{width:12px;height:12px}
/* ---------- menu bar + popover ---------- */
.menubar{height:24px;display:flex;justify-content:flex-end;align-items:center;gap:14px;padding:0 12px;font-size:13px;width:356px;box-sizing:border-box;
background:rgba(236,236,236,.85);color:#111;border-radius:6px 6px 0 0}
.mac.dark .menubar{background:rgba(28,28,30,.9);color:#eee}
.menubar .extra{display:inline-flex;align-items:center;gap:3px;padding:1px 6px;border-radius:4px;background:rgba(0,0,0,.12)}
.mac.dark .menubar .extra{background:rgba(255,255,255,.18)}
.popwrap{position:relative;width:356px;padding-top:8px}
.popover{width:340px;margin-left:8px;border-radius:12px;background:var(--pop);box-shadow:var(--shadow);overflow:hidden;position:relative}
.popover:before{content:"";position:absolute;top:-6px;right:42px;width:12px;height:12px;background:var(--pop);transform:rotate(45deg)}
.pp{padding:12px 12px 0}
.pp-head{display:flex;align-items:flex-start;gap:8px}
.pp-title{font-size:13px;font-weight:600}
.pp-sub{font-size:11px;color:var(--label2);margin-top:1px}
.pp-head .grow{flex:1;min-width:0}
.badge{font:600 11px/1 inherit;padding:3px 6px;border-radius:99px;background:var(--fill2);color:var(--label2);font-variant-numeric:tabular-nums}
.strip{display:flex;gap:6px;margin:12px 0 0;overflow:hidden}
.thumb{position:relative;flex:none;height:62px;width:96px;border-radius:5px;background:var(--thumbA);box-shadow:0 0 0 .5px var(--sep) inset;overflow:hidden}
.thumb:nth-child(3n+2){background:var(--thumbB)}.thumb:nth-child(3n){background:var(--thumbC)}
.thumb .n{position:absolute;left:4px;top:4px;font:600 10px/1 inherit;color:#fff;background:rgba(0,0,0,.55);padding:2px 4px;border-radius:3px}
.thumb .lines{position:absolute;left:10px;right:10px;top:22px;display:grid;gap:5px}
.thumb .lines b{display:block;height:4px;border-radius:2px;background:rgba(0,0,0,.14)}
.mac.dark .thumb .lines b{background:rgba(255,255,255,.14)}
.thumb .lines b:nth-child(2){width:70%}.thumb .lines b:nth-child(3){width:45%}
.thumb.more{width:44px;background:var(--fill)!important;display:flex;align-items:center;justify-content:center;font-size:11px;color:var(--label2)}
.empty-strip{margin:12px 0 0;height:62px;border-radius:6px;background:var(--fill);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;text-align:center}
.empty-strip .t{font-size:12px;color:var(--label)}
.empty-strip .s{font-size:11px;color:var(--label2)}
.actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:12px 0 0}
.actions .btn{height:28px;font-size:13px;border-radius:7px}
.secondary{display:flex;justify-content:space-between;align-items:center;margin:10px 0 0}
.status{margin:10px -12px 0;padding:8px 12px;border-top:.5px solid var(--sep);display:flex;gap:8px;align-items:center;font-size:12px}
.status .dot{width:7px;height:7px;border-radius:50%;background:var(--green);flex:none}
.status .grow{flex:1}
.pp-foot{margin:0 -12px;padding:6px 8px 6px 12px;border-top:.5px solid var(--sep);display:flex;align-items:center;justify-content:space-between;font-size:11px;color:var(--label2)}
.capturing .thumb.live{box-shadow:0 0 0 2px var(--accent) inset}
.spinner{width:12px;height:12px;border-radius:50%;border:1.6px solid rgba(255,255,255,.45);border-top-color:#fff;flex:none}
.btn:not(.primary) .spinner{border-color:var(--fill2);border-top-color:var(--label2)}
/* ---------- main window ---------- */
.window{border-radius:10px;background:var(--content);box-shadow:var(--shadow);overflow:hidden;display:grid;grid-template-columns:232px 1fr 300px;grid-template-rows:52px 1fr;position:relative}
.window.noinsp{grid-template-columns:232px 1fr}
.titlebar{grid-column:1/-1;display:grid;grid-template-columns:232px 1fr 300px;border-bottom:.5px solid var(--sep);background:var(--win)}
.window.noinsp .titlebar{grid-template-columns:232px 1fr}
.tb-side{display:flex;align-items:center;gap:8px;padding:0 12px 0 20px;background:var(--side);border-right:.5px solid var(--sep)}
.lights{display:flex;gap:8px}
.lights i{width:12px;height:12px;border-radius:50%;display:block;box-shadow:0 0 0 .5px rgba(0,0,0,.18) inset}
.lights i:nth-child(1){background:#ff5f57}.lights i:nth-child(2){background:#febc2e}.lights i:nth-child(3){background:#28c840}
.tb-main{display:flex;align-items:center;gap:8px;padding:0 12px 0 16px}
.tb-main .title{font-size:15px;font-weight:600}
.tb-main .subtitle{font-size:11px;color:var(--label2)}
.tb-main .grow{flex:1}
.tbbtn{display:inline-flex;align-items:center;gap:5px;height:28px;padding:0 9px;border-radius:7px;color:var(--label);font-size:13px}
.tbbtn:hover{background:var(--fill)}
.tbbtn.prom{background:var(--accent);color:#fff}
.tbgroup{display:flex;gap:2px}
.tb-insp{display:flex;align-items:center;justify-content:flex-end;padding:0 12px;border-left:.5px solid var(--sep)}
.sidebar{background:var(--side);border-right:.5px solid var(--sep);padding:8px 10px;overflow:hidden}
.search{height:26px;border-radius:7px;background:var(--fill2);display:flex;align-items:center;gap:6px;padding:0 8px;color:var(--label3);font-size:13px;margin:0 0 10px}
.sgroup{font:600 11px/1 inherit;color:var(--label2);padding:10px 8px 5px}
.srow{display:grid;grid-template-columns:1fr auto;gap:0 6px;padding:5px 8px;border-radius:6px;margin:0 0 1px}
.srow .l1{font-size:13px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.srow .l2{grid-column:1/-1;font-size:11px;color:var(--label2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.srow .tm{font-size:11px;color:var(--label2);font-variant-numeric:tabular-nums;align-self:center}
.srow.sel{background:var(--selection);color:var(--selText)}
.srow.sel .l2,.srow.sel .tm{color:rgba(255,255,255,.78)}
.srow .st{display:inline-flex;align-items:center;gap:3px}
.srow .st.ret{color:var(--orange)}
.srow.sel .st.ret{color:#fff}
.current-pill{font:600 10px/1 inherit;padding:2px 5px;border-radius:4px;background:var(--accent);color:#fff;margin-left:4px;vertical-align:1px}
.srow.sel .current-pill{background:rgba(255,255,255,.25)}
.content{padding:18px 20px;overflow:hidden;background:var(--content)}
.chead{display:flex;align-items:baseline;gap:10px;margin:0 0 14px}
.chead h2{margin:0;font-size:13px;font-weight:600}
.chead .grow{flex:1}
.grid{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}
.page{display:flex;flex-direction:column;gap:6px}
.page .shot{position:relative;aspect-ratio:16/10;border-radius:6px;background:var(--thumbA);box-shadow:0 0 0 .5px var(--sep) inset;overflow:hidden}
.page:nth-child(3n+2) .shot{background:var(--thumbB)}.page:nth-child(3n) .shot{background:var(--thumbC)}
.page .shot .lines{position:absolute;left:14%;right:14%;top:28%;display:grid;gap:7px}
.page .shot .lines b{display:block;height:6px;border-radius:3px;background:rgba(0,0,0,.12)}
.mac.dark .page .shot .lines b{background:rgba(255,255,255,.12)}
.page .shot .lines b:nth-child(2){width:72%}.page .shot .lines b:nth-child(3){width:48%}
.page .shot .mark{position:absolute;right:8px;top:8px;font:600 10px/1 inherit;padding:3px 5px;border-radius:4px;background:var(--orange);color:#fff}
.page .meta{display:flex;justify-content:space-between;font-size:11px;color:var(--label2);font-variant-numeric:tabular-nums}
.page .meta b{color:var(--label);font-weight:600}
.page.sel .shot{box-shadow:0 0 0 3px var(--accent)}
.inspector{border-left:.5px solid var(--sep);background:var(--win);padding:14px 14px;overflow:hidden}
.mac.dark .inspector{background:#232325}
.ihead{font:600 11px/1 inherit;color:var(--label2);margin:6px 2px 7px}
.group{background:var(--group);border-radius:8px;box-shadow:0 0 0 .5px var(--groupBorder);margin:0 0 14px}
.grow-row{display:grid;grid-template-columns:78px 1fr;align-items:center;gap:8px;padding:6px 10px;min-height:22px}
.grow-row + .grow-row{border-top:.5px solid var(--sep)}
.grow-row .k{font-size:12px;color:var(--label2)}
.grow-row .v{font-size:12px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.grow-row .field{height:20px;font-size:12px;background:transparent;box-shadow:none;padding:0}
.grow-row .field.focus{background:var(--ctl);box-shadow:0 0 0 .5px var(--accent) inset,0 0 0 3px color-mix(in srgb,var(--accent) 35%,transparent);padding:0 5px;margin:0 -5px}
.note .v{white-space:normal}
.ifoot{font-size:11px;color:var(--label2);margin:-6px 2px 12px;line-height:1.35}
.ret-banner{display:flex;gap:8px;align-items:flex-start;padding:8px 10px;border-radius:8px;background:color-mix(in srgb,var(--orange) 12%,transparent);margin:0 0 14px;font-size:12px}
.ret-banner .grow{flex:1}
.ret-banner svg{color:var(--orange);margin-top:1px}
.empty-main{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;height:100%;gap:8px;padding:0 40px}
.empty-main .t{font-size:15px;font-weight:600}
.empty-main .s{font-size:12px;color:var(--label2);max-width:320px}
/* ---------- settings ---------- */
.settings{width:420px;border-radius:10px;background:var(--win);box-shadow:var(--shadow);overflow:hidden}
.mac.dark .settings{background:#1f1f21}
.st-title{height:52px;display:grid;grid-template-columns:70px 1fr 70px;align-items:center;padding:0 0 0 14px}
.st-title .t{text-align:center;font-size:13px;font-weight:600}
.st-body{padding:0 18px 18px}
.st-body .ihead{margin:12px 2px 7px}
.st-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:7px 10px;min-height:22px}
.st-row + .st-row{border-top:.5px solid var(--sep)}
.st-row .k{font-size:13px}
.st-row .v{display:flex;align-items:center;gap:8px;min-width:0}
.st-row .path{font-size:12px;color:var(--label2);max-width:170px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.recorder{display:inline-flex;align-items:center;height:22px;padding:0 10px;border-radius:5px;background:var(--fill2);font-size:13px;letter-spacing:.06em}
.st-help{font-size:11px;color:var(--label2);margin:6px 2px 0;line-height:1.35}
/* annotations under each mock */
.notes{max-width:360px;font-size:12px;color:var(--mut);line-height:1.45;margin:0;padding-left:16px}
.notes li{margin:0 0 3px}
</style>
</head>
<body>
<header class="board">
<h1>Redline, rebuilt from the job outwards</h1>
<p>The menu-bar popover only answers "what am I capturing, and what do I do next". Everything about past sessions, review details and PDF facts lives in one Redline window. Settings has three sections. Each mock is shown at 1:1 size in light and dark.</p>
</header>
<section class="turn" id="t1">
<div class="thd"><a class="tid" href="#t1">1</a><span class="tname">Menu-bar popover: glance and act</span><span class="tnote">340 pt wide · controlSize small · current session only</span></div>
<div class="row" id="popovers"></div>
</section>
<section class="turn" id="t2">
<div class="thd"><a class="tid" href="#t2">2</a><span class="tname">Redline window: the session workspace</span><span class="tnote">1100 × 700 · sidebar · content · inspector · controlSize regular</span></div>
<div class="row" id="mains"></div>
</section>
<section class="turn" id="t3">
<div class="thd"><a class="tid" href="#t3">3</a><span class="tname">Redline window: first run, nothing captured</span><span class="tnote">1100 × 700</span></div>
<div class="row" id="empties"></div>
</section>
<section class="turn" id="t4">
<div class="thd"><a class="tid" href="#t4">4</a><span class="tname">Settings</span><span class="tnote">420 × 484 · three groups, no tabs</span></div>
<div class="row" id="settings"></div>
</section>
<script>
/* Inline SVG stand-ins for the SF Symbols the app will use (names in data-sf). */
const SYM = {
camera: '<svg class="sym" viewBox="0 0 16 16" data-sf="camera.viewfinder"><path d="M2 5V3.5A1.5 1.5 0 0 1 3.5 2H5M11 2h1.5A1.5 1.5 0 0 1 14 3.5V5M14 11v1.5a1.5 1.5 0 0 1-1.5 1.5H11M5 14H3.5A1.5 1.5 0 0 1 2 12.5V11"/><circle cx="8" cy="8" r="2.4"/></svg>',
send: '<svg class="sym" viewBox="0 0 16 16" data-sf="paperplane"><path d="M14 2 2 7l5 2 2 5 5-12Z"/><path d="m7 9 3-3"/></svg>',
plus: '<svg class="sym" viewBox="0 0 16 16" data-sf="plus.rectangle.on.rectangle"><rect x="2.5" y="4.5" width="9" height="9" rx="1.5"/><path d="M5 2.5h7a1.5 1.5 0 0 1 1.5 1.5v7M7 9h0M7 7v4M5 9h4"/></svg>',
window: '<svg class="sym" viewBox="0 0 16 16" data-sf="macwindow"><rect x="2" y="3" width="12" height="10" rx="1.5"/><path d="M2 6h12"/></svg>',
more: '<svg class="sym" viewBox="0 0 16 16" data-sf="ellipsis.circle"><circle cx="8" cy="8" r="6"/><circle cx="5.5" cy="8" r=".4" fill="currentColor"/><circle cx="8" cy="8" r=".4" fill="currentColor"/><circle cx="10.5" cy="8" r=".4" fill="currentColor"/></svg>',
pencil: '<svg class="sym sm" viewBox="0 0 16 16" data-sf="pencil.tip.crop.circle"><path d="M10.5 2.5 13.5 5.5 6 13H3v-3Z"/></svg>',
search: '<svg class="sym" viewBox="0 0 16 16" data-sf="magnifyingglass"><circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3 3"/></svg>',
sidebar: '<svg class="sym" viewBox="0 0 16 16" data-sf="sidebar.left"><rect x="2" y="3" width="12" height="10" rx="1.5"/><path d="M6 3v10"/></svg>',
inspector: '<svg class="sym" viewBox="0 0 16 16" data-sf="sidebar.right"><rect x="2" y="3" width="12" height="10" rx="1.5"/><path d="M10 3v10"/></svg>',
finder: '<svg class="sym" viewBox="0 0 16 16" data-sf="folder"><path d="M2 4.5A1.5 1.5 0 0 1 3.5 3h2.6l1.4 1.5h5A1.5 1.5 0 0 1 14 6v5.5a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 2 11.5Z"/></svg>',
check: '<svg class="sym sm" viewBox="0 0 16 16" data-sf="checkmark.circle"><circle cx="8" cy="8" r="6"/><path d="m5.5 8 1.8 1.8L10.8 6.3"/></svg>',
marked: '<svg class="sym sm" viewBox="0 0 16 16" data-sf="pencil.and.outline"><path d="M10.5 2.5 13.5 5.5 6 13H3v-3Z"/></svg>',
warn: '<svg class="sym" viewBox="0 0 16 16" data-sf="exclamationmark.triangle"><path d="M8 2.5 14 13H2Z"/><path d="M8 6.5v3M8 11.3v.1"/></svg>',
menuIcon: '<svg class="sym" viewBox="0 0 16 16" data-sf="viewfinder"><path d="M2 5V3.5A1.5 1.5 0 0 1 3.5 2H5M11 2h1.5A1.5 1.5 0 0 1 14 3.5V5M14 11v1.5a1.5 1.5 0 0 1-1.5 1.5H11M5 14H3.5A1.5 1.5 0 0 1 2 12.5V11"/></svg>'
};
const thumbs = n => Array.from({length:n},(_,i)=>`<div class="thumb${i===n-1?' live':''}"><span class="n">${i+1}</span><div class="lines"><b></b><b></b><b></b></div></div>`).join('');
function opt(id,label,html,notes){
return `<div class="opt" id="${id}"><div class="olabel"><a class="oid" href="#${id}">${id}</a>${label}</div><div class="scroller">${html}</div>${notes?`<ul class="notes">${notes.map(n=>`<li>${n}</li>`).join('')}</ul>`:''}</div>`;
}
/* ---------- popover ---------- */
function popover(theme,state){
const dark = theme==='dark'?' dark':'';
const count = state==='idle'?0:(state==='capturing'?4:3);
const head = `
<div class="pp-head">
<div class="grow">
<div class="pp-title">DEV03 · v1.4.2 (41)</div>
<div class="pp-sub">a1b2c3d · Ben Hippler · started 10:31</div>
</div>
${count?`<span class="badge" aria-label="${count} pages">${count} pages</span>`:''}
<button class="btn icon" aria-label="Edit review details" title="Edit review details">${SYM.pencil}</button>
</div>`;
const body = state==='idle'
? `<div class="empty-strip"><div class="t">Nothing captured yet</div><div class="s">⌥⇧2 captures 800 × 600 on Display 1</div></div>`
: `<div class="strip${state==='capturing'?' capturing':''}">${thumbs(count===4?3:3)}${count>3?'<div class="thumb more">+1</div>':''}</div>`;
const capBtn = state==='capturing'
? `<button class="btn" disabled><span class="spinner"></span>Capturing…</button>`
: `<button class="btn">${SYM.camera}Capture <span class="kbd">⌥⇧2</span></button>`;
const sendBtn = state==='idle'
? `<button class="btn primary" disabled>${SYM.send}Send</button>`
: `<button class="btn primary">${SYM.send}Send ${count} pages…</button>`;
const status = state==='with'
? `<div class="status"><span class="dot" style="background:var(--orange)"></span><span class="grow">1 PDF came back with marks on 2 pages</span><button class="btn plain sm">Show</button></div>`
: '';
return `<div class="mac${dark}">
<div class="menubar"><span>Fri 31 Oct 10:42</span><span class="extra">${SYM.menuIcon}<span style="font-size:11px;font-weight:600">${count||''}</span></span></div>
<div class="popwrap"><div class="popover" role="dialog" aria-label="Redline">
<div class="pp">
${head}
${body}
<div class="actions">${capBtn}${sendBtn}</div>
<div class="secondary">
<button class="btn plain sm" ${state==='idle'?'disabled':''}>${SYM.plus}New Session</button>
<button class="btn plain sm">${SYM.window}Open Redline</button>
</div>
${status}
<div class="pp-foot" style="${status?'border-top:0;margin-top:0':'margin-top:12px'}">
<span>Sends via AirDrop · All sessions kept</span>
<button class="btn icon" aria-label="More">${SYM.more}</button>
</div>
</div>
</div></div></div>`;
}
const popNotes = {
idle:['The session already carries the inherited review details, so the title is never empty after first use.','Send is disabled, not hidden, so the layout never jumps.'],
with:['Send states the page count it will produce.','One status line appears only when something happened: a return, a send, or an error.'],
capturing:['The newest thumbnail gets the accent ring; Capture shows progress and is disabled until the PNG is on disk.','The More menu holds Settings…, Check for Updates…, Quit Redline.']
};
document.getElementById('popovers').innerHTML =
['idle','with','capturing'].flatMap(s=>['light','dark'].map(t=>
opt(`1${s[0]}${t[0]}`,`${{idle:'Idle, empty session',with:'Captures present + a return',capturing:'Capturing'}[s]} · ${t}`,popover(t,s),t==='light'?popNotes[s]:null))).join('');
/* ---------- main window ---------- */
const sessions = [
{g:'Today'},
{lane:'DEV03',tm:'10:31',l2:'3 pages · not sent',cur:true,sel:true},
{lane:'DEV03',tm:'09:12',l2:'5 pages · sent',st:'sent'},
{lane:'OMS test lane',tm:'08:40',l2:'2 pages · came back marked',st:'ret'},
{g:'Yesterday'},
{lane:'STAGE',tm:'17:04',l2:'7 pages · sent',st:'sent'},
{lane:'DEV03',tm:'14:22',l2:'4 pages · sent',st:'sent'},
{g:'This week'},
{lane:'PROD',tm:'Tue',l2:'1 page · not sent'},
{lane:'4F2A9C1D',tm:'Mon',l2:'6 pages · sent',st:'sent'},
];
function sidebarRows(list){
return list.map(s=>s.g?`<div class="sgroup">${s.g}</div>`:
`<div class="srow${s.sel?' sel':''}"><span class="l1">${s.lane}${s.cur?'<span class="current-pill">Current</span>':''}</span><span class="tm">${s.tm}</span><span class="l2">${s.st==='ret'?`<span class="st ret">${SYM.marked} ${s.l2}</span>`:s.l2}</span></div>`).join('');
}
function titlebar(title,sub,canSend){
return `<div class="titlebar">
<div class="tb-side"><div class="lights"><i></i><i></i><i></i></div><span style="flex:1"></span><span class="tbbtn" aria-label="Hide sidebar">${SYM.sidebar}</span></div>
<div class="tb-main"><div><div class="title">${title}</div><div class="subtitle">${sub}</div></div><span class="grow"></span>
<div class="tbgroup">
<span class="tbbtn" title="New Session ⌘N">${SYM.plus}New Session</span>
<span class="tbbtn" title="Capture ⌥⇧2">${SYM.camera}Capture</span>
<span class="tbbtn prom" style="${canSend?'':'opacity:.4'}" title="Send ⌘S">${SYM.send}Send…</span>
</div></div>
<div class="tb-insp"><span class="tbbtn" aria-label="Hide inspector">${SYM.inspector}</span></div>
</div>`;
}
function inspector(opts){
const f = opts.focus;
return `<aside class="inspector" aria-label="Session inspector">
<div class="ihead">Review details</div>
<div class="group">
<div class="grow-row"><span class="k">Lane</span><span class="field${f==='lane'?' focus':''}">DEV03</span></div>
<div class="grow-row"><span class="k">Deployed</span><span class="field">v1.4.2 (41)</span></div>
<div class="grow-row"><span class="k">Commit</span><span class="field mono">a1b2c3d4</span></div>
<div class="grow-row"><span class="k">Reviewer</span><span class="field">Ben Hippler</span></div>
<div class="grow-row note"><span class="k">Note</span><span class="field ph">Add a note</span></div>
</div>
<div class="ifoot">Printed on every page of the PDF. A new session starts with these values.</div>
<div class="ihead">PDF</div>
<div class="group">
<div class="grow-row"><span class="k">File name</span><span class="v mono" title="Redline-20261031-1042-DEV03-4F2A9C1D.pdf">Redline-20261031-1042-DEV03-4F2A9C1D.pdf</span></div>
<div class="grow-row"><span class="k">Pages</span><span class="v">${opts.pages}</span></div>
<div class="grow-row"><span class="k">Sends via</span><span class="v">AirDrop</span></div>
<div class="grow-row"><span class="k">Status</span><span class="v sec">Not sent yet</span></div>
</div>
<div class="ihead">Session</div>
<div class="group">
<div class="grow-row"><span class="k">Started</span><span class="v">31 Oct 2026, 10:31 Dubai</span></div>
<div class="grow-row"><span class="k">ID</span><span class="v mono">4F2A9C1D</span></div>
<div class="grow-row"><span class="k">Captures</span><span class="v"><a href="#t2">Show in Finder</a></span></div>
</div>
</aside>`;
}
function mainWindow(theme){
const dark = theme==='dark'?' dark':'';
const pages = [['1','10:31'],['2','10:34'],['3','10:39']];
return `<div class="mac${dark}"><div class="window" style="width:1100px;height:700px">
${titlebar('DEV03','Current session · 3 pages · not sent',true)}
<nav class="sidebar" aria-label="Sessions">
<div class="search">${SYM.search}Search</div>
${sidebarRows(sessions)}
</nav>
<main class="content">
<div class="chead"><h2>Pages</h2><span class="sec" style="font-size:12px">In PDF order · Delete removes the selected page</span><span class="grow"></span><button class="btn">${SYM.camera}Capture <span class="kbd">⌥⇧2</span></button></div>
<div class="grid">${pages.map((p,i)=>`<div class="page${i===1?' sel':''}"><div class="shot"><div class="lines"><b></b><b></b><b></b></div></div><div class="meta"><span><b>Page ${p[0]}</b></span><span>${p[1]}</span></div></div>`).join('')}</div>
</main>
${inspector({pages:3,focus:'lane'})}
</div></div>`;
}
function returnedWindow(theme){
const dark = theme==='dark'?' dark':'';
const list = sessions.map(s=>s.sel?{...s,sel:false}:s.lane==='OMS test lane'?{...s,sel:true}:s);
const pages = [['1','08:40',false],['2','08:43',true]];
return `<div class="mac${dark}"><div class="window" style="width:1100px;height:700px">
${titlebar('OMS test lane','Sent 08:52 · came back 09:30 with marks',false)}
<nav class="sidebar" aria-label="Sessions"><div class="search">${SYM.search}Search</div>${sidebarRows(list)}</nav>
<main class="content">
<div class="ret-banner">${SYM.marked}<span class="grow"><b>Came back with marks on page 2.</b><br><span class="sec">Redline-20261031-0852-OMS-TEST-LANE-9B8C7D6E.pdf, in Downloads</span></span><button class="btn sm">Open PDF</button><button class="btn sm">Copy Link</button></div>
<div class="chead"><h2>Pages</h2><span class="grow"></span></div>
<div class="grid">${pages.map(p=>`<div class="page"><div class="shot"><div class="lines"><b></b><b></b><b></b></div>${p[2]?'<span class="mark">Marked</span>':''}</div><div class="meta"><span><b>Page ${p[0]}</b></span><span>${p[1]}</span></div></div>`).join('')}</div>
</main>
<aside class="inspector" aria-label="Session inspector">
<div class="ihead">Review details</div>
<div class="group">
<div class="grow-row"><span class="k">Lane</span><span class="v">OMS test lane</span></div>
<div class="grow-row"><span class="k">Deployed</span><span class="v">v2.0.0-rc3</span></div>
<div class="grow-row"><span class="k">Commit</span><span class="v mono">9f3e2d1</span></div>
<div class="grow-row"><span class="k">Reviewer</span><span class="v">Ben Hippler</span></div>
</div>
<div class="ifoot">Past sessions are read-only: the PDF already carries these values.</div>
<div class="ihead">PDF</div>
<div class="group">
<div class="grow-row"><span class="k">File name</span><span class="v mono">Redline-20261031-0852-OMS-TEST-LANE-9B8C7D6E.pdf</span></div>
<div class="grow-row"><span class="k">Sent</span><span class="v">31 Oct 2026, 08:52 via AirDrop</span></div>
<div class="grow-row"><span class="k">Returned</span><span class="v">09:30 · marks on 1 of 2 pages</span></div>
<div class="grow-row"><span class="k"></span><span class="v"><a href="#t2">Show PDF in Finder</a></span></div>
</div>
</aside>
</div></div>`;
}
document.getElementById('mains').innerHTML =
opt('2a','Current session selected, Lane field focused · light',mainWindow('light'),[
'Sidebar: every kept session grouped by day; the current one is pinned at the top with a Current tag.',
'Content: the pages exactly as the PDF will order them. Selection ring shows the focused page.',
'Inspector: the three facts a reader of the PDF needs (review details, PDF, session). Editable only for the current session.'])
+ opt('2b','Current session · dark',mainWindow('dark'))
+ opt('2c','Past session that came back marked · light',returnedWindow('light'),[
'A returned PDF is news, so it gets the one tinted banner in the app, with the two things you do next.',
'No Send, no Capture on a past session: the toolbar dims Send and the content drops the Capture button.'])
+ opt('2d','Past session that came back marked · dark',returnedWindow('dark'));
/* ---------- empty window ---------- */
function emptyWindow(theme){
const dark = theme==='dark'?' dark':'';
return `<div class="mac${dark}"><div class="window" style="width:1100px;height:700px">
${titlebar('New session','Nothing captured yet',false)}
<nav class="sidebar" aria-label="Sessions"><div class="search">${SYM.search}Search</div><div class="sgroup">Today</div>
<div class="srow sel"><span class="l1">New session<span class="current-pill">Current</span></span><span class="tm">10:31</span><span class="l2">No pages yet</span></div></nav>
<main class="content"><div class="empty-main">
<div class="t">No pages in this session</div>
<div class="s">Press ⌥⇧2 anywhere to capture the saved area, or choose an area now. Each capture becomes one page of the PDF.</div>
<div style="display:flex;gap:8px;margin-top:6px"><button class="btn lg">Choose Area…</button><button class="btn lg primary">${SYM.camera}Capture</button></div>
</div></main>
<aside class="inspector" aria-label="Session inspector">
<div class="ihead">Review details</div>
<div class="group">
<div class="grow-row"><span class="k">Lane</span><span class="field ph focus">dev03, customer test lane…</span></div>
<div class="grow-row"><span class="k">Deployed</span><span class="field ph">Build that is live</span></div>
<div class="grow-row"><span class="k">Commit</span><span class="field ph mono">Git SHA</span></div>
<div class="grow-row"><span class="k">Reviewer</span><span class="field">Ben Hippler</span></div>
<div class="grow-row note"><span class="k">Note</span><span class="field ph">Add a note</span></div>
</div>
<div class="ifoot">Fill these in once. They print on every page and carry over to the next session.</div>
</aside>
</div></div>`;
}
document.getElementById('empties').innerHTML =
opt('3a','First run · light',emptyWindow('light'),['The first thing the window asks for is the lane, because it names the file and heads every page.','Reviewer is pre-filled from the Mac account; nothing else is guessed.'])
+ opt('3b','First run · dark',emptyWindow('dark'));
/* ---------- settings ---------- */
function settings(theme){
const dark = theme==='dark'?' dark':'';
return `<div class="mac${dark}"><div class="settings" style="height:484px">
<div class="st-title"><div class="lights"><i></i><i style="background:var(--fill2)"></i><i style="background:var(--fill2)"></i></div><div class="t">Redline Settings</div><div></div></div>
<div class="st-body">
<div class="ihead">Capture</div>
<div class="group">
<div class="st-row"><span class="k">Capture shortcut</span><span class="v"><span class="recorder">⌥⇧2</span></span></div>
<div class="st-row"><span class="k">Area</span><span class="v"><span class="sec" style="font-size:12px">800 × 600 on Display 1</span><button class="btn sm">Choose…</button></span></div>
</div>
<div class="ihead">Sending</div>
<div class="group">
<div class="st-row"><span class="k">Send with</span><span class="v"><span class="seg"><span class="on">AirDrop</span><span>OneDrive</span></span></span></div>
<div class="st-row"><span class="k">Save PDFs to</span><span class="v"><span class="path">~/Desktop</span><button class="btn sm">Choose…</button></span></div>
<div class="st-row"><span class="k">Watch for returns in</span><span class="v"><span class="path">~/Downloads</span><button class="btn sm">Choose…</button></span></div>
</div>
<div class="ihead">Sessions</div>
<div class="group">
<div class="st-row"><span class="k">Delete sessions older than</span><span class="v"><span class="popup">Never<i></i></span></span></div>
<div class="st-row"><span class="k sec" style="font-size:12px">18 sessions kept</span><span class="v"><button class="btn sm" disabled>Clean Up Now…</button></span></div>
</div>
<div class="st-help">Deleting removes Redline's own screenshots only. PDFs you sent stay where they are.</div>
</div>
</div></div>`;
}
document.getElementById('settings').innerHTML =
opt('4a','Settings · light',settings('light'),['Three labelled groups replace headings-plus-grid. Every row is "what it is" on the left, the control on the right.','Clean Up Now… is enabled only when a limit is set, and confirms with the exact count before deleting.'])
+ opt('4b','Settings · dark',settings('dark'));
</script>
</body>
</html>