Range-diff !528

Back to !528

User commands: org.run and keyboard macros

1:  580b3ea ! 1:  4d8e517 User commands: org.run and keyboard macros
    @@ Sources/Orgstar/ContentView.swift: struct ContentView: View {
     +            commands.show(refusal)
     +            return finished(refusal)
     +        }
    -         UserCommandTrust.check(request.command, modules: modules, trust: trust, ask: commands.ask, run: {
    +         let ask: @MainActor (UserCommandTrust.Question, @escaping (UserCommandTrust.Answer?) -> Void) -> Void = { question, reply in
    +             let answers = UserCommandTrust.Answer.allCases
    +             // The echo area's line can cut the path short, so the detail above it repeats it whole.
    +@@ Sources/Orgstar/ContentView.swift: struct ContentView: View {
    +             }
    +         }
    +         UserCommandTrust.check(request.command, modules: modules, trust: trust, ask: ask, run: {
     -            guard let context = commands.editor?.context() else { return }
     +            guard let editor = commands.editor else { return finished("") }
                  commands.show(String(localized: "Running \(request.command.title)… (⌘. to cancel)", comment: "A user command started"))
    @@ Sources/OrgstarMobile/EditorScreen.swift: struct EditorScreen: View {
     -    private func runUserCommand(_ request: UserCommandRequest) {
     -        guard let modules = session.userCommands.folder else { return }
     -        if let refusal = session.refusesUserCommand(path) { return message = refusal }
    +-        let ask: @MainActor (Prompt, @escaping (String?) -> Void) -> Void = { prompt = PromptRequest(prompt: $0, reply: $1) }
     +    /// Runs a user command once its file is trusted on this device; `finished` gets its message
     +    /// once it has ended, nil when its result was applied. The command's prompts go through the
     +    /// editor, so keyboard macros record and replay their answers.
    @@ Sources/OrgstarMobile/EditorScreen.swift: struct EditorScreen: View {
     +            message = refusal
     +            return finished(refusal)
     +        }
    -         let ask: @MainActor (Prompt, @escaping (String?) -> Void) -> Void = { prompt = PromptRequest(prompt: $0, reply: $1) }
    -         UserCommandTrust.check(request.command, modules: modules, trust: trust, ask: ask, run: {
    +         UserCommandTrust.check(request.command, modules: modules, trust: trust, ask: { trustRequest = TrustRequest(question: $0, reply: $1) }, run: {
     -            guard let context = editor?.editContext() else { return }
     +            guard let editor else { return finished("") }
                  message = String(localized: "Running \(request.command.title)…", comment: "A user command started on iPhone and iPad")
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form