Skip to content

feat: add public connections API and repository filtering - #1550

Merged
brendan-kellam merged 4 commits into
mainfrom
sou-1870-list-connections
Aug 13, 2026
Merged

feat: add public connections API and repository filtering#1550
brendan-kellam merged 4 commits into
mainfrom
sou-1870-list-connections

Conversation

@brendan-kellam

@brendan-kellam brendan-kellam commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Fixes SOU-1870

Summary

  • add GET /api/connections with connection metadata scoped through repositories visible to the caller
  • add an optional connectionId filter to GET /api/repos, including pagination and count handling
  • publish both behaviors in the public OpenAPI specification
  • add focused service tests for connection listing and repository filtering

Test plan

  • yarn workspace @sourcebot/web test src/app/api/(server)/connections/listConnectionsApi.test.ts src/app/api/(server)/repos/listReposApi.test.ts --run
  • yarn workspace @sourcebot/web exec eslint on the changed TypeScript files
  • yarn workspace @sourcebot/web openapi:generate

Stack created with GitHub Stacks CLI


Note

Low Risk
Additive public read APIs that reuse existing optional-auth and repo-scoping patterns; no new credential exposure beyond id/name/type metadata.

Overview
Adds GET /api/connections, which returns deduplicated code-host connection metadata (id, name, connectionType) for connections tied to at least one repository the caller can see. Listing goes through visible repos so the scoped Prisma client applies the same visibility rules as repository APIs; credentials and connection config are not returned.

GET /api/repos gains an optional connectionId query parameter (positive integer, IDs from the connections endpoint). Repository queries and X-Total-Count use a shared where clause, and pagination Link headers preserve connectionId when present.

Public OpenAPI, docs navigation, and changelog are updated; service tests cover connection deduplication and connection-based repo filtering.

Reviewed by Cursor Bugbot for commit 5d019f3. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • New Features
    • Added a public API endpoint to list visible repository connections.
    • Added optional connectionId filtering to the repository listing API.
    • Added API reference documentation for connection listings and repository filtering.
  • Bug Fixes
    • Ensured connection-filtered repository results, counts, and pagination links remain consistent.
    • Ensured connection listings return unique, consistently ordered results.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7835cd3e-51d2-42a8-bddc-5ed108da296c

📥 Commits

Reviewing files that changed from the base of the PR and between ffeb8c3 and c717571.

📒 Files selected for processing (1)
  • CHANGELOG.md

Walkthrough

The PR adds GET /api/connections for visible repository connections. It also adds an optional connectionId filter to GET /api/repos, with validation, pagination support, tests, and OpenAPI documentation.

Changes

Public connection APIs

Layer / File(s) Summary
Connection listing flow
packages/web/src/app/api/(server)/connections/*, packages/web/src/openapi/*, docs/api-reference/sourcebot-public.openapi.json, docs/docs.json, CHANGELOG.md
Adds connection schemas, visible-connection querying, deduplication, deterministic sorting, route handling, tests, API documentation, navigation, and a changelog entry.
Repository connection filtering
packages/web/src/app/api/(server)/repos/*, packages/web/src/lib/schemas.ts, packages/web/src/lib/types.ts, docs/api-reference/sourcebot-public.openapi.json
Adds positive-integer connectionId validation and applies the filter to repository results, counts, and pagination links. Tests cover filtered and unfiltered queries.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ConnectionsRoute
  participant listConnections
  participant RepositoryQuery
  Client->>ConnectionsRoute: GET /api/connections
  ConnectionsRoute->>listConnections: Request visible connections
  listConnections->>RepositoryQuery: Query visible repositories
  RepositoryQuery-->>listConnections: Return repository connections
  listConnections-->>ConnectionsRoute: Return unique sorted connections
  ConnectionsRoute-->>Client: Return JSON response
Loading

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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the two main changes: the public connections API and repository filtering.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sou-1870-list-connections

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@brendan-kellam brendan-kellam changed the title sou 1870 list connections feat: add public connections API and repository filtering Aug 6, 2026
@brendan-kellam
brendan-kellam force-pushed the sou-1870-list-connections branch 2 times, most recently from d892993 to 5d019f3 Compare August 6, 2026 19:17

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5d6da1b. Configure here.

Comment thread packages/web/src/app/api/(server)/connections/listConnectionsApi.ts
jsourcebot
jsourcebot previously approved these changes Aug 13, 2026
Base automatically changed from sou-1870-scoped-access-tokens to main August 13, 2026 03:50
@mintlify

mintlify Bot commented Aug 13, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
sourcebot 🟢 Ready View Preview Aug 13, 2026, 3:51 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@CHANGELOG.md`:
- Line 27: Move the PR `#1550` changelog entry from the released 5.1.6 section to
the bottom of the applicable [Unreleased] section, preserving its wording and
link.
🪄 Autofix

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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 167f928b-27ba-467f-9cea-db589fbea7e1

📥 Commits

Reviewing files that changed from the base of the PR and between 3a4447b and ffeb8c3.

📒 Files selected for processing (13)
  • CHANGELOG.md
  • docs/api-reference/sourcebot-public.openapi.json
  • docs/docs.json
  • packages/web/src/app/api/(server)/connections/listConnectionsApi.test.ts
  • packages/web/src/app/api/(server)/connections/listConnectionsApi.ts
  • packages/web/src/app/api/(server)/connections/route.ts
  • packages/web/src/app/api/(server)/repos/listReposApi.test.ts
  • packages/web/src/app/api/(server)/repos/listReposApi.ts
  • packages/web/src/app/api/(server)/repos/route.ts
  • packages/web/src/lib/schemas.ts
  • packages/web/src/lib/types.ts
  • packages/web/src/openapi/publicApiDocument.ts
  • packages/web/src/openapi/publicApiSchemas.ts

Comment thread CHANGELOG.md Outdated
@brendan-kellam
brendan-kellam merged commit 9ae8901 into main Aug 13, 2026
12 of 13 checks passed
@brendan-kellam
brendan-kellam deleted the sou-1870-list-connections branch August 13, 2026 04:11
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.

2 participants