diff options
| author | plyght <[email protected]> | 2025-07-21 17:31:29 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-21 10:31:29 -0500 |
| commit | 4b2e52c834680301556ad103f7cd885071b8df6e (patch) | |
| tree | 6e8cac5cbde5a9590b3fef4cee6cfe28cfbf3922 /packages/tui/internal/app | |
| parent | 6867658c0ff7b6d9d1d167ff8394c135b740877c (diff) | |
| download | opencode-4b2e52c834680301556ad103f7cd885071b8df6e.tar.gz opencode-4b2e52c834680301556ad103f7cd885071b8df6e.zip | |
feat(tui): paste minimizing (#784)
Co-authored-by: adamdotdevin <[email protected]>
Diffstat (limited to 'packages/tui/internal/app')
| -rw-r--r-- | packages/tui/internal/app/prompt.go | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/packages/tui/internal/app/prompt.go b/packages/tui/internal/app/prompt.go index dcd0b97fa..158951d84 100644 --- a/packages/tui/internal/app/prompt.go +++ b/packages/tui/internal/app/prompt.go @@ -25,12 +25,32 @@ func (p Prompt) ToMessage( Created: float64(time.Now().UnixMilli()), }, } + + text := p.Text + textAttachments := []*attachment.Attachment{} + for _, attachment := range p.Attachments { + if attachment.Type == "text" { + textAttachments = append(textAttachments, attachment) + } + } + for i := 0; i < len(textAttachments)-1; i++ { + for j := i + 1; j < len(textAttachments); j++ { + if textAttachments[i].StartIndex < textAttachments[j].StartIndex { + textAttachments[i], textAttachments[j] = textAttachments[j], textAttachments[i] + } + } + } + for _, att := range textAttachments { + source, _ := att.GetTextSource() + text = text[:att.StartIndex] + source.Value + text[att.EndIndex:] + } + parts := []opencode.PartUnion{opencode.TextPart{ ID: id.Ascending(id.Part), MessageID: messageID, SessionID: sessionID, Type: opencode.TextPartTypeText, - Text: p.Text, + Text: text, }} for _, attachment := range p.Attachments { text := opencode.FilePartSourceText{ @@ -40,6 +60,8 @@ func (p Prompt) ToMessage( } var source *opencode.FilePartSource switch attachment.Type { + case "text": + continue case "file": fileSource, _ := attachment.GetFileSource() source = &opencode.FilePartSource{ |
