core: sync updates across opencode, sdk, tui, and plugin components

This commit is contained in:
Dax Raad 2025-08-31 20:19:30 -04:00
commit 55cfacc6f4
45 changed files with 937 additions and 318 deletions

View file

@ -101,7 +101,7 @@ type PermissionRespondedToMsg struct {
func New(
ctx context.Context,
version string,
project opencode.Project,
project *opencode.Project,
path *opencode.Path,
agents []opencode.Agent,
httpClient *opencode.Client,
@ -113,7 +113,7 @@ func New(
util.RootPath = project.Worktree
util.CwdPath, _ = os.Getwd()
configInfo, err := httpClient.Config.Get(ctx)
configInfo, err := httpClient.Config.Get(ctx, opencode.ConfigGetParams{})
if err != nil {
return nil, err
}
@ -188,13 +188,13 @@ func New(
slog.Debug("Loaded config", "config", configInfo)
customCommands, err := httpClient.Command.List(ctx)
customCommands, err := httpClient.Command.List(ctx, opencode.CommandListParams{})
if err != nil {
return nil, err
}
app := &App{
Project: project,
Project: *project,
Agents: agents,
Version: version,
StatePath: appStatePath,
@ -460,7 +460,7 @@ func findProviderByID(providers []opencode.Provider, providerID string) *opencod
}
func (a *App) InitializeProvider() tea.Cmd {
providersResponse, err := a.Client.App.Providers(context.Background())
providersResponse, err := a.Client.App.Providers(context.Background(), opencode.AppProvidersParams{})
if err != nil {
slog.Error("Failed to list providers", "error", err)
// TODO: notify user
@ -879,7 +879,7 @@ func (a *App) Cancel(ctx context.Context, sessionID string) error {
a.compactCancel = nil
}
_, err := a.Client.Session.Abort(ctx, sessionID)
_, err := a.Client.Session.Abort(ctx, sessionID, opencode.SessionAbortParams{})
if err != nil {
slog.Error("Failed to cancel session", "error", err)
return err
@ -888,7 +888,7 @@ func (a *App) Cancel(ctx context.Context, sessionID string) error {
}
func (a *App) ListSessions(ctx context.Context) ([]opencode.Session, error) {
response, err := a.Client.Session.List(ctx)
response, err := a.Client.Session.List(ctx, opencode.SessionListParams{})
if err != nil {
return nil, err
}
@ -900,7 +900,7 @@ func (a *App) ListSessions(ctx context.Context) ([]opencode.Session, error) {
}
func (a *App) DeleteSession(ctx context.Context, sessionID string) error {
_, err := a.Client.Session.Delete(ctx, sessionID)
_, err := a.Client.Session.Delete(ctx, sessionID, opencode.SessionDeleteParams{})
if err != nil {
slog.Error("Failed to delete session", "error", err)
return err
@ -920,7 +920,7 @@ func (a *App) UpdateSession(ctx context.Context, sessionID string, title string)
}
func (a *App) ListMessages(ctx context.Context, sessionId string) ([]Message, error) {
response, err := a.Client.Session.Messages(ctx, sessionId)
response, err := a.Client.Session.Messages(ctx, sessionId, opencode.SessionMessagesParams{})
if err != nil {
return nil, err
}
@ -942,7 +942,7 @@ func (a *App) ListMessages(ctx context.Context, sessionId string) ([]Message, er
}
func (a *App) ListProviders(ctx context.Context) ([]opencode.Provider, error) {
response, err := a.Client.App.Providers(ctx)
response, err := a.Client.App.Providers(ctx, opencode.AppProvidersParams{})
if err != nil {
return nil, err
}

View file

@ -32,6 +32,7 @@ func (cg *agentsContextGroup) GetChildEntries(
agents, err := cg.app.Client.Agent.List(
context.Background(),
opencode.AgentListParams{},
)
if err != nil {
slog.Error("Failed to get agent list", "error", err)

View file

@ -29,7 +29,7 @@ func (cg *filesContextGroup) GetEmptyMessage() string {
func (cg *filesContextGroup) getGitFiles() []CompletionSuggestion {
items := make([]CompletionSuggestion, 0)
status, _ := cg.app.Client.File.Status(context.Background())
status, _ := cg.app.Client.File.Status(context.Background(), opencode.FileStatusParams{})
if status != nil {
files := *status
sort.Slice(files, func(i, j int) bool {

View file

@ -769,6 +769,7 @@ func (m *messagesComponent) renderView() tea.Cmd {
context.Background(),
m.app.CurrentPermission.SessionID,
m.app.CurrentPermission.MessageID,
opencode.SessionMessageParams{},
)
if err != nil || response == nil {
slog.Error("Failed to get message from child session", "error", err)
@ -1238,6 +1239,7 @@ func (m *messagesComponent) RedoLastMessage() (tea.Model, tea.Cmd) {
response, err := m.app.Client.Session.Unrevert(
context.Background(),
m.app.Session.ID,
opencode.SessionUnrevertParams{},
)
if err != nil {
slog.Error("Failed to unrevert session", "error", err)

View file

@ -393,7 +393,7 @@ func (a Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
a.showCompletionDialog = false
// If we're in a child session, switch back to parent before sending prompt
if a.app.Session.ParentID != "" {
parentSession, err := a.app.Client.Session.Get(context.Background(), a.app.Session.ParentID)
parentSession, err := a.app.Client.Session.Get(context.Background(), a.app.Session.ParentID, opencode.SessionGetParams{})
if err != nil {
slog.Error("Failed to get parent session", "error", err)
return a, toast.NewErrorToast("Failed to get parent session")
@ -411,7 +411,7 @@ func (a Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case app.SendCommand:
// If we're in a child session, switch back to parent before sending prompt
if a.app.Session.ParentID != "" {
parentSession, err := a.app.Client.Session.Get(context.Background(), a.app.Session.ParentID)
parentSession, err := a.app.Client.Session.Get(context.Background(), a.app.Session.ParentID, opencode.SessionGetParams{})
if err != nil {
slog.Error("Failed to get parent session", "error", err)
return a, toast.NewErrorToast("Failed to get parent session")
@ -429,7 +429,7 @@ func (a Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case app.SendShell:
// If we're in a child session, switch back to parent before sending prompt
if a.app.Session.ParentID != "" {
parentSession, err := a.app.Client.Session.Get(context.Background(), a.app.Session.ParentID)
parentSession, err := a.app.Client.Session.Get(context.Background(), a.app.Session.ParentID, opencode.SessionGetParams{})
if err != nil {
slog.Error("Failed to get parent session", "error", err)
return a, toast.NewErrorToast("Failed to get parent session")
@ -676,7 +676,7 @@ func (a Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if nextMessageID == "" {
// Last message - use unrevert to restore full conversation
response, err = a.app.Client.Session.Unrevert(context.Background(), a.app.Session.ID)
response, err = a.app.Client.Session.Unrevert(context.Background(), a.app.Session.ID, opencode.SessionUnrevertParams{})
} else {
// Revert to next message to make target the last visible
response, err = a.app.Client.Session.Revert(context.Background(), a.app.Session.ID,
@ -1185,7 +1185,7 @@ func (a Model) executeCommand(command commands.Command) (tea.Model, tea.Cmd) {
if a.app.Session.ID == "" {
return a, nil
}
response, err := a.app.Client.Session.Share(context.Background(), a.app.Session.ID)
response, err := a.app.Client.Session.Share(context.Background(), a.app.Session.ID, opencode.SessionShareParams{})
if err != nil {
slog.Error("Failed to share session", "error", err)
return a, toast.NewErrorToast("Failed to share session")
@ -1197,7 +1197,7 @@ func (a Model) executeCommand(command commands.Command) (tea.Model, tea.Cmd) {
if a.app.Session.ID == "" {
return a, nil
}
_, err := a.app.Client.Session.Unshare(context.Background(), a.app.Session.ID)
_, err := a.app.Client.Session.Unshare(context.Background(), a.app.Session.ID, opencode.SessionUnshareParams{})
if err != nil {
slog.Error("Failed to unshare session", "error", err)
return a, toast.NewErrorToast("Failed to unshare session")
@ -1225,7 +1225,7 @@ func (a Model) executeCommand(command commands.Command) (tea.Model, tea.Cmd) {
var parentSession *opencode.Session
if a.app.Session.ParentID != "" {
parentSessionID = a.app.Session.ParentID
session, err := a.app.Client.Session.Get(context.Background(), parentSessionID)
session, err := a.app.Client.Session.Get(context.Background(), parentSessionID, opencode.SessionGetParams{})
if err != nil {
slog.Error("Failed to get parent session", "error", err)
return toast.NewErrorToast("Failed to get parent session")
@ -1235,7 +1235,7 @@ func (a Model) executeCommand(command commands.Command) (tea.Model, tea.Cmd) {
parentSession = a.app.Session
}
children, err := a.app.Client.Session.Children(context.Background(), parentSessionID)
children, err := a.app.Client.Session.Children(context.Background(), parentSessionID, opencode.SessionChildrenParams{})
if err != nil {
slog.Error("Failed to get session children", "error", err)
return toast.NewErrorToast("Failed to get session children")
@ -1283,7 +1283,7 @@ func (a Model) executeCommand(command commands.Command) (tea.Model, tea.Cmd) {
var parentSession *opencode.Session
if a.app.Session.ParentID != "" {
parentSessionID = a.app.Session.ParentID
session, err := a.app.Client.Session.Get(context.Background(), parentSessionID)
session, err := a.app.Client.Session.Get(context.Background(), parentSessionID, opencode.SessionGetParams{})
if err != nil {
slog.Error("Failed to get parent session", "error", err)
return toast.NewErrorToast("Failed to get parent session")
@ -1293,7 +1293,7 @@ func (a Model) executeCommand(command commands.Command) (tea.Model, tea.Cmd) {
parentSession = a.app.Session
}
children, err := a.app.Client.Session.Children(context.Background(), parentSessionID)
children, err := a.app.Client.Session.Children(context.Background(), parentSessionID, opencode.SessionChildrenParams{})
if err != nil {
slog.Error("Failed to get session children", "error", err)
return toast.NewErrorToast("Failed to get session children")