Skip to content
← Public packages

@kentcdodds/sentry-triage

Sentry triage wakes Cole (Grok Bot) per issue: one active wake per repo (lease + queue), loop-safe Discord. Cole may spawn Cursor for isolated repo work.

src/reset-issue.ts

28 lines · 1.0 KB · TypeScript
import { packageStorage } from 'kody:runtime'
import { issueStorageKey } from './shared.ts'
import type { ResetIssueInput, ResetIssueResult } from './types.ts'

/**
 * Maintenance: clear the triage record and claim for one Sentry issue so the
 * next delivery (or a manual re-invocation of the handler) triages it again.
 * Useful after wake failures or when a fix regressed and a fresh Cole wake is
 * wanted. Invoked cross-package via a static `kody:@kentcdodds/sentry-triage` import.
 */
export default async function resetIssue(
	input: ResetIssueInput,
): Promise<ResetIssueResult> {
	const issueId = String(input.issueId ?? '').trim()
	if (!issueId) throw new Error('issueId is required.')
	const storage = packageStorage()
	const key = issueStorageKey(issueId)
	const existing = await storage.get(key)
	await storage.delete(key)
	try {
		await storage.sql(`DELETE FROM triage_claims WHERE issue_id = ?1`, [
			issueId,
		])
	} catch {
		// Claims table may not exist yet; nothing to clear.
	}
	return { ok: true, issueId, hadRecord: existing != null }
}