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:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user