diff options
| author | adamdotdevin <[email protected]> | 2025-07-21 05:52:02 -0500 |
|---|---|---|
| committer | adamdotdevin <[email protected]> | 2025-07-21 05:52:11 -0500 |
| commit | 8e8796507d9adcb89341dfe01ec499938611ebea (patch) | |
| tree | a4d503f71eed1280a478b1adaf2037a88594eac3 /packages/tui/internal/attachment | |
| parent | cef5c295834760d9d3a57334f2e52bd528c66e68 (diff) | |
| download | opencode-8e8796507d9adcb89341dfe01ec499938611ebea.tar.gz opencode-8e8796507d9adcb89341dfe01ec499938611ebea.zip | |
feat(tui): message history select with up/down arrows
Diffstat (limited to 'packages/tui/internal/attachment')
| -rw-r--r-- | packages/tui/internal/attachment/attachment.go | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/packages/tui/internal/attachment/attachment.go b/packages/tui/internal/attachment/attachment.go new file mode 100644 index 000000000..178de9954 --- /dev/null +++ b/packages/tui/internal/attachment/attachment.go @@ -0,0 +1,65 @@ +package attachment + +import ( + "github.com/google/uuid" +) + +type FileSource struct { + Path string `toml:"path"` + Mime string `toml:"mime"` + Data []byte `toml:"data,omitempty"` // Optional for image data +} + +type SymbolSource struct { + Path string `toml:"path"` + Name string `toml:"name"` + Kind int `toml:"kind"` + Range SymbolRange `toml:"range"` +} + +type SymbolRange struct { + Start Position `toml:"start"` + End Position `toml:"end"` +} + +type Position struct { + Line int `toml:"line"` + Char int `toml:"char"` +} + +type Attachment struct { + ID string `toml:"id"` + Type string `toml:"type"` + Display string `toml:"display"` + URL string `toml:"url"` + Filename string `toml:"filename"` + MediaType string `toml:"media_type"` + StartIndex int `toml:"start_index"` + EndIndex int `toml:"end_index"` + Source any `toml:"source,omitempty"` +} + +// NewAttachment creates a new attachment with a unique ID +func NewAttachment() *Attachment { + return &Attachment{ + ID: uuid.NewString(), + } +} + +// GetFileSource returns the source as FileSource if the attachment is a file type +func (a *Attachment) GetFileSource() (*FileSource, bool) { + if a.Type != "file" { + return nil, false + } + fs, ok := a.Source.(*FileSource) + return fs, ok +} + +// GetSymbolSource returns the source as SymbolSource if the attachment is a symbol type +func (a *Attachment) GetSymbolSource() (*SymbolSource, bool) { + if a.Type != "symbol" { + return nil, false + } + ss, ok := a.Source.(*SymbolSource) + return ss, ok +} |
