native macOS codings agent orchestrator
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

Revert "Hide script placeholders while editors are focused"

This reverts commit 9ca2ef8b2a8de8e9d4be8c8570c19dfc6464eb6d.

onevcat 32a7894c 9ca2ef8b

+9 -87
+8 -61
supacode/Features/Settings/Views/RepositorySettingsView.swift
··· 18 18 @State private var popoverRefocusTask: Task<Void, Never>? 19 19 @State private var commandEditorCommandID: UserCustomCommand.ID? 20 20 @State private var editingNameCommandID: UserCustomCommand.ID? 21 - @State private var focusedScriptEditor: ScriptEditorFocus? 22 21 @FocusState private var focusedNameEditorCommandID: UserCustomCommand.ID? 23 22 24 23 private let keyTokenResolver = ShortcutKeyTokenResolver() ··· 49 48 "cloud.fill", 50 49 "tray.and.arrow.down.fill", 51 50 ] 52 - 53 - private enum ScriptEditorFocus: Equatable { 54 - case setup 55 - case archive 56 - case run 57 - case command(UserCustomCommand.ID) 58 - } 59 51 60 52 var body: some View { 61 53 let baseRefOptions = ··· 177 169 Section { 178 170 ZStack(alignment: .topLeading) { 179 171 PlainTextEditor( 180 - text: settings.setupScript, 181 - onFocusChange: { isFocused in 182 - if isFocused { 183 - focusedScriptEditor = .setup 184 - } else if focusedScriptEditor == .setup { 185 - focusedScriptEditor = nil 186 - } 187 - } 172 + text: settings.setupScript 188 173 ) 189 174 .frame(minHeight: 120) 190 - if store.settings.setupScript.isEmpty, 191 - focusedScriptEditor != .setup 192 - { 175 + if store.settings.setupScript.isEmpty { 193 176 Text("claude --dangerously-skip-permissions") 194 177 .foregroundStyle(.secondary) 195 178 .padding(.leading, plainTextPlaceholderLeading) ··· 211 194 Section { 212 195 ZStack(alignment: .topLeading) { 213 196 PlainTextEditor( 214 - text: settings.archiveScript, 215 - onFocusChange: { isFocused in 216 - if isFocused { 217 - focusedScriptEditor = .archive 218 - } else if focusedScriptEditor == .archive { 219 - focusedScriptEditor = nil 220 - } 221 - } 197 + text: settings.archiveScript 222 198 ) 223 199 .frame(minHeight: 120) 224 - if store.settings.archiveScript.isEmpty, 225 - focusedScriptEditor != .archive 226 - { 200 + if store.settings.archiveScript.isEmpty { 227 201 Text("docker compose down") 228 202 .foregroundStyle(.secondary) 229 203 .padding(.leading, plainTextPlaceholderLeading) ··· 245 219 Section { 246 220 ZStack(alignment: .topLeading) { 247 221 PlainTextEditor( 248 - text: settings.runScript, 249 - onFocusChange: { isFocused in 250 - if isFocused { 251 - focusedScriptEditor = .run 252 - } else if focusedScriptEditor == .run { 253 - focusedScriptEditor = nil 254 - } 255 - } 222 + text: settings.runScript 256 223 ) 257 224 .frame(minHeight: 120) 258 - if store.settings.runScript.isEmpty, 259 - focusedScriptEditor != .run 260 - { 225 + if store.settings.runScript.isEmpty { 261 226 Text("npm run dev") 262 227 .foregroundStyle(.secondary) 263 228 .padding(.leading, plainTextPlaceholderLeading) ··· 324 289 popoverRefocusTask?.cancel() 325 290 popoverRefocusTask = nil 326 291 focusedNameEditorCommandID = nil 327 - focusedScriptEditor = nil 328 292 } 329 293 .alert( 330 294 "Shortcut Conflict", ··· 750 714 PlainTextEditor( 751 715 text: command.command, 752 716 isMonospaced: true, 753 - shouldFocus: true, 754 - onFocusChange: { isFocused in 755 - let field = ScriptEditorFocus.command(command.wrappedValue.id) 756 - if isFocused { 757 - focusedScriptEditor = field 758 - } else if focusedScriptEditor == field { 759 - focusedScriptEditor = nil 760 - } 761 - } 717 + shouldFocus: true 762 718 ) 763 719 .frame(height: 140) 764 720 765 - if command.wrappedValue.command.isEmpty, 766 - focusedScriptEditor != .command(command.wrappedValue.id) 767 - { 721 + if command.wrappedValue.command.isEmpty { 768 722 Text(scriptPlaceholder(for: command.wrappedValue.execution)) 769 723 .foregroundStyle(.secondary) 770 724 .padding(.leading, plainTextPlaceholderLeading) ··· 959 913 commandEditorCommandID = nil 960 914 editingNameCommandID = nil 961 915 focusedNameEditorCommandID = nil 962 - focusedScriptEditor = nil 963 916 return 964 917 } 965 918 ··· 1000 953 { 1001 954 self.editingNameCommandID = nil 1002 955 focusedNameEditorCommandID = nil 1003 - } 1004 - 1005 - if case let .command(commandID) = focusedScriptEditor, 1006 - !validIDs.contains(commandID) 1007 - { 1008 - focusedScriptEditor = nil 1009 956 } 1010 957 } 1011 958
+1 -26
supacode/Support/PlainTextEditor.swift
··· 5 5 @Binding var text: String 6 6 var isMonospaced: Bool = false 7 7 var shouldFocus: Bool = false 8 - var onFocusChange: ((Bool) -> Void)? = nil 9 8 10 9 func makeCoordinator() -> Coordinator { 11 10 Coordinator(text: $text) 12 11 } 13 12 14 13 func makeNSView(context: Context) -> NSScrollView { 15 - let textView = FocusAwareTextView(frame: .zero) 14 + let textView = NSTextView(frame: .zero) 16 15 textView.delegate = context.coordinator 17 - textView.onFocusChange = onFocusChange 18 16 textView.drawsBackground = false 19 17 textView.isRichText = false 20 18 textView.importsGraphics = false ··· 44 42 45 43 func updateNSView(_ nsView: NSScrollView, context: Context) { 46 44 guard let textView = nsView.documentView as? NSTextView else { return } 47 - if let focusAwareTextView = textView as? FocusAwareTextView { 48 - focusAwareTextView.onFocusChange = onFocusChange 49 - } 50 45 if textView.string != text { 51 46 textView.string = text 52 47 } ··· 78 73 func textDidChange(_ notification: Notification) { 79 74 guard let textView = notification.object as? NSTextView else { return } 80 75 text = textView.string 81 - } 82 - } 83 - 84 - final class FocusAwareTextView: NSTextView { 85 - var onFocusChange: ((Bool) -> Void)? 86 - 87 - override func becomeFirstResponder() -> Bool { 88 - let didBecomeFirstResponder = super.becomeFirstResponder() 89 - if didBecomeFirstResponder { 90 - onFocusChange?(true) 91 - } 92 - return didBecomeFirstResponder 93 - } 94 - 95 - override func resignFirstResponder() -> Bool { 96 - let didResignFirstResponder = super.resignFirstResponder() 97 - if didResignFirstResponder { 98 - onFocusChange?(false) 99 - } 100 - return didResignFirstResponder 101 76 } 102 77 } 103 78 }