refactor: remove progress field from TaskSession and AgentExecution (#75)

This commit is contained in:
João Salavisa
2026-01-23 17:37:16 +00:00
committed by GitHub
parent 9d34c63202
commit 9af9b7e008
16 changed files with 21 additions and 58 deletions
@@ -42,7 +42,6 @@ func (c *Controller) ListAgents(ctx context.Context, req dto.ListAgentsRequest)
AgentProfileID: a.AgentProfileID,
ContainerID: a.ContainerID,
Status: string(a.Status),
Progress: a.Progress,
StartedAt: a.StartedAt,
FinishedAt: a.FinishedAt,
ExitCode: a.ExitCode,
@@ -96,7 +95,6 @@ func (c *Controller) GetAgentStatus(ctx context.Context, req dto.GetAgentStatusR
AgentProfileID: agent.AgentProfileID,
ContainerID: agent.ContainerID,
Status: string(agent.Status),
Progress: agent.Progress,
StartedAt: agent.StartedAt,
FinishedAt: agent.FinishedAt,
ExitCode: agent.ExitCode,
-3
View File
@@ -13,7 +13,6 @@ type AgentDTO struct {
AgentProfileID string `json:"agent_profile_id"`
ContainerID string `json:"container_id,omitempty"`
Status string `json:"status"`
Progress int `json:"progress"`
StartedAt string `json:"started_at"`
FinishedAt string `json:"finished_at,omitempty"`
ExitCode *int `json:"exit_code,omitempty"`
@@ -96,7 +95,6 @@ func FromAgentExecution(execution *AgentExecutionData) AgentDTO {
AgentProfileID: execution.AgentProfileID,
ContainerID: execution.ContainerID,
Status: execution.Status,
Progress: execution.Progress,
StartedAt: execution.StartedAt.Format("2006-01-02T15:04:05Z"),
}
if execution.FinishedAt != nil && !execution.FinishedAt.IsZero() {
@@ -118,7 +116,6 @@ type AgentExecutionData struct {
AgentProfileID string
ContainerID string
Status string
Progress int
StartedAt time.Time
FinishedAt *time.Time
ExitCode *int
@@ -12,7 +12,6 @@ type AgentEventPayload struct {
Status string `json:"status"`
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
Progress int `json:"progress"`
ErrorMessage string `json:"error_message,omitempty"`
ExitCode *int `json:"exit_code,omitempty"`
}
@@ -42,7 +42,6 @@ func (p *EventPublisher) PublishAgentEvent(ctx context.Context, eventType string
Status: string(execution.Status),
StartedAt: execution.StartedAt,
FinishedAt: execution.FinishedAt,
Progress: execution.Progress,
ErrorMessage: execution.ErrorMessage,
ExitCode: execution.ExitCode,
}
@@ -1510,7 +1510,6 @@ func (m *Manager) MarkCompleted(executionID string, exitCode int, errorMessage s
if exitCode == 0 && errorMessage == "" {
exec.Status = v1.AgentStatusCompleted
exec.Progress = 100
} else {
exec.Status = v1.AgentStatusFailed
}
@@ -287,7 +287,6 @@ func TestManager_MarkCompleted_Success(t *testing.T) {
ContainerID: "container-123",
Status: v1.AgentStatusRunning,
StartedAt: time.Now(),
Progress: 50,
}
mgr.executionStore.Add(execution)
@@ -302,9 +301,6 @@ func TestManager_MarkCompleted_Success(t *testing.T) {
if got.Status != v1.AgentStatusCompleted {
t.Errorf("expected status %v, got %v", v1.AgentStatusCompleted, got.Status)
}
if got.Progress != 100 {
t.Errorf("expected progress 100, got %d", got.Progress)
}
if got.FinishedAt == nil {
t.Error("expected FinishedAt to be set")
}
@@ -109,7 +109,6 @@ func (ri *RuntimeInstance) ToAgentExecution(req *RuntimeCreateRequest) *AgentExe
WorkspacePath: workspacePath,
Status: v1.AgentStatusRunning,
StartedAt: time.Now(),
Progress: 0,
Metadata: metadata,
agentctl: ri.Client,
standaloneInstanceID: ri.StandaloneInstanceID,
@@ -27,13 +27,12 @@ type AgentExecution struct {
WorkspacePath string // Path to the workspace (worktree or repository path)
ACPSessionID string // ACP session ID to resume, if available
AgentCommand string // Command to start the agent subprocess
Status v1.AgentStatus
StartedAt time.Time
FinishedAt *time.Time
ExitCode *int
ErrorMessage string
Progress int
Metadata map[string]interface{}
Status v1.AgentStatus
StartedAt time.Time
FinishedAt *time.Time
ExitCode *int
ErrorMessage string
Metadata map[string]interface{}
// agentctl client for this execution
agentctl *agentctl.Client
@@ -112,7 +112,6 @@ type TaskExecution struct {
AgentProfileID string
StartedAt time.Time
SessionState v1.TaskSessionState
Progress int
LastUpdate time.Time
// SessionID is the database ID of the agent session
SessionID string
@@ -129,7 +128,6 @@ func FromTaskSession(s *models.TaskSession) *TaskExecution {
AgentProfileID: s.AgentProfileID,
StartedAt: s.StartedAt,
SessionState: agentSessionStateToV1(s.State),
Progress: s.Progress,
LastUpdate: s.UpdatedAt,
SessionID: s.ID,
}
@@ -308,7 +306,6 @@ func (e *Executor) ExecuteWithProfile(ctx context.Context, task *v1.Task, agentP
RepositoryID: repositoryID,
BaseBranch: baseBranch,
State: models.TaskSessionStateCreated,
Progress: 0,
StartedAt: now,
UpdatedAt: now,
AgentProfileSnapshot: agentProfileSnapshot,
@@ -355,7 +352,6 @@ func (e *Executor) ExecuteWithProfile(ctx context.Context, task *v1.Task, agentP
session.AgentExecutionID = resp.AgentExecutionID
session.ContainerID = resp.ContainerID
session.State = models.TaskSessionStateStarting
session.Progress = 0
session.ErrorMessage = ""
session.UpdatedAt = time.Now().UTC()
@@ -417,7 +413,6 @@ func (e *Executor) ExecuteWithProfile(ctx context.Context, task *v1.Task, agentP
AgentProfileID: agentProfileID,
StartedAt: now,
SessionState: v1.TaskSessionStateStarting,
Progress: 0,
LastUpdate: now,
SessionID: sessionID,
WorktreePath: resp.WorktreePath,
@@ -584,7 +579,6 @@ func (e *Executor) ResumeSession(ctx context.Context, session *models.TaskSessio
session.AgentExecutionID = resp.AgentExecutionID
session.ContainerID = resp.ContainerID
session.Progress = 0
session.ErrorMessage = ""
if startAgent {
session.State = models.TaskSessionStateStarting
@@ -665,7 +659,6 @@ func (e *Executor) ResumeSession(ctx context.Context, session *models.TaskSessio
AgentProfileID: session.AgentProfileID,
StartedAt: now,
SessionState: v1.TaskSessionStateStarting,
Progress: 0,
LastUpdate: now,
SessionID: session.ID,
WorktreePath: worktreePath,
-2
View File
@@ -135,7 +135,6 @@ type TaskSessionDTO struct {
WorktreePath string `json:"worktree_path,omitempty"`
WorktreeBranch string `json:"worktree_branch,omitempty"`
State models.TaskSessionState `json:"state"`
Progress int `json:"progress"`
ErrorMessage string `json:"error_message,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
AgentProfileSnapshot map[string]interface{} `json:"agent_profile_snapshot,omitempty"`
@@ -408,7 +407,6 @@ func FromTaskSession(session *models.TaskSession) TaskSessionDTO {
RepositoryID: session.RepositoryID,
BaseBranch: session.BaseBranch,
State: session.State,
Progress: session.Progress,
ErrorMessage: session.ErrorMessage,
Metadata: session.Metadata,
AgentProfileSnapshot: session.AgentProfileSnapshot,
@@ -203,7 +203,6 @@ type TaskSession struct {
EnvironmentSnapshot map[string]interface{} `json:"environment_snapshot,omitempty"`
RepositorySnapshot map[string]interface{} `json:"repository_snapshot,omitempty"`
State TaskSessionState `json:"state"`
Progress int `json:"progress"` // 0-100
ErrorMessage string `json:"error_message,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
StartedAt time.Time `json:"started_at"`
@@ -226,7 +225,6 @@ func (s *TaskSession) ToAPI() map[string]interface{} {
"base_branch": s.BaseBranch,
"worktrees": s.Worktrees,
"state": string(s.State),
"progress": s.Progress,
"started_at": s.StartedAt,
"updated_at": s.UpdatedAt,
}
+15 -16
View File
@@ -249,7 +249,6 @@ func (r *sqliteRepository) initSchema() error {
environment_snapshot TEXT DEFAULT '{}',
repository_snapshot TEXT DEFAULT '{}',
state TEXT NOT NULL DEFAULT 'CREATED',
progress INTEGER DEFAULT 0,
error_message TEXT DEFAULT '',
metadata TEXT DEFAULT '{}',
started_at DATETIME NOT NULL,
@@ -1987,12 +1986,12 @@ func (r *sqliteRepository) CreateTaskSession(ctx context.Context, session *model
id, task_id, agent_execution_id, container_id, agent_profile_id, executor_id, environment_id,
repository_id, base_branch,
agent_profile_snapshot, executor_snapshot, environment_snapshot, repository_snapshot,
state, progress, error_message, metadata, started_at, completed_at, updated_at
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
state, error_message, metadata, started_at, completed_at, updated_at
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`, session.ID, session.TaskID, session.AgentExecutionID, session.ContainerID, session.AgentProfileID,
session.ExecutorID, session.EnvironmentID, session.RepositoryID, session.BaseBranch,
string(agentProfileSnapshotJSON), string(executorSnapshotJSON), string(environmentSnapshotJSON), string(repositorySnapshotJSON),
string(session.State), session.Progress, session.ErrorMessage, string(metadataJSON),
string(session.State), session.ErrorMessage, string(metadataJSON),
session.StartedAt, session.CompletedAt, session.UpdatedAt)
return err
@@ -2013,14 +2012,14 @@ func (r *sqliteRepository) GetTaskSession(ctx context.Context, id string) (*mode
SELECT id, task_id, agent_execution_id, container_id, agent_profile_id, executor_id, environment_id,
repository_id, base_branch,
agent_profile_snapshot, executor_snapshot, environment_snapshot, repository_snapshot,
state, progress, error_message, metadata, started_at, completed_at, updated_at
state, error_message, metadata, started_at, completed_at, updated_at
FROM task_sessions WHERE id = ?
`, id).Scan(
&session.ID, &session.TaskID, &session.AgentExecutionID, &session.ContainerID, &session.AgentProfileID,
&session.ExecutorID, &session.EnvironmentID,
&session.RepositoryID, &session.BaseBranch,
&agentProfileSnapshotJSON, &executorSnapshotJSON, &environmentSnapshotJSON, &repositorySnapshotJSON,
&state, &session.Progress, &session.ErrorMessage, &metadataJSON, &session.StartedAt, &completedAt, &session.UpdatedAt,
&state, &session.ErrorMessage, &metadataJSON, &session.StartedAt, &completedAt, &session.UpdatedAt,
)
if err == sql.ErrNoRows {
@@ -2084,14 +2083,14 @@ func (r *sqliteRepository) GetTaskSessionByTaskID(ctx context.Context, taskID st
SELECT id, task_id, agent_execution_id, container_id, agent_profile_id, executor_id, environment_id,
repository_id, base_branch,
agent_profile_snapshot, executor_snapshot, environment_snapshot, repository_snapshot,
state, progress, error_message, metadata, started_at, completed_at, updated_at
state, error_message, metadata, started_at, completed_at, updated_at
FROM task_sessions WHERE task_id = ? ORDER BY started_at DESC LIMIT 1
`, taskID).Scan(
&session.ID, &session.TaskID, &session.AgentExecutionID, &session.ContainerID, &session.AgentProfileID,
&session.ExecutorID, &session.EnvironmentID,
&session.RepositoryID, &session.BaseBranch,
&agentProfileSnapshotJSON, &executorSnapshotJSON, &environmentSnapshotJSON, &repositorySnapshotJSON,
&state, &session.Progress, &session.ErrorMessage, &metadataJSON, &session.StartedAt, &completedAt, &session.UpdatedAt,
&state, &session.ErrorMessage, &metadataJSON, &session.StartedAt, &completedAt, &session.UpdatedAt,
)
if err == sql.ErrNoRows {
@@ -2155,7 +2154,7 @@ func (r *sqliteRepository) GetActiveTaskSessionByTaskID(ctx context.Context, tas
SELECT id, task_id, agent_execution_id, container_id, agent_profile_id, executor_id, environment_id,
repository_id, base_branch,
agent_profile_snapshot, executor_snapshot, environment_snapshot, repository_snapshot,
state, progress, error_message, metadata, started_at, completed_at, updated_at
state, error_message, metadata, started_at, completed_at, updated_at
FROM task_sessions
WHERE task_id = ? AND state IN ('CREATED', 'STARTING', 'RUNNING', 'WAITING_FOR_INPUT')
ORDER BY started_at DESC LIMIT 1
@@ -2164,7 +2163,7 @@ func (r *sqliteRepository) GetActiveTaskSessionByTaskID(ctx context.Context, tas
&session.ExecutorID, &session.EnvironmentID,
&session.RepositoryID, &session.BaseBranch,
&agentProfileSnapshotJSON, &executorSnapshotJSON, &environmentSnapshotJSON, &repositorySnapshotJSON,
&state, &session.Progress, &session.ErrorMessage, &metadataJSON, &session.StartedAt, &completedAt, &session.UpdatedAt,
&state, &session.ErrorMessage, &metadataJSON, &session.StartedAt, &completedAt, &session.UpdatedAt,
)
if err == sql.ErrNoRows {
@@ -2243,12 +2242,12 @@ func (r *sqliteRepository) UpdateTaskSession(ctx context.Context, session *model
agent_execution_id = ?, container_id = ?, agent_profile_id = ?, executor_id = ?, environment_id = ?,
repository_id = ?, base_branch = ?,
agent_profile_snapshot = ?, executor_snapshot = ?, environment_snapshot = ?, repository_snapshot = ?,
state = ?, progress = ?, error_message = ?, metadata = ?, completed_at = ?, updated_at = ?
state = ?, error_message = ?, metadata = ?, completed_at = ?, updated_at = ?
WHERE id = ?
`, session.AgentExecutionID, session.ContainerID, session.AgentProfileID, session.ExecutorID, session.EnvironmentID,
session.RepositoryID, session.BaseBranch,
string(agentProfileSnapshotJSON), string(executorSnapshotJSON), string(environmentSnapshotJSON), string(repositorySnapshotJSON),
string(session.State), session.Progress, session.ErrorMessage, string(metadataJSON), session.CompletedAt,
string(session.State), session.ErrorMessage, string(metadataJSON), session.CompletedAt,
session.UpdatedAt, session.ID)
if err != nil {
return err
@@ -2290,7 +2289,7 @@ func (r *sqliteRepository) ListTaskSessions(ctx context.Context, taskID string)
SELECT id, task_id, agent_execution_id, container_id, agent_profile_id, executor_id, environment_id,
repository_id, base_branch,
agent_profile_snapshot, executor_snapshot, environment_snapshot, repository_snapshot,
state, progress, error_message, metadata, started_at, completed_at, updated_at
state, error_message, metadata, started_at, completed_at, updated_at
FROM task_sessions WHERE task_id = ? ORDER BY started_at DESC
`, taskID)
if err != nil {
@@ -2318,7 +2317,7 @@ func (r *sqliteRepository) ListActiveTaskSessions(ctx context.Context) ([]*model
SELECT id, task_id, agent_execution_id, container_id, agent_profile_id, executor_id, environment_id,
repository_id, base_branch,
agent_profile_snapshot, executor_snapshot, environment_snapshot, repository_snapshot,
state, progress, error_message, metadata, started_at, completed_at, updated_at
state, error_message, metadata, started_at, completed_at, updated_at
FROM task_sessions WHERE state IN ('CREATED', 'STARTING', 'RUNNING', 'WAITING_FOR_INPUT') ORDER BY started_at DESC
`)
if err != nil {
@@ -2346,7 +2345,7 @@ func (r *sqliteRepository) ListActiveTaskSessionsByTaskID(ctx context.Context, t
SELECT id, task_id, agent_execution_id, container_id, agent_profile_id, executor_id, environment_id,
repository_id, base_branch,
agent_profile_snapshot, executor_snapshot, environment_snapshot, repository_snapshot,
state, progress, error_message, metadata, started_at, completed_at, updated_at
state, error_message, metadata, started_at, completed_at, updated_at
FROM task_sessions WHERE task_id = ? AND state IN ('CREATED', 'STARTING', 'RUNNING', 'WAITING_FOR_INPUT') ORDER BY started_at DESC
`, taskID)
if err != nil {
@@ -2441,7 +2440,7 @@ func (r *sqliteRepository) scanTaskSessions(ctx context.Context, rows *sql.Rows)
&session.ExecutorID, &session.EnvironmentID,
&session.RepositoryID, &session.BaseBranch,
&agentProfileSnapshotJSON, &executorSnapshotJSON, &environmentSnapshotJSON, &repositorySnapshotJSON,
&state, &session.Progress, &session.ErrorMessage, &metadataJSON, &session.StartedAt, &completedAt, &session.UpdatedAt,
&state, &session.ErrorMessage, &metadataJSON, &session.StartedAt, &completedAt, &session.UpdatedAt,
)
if err != nil {
return nil, err
@@ -784,7 +784,6 @@ func TestSQLiteRepository_TaskSessionCRUD(t *testing.T) {
ExecutorID: "executor-1",
EnvironmentID: "env-1",
State: models.TaskSessionStateStarting,
Progress: 0,
Metadata: map[string]interface{}{"key": "value"},
}
if err := repo.CreateTaskSession(ctx, session); err != nil {
@@ -820,7 +819,6 @@ func TestSQLiteRepository_TaskSessionCRUD(t *testing.T) {
// Update agent session
session.State = models.TaskSessionStateRunning
session.Progress = 50
if err := repo.UpdateTaskSession(ctx, session); err != nil {
t.Fatalf("failed to update agent session: %v", err)
}
@@ -828,9 +826,6 @@ func TestSQLiteRepository_TaskSessionCRUD(t *testing.T) {
if retrieved.State != models.TaskSessionStateRunning {
t.Errorf("expected state 'running', got %s", retrieved.State)
}
if retrieved.Progress != 50 {
t.Errorf("expected progress 50, got %d", retrieved.Progress)
}
// Delete agent session
if err := repo.DeleteTaskSession(ctx, session.ID); err != nil {
@@ -91,7 +91,6 @@ export function useSessionResumption(
id: sessionId,
task_id: taskId,
state: status.state as TaskSessionState,
progress: session?.progress ?? 0,
started_at: session?.started_at ?? '',
updated_at: session?.updated_at ?? '',
});
@@ -125,7 +124,6 @@ export function useSessionResumption(
id: sessionId,
task_id: taskId,
state: resumeResp.state as TaskSessionState,
progress: session?.progress ?? 0,
started_at: session?.started_at ?? '',
updated_at: session?.updated_at ?? '',
});
@@ -185,7 +183,6 @@ export function useSessionResumption(
id: sessionId,
task_id: taskId,
state: response.state as TaskSessionState,
progress: session?.progress ?? 0,
started_at: session?.started_at ?? '',
updated_at: session?.updated_at ?? '',
});
-1
View File
@@ -146,7 +146,6 @@ export type TaskSession = {
worktree_path?: string;
worktree_branch?: string;
state: TaskSessionState;
progress: number;
error_message?: string;
metadata?: Record<string, unknown> | null;
agent_profile_snapshot?: Record<string, unknown> | null;
@@ -31,7 +31,6 @@ export function registerTaskSessionHandlers(store: StoreApi<AppState>): WsHandle
id: sessionId,
task_id: taskId,
state: newState,
progress: 0,
started_at: '',
updated_at: '',
...(agentProfileId ? { agent_profile_id: agentProfileId } : {}),
@@ -47,7 +46,6 @@ export function registerTaskSessionHandlers(store: StoreApi<AppState>): WsHandle
id: sessionId,
task_id: taskId,
state: newState,
progress: 0,
started_at: '',
updated_at: '',
...(agentProfileId ? { agent_profile_id: agentProfileId } : {}),