: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(stamphog): keep the repo list usable for all-repos installs (#100144)
Julian Bez31c512a0c0f2
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex d36b6b6047a6..bb884442fe47 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -9776,6 +9776,10 @@ snapshots:hash: v1.k794b7964.2ff771815c26e56d32f41eae88bb1c453a6fe50e273cb5095c1c3f9477dc590f.5A7_p3_Mbh5nL3T1e5olwqpfNMu6t4_-TKQ0j1ja1AYscenes-app-stamphog-digests--digests-list-empty--light:hash: v1.k794b7964.46c349724a92b59d4693ac9e9164bcff7c89c8d04ef967fee23ff5052457c63e.HqC03R4DRb_7TP-ljXEykmHv_DOCNYRAhZeNr5fSAoE+ scenes-app-stamphog-repositories--repositories-list--dark:+ hash: v1.k794b7964.d3fef1c6e6cfe2236106ae143dca48f4532d29c1c5bfcd3d6c5995b2b7c917fc.TwE2zKzmtrveSPIxEAtz5ZpkWvOwZQ0qSKDWYbbSPRM+ scenes-app-stamphog-repositories--repositories-list--light:+ hash: v1.k794b7964.69b3f8946be364d5f94d9ac4c0c05413edf014ea55069c181f924d30bbab458a.urlrVpziCX4AJeDE8XUxOBBD79YMKSsUOQnTd4CnD2oscenes-app-stamphog-runs--runs-list--dark:hash: v1.k794b7964.0f6fb2d21628b8c0f8781d21610ca6fd605216cb07cfeae30f9fc6189ca72d2b.GzyJek2YNFSPSBQoznkgE_FcldLmSLCiVa0gCaHUIxIscenes-app-stamphog-runs--runs-list--light:diff --git a/products/stamphog/backend/presentation/serializers.py b/products/stamphog/backend/presentation/serializers.pyindex dda42fbf7f1a..e4d81b0bdc1b 100644--- a/products/stamphog/backend/presentation/serializers.py+++ b/products/stamphog/backend/presentation/serializers.py@@ -165,18 +165,18 @@ class StamphogInstallInfoSerializer(serializers.Serializer):install_url = serializers.CharField(read_only=True,help_text=(- "GitHub install URL (github.com/apps/<slug>/installations/new) the user opens to install the "- "App, or blank if the App slug is unconfigured. Used for the genuinely-not-installed case; the "- "primary 'Connect' button uses authorize_url instead."+ "GitHub install URL (github.com/apps/<slug>/installations/new) the 'Connect' button opens. The "+ "user picks a GitHub account there and chooses which repositories the App can reach, including "+ "an account where the App is already installed. Blank if the App slug is unconfigured."),)authorize_url = serializers.CharField(read_only=True,help_text=(- "GitHub authorize URL (github.com/login/oauth/authorize) the 'Connect' button opens. "- "Authorize-first: an already-installed user is redirected straight back with an OAuth code (no "- "installation_id), and sync_installation then discovers their installations server-side. Blank "- "if the App client id is unconfigured."+ "GitHub authorize URL (github.com/login/oauth/authorize). GitHub's redirect after configuring an "+ "existing installation carries no OAuth code, so the client passes through this URL once: an "+ "installed App redirects straight back with a code, which sync_installation uses to prove "+ "ownership. Blank if the App client id is unconfigured."),)diff --git a/products/stamphog/backend/presentation/views.py b/products/stamphog/backend/presentation/views.pyindex 57fdd478c5e1..f8a8dfaeb2cf 100644--- a/products/stamphog/backend/presentation/views.py+++ b/products/stamphog/backend/presentation/views.py@@ -283,9 +283,10 @@ class StamphogRepoConfigViewSet(_StamphogTeamScopedViewSet, viewsets.GenericViewif slug:install_url = f"https://github.com/apps/{slug}/installations/new?state={quote(state)}"if client_id:- # Authorize-first: an already-installed user gets a silent instant redirect back with an OAuth- # code but no installation_id, so the connect button never dead-ends on GitHub's "update- # installation" screen. Discovery then finds the installations from the code, server-side.+ # The connect button opens install_url, so the user can choose repositories on GitHub. GitHub's+ # redirect after "Configure" on an existing installation carries no OAuth code, so the frontend+ # sends the browser through authorize_url once: an installed App redirects back at once with a+ # code, and the sync proves ownership from it.authorize_url = (f"https://github.com/login/oauth/authorize?client_id={quote(client_id)}&state={quote(state)}")diff --git a/products/stamphog/backend/tests/test_api.py b/products/stamphog/backend/tests/test_api.pyindex e858669a669d..0de393606da7 100644--- a/products/stamphog/backend/tests/test_api.py+++ b/products/stamphog/backend/tests/test_api.py@@ -807,7 +807,7 @@ class TestSyncInstallationAPI(StamphogTeamScopedTestMixin, APIBaseTest):def test_discovery_without_installation_id_syncs_discovered_installation(self, mock_exchange, mock_discover, mock_list) -> None:- # Authorize-first: the callback carries no installation_id. The backend discovers the caller's+ # An authorize callback carries no installation_id. The backend discovers the caller's# installations from the OAuth code (GitHub returns only installations of this App the user can# reach) and syncs them, so the client never has to supply a forgeable id.response = self.client.post(self.url, {"code": "oauth-code", "state": self.state}, format="json")diff --git a/products/stamphog/frontend/generated/api.schemas.ts b/products/stamphog/frontend/generated/api.schemas.tsindex 1cbdf97e5f9a..606a88867ea7 100644--- a/products/stamphog/frontend/generated/api.schemas.ts+++ b/products/stamphog/frontend/generated/api.schemas.ts@@ -238,9 +238,9 @@ export interface PatchedStamphogRepoConfigWriteApi {export interface StamphogInstallInfoApi {/** URL-friendly slug of the dedicated Stamphog GitHub App, or blank if unconfigured. */readonly app_slug: string- /** GitHub install URL (github.com/apps/<slug>/installations/new) the user opens to install the App, or blank if the App slug is unconfigured. Used for the genuinely-not-installed case; the primary 'Connect' button uses authorize_url instead. */+ /** GitHub install URL (github.com/apps/<slug>/installations/new) the 'Connect' button opens. The user picks a GitHub account there and chooses which repositories the App can reach, including an account where the App is already installed. Blank if the App slug is unconfigured. */readonly install_url: string- /** GitHub authorize URL (github.com/login/oauth/authorize) the 'Connect' button opens. Authorize-first: an already-installed user is redirected straight back with an OAuth code (no installation_id), and sync_installation then discovers their installations server-side. Blank if the App client id is unconfigured. */+ /** GitHub authorize URL (github.com/login/oauth/authorize). GitHub's redirect after configuring an existing installation carries no OAuth code, so the client passes through this URL once: an installed App redirects straight back with a code, which sync_installation uses to prove ownership. Blank if the App client id is unconfigured. */readonly authorize_url: string}diff --git a/products/stamphog/frontend/scenes/StamphogScene/StamphogScene.stories.tsx b/products/stamphog/frontend/scenes/StamphogScene/StamphogScene.stories.tsxnew file mode 100644index 000000000000..fb3a6a2c08a2--- /dev/null+++ b/products/stamphog/frontend/scenes/StamphogScene/StamphogScene.stories.tsx@@ -0,0 +1,101 @@+import type { Meta, StoryObj } from '@storybook/react'++import { App } from 'scenes/App'+import { urls } from 'scenes/urls'++import { mswDecorator } from '~/mocks/browser'++import type { StamphogRepoConfigApi } from '../../generated/api.schemas'++const REPO_NAMES = [+ 'posthog',+ 'posthog-js',+ 'posthog-python',+ 'posthog-node',+ 'posthog-ios',+ 'posthog-android',+ 'posthog-flutter',+ 'posthog-go',+ 'posthog-ruby',+ 'posthog-php',+ 'posthog.com',+ 'charts',+ 'hogql-parser',+ 'plugin-server',+ 'rrweb',+ 'wizard',+ 'hogland',+ 'pr-approval-agent',+]++const repoConfig = (name: string, index: number, on: { enabled: boolean; digest: boolean }): StamphogRepoConfigApi =>+ ({+ id: `00000000-0000-0000-0000-${String(index).padStart(12, '0')}`,+ repository: `PostHog/${name}`,+ provider: 'github',+ enabled: on.enabled,+ digest_enabled: on.digest,+ installation_id: '1',+ review_mode: 'all',+ trigger_label: 'stamphog',+ created_at: '2026-07-01T00:00:00Z',+ updated_at: '2026-07-01T00:00:00Z',+ }) as StamphogRepoConfigApi++const page = (results: StamphogRepoConfigApi[]): Record<string, unknown> => ({+ count: results.length,+ next: null,+ previous: null,+ results,+})++const repoConfigs = page(+ REPO_NAMES.map((name, index) =>+ repoConfig(name, index, { enabled: name === 'posthog' || name === 'wizard', digest: name === 'posthog-js' })+ )+)++const allOrgRepoConfigs = page(+ Array.from({ length: 730 }, (_, index) =>+ repoConfig(`service-${String(index).padStart(3, '0')}`, index, { enabled: index % 97 === 0, digest: false })+ )+)++const meta: Meta = {+ component: App,+ title: 'Scenes-App/Stamphog/Repositories',+ parameters: {+ layout: 'fullscreen',+ viewMode: 'story',+ mockDate: '2026-08-17 23:30:00',+ pageUrl: urls.stamphog(),+ testOptions: { waitForSelector: '[data-attr="stamphog-repo-status-filter-all"]' },+ },+ decorators: [+ mswDecorator({+ get: {+ '/api/projects/:team_id/stamphog/repo_configs/': repoConfigs,+ '/api/projects/:team_id/stamphog/repo_configs/install_info/': {+ app_slug: 'stamphog',+ install_url: 'https://github.com/apps/stamphog/installations/new',+ authorize_url: 'https://github.com/login/oauth/authorize',+ },+ },+ }),+ ],+}+export default meta++export const RepositoriesList: StoryObj = {}++// Too tall for a useful snapshot. It exists to check that search and the status filter stay fast at org scale.+export const AllOrgRepositories: StoryObj = {+ tags: ['test-skip'],+ decorators: [+ mswDecorator({+ get: {+ '/api/projects/:team_id/stamphog/repo_configs/': allOrgRepoConfigs,+ },+ }),+ ],+}diff --git a/products/stamphog/frontend/scenes/StamphogScene/StamphogScene.tsx b/products/stamphog/frontend/scenes/StamphogScene/StamphogScene.tsxindex 0869ec354766..7fbad2acc3ed 100644--- a/products/stamphog/frontend/scenes/StamphogScene/StamphogScene.tsx+++ b/products/stamphog/frontend/scenes/StamphogScene/StamphogScene.tsx@@ -1,7 +1,16 @@import { useActions, useValues } from 'kea'import { IconGithub } from '@posthog/icons'-import { LemonBanner, LemonButton, LemonInput, LemonSelect, LemonSwitch, LemonTable, Link } from '@posthog/lemon-ui'+import {+ LemonBanner,+ LemonButton,+ LemonInput,+ LemonSegmentedButton,+ LemonSelect,+ LemonSwitch,+ LemonTable,+ Link,+} from '@posthog/lemon-ui'import { TZLabel } from 'lib/components/TZLabel'import { LemonTableColumns } from 'lib/lemon-ui/LemonTable'@@ -15,7 +24,7 @@ import { AccessControlLevel, AccessControlResourceType } from '~/types'import { StamphogTabs } from '../../components/StamphogTabs'import { ReviewModeEnumApi, type StamphogRepoConfigApi } from '../../generated/api.schemas'import { REVIEW_MODE_LABELS } from '../../reviewModeLabels'-import { stamphogSceneLogic } from './stamphogSceneLogic'+import { type RepoStatusFilter, stamphogSceneLogic } from './stamphogSceneLogic'// Whether a repository is reviewed at all is a manager decision. The digest only changes who hears// about the work, and connecting a repository starts no review on its own, so both stay at editor.@@ -34,20 +43,21 @@ export const scene: SceneExport = {}function ConnectRepositoryButton(): JSX.Element {- // Authorize-first: the connect button opens the OAuth authorize URL. An already-installed user gets a- // silent instant redirect back, so it never dead-ends on GitHub's "update installation" screen.- const { authorizeUrl, installInfoLoading, stamphogAccessLevel } = useValues(stamphogSceneLogic)+ const { installInfo, installUrl, installInfoLoading, stamphogAccessLevel } = useValues(stamphogSceneLogic)+ // The callback finishes through the authorize URL, so an install link alone cannot connect anything.+ const canConnect = !!installUrl && !!installInfo?.authorize_urlreturn (<LemonButtontype="primary"icon={<IconGithub />}- to={authorizeUrl || undefined}+ to={canConnect ? installUrl : undefined}disableClientSideRouting+ data-attr="stamphog-connect-repository"disabledReason={editorDisabledReason(stamphogAccessLevel) ??(installInfoLoading? 'Loading install details'- : authorizeUrl+ : canConnect? undefined: 'GitHub App not configured yet')}@@ -133,7 +143,7 @@ function SyncedBanner(): JSX.Element | null {}function ReviewModeCell({ repo, updating }: { repo: StamphogRepoConfigApi; updating: boolean }): JSX.Element {- const { setReviewMode, setTriggerLabel } = useActions(stamphogSceneLogic)+ const { updateRepoConfig } = useActions(stamphogSceneLogic)const disabledReason =managerDisabledReason(toAccessControlLevel(repo.user_access_level)) ?? (updating ? 'Updating' : undefined)@@ -142,7 +152,7 @@ function ReviewModeCell({ repo, updating }: { repo: StamphogRepoConfigApi; updat// Save only real changes — blur after no edit (or after enter already saved) must not re-PATCH,// and a blank label is rejected by the API anyway.if (trimmed && trimmed !== repo.trigger_label) {- setTriggerLabel(repo.id, trimmed)+ updateRepoConfig(repo.id, { trigger_label: trimmed })}}@@ -152,7 +162,7 @@ function ReviewModeCell({ repo, updating }: { repo: StamphogRepoConfigApi; updatsize="small"value={repo.review_mode ?? ReviewModeEnumApi.All}disabledReason={disabledReason}- onChange={(mode) => setReviewMode(repo.id, mode)}+ onChange={(mode) => updateRepoConfig(repo.id, { review_mode: mode })}options={[{ value: ReviewModeEnumApi.All, label: REVIEW_MODE_LABELS[ReviewModeEnumApi.All] },{ value: ReviewModeEnumApi.Label, label: REVIEW_MODE_LABELS[ReviewModeEnumApi.Label] },@@ -177,9 +187,17 @@ function ReviewModeCell({ repo, updating }: { repo: StamphogRepoConfigApi; updat}function RepoConfigsTable(): JSX.Element {- const { filteredRepoConfigs, repoConfigs, repoConfigsLoading, updatingRepoIds, repoSearch } =- useValues(stamphogSceneLogic)- const { setRepoEnabled, setDigestEnabled, setRepoSearch } = useActions(stamphogSceneLogic)+ const {+ visibleRepoConfigs,+ filteredRepoConfigs,+ repoConfigs,+ repoConfigsLoading,+ updatingRepoIds,+ repoSearch,+ repoStatusFilter,+ repoStatusCounts,+ } = useValues(stamphogSceneLogic)+ const { updateRepoConfig, setRepoSearch, setRepoStatusFilter, showAllRepos } = useActions(stamphogSceneLogic)const columns: LemonTableColumns<StamphogRepoConfigApi> = [{@@ -197,7 +215,7 @@ function RepoConfigsTable(): JSX.Element {managerDisabledReason(toAccessControlLevel(repo.user_access_level)) ??(updatingRepoIds.includes(repo.id) ? 'Updating' : undefined)}- onChange={(checked) => setRepoEnabled(repo.id, checked)}+ onChange={(checked) => updateRepoConfig(repo.id, { enabled: checked })}/>),},@@ -216,7 +234,7 @@ function RepoConfigsTable(): JSX.Element {editorDisabledReason(toAccessControlLevel(repo.user_access_level)) ??(updatingRepoIds.includes(repo.id) ? 'Updating' : undefined)}- onChange={(checked) => setDigestEnabled(repo.id, checked)}+ onChange={(checked) => updateRepoConfig(repo.id, { digest_enabled: checked })}/>),},@@ -230,22 +248,65 @@ function RepoConfigsTable(): JSX.Element {return (<div className="flex flex-col gap-2">{repoConfigs.length > 10 && (- <LemonInput- type="search"- placeholder="Search repositories"- value={repoSearch}- onChange={setRepoSearch}- className="max-w-100"- />+ <div className="flex items-center gap-2 flex-wrap">+ <LemonInput+ type="search"+ placeholder="Search repositories"+ value={repoSearch}+ onChange={setRepoSearch}+ className="max-w-100"+ data-attr="stamphog-repo-search"+ />+ <LemonSegmentedButton<RepoStatusFilter>+ size="small"+ value={repoStatusFilter}+ onChange={setRepoStatusFilter}+ options={[+ {+ value: 'all',+ label: `All (${repoStatusCounts.all})`,+ 'data-attr': 'stamphog-repo-status-filter-all',+ },+ {+ value: 'on',+ label: `On (${repoStatusCounts.on})`,+ tooltip: 'Reviews or the digest are turned on',+ 'data-attr': 'stamphog-repo-status-filter-on',+ },+ {+ value: 'off',+ label: `Off (${repoStatusCounts.off})`,+ tooltip: 'Connected, with reviews and the digest turned off',+ 'data-attr': 'stamphog-repo-status-filter-off',+ },+ ]}+ />+ </div>)}<LemonTablecolumns={columns}- dataSource={filteredRepoConfigs}+ dataSource={visibleRepoConfigs}loading={repoConfigsLoading}rowKey="id"- pagination={{ pageSize: 20 }}- emptyState="No repositories yet. Install the Stamphog GitHub App to get started."+ emptyState={+ repoConfigs.length === 0+ ? 'No repositories yet. Install the Stamphog GitHub App to get started.'+ : 'No repositories match. Clear the search or pick All to see every repository.'+ }/>+ {filteredRepoConfigs.length > visibleRepoConfigs.length && (+ <div className="flex items-center gap-2 flex-wrap text-secondary">+ <span>{`Showing ${visibleRepoConfigs.length} of ${filteredRepoConfigs.length}. Search to find a repository, or show the full list.`}</span>+ <LemonButton+ size="small"+ type="secondary"+ onClick={showAllRepos}+ data-attr="stamphog-repo-show-all"+ >+ {`Show all ${filteredRepoConfigs.length}`}+ </LemonButton>+ </div>+ )}</div>)}diff --git a/products/stamphog/frontend/scenes/StamphogScene/stamphogSceneLogic.ts b/products/stamphog/frontend/scenes/StamphogScene/stamphogSceneLogic.tsindex 116baa0204e6..fc135be35e99 100644--- a/products/stamphog/frontend/scenes/StamphogScene/stamphogSceneLogic.ts+++ b/products/stamphog/frontend/scenes/StamphogScene/stamphogSceneLogic.ts@@ -16,7 +16,7 @@ import {stamphogRepoConfigsSyncInstallationCreate,} from '../../generated/api'import type {- ReviewModeEnumApi,+ PatchedStamphogRepoConfigWriteApi,StamphogDiscoveredInstallationApi,StamphogInstallInfoApi,StamphogRepoConfigApi,@@ -29,11 +29,24 @@ import type {// that discovered them — it rides the browser instead, and the explicit-id path verifies it.const PENDING_INSTALLATION_STORAGE_KEY = 'stamphog-pending-installation-id'+// Large enough that an organization-wide install loads in one request. The list endpoint sets no max limit.+const REPO_CONFIGS_PAGE_SIZE = 1000++// Every table row mounts two switches and a select, so mounting an org's worth of rows stalls the page+// for a noticeable moment on each search or filter change. Search is how people find a repo among+// hundreds, so the table renders the first matches and offers the full list on request.+const VISIBLE_REPO_LIMIT = 100++export type RepoStatusFilter = 'all' | 'on' | 'off'++function isRepoOn(repo: StamphogRepoConfigApi): boolean {+ return !!repo.enabled || !!repo.digest_enabled+}+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface stamphogSceneLogicValues {currentProjectId: number | string // teamLogicappNotInstalled: boolean- authorizeUrl: stringdiscoveredInstallations: readonly StamphogDiscoveredInstallationApi[]filteredRepoConfigs: StamphogRepoConfigApi[]installInfo: StamphogInstallInfoApi | null@@ -42,12 +55,16 @@ export interface stamphogSceneLogicValues {repoConfigs: StamphogRepoConfigApi[]repoConfigsLoading: booleanrepoSearch: string+ repoStatusCounts: Record<RepoStatusFilter, number>+ repoStatusFilter: RepoStatusFilter+ showingAllRepos: booleanskippedRepos: readonly string[]stamphogAccessLevel: AccessControlLevel | undefinedsyncResult: StamphogSyncInstallationResponseApi | nullsyncResultLoading: booleansyncedRepos: readonly StamphogRepoConfigApi[]updatingRepoIds: string[]+ visibleRepoConfigs: StamphogRepoConfigApi[]}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -85,42 +102,20 @@ export interface stamphogSceneLogicActions {repoConfigs: StamphogRepoConfigApi[]payload?: any}- redirectToAuthorize: () => {- value: true+ repoConfigUpdated: (config: StamphogRepoConfigApi) => {+ config: StamphogRepoConfigApi}repoUpdateDone: (id: string) => {id: string}- setDigestEnabled: (- id: string,- enabled: boolean- ) => {- enabled: boolean- id: string- }- setRepoEnabled: (- id: string,- enabled: boolean- ) => {- enabled: boolean- id: string- }setRepoSearch: (search: string) => {search: string}- setReviewMode: (- id: string,- reviewMode: ReviewModeEnumApi- ) => {- id: string- reviewMode: ReviewModeEnumApi+ setRepoStatusFilter: (filter: RepoStatusFilter) => {+ filter: RepoStatusFilter}- setTriggerLabel: (- id: string,- triggerLabel: string- ) => {- id: string- triggerLabel: string+ showAllRepos: () => {+ value: true}syncInstallation: ({installationId,@@ -128,7 +123,7 @@ export interface stamphogSceneLogicActions {state,}: {code: string- // Optional: absent on the authorize-first redirect, where the backend discovers the+ // Optional: absent when the callback carries only a code, where the backend discovers the// caller's installations from the code instead of trusting a supplied id.installationId?: stringstate: string@@ -159,13 +154,19 @@ export interface stamphogSceneLogicActions {state: string}}+ updateRepoConfig: (+ id: string,+ patch: PatchedStamphogRepoConfigWriteApi+ ) => {+ id: string+ patch: PatchedStamphogRepoConfigWriteApi+ }}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface stamphogSceneLogicMeta {__keaTypeGenInternalSelectorTypes: {installUrl: (installInfo: StamphogInstallInfoApi | null) => string- authorizeUrl: (installInfo: StamphogInstallInfoApi | null) => stringappNotInstalled: (syncResult: StamphogSyncInstallationResponseApi | null) => booleandiscoveredInstallations: (syncResult: StamphogSyncInstallationResponseApi | null@@ -173,7 +174,16 @@ export interface stamphogSceneLogicMeta {syncedRepos: (syncResult: StamphogSyncInstallationResponseApi | null) => readonly StamphogRepoConfigApi[]skippedRepos: (syncResult: StamphogSyncInstallationResponseApi | null) => readonly string[]stamphogAccessLevel: (repoConfigs: StamphogRepoConfigApi[]) => AccessControlLevel | undefined- filteredRepoConfigs: (repoConfigs: StamphogRepoConfigApi[], repoSearch: string) => StamphogRepoConfigApi[]+ repoStatusCounts: (repoConfigs: StamphogRepoConfigApi[]) => Record<RepoStatusFilter, number>+ filteredRepoConfigs: (+ repoConfigs: StamphogRepoConfigApi[],+ repoSearch: string,+ repoStatusFilter: RepoStatusFilter+ ) => StamphogRepoConfigApi[]+ visibleRepoConfigs: (+ filteredRepoConfigs: StamphogRepoConfigApi[],+ showingAllRepos: boolean+ ) => StamphogRepoConfigApi[]}}@@ -192,13 +202,12 @@ export const stamphogSceneLogic = kea<stamphogSceneLogicType>([})),actions({- setRepoEnabled: (id: string, enabled: boolean) => ({ id, enabled }),- setDigestEnabled: (id: string, enabled: boolean) => ({ id, enabled }),- setReviewMode: (id: string, reviewMode: ReviewModeEnumApi) => ({ id, reviewMode }),- setTriggerLabel: (id: string, triggerLabel: string) => ({ id, triggerLabel }),+ updateRepoConfig: (id: string, patch: PatchedStamphogRepoConfigWriteApi) => ({ id, patch }),repoUpdateDone: (id: string) => ({ id }),+ repoConfigUpdated: (config: StamphogRepoConfigApi) => ({ config }),setRepoSearch: (search: string) => ({ search }),- redirectToAuthorize: true,+ setRepoStatusFilter: (filter: RepoStatusFilter) => ({ filter }),+ showAllRepos: true,connectInstallation: (installationId: string) => ({ installationId }),}),@@ -207,15 +216,13 @@ export const stamphogSceneLogic = kea<stamphogSceneLogicType>([[] as StamphogRepoConfigApi[],{loadRepoConfigs: async () => {- // A GitHub installation can surface hundreds of repos, so follow LimitOffset- // pagination and fetch every page. The table searches and paginates this list- // client-side, so a truncated first page would hide repos that then can't be found- // or toggled — the whole point of the toggle list.- const pageSize = 100+ // A GitHub installation can surface hundreds of repos, so fetch every page. The table+ // searches and filters this list client-side, so a truncated first page would hide+ // repos that nobody could then find or toggle.const all: StamphogRepoConfigApi[] = []- for (let offset = 0; ; offset += pageSize) {+ for (let offset = 0; ; offset += REPO_CONFIGS_PAGE_SIZE) {const response = await stamphogRepoConfigsList(String(values.currentProjectId), {- limit: pageSize,+ limit: REPO_CONFIGS_PAGE_SIZE,offset,})all.push(...response.results)@@ -223,7 +230,9 @@ export const stamphogSceneLogic = kea<stamphogSceneLogicType>([break}}- return all+ // Repos that are on go first so they don't sink among hundreds of idle ones. The sort+ // runs on load only, so a toggled row stays where it is until the next load.+ return all.sort((a, b) => Number(isRepoOn(b)) - Number(isRepoOn(a)))},},],@@ -245,7 +254,7 @@ export const stamphogSceneLogic = kea<stamphogSceneLogicType>([code,state,}: {- // Optional: absent on the authorize-first redirect, where the backend discovers the+ // Optional: absent when the callback carries only a code, where the backend discovers the// caller's installations from the code instead of trusting a supplied id.installationId?: stringcode: string@@ -267,14 +276,25 @@ export const stamphogSceneLogic = kea<stamphogSceneLogicType>([updatingRepoIds: [[] as string[],{- setRepoEnabled: (state, { id }) => (state.includes(id) ? state : [...state, id]),- setDigestEnabled: (state, { id }) => (state.includes(id) ? state : [...state, id]),- setReviewMode: (state, { id }) => (state.includes(id) ? state : [...state, id]),- setTriggerLabel: (state, { id }) => (state.includes(id) ? state : [...state, id]),+ updateRepoConfig: (state, { id }) => (state.includes(id) ? state : [...state, id]),repoUpdateDone: (state, { id }) => state.filter((x) => x !== id),},],+ repoConfigs: {+ repoConfigUpdated: (state, { config }) => state.map((repo) => (repo.id === config.id ? config : repo)),+ },repoSearch: ['', { setRepoSearch: (_, { search }) => search }],+ repoStatusFilter: ['all' as RepoStatusFilter, { setRepoStatusFilter: (_, { filter }) => filter }],+ // A new search or filter goes back to the capped list, so clearing a search later doesn't mount+ // every row again.+ showingAllRepos: [+ false,+ {+ showAllRepos: () => true,+ setRepoSearch: () => false,+ setRepoStatusFilter: () => false,+ },+ ],}),selectors({@@ -282,10 +302,6 @@ export const stamphogSceneLogic = kea<stamphogSceneLogicType>([(s) => [s.installInfo],(installInfo: StamphogInstallInfoApi | null): string => installInfo?.install_url ?? '',],- authorizeUrl: [- (s) => [s.installInfo],- (installInfo: StamphogInstallInfoApi | null): string => installInfo?.authorize_url ?? '',- ],appNotInstalled: [(s) => [s.syncResult],(syncResult: StamphogSyncInstallationResponseApi | null): boolean => syncResult?.app_not_installed ?? false,@@ -313,73 +329,54 @@ export const stamphogSceneLogic = kea<stamphogSceneLogicType>([(repoConfigs: StamphogRepoConfigApi[]): AccessControlLevel | undefined =>repoConfigs.length > 0 ? toAccessControlLevel(repoConfigs[0].user_access_level) : undefined,],- // A GitHub App install can surface hundreds of repos, so the table filters client-side by name.+ repoStatusCounts: [+ (s) => [s.repoConfigs],+ (repoConfigs: StamphogRepoConfigApi[]): Record<RepoStatusFilter, number> => {+ const on = repoConfigs.filter(isRepoOn).length+ return { all: repoConfigs.length, on, off: repoConfigs.length - on }+ },+ ],+ // A GitHub App install can surface hundreds of repos, so the table filters client-side by name and status.filteredRepoConfigs: [- (s) => [s.repoConfigs, s.repoSearch],- (repoConfigs: StamphogRepoConfigApi[], repoSearch: string): StamphogRepoConfigApi[] => {+ (s) => [s.repoConfigs, s.repoSearch, s.repoStatusFilter],+ (+ repoConfigs: StamphogRepoConfigApi[],+ repoSearch: string,+ repoStatusFilter: RepoStatusFilter+ ): StamphogRepoConfigApi[] => {const needle = repoSearch.trim().toLowerCase()- if (!needle) {- return repoConfigs- }- return repoConfigs.filter((repo) => repo.repository.toLowerCase().includes(needle))+ return repoConfigs.filter(+ (repo) =>+ (repoStatusFilter === 'all' || isRepoOn(repo) === (repoStatusFilter === 'on')) &&+ (!needle || repo.repository.toLowerCase().includes(needle))+ )},],+ visibleRepoConfigs: [+ (s) => [s.filteredRepoConfigs, s.showingAllRepos],+ (filteredRepoConfigs: StamphogRepoConfigApi[], showingAllRepos: boolean): StamphogRepoConfigApi[] =>+ showingAllRepos ? filteredRepoConfigs : filteredRepoConfigs.slice(0, VISIBLE_REPO_LIMIT),+ ],}),listeners(({ actions, values }) => ({- setRepoEnabled: async ({ id, enabled }) => {+ updateRepoConfig: async ({ id, patch }) => {try {- await stamphogRepoConfigsPartialUpdate(String(values.currentProjectId), id, { enabled })- actions.loadRepoConfigs()+ actions.repoConfigUpdated(+ await stamphogRepoConfigsPartialUpdate(String(values.currentProjectId), id, patch)+ )} catch {lemonToast.error('Failed to update repository')} finally {actions.repoUpdateDone(id)}},- setDigestEnabled: async ({ id, enabled }) => {- try {- await stamphogRepoConfigsPartialUpdate(String(values.currentProjectId), id, { digest_enabled: enabled })- actions.loadRepoConfigs()- } catch {- lemonToast.error('Failed to update digest setting')- } finally {- actions.repoUpdateDone(id)- }- },- setReviewMode: async ({ id, reviewMode }) => {- try {- await stamphogRepoConfigsPartialUpdate(String(values.currentProjectId), id, {- review_mode: reviewMode,- })- actions.loadRepoConfigs()- } catch {- lemonToast.error('Failed to update review mode')- } finally {- actions.repoUpdateDone(id)- }- },- setTriggerLabel: async ({ id, triggerLabel }) => {- try {- await stamphogRepoConfigsPartialUpdate(String(values.currentProjectId), id, {- trigger_label: triggerLabel,- })- actions.loadRepoConfigs()- } catch {- lemonToast.error('Failed to update trigger label')- } finally {- actions.repoUpdateDone(id)- }- },- connectInstallation: ({ installationId }) => {+ connectInstallation: async ({ installationId }) => {sessionStorage.setItem(PENDING_INSTALLATION_STORAGE_KEY, installationId)- actions.redirectToAuthorize()- },- redirectToAuthorize: async () => {// The setup_action=update redirect carries no code (nothing to sync), so bounce the browser- // through the authorize URL for one silent hop — GitHub redirects straight back with a code- // and the discovery path takes over. Fetch install info directly rather than racing the loader,- // which may not have resolved yet when the callback fires.+ // through the authorize URL for one silent hop. GitHub redirects straight back with a code, and+ // the stashed installation id goes with it. Fetch install info directly rather than racing the+ // loader, which may not have resolved yet when the callback fires.try {const info = await stamphogRepoConfigsInstallInfoRetrieve(String(values.currentProjectId))if (info.authorize_url) {@@ -417,6 +414,10 @@ export const stamphogSceneLogic = kea<stamphogSceneLogicType>([// GitHub sends the user back with ?error=access_denied when they hit Cancel on the// authorize screen — a normal action on the primary connect flow, not a failure. Land// them back on the plain page instead of a silent dead-end on the callback URL.+ // Read and clear the stashed pick before any early return, so a stale id cannot bind the wrong+ // installation on a later code-only callback.+ const stashedInstallationId = sessionStorage.getItem(PENDING_INSTALLATION_STORAGE_KEY)+ sessionStorage.removeItem(PENDING_INSTALLATION_STORAGE_KEY)if (searchParams.error) {router.actions.replace(urls.stamphog())if (searchParams.error === 'access_denied') {@@ -426,10 +427,17 @@ export const stamphogSceneLogic = kea<stamphogSceneLogicType>([}return}- // A stashed pick (from the multi-installation chooser) fills in for the missing- // installation_id on the authorize redirect; an explicit URL param wins.- const stashedInstallationId = sessionStorage.getItem(PENDING_INSTALLATION_STORAGE_KEY)- sessionStorage.removeItem(PENDING_INSTALLATION_STORAGE_KEY)+ // A member without admin rights on the GitHub organization only files an install request, so+ // GitHub returns without an installation or a code. Nothing can connect until an owner approves.+ if (searchParams.setup_action === 'request') {+ router.actions.replace(urls.stamphog())+ lemonToast.info(+ 'GitHub sent your install request to the organization owners. Connect again once they approve it.'+ )+ return+ }+ // A stashed pick fills in for the missing installation_id on the authorize redirect; an explicit+ // URL param wins.const installationId = searchParams.installation_id || stashedInstallationId || undefinedconst code = searchParams.codeconst state = searchParams.state@@ -440,7 +448,10 @@ export const stamphogSceneLogic = kea<stamphogSceneLogicType>([state: String(state),})} else if (installationId && state) {- actions.redirectToAuthorize()+ actions.connectInstallation(String(installationId))+ } else {+ // Backing out of GitHub's install page returns only the state, so there is nothing to connect.+ router.actions.replace(urls.stamphog())}},})),diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 5abfff87edcf..84ea0b329d95 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -86323,9 +86323,9 @@ export namespace Schemas {export interface StamphogInstallInfo {/** URL-friendly slug of the dedicated Stamphog GitHub App, or blank if unconfigured. */readonly app_slug: string;- /** GitHub install URL (github.com/apps/<slug>/installations/new) the user opens to install the App, or blank if the App slug is unconfigured. Used for the genuinely-not-installed case; the primary 'Connect' button uses authorize_url instead. */+ /** GitHub install URL (github.com/apps/<slug>/installations/new) the 'Connect' button opens. The user picks a GitHub account there and chooses which repositories the App can reach, including an account where the App is already installed. Blank if the App slug is unconfigured. */readonly install_url: string;- /** GitHub authorize URL (github.com/login/oauth/authorize) the 'Connect' button opens. Authorize-first: an already-installed user is redirected straight back with an OAuth code (no installation_id), and sync_installation then discovers their installations server-side. Blank if the App client id is unconfigured. */+ /** GitHub authorize URL (github.com/login/oauth/authorize). GitHub's redirect after configuring an existing installation carries no OAuth code, so the client passes through this URL once: an installed App redirects straight back with a code, which sync_installation uses to prove ownership. Blank if the App client id is unconfigured. */readonly authorize_url: string;}