Skip to content

Commit dce4585

Browse files
authored
Fix / Improve Github Eyes Reaction Removal (#5383)
1 parent 5e7d908 commit dce4585

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

packages/opencode/src/cli/cmd/github.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ type IssueQueryResponse = {
124124
}
125125
}
126126

127+
const AGENT_USERNAME = "opencode-agent[bot]"
128+
const AGENT_REACTION = "eyes"
127129
const WORKFLOW_FILE = ".github/workflows/opencode.yml"
128130

129131
export const GithubCommand = cmd({
@@ -422,7 +424,7 @@ export const GithubRunCommand = cmd({
422424
await configureGit(appToken)
423425
await assertPermissions()
424426

425-
await addReaction("eyes")
427+
await addReaction()
426428

427429
// Setup opencode session
428430
const repoData = await fetchRepo()
@@ -812,8 +814,8 @@ export const GithubRunCommand = cmd({
812814

813815
await $`git config --local --unset-all ${config}`
814816
await $`git config --local ${config} "AUTHORIZATION: basic ${newCredentials}"`
815-
await $`git config --global user.name "opencode-agent[bot]"`
816-
await $`git config --global user.email "opencode-agent[bot]@users.noreply.github.com"`
817+
await $`git config --global user.name "${AGENT_USERNAME}"`
818+
await $`git config --global user.email "${AGENT_USERNAME}@users.noreply.github.com"`
817819
}
818820

819821
async function restoreGitConfig() {
@@ -935,13 +937,13 @@ Co-authored-by: ${actor} <${actor}@users.noreply.github.com>"`
935937
if (!["admin", "write"].includes(permission)) throw new Error(`User ${actor} does not have write permissions`)
936938
}
937939

938-
async function addReaction(reaction: "eyes") {
940+
async function addReaction() {
939941
console.log("Adding reaction...")
940942
return await octoRest.rest.reactions.createForIssueComment({
941943
owner,
942944
repo,
943945
comment_id: triggerCommentId,
944-
content: reaction,
946+
content: AGENT_REACTION,
945947
})
946948
}
947949

@@ -951,9 +953,10 @@ Co-authored-by: ${actor} <${actor}@users.noreply.github.com>"`
951953
owner,
952954
repo,
953955
comment_id: triggerCommentId,
956+
content: AGENT_REACTION,
954957
})
955958

956-
const eyesReaction = reactions.data.find((r) => r.content === "eyes")
959+
const eyesReaction = reactions.data.find((r) => r.user?.login === AGENT_USERNAME)
957960
if (!eyesReaction) return
958961

959962
await octoRest.rest.reactions.deleteForIssueComment({

0 commit comments

Comments
 (0)