cotabby icon indicating copy to clipboard operation
cotabby copied to clipboard

Add suggestion acceptance behavior settings

Open FuJacob opened this issue 7 months ago • 2 comments

Problem

Tabby currently has a fixed acceptance policy for how much text is inserted when the user accepts a suggestion. Different users and writing contexts may prefer accepting one word, one phrase/chunk, or the full suggestion.

Goal

Let users configure how much of a suggestion is accepted per accept action.

Proposed Scope

  • Add an acceptance behavior setting with options such as:
    • One word
    • One phrase/chunk
    • Full suggestion
  • Update SuggestionSessionReconciler.nextAcceptanceChunk or equivalent acceptance policy to honor the setting.
  • Keep existing partial-session reconciliation working for all acceptance modes.
  • Surface the setting in Settings and/or the menu bar.
  • Make the default match current behavior unless we intentionally choose a better default.

Acceptance Criteria

  • Users can choose the amount accepted per shortcut press.
  • One-word, chunk, and full-suggestion modes work without breaking session reconciliation.
  • The selected behavior persists across app restarts.
  • The overlay and diagnostics still reflect the remaining suggestion after partial acceptance.
  • Pass-through behavior remains unchanged when no valid suggestion is ready.

Open Questions

  • What exactly should count as a “phrase/chunk”?
  • Should acceptance behavior be global, per app, or per instruction profile?
  • Should full-suggestion acceptance be disabled for very long suggestions?

FuJacob avatar Apr 21 '26 19:04 FuJacob

Hi, interested in picking this up. Wanted to sanity-check the design with you before writing code.

Where things stand

Reading SuggestionSessionReconciler.swift and SuggestionCoordinator+Acceptance.swift, two of the three modes are already wired:

  • Word → acceptCurrentSuggestion() → prepareAcceptance → nextAcceptanceChunk
  • Full → acceptEntireSuggestion() → prepareFullAcceptance

But they're bound to two separate keys (acceptanceKeyCode, fullAcceptKey), not a user-selectable mode on the primary key. So the new work is the phrase path plus a setting that picks the default for the primary accept key.

Proposed shape

Phrase chunker. Add nextAcceptancePhrase(from:autoAcceptTrailingPunctuation:) to the reconciler. It composes over the existing word chunker: keep extending word chunks until one ends in ., !, ?, or \n, or until the tail runs out. Trailing-punctuation policy and the U.S.A. interior-dot case work automatically because nextAcceptanceChunk already handles them.

Setting. AcceptanceGranularity { word, phrase, full } in SuggestionSettingsModel, persisted via UserDefaults, default .word to preserve current behavior. Picker in the Shortcuts section of SettingsView.

Coordinator wiring. acceptCurrentSuggestion() reads the setting and dispatches. acceptEntireSuggestion() keeps using .full regardless, so the dedicated full-accept key stays as a per-press override. prepareAcceptance takes a chunker function parameter, so the word and phrase paths share the same reconciliation. Both produce a valid prefix of remainingText, so session-advance accounting is unchanged.

Tests. Mirrors the 12 existing nextAcceptanceChunk tests; ~7 new cases for sentence boundaries, abbreviations, empty tail, and the autoAcceptTrailingPunctuation: false interaction with phrase mode.

Questions

  1. Phrase boundary: sentence-bounded (.!?\n) reuses the existing trailing-punctuation logic and matches what Copilot and Cursor do. Other options would be comma-clauses or a token-count cap. Preference?
  2. Setting scope: I'd put a single global setting on the primary accept key and keep the existing fullAcceptKey keybind as a per-press override. The issue mentions per-app and per-profile — those touch the rules system, so I was going to leave them for a follow-up. OK with that?

rpickmans avatar May 27 '26 14:05 rpickmans

  1. Yes we can match cursor
  2. Yes leave as follow up

Thanks!! @rpickmans

FuJacob avatar May 28 '26 08:05 FuJacob