Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/opencode/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,16 @@ export namespace Config {
.optional(),
})
.optional(),
editor: z
.object({
summary_thresholds: z
.object({
lines: z.number().min(1).optional(),
chars: z.number().min(1).optional(),
})
.optional(),
})
.optional(),
})
.optional(),
})
Expand Down
50 changes: 48 additions & 2 deletions packages/sdk/go/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,14 +693,16 @@ func (r configCommandJSON) RawJSON() string {
}

type ConfigExperimental struct {
Hook ConfigExperimentalHook `json:"hook"`
JSON configExperimentalJSON `json:"-"`
Hook ConfigExperimentalHook `json:"hook"`
Editor ConfigExperimentalEditor `json:"editor"`
JSON configExperimentalJSON `json:"-"`
}

// configExperimentalJSON contains the JSON metadata for the struct
// [ConfigExperimental]
type configExperimentalJSON struct {
Hook apijson.Field
Editor apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
Expand Down Expand Up @@ -782,6 +784,50 @@ func (r configExperimentalHookSessionCompletedJSON) RawJSON() string {
return r.raw
}

type ConfigExperimentalEditor struct {
SummaryThresholds ConfigExperimentalEditorSummaryThresholds `json:"summary_thresholds"`
JSON configExperimentalEditorJSON `json:"-"`
}

// configExperimentalEditorJSON contains the JSON metadata for the struct
// [ConfigExperimentalEditor]
type configExperimentalEditorJSON struct {
SummaryThresholds apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *ConfigExperimentalEditor) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r configExperimentalEditorJSON) RawJSON() string {
return r.raw
}

type ConfigExperimentalEditorSummaryThresholds struct {
Lines int64 `json:"lines"`
Chars int64 `json:"chars"`
JSON configExperimentalEditorSummaryThresholdsJSON `json:"-"`
}

// configExperimentalEditorSummaryThresholdsJSON contains the JSON metadata for the struct
// [ConfigExperimentalEditorSummaryThresholds]
type configExperimentalEditorSummaryThresholdsJSON struct {
Lines apijson.Field
Chars apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *ConfigExperimentalEditorSummaryThresholds) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r configExperimentalEditorSummaryThresholdsJSON) RawJSON() string {
return r.raw
}

type ConfigFormatter struct {
Command []string `json:"command"`
Disabled bool `json:"disabled"`
Expand Down
6 changes: 6 additions & 0 deletions packages/sdk/js/src/gen/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,12 @@ export type Config = {
}
}>
}
editor?: {
summary_thresholds?: {
lines?: number
chars?: number
}
}
}
}

Expand Down
16 changes: 14 additions & 2 deletions packages/tui/internal/components/chat/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,8 +652,20 @@ func (m *editorComponent) shouldSummarizePastedText(text string) bool {
lineCount := len(lines)
charCount := len(text)

// Consider text long if it has more than 3 lines or more than 150 characters
return lineCount > 3 || charCount > 150
// Default thresholds
linesThreshold := int64(3)
charsThreshold := int64(150)

// Override with config if provided
if m.app.Config != nil && m.app.Config.Experimental.Editor.SummaryThresholds.Lines > 0 {
linesThreshold = m.app.Config.Experimental.Editor.SummaryThresholds.Lines
}
if m.app.Config != nil && m.app.Config.Experimental.Editor.SummaryThresholds.Chars > 0 {
charsThreshold = m.app.Config.Experimental.Editor.SummaryThresholds.Chars
}

// Consider text long if it exceeds the thresholds
return lineCount > int(linesThreshold) || charCount > int(charsThreshold)
}

// handleLongPaste handles long pasted text by creating a summary attachment
Expand Down