diff --git a/internal/proto/proto.go b/internal/proto/proto.go index 5d4992ee0da71e1842ed696f1c3b8e05493cf06f..87dafd24abc44dabff608ed6744c17703c244a37 100644 --- a/internal/proto/proto.go +++ b/internal/proto/proto.go @@ -56,7 +56,7 @@ type AgentSession struct { // IsZero checks if the AgentSession is zero-valued. func (a AgentSession) IsZero() bool { - return a == AgentSession{} + return a.ID == "" && !a.IsBusy } // PermissionAction represents an action taken on a permission request. diff --git a/internal/proto/session.go b/internal/proto/session.go index 846ac592017e6ce447c6c6a94535d9317adad7d8..6c7aca7bd8b010d44e39ee582e03edaa7cea5a66 100644 --- a/internal/proto/session.go +++ b/internal/proto/session.go @@ -10,6 +10,14 @@ type Session struct { CompletionTokens int64 `json:"completion_tokens"` SummaryMessageID string `json:"summary_message_id"` Cost float64 `json:"cost"` + Todos []Todo `json:"todos,omitempty"` CreatedAt int64 `json:"created_at"` UpdatedAt int64 `json:"updated_at"` } + +// Todo represents a single todo entry on a session in the proto layer. +type Todo struct { + Content string `json:"content"` + Status string `json:"status"` + ActiveForm string `json:"active_form"` +} diff --git a/internal/server/events.go b/internal/server/events.go index 57536044bcdc9999d92a6fb5431297c19ef2a761..2c1401fe1f6a3e7293d4f983fe7aab7ef770439f 100644 --- a/internal/server/events.go +++ b/internal/server/events.go @@ -135,11 +135,27 @@ func sessionToProto(s session.Session) proto.Session { PromptTokens: s.PromptTokens, CompletionTokens: s.CompletionTokens, Cost: s.Cost, + Todos: todosToProto(s.Todos), CreatedAt: s.CreatedAt, UpdatedAt: s.UpdatedAt, } } +func todosToProto(todos []session.Todo) []proto.Todo { + if len(todos) == 0 { + return nil + } + out := make([]proto.Todo, len(todos)) + for i, t := range todos { + out[i] = proto.Todo{ + Content: t.Content, + Status: string(t.Status), + ActiveForm: t.ActiveForm, + } + } + return out +} + func fileToProto(f history.File) proto.File { return proto.File{ ID: f.ID, diff --git a/internal/workspace/client_workspace.go b/internal/workspace/client_workspace.go index aba4951504c3a7848398980a0ddd870d84d458cb..82fde1c5bbcf8393d854f98ecff6aa2a64fe0de9 100644 --- a/internal/workspace/client_workspace.go +++ b/internal/workspace/client_workspace.go @@ -671,11 +671,27 @@ func protoToSession(s proto.Session) session.Session { PromptTokens: s.PromptTokens, CompletionTokens: s.CompletionTokens, Cost: s.Cost, + Todos: protoToTodos(s.Todos), CreatedAt: s.CreatedAt, UpdatedAt: s.UpdatedAt, } } +func protoToTodos(todos []proto.Todo) []session.Todo { + if len(todos) == 0 { + return nil + } + out := make([]session.Todo, len(todos)) + for i, t := range todos { + out[i] = session.Todo{ + Content: t.Content, + Status: session.TodoStatus(t.Status), + ActiveForm: t.ActiveForm, + } + } + return out +} + func protoToFile(f proto.File) history.File { return history.File{ ID: f.ID, @@ -770,7 +786,23 @@ func sessionToProto(s session.Session) proto.Session { PromptTokens: s.PromptTokens, CompletionTokens: s.CompletionTokens, Cost: s.Cost, + Todos: todosToProto(s.Todos), CreatedAt: s.CreatedAt, UpdatedAt: s.UpdatedAt, } } + +func todosToProto(todos []session.Todo) []proto.Todo { + if len(todos) == 0 { + return nil + } + out := make([]proto.Todo, len(todos)) + for i, t := range todos { + out[i] = proto.Todo{ + Content: t.Content, + Status: string(t.Status), + ActiveForm: t.ActiveForm, + } + } + return out +}