Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore: github settings update (#109836)

Alex Vc0accdd225d3
diff --git a/frontend/src/lib/integrations/GitHubRepositoryCombobox.test.tsx b/frontend/src/lib/integrations/GitHubRepositoryCombobox.test.tsx
index c5a42b4cd922..210067985b07 100644
--- a/frontend/src/lib/integrations/GitHubRepositoryCombobox.test.tsx
+++ b/frontend/src/lib/integrations/GitHubRepositoryCombobox.test.tsx
@@ -18,7 +18,7 @@ describe('GitHubRepositoryCombobox', () => {
requests = 0
useMocks({
get: {
- '/api/environments/:team_id/integrations/:id/github_repos': () => {
+ '/api/projects/:team_id/integrations/:id/github_repos/': () => {
const firstPage = requests++ === 0
return [
200,
@@ -76,6 +76,19 @@ describe('GitHubRepositoryCombobox', () => {
expect(onChange).toHaveBeenCalledWith('example-org/active')
})
+ it('loads later pages without a load-more click when loadAll is set', async () => {
+ hasMore = true
+ render(
+ <Provider>
+ <GitHubRepositoryCombobox integrationId={123} value="" onChange={jest.fn()} loadAll />
+ </Provider>
+ )
+ await userEvent.click(screen.getByRole('combobox'))
+ expect(await screen.findByText('example-org/archived')).toBeVisible()
+ expect(await screen.findByText('example-org/active')).toBeVisible()
+ expect(screen.queryByText('Load more')).not.toBeInTheDocument()
+ })
+
it('disables the trigger and exposes its explanation', async () => {
render(
<Provider>
diff --git a/frontend/src/lib/integrations/GitHubRepositoryCombobox.tsx b/frontend/src/lib/integrations/GitHubRepositoryCombobox.tsx
index d047326d96e8..5ca3b887208a 100644
--- a/frontend/src/lib/integrations/GitHubRepositoryCombobox.tsx
+++ b/frontend/src/lib/integrations/GitHubRepositoryCombobox.tsx
@@ -28,6 +28,8 @@ export interface GitHubRepositoryComboboxProps {
/** When true, prepends a "— No repository —" item so users can explicitly clear the selection. */
showNoneOption?: boolean
repositoryFilter?: (repository: GitHubRepoApi) => boolean
+ /** Load every page. The default picker stops after the first page and waits for "Load more". */
+ loadAll?: boolean
fullWidth?: boolean
}
@@ -48,9 +50,10 @@ export function GitHubRepositoryCombobox({
placeholder = 'Select repository...',
showNoneOption = false,
repositoryFilter,
+ loadAll = false,
fullWidth = false,
}: GitHubRepositoryComboboxProps): JSX.Element {
- const logic = githubRepositorySearchLogic({ id: integrationId })
+ const logic = githubRepositorySearchLogic({ id: integrationId, loadAll })
const { repositories, loading, hasMore, searchQuery, error } = useValues(logic)
const repositoryNames = (repositoryFilter ? repositories.filter(repositoryFilter) : repositories).map(
(repo) => repo.full_name
@@ -134,7 +137,7 @@ export function GitHubRepositoryCombobox({
}
</ComboboxList>
- {hasMore && (
+ {hasMore && !loadAll && (
<ComboboxLoadMoreFooter
loadedCount={repositoryNames.length}
itemsLabel="repositories"
diff --git a/frontend/src/lib/integrations/githubRepositorySearchLogic.ts b/frontend/src/lib/integrations/githubRepositorySearchLogic.ts
index 82f7e7c1e987..53df92384b69 100644
--- a/frontend/src/lib/integrations/githubRepositorySearchLogic.ts
+++ b/frontend/src/lib/integrations/githubRepositorySearchLogic.ts
@@ -12,15 +12,19 @@ import {
selectors,
} from 'kea'
-import api from 'lib/api'
+import { ApiConfig } from 'lib/api'
+import { integrationsGithubReposRetrieve } from 'products/integrations/frontend/generated/api'
import type { GitHubRepoApi } from 'products/integrations/frontend/generated/api.schemas'
const PAGE_SIZE = 50
+const FULL_LIST_PAGE_SIZE = 500
const SEARCH_DEBOUNCE_MS = 300
export interface GithubRepositorySearchLogicProps {
id: number
+ /** Keep requesting pages until the installation's repository list is exhausted. */
+ loadAll?: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -64,7 +68,7 @@ export interface githubRepositorySearchLogicActions {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface githubRepositorySearchLogicMeta {
- key: number
+ key: number | string
__keaTypeGenInternalSelectorTypes: {
repositoryNames: (repositories: GitHubRepoApi[]) => string[]
}
@@ -81,12 +85,13 @@ export type githubRepositorySearchLogicType = MakeLogicType<
* Server-side searchable, paginated GitHub repository source for a single integration. Unlike
* {@link githubIntegrationLogic} — which eagerly bulk-loads every repository in 500-row pages and ignores
* the search term — this drives the `github_repos` endpoint's `search`/`limit`/`offset` params directly so
- * a repo picker can search across very large accounts without loading the whole list. Keyed by integration
- * id so concurrent pickers stay independent.
+ * a repo picker can search across very large accounts without loading the whole list. Pass `loadAll` when
+ * the caller has to offer every repository. Keyed by integration id so concurrent pickers stay independent;
+ * `loadAll` is part of the key so a full-list picker does not share a first-page instance.
*/
export const githubRepositorySearchLogic = kea<githubRepositorySearchLogicType>([
props({} as GithubRepositorySearchLogicProps),
- key((props) => props.id),
+ key((props) => (props.loadAll ? `all:${props.id}` : props.id)),
path((key) => ['lib', 'integrations', 'githubRepositorySearchLogic', key]),
actions({
@@ -102,7 +107,7 @@ export const githubRepositorySearchLogic = kea<githubRepositorySearchLogicType>(
refresh: true,
}),
- reducers({
+ reducers(({ props }) => ({
searchQuery: [
'',
{
@@ -131,7 +136,8 @@ export const githubRepositorySearchLogic = kea<githubRepositorySearchLogicType>(
setSearchQuery: () => true,
refresh: () => true,
loadPage: () => true,
- loadPageSuccess: () => false,
+ // Stay in the loading state between pages so the first page does not look like the full list.
+ loadPageSuccess: (_, { hasMore }) => !!(props.loadAll && hasMore),
loadPageFailure: () => false,
},
],
@@ -157,10 +163,10 @@ export const githubRepositorySearchLogic = kea<githubRepositorySearchLogicType>(
{
setSearchQuery: () => 0,
refresh: () => 0,
- loadPageSuccess: (_, { offset }) => offset + PAGE_SIZE,
+ loadPageSuccess: (_, { offset }) => offset + (props.loadAll ? FULL_LIST_PAGE_SIZE : PAGE_SIZE),
},
],
- }),
+ })),
selectors({
// The picker selects on `owner/repo` (matches the Task API's repository format).
@@ -184,14 +190,20 @@ export const githubRepositorySearchLogic = kea<githubRepositorySearchLogicType>(
actions.loadPage(values.currentOffset)
}
},
+ loadPageSuccess: ({ hasMore, repositories }) => {
+ // An allowlist picker has to offer every repo. An empty page means the offset ran past the end.
+ if (props.loadAll && hasMore && repositories.length > 0) {
+ actions.loadPage(values.currentOffset)
+ }
+ },
loadPage: async ({ offset }, breakpoint) => {
// Snapshot the query driving this request so a response that resolves after the search
// has moved on (e.g. a slow "Load more" landing mid-typing) can be discarded instead of
// committing stale repositories onto the new result set.
const query = values.searchQuery.trim()
try {
- const response = await api.integrations.githubRepositories(props.id, {
- limit: PAGE_SIZE,
+ const response = await integrationsGithubReposRetrieve(String(ApiConfig.getCurrentTeamId()), props.id, {
+ limit: props.loadAll ? FULL_LIST_PAGE_SIZE : PAGE_SIZE,
offset,
search: query || undefined,
})
diff --git a/products/business_knowledge/backend/github_repos.py b/products/business_knowledge/backend/github_repos.py
index 06692fd960b4..a7b0a2748e9d 100644
--- a/products/business_knowledge/backend/github_repos.py
+++ b/products/business_knowledge/backend/github_repos.py
@@ -41,7 +41,7 @@ from .models import TeamBusinessKnowledgeConfig
logger = structlog.get_logger(__name__)
GITHUB_REPOS_FLAG = "business-knowledge-github-repos"
-MAX_GITHUB_REPOS = 20
+MAX_GITHUB_REPOS = 100
MAX_SEARCH_HITS = 20
MAX_README_HITS = 5
MAX_FILE_TEXT_CHARS = 32_000
diff --git a/products/business_knowledge/backend/tests/test_github_repos.py b/products/business_knowledge/backend/tests/test_github_repos.py
index b1cc02cd5ea3..b8aa74dc6f4a 100644
--- a/products/business_knowledge/backend/tests/test_github_repos.py
+++ b/products/business_knowledge/backend/tests/test_github_repos.py
@@ -10,6 +10,7 @@ from posthog.models.integration_repository_cache import IntegrationRepositoryCac
from posthog.models.team import Team
from posthog.models.team.extensions import get_or_create_team_extension
+from products.business_knowledge.backend.github_repos import MAX_GITHUB_REPOS
from products.business_knowledge.backend.models import TeamBusinessKnowledgeConfig
BILLING = "acme/billing"
@@ -80,7 +81,7 @@ class TestBusinessKnowledgeGithubRepos(APIBaseTest):
assert bad.status_code == 400
assert "owner/repo" in str(bad.json())
- too_many = self._select([f"acme/repo-{index}" for index in range(21)])
+ too_many = self._select([f"acme/repo-{index}" for index in range(MAX_GITHUB_REPOS + 1)])
assert too_many.status_code == 400
def test_connect_rejects_another_teams_installation(self, _capture, _flag) -> None:
diff --git a/products/business_knowledge/frontend/generated/api.schemas.ts b/products/business_knowledge/frontend/generated/api.schemas.ts
index 9b9d6c2df2c0..016122465dc1 100644
--- a/products/business_knowledge/frontend/generated/api.schemas.ts
+++ b/products/business_knowledge/frontend/generated/api.schemas.ts
@@ -345,8 +345,8 @@ export interface RepositorySearchResponseApi {
export interface RepositorySelectionApi {
/**
- * owner/repo names to allow. At most 20. Replaces the current list.
- * @maxItems 20
+ * owner/repo names to allow. At most 100. Replaces the current list.
+ * @maxItems 100
*/
repos: string[]
}
diff --git a/products/business_knowledge/frontend/generated/api.zod.ts b/products/business_knowledge/frontend/generated/api.zod.ts
index 6117055ed360..3cff400245cf 100644
--- a/products/business_knowledge/frontend/generated/api.zod.ts
+++ b/products/business_knowledge/frontend/generated/api.zod.ts
@@ -64,13 +64,13 @@ export const BusinessKnowledgeRepositoriesConnectCreateBody = /* @__PURE__ */ zo
* Every name must be a repository the connected installation can see. Names are stored lowercased.
* @summary Replace the repositories business knowledge can read
*/
-export const businessKnowledgeRepositoriesSelectionCreateBodyReposMax = 20
+export const businessKnowledgeRepositoriesSelectionCreateBodyReposMax = 100
export const BusinessKnowledgeRepositoriesSelectionCreateBody = /* @__PURE__ */ zod.object({
repos: zod
.array(zod.string())
.max(businessKnowledgeRepositoriesSelectionCreateBodyReposMax)
- .describe('owner\/repo names to allow. At most 20. Replaces the current list.'),
+ .describe('owner\/repo names to allow. At most 100. Replaces the current list.'),
})
/**
diff --git a/products/business_knowledge/frontend/scenes/settings/GithubReposSetting.tsx b/products/business_knowledge/frontend/scenes/settings/GithubReposSetting.tsx
index 9f62274fb908..a3d829594a07 100644
--- a/products/business_knowledge/frontend/scenes/settings/GithubReposSetting.tsx
+++ b/products/business_knowledge/frontend/scenes/settings/GithubReposSetting.tsx
@@ -110,19 +110,21 @@ export function GithubReposSetting(): JSX.Element {
</LemonSnack>
))}
</div>
- <GitHubRepositoryCombobox
- integrationId={connection.integration_id}
- value=""
- onChange={(fullName) => {
- if (fullName) {
- addRepo(fullName)
- }
- }}
- disabled={saving || atCap}
- disabledReason={atCap ? `You can select up to ${MAX_GITHUB_REPOS} repositories` : undefined}
- placeholder="Add a repository"
- />
- <div>
+ <div className="flex flex-wrap items-center gap-2">
+ <GitHubRepositoryCombobox
+ integrationId={connection.integration_id}
+ value=""
+ onChange={(fullName) => {
+ if (fullName) {
+ addRepo(fullName)
+ }
+ }}
+ repositoryFilter={(repository) => !draftRepos.includes(repository.full_name.toLowerCase())}
+ loadAll
+ disabled={saving || atCap}
+ disabledReason={atCap ? `You can select up to ${MAX_GITHUB_REPOS} repositories` : undefined}
+ placeholder="Add a repository"
+ />
<LemonButton
type="primary"
size="small"
diff --git a/products/business_knowledge/frontend/scenes/settings/githubReposLogic.ts b/products/business_knowledge/frontend/scenes/settings/githubReposLogic.ts
index 9e1274d143d4..a98113b81be4 100644
--- a/products/business_knowledge/frontend/scenes/settings/githubReposLogic.ts
+++ b/products/business_knowledge/frontend/scenes/settings/githubReposLogic.ts
@@ -9,7 +9,7 @@ import * as api from '../../generated/api'
import type { RepositoryConnectionApi } from '../../generated/api.schemas'
// Mirrors MAX_GITHUB_REPOS in products/business_knowledge/backend/github_repos.py.
-export const MAX_GITHUB_REPOS = 20
+export const MAX_GITHUB_REPOS = 100
function teamId(): string {
return String(ApiConfig.getCurrentTeamId())
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 241616e23369..15e8a39be60e 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -90384,8 +90384,8 @@ export namespace Schemas {
export interface RepositorySelection {
/**
- * owner/repo names to allow. At most 20. Replaces the current list.
- * @maxItems 20
+ * owner/repo names to allow. At most 100. Replaces the current list.
+ * @maxItems 100
*/
repos: string[];
}