Derive trigger timestamps for issues and pull_request events (#1592)

* Derive trigger timestamps for issues and pull_request events

For issues labeled/assigned triggers, look up the matching event in the
issue's event history to get the exact time of the label/assignment,
falling back to the payload's updated_at/created_at when the lookup
fails. issues opened uses issue.created_at; pull_request opened uses
pull_request.created_at and other pull_request actions use updated_at.

* Ignore issue label/assign events older than the payload snapshot

A matching labeled/assigned event that predates the webhook payload's
issue.updated_at cannot be the event that fired the webhook, so fall
back to the payload timestamps instead of adopting it as the boundary.
This commit is contained in:
Ashwin Bhat
2026-08-03 19:15:50 -07:00
committed by GitHub
parent 86180fa9e4
commit b2963b9127
4 changed files with 520 additions and 6 deletions
+7 -1
View File
@@ -140,7 +140,7 @@ export const mockIssueOpenedContext: ParsedGitHubContext = {
body: "## Description\n\nThe application crashes immediately after launching.\n\n## Steps to reproduce\n\n1. Install the app\n2. Launch it\n3. See crash\n\n/claude please help me fix this",
assignee: null,
created_at: "2024-01-15T10:30:00Z",
updated_at: "2024-01-15T10:30:00Z",
updated_at: "2024-01-15T10:35:00Z",
html_url: "https://github.com/test-owner/test-repo/issues/42",
user: {
login: "john-doe",
@@ -191,6 +191,8 @@ export const mockIssueAssignedContext: ParsedGitHubContext = {
avatar_url: "https://avatars.githubusercontent.com/u/11111",
html_url: "https://github.com/claude-bot",
},
created_at: "2024-01-15T09:00:00Z",
updated_at: "2024-01-15T11:00:00Z",
},
repository: {
name: "test-repo",
@@ -225,6 +227,8 @@ export const mockIssueLabeledContext: ParsedGitHubContext = {
html_url: "https://github.com/alice-wonder",
},
assignee: null,
created_at: "2024-01-15T09:30:00Z",
updated_at: "2024-01-15T11:30:00Z",
},
label: {
id: 987654321,
@@ -355,6 +359,8 @@ export const mockPullRequestOpenedContext: ParsedGitHubContext = {
avatar_url: "https://avatars.githubusercontent.com/u/55555",
html_url: "https://github.com/feature-developer",
},
created_at: "2024-01-15T14:00:00Z",
updated_at: "2024-01-15T14:05:00Z",
},
repository: {
name: "test-repo",