From 93682e84cba30dfc419b2ad589856cfdbe06d799 Mon Sep 17 00:00:00 2001 From: Jacob Fu <141651335+FuJacob@users.noreply.github.com> Date: Thu, 11 Jun 2026 23:32:33 -0700 Subject: [PATCH] refactor(settings): group acceptance toggles under Writing, split General behavior Move 'Accept Punctuation With Word' and 'Add Space After Accepting' out of General into a new Writing > Acceptance section, next to the other controls that shape inserted text. Split General's catch-all Behavior section into Context (clipboard/app) and Suggestions (multi-line/macros). Update the search index category mapping so both toggles resolve to Writing. --- .../UI/Settings/Panes/GeneralPaneView.swift | 40 ++++--------------- .../UI/Settings/Panes/WritingPaneView.swift | 36 +++++++++++++++++ Cotabby/UI/Settings/SettingsIndex.swift | 8 ++-- 3 files changed, 47 insertions(+), 37 deletions(-) diff --git a/Cotabby/UI/Settings/Panes/GeneralPaneView.swift b/Cotabby/UI/Settings/Panes/GeneralPaneView.swift index cbc64c54..3c161a3e 100644 --- a/Cotabby/UI/Settings/Panes/GeneralPaneView.swift +++ b/Cotabby/UI/Settings/Panes/GeneralPaneView.swift @@ -45,7 +45,11 @@ struct GeneralPaneView: View { } } - Section("Behavior") { + // Split from the old catch-all "Behavior" group: what the model is allowed to read + // (Context) reads differently from what a suggestion may contain (Suggestions). The + // acceptance toggles that used to live here now sit with Writing, next to the other + // controls that shape inserted text. + Section("Context") { Toggle(isOn: clipboardContextEnabledBinding) { SettingsRowLabel( title: "Include Clipboard Context", @@ -61,7 +65,9 @@ struct GeneralPaneView: View { systemImage: "macwindow" ) } + } + Section("Suggestions") { Toggle(isOn: multiLineEnabledBinding) { SettingsRowLabel( title: "Allow Multi-line Suggestions", @@ -70,24 +76,6 @@ struct GeneralPaneView: View { ) } - Toggle(isOn: autoAcceptTrailingPunctuationBinding) { - SettingsRowLabel( - title: "Accept Punctuation With Word", - description: "When you accept a word, also accept the punctuation that follows it " + - "(commas, periods) so you don't have to type it.", - systemImage: "textformat.abc" - ) - } - - Toggle(isOn: addSpaceAfterAcceptBinding) { - SettingsRowLabel( - title: "Add Space After Accepting", - description: "When accepting a suggestion finishes a word, also add a space so you can " + - "keep typing. Skipped when it already ends in punctuation or a space.", - systemImage: "space" - ) - } - Toggle(isOn: macroExpansionEnabledBinding) { SettingsRowLabel( title: "Inline Macros", @@ -199,20 +187,6 @@ struct GeneralPaneView: View { ) } - private var autoAcceptTrailingPunctuationBinding: Binding { - Binding( - get: { suggestionSettings.autoAcceptTrailingPunctuation }, - set: { suggestionSettings.setAutoAcceptTrailingPunctuation($0) } - ) - } - - private var addSpaceAfterAcceptBinding: Binding { - Binding( - get: { suggestionSettings.addSpaceAfterAccept }, - set: { suggestionSettings.setAddSpaceAfterAccept($0) } - ) - } - private var macroExpansionEnabledBinding: Binding { Binding( get: { suggestionSettings.isMacroExpansionEnabled }, diff --git a/Cotabby/UI/Settings/Panes/WritingPaneView.swift b/Cotabby/UI/Settings/Panes/WritingPaneView.swift index 8d5874b3..b79527df 100644 --- a/Cotabby/UI/Settings/Panes/WritingPaneView.swift +++ b/Cotabby/UI/Settings/Panes/WritingPaneView.swift @@ -45,6 +45,28 @@ struct WritingPaneView: View { } } + // What an accept inserts beyond the bare word. These shape the written output, so they sit + // with Writing rather than General; the accept keys themselves live in the Shortcuts pane. + Section("Acceptance") { + Toggle(isOn: autoAcceptTrailingPunctuationBinding) { + SettingsRowLabel( + title: "Accept Punctuation With Word", + description: "When you accept a word, also accept the punctuation that follows it " + + "(commas, periods) so you don't have to type it.", + systemImage: "textformat.abc" + ) + } + + Toggle(isOn: addSpaceAfterAcceptBinding) { + SettingsRowLabel( + title: "Add Space After Accepting", + description: "When accepting a suggestion finishes a word, also add a space so you can " + + "keep typing. Skipped when it already ends in punctuation or a space.", + systemImage: "space" + ) + } + } + Section("Corrections") { Toggle(isOn: suppressCompletionsOnTypoBinding) { SettingsRowLabel( @@ -128,6 +150,20 @@ struct WritingPaneView: View { ) } + private var autoAcceptTrailingPunctuationBinding: Binding { + Binding( + get: { suggestionSettings.autoAcceptTrailingPunctuation }, + set: { suggestionSettings.setAutoAcceptTrailingPunctuation($0) } + ) + } + + private var addSpaceAfterAcceptBinding: Binding { + Binding( + get: { suggestionSettings.addSpaceAfterAccept }, + set: { suggestionSettings.setAddSpaceAfterAccept($0) } + ) + } + private var suppressCompletionsOnTypoBinding: Binding { Binding( get: { suggestionSettings.suppressCompletionsOnTypo }, diff --git a/Cotabby/UI/Settings/SettingsIndex.swift b/Cotabby/UI/Settings/SettingsIndex.swift index b030b9b2..95c2bf25 100644 --- a/Cotabby/UI/Settings/SettingsIndex.swift +++ b/Cotabby/UI/Settings/SettingsIndex.swift @@ -16,8 +16,6 @@ enum SettingsItem: String, CaseIterable, Identifiable { case includeClipboardContext case includeAppContext case allowMultiLine - case acceptPunctuation - case addSpaceAfterAccept case inlineMacros case onboarding // Appearance @@ -36,6 +34,8 @@ enum SettingsItem: String, CaseIterable, Identifiable { case emojiHistory // Writing case length + case acceptPunctuation + case addSpaceAfterAccept case name case languages case customRules @@ -222,14 +222,14 @@ enum SettingsItem: String, CaseIterable, Identifiable { var category: SettingsCategory { switch self { case .enableGlobally, .fastMode, .openAtLogin, .includeClipboardContext, .includeAppContext, - .allowMultiLine, .acceptPunctuation, .addSpaceAfterAccept, .inlineMacros, .onboarding: + .allowMultiLine, .inlineMacros, .onboarding: return .general case .suggestionDisplay, .streamWhileGenerating, .showFieldIndicator, .showWordCount, .showKeyHint, .ghostTextColor, .ghostTextOpacity, .ghostTextSize: return .appearance case .emojiPicker, .emojiSkinTone, .emojiPeopleStyle, .emojiHistory: return .emoji - case .length, .name, .languages, .customRules, + case .length, .acceptPunctuation, .addSpaceAfterAccept, .name, .languages, .customRules, .hideSuggestionsOnTypo, .offerTypoCorrections, .spellingDictionaries, .automaticallyFixTypos: return .writing case .extendedContext, .contextLivePreview: