chore: consolidate chat page into tui.go

This commit is contained in:
adamdottv 2025-06-17 07:09:04 -05:00
commit a5da5127fa
No known key found for this signature in database
GPG key ID: 9CB48779AF150E75
17 changed files with 236 additions and 372 deletions

View file

@ -11,7 +11,6 @@ import (
tea "github.com/charmbracelet/bubbletea/v2"
"github.com/sst/opencode/internal/commands"
"github.com/sst/opencode/internal/config"
"github.com/sst/opencode/internal/state"
"github.com/sst/opencode/internal/theme"
"github.com/sst/opencode/internal/util"
"github.com/sst/opencode/pkg/client"
@ -32,6 +31,14 @@ type App struct {
Commands commands.Registry
}
type SessionSelectedMsg = *client.SessionInfo
type ModelSelectedMsg struct {
Provider client.ProviderInfo
Model client.ModelInfo
}
type SessionClearedMsg struct{}
type CompactSessionMsg struct{}
func New(
ctx context.Context,
version string,
@ -118,7 +125,7 @@ func (a *App) InitializeProvider() tea.Cmd {
}
// TODO: handle no provider or model setup, yet
return state.ModelSelectedMsg{
return ModelSelectedMsg{
Provider: *currentProvider,
Model: *currentModel,
}
@ -167,7 +174,7 @@ func (a *App) InitializeProject(ctx context.Context) tea.Cmd {
}
a.Session = session
cmds = append(cmds, util.CmdHandler(state.SessionSelectedMsg(session)))
cmds = append(cmds, util.CmdHandler(SessionSelectedMsg(session)))
go func() {
response, err := a.Client.PostSessionInitialize(ctx, client.PostSessionInitializeJSONRequestBody{
@ -236,7 +243,7 @@ func (a *App) SendChatMessage(ctx context.Context, text string, attachments []At
return nil
}
a.Session = session
cmds = append(cmds, util.CmdHandler(state.SessionSelectedMsg(session)))
cmds = append(cmds, util.CmdHandler(SessionSelectedMsg(session)))
}
// TODO: Handle attachments when API supports them