Revert "feat(comments): since-delta new-comment hint + default-on comment ses…" (#3455)

This reverts commit 5e78e5100a.
This commit is contained in:
Naiyuan Qing
2026-05-28 17:52:59 +08:00
committed by GitHub
parent 372a330707
commit d90732750f
17 changed files with 109 additions and 464 deletions

View File

@@ -1403,31 +1403,6 @@ func (q *Queries) GetLastTaskSession(ctx context.Context, arg GetLastTaskSession
return i, err
}
const getLastTaskStartedAtForIssueAndAgent = `-- name: GetLastTaskStartedAtForIssueAndAgent :one
SELECT started_at FROM agent_task_queue
WHERE agent_id = $1 AND issue_id = $2 AND started_at IS NOT NULL
ORDER BY started_at DESC
LIMIT 1
`
type GetLastTaskStartedAtForIssueAndAgentParams struct {
AgentID pgtype.UUID `json:"agent_id"`
IssueID pgtype.UUID `json:"issue_id"`
}
// Returns the started_at of the most recent prior task for this (agent, issue)
// pair, used as the "since" anchor for counting comments that arrived since the
// agent's last run. Any terminal state counts as "a run happened". Tasks with
// no started_at (never dispatched / the just-claimed current task) are excluded,
// so this never returns the current claim's own row. MUST use started_at, never
// completed_at: a long run would otherwise miss comments posted while it ran.
func (q *Queries) GetLastTaskStartedAtForIssueAndAgent(ctx context.Context, arg GetLastTaskStartedAtForIssueAndAgentParams) (pgtype.Timestamptz, error) {
row := q.db.QueryRow(ctx, getLastTaskStartedAtForIssueAndAgent, arg.AgentID, arg.IssueID)
var started_at pgtype.Timestamptz
err := row.Scan(&started_at)
return started_at, err
}
const getLatestTaskIsLeaderForIssueAndAgent = `-- name: GetLatestTaskIsLeaderForIssueAndAgent :one
SELECT is_leader_task FROM agent_task_queue
WHERE issue_id = $1 AND agent_id = $2

View File

@@ -28,37 +28,6 @@ func (q *Queries) CountComments(ctx context.Context, arg CountCommentsParams) (i
return count, err
}
const countNewCommentsSince = `-- name: CountNewCommentsSince :one
SELECT count(*) FROM comment
WHERE issue_id = $1
AND workspace_id = $2
AND created_at > $3
AND NOT (author_type = 'agent' AND author_id = $4)
`
type CountNewCommentsSinceParams struct {
IssueID pgtype.UUID `json:"issue_id"`
WorkspaceID pgtype.UUID `json:"workspace_id"`
Since pgtype.Timestamptz `json:"since"`
AuthorID pgtype.UUID `json:"author_id"`
}
// Counts comments on an issue created strictly after @since, excluding any
// authored by the given agent (@author_id). Feeds the daemon claim response so
// a comment-triggered task can tell the agent how many comments arrived since
// its last run on this issue, without shipping their bodies.
func (q *Queries) CountNewCommentsSince(ctx context.Context, arg CountNewCommentsSinceParams) (int64, error) {
row := q.db.QueryRow(ctx, countNewCommentsSince,
arg.IssueID,
arg.WorkspaceID,
arg.Since,
arg.AuthorID,
)
var count int64
err := row.Scan(&count)
return count, err
}
const createComment = `-- name: CreateComment :one
INSERT INTO comment (issue_id, workspace_id, author_type, author_id, content, type, parent_id)
VALUES ($1, $2, $3, $4, $5, $6, $7)

View File

@@ -389,18 +389,6 @@ WHERE agent_id = $1 AND issue_id = $2
ORDER BY COALESCE(completed_at, started_at, dispatched_at, created_at) DESC
LIMIT 1;
-- name: GetLastTaskStartedAtForIssueAndAgent :one
-- Returns the started_at of the most recent prior task for this (agent, issue)
-- pair, used as the "since" anchor for counting comments that arrived since the
-- agent's last run. Any terminal state counts as "a run happened". Tasks with
-- no started_at (never dispatched / the just-claimed current task) are excluded,
-- so this never returns the current claim's own row. MUST use started_at, never
-- completed_at: a long run would otherwise miss comments posted while it ran.
SELECT started_at FROM agent_task_queue
WHERE agent_id = $1 AND issue_id = $2 AND started_at IS NOT NULL
ORDER BY started_at DESC
LIMIT 1;
-- name: FailAgentTask :one
-- Marks a task as failed. session_id and work_dir are merged via COALESCE so
-- if the agent already established a real session before failing (e.g. it

View File

@@ -201,17 +201,6 @@ ORDER BY p.last_activity_at ASC, p.root_id ASC, c.created_at ASC, c.id ASC;
SELECT count(*) FROM comment
WHERE issue_id = $1 AND workspace_id = $2;
-- name: CountNewCommentsSince :one
-- Counts comments on an issue created strictly after @since, excluding any
-- authored by the given agent (@author_id). Feeds the daemon claim response so
-- a comment-triggered task can tell the agent how many comments arrived since
-- its last run on this issue, without shipping their bodies.
SELECT count(*) FROM comment
WHERE issue_id = @issue_id
AND workspace_id = @workspace_id
AND created_at > @since
AND NOT (author_type = 'agent' AND author_id = @author_id);
-- name: GetComment :one
SELECT * FROM comment
WHERE id = $1;