import SwiftUI /// ⌘N: the project's plain-text note. Closing it in any way saves it. struct NoteOverlay: View { let note: NoteStore var onPassOn: () -> Void var onClose: () -> Void var body: some View { OverlayShell(.sized(width: 780), onDismiss: onClose) { VStack(spacing: 0) { OverlayHeader(systemImage: "note.text", title: "Note", detail: NoteStore.fileName) { Button(action: onPassOn) { HStack(spacing: 8) { Text("To the agent") Keycap("⌘P", style: .onAmber, small: true) } } .buttonStyle(.primary) } OverlayTextEditor(text: Binding(get: { note.text }, set: { note.text = $0 }), placeholder: "Anything you want to keep next to this project…", onKey: handle) .frame(maxWidth: .infinity, maxHeight: .infinity) Text("saved on focus loss · \(note.characterCount) characters") .typeRole(Typography.meta) .foregroundStyle(Palette.text4) .padding(.horizontal, 20) .frame(maxWidth: .infinity, alignment: .leading) .frame(height: 34) .hairline(.top) } .frame(maxHeight: .infinity) } .onDisappear { Task { await note.save() } } } private func handle(_ key: OverlayKey) -> Bool { switch key { case .commandP: onPassOn() case .escape: onClose() default: return false } return true } }