Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(github): revoking this machine deletes its cached issues

review9544209e7aa9
diff --git a/src/core/github/host.test.ts b/src/core/github/host.test.ts
index ad99a908f..b89063a6d 100644
--- a/src/core/github/host.test.ts
+++ b/src/core/github/host.test.ts
@@ -27,7 +27,7 @@ const project: Project = {
}
}
-function fixture() {
+function fixture(options: { onRevoked?: (projectId: string) => Promise<void> } = {}) {
let current: Project = project
let state: GitHubControlState = {
version: 1,
@@ -121,6 +121,7 @@ function fixture() {
? { status: 'unknown', reason: 'unreachable' }
: { status: 'unauthorized' }),
client: vi.fn(() => client),
+ ...(options.onRevoked ? { onRevoked: options.onRevoked } : {}),
rate: (userId: string) => userId === '1'
? {
status: { resource: 'core', limit: 5_000, remaining: 7, resetAt: 9, observedAt: 1 },
@@ -205,6 +206,20 @@ describe('GitHubHostController', () => {
expect((await controller.status('project-1')).project).toMatchObject({ approved: true, mappingApproved: false })
})
+ it('revokes first and then clears the cache, and says so when the cache could not be cleared', async () => {
+ const order: string[] = []
+ const { controller, controls } = fixture({
+ onRevoked: async (projectId: string) => { order.push(`clear:${projectId}`); throw new Error('EBUSY') }
+ })
+ controls.revoke.mockImplementationOnce(async () => {
+ order.push('revoke')
+ return { version: 1, revision: 1, authProvider: 'auto', approvals: [] }
+ })
+ await expect(controller.revoke({ projectId: 'project-1', expectedRevision: 0 }))
+ .rejects.toMatchObject({ code: 'revoked-cache-kept' })
+ expect(order).toEqual(['revoke', 'clear:project-1'])
+ })
+
it('rejects approval for a repository other than the configured or detected repository', async () => {
const { controller } = fixture()
await expect(controller.approve({
diff --git a/src/core/github/host.ts b/src/core/github/host.ts
index 0d25e4134..bd8d179e4 100644
--- a/src/core/github/host.ts
+++ b/src/core/github/host.ts
@@ -25,7 +25,8 @@ export class GitHubHostError extends Error {
| 'not-approved'
| 'not-authenticated'
| 'invalid-token'
- | 'configuration-changed') {
+ | 'configuration-changed'
+ | 'revoked-cache-kept') {
super(code)
}
}
@@ -79,6 +80,8 @@ type HostDependencies = {
/** The request budget last seen for an identity, and why sync is held (if it is). */
rate?(userId: string): { status?: GitHubRateStatus; throttle?: GitHubThrottle }
onCredentialBoundaryChange?(): void
+ /** Runs after a revoke is recorded: deletes this project's private issue cache from disk. */
+ onRevoked?(projectId: string): Promise<void>
}
type ResolvedProject = ProjectRecord & {
@@ -175,6 +178,15 @@ export class GitHubHostController {
localApprovalId: record.localApprovalId
})
this.dependencies.onCredentialBoundaryChange?.()
+ // "Stop this computer from reading issues" must not leave what it already read behind: the
+ // cache is plaintext JSON (issue bodies included) under userData. The revoke is recorded FIRST,
+ // so a failed delete never leaves the machine approved — it is reported instead, and "Clear
+ // cached data" (which needs no approval) remains the way to finish the job.
+ try {
+ await this.dependencies.onRevoked?.(input.projectId)
+ } catch {
+ throw new GitHubHostError('revoked-cache-kept')
+ }
return this.status(input.projectId)
}
diff --git a/src/core/github/integration.test.ts b/src/core/github/integration.test.ts
index 3e9484898..f7b6fbcfb 100644
--- a/src/core/github/integration.test.ts
+++ b/src/core/github/integration.test.ts
@@ -165,3 +165,47 @@ describe('registerGitHubIntegration rate budget', () => {
expect(view.throttle).toEqual({ until: reset * 1_000, kind: 'low-budget' })
})
})
+
+describe('registerGitHubIntegration revoke', () => {
+ it('deletes the private issue cache from disk when this machine is revoked', async () => {
+ const issue = {
+ id: 1001, number: 1, title: 'Secret roadmap', body: 'private body', state: 'open',
+ state_reason: null, html_url: 'https://github.com/owner/repo/issues/1',
+ url: 'https://api.github.com/repos/owner/repo/issues/1', labels: [], assignees: [],
+ created_at: '2026-08-01T10:00:00Z', updated_at: '2026-08-09T10:00:00Z', locked: false
+ }
+ globalThis.fetch = (async (input: RequestInfo | URL) => String(input).endsWith('/user')
+ ? new Response(JSON.stringify({ id: 1, login: 'octocat' }), { status: 200 })
+ : new Response(JSON.stringify([issue]), { status: 200, headers: { etag: 'W/"top"' } })
+ ) as typeof globalThis.fetch
+ const secret: GitHubSecretStore = {
+ availability: 'encrypted',
+ readForHost: async () => 'stored-token',
+ save: async () => undefined,
+ clear: async () => undefined
+ }
+ const { controller, service } = registerGitHubIntegration({
+ platform: fakePlatform(),
+ userDataDir,
+ project: async (id) => id === project.id ? { project, localApprovalId: 'local-1' } : null,
+ detectRepository: async () => 'owner/repo',
+ secret,
+ run: async () => ({ ok: false, stdout: '', stderr: 'not logged in' })
+ })
+ const initial = await controller.status('project-1')
+ await controller.approve({
+ projectId: 'project-1', repository: 'owner/repo', expectedRevision: initial.control.revision
+ })
+ await service.refresh({ projectId: 'project-1', full: true })
+ const cacheDir = path.join(userDataDir, 'github-issues-cache')
+ const cached = await fs.readdir(cacheDir)
+ expect(cached).toHaveLength(1)
+ expect(await fs.readFile(path.join(cacheDir, cached[0]), 'utf-8')).toContain('private body')
+
+ const approved = await controller.status('project-1')
+ await controller.revoke({ projectId: 'project-1', expectedRevision: approved.control.revision })
+
+ expect(await fs.readdir(cacheDir)).toEqual([])
+ expect(await fs.readdir(path.join(userDataDir, 'github-issues-bindings'))).toEqual([])
+ })
+})
diff --git a/src/core/github/integration.ts b/src/core/github/integration.ts
index 87eaa0aa9..b0d690c07 100644
--- a/src/core/github/integration.ts
+++ b/src/core/github/integration.ts
@@ -58,7 +58,9 @@ export function registerGitHubIntegration(dependencies: Dependencies): {
onCredentialBoundaryChange: () => {
coordinator.cancelAll()
resolver.invalidate()
- }
+ },
+ // `service` is declared below; this only runs on a revoke, long after both exist.
+ onRevoked: (projectId) => service.clearCache({ projectId })
})
const service = new GitHubIssueService({
cache: new GitHubIssueCache(dependencies.userDataDir),
diff --git a/src/renderer/components/settings/sections/GitHubIssuesSection.tsx b/src/renderer/components/settings/sections/GitHubIssuesSection.tsx
index 3d32c0d47..483b22046 100644
--- a/src/renderer/components/settings/sections/GitHubIssuesSection.tsx
+++ b/src/renderer/components/settings/sections/GitHubIssuesSection.tsx
@@ -71,6 +71,9 @@ function messageFor(error: unknown): string {
if (code.includes('github-unreachable')) {
return 'GitHub could not be reached. Nothing was changed; try again in a moment.'
}
+ if (code.includes('revoked-cache-kept')) {
+ return 'This machine is revoked, but its cached issues could not be deleted. Use “Clear cached data” to remove them.'
+ }
if (code.includes('invalid-token')) return 'GitHub could not validate that token.'
if (code.includes('not-authenticated')) return 'Sign in with GitHub CLI or save a valid token first.'
if (code.includes('not-approved')) return 'Approve this repository on this machine first.'
@@ -621,7 +624,7 @@ export function GitHubIssuesSection({ isActive }: { isActive: boolean }): React.
)}
{confirmation === 'revoke' && (
<ConfirmDialog
- message="Stop this computer from reading or changing issues for this project?"
+ message="Stop this computer from reading or changing issues for this project? Its cached copy of the issues is deleted too."
confirmLabel="Revoke"
onCancel={() => setConfirmation(null)}
onConfirm={() => {