Skip to content

feat(integrations): github and slack, plus Linear-quality PR notifications - #36

Merged
pulkitxm merged 9 commits into
mainfrom
feat/s13-integrations
Jul 24, 2026
Merged

pulkitxm merged 9 commits into
mainfrom
feat/s13-integrations

Conversation

@pulkitxm

@pulkitxm pulkitxm commented Jul 23, 2026 •

Copy link
Copy Markdown
Member

Add GitHub and Slack integrations with webhooks, surface pull requests on issues and in an inbox, and send review-requested and approved notifications.

Greptile Summary

This PR adds GitHub and Slack integrations: a webhook handler that applies PR events to issues (state transitions, git links, notifications), a Slack dispatch layer for channel notifications and issue unfurls, an inbox overhaul with tab filtering and a mention badge, and a new Pull Requests view scoped to the current user's issues.

  • GitHub webhook (apps/web/src/app/api/webhooks/github/route.ts): verifies HMAC signatures, deduplicates deliveries by X-GitHub-Delivery, applies events inside a transaction, then publishes realtime actions and dispatches Slack notifications outside the transaction.
  • Slack integration (packages/services/src/slack/dispatch.ts, slack/index.ts): stores a bot token in credentials, resolves per-team channel targets, posts PR notifications, and unfurls Orbit issue links shared in Slack.
  • Inbox + Pulls UI (inbox-view.tsx, pulls-view.tsx): adds All / Unread / Mentions / Pull requests tabs, a separate @ mention badge, and a grouped PR list page with realtime refresh.

Confidence Score: 3/5

The core GitHub event processing is solid and idempotent, but the webhook handler has a gap between transaction commit and delivery acknowledgement that can cause duplicate notifications on retry, and the Slack bot token sits unencrypted in the database.

Two independent gaps lower confidence. First, after the transaction commits notifications to the DB, any exception in the post-transaction Slack or Redis path marks the delivery failed. GitHub's next retry resets the delivery to received and re-runs notifyMany in a new transaction, producing duplicate inbox items for the same PR event. Second, the Slack bot token is stored as plaintext JSON in the credentials column — DB read access, backups, or slow-query logs expose it with no additional protection needed. Both issues are on paths that will be exercised in production the moment GitHub or Redis has a transient error.

apps/web/src/app/api/webhooks/github/route.ts (transaction commit vs. processed status gap) and packages/services/src/slack/dispatch.ts (plaintext bot token in ensureSlackIntegration).

Security Review

  • Plaintext credential storage (packages/services/src/slack/dispatch.ts — ensureSlackIntegration): the Slack bot token is written as { botToken } in the integration.credentials JSON column with no encryption. DB read access, backups, or query logs expose the token directly. A server-side encryption layer (encrypt on write, decrypt on read in resolveSlackContext) would contain the blast radius to processes holding the key.
  • GitHub webhook signature verification uses timingSafeEqual and rejects an absent or empty secret — no bypass path identified.
  • Slack webhook signature verification (verifySlackSignature) is pre-existing and unchanged.
  • teamId in the Slack connect flow is validated against the caller's organization via assertTeamInWorkspace before connectSlackChannel is called.
  • All integration management routes enforce integration:manage permission via assertCan.

Important Files Changed

Filename Overview
apps/web/src/app/api/webhooks/github/route.ts New GitHub webhook handler — signature verification and delivery dedup are solid, but Slack dispatch outside the transaction creates a window where retry reprocessing produces duplicate notifications.
packages/services/src/slack/dispatch.ts Slack targeting, channel connect/disconnect, and unfurl logic are well structured; bot token stored in plaintext JSON is a security concern.
packages/services/src/github/apply.ts Core GitHub event application — idempotent gitLink upsert, correct forward-only state transitions, audience-aware notifications; well tested.
apps/web/src/features/inbox/inbox-view.tsx Tab filtering, mention badge, and delta application are correctly implemented; mentions counter lacks server reconciliation after user actions.
apps/web/src/app/api/integrations/slack/route.ts teamId validated against caller's organization via assertTeamInWorkspace before connectSlackChannel; all actions properly permission-gated.
packages/core/src/realtime/backfill.ts Adds git_link loader for realtime backfill; correctly scopes to issue, team, creator, and optionally assignee.

Sequence Diagram

sequenceDiagram
    participant GH as GitHub
    participant WH as Webhook Handler
    participant DB as Postgres (tx)
    participant Redis
    participant Slack

    GH->>WH: POST /api/webhooks/github (X-GitHub-Delivery)
    WH->>WH: verifyGithubSignature
    WH->>DB: INSERT webhookDelivery (claimed)
    alt duplicate delivery
        WH-->>GH: 200 duplicate
    end
    WH->>DB: BEGIN TRANSACTION
    DB->>DB: applyGithubEvent (upsert gitLink, transition issue)
    DB->>DB: notifyMany (insert notifications)
    DB->>WH: COMMIT — actions + notificationEvents
    WH->>Redis: publish SyncActions
    WH->>DB: resolveSlackContext / resolveSlackTargets
    WH->>Slack: postMessage (PR update text)
    note over WH,Slack: If Slack/Redis throws here, delivery stays "received" → GH retry re-runs notifyMany
    WH->>DB: "UPDATE webhookDelivery SET status=processed"
    WH-->>GH: 200 ok
Loading

Comments Outside Diff (1)

  1. packages/services/src/slack/dispatch.ts, line 1453-1463 (link)

    P1 security Slack bot token written to credentials in plaintext

    ensureSlackIntegration stores { botToken: input.botToken } as plain JSON in the integration.credentials column. Any user or process with read access to the integration table can retrieve the token directly. If DB backups or logs capture this column, the token is leaked. The token arrives from the browser over HTTPS, but at rest it is unprotected.

    Encrypting the value with a server-side key before writing (and decrypting on read in resolveSlackContext) would limit exposure to processes that hold the encryption key rather than anyone who can read the table.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: packages/services/src/slack/dispatch.ts
    Line: 1453-1463
    
    Comment:
    **Slack bot token written to `credentials` in plaintext**
    
    `ensureSlackIntegration` stores `{ botToken: input.botToken }` as plain JSON in the `integration.credentials` column. Any user or process with read access to the `integration` table can retrieve the token directly. If DB backups or logs capture this column, the token is leaked. The token arrives from the browser over HTTPS, but at rest it is unprotected.
    
    Encrypting the value with a server-side key before writing (and decrypting on read in `resolveSlackContext`) would limit exposure to processes that hold the encryption key rather than anyone who can read the table.
    
    How can I resolve this? If you propose a fix, please make it concise.

    Fix in Claude Code

Fix All in Claude Code

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
packages/services/src/slack/dispatch.ts:1453-1463
**Slack bot token written to `credentials` in plaintext**

`ensureSlackIntegration` stores `{ botToken: input.botToken }` as plain JSON in the `integration.credentials` column. Any user or process with read access to the `integration` table can retrieve the token directly. If DB backups or logs capture this column, the token is leaked. The token arrives from the browser over HTTPS, but at rest it is unprotected.

Encrypting the value with a server-side key before writing (and decrypting on read in `resolveSlackContext`) would limit exposure to processes that hold the encryption key rather than anyone who can read the table.

Reviews (4): Last reviewed commit: "fix(notifications): count mentions in th..." | Re-trigger Greptile

pulkitxm added 3 commits July 24, 2026 01:59
…tions

GitHub connects on webhooks: link a repository, verify and receive events, map
pull requests and their reviews to issues, and show the linked PR state on the
issue. Slack connects a channel, unfurls issue links and posts notifications.
Both verify their webhook signatures, GitHub by HMAC and Slack by its signing
secret.

The notification taxonomy now carries the PR events that actually matter, the
ones the product owner called out: review requested, review submitted, approved,
merged and checks failed, alongside the existing issue, comment and mention
events, grouped and filterable like Linear's inbox. A PRs section surfaces the
pull requests linked to a person's work with their review state. Everything
realtime.
# Conflicts:
#	apps/web/src/features/inbox/inbox-view.tsx
…nded streams

Add a git_link loader to the reconnect backfill so catchup covers the new sync
model, restore the integration:manage permission the policy merge dropped, and
keep S4's fine-grained inbox patching while preserving the mentions and pull
request tabs.
@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds GitHub pull-request synchronization and notifications, Slack integration management and unfurl handling, a pull-request viewing experience, and inbox filtering with separate mention unread counts.

Changes

GitHub pull requests

Layer / File(s) Summary
GitHub event processing
packages/services/src/github/*
Normalizes GitHub events, updates linked issues and pull-request records, emits notifications and sync actions, and adds coverage for lifecycle and review transitions.
GitHub webhook delivery
apps/web/src/app/api/webhooks/github/route.ts
Verifies, deduplicates, processes, publishes, and records GitHub webhook deliveries.
Pull-request views
apps/web/src/features/pulls/*, apps/web/src/app/(app)/pulls/page.tsx, apps/web/src/features/issues/issue-detail.tsx
Adds pull-request loading, grouping, state badges, realtime refresh, a pull-request page, and pull requests on issue details.
GitHub synchronization contracts
packages/shared/src/events/sync.ts, packages/core/src/realtime/backfill.ts
Adds git_link to sync validation and realtime backfill.
Navigation and linked pull APIs
apps/web/src/app/api/integrations/git-links/route.ts, apps/web/src/lib/navigation.ts
Adds issue pull-request retrieval and pull-request navigation.

Slack and integration management

Layer / File(s) Summary
Integration contracts
packages/shared/src/validators/integration.ts, packages/shared/src/policy/*
Adds integration payload validators and the integration:manage permission.
Integration settings
apps/web/src/features/settings/*, apps/web/src/app/(app)/settings/integrations/page.tsx
Adds integration settings loading, GitHub and Slack management controls, and settings navigation.
Integration routes
apps/web/src/app/api/integrations/github/route.ts, apps/web/src/app/api/integrations/slack/route.ts
Adds authenticated GitHub repository and Slack installation/channel management endpoints.
Slack dispatch and webhooks
packages/services/src/slack/*, apps/web/src/app/api/webhooks/slack/route.ts
Adds Slack target management, message dispatch, issue unfurls, event schemas, and webhook processing.

Inbox notification filtering

Layer / File(s) Summary
Unread counter data flow
packages/services/src/notifications/*, apps/web/src/features/inbox/data.ts, apps/web/src/features/inbox/inbox-realtime.tsx, apps/web/src/app/(app)/inbox/page.tsx
Computes and propagates separate total and mention unread counts.
Inbox tabs and mention state
apps/web/src/features/inbox/inbox-view.tsx, packages/shared/src/constants/notification.ts
Adds All, Unread, Mentions, and Pull requests tabs with filtered navigation, rendering, badges, and read-state updates.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title matches the main change: GitHub/Slack integrations and PR notifications.
Description check ✅ Passed The description accurately summarizes the GitHub, Slack, inbox, and pull request changes.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/s13-integrations

Comment @coderabbitai help to get the list of available commands.

Comment thread packages/services/src/github/index.ts Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 17

🧹 Nitpick comments (7)
packages/services/src/github/github.test.ts (1)

99-143: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing test coverage for check_suite event normalization.

parseGithubEvent handles three event types but this suite only exercises pull_request and pull_request_review.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/services/src/github/github.test.ts` around lines 99 - 143, The
parseGithubEvent test suite lacks coverage for check_suite normalization. Add a
test in the parseGithubEvent describe block that supplies a representative
check_suite payload and asserts the normalized check-suite event fields, while
preserving the existing pull request, review, and unrelated-event tests.
packages/services/src/github/index.ts (1)

85-85: 📐 Maintainability & Code Quality | 🔵 Trivial

Use top-level z.url() instead of the deprecated .string().url() chain.

Zod 4 deprecated the chained string-format methods in favor of top-level functions; the chained form still works but will be removed in a future major version.

♻️ Proposed fix
-  html_url: z.string().url().max(2048),
+  html_url: z.url().max(2048),

Apply similarly at line 111 (review.html_url).

Also applies to: 111-111

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/services/src/github/index.ts` at line 85, Update the `html_url` and
`review.html_url` schema definitions to use top-level `z.url()` with the
existing maximum-length constraint, removing the deprecated `z.string().url()`
chain while preserving URL validation and the 2048-character limit.
packages/services/src/github/apply.test.ts (2)

232-236: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Fragile assumption: destructured event may not be the asserted pr_approved event.

Line 232 checks .some(...) for pr_approved, but line 233 destructures the first array element and asserts its userIds without confirming it's the same event. If a future change adds another notification event alongside pr_approved (e.g., a generic pr_review_submitted), this test could silently assert against the wrong event.

🧪 Proposed fix
-      expect(result.notificationEvents.some((event) => event.type === 'pr_approved')).toBe(true);
-      const [event] = result.notificationEvents;
+      const event = result.notificationEvents.find((e) => e.type === 'pr_approved');
+      expect(event).toBeDefined();
       expect(event?.userIds).toContain(fixture.creatorId);
       expect(event?.userIds).toContain(fixture.assigneeId);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/services/src/github/apply.test.ts` around lines 232 - 236, Update
the test around the notificationEvents assertions to select the event whose type
is pr_approved before validating userIds, rather than destructuring the first
event. Keep the existing checks for fixture.creatorId and fixture.assigneeId on
that specifically selected approval event.

212-263: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate pull_request_review payload construction across two tests.

The review-event body built for "approved" (lines 215-230) and "changes_requested" (lines 242-257) is nearly identical, differing only in review.state/user. Consider a small helper mirroring prEvent() to reduce duplication and ease future maintenance.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/services/src/github/apply.test.ts` around lines 212 - 263, Extract
the shared pull_request_review payload construction from the two tests into a
small helper, mirroring the existing prEvent() pattern. Parameterize the
differing review state and user data, then use the helper in both approval and
changes_requested test cases while preserving their existing assertions and
event behavior.
apps/web/src/app/api/integrations/github/route.ts (1)

98-133: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Optional: reduce round-trips in ensureIntegration.

The fresh-connect path does select → insert → select. Using .onConflictDoNothing().returning() and only falling back to a select when the returned array is empty would save one query on first connect.

♻️ Proposed refactor
   if (existing !== undefined) return existing.id;

   const id = randomUUIDv7();
-  await db
+  const [inserted] = await db
     .insert(schema.integration)
     .values({ id, organizationId, provider: 'github', externalId, connectedById })
-    .onConflictDoNothing();
-  const [row] = await db
-    .select({ id: schema.integration.id })
-    .from(schema.integration)
-    .where(
-      and(
-        eq(schema.integration.organizationId, organizationId),
-        eq(schema.integration.provider, 'github'),
-        eq(schema.integration.externalId, externalId),
-      ),
-    )
-    .limit(1);
-  return row?.id ?? id;
+    .onConflictDoNothing()
+    .returning({ id: schema.integration.id });
+  if (inserted !== undefined) return inserted.id;
+  const [row] = await db
+    .select({ id: schema.integration.id })
+    .from(schema.integration)
+    .where(
+      and(
+        eq(schema.integration.organizationId, organizationId),
+        eq(schema.integration.provider, 'github'),
+        eq(schema.integration.externalId, externalId),
+      ),
+    )
+    .limit(1);
+  return row?.id ?? id;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/src/app/api/integrations/github/route.ts` around lines 98 - 133,
Optimize ensureIntegration by making the insert return the created integration
ID via onConflictDoNothing().returning(), then return that ID immediately when
insertion succeeds. Only perform the existing lookup after an empty returning
result, preserving the existing-ID path and conflict behavior.
packages/services/src/slack/dispatch.test.ts (1)

63-71: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider adding coverage for ensureSlackIntegration and resolveSlackContext's failure paths.

Only the "happy path" read of resolveSlackContext is tested. Given the correctness concerns raised in dispatch.ts around externalId scoping and defaults, tests for ensureSlackIntegration's upsert behavior and resolveSlackContext returning null/token: null for missing or malformed credentials would help lock down intended behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/services/src/slack/dispatch.test.ts` around lines 63 - 71, Add tests
in the existing Slack dispatch test suite covering ensureSlackIntegration upsert
behavior, including externalId scoping, and resolveSlackContext failure cases.
Verify missing credentials return null and malformed credentials produce the
expected token: null result, while preserving the existing happy-path coverage.
packages/services/src/slack/dispatch.ts (1)

168-195: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Sequential per-item await loops for network/DB fan-out.

dispatchSlackMessage posts to each channel target one at a time, and resolveIssueUnfurls loads each issue one at a time — both could be parallelized (e.g., Promise.allSettled) to cut latency, especially since dispatchSlackMessage is awaited inline in the GitHub webhook handler's request path before it responds.

♻️ Example for dispatchSlackMessage
-  let delivered = 0;
-  for (const target of targets) {
-    try {
-      await client.postMessage({
-        channel: target.channelId,
-        text: input.text,
-        ...(input.blocks === undefined ? {} : { blocks: input.blocks }),
-      });
-      delivered += 1;
-    } catch (error) {
-      console.error('[orbit] slack channel post failed', error);
-    }
-  }
-  return delivered;
+  const results = await Promise.allSettled(
+    targets.map((target) =>
+      client.postMessage({
+        channel: target.channelId,
+        text: input.text,
+        ...(input.blocks === undefined ? {} : { blocks: input.blocks }),
+      }),
+    ),
+  );
+  results
+    .filter((result) => result.status === 'rejected')
+    .forEach((result) => console.error('[orbit] slack channel post failed', result.reason));
+  return results.filter((result) => result.status === 'fulfilled').length;

Also applies to: 239-253

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/services/src/slack/dispatch.ts` around lines 168 - 195, Parallelize
the per-target network work in dispatchSlackMessage and the per-issue loads in
resolveIssueUnfurls instead of awaiting each item sequentially. Use an
all-settled pattern so one failure does not prevent other items from completing,
preserve the existing error handling, and ensure dispatchSlackMessage still
returns the count of successfully delivered messages.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/web/src/app/api/integrations/git-links/route.ts`:
- Line 6: Move the integration query schema currently declared as querySchema
into `@orbit/shared/validators`, export it there using the shared idSchema, and
update the route handler to import and use that shared schema for request
parsing instead of defining a local Zod schema.
- Around line 8-34: Update GET to enforce the shared issue-read policy after
parsing issueId and before querying schema.gitLink. Reuse the repository’s
established policy assertion for the specified issue, while preserving the
existing organization, issue, and pull-request filters.

In `@apps/web/src/app/api/integrations/github/route.ts`:
- Around line 35-96: Update POST and DELETE in
apps/web/src/app/api/integrations/github/route.ts (lines 35-96) and the
corresponding mutation handlers in
apps/web/src/app/api/integrations/slack/route.ts (lines 42-72) to use the shared
mutation pipeline or return SyncActions and publish them. Ensure every direct
mutation of githubRepositorySync, integration, and slackChannelSync bumps
sync_id and invokes publish so realtime subscribers receive repository and
channel mapping changes.
- Around line 41-77: Validate input.teamId belongs to principal.organizationId
before persisting it in the GitHub route’s ensureIntegration/repository mutation
and the Slack route’s corresponding channel mutation; reject cross-workspace
teams. Update both mutations to advance sync_id and publish the appropriate
SyncAction through the existing sync pipeline so realtime clients receive the
changes. Affected sites: apps/web/src/app/api/integrations/github/route.ts lines
41-77 and apps/web/src/app/api/integrations/slack/route.ts lines 57-67; apply
both validations and sync publications at each site.

In `@apps/web/src/app/api/integrations/slack/route.ts`:
- Around line 89-100: Update the Slack API call flow used by PATCH and
SlackClient.listConversations to enforce an AbortSignal timeout around the
underlying SlackClient.call fetch, ensuring stalled requests terminate; if
retries are added, bound their count and preserve the existing validation and
channel response behavior.

In `@apps/web/src/app/api/webhooks/github/route.ts`:
- Around line 26-46: The GitHub webhook deduplication flow must allow retries
for non-processed deliveries and mark failed attempts consistently. Update the
claim logic around the webhookDelivery insert to inspect an existing row’s
status and return “duplicate” only when it is “processed”; reuse or update the
matched delivery record for other statuses. Ensure every early-return failure
path in the handler, including the JSON.parse failure, updates that delivery row
to “failed” before responding.
- Around line 63-70: Update the Slack dispatch block in the webhook route to
build the inbox link through the shared public URL helper from env.ts, using
absoluteUrl or publicAppUrl instead of reading NEXT_PUBLIC_APP_URL or
concatenating a localhost fallback. Preserve the existing organization, team,
and message behavior while passing the helper-generated inbox URL in
outcome.slackText.

In `@apps/web/src/app/api/webhooks/slack/route.ts`:
- Around line 30-31: Update the Slack webhook route’s slackEventSchema usage so
request parsing relies on a Zod schema owned or re-exported by `@orbit/shared`
rather than `@orbit/services`. Relocate or re-export the schema through
`@orbit/shared`, then update the route import while preserving the existing
safeParse validation and response behavior.

In `@apps/web/src/features/inbox/inbox-view.tsx`:
- Around line 161-172: Update InboxView’s realtime patch and snooze/delete
response handling to carry and apply an unread-mention delta or count alongside
unread. Centralize counter reconciliation so every incoming, snoozed, and
deleted update modifies both unread and mentions, while preserving the existing
prop synchronization in the useEffect.

In `@apps/web/src/features/pulls/pulls-view.tsx`:
- Around line 36-43: The pull-list subscription and git-link backfill must use
the same personal pull-update scope contract. In
apps/web/src/features/pulls/pulls-view.tsx lines 36-43, subscribe to the scopes
used for personal pull updates rather than only scopes.user(userId). In
packages/core/src/realtime/backfill.ts lines 477-481, emit recipient user scopes
for the issue assignee and creator, and update the live publisher to use that
same contract.
- Around line 37-48: Replace the router.refresh flow in
apps/web/src/features/pulls/pulls-view.tsx#L37-L48 with a keyed TanStack Query
for the personal pull list, patching or invalidating that query from relevant
notification and git_link deltas without a full route refresh. In
apps/web/src/features/pulls/issue-pull-requests.tsx#L25-L51, replace local fetch
state with a keyed query that exposes request errors and updates the issue
pull-list cache from git_link actions; update both sites using the existing
query keys, fetchers, and shared realtime-cache utilities.

In `@apps/web/src/features/settings/integrations-panel.tsx`:
- Around line 20-32: Replace the raw apiRequest/router.refresh mutation flow in
IntegrationsPanel’s call function with TanStack Query mutations, using
optimistic cache updates for integration changes and invalidating or patching
affected query data without triggering a full router refresh. Preserve existing
error handling through setError and ensure link/unlink repository and Slack
install/connect/disconnect actions all use the shared mutation path.

In `@packages/services/src/github/apply.ts`:
- Around line 158-229: Determine whether the upsert inserted or updated the row
using the database result, not the pre-fetch result in existing. Update the
gitLink insert/upsert return path and buildAction call to expose and use an
insertion indicator, such as a PostgreSQL xmax-based RETURNING expression, so
concurrent deliveries emit exactly one insert action and update actions for
conflicts. Preserve the existing lookup for row identity and state handling.
- Around line 83-94: Update the issue-resolution flow around identifiers and
loadLinkedIssues to also resolve check_suite events through existing gitLink
rows using checks.prNumbers, matching provider GitHub, repository, and PR
number; merge or prefer these linked issues alongside text-extracted identifiers
so already-linked PRs work when branch/title parsing yields none. Preserve the
current identifier-based lookup for events without matching git links.
- Around line 306-355: Gate the review-decision branch in
pullRequestNotification on the appropriate review submission action, so edited
pull_request_review events do not emit repeated pr_approved or
pr_review_submitted notifications. Preserve the existing review decision and
dismissal checks for qualifying review actions, while leaving the
review_requested and lifecycle branches unchanged.

In `@packages/services/src/slack/dispatch.ts`:
- Around line 67-124: Update connectSlackChannel and disconnectSlackChannel to
participate in the existing sync pipeline: bump the relevant syncId and publish
the corresponding SyncAction after their slackChannelSync mutations, matching
the behavior of other mutators in this codebase. If these rows are intentionally
excluded from realtime updates, document that contract instead.
- Around line 24-36: Update resolveSlackContext in
packages/services/src/slack/dispatch.ts to accept a Slack workspace/team id and
add an integration.externalId filter alongside the existing organization and
provider filters. Update the caller in
apps/web/src/app/api/webhooks/slack/route.ts to pass slackTeamId, and apply the
same argument wherever another caller already knows the workspace id.

---

Nitpick comments:
In `@apps/web/src/app/api/integrations/github/route.ts`:
- Around line 98-133: Optimize ensureIntegration by making the insert return the
created integration ID via onConflictDoNothing().returning(), then return that
ID immediately when insertion succeeds. Only perform the existing lookup after
an empty returning result, preserving the existing-ID path and conflict
behavior.

In `@packages/services/src/github/apply.test.ts`:
- Around line 232-236: Update the test around the notificationEvents assertions
to select the event whose type is pr_approved before validating userIds, rather
than destructuring the first event. Keep the existing checks for
fixture.creatorId and fixture.assigneeId on that specifically selected approval
event.
- Around line 212-263: Extract the shared pull_request_review payload
construction from the two tests into a small helper, mirroring the existing
prEvent() pattern. Parameterize the differing review state and user data, then
use the helper in both approval and changes_requested test cases while
preserving their existing assertions and event behavior.

In `@packages/services/src/github/github.test.ts`:
- Around line 99-143: The parseGithubEvent test suite lacks coverage for
check_suite normalization. Add a test in the parseGithubEvent describe block
that supplies a representative check_suite payload and asserts the normalized
check-suite event fields, while preserving the existing pull request, review,
and unrelated-event tests.

In `@packages/services/src/github/index.ts`:
- Line 85: Update the `html_url` and `review.html_url` schema definitions to use
top-level `z.url()` with the existing maximum-length constraint, removing the
deprecated `z.string().url()` chain while preserving URL validation and the
2048-character limit.

In `@packages/services/src/slack/dispatch.test.ts`:
- Around line 63-71: Add tests in the existing Slack dispatch test suite
covering ensureSlackIntegration upsert behavior, including externalId scoping,
and resolveSlackContext failure cases. Verify missing credentials return null
and malformed credentials produce the expected token: null result, while
preserving the existing happy-path coverage.

In `@packages/services/src/slack/dispatch.ts`:
- Around line 168-195: Parallelize the per-target network work in
dispatchSlackMessage and the per-issue loads in resolveIssueUnfurls instead of
awaiting each item sequentially. Use an all-settled pattern so one failure does
not prevent other items from completing, preserve the existing error handling,
and ensure dispatchSlackMessage still returns the count of successfully
delivered messages.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2d9fae1c-d928-4f59-8cde-fc17eac9c937

📥 Commits

Reviewing files that changed from the base of the PR and between d4c7754 and 8bf420a.

📒 Files selected for processing (39)
  • apps/web/src/app/(app)/inbox/page.tsx
  • apps/web/src/app/(app)/pulls/page.tsx
  • apps/web/src/app/(app)/settings/integrations/page.tsx
  • apps/web/src/app/api/integrations/git-links/route.ts
  • apps/web/src/app/api/integrations/github/route.ts
  • apps/web/src/app/api/integrations/slack/route.ts
  • apps/web/src/app/api/webhooks/github/route.ts
  • apps/web/src/app/api/webhooks/slack/route.ts
  • apps/web/src/components/keyboard-hints.test.tsx
  • apps/web/src/features/inbox/data.ts
  • apps/web/src/features/inbox/inbox-realtime.tsx
  • apps/web/src/features/inbox/inbox-view.tsx
  • apps/web/src/features/issues/issue-detail.tsx
  • apps/web/src/features/pulls/data.ts
  • apps/web/src/features/pulls/issue-pull-requests.tsx
  • apps/web/src/features/pulls/pr-state.ts
  • apps/web/src/features/pulls/pulls-realtime.tsx
  • apps/web/src/features/pulls/pulls-view.tsx
  • apps/web/src/features/settings/integrations-data.ts
  • apps/web/src/features/settings/integrations-panel.tsx
  • apps/web/src/features/settings/settings-nav.tsx
  • apps/web/src/lib/navigation.ts
  • packages/core/src/realtime/backfill.ts
  • packages/services/src/github/apply.test.ts
  • packages/services/src/github/apply.ts
  • packages/services/src/github/github.test.ts
  • packages/services/src/github/index.ts
  • packages/services/src/index.ts
  • packages/services/src/notifications/index.ts
  • packages/services/src/notifications/notifications.test.ts
  • packages/services/src/slack/dispatch.test.ts
  • packages/services/src/slack/dispatch.ts
  • packages/services/src/slack/index.ts
  • packages/shared/src/constants/notification.ts
  • packages/shared/src/events/sync.ts
  • packages/shared/src/policy/index.ts
  • packages/shared/src/policy/policy.test.ts
  • packages/shared/src/validators/index.ts
  • packages/shared/src/validators/integration.ts

Comment thread packages/services/src/github/apply.ts Resolved
Comment thread packages/services/src/github/apply.ts Resolved
Comment thread packages/services/src/github/apply.ts Resolved
Comment thread packages/services/src/slack/dispatch.ts Resolved
Comment thread packages/services/src/slack/dispatch.ts Resolved
pulkitxm added 5 commits July 24, 2026 11:23
Use safeParse in parseGithubEvent so a malformed payload returns an empty
result instead of aborting the webhook transaction and dropping the delivery.
Derive git_link insert vs update from the upsert RETURNING xmax so concurrent
deliveries never broadcast a duplicate insert. Resolve check_suite issues via
existing git_link rows keyed by PR number when branch names do not encode the
identifier. Gate review-decision notifications on the submitted action so edited
reviews do not renotify. Publish and backfill git_link actions to the issue
creator and assignee user scopes so the personal pull list stays live.
…nt schema

Filter resolveSlackContext on the integration externalId so a webhook that
already knows the Slack team id cannot pick up another workspace's bot token.
Add an AbortSignal timeout to every SlackClient call so a stalled Slack request
cannot hang the handler. Move the Slack event schema into @orbit/shared so the
webhook route parses request input with a shared validator.
… links

Reprocess GitHub deliveries whose prior attempt did not reach processed, and
mark every early-return path failed, so a redelivery of a failed or incomplete
delivery is no longer dropped as a duplicate. Build the Slack inbox link with
absoluteUrl instead of a localhost fallback. Assert issue:read on the git-links
route and parse its query with a shared schema. Reject repository and channel
links to a team outside the caller's workspace.
Give both integration Team selects an id and htmlFor so the label focuses the
control. Carry a mention delta through the realtime patch and the local delete
so the @ badge reflects incoming, read and deleted unread mentions without a
reload.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant