Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.
Open
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
14 changes: 13 additions & 1 deletion mods.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,19 @@ func (m *Mods) readFromCache() tea.Cmd {
return modsError{err, "There was an error loading the conversation."}
}

m.appendToOutput(proto.Conversation(messages).String())
content := proto.Conversation(messages).String()

// In raw mode, directly print the content instead of using glamour
if m.Config.Raw {
fmt.Print(content)
return completionOutput{
errh: func(err error) tea.Msg {
return modsError{err: err}
},
}
}

m.appendToOutput(content)
return completionOutput{
errh: func(err error) tea.Msg {
return modsError{err: err}
Expand Down
30 changes: 30 additions & 0 deletions mods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"testing"

"github.com/charmbracelet/mods/internal/cache"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -220,3 +221,32 @@ func TestCutPrompt(t *testing.T) {
})
}
}

func TestReadFromCacheRawMode(t *testing.T) {
newMods := func(t *testing.T) *Mods {
db := testDB(t)
cache, err := cache.NewConversations(t.TempDir())
require.NoError(t, err)
return &Mods{
db: db,
cache: cache,
Config: &Config{},
}
}

t.Run("raw mode should not panic", func(t *testing.T) {
mods := newMods(t)
mods.Config.Raw = true
mods.Config.cacheReadFromID = "test-id"

// This test verifies that the function doesn't panic when called
// with raw mode enabled. Since there's no data in the cache,
// it will return a modsError, which is expected behavior.

msg := mods.readFromCache()()
// Should return either completionOutput (if cache has data) or modsError (if cache is empty)
_, isCompletionOutput := msg.(completionOutput)
_, isModsError := msg.(modsError)
require.True(t, isCompletionOutput || isModsError, "should return completionOutput or modsError")
})
}