[BUG] Automatic goal sync skips goal.completed webhooks

Open
#4,073 2 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@Dhruvdesai793 is already working on this.

Since Dec 3, 2026.

  • #4079 by @Dhruvdesai793 — open

Assessment

This issue has not been assessed yet.

Description

bug needs-triage status:assigned
What happened?

Activity-derived goals can reach their target during automatic GitHub sync without dispatching the configured goal.completed webhook. src/lib/goals-sync.ts updates progress but does not detect the incomplete-to-complete transition or dispatch the event. The manual goal PATCH route dispatches completion notifications, but activity-derived progress is updated through /api/goals/sync and the cron route, so subscribers receive no completion event.

Expected: Completing an activity-derived goal through sync emits the same goal.completed event as a manual completion.

Proposed solution: Compare the stored and newly synced progress against the target, dispatch on the first incomplete-to-complete transition, and make repeated syncs idempotent. Add tests for a sync that reaches the target and a repeat sync that must not duplicate the event.

Steps to reproduce
  1. Configure a webhook subscription for goal.completed.
  2. Create an activity-derived goal with a target of one commit.
  3. Record matching GitHub activity and run goal sync (or wait for the cron sync).
  4. Observe that goal progress reaches the target but no completion webhook is sent.
Where is it?

Goals

Where did you see it?

Local development

Browser and device

Not browser-specific: server-side sync/webhook behavior. Local development on Linux x86_64, Node v26.13.1, Vitest 4.1.12.

Screenshots, console errors or logs

No screenshot applies to this server-side behavior. Validation: ./node_modules/.bin/tsc --noEmit completed successfully. Focused existing tests ./node_modules/.bin/vitest run test/goals-sync-lib.test.ts test/weekly-summary-combined.test.ts --reporter=dot passed (2 files, 28 tests), but do not assert webhook dispatch when automatic sync crosses the target. Full ./node_modules/.bin/vitest run: 3,405 passed, 54 failed; all failures were six component suites where JSDOM lacked localStorage, unrelated to goal sync. The sync transition/webhook regression described above is not currently covered.

Want to fix it?
  • I'd like to work on this. A maintainer will assign you; please don't start before that.
Dominant language
TypeScript
Stars
246
Forks
436
Avg merge
9h 33m
Merged PRs (30d)
213

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Priyanshu-byte-coder/devtrack

All issues in Priyanshu-byte-coder/devtrack

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.