Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Swarm GitHub access: "You can push" once GitHub has said so, and an ask screen for someone it refused (#2337)

scholes-autonomous7ba1136ea3cb
diff --git a/backend/integration/superTabGithub.test.ts b/backend/integration/superTabGithub.test.ts
index 9050ccad9..3934ca9c4 100644
--- a/backend/integration/superTabGithub.test.ts
+++ b/backend/integration/superTabGithub.test.ts
@@ -71,12 +71,18 @@ async function fresh(options: { github?: boolean; approveAll?: boolean; signIn?:
})
// Every project approved unless a test says otherwise (github/approvals.ts); what was approved, kept here.
const approved: Array<{ tabId: string; projectId: string; repository: string; scope: string; login: string }> = []
+ const refused = new Map<string, string>()
const approvals: Approvals = {
approved: async (_env, tabId, projectId, repository) => options.approveAll !== false
|| approved.some(a => a.tabId === tabId && a.repository === repository.toLowerCase() && (a.scope === 'swarm' || a.projectId === projectId)),
approve: async (request, login) => { approved.push({ ...request, login }) },
approvedProjects: async (_env, tabId, repository) => approved
.filter(a => a.tabId === tabId && a.repository === repository.toLowerCase() && a.scope === 'project').map(a => a.projectId),
+ refuse: async (request, login) => { refused.set(`${request.tabId}/${request.projectId}/${request.repository}/${request.userId}`, login) },
+ reader: async (_env, tabId, projectId, repository, userId) => {
+ const login = refused.get(`${tabId}/${projectId}/${repository.toLowerCase()}/${userId}`)
+ return login ? { canPush: false, githubLogin: login } : null
+ },
}
await app.register(superTabRoutes, { store, github: options.github === false ? null : tokens, approvals, signIn: options.signIn ?? null })
await app.ready()
@@ -333,6 +339,9 @@ describe('a queued start\'s preparation token', () => {
const refused = await env.app.inject({ method: 'GET', url: `/api/github/callback?code=c&state=${encodeURIComponent(state)}` })
expect(refused.statusCode).toBe(403)
expect(refused.body).toContain('can&#39;t push to example/app')
+ // The app then knows GitHub said so, and asks them to send it on (design 2026-10-30).
+ const after = await env.app.inject({ method: 'GET', url: `/api/super-tabs/${tab}/projects/lead/github`, headers: { authorization: `Bearer ${owner.sub}` } })
+ expect(after.json().data).toMatchObject({ state: 'not-approved', you: { canPush: false, githubLogin: 'olive' } })
push = true
const done = await env.app.inject({ method: 'GET', url: `/api/github/callback?code=c&state=${encodeURIComponent(state)}` })
expect(done.statusCode).toBe(200)
diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma
index 63c3ffd2f..172b2cdc9 100644
--- a/backend/prisma/schema.prisma
+++ b/backend/prisma/schema.prisma
@@ -2005,4 +2005,24 @@ model GitHubRepositoryApproval {
@@unique([autonomousEnv, tabId, repository, projectId])
@@index([tabId])
+ /// Whether the reader allowed a repository before, in any Swarm (github/approvals.ts `reader`).
+ @@index([autonomousEnv, approvedBy, repository])
+}
+
+/// A person GitHub said cannot push to a project's repository when they tried to allow it (github/approvals.ts): the app
+/// then asks them to send it to someone who can, instead of offering the same sign-in again. One per person, project and
+/// repository; removed when the repository is allowed for the project.
+model GitHubApprovalRefusal {
+ id String @id @map("_id")
+ autonomousEnv String
+ tabId String
+ projectId String
+ /// owner/name, lower case, as the project names it.
+ repository String
+ userId String
+ githubLogin String
+ createdAt DateTime @default(now())
+
+ @@unique([autonomousEnv, tabId, repository, projectId, userId])
+ @@index([tabId])
}
diff --git a/backend/src/github/approvals.test.ts b/backend/src/github/approvals.test.ts
index d975218cd..0c60f4d27 100644
--- a/backend/src/github/approvals.test.ts
+++ b/backend/src/github/approvals.test.ts
@@ -77,7 +77,7 @@ describe('approvals', () => {
findFirst: vi.fn(async ({ where }: { where: { autonomousEnv: string; tabId: string; repository: string; projectId: { in: string[] } } }) =>
rows.find(r => r.autonomousEnv === where.autonomousEnv && r.tabId === where.tabId && r.repository === where.repository && where.projectId.in.includes(r.projectId!)) ?? null),
upsert: vi.fn(async ({ create }: { create: Record<string, string> }) => { rows.push(create); return create }),
- } }
+ }, gitHubApprovalRefusal: { deleteMany: vi.fn(async () => ({ count: 0 })) } }
const approvals = new PrismaApprovals(db as never)
expect(await approvals.approved('prod', 'tab', 'p1', 'alice/a')).toBe(false)
await approvals.approve(request, 'alice')
@@ -89,4 +89,46 @@ describe('approvals', () => {
expect(await approvals.approved('prod', 'tab', 'p2', 'alice/a')).toBe(true)
expect(await approvals.approved('prod', 'other-tab', 'p2', 'alice/a')).toBe(false)
})
+
+ // Design 2026-10-30: the app shows "You can push" to someone who allowed the repository before, and asks someone GitHub
+ // refused to send it on, instead of offering the same sign-in again.
+ it('remember what GitHub said about the reader, and forget a refusal once the repository is allowed', async () => {
+ const approved: Array<Record<string, string>> = [], refused: Array<Record<string, string>> = []
+ const same = (r: Record<string, string>, w: Record<string, unknown>) => Object.entries(w).every(([k, v]) => r[k] === v)
+ const db = {
+ gitHubRepositoryApproval: {
+ findFirst: vi.fn(async ({ where }: { where: Record<string, unknown> }) => approved.find(r => same(r, where)) ?? null),
+ upsert: vi.fn(async ({ create }: { create: Record<string, string> }) => { approved.push(create); return create }),
+ },
+ gitHubApprovalRefusal: {
+ findUnique: vi.fn(async ({ where }: { where: { autonomousEnv_tabId_repository_projectId_userId: Record<string, string> } }) =>
+ refused.find(r => same(r, where.autonomousEnv_tabId_repository_projectId_userId)) ?? null),
+ upsert: vi.fn(async ({ where, update, create }: { where: { autonomousEnv_tabId_repository_projectId_userId: Record<string, string> };
+ update: Record<string, unknown>; create: Record<string, string> }) => {
+ const row = refused.find(r => same(r, where.autonomousEnv_tabId_repository_projectId_userId))
+ if (row) Object.assign(row, update); else refused.push(create)
+ }),
+ deleteMany: vi.fn(async ({ where }: { where: Record<string, unknown> }) => {
+ for (let i = refused.length - 1; i >= 0; i--) if (same(refused[i]!, where)) refused.splice(i, 1)
+ }),
+ },
+ }
+ const approvals = new PrismaApprovals(db as never)
+ expect(await approvals.reader('prod', 'tab', 'p1', 'alice/a', 'alice')).toBeNull()
+ await approvals.refuse(request, 'bob-gh')
+ await approvals.refuse(request, 'bob-gh2')
+ expect(refused).toHaveLength(1)
+ expect(await approvals.reader('prod', 'tab', 'p1', 'Alice/A', 'alice')).toEqual({ canPush: false, githubLogin: 'bob-gh2' })
+ expect(await approvals.reader('prod', 'tab', 'p1', 'alice/a', 'someone-else')).toBeNull()
+ // Someone else allows it: the refusal goes, and whoever allowed it reads as able to push, in the Swarm's other projects and
+ // in their other Swarms too.
+ await approvals.approve({ ...request, userId: 'user-2' }, 'carol')
+ expect(refused).toHaveLength(0)
+ expect(await approvals.reader('prod', 'tab', 'p2', 'alice/a', 'user-2')).toEqual({ canPush: true, githubLogin: 'carol' })
+ expect(await approvals.reader('prod', 'another-swarm', 'p9', 'alice/a', 'user-2')).toEqual({ canPush: true, githubLogin: 'carol' })
+ expect(await approvals.reader('dev', 'another-swarm', 'p9', 'alice/a', 'user-2')).toBeNull()
+ await approvals.refuse({ ...request, projectId: 'p2' }, 'bob-gh')
+ await approvals.approve({ ...request, scope: 'swarm', userId: 'user-2' }, 'carol')
+ expect(refused).toHaveLength(0)
+ })
})
diff --git a/backend/src/github/approvals.ts b/backend/src/github/approvals.ts
index 5eb5a52f1..e5b052330 100644
--- a/backend/src/github/approvals.ts
+++ b/backend/src/github/approvals.ts
@@ -109,16 +109,23 @@ export function githubSignIn(env: { GITHUB_APP_CLIENT_ID: string; GITHUB_APP_CLI
return new GitHubSignIn({ clientId, clientSecret })
}
+/** What GitHub last said about the reader on a repository: they can push (they allowed it before, in any Swarm), or they
+ * cannot (their sign-in was refused for this project). Null before they signed in for it. */
+export interface ReaderAccess { canPush: boolean; githubLogin: string }
+
/** Where approvals are kept. */
export interface Approvals {
approved(autonomousEnv: string, tabId: string, projectId: string, repository: string): Promise<boolean>
approve(request: ApprovalRequest, githubLogin: string): Promise<void>
+ /** GitHub said [request]'s person cannot push to its repository (2026-10-30 design: the app asks them to send it on). */
+ refuse(request: ApprovalRequest, githubLogin: string): Promise<void>
+ reader(autonomousEnv: string, tabId: string, projectId: string, repository: string, userId: string): Promise<ReaderAccess | null>
/** The projects of [tabId] [repository] is approved for one by one (not those approved for the whole Swarm). */
approvedProjects(autonomousEnv: string, tabId: string, repository: string): Promise<string[]>
}
export class PrismaApprovals implements Approvals {
- constructor(private readonly db: Pick<PrismaClient, 'gitHubRepositoryApproval'>) {}
+ constructor(private readonly db: Pick<PrismaClient, 'gitHubRepositoryApproval' | 'gitHubApprovalRefusal'>) {}
async approved(autonomousEnv: string, tabId: string, projectId: string, repository: string): Promise<boolean> {
return !!await this.db.gitHubRepositoryApproval.findFirst({ where: { autonomousEnv, tabId, repository: repository.toLowerCase(),
@@ -138,5 +145,28 @@ export class PrismaApprovals implements Approvals {
await this.db.gitHubRepositoryApproval.upsert({ where, update: { approvedBy: request.userId, githubLogin },
create: { id: randomUUID(), autonomousEnv: request.autonomousEnv, tabId: request.tabId, projectId, repository: request.repository,
approvedBy: request.userId, githubLogin } })
+ // Allowed now: nobody's refusal for it is worth showing any more.
+ await this.db.gitHubApprovalRefusal.deleteMany({ where: { autonomousEnv: request.autonomousEnv, tabId: request.tabId,
+ repository: request.repository, ...(request.scope === 'swarm' ? {} : { projectId: request.projectId }) } })
+ }
+
+ async refuse(request: ApprovalRequest, githubLogin: string): Promise<void> {
+ const where = { autonomousEnv_tabId_repository_projectId_userId: { autonomousEnv: request.autonomousEnv, tabId: request.tabId,
+ repository: request.repository, projectId: request.projectId, userId: request.userId } }
+ await this.db.gitHubApprovalRefusal.upsert({ where, update: { githubLogin, createdAt: new Date() },
+ create: { id: randomUUID(), autonomousEnv: request.autonomousEnv, tabId: request.tabId, projectId: request.projectId,
+ repository: request.repository, userId: request.userId, githubLogin } })
+ }
+
+ async reader(autonomousEnv: string, tabId: string, projectId: string, repository: string, userId: string): Promise<ReaderAccess | null> {
+ repository = repository.toLowerCase()
+ const refused = await this.db.gitHubApprovalRefusal.findUnique({ where: { autonomousEnv_tabId_repository_projectId_userId:
+ { autonomousEnv, tabId, repository, projectId, userId } }, select: { githubLogin: true } })
+ if (refused) return { canPush: false, githubLogin: refused.githubLogin }
+ // They allowed this repository before, for any project in any of their Swarms: GitHub said then that they can push to it
+ // (2026-10-30: a new Swarm on a repository its owner had allowed in another Swarm showed no "You can push").
+ const allowed = await this.db.gitHubRepositoryApproval.findFirst({ where: { autonomousEnv, repository, approvedBy: userId },
+ select: { githubLogin: true } })
+ return allowed ? { canPush: true, githubLogin: allowed.githubLogin } : null
}
}
diff --git a/backend/src/github/projectAccess.ts b/backend/src/github/projectAccess.ts
index 663080eaa..74d71698c 100644
--- a/backend/src/github/projectAccess.ts
+++ b/backend/src/github/projectAccess.ts
@@ -12,14 +12,16 @@ export type ProjectGitHubAccess =
| { state: 'not-github'; repositoryUrl: string }
| { state: 'covered'; repository: string }
| { state: 'not-installed'; repository: string; installUrl: string | null; canApprove: boolean }
- | { state: 'not-approved'; repository: string; canApprove: boolean; approvedFor?: string[] }
+ | { state: 'not-approved'; repository: string; canApprove: boolean; approvedFor?: string[]; you?: { canPush: boolean; githubLogin: string } }
| { state: 'unknown'; repository: string }
/** [app]: this server's GitHub App, null when it has none. [approved]: whether someone who can push to the repository
* approved it for this project (github/approvals.ts). [canApprove]: this server has the app's sign-in to approve with.
* [refresh]: a person asked to check again. */
export async function projectGitHubAccess(app: Pick<GitHubApp, 'resolve' | 'forget' | 'installUrl' | 'currentFullName'> | null, repositoryUrl: string | null,
- approval: { approved: (repository: string) => Promise<boolean>; canApprove: boolean; approvedFor?: (repository: string) => Promise<string[]> },
+ approval: { approved: (repository: string) => Promise<boolean>; canApprove: boolean; approvedFor?: (repository: string) => Promise<string[]>
+ /** What GitHub last said about the reader on it (github/approvals.ts `reader`). */
+ you?: (repository: string) => Promise<{ canPush: boolean; githubLogin: string } | null> },
refresh = false): Promise<ProjectGitHubAccess> {
if (!app) return { state: 'unavailable' }
if (!repositoryUrl) return { state: 'no-repository' }
@@ -36,7 +38,9 @@ export async function projectGitHubAccess(app: Pick<GitHubApp, 'resolve' | 'forg
if (await approval.approved(repository.fullName.toLowerCase())) return { state: 'covered', repository: shown }
// The reader's other projects it is approved for: approving is per project, so a second one asks again (2026-10-28).
const approvedFor = await approval.approvedFor?.(repository.fullName.toLowerCase()) ?? []
- return { state: 'not-approved', repository: shown, canApprove: approval.canApprove, ...(approvedFor.length ? { approvedFor } : {}) }
+ const you = await approval.you?.(repository.fullName.toLowerCase()) ?? null
+ return { state: 'not-approved', repository: shown, canApprove: approval.canApprove, ...(approvedFor.length ? { approvedFor } : {}),
+ ...(you ? { you } : {}) }
} catch (error) {
// Wrong app credentials are the server's to fix and say so; GitHub not answering is never read as covered.
if (error instanceof GitHubAppError && error.code === 'GITHUB_APP_MISCONFIGURED') throw error
diff --git a/backend/src/routes/superTabs.ts b/backend/src/routes/superTabs.ts
index 175c18d28..bc0a86ca2 100644
--- a/backend/src/routes/superTabs.ts
+++ b/backend/src/routes/superTabs.ts
@@ -238,7 +238,8 @@ export async function superTabRoutes(app: FastifyInstance, options: { store?: Su
approvedFor: async repository => {
const ids = await approvals.approvedProjects(req.user!.autonomousEnv, req.params.tabId, repository)
return project.others.filter(other => ids.includes(other.id)).map(other => other.name)
- } },
+ },
+ you: repository => approvals.reader(req.user!.autonomousEnv, req.params.tabId, req.params.projectId, repository, req.user!.sub) },
req.query.refresh === '1')
}))
// Approving a project's repository: the person signs in to GitHub through the app (or installs it, which signs them in
@@ -268,6 +269,8 @@ export async function superTabRoutes(app: FastifyInstance, options: { store?: Su
const seen = await signIn.permission(req.query.code, named).catch(() => null)
if (!seen) return page('GitHub could not confirm your access', 'Go back to Harness and choose Continue in GitHub again.', 502)
if (!seen.push) {
+ // Kept, so the app asks them to send it to someone who can rather than offering this sign-in again.
+ await approvals.refuse(request, seen.login).catch(() => undefined)
return page(`You can't push to ${named.fullName}`, 'So you can\'t allow it. Ask someone who can push to it to open the project in Harness and choose Set up GitHub for teammates.', 403)
}
await approvals.approve(request, seen.login)
diff --git a/desktop/lib/shared/theme/app_icons.dart b/desktop/lib/shared/theme/app_icons.dart
index c8e2f54a1..7a03d51e4 100644
--- a/desktop/lib/shared/theme/app_icons.dart
+++ b/desktop/lib/shared/theme/app_icons.dart
@@ -39,6 +39,7 @@ abstract final class AppIcons {
static const arrowUpRight = LucideIcons.arrowUpRight400;
static const bell = LucideIcons.bell400;
static const bellRing = LucideIcons.bellRing400;
+ static const book = LucideIcons.book400;
static const bookOpen = LucideIcons.bookOpen400;
static const bot = LucideIcons.bot400;
static const box = LucideIcons.box400;
diff --git a/desktop/lib/super_tabs/project_github.dart b/desktop/lib/super_tabs/project_github.dart
index c613c28d1..d1cc0dc14 100644
--- a/desktop/lib/super_tabs/project_github.dart
+++ b/desktop/lib/super_tabs/project_github.dart
@@ -30,7 +30,14 @@ class SuperTabProjectGitHub {
approvedFor = [
for (final name in row['approvedFor'] as List? ?? const [])
if (name is String) name,
- ];
+ ],
+ youCanPush = row['you'] is Map && (row['you'] as Map)['canPush'] is bool
+ ? (row['you'] as Map)['canPush'] as bool
+ : null,
+ githubLogin =
+ row['you'] is Map && (row['you'] as Map)['githubLogin'] is String
+ ? (row['you'] as Map)['githubLogin'] as String
+ : null;
/// `covered`, `not-installed`, `not-approved` (installed, but nobody who can push to it approved it for this project:
/// backend github/approvals.ts), `not-github`, `no-repository`, `unknown` (GitHub did not answer), `unread` (this
@@ -46,6 +53,13 @@ class SuperTabProjectGitHub {
/// github/projectAccess.ts): approving is per project, so a second one asks again.
final List<String> approvedFor;
+ /// What GitHub last said about the reader on the repository (backend github/approvals.ts `reader`): true once they
+ /// allowed it in this Swarm, false once their sign-in was refused for this project, null before either.
+ final bool? youCanPush;
+
+ /// The reader's GitHub account, when [youCanPush] is known.
+ final String? githubLogin;
+
/// The sidebar's one line under the project, null when it needs none. Setting up access is a step to take, not a
/// fault, so it reads as one (design 2026-10-30: the orange "Teammates can't push here yet" read as an error on a
/// Swarm whose owner had done nothing wrong); a repository that is not on GitHub is the one real blocker.
@@ -107,6 +121,9 @@ class _ProjectGitHubAccessState extends State<ProjectGitHubAccess>
/// The page last opened in the browser, for "Open GitHub again".
String? _openedLink;
+ /// The state GitHub's page was opened for: the waiting screen stays until it changes or the person cancels.
+ String? _openedFor;
+
@override
void initState() {
super.initState();
@@ -146,7 +163,12 @@ class _ProjectGitHubAccessState extends State<ProjectGitHubAccess>
if (mounted) {
setState(() {
_checking = false;
- _inBrowser = false;
+ // Coming back to the app is not finishing on GitHub (2026-10-30: the waiting screen vanished the moment
+ // Harness came to the front, so nobody ever saw it). It ends when GitHub's answer changes, or on Cancel.
+ if (_answerOf(widget.controller.githubAccessOf(widget.projectId)) !=
+ _openedFor) {
+ _inBrowser = false;
+ }
});
}
}
@@ -236,6 +258,10 @@ class _ProjectGitHubAccessState extends State<ProjectGitHubAccess>
);
}
+ /// What GitHub has said, as the waiting screen compares it: a refused sign-in ends the wait as an approval does.
+ static String? _answerOf(SuperTabProjectGitHub? access) =>
+ access == null ? null : '${access.state}/${access.youCanPush}';
+
bool _canApprove(SuperTabProjectGitHub access) =>
access.state == 'not-approved' && access.canApprove;
@@ -337,7 +363,7 @@ class _ProjectGitHubAccessState extends State<ProjectGitHubAccess>
height: 18,
child: CircularProgressIndicator(
strokeWidth: 2,
- color: grid.AppPalette.swarmAccent,
+ color: grid.AppPalette.accentOnSurface,
),
),
heading: 'Finish in GitHub',
@@ -400,45 +426,86 @@ class _ProjectGitHubAccessState extends State<ProjectGitHubAccess>
),
],
);
- case 'not-approved' when access.canApprove:
+ case 'not-approved' when access.canApprove && access.youCanPush == false:
+ // GitHub said this reader can't push (design 2b): asking them to sign in again would end the same way.
+ final message =
+ 'Could you open $name in Harness and click “Set up GitHub for teammates”? Our agents need it to push '
+ 'to $repository.';
return _screen(
- heading: "Let teammates' agents push to $name",
+ key: const Key('super-project-github-ask-screen'),
+ heading: 'Someone with write access needs to allow this',
body: [
_body(
- "Agents on your teammates' machines push branches and open pull requests through the Harness "
- 'GitHub app. Anyone who can push to $repository can allow it for this project.'
- '${access.approvedFor.isEmpty ? '' : " It's already allowed for ${_names(access.approvedFor)}."}',
+ "Your GitHub account${access.githubLogin == null ? '' : ' (${access.githubLogin})'} can't push to "
+ "$repository, so teammates' agents can't push there through you. Ask someone in this Swarm who can "
+ 'push to open the project and allow it.',
key: ValueKey('super-project-github-text-${widget.projectId}'),
),
- _repository(repository),
- _allows('Push branches and open pull requests'),
- _allows('Only in this repository, only for this project'),
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ 'Message to send them',
+ style: DesktopChrome.control(medium: true),
+ ),
+ const SizedBox(height: _gap),
+ Container(
+ width: double.infinity,
+ padding: const EdgeInsets.symmetric(
+ horizontal: grid.AppDesktop.groupGap,
+ vertical: grid.AppDesktop.controlGap,
+ ),
+ decoration: BoxDecoration(
+ color: grid.AppSurface.wellFill,
+ borderRadius: BorderRadius.circular(
+ DesktopChrome.rowRadius,
+ ),
+ border: Border.all(color: DesktopChrome.rim),
+ ),
+ child: SelectableText(
+ message,
+ style: DesktopChrome.text(size: 13),
+ ),
+ ),
+ ],
+ ),
_body(
- "GitHub opens next to check that you can push to it. Come back here when it's done.",
+ "This project updates by itself once they've allowed it.",
muted: true,
),
- if (_error != null) _errorText(),
],
- aside: [
- TextButton(
+ actions: [
+ OutlinedButton(onPressed: close, child: const Text('Close')),
+ FilledButton(
key: const Key('super-project-github-ask'),
onPressed: () async {
- await Clipboard.setData(
- ClipboardData(
- text:
- 'Could you open $name in Harness and click “Set up GitHub for teammates”? Our agents '
- 'need it to push to $repository.',
- ),
- );
+ await Clipboard.setData(ClipboardData(text: message));
if (mounted) setState(() => _askCopied = true);
},
- child: Text(
- _askCopied
- ? 'Message copied'
- : "Can't push to it? Copy a message",
- ),
+ child: Text(_askCopied ? 'Message copied' : 'Copy message'),
),
],
+ );
+ case 'not-approved' when access.canApprove:
+ final canPush = access.youCanPush == true;
+ return _screen(
+ heading: "Let teammates' agents push to $name",
+ body: [
+ _body(
+ "Agents on your teammates' machines push branches and open pull requests through the Harness GitHub app. "
+ '${canPush ? 'You have write access, so you can allow it.' : 'Anyone who can push to $repository can allow it.'}'
+ '${access.approvedFor.isEmpty ? '' : " It's already allowed for ${_names(access.approvedFor)}."}',
+ key: ValueKey('super-project-github-text-${widget.projectId}'),
+ ),
+ _repository(repository, canPush: canPush),
+ _allows('Push branches and open pull requests'),
+ _allows('Only in this repository, only for this project'),
+ _body(
+ "GitHub opens next so you can confirm it's you. Come back here when it's done.",
+ muted: true,
+ ),
+ if (_error != null) _errorText(),
+ ],
actions: [
OutlinedButton(onPressed: close, child: const Text('Not now')),
_approveButton(),
@@ -516,17 +583,33 @@ class _ProjectGitHubAccessState extends State<ProjectGitHubAccess>
child: Text(
heading,
key: const Key('super-project-github-heading'),
- style: DesktopChrome.heading(),
+ // The design's dialog heading: the title role, semibold.
+ style: grid.AppType.title(color: DesktopChrome.foreground),
),
),
],
),
- for (final part in body) ...[const SizedBox(height: _gap + 2), part],
+ for (final part in body) ...[
+ const SizedBox(height: DesktopChrome.groupGap),
+ part,
+ ],
if (aside.isNotEmpty) ...[
- const SizedBox(height: _gap),
- Wrap(spacing: 4, children: aside),
+ const SizedBox(height: _halfGap),
+ TextButtonTheme(
+ data: TextButtonThemeData(
+ style: TextButton.styleFrom(
+ foregroundColor: grid.AppPalette.accentOnSurface,
+ backgroundColor: Colors.transparent,
+ side: BorderSide.none,
+ padding: EdgeInsets.zero,
+ minimumSize: const Size(0, 32),
+ tapTargetSize: MaterialTapTargetSize.shrinkWrap,
+ ),
+ ),
+ child: Wrap(spacing: _gap * 2, children: aside),
+ ),
],
- const SizedBox(height: _gap * 2),
+ const SizedBox(height: DesktopChrome.groupGap + _gap),
// Wraps under large text rather than overflowing the dialog.
SizedBox(
width: double.infinity,
@@ -541,13 +624,22 @@ class _ProjectGitHubAccessState extends State<ProjectGitHubAccess>
),
);
- Widget _body(String text, {Key? key, bool muted = false}) => Text(
+ /// A paragraph in the secondary text colour, as the design has it; [note] smaller, [primary] for what is allowed.
+ Widget _body(
+ String text, {
+ Key? key,
+ bool muted = false,
+ bool primary = false,
+ }) => Text(
text,
key: key,
- style: DesktopChrome.text(color: muted ? DesktopChrome.muted : null),
+ style: DesktopChrome.text(
+ color: primary ? null : DesktopChrome.muted,
+ size: muted ? 13 : 14,
+ ),
);
- Widget _repository(String repository) => Container(
+ Widget _repository(String repository, {bool canPush = false}) => Container(
padding: const EdgeInsets.symmetric(
horizontal: grid.AppDesktop.groupGap,
vertical: grid.AppDesktop.controlGap,
@@ -560,7 +652,7 @@ class _ProjectGitHubAccessState extends State<ProjectGitHubAccess>
child: Row(
children: [
Icon(
- AppIcons.gitBranch,
+ AppIcons.book,
size: grid.AppControl.iconSize,
color: DesktopChrome.muted,
),
@@ -568,6 +660,23 @@ class _ProjectGitHubAccessState extends State<ProjectGitHubAccess>
Expanded(
child: Text(repository, style: DesktopChrome.text(medium: true)),
),
+ // Known only once GitHub has said so: they allowed it for another project of the Swarm.
+ if (canPush)
+ Container(
+ key: const Key('super-project-github-can-push'),
+ padding: const EdgeInsets.symmetric(
+ horizontal: grid.AppDesktop.badgeInset,
+ vertical: grid.AppDesktop.listRowGap,
+ ),
+ decoration: ShapeDecoration(
+ color: grid.AppPalette.online.withValues(alpha: .16),
+ shape: const StadiumBorder(),
+ ),
+ child: Text(
+ 'You can push',
+ style: DesktopChrome.metadata(color: grid.AppPalette.online),
+ ),
+ ),
],
),
);
@@ -584,7 +693,7 @@ class _ProjectGitHubAccessState extends State<ProjectGitHubAccess>
),
),
const SizedBox(width: 10),
- Expanded(child: _body(text)),
+ Expanded(child: _body(text, primary: true)),
],
);
@@ -643,6 +752,9 @@ class _ProjectGitHubAccessState extends State<ProjectGitHubAccess>
_busy = false;
_inBrowser = true;
_openedLink = link;
+ _openedFor = _answerOf(
+ widget.controller.githubAccessOf(widget.projectId),
+ );
});
}
}
@@ -666,6 +778,9 @@ class _ProjectGitHubAccessState extends State<ProjectGitHubAccess>
setState(() {
_inBrowser = true;
_openedLink = links.authorizeUrl;
+ _openedFor = _answerOf(
+ widget.controller.githubAccessOf(widget.projectId),
+ );
});
}
} on SuperTabFailure catch (failure) {
@@ -748,7 +863,7 @@ class _ProjectGitHubLineState extends State<ProjectGitHubLine>
width: 6,
height: 6,
decoration: BoxDecoration(
- color: grid.AppPalette.swarmAccent,
+ color: grid.AppPalette.accentOnSurface,
shape: BoxShape.circle,
),
),
diff --git a/desktop/test/super_tab_project_github_test.dart b/desktop/test/super_tab_project_github_test.dart
index ca7568fda..2e802f455 100644
--- a/desktop/test/super_tab_project_github_test.dart
+++ b/desktop/test/super_tab_project_github_test.dart
@@ -410,12 +410,15 @@ void main() {
);
expect(find.text('acme/app'), findsOneWidget);
expect(find.text('Push branches and open pull requests'), findsOneWidget);
- await tester.ensureVisible(
- find.byKey(const Key('super-project-github-ask')),
+ // Before GitHub has said anything about the reader, no claim either way.
+ expect(
+ find.textContaining('Anyone who can push to acme/app'),
+ findsOneWidget,
+ );
+ expect(
+ find.byKey(const Key('super-project-github-can-push')),
+ findsNothing,
);
- await tester.tap(find.byKey(const Key('super-project-github-ask')));
- await tester.pumpAndSettle();
- expect(find.text('Message copied'), findsOneWidget);
await tester.ensureVisible(
find.byKey(const Key('super-project-github-approve')),
);
@@ -426,6 +429,12 @@ void main() {
expect(launched.last, contains('/login/oauth/authorize'));
expect(find.text('Finish in GitHub'), findsOneWidget);
expect(find.text("What GitHub's page means"), findsOneWidget);
+ // Back in the app before finishing on GitHub: still waiting, not back at the question.
+ tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.inactive);
+ tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 100));
+ expect(find.text('Finish in GitHub'), findsOneWidget);
// Cancel goes back to the question; Continue opens GitHub again.
await tester.ensureVisible(
find.byKey(const Key('super-project-github-cancel')),
@@ -462,6 +471,98 @@ void main() {
},
);
+ // Design 2026-10-30, 2a and 2b: "You can push" only once GitHub has said so, and someone GitHub refused is asked to send
+ // it on rather than offered the same sign-in again.
+ testWidgets(
+ 'the dialog says you can push once GitHub has, and asks someone it refused to send it on',
+ (tester) async {
+ Future<SuperTabController> open(Map<String, dynamic> you) async {
+ answer = {
+ 'state': 'not-approved',
+ 'repository': 'acme/app',
+ 'canApprove': true,
+ 'you': you,
+ };
+ final c = controllerFor();
+ await c.refresh();
+ final project = c.snapshot!.projects.first;
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: Builder(
+ builder: (context) => TextButton(
+ onPressed: () => showProjectGitHubAccess(context, c, project),
+ child: const Text('open github'),
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.tap(find.text('open github'));
+ await tester.pumpAndSettle();
+ return c;
+ }
+
+ final able = await open({'canPush': true, 'githubLogin': 'olive'});
+ expect(
+ find.byKey(const Key('super-project-github-can-push')),
+ findsOneWidget,
+ );
+ expect(
+ find.textContaining('You have write access, so you can allow it.'),
+ findsOneWidget,
+ );
+ await tester.tap(find.text('Not now'));
+ await tester.pumpAndSettle();
+ able.dispose();
+ final refused = await open({'canPush': false, 'githubLogin': 'olive'});
+ expect(
+ find.text('Someone with write access needs to allow this'),
+ findsOneWidget,
+ );
+ expect(
+ find.textContaining('(olive) can\'t push to acme/app'),
+ findsOneWidget,
+ );
+ expect(
+ find.byKey(const Key('super-project-github-approve')),
+ findsNothing,
+ );
+ await tester.ensureVisible(
+ find.byKey(const Key('super-project-github-ask')),
+ );
+ await tester.tap(find.byKey(const Key('super-project-github-ask')));
+ await tester.pumpAndSettle();
+ expect(find.text('Message copied'), findsOneWidget);
+ await tester.tap(find.text('Close'));
+ await tester.pumpAndSettle();
+ refused.dispose();
+ // Refused while waiting: back in the app, the wait ends on the ask, not on the question again.
+ final waiting = await open({});
+ await tester.ensureVisible(
+ find.byKey(const Key('super-project-github-approve')),
+ );
+ await tester.tap(find.byKey(const Key('super-project-github-approve')));
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 100));
+ expect(find.text('Finish in GitHub'), findsOneWidget);
+ answer = {
+ 'state': 'not-approved',
+ 'repository': 'acme/app',
+ 'canApprove': true,
+ 'you': {'canPush': false, 'githubLogin': 'olive'},
+ };
+ tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.inactive);
+ tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
+ await tester.pumpAndSettle();
+ expect(
+ find.text('Someone with write access needs to allow this'),
+ findsOneWidget,
+ );
+ waiting.dispose();
+ },
+ );
+
testWidgets('shows nothing on a server without the route', (tester) async {
failure = const SuperTabFailure('NOT_FOUND', 'Not found', statusCode: 404);
final c = await mount(