Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c89313c
fix(github): load PR diffs for Enterprise remotes
wonjerry Jul 16, 2026
9ac7fd4
fix(github): encode PR content paths by segment
wonjerry Jul 16, 2026
7b49c57
Fix PR review actions failing on GitHub Enterprise remotes
AmethystLiang Jul 16, 2026
93d8a04
Route gh host qualification through runner options instead of argv sniff
AmethystLiang Jul 16, 2026
3ded2bb
Fix gh CLI GHES host pinning and rate-limit scope leaks
AmethystLiang Jul 16, 2026
a38a44f
Fix GitHub Enterprise host identity loss across PR/work-item paths
AmethystLiang Jul 16, 2026
791b93e
Make repository identity host-aware across all GitHub surfaces
AmethystLiang Jul 17, 2026
50efc2a
Fix expected slug to include host field in GitHub PR link test
AmethystLiang Jul 17, 2026
bb69980
Surface per-host gh auth state for GitHub Enterprise
AmethystLiang Jul 17, 2026
f807844
Bound GHES identity caches and preserve non-default ports in host ide…
AmethystLiang Jul 17, 2026
00835e0
Thread GitHub host through issue detail requests
AmethystLiang Jul 17, 2026
5a75fce
Scope remaining GitHub rate-limit accounting
AmethystLiang Jul 16, 2026
f683174
Resolve typed PR lookups across hosted repository candidates
AmethystLiang Jul 17, 2026
e5281f5
Refactor GitHub repository execution setup
AmethystLiang Jul 16, 2026
b31cc77
Carry host on smart-submit link intents
AmethystLiang Jul 17, 2026
a6160e8
Carry the project host on GitHub item dialog origins
AmethystLiang Jul 17, 2026
02206e6
Keep GHES web ports but drop SSH transport ports in host identity
AmethystLiang Jul 17, 2026
ee835fc
Support GitHub Enterprise diffs and mutations with host-scoped caches
AmethystLiang Jul 17, 2026
4deaa81
Support GitHub Enterprise diffs and mutations with host-scoped caches
AmethystLiang Jul 17, 2026
5a1f3a4
Support GitHub Enterprise work-item diffs with host-scoped execution
AmethystLiang Jul 17, 2026
2e84de0
Support GitHub Enterprise work-item diffs with host-scoped execution
AmethystLiang Jul 17, 2026
672489a
fix(review): drop dead rateLimitGuard/noteRateLimitSpend re-export
AmethystLiang Jul 20, 2026
77789a8
fix(ci): split Enterprise host work-item tests under max-lines
AmethystLiang Jul 21, 2026
ce2e9c4
test(github): align mocks with host-scoped repository resolution
AmethystLiang Jul 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
240 changes: 130 additions & 110 deletions mobile/app/h/[hostId]/tasks.tsx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion mobile/src/components/pr-sidebar/PRCommentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { PRCommentComposer } from './PRCommentComposer'
import { formatPrCommentRelativeTime } from './pr-comment-time'
import { prCommentsStyles as styles } from './pr-comments-styles'

export type PRCommentRepoSlug = { owner: string; repo: string }
export type PRCommentRepoSlug = { owner: string; repo: string; host?: string }

// Action handlers are passed from the comment actions hook (stable callbacks), so
// adding them keeps the memo'd card from re-rendering on unrelated timeline changes.
Expand Down
51 changes: 50 additions & 1 deletion mobile/src/session/github-pr-mutations.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { describe, expect, it, vi } from 'vitest'
import type { RpcResponse } from '../transport/types'
import {
fetchAddIssueComment,
fetchAddPRReviewCommentReply,
fetchDeleteIssueComment,
fetchMergePR,
fetchResolveReviewThread,
Expand Down Expand Up @@ -29,6 +31,7 @@ function clientRejecting(message: string) {
}

const WORKTREE_ID = 'repo-42::/path/to/wt'
const ENTERPRISE_PR_REPO = { owner: 'o', repo: 'r', host: 'github.acme.test' }

describe('fetchResolveReviewThread / fetchUpdatePRTitle — bare-boolean host result', () => {
it('treats an explicit true as success', async () => {
Expand Down Expand Up @@ -102,29 +105,75 @@ describe('mutation transport rejection normalization', () => {
})
})

describe('Enterprise PR repo forwarding', () => {
it('forwards the host through title, root-comment, and review-reply RPCs', async () => {
const titleClient = clientReturning(okResponse(true))
await fetchUpdatePRTitle(titleClient, WORKTREE_ID, {
prNumber: 7,
title: 'New title',
prRepo: ENTERPRISE_PR_REPO
})
expect(titleClient.sendRequest).toHaveBeenCalledWith(
'github.updatePRTitle',
expect.objectContaining({ prRepo: ENTERPRISE_PR_REPO })
)

const rootClient = clientReturning(okResponse({ ok: true }))
await fetchAddIssueComment(rootClient, WORKTREE_ID, {
prNumber: 7,
body: 'Root comment',
prRepo: ENTERPRISE_PR_REPO
})
expect(rootClient.sendRequest).toHaveBeenCalledWith(
'github.addIssueComment',
expect.objectContaining({ prRepo: ENTERPRISE_PR_REPO })
)

const replyClient = clientReturning(okResponse({ ok: true }))
await fetchAddPRReviewCommentReply(replyClient, WORKTREE_ID, {
prNumber: 7,
commentId: 42,
body: 'Reply',
prRepo: ENTERPRISE_PR_REPO
})
expect(replyClient.sendRequest).toHaveBeenCalledWith(
'github.addPRReviewCommentReply',
expect.objectContaining({ prRepo: ENTERPRISE_PR_REPO })
)
})
})

describe('fetchUpdateIssueComment / fetchDeleteIssueComment — slug-addressed envelope', () => {
it('sends owner/repo/commentId(+body) and reads the { ok } envelope', async () => {
const editClient = clientReturning(okResponse({ ok: true }))
const edit = await fetchUpdateIssueComment(editClient, {
owner: 'o',
repo: 'r',
host: 'github.acme.test',
commentId: 5,
body: 'edited'
})
expect(edit).toEqual({ ok: true })
expect(editClient.sendRequest).toHaveBeenCalledWith('github.project.updateIssueCommentBySlug', {
owner: 'o',
repo: 'r',
host: 'github.acme.test',
commentId: 5,
body: 'edited'
})

const delClient = clientReturning(okResponse({ ok: true }))
const del = await fetchDeleteIssueComment(delClient, { owner: 'o', repo: 'r', commentId: 5 })
const del = await fetchDeleteIssueComment(delClient, {
owner: 'o',
repo: 'r',
host: 'github.acme.test',
commentId: 5
})
expect(del).toEqual({ ok: true })
expect(delClient.sendRequest).toHaveBeenCalledWith('github.project.deleteIssueCommentBySlug', {
owner: 'o',
repo: 'r',
host: 'github.acme.test',
commentId: 5
})
})
Expand Down
96 changes: 45 additions & 51 deletions mobile/src/session/github-pr-mutations.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { GitHubPRMergeMethod } from '../../../src/shared/types'
import type { RpcClient } from '../transport/rpc-client'
import { buildGithubPrParams, type GitHubPrRepoSlug } from './github-pr-rpc'
import { buildGithubPrParams, githubPrRepoSlugParam, type GitHubPrRepoSlug } from './github-pr-rpc'

// Mutation wrappers for the github.* PR surface, split out so github-pr-rpc.ts
// stays under the max-lines budget. They mirror the read wrappers' shape but
Expand Down Expand Up @@ -101,16 +101,10 @@ export async function fetchUpdatePRTitle(
args: { prNumber: number; title: string; prRepo?: GitHubPrRepoSlug | null }
): Promise<GitHubPrMutationOutcome> {
const params: Record<string, unknown> = { prNumber: args.prNumber, title: args.title }
// updatePRTitle accepts prRepo for fork PRs, but it is not in the centralized
// METHODS_ACCEPTING_PR_REPO read allow-list — pass it explicitly so it reaches the
// host schema (which declares it optional/nullable).
if (args.prRepo) {
params.prRepo = { owner: args.prRepo.owner, repo: args.prRepo.repo }
}
const response = await sendRaw(
client,
'github.updatePRTitle',
buildGithubPrParams('github.updatePRTitle', worktreeId, params)
buildGithubPrParams('github.updatePRTitle', worktreeId, params, { prRepo: args.prRepo })
)
if (!response.ok) {
return { ok: false, error: response.error || 'Request failed: github.updatePRTitle' }
Expand Down Expand Up @@ -147,48 +141,51 @@ export async function fetchSetPRAutoMerge(
export async function fetchUpdatePRState(
client: Pick<RpcClient, 'sendRequest'>,
worktreeId: string,
args: { prNumber: number; state: 'open' | 'closed' }
args: { prNumber: number; state: 'open' | 'closed'; prRepo?: GitHubPrRepoSlug | null }
): Promise<GitHubPrMutationOutcome> {
// updatePRState does NOT accept prRepo (KTD3) — buildGithubPrParams omits it.
return sendGithubPrMutation(
client,
'github.updatePRState',
buildGithubPrParams('github.updatePRState', worktreeId, {
prNumber: args.prNumber,
updates: { state: args.state }
})
buildGithubPrParams(
'github.updatePRState',
worktreeId,
{ prNumber: args.prNumber, updates: { state: args.state } },
{ prRepo: args.prRepo }
)
)
}

export async function fetchRequestPRReviewers(
client: Pick<RpcClient, 'sendRequest'>,
worktreeId: string,
args: { prNumber: number; reviewers: string[] }
args: { prNumber: number; reviewers: string[]; prRepo?: GitHubPrRepoSlug | null }
): Promise<GitHubPrMutationOutcome> {
// requestPRReviewers does NOT accept prRepo (KTD3).
return sendGithubPrMutation(
client,
'github.requestPRReviewers',
buildGithubPrParams('github.requestPRReviewers', worktreeId, {
prNumber: args.prNumber,
reviewers: args.reviewers
})
buildGithubPrParams(
'github.requestPRReviewers',
worktreeId,
{ prNumber: args.prNumber, reviewers: args.reviewers },
{ prRepo: args.prRepo }
)
)
}

export async function fetchRemovePRReviewers(
client: Pick<RpcClient, 'sendRequest'>,
worktreeId: string,
args: { prNumber: number; reviewers: string[] }
args: { prNumber: number; reviewers: string[]; prRepo?: GitHubPrRepoSlug | null }
): Promise<GitHubPrMutationOutcome> {
// removePRReviewers does NOT accept prRepo (KTD3).
return sendGithubPrMutation(
client,
'github.removePRReviewers',
buildGithubPrParams('github.removePRReviewers', worktreeId, {
prNumber: args.prNumber,
reviewers: args.reviewers
})
buildGithubPrParams(
'github.removePRReviewers',
worktreeId,
{ prNumber: args.prNumber, reviewers: args.reviewers },
{ prRepo: args.prRepo }
)
)
}

Expand Down Expand Up @@ -222,16 +219,12 @@ export async function fetchAddPRReviewCommentReply(
if (typeof args.line === 'number') {
params.line = args.line
}
// addPRReviewCommentReply accepts prRepo for fork PRs, but it is not in the
// centralized METHODS_ACCEPTING_PR_REPO allow-list (read-focused) — pass it
// explicitly so it reaches the host schema, which declares it optional.
if (args.prRepo) {
params.prRepo = { owner: args.prRepo.owner, repo: args.prRepo.repo }
}
return sendGithubPrMutation(
client,
'github.addPRReviewCommentReply',
buildGithubPrParams('github.addPRReviewCommentReply', worktreeId, params)
buildGithubPrParams('github.addPRReviewCommentReply', worktreeId, params, {
prRepo: args.prRepo
})
)
}

Expand All @@ -246,13 +239,10 @@ export async function fetchAddIssueComment(
body: args.body,
type: 'pr'
}
if (args.prRepo) {
params.prRepo = { owner: args.prRepo.owner, repo: args.prRepo.repo }
}
return sendGithubPrMutation(
client,
'github.addIssueComment',
buildGithubPrParams('github.addIssueComment', worktreeId, params)
buildGithubPrParams('github.addIssueComment', worktreeId, params, { prRepo: args.prRepo })
)
}

Expand All @@ -262,15 +252,17 @@ export async function fetchAddIssueComment(
export async function fetchResolveReviewThread(
client: Pick<RpcClient, 'sendRequest'>,
worktreeId: string,
args: { threadId: string; resolve: boolean }
args: { threadId: string; resolve: boolean; prRepo?: GitHubPrRepoSlug | null }
): Promise<GitHubPrMutationOutcome> {
const response = await sendRaw(
client,
'github.resolveReviewThread',
buildGithubPrParams('github.resolveReviewThread', worktreeId, {
threadId: args.threadId,
resolve: args.resolve
})
buildGithubPrParams(
'github.resolveReviewThread',
worktreeId,
{ threadId: args.threadId, resolve: args.resolve },
{ prRepo: args.prRepo }
)
)
if (!response.ok) {
return {
Expand All @@ -292,11 +284,10 @@ export async function fetchResolveReviewThread(
// GitHubProjectMutationResult `{ ok }` envelope sendGithubPrMutation reads.
export async function fetchUpdateIssueComment(
client: Pick<RpcClient, 'sendRequest'>,
args: { owner: string; repo: string; commentId: number; body: string }
args: { owner: string; repo: string; host?: string; commentId: number; body: string }
): Promise<GitHubPrMutationOutcome> {
return sendGithubPrMutation(client, 'github.project.updateIssueCommentBySlug', {
owner: args.owner,
repo: args.repo,
...githubPrRepoSlugParam(args),
commentId: args.commentId,
body: args.body
})
Expand All @@ -305,21 +296,24 @@ export async function fetchUpdateIssueComment(
// Delete a root conversation (issue) comment. Slug-addressed like the edit wrapper.
export async function fetchDeleteIssueComment(
client: Pick<RpcClient, 'sendRequest'>,
args: { owner: string; repo: string; commentId: number }
args: { owner: string; repo: string; host?: string; commentId: number }
): Promise<GitHubPrMutationOutcome> {
return sendGithubPrMutation(client, 'github.project.deleteIssueCommentBySlug', {
owner: args.owner,
repo: args.repo,
...githubPrRepoSlugParam(args),
commentId: args.commentId
})
}

export async function fetchRerunPRChecks(
client: Pick<RpcClient, 'sendRequest'>,
worktreeId: string,
args: { prNumber: number; headSha?: string | null; failedOnly?: boolean }
args: {
prNumber: number
headSha?: string | null
failedOnly?: boolean
prRepo?: GitHubPrRepoSlug | null
}
): Promise<GitHubPrMutationOutcome> {
// rerunPRChecks does NOT accept prRepo (KTD3); headSha is a plain param here.
const params: Record<string, unknown> = { prNumber: args.prNumber }
if (args.failedOnly !== undefined) {
params.failedOnly = args.failedOnly
Expand All @@ -330,6 +324,6 @@ export async function fetchRerunPRChecks(
return sendGithubPrMutation(
client,
'github.rerunPRChecks',
buildGithubPrParams('github.rerunPRChecks', worktreeId, params)
buildGithubPrParams('github.rerunPRChecks', worktreeId, params, { prRepo: args.prRepo })
)
}
40 changes: 26 additions & 14 deletions mobile/src/session/github-pr-rpc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,17 @@ describe('readPRForBranch', () => {
const parsed = readPRForBranch({
number: 3,
state: 'open',
prRepo: { owner: 'forkOwner', repo: 'forkRepo' },
prRepo: { owner: 'forkOwner', repo: 'forkRepo', host: 'github.acme.test' },
mergeMethodSettings: {
defaultMethod: 'squash',
allowedMethods: { merge: false, squash: true, rebase: true }
}
})
expect(parsed?.prRepo).toEqual({ owner: 'forkOwner', repo: 'forkRepo' })
expect(parsed?.prRepo).toEqual({
owner: 'forkOwner',
repo: 'forkRepo',
host: 'github.acme.test'
})
expect(parsed?.mergeMethodSettings).toEqual({
defaultMethod: 'squash',
allowedMethods: { merge: false, squash: true, rebase: true }
Expand Down Expand Up @@ -266,7 +270,7 @@ describe('readAssignableUsers', () => {
})

describe('buildGithubPrParams — method-aware prRepo / headSha', () => {
const fork = { owner: 'forkOwner', repo: 'forkRepo' }
const fork = { owner: 'forkOwner', repo: 'forkRepo', host: 'github.acme.test' }

it('reuses mobileRepoSelectorFromWorktreeId for the repo selector', () => {
const params = buildGithubPrParams('github.prChecks', WORKTREE_ID, { prNumber: 1 })
Expand All @@ -278,23 +282,28 @@ describe('buildGithubPrParams — method-aware prRepo / headSha', () => {
for (const method of [
'github.prChecks',
'github.prCheckDetails',
'github.rerunPRChecks',
'github.resolveReviewThread',
'github.setPRFileViewed',
'github.updatePRState',
'github.requestPRReviewers',
'github.removePRReviewers',
'github.mergePR',
'github.setPRAutoMerge',
'github.prComments'
'github.updatePRTitle',
'github.prComments',
'github.prFileContents',
'github.addPRReviewComment',
'github.addIssueComment',
'github.addPRReviewCommentReply'
]) {
const params = buildGithubPrParams(method, WORKTREE_ID, { prNumber: 1 }, { prRepo: fork })
expect(params.prRepo).toEqual(fork)
}
})

it('omits prRepo for methods that reject it', () => {
for (const method of [
'github.updatePRState',
'github.requestPRReviewers',
'github.removePRReviewers',
'github.listAssignableUsers',
'github.rerunPRChecks'
]) {
for (const method of ['github.repoSlug', 'github.prForBranch', 'github.listAssignableUsers']) {
const params = buildGithubPrParams(method, WORKTREE_ID, { prNumber: 1 }, { prRepo: fork })
expect('prRepo' in params).toBe(false)
}
Expand Down Expand Up @@ -380,12 +389,15 @@ describe('fetch wrappers', () => {
expect('headSha' in (params as object)).toBe(false)
})

it('fetchGithubRepoSlug returns the slug for a github repo, null otherwise', async () => {
it('fetchGithubRepoSlug preserves an Enterprise host, and returns null otherwise', async () => {
const found = await fetchGithubRepoSlug(
mockClient(okResponse({ owner: 'o', repo: 'r' })).client,
mockClient(okResponse({ owner: 'o', repo: 'r', host: 'github.acme.test' })).client,
WORKTREE_ID
)
expect(found).toEqual({ ok: true, result: { owner: 'o', repo: 'r' } })
expect(found).toEqual({
ok: true,
result: { owner: 'o', repo: 'r', host: 'github.acme.test' }
})
const none = await fetchGithubRepoSlug(mockClient(okResponse(null)).client, WORKTREE_ID)
expect(none).toEqual({ ok: true, result: null })
})
Expand Down
Loading
Loading