Cotton code
75 lines · 2.9 KB · SwiftRaw
import Foundation// MARK: - Shake to report: `feedback.send` (owner, 13 Nov 2026)//// A shaken report goes to Cotton's own database (the `cotton-product` object's// `app_report`), never into the reporter's Personal. The phone hands the core// one sentence, the PATH of the PNG it wrote of the screen (never the bytes),// where the person stood, this device and its system, the shell's log tail and// the open host the flavour signs in at. The core stamps the app, the build// and the platform itself, keeps the report in its outbox before it posts, and// answers `sent` (Cotton has it) or `kept` (sent by a later `feedback.flush`);// a refusal is the Worker's words (`crates/cotton-ffi/src/phone/feedback_send.rs`).extension CottonMethod {    public static let feedbackSend = "feedback.send"    /// Every kept report tried again: once after the core opens, and each time    /// the app comes to the front. Only logged.    public static let feedbackFlush = "feedback.flush"}/// The pixel size of a screenshot the shake took.public struct FeedbackImageSize: Codable, Sendable, Equatable {    public var width: Int    public var height: Int    public init(width: Int, height: Int) {        self.width = width        self.height = height    }}/// `feedback.send`'s request, every key the core reads and nothing else.public struct FeedbackSendRequest: Encodable, Sendable, Equatable {    public var sentence: String    /// A PNG this app wrote to its temp directory, deleted once the call    /// returns (the core copied it); nil for a report with no picture.    public var screenshotPath: String?    public var route: String    /// `utsname.machine` (`iPhone16,2`), `hw.model` on a Mac.    public var device: String    /// `iOS 26.1`, `macOS 26.1`.    public var os: String    /// The newest lines of the shell's log ring, oldest first.    public var log: [String]    /// The open host the flavour hands `personal.code`; a signed-out report    /// goes there with no bearer.    public var server: String?    public init(sentence: String, screenshotPath: String? = nil, route: String, device: String, os: String, log: [String], server: String?) {        self.sentence = sentence        self.screenshotPath = screenshotPath        self.route = route        self.device = device        self.os = os        self.log = log        self.server = server    }}/// What `feedback.send` answered when it did not refuse.public struct FeedbackSent: Decodable, Sendable, Equatable {    public var id: String    /// `sent`: Cotton has it. `kept`: on this phone until there is a connection.    public var state: String    /// Who the Worker filed it as, `signed_in` or `anonymous`, when it was sent.    public var sender: String?    public init(id: String, state: String, sender: String? = nil) {        self.id = id        self.state = state        self.sender = sender    }    public var kept: Bool { state == "kept" }}