summaryrefslogtreecommitdiffhomepage
path: root/internal/tui/page
diff options
context:
space:
mode:
authoradamdottv <[email protected]>2025-05-02 09:24:24 -0500
committerAdam <[email protected]>2025-05-02 15:24:47 -0500
commit49423da081d6fdffb0bd7275e070a2edeb28e3b5 (patch)
tree3119b731ecd46ff8ef3c26d779c0420c7dfe6c9e /internal/tui/page
parent364cf5b429c3dd6952d45c3361765aa3898e6326 (diff)
downloadopencode-49423da081d6fdffb0bd7275e070a2edeb28e3b5.tar.gz
opencode-49423da081d6fdffb0bd7275e070a2edeb28e3b5.zip
feat: compact command with auto-compact
Diffstat (limited to 'internal/tui/page')
-rw-r--r--internal/tui/page/chat.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/tui/page/chat.go b/internal/tui/page/chat.go
index 62a5b9f4f..024974e5c 100644
--- a/internal/tui/page/chat.go
+++ b/internal/tui/page/chat.go
@@ -2,10 +2,12 @@ package page
import (
"context"
+ "fmt"
"github.com/charmbracelet/bubbles/key"
tea "github.com/charmbracelet/bubbletea"
"github.com/opencode-ai/opencode/internal/app"
+ "github.com/opencode-ai/opencode/internal/logging"
"github.com/opencode-ai/opencode/internal/session"
"github.com/opencode-ai/opencode/internal/tui/components/chat"
"github.com/opencode-ai/opencode/internal/tui/layout"
@@ -64,6 +66,22 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
}
p.session = msg
+ case chat.CompactSessionMsg:
+ if p.session.ID == "" {
+ return p, util.ReportWarn("No active session to compact.")
+ }
+
+ // Run compaction in background
+ go func(sessionID string) {
+ err := p.app.CoderAgent.CompactSession(context.Background(), sessionID)
+ if err != nil {
+ logging.ErrorPersist(fmt.Sprintf("Compaction failed: %v", err))
+ } else {
+ logging.InfoPersist("Conversation compacted successfully.")
+ }
+ }(p.session.ID)
+
+ return p, nil
case tea.KeyMsg:
switch {
case key.Matches(msg, keyMap.NewSession):