From efe305e42431099a5a7605a0ff1b73d34c889b5e Mon Sep 17 00:00:00 2001 From: Sentinent Agent Date: Wed, 29 Apr 2026 03:26:44 +0000 Subject: [PATCH] fix(github): update source_metadata state field instead of signals.status UpdateGitHubIssueState was writing 'open'/'closed' into the signals.status column which is reserved for read/unread/archived workflow state. Instead, update the state key inside the source_metadata JSON using SQLite replace() so the dashboard correctly reflects the open/closed state after toggling. Fixes Sentinent-AI/Sentinent#35 --- services/github.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/services/github.go b/services/github.go index 1eb3608..b20065a 100644 --- a/services/github.go +++ b/services/github.go @@ -733,10 +733,24 @@ func UpdateGitHubIssueState(userID, workspaceID int, repo string, number int, st return fmt.Errorf("GitHub API error: %d - %s", resp.StatusCode, string(respBody)) } - // Update local signal state if it exists + // Update the state field inside source_metadata for the matching signal. + // The previous state is the opposite of the new one. + oldState := "closed" + if state == "closed" { + oldState = "open" + } _, _ = database.DB.Exec( - `UPDATE signals SET status = ? WHERE user_id = ? AND workspace_id = ? AND source_type = 'github' AND source_metadata LIKE ?`, - state, userID, workspaceID, fmt.Sprintf("%%\"number\":%d%%", number), + `UPDATE signals + SET source_metadata = replace(source_metadata, ?, ?), + updated_at = CURRENT_TIMESTAMP + WHERE user_id = ? + AND workspace_id = ? + AND source_type = 'github' + AND source_metadata LIKE ?`, + fmt.Sprintf(`"state":"%s"`, oldState), + fmt.Sprintf(`"state":"%s"`, state), + userID, workspaceID, + fmt.Sprintf(`%%"number":%d%%`, number), ) return nil