From b283d753c090e76a7632cc486f0b68df03303d78 Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Thu, 5 Nov 2026 23:41:06 -0800 Subject: [PATCH 1/8] feat(connectors): the GitHub install link says what All repositories gives, and the picker names the repo GitHub's install page opens on All repositories, so the warning now sits on the link and says what leaving it costs. The picker labels each repository public or private and names the one a person is connecting. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015AKgpQtAEnhB56gowm8yYg --- .../service/githubConnectRepositories.test.js | 15 +++++++-- backend/services/githubConnectProof.ts | 5 ++- frontend/src/i18n/locales/en.json | 7 +++- frontend/src/i18n/locales/zh-CN.json | 7 +++- .../ConnectorsPage.githubAccessStep.test.tsx | 18 +++++----- .../__tests__/ConnectorsPage.tools.test.tsx | 33 +++++++++++++++++-- frontend/src/v2/connectors/ConnectorsPage.tsx | 28 +++++++--------- .../v2/connectors/GithubInstallWarning.tsx | 28 ++++++++++++++++ frontend/src/v2/connectors/ToolPanels.tsx | 31 +++++++++++++---- frontend/src/v2/connectors/connectors.css | 3 ++ frontend/src/v2/connectors/toolModel.ts | 1 + 11 files changed, 137 insertions(+), 39 deletions(-) create mode 100644 frontend/src/v2/connectors/GithubInstallWarning.tsx diff --git a/backend/__tests__/service/githubConnectRepositories.test.js b/backend/__tests__/service/githubConnectRepositories.test.js index b7b94dce04..2b6d36b1bd 100644 --- a/backend/__tests__/service/githubConnectRepositories.test.js +++ b/backend/__tests__/service/githubConnectRepositories.test.js @@ -94,7 +94,7 @@ let nextRepoId = 1000; const repo = (fullName, permissions = { push: true, pull: true }, id = (nextRepoId += 1)) => { const [login, name] = fullName.split('/'); return { - id, name, full_name: fullName, owner: { login }, permissions, + id, name, full_name: fullName, owner: { login }, permissions, private: true, }; }; const filler = (count) => Array.from({ length: count }, (_, i) => repo(`Outside-Team/filler-${i}`)); @@ -361,12 +361,21 @@ describe('F221: the picker for a person\'s own repositories', () => { const res = await list(alice); expect(res.status).toBe(200); expect(res.body.repositories).toEqual([ - { installationId: INSTALL, owner: 'Outside-Team', repo: 'Widget' }, - { installationId: INSTALL, owner: 'Outside-Team', repo: 'Gadget' }, + { installationId: INSTALL, owner: 'Outside-Team', repo: 'Widget', private: true }, + { installationId: INSTALL, owner: 'Outside-Team', repo: 'Gadget', private: true }, ]); expect(res.body.truncated).toBe(false); }); + it('says which rows are public, and treats a row GitHub does not mark as private', async () => { + const { private: unmarked, ...noFlag } = repo('Outside-Team/Unmarked'); + expect(unmarked).toBe(true); + view.repositories[INSTALL] = [{ ...repo('Outside-Team/Open'), private: false }, noFlag]; + await giveUserToken(alice, 'alice-user-token'); + const res = await list(alice); + expect(res.body.repositories.map((row) => [row.repo, row.private])).toEqual([['Open', false], ['Unmarked', true]]); + }); + test('every request carries the caller\'s own token, and creates nothing', async () => { await giveUserToken(alice, 'alice-user-token'); await giveUserToken(bob, 'bob-user-token'); diff --git a/backend/services/githubConnectProof.ts b/backend/services/githubConnectProof.ts index 52dde86286..a25e4f15da 100644 --- a/backend/services/githubConnectProof.ts +++ b/backend/services/githubConnectProof.ts @@ -143,6 +143,7 @@ interface RepositoryEntry { name?: unknown; full_name?: unknown; owner?: { login?: unknown }; + private?: unknown; permissions?: { admin?: unknown; maintain?: unknown; push?: unknown }; } @@ -198,6 +199,7 @@ export interface ConnectableRepository { installationId: string; owner: string; repo: string; + private: boolean; } /** @@ -251,7 +253,8 @@ export const listConnectRepositories = async ( list.filter(canPush).forEach((repository) => { const owner = String(repository?.owner?.login ?? ''); const repo = String(repository?.name ?? ''); - if (owner && repo) repositories.push({ installationId, owner, repo }); + // A row GitHub doesn't mark public is not called public. + if (owner && repo) repositories.push({ installationId, owner, repo, private: repository?.private !== false }); }); if (list.length < PAGE_SIZE) break; if (page === LIST_MAX_PAGES) truncated = true; diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json index c9e9868e88..7c25750bc8 100644 --- a/frontend/src/i18n/locales/en.json +++ b/frontend/src/i18n/locales/en.json @@ -2603,7 +2603,8 @@ "gatesTitle": "Pods that reach this channel", "hostedMcpAppInstalledConnected": "{{provider}} App installed. {{provider}} is connected.", "hostedMcpAppInstalledFinish": "{{provider}} App installed. Press Connect on {{provider}} to finish.", - "hostedMcpAccessNext": "Choose 'Only select repositories' to limit which private repos {{provider}} can read. Public repos are always readable.", + "hostedMcpAccessNext": "On GitHub, choose 'Only select repositories'.", + "hostedMcpAccessAll": "GitHub's install page opens on All repositories. Leave it there and Commonly Connect can reach every repository on that account or org, including new ones. Public repos are always readable.", "hostedMcpAccessOpen": "Open {{provider}}", "hostedMcpReachNone": "{{provider}} is connected, but this account can't see any projects, so searches will come back empty. Add a project in {{provider}}, or connect an account that has one.", "hostedMcpManualRevoke": "Your previous {{provider}} account may still have Commonly connected. Switch to it on {{provider}}, then remove Commonly there.", @@ -2818,6 +2819,10 @@ "connectGithub": "Connect GitHub", "none": "No repositories left to connect. To add more, install Commonly Connect on your account or org and pick the repositories.", "choose": "Choose a repository", + "optionPrivate": "{{repository}} (private)", + "optionPublic": "{{repository}} (public)", + "pickedPrivate": "You're connecting {{repository}}, a private repository.", + "pickedPublic": "You're connecting {{repository}}, a public repository.", "truncated": "This list may be incomplete.", "connecting": "Connecting…", "checkAgain": "Check again", diff --git a/frontend/src/i18n/locales/zh-CN.json b/frontend/src/i18n/locales/zh-CN.json index 5d6735a119..87be21b439 100644 --- a/frontend/src/i18n/locales/zh-CN.json +++ b/frontend/src/i18n/locales/zh-CN.json @@ -2591,7 +2591,8 @@ "gatesTitle": "接入此频道的 Pod", "hostedMcpAppInstalledConnected": "{{provider}} App 已安装,{{provider}} 已连接。", "hostedMcpAppInstalledFinish": "{{provider}} App 已安装。在 {{provider}} 卡片上点「连接」完成设置。", - "hostedMcpAccessNext": "选择“Only select repositories”,限定 {{provider}} 可以读取哪些私有仓库。公开仓库始终可以读取。", + "hostedMcpAccessNext": "在 GitHub 上选择“Only select repositories”。", + "hostedMcpAccessAll": "GitHub 的安装页默认选中 All repositories。如果不改,Commonly Connect 就能访问这个账号或组织下的所有仓库,包括以后新建的仓库。公开仓库始终可以读取。", "hostedMcpAccessOpen": "打开 {{provider}}", "hostedMcpReachNone": "{{provider}} 已连接,但这个账号看不到任何项目,所以搜索结果为空。请在 {{provider}} 里添加项目,或者连接一个有项目的账号。", "hostedMcpManualRevoke": "你之前的 {{provider}} 账号可能仍保留对 Commonly 的授权。请在 {{provider}} 切换到那个账号,再在那里移除 Commonly。", @@ -2819,6 +2820,10 @@ "connectGithub": "连接 GitHub", "none": "没有其他可连接的仓库了。如需添加,请把 Commonly Connect 安装到你的账号或组织,再选择仓库。", "choose": "选择仓库", + "optionPrivate": "{{repository}}(私有)", + "optionPublic": "{{repository}}(公开)", + "pickedPrivate": "你要连接的是私有仓库 {{repository}}。", + "pickedPublic": "你要连接的是公开仓库 {{repository}}。", "truncated": "这个列表可能不完整。", "connecting": "正在连接…", "checkAgain": "重新检查", diff --git a/frontend/src/v2/__tests__/ConnectorsPage.githubAccessStep.test.tsx b/frontend/src/v2/__tests__/ConnectorsPage.githubAccessStep.test.tsx index 5fcfe128f9..ce7901948b 100644 --- a/frontend/src/v2/__tests__/ConnectorsPage.githubAccessStep.test.tsx +++ b/frontend/src/v2/__tests__/ConnectorsPage.githubAccessStep.test.tsx @@ -107,12 +107,13 @@ describe('connected, with the App not installed yet (next=access)', () => { mockApi({ connectors: [githubRow], installables: [hostedGithub({ connections: [{ connectionId: 'i-gh', owner: 'sam', repo: '' }] })] }); renderPage(); - const notice = (await screen.findByText(fill(en.connectors.hostedMcpAccessNext), { exact: false })).closest('p'); + const notice = (await screen.findByText(en.connectors.hostedMcpAccessNext)).closest('.v2-cx-warning'); expect(notice).toHaveAttribute('role', 'status'); // GitHub's install page preselects "All repositories" and always reads - // public repos, so the notice names the choice; the link only opens the page. + // public repos, so the link carries the choice and what leaving it costs. + expect(notice).toHaveTextContent("On GitHub, choose 'Only select repositories'."); expect(notice).toHaveTextContent( - "Choose 'Only select repositories' to limit which private repos GitHub can read. Public repos are always readable.", + 'Leave it there and Commonly Connect can reach every repository on that account or org, including new ones.', ); const link = within(notice).getByRole('link', { name: fill(en.connectors.hostedMcpAccessOpen) }); expect(link).toHaveTextContent('Open GitHub'); @@ -133,7 +134,7 @@ describe('connected, with the App not installed yet (next=access)', () => { }); renderPage(); - expect(await screen.findByText(fill(en.connectors.hostedMcpAccessNext), { exact: false })).toBeInTheDocument(); + expect(await screen.findByText(en.connectors.hostedMcpAccessNext)).toBeInTheDocument(); const popover = await findPopover('GitHub'); expect(await within(popover).findByRole('link', { name: "Open GitHub's connected apps" })).toHaveAttribute('href', revokePage); expect(window.location.search).toBe(''); @@ -146,8 +147,9 @@ describe('connected, with the App not installed yet (next=access)', () => { await act(async () => { await i18n.changeLanguage('zh-CN'); }); try { renderPage(); - const notice = (await screen.findByText('Only select repositories', { exact: false })).closest('p'); - expect(notice).toHaveTextContent('选择“Only select repositories”,限定 GitHub 可以读取哪些私有仓库。公开仓库始终可以读取。'); + const notice = (await screen.findByText('Only select repositories', { exact: false })).closest('.v2-cx-warning'); + expect(notice).toHaveTextContent('在 GitHub 上选择“Only select repositories”。'); + expect(notice).toHaveTextContent('Commonly Connect 就能访问这个账号或组织下的所有仓库'); expect(within(notice).getByRole('link', { name: '打开 GitHub' })).toHaveAttribute('href', accessPage); } finally { await act(async () => { await i18n.changeLanguage('en'); }); @@ -162,7 +164,7 @@ describe('connected, with the App not installed yet (next=access)', () => { await pageReady(); await waitFor(() => expect(window.location.search).toBe('')); await settle(); - expect(screen.queryByText(fill(en.connectors.hostedMcpAccessNext), { exact: false })).toBeNull(); + expect(screen.queryByText(en.connectors.hostedMcpAccessNext)).toBeNull(); }); it('leaves other query values in place', async () => { @@ -170,7 +172,7 @@ describe('connected, with the App not installed yet (next=access)', () => { mockApi({ connectors: [githubRow], installables: [hostedGithub()] }); renderPage(); - await screen.findByText(fill(en.connectors.hostedMcpAccessNext), { exact: false }); + await screen.findByText(en.connectors.hostedMcpAccessNext); expect(window.location.search).toBe('?keep=1'); }); }); diff --git a/frontend/src/v2/__tests__/ConnectorsPage.tools.test.tsx b/frontend/src/v2/__tests__/ConnectorsPage.tools.test.tsx index 9eda5aa16c..a9941a74e2 100644 --- a/frontend/src/v2/__tests__/ConnectorsPage.tools.test.tsx +++ b/frontend/src/v2/__tests__/ConnectorsPage.tools.test.tsx @@ -1645,8 +1645,8 @@ describe('F221: connecting your own repository', () => { ...linearEntry, installableId: 'github-mcp', label: 'GitHub MCP', entryId: 'github-mcp', repositoryConnect: true, accessPage: 'https://github.com/apps/connect/installations/new', connections: [], }; const repos = [ - { installationId: '7001', owner: 'Outside-Team', repo: 'Widget' }, - { installationId: '7001', owner: 'Outside-Team', repo: 'Gadget' }, + { installationId: '7001', owner: 'Outside-Team', repo: 'Widget', private: true }, + { installationId: '7001', owner: 'Outside-Team', repo: 'Gadget', private: false }, ]; const openStep = async ({ listed, refused, entries = [appEntry, hostedGithub] }) => { const route = (url) => { @@ -1690,6 +1690,35 @@ describe('F221: connecting your own repository', () => { const step = await openStep({ listed: { repositories: [], truncated: false } }); const link = await within(step).findByRole('link'); expect(link).toHaveAttribute('href', hostedGithub.accessPage); + const warning = link.closest('.v2-cx-warning'); + expect(warning).toHaveTextContent("On GitHub, choose 'Only select repositories'."); + expect(warning).toHaveTextContent('Commonly Connect can reach every repository on that account or org'); + }); + + it('warns beside the install link on the offer, and only for GitHub', async () => { + mockTools({ entries: [hostedGithub, { ...linearEntry, accessPage: 'https://linear.example/access' }], grants: [], seats: { p1: [scout], p2: [] } }); + renderPage(); + const github = await openToolPopover('GitHub MCP'); + expect(within(github).getByRole('link', { name: 'Choose what GitHub MCP can reach' }).closest('.v2-cx-warning')).not.toBeNull(); + const linear = await openToolPopover('Linear'); + expect(within(linear).queryByText("On GitHub, choose 'Only select repositories'.")).toBeNull(); + }); + + it('labels each row and names the picked repository, public or private', async () => { + const step = await openStep({ listed: { repositories: repos, truncated: false } }); + const select = await within(step).findByLabelText('repository'); + expect(within(select).getByRole('option', { name: 'Outside-Team/Widget (private)' })).toHaveValue('Outside-Team/Widget'); + expect(within(select).getByRole('option', { name: 'Outside-Team/Gadget (public)' })).toHaveValue('Outside-Team/Gadget'); + expect(within(step).queryByRole('status')).toBeNull(); + fireEvent.change(select, { target: { value: 'Outside-Team/Gadget' } }); + expect(within(step).getByRole('status')).toHaveTextContent("You're connecting Outside-Team/Gadget, a public repository."); + fireEvent.change(select, { target: { value: 'Outside-Team/Widget' } }); + expect(within(step).getByRole('status')).toHaveTextContent("You're connecting Outside-Team/Widget, a private repository."); + }); + + it('names the one repository it picked by itself', async () => { + const step = await openStep({ listed: { repositories: [repos[1]], truncated: false } }); + expect(await within(step).findByRole('status')).toHaveTextContent("You're connecting Outside-Team/Gadget, a public repository."); }); it('a member with a live grant can still connect another repository', async () => { diff --git a/frontend/src/v2/connectors/ConnectorsPage.tsx b/frontend/src/v2/connectors/ConnectorsPage.tsx index 44923084c6..b7c0cbe495 100644 --- a/frontend/src/v2/connectors/ConnectorsPage.tsx +++ b/frontend/src/v2/connectors/ConnectorsPage.tsx @@ -20,6 +20,7 @@ import ConnectorDrawer, { ConnectorDrawerPresence } from './ConnectorDrawer'; import ConnectorLogo from './ConnectorLogo'; import ConnectorPopover from './ConnectorPopover'; import ConnectorTile from './ConnectorTile'; +import GithubInstallWarning from './GithubInstallWarning'; import type { TileDot } from './ConnectorTile'; import './connectors.css'; @@ -552,12 +553,18 @@ const ConnectorsPage: React.FC = () => { const callbackNotice = c.hostedMcpCallbackNotice; const noticeBlock = ( <> - {callbackNotice && ( + {callbackNotice && callbackNotice.kind === 'access' && ( + + + {t('connectors.hostedMcpAccessOpen', { defaultValue: 'Open {{provider}}', provider: callbackNotice.provider })} + + + )} + {callbackNotice && callbackNotice.kind !== 'access' && (

{callbackNotice.kind === 'reach' ? t('connectors.hostedMcpReachNone', { provider: callbackNotice.provider }) - : callbackNotice.kind === 'installed' - ? (callbackNotice.connected + : callbackNotice.connected ? t('connectors.hostedMcpAppInstalledConnected', { defaultValue: '{{provider}} App installed. {{provider}} is connected.', provider: callbackNotice.provider, @@ -565,20 +572,7 @@ const ConnectorsPage: React.FC = () => { : t('connectors.hostedMcpAppInstalledFinish', { defaultValue: '{{provider}} App installed. Press Connect on {{provider}} to finish.', provider: callbackNotice.provider, - })) - : ( - <> - {/* GitHub's install page preselects "All repositories" and always - reads public repos, so the notice names the choice to make there. */} - {t('connectors.hostedMcpAccessNext', { - defaultValue: "Choose 'Only select repositories' to limit which private repos {{provider}} can read. Public repos are always readable.", - provider: callbackNotice.provider, - })}{' '} - - {t('connectors.hostedMcpAccessOpen', { defaultValue: 'Open {{provider}}', provider: callbackNotice.provider })} - - - )} + })}

)} {errorText && ( diff --git a/frontend/src/v2/connectors/GithubInstallWarning.tsx b/frontend/src/v2/connectors/GithubInstallWarning.tsx new file mode 100644 index 0000000000..522ded8e3d --- /dev/null +++ b/frontend/src/v2/connectors/GithubInstallWarning.tsx @@ -0,0 +1,28 @@ +// F221: GitHub's install page opens on "All repositories", so a click-through +// gives Commonly Connect every repo. The choice and what it costs sit with the +// link that opens that page, not earlier in the flow. +import React from 'react'; +import { useTranslation } from 'react-i18next'; + +interface GithubInstallWarningProps { + /** The link to the install page. */ + children: React.ReactNode; + role?: string; +} + +const GithubInstallWarning: React.FC = ({ children, role }) => { + const { t } = useTranslation(); + return ( +
+ {t('connectors.hostedMcpAccessNext', { defaultValue: "On GitHub, choose 'Only select repositories'." })} +

+ {t('connectors.hostedMcpAccessAll', { + defaultValue: "GitHub's install page opens on All repositories. Leave it there and Commonly Connect can reach every repository on that account or org, including new ones. Public repos are always readable.", + })} +

+

{children}

+
+ ); +}; + +export default GithubInstallWarning; diff --git a/frontend/src/v2/connectors/ToolPanels.tsx b/frontend/src/v2/connectors/ToolPanels.tsx index bf7f0fcb65..f78fa849c3 100644 --- a/frontend/src/v2/connectors/ToolPanels.tsx +++ b/frontend/src/v2/connectors/ToolPanels.tsx @@ -7,6 +7,7 @@ import { localizeRelativeTime, localizeWindow } from '../utils/localizeRelativeT import { ActGlyph } from '../icons/glyphs'; import { PlatformGlyph } from '../icons/platforms'; import { catalogDescription } from '../utils/connectorCatalogDescription'; +import GithubInstallWarning from './GithubInstallWarning'; import { grantHarnessNames } from '../utils/harnessCatalog'; import { shortAge, @@ -497,7 +498,9 @@ export const useToolPanels = (m: ToolConnectorsModel) => { {renderLinearWriteNote(entry)} {renderReachNote(entry, entry.connections)} {(canConnectHosted || keyable.length > 0) && entry.connectNotice &&

{entry.connectNotice}

} - {isHosted && entry.available && entry.accessPage &&

{renderAccessLink(entry)}

} + {isHosted && entry.available && entry.accessPage && (entry.entryId === 'github-mcp' + ? {renderAccessLink(entry)} + :

{renderAccessLink(entry)}

)} {renderManualRevokeNotice(entry)} ); @@ -566,6 +569,9 @@ export const useToolPanels = (m: ToolConnectorsModel) => { if (!repositoryConnect) return null; const { status, repositories, truncated, selected } = repositoryConnect; const githubEntry = catalog.find((entry) => entry.entryId === 'github-mcp'); + // The list can hold public repositories, and a single row comes picked, so + // the step names what Connect will connect. + const picked = repositories.find(({ owner, repo }) => `${owner}/${repo}` === selected); return (