Simplify codebase per audit of 8b89f14

This commit is contained in:
Ian Gulliver
2026-10-23 15:10:06 -07:00
parent a53b293528
commit b5a72d713b
14 changed files with 361 additions and 820 deletions
+2 -12
View File
@@ -72,28 +72,18 @@ func (s *Store) GetInboxItem(ctx context.Context, id string) (api.InboxItem, err
}
type InboxFilter struct {
ProjectID string
TaskID string
SessionID string
State api.InboxState
TaskID string
State api.InboxState
}
func (s *Store) ListInbox(ctx context.Context, f InboxFilter) ([]api.InboxItem, error) {
where := []string{"state = ?"}
args := []any{string(f.State)}
if f.ProjectID != "" {
where = append(where, "project_id = ?")
args = append(args, f.ProjectID)
}
if f.TaskID != "" {
where = append(where, "task_id = ?")
args = append(args, f.TaskID)
}
if f.SessionID != "" {
where = append(where, "agent_session_id = ?")
args = append(args, f.SessionID)
}
ids, err := queryIDs(ctx, s.db, `SELECT id FROM inbox_items WHERE `+strings.Join(where, " AND ")+` ORDER BY created_at`, args...)
if err != nil {
-18
View File
@@ -41,24 +41,6 @@ func (s *Store) CreateSnapshot(ctx context.Context, snap api.Snapshot, projectID
})
}
func (s *Store) ListSnapshots(ctx context.Context, taskID string) ([]api.Snapshot, error) {
rows, err := s.db.QueryContext(ctx, `SELECT `+snapshotColumns+` FROM snapshots WHERE task_id = ? ORDER BY n`, taskID)
if err != nil {
return nil, err
}
defer rows.Close()
snaps := []api.Snapshot{}
for rows.Next() {
snap, err := scanSnapshot(rows)
if err != nil {
return nil, err
}
snaps = append(snaps, snap)
}
return snaps, rows.Err()
}
func (s *Store) GetSnapshot(ctx context.Context, taskID string, n int) (api.Snapshot, error) {
snap, err := scanSnapshot(s.db.QueryRowContext(ctx, `SELECT `+snapshotColumns+` FROM snapshots WHERE task_id = ? AND n = ?`, taskID, n))
if errors.Is(err, sql.ErrNoRows) {