mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
refactor(github): organize concrete feature owners (#41601)
This commit is contained in:
@@ -14,7 +14,7 @@ import type { ProjectExecutionRuntimeResolution } from '../../../shared/executio
|
||||
import { OrcaRuntimeWithLinearCommands } from '../integrations/linear/linear-commands'
|
||||
|
||||
import type { RuntimeStore } from './runtime-store-contract'
|
||||
import { installGitHubProjectAccounts } from '../../github/github-project-account'
|
||||
import { installGitHubProjectAccounts } from '../../github/accounts/github-project-account'
|
||||
import type { WorkspaceSleepPlatform } from '../workspaces/sleep/workspace-sleep-platform'
|
||||
import type { StatsCollector } from '../../stats/collector'
|
||||
|
||||
@@ -56,7 +56,7 @@ import { createEphemeralAgentSessionClaimSigner } from '../agent-session/ownersh
|
||||
import { registerConptyDa1OverrideInstaller } from '../terminal/output/terminal-model-query-authority'
|
||||
import { registerTerminalViewAttributesApplier } from '../terminal/view/terminal-view-attribute-store'
|
||||
import { RuntimeMachineName } from '../hosts/platform-probe/runtime-machine-name'
|
||||
import { setPRConflictSummaryRemoteFetches } from '../../github/conflict-summary'
|
||||
import { setPRConflictSummaryRemoteFetches } from '../../github/pull-requests/conflicts/conflict-summary'
|
||||
import { DESKTOP_TERMINAL_SCROLLBACK_ROWS_DEFAULT } from '../../../shared/terminal/replay/terminal-scrollback-policy'
|
||||
|
||||
// oxlint-disable-next-line typescript/no-unsafe-declaration-merging -- SAFETY: The constructor installs every checked canonical surface.
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
import '../../../github/rate-limit'
|
||||
import '../../../github/api/rate-limit'
|
||||
import type {
|
||||
GitHubCreateIssueFields,
|
||||
GitHubIssueUpdate
|
||||
} from '../../../../shared/issue-mutation-types'
|
||||
import type { GitHubOwnerRepo } from '../../../../shared/github/pull-request-types'
|
||||
import type { GitHubPRReviewCommentInput } from '../../../../shared/github/comment-types'
|
||||
import type { GitHubRepositoryIdentity as GitHubOwnerRepo } from '../../../../shared/github/repositories/repository-identity'
|
||||
import type { GitHubPRReviewCommentInput } from '../../../../shared/github/comments/comment-types'
|
||||
import type { Repo } from '../../../../shared/repo-types'
|
||||
import type { LocalProjectGhExecOptions } from '../../../workspaces/execution-host/project-runtime-git-options'
|
||||
import { addIssueComment } from '../../../github/issue-comment'
|
||||
import { addIssueComment } from '../../../github/issues/issue-comment'
|
||||
import {
|
||||
addPRReviewComment,
|
||||
addPRReviewCommentReply
|
||||
} from '../../../github/client/create/add-pr-review-comment'
|
||||
import { createIssue } from '../../../github/issue-create'
|
||||
import { updateIssue } from '../../../github/issue-update'
|
||||
import { createIssue } from '../../../github/issues/issue-create'
|
||||
import { updateIssue } from '../../../github/issues/issue-update'
|
||||
import { getRepoRoutingConnectionId } from '../../../../shared/execution-host'
|
||||
import type { GitHubAttachmentTarget } from '../../../../shared/rpc-contract/github-attachment-params'
|
||||
import { uploadGitHubImage } from '../../../github/image-attachment-upload'
|
||||
import { uploadGitHubImage } from '../../../github/attachments/image-attachment-upload'
|
||||
import {
|
||||
resolveGitHubRepoExecution,
|
||||
resolveIssueGitHubApiRepositorySource
|
||||
} from '../../../github/github-api-repository'
|
||||
import { projectGhExecOptions } from '../../../github/project-view/internals'
|
||||
} from '../../../github/repositories/github-api-repository'
|
||||
import { projectGhExecOptions } from '../../../github/project-view/project-host-execution'
|
||||
import { runAsDefaultWslCliUserAct } from '../../../git/command-runner/hosted-cli/default-wsl-cli-fallback'
|
||||
|
||||
type LocalGitArgs = [] | [LocalProjectGhExecOptions]
|
||||
|
||||
@@ -37,7 +37,7 @@ import type {
|
||||
UpdateIssueTypeBySlugArgs,
|
||||
UpdateProjectItemFieldArgs,
|
||||
UpdatePullRequestBySlugArgs
|
||||
} from '../../../../shared/github/project-request-types'
|
||||
} from '../../../../shared/github/projects/project-request-types'
|
||||
|
||||
export class RuntimeGitHubProjectCommands {
|
||||
listGitHubProjects(args?: ListAccessibleProjectsArgs) {
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import type { GhAccountBinding } from '../../../../shared/github/account-binding'
|
||||
import type { GitHubOwnerRepo } from '../../../../shared/github/pull-request-types'
|
||||
import type { ListWorkItemsResult } from '../../../../shared/github/work-item-types'
|
||||
import type { GhAccountBinding } from '../../../../shared/github/accounts/account-binding'
|
||||
import type { GitHubRepositoryIdentity as GitHubOwnerRepo } from '../../../../shared/github/repositories/repository-identity'
|
||||
import type { ListWorkItemsResult } from '../../../../shared/github/work-items/work-item-types'
|
||||
import type { Repo } from '../../../../shared/repo-types'
|
||||
import type { LocalProjectGhExecOptions } from '../../../workspaces/execution-host/project-runtime-git-options'
|
||||
import { countWorkItems } from '../../../github/client/list/count-work-items'
|
||||
import { getWorkItem, getWorkItemByOwnerRepo } from '../../../github/client/fetch/get-work-item'
|
||||
import { listAssignableUsers, listLabels } from '../../../github/issue-field-options'
|
||||
import { listIssues } from '../../../github/issues'
|
||||
import { listAssignableUsers, listLabels } from '../../../github/issues/issue-field-options'
|
||||
import { listIssues } from '../../../github/issues/issues'
|
||||
import { listWorkItems } from '../../../github/client/list/list-work-items'
|
||||
import type { MainWorkItem } from '../../../github/client/map/work-item-field-coercion'
|
||||
import {
|
||||
listGhAccountBindingInventory,
|
||||
validateGhAccountBinding
|
||||
} from '../../../github/gh-account-binding-inventory'
|
||||
import { getRateLimit } from '../../../github/rate-limit'
|
||||
import { resolveGhAccountRequiredHost } from '../../../github/account-binding-required-host'
|
||||
import { getWorkItemDetails } from '../../../github/work-item-details'
|
||||
} from '../../../github/accounts/gh-account-binding-inventory'
|
||||
import { getRateLimit } from '../../../github/api/rate-limit'
|
||||
import { resolveGhAccountRequiredHost } from '../../../github/accounts/account-binding-required-host'
|
||||
import { getWorkItemDetails } from '../../../github/work-items/work-item-details'
|
||||
import { getRepoRoutingConnectionId } from '../../../../shared/execution-host'
|
||||
|
||||
type LocalGitArgs = [] | [LocalProjectGhExecOptions]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { GhAccountBinding } from '../../../../shared/github/account-binding'
|
||||
import type { GitHubOwnerRepo } from '../../../../shared/github/pull-request-types'
|
||||
import type { GhAccountBinding } from '../../../../shared/github/accounts/account-binding'
|
||||
import type { GitHubRepositoryIdentity as GitHubOwnerRepo } from '../../../../shared/github/repositories/repository-identity'
|
||||
import type { GitHubPullRequestStateUpdate } from '../../../../shared/issue-mutation-types'
|
||||
import type { GitHubReactionContent } from '../../../../shared/github/comment-types'
|
||||
import type { GitHubReactionContent } from '../../../../shared/github/comments/comment-types'
|
||||
import type { Repo } from '../../../../shared/repo-types'
|
||||
import type { LocalProjectGhExecOptions } from '../../../workspaces/execution-host/project-runtime-git-options'
|
||||
import { mergePR } from '../../../github/client/merge/merge-pr'
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import type { GitHubOwnerRepo, GitHubPRFile } from '../../../../shared/github/pull-request-types'
|
||||
import type { GitHubRepositoryIdentity as GitHubOwnerRepo } from '../../../../shared/github/repositories/repository-identity'
|
||||
import type { GitHubPRFile } from '../../../../shared/github/pull-requests/pull-request-types'
|
||||
import type { Repo } from '../../../../shared/repo-types'
|
||||
import type { LocalProjectGhExecOptions } from '../../../workspaces/execution-host/project-runtime-git-options'
|
||||
import { getIssue } from '../../../github/issues'
|
||||
import { getIssue } from '../../../github/issues/issues'
|
||||
import { getPRCheckDetails } from '../../../github/client/check/get-pr-check-details'
|
||||
import { getPRChecks } from '../../../github/client/check/get-pr-checks'
|
||||
import { getPRComments } from '../../../github/client/fetch/get-pr-comments'
|
||||
import { getPRFileContents } from '../../../github/work-item-details'
|
||||
import { getPRFileContents } from '../../../github/pull-requests/files/pull-request-file-contents'
|
||||
import { getRepoRoutingConnectionId } from '../../../../shared/execution-host'
|
||||
|
||||
type LocalGitArgs = [] | [LocalProjectGhExecOptions]
|
||||
|
||||
@@ -3,10 +3,10 @@ import type { Repo } from '../../../../shared/repo-types'
|
||||
import {
|
||||
fetchPrHeadTrackingRef,
|
||||
fetchGitHubPullRequestHeadRef
|
||||
} from '../../../github/pr-head-tracking-ref'
|
||||
import { resolveGitHubPrStartPoint } from '../../../github/pr-start-point'
|
||||
import { resolvePrStartPointUnlessWslStopped } from '../../../github/pr-start-point-wsl-gate'
|
||||
import { resolveGitHubReviewHeadRemote } from '../../../github/review-head-remote'
|
||||
} from '../../../github/pull-requests/start-points/pr-head-tracking-ref'
|
||||
import { resolveGitHubPrStartPoint } from '../../../github/pull-requests/start-points/pr-start-point'
|
||||
import { resolvePrStartPointUnlessWslStopped } from '../../../github/pull-requests/start-points/pr-start-point-wsl-gate'
|
||||
import { resolveGitHubReviewHeadRemote } from '../../../github/pull-requests/start-points/review-head-remote'
|
||||
import { gitExecFileAsync } from '../../../git/command-runner/git-exec-file'
|
||||
import {
|
||||
getLocalProjectGitExecOptions,
|
||||
|
||||
@@ -16,7 +16,7 @@ import type { ProjectRuntimeResolutionStore } from '../../../workspaces/executio
|
||||
import { resolveRuntimeGitLabForkMrBase } from './runtime-gitlab-fork-mr-base'
|
||||
import { resolveRuntimeGitLabIssueSourceRemote } from './runtime-gitlab-issue-source-remote'
|
||||
import { reviewStartPointFailure } from '../../../../shared/review-start-point-failure-copy'
|
||||
import { resolvePrStartPointUnlessWslStopped } from '../../../github/pr-start-point-wsl-gate'
|
||||
import { resolvePrStartPointUnlessWslStopped } from '../../../github/pull-requests/start-points/pr-start-point-wsl-gate'
|
||||
|
||||
export type RuntimeGitLabWorktreeBaseArgs = {
|
||||
repoSelector: string
|
||||
|
||||
@@ -1,29 +1,30 @@
|
||||
import type {
|
||||
CreateHostedReviewInput,
|
||||
CreateHostedReviewResult,
|
||||
CreateStackedHostedReviewInput,
|
||||
CreateStackedHostedReviewResult,
|
||||
HostedReviewCreationEligibility,
|
||||
HostedReviewCreationEligibilityArgs,
|
||||
HostedReviewForBranchReply
|
||||
} from '../../../../shared/source-control/hosted-review/hosted-review-contracts'
|
||||
import type { GitHubOwnerRepo } from '../../../../shared/github/pull-request-types'
|
||||
import type {
|
||||
GitHubPRRefreshReason,
|
||||
PRRefreshOutcome
|
||||
} from '../../../../shared/github/pull-request-refresh-types'
|
||||
import type { Repo } from '../../../../shared/repo-types'
|
||||
import type { DeviceScope } from '../../../../shared/runtime-session-contracts'
|
||||
import {
|
||||
getPRForBranchOutcome,
|
||||
readRecentPhonePROutcome
|
||||
} from '../../../github/client/lookup/pr-for-branch-outcome'
|
||||
import type { GitHubRepositoryIdentity as GitHubOwnerRepo } from '../../../../shared/github/repositories/repository-identity'
|
||||
import type {
|
||||
GitHubPRRefreshReason,
|
||||
PRRefreshOutcome
|
||||
} from '../../../../shared/github/pull-requests/refresh/pull-request-refresh-types'
|
||||
import type { Repo } from '../../../../shared/repo-types'
|
||||
import type { DeviceScope } from '../../../../shared/runtime-session-contracts'
|
||||
import { getRepoSlug, getRepoUpstream } from '../../../github/client/fetch/repo-slug-upstream'
|
||||
import { admissionTierForRefreshReason } from '../../../github/pull-requests/refresh/pr-refresh-candidate-policy'
|
||||
import type { GitHubPRBranchLookupOptions } from '../../../github/client/lookup/pull-request-lookup-data'
|
||||
import { admissionTierForRefreshReason } from '../../../github/pr-refresh-candidate-policy'
|
||||
import { runHostedPRRead } from '../../../github/pr-refresh-coordinator'
|
||||
import { runHostedPRRead } from '../../../github/pull-requests/refresh/pr-refresh-coordinator'
|
||||
import {
|
||||
type CreateHostedReviewInput,
|
||||
type CreateHostedReviewResult,
|
||||
type CreateStackedHostedReviewInput,
|
||||
type CreateStackedHostedReviewResult,
|
||||
type HostedReviewCreationEligibility,
|
||||
type HostedReviewCreationEligibilityArgs,
|
||||
type HostedReviewForBranchReply,
|
||||
hostedReviewForBranchReply
|
||||
} from '../../../../shared/source-control/hosted-review/hosted-review-contracts'
|
||||
import type { GitAdmissionTier } from '../../../../shared/rpc-contract/git-admission-tier-params'
|
||||
import { hostedReviewForBranchReply } from '../../../../shared/source-control/hosted-review/hosted-review-contracts'
|
||||
|
||||
import { readHostedReviewForBranch } from '../../../source-control/hosted-review'
|
||||
import { getStoredRepoExecutionHostId } from '../../../workspaces/execution-host/repo-execution-host'
|
||||
import { hostedReviewSshConnectionId } from '../../../source-control/hosted-review-execution-host'
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
import type * as GithubRepositoryIdentityModule from '../../../github/repositories/github-repository-identity'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type {
|
||||
GitHubPRRefreshReason,
|
||||
PRRefreshOutcome
|
||||
} from '../../../../shared/github/pull-request-refresh-types'
|
||||
} from '../../../../shared/github/pull-requests/refresh/pull-request-refresh-types'
|
||||
import type {
|
||||
GitHubRepoContext,
|
||||
LocalGitExecOptions
|
||||
} from '../../../github/github-repository-identity'
|
||||
} from '../../../github/repositories/github-repository-identity'
|
||||
import type { Repo } from '../../../../shared/repo-types'
|
||||
import type { DeviceScope } from '../../../../shared/runtime-session-contracts'
|
||||
import { makePR } from '../../../github/pr-refresh-coordinator-test-harness'
|
||||
import { makePR } from '../../../github/pull-requests/refresh/pr-refresh-coordinator-test-harness'
|
||||
|
||||
const mocks = vi.hoisted(() => ({ resolve: vi.fn() }))
|
||||
vi.mock('../../../github/gh-utils', () => ({
|
||||
vi.mock('../../../github/execution/github-operation-slots', () => ({
|
||||
acquire: vi.fn(async () => {}),
|
||||
release: vi.fn(),
|
||||
release: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('../../../github/repositories/github-repository-identity', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof GithubRepositoryIdentityModule>()),
|
||||
githubRepoContext: (
|
||||
repoPath: string,
|
||||
connectionId: string | null,
|
||||
@@ -25,7 +30,7 @@ vi.mock('../../../github/gh-utils', () => ({
|
||||
vi.mock('../../../github/client/lookup/branch-lookup-resolution', () => ({
|
||||
resolvePRForBranchOutcome: mocks.resolve
|
||||
}))
|
||||
vi.mock('../../../github/pr-refresh-coordinator', () => ({
|
||||
vi.mock('../../../github/pull-requests/refresh/pr-refresh-coordinator', () => ({
|
||||
runHostedPRRead: (_candidate: unknown, read: () => Promise<PRRefreshOutcome>) => read()
|
||||
}))
|
||||
import { RuntimeHostedReviewCommands } from './runtime-hosted-review-commands'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { PHONE_RELAY_CONNECT_BUDGET_MS } from '../../../shared/remote-runtime/recipe-vm-wake'
|
||||
import { verifyRelayedGitHubAuthority } from './relay-github-authority'
|
||||
import { createRelayedBrowserTab } from './relayed-browser-tab-create'
|
||||
import { GITHUB_EXACT_OPERATION_UNSUPPORTED } from '../../../shared/github/work-item-target'
|
||||
import { GITHUB_EXACT_OPERATION_UNSUPPORTED } from '../../../shared/github/work-items/work-item-target'
|
||||
import { pairedRuntimeConnectionFromOffer } from '../../../shared/remote-runtime/pairing/paired-runtime-connection'
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import type { RpcRequest } from '../rpc/core'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import { z } from 'zod'
|
||||
import { classifyExactGitHubOperation } from '../../../shared/github/exact-work-item-operation'
|
||||
import { GITHUB_EXACT_OPERATION_UNSUPPORTED } from '../../../shared/github/work-item-target'
|
||||
import { classifyExactGitHubOperation } from '../../../shared/github/work-items/exact-work-item-operation'
|
||||
import { GITHUB_EXACT_OPERATION_UNSUPPORTED } from '../../../shared/github/work-items/work-item-target'
|
||||
import { GITHUB_EXACT_DETAILS_READ_INTENT_RUNTIME_CAPABILITY } from '../../../shared/work-items/task-source-runtime-capabilities'
|
||||
import { GITHUB_EXACT_WORK_ITEM_TARGET_RUNTIME_CAPABILITY } from '../../../shared/source-control/runtime/source-control-runtime-capabilities'
|
||||
import type { RemoteRuntimePassthroughSocket } from '../../../shared/remote-runtime/remote-runtime-passthrough-socket'
|
||||
|
||||
@@ -1,3 +1,29 @@
|
||||
import type * as RepoSlugUpstreamModule from '../../github/client/fetch/repo-slug-upstream'
|
||||
import type * as GetPrForBranchModule from '../../github/client/lookup/get-pr-for-branch'
|
||||
import type * as PrForBranchOutcomeModule from '../../github/client/lookup/pr-for-branch-outcome'
|
||||
import type * as GetWorkItemModule from '../../github/client/fetch/get-work-item'
|
||||
import type * as PullRequestPushTargetModule from '../../github/client/lookup/pull-request-push-target'
|
||||
import type * as GetPrChecksModule from '../../github/client/check/get-pr-checks'
|
||||
import type * as RerunPrChecksModule from '../../github/client/check/rerun-pr-checks'
|
||||
import type * as GetPrCheckDetailsModule from '../../github/client/check/get-pr-check-details'
|
||||
import type * as GetPrCommentsModule from '../../github/client/fetch/get-pr-comments'
|
||||
import type * as ResolveReviewThreadModule from '../../github/client/update/resolve-review-thread'
|
||||
import type * as PrFileViewedModule from '../../github/client/update/pr-file-viewed'
|
||||
import type * as PrDetailsModule from '../../github/client/update/pr-details'
|
||||
import type * as MergePrModule from '../../github/client/merge/merge-pr'
|
||||
import type * as PrAutoMergeModule from '../../github/client/merge/pr-auto-merge'
|
||||
import type * as PrStateModule from '../../github/client/update/pr-state'
|
||||
import type * as PrReviewersModule from '../../github/client/update/pr-reviewers'
|
||||
import type * as AddPrReviewCommentModule from '../../github/client/create/add-pr-review-comment'
|
||||
import type * as IssuesModule from '../../github/issues/issues'
|
||||
import type * as ListWorkItemsModule from '../../github/client/list/list-work-items'
|
||||
import type * as CountWorkItemsModule from '../../github/client/list/count-work-items'
|
||||
import type * as IssueCreateModule from '../../github/issues/issue-create'
|
||||
import type * as IssueUpdateModule from '../../github/issues/issue-update'
|
||||
import type * as IssueCommentModule from '../../github/issues/issue-comment'
|
||||
import type * as IssueFieldOptionsModule from '../../github/issues/issue-field-options'
|
||||
import type * as WorkItemDetailsModule from '../../github/work-items/work-item-details'
|
||||
import type * as PullRequestFileContentsModule from '../../github/pull-requests/files/pull-request-file-contents'
|
||||
import { vi, type Mock } from 'vitest'
|
||||
|
||||
// GitHub and hosted-review mocks shared by runtime specs through setup.spec.
|
||||
@@ -105,176 +131,147 @@ vi.mock('../../source-control/hosted-review', () => ({
|
||||
}))
|
||||
|
||||
vi.mock('../../github/client/fetch/repo-slug-upstream', async (importOriginal) => ({
|
||||
...(await importOriginal<Record<string, unknown>>()),
|
||||
...(await importOriginal<typeof RepoSlugUpstreamModule>()),
|
||||
getRepoSlug: getRepoSlugMock,
|
||||
getRepoUpstream: getRepoUpstreamMock
|
||||
}))
|
||||
|
||||
vi.mock('../../github/client', async (importOriginal) => {
|
||||
const actual = (await importOriginal()) as Record<string, unknown>
|
||||
return {
|
||||
...actual,
|
||||
getPRForBranch: getPRForBranchMock,
|
||||
getPRForBranchOutcome: getPRForBranchOutcomeMock,
|
||||
getRepoSlug: getRepoSlugMock,
|
||||
getRepoUpstream: getRepoUpstreamMock,
|
||||
getWorkItem: getGitHubWorkItemMock,
|
||||
getPullRequestPushTarget: getPullRequestPushTargetMock,
|
||||
getWorkItemByOwnerRepo: getGitHubWorkItemByOwnerRepoMock,
|
||||
getPRChecks: getGitHubPRChecksMock,
|
||||
rerunPRChecks: rerunGitHubPRChecksMock,
|
||||
getPRCheckDetails: getGitHubPRCheckDetailsMock,
|
||||
getPRComments: getGitHubPRCommentsMock,
|
||||
resolveReviewThread: resolveGitHubReviewThreadMock,
|
||||
setPRFileViewed: setGitHubPRFileViewedMock,
|
||||
updatePRTitle: updateGitHubPRTitleMock,
|
||||
updatePRDetails: updateGitHubPRDetailsMock,
|
||||
mergePR: mergeGitHubPRMock,
|
||||
setPRAutoMerge: setGitHubPRAutoMergeMock,
|
||||
updatePRState: updateGitHubPRStateMock,
|
||||
requestPRReviewers: requestGitHubPRReviewersMock,
|
||||
removePRReviewers: removeGitHubPRReviewersMock,
|
||||
addPRReviewComment: addGitHubPRReviewCommentMock,
|
||||
addPRReviewCommentReply: addGitHubPRReviewCommentReplyMock,
|
||||
listIssues: listGitHubIssuesMock,
|
||||
listWorkItems: listGitHubWorkItemsMock,
|
||||
countWorkItems: countGitHubWorkItemsMock,
|
||||
getIssue: getIssueMock,
|
||||
createIssue: createGitHubIssueMock,
|
||||
updateIssue: updateGitHubIssueMock,
|
||||
addIssueComment: addGitHubIssueCommentMock,
|
||||
listLabels: listGitHubLabelsMock,
|
||||
listAssignableUsers: listGitHubAssignableUsersMock
|
||||
}
|
||||
})
|
||||
vi.mock('../../github/client/lookup/get-pr-for-branch', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof GetPrForBranchModule>()),
|
||||
getPRForBranch: getPRForBranchMock
|
||||
}))
|
||||
|
||||
vi.mock('../../github/work-item-details', async (importOriginal) => {
|
||||
const actual = (await importOriginal()) as Record<string, unknown>
|
||||
return {
|
||||
...actual,
|
||||
getWorkItemDetails: getGitHubWorkItemDetailsMock,
|
||||
getPRFileContents: getGitHubPRFileContentsMock
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock('../../github/issues', async (importOriginal) => {
|
||||
const actual = (await importOriginal()) as Record<string, unknown>
|
||||
return {
|
||||
...actual,
|
||||
getIssue: getIssueMock,
|
||||
listIssues: listGitHubIssuesMock
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock(import('../../github/client/lookup/pr-for-branch-outcome'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/client/lookup/pr-for-branch-outcome', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof PrForBranchOutcomeModule>()),
|
||||
getPRForBranchOutcome: getPRForBranchOutcomeMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/client/fetch/get-work-item'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/client/fetch/get-work-item', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof GetWorkItemModule>()),
|
||||
getWorkItem: getGitHubWorkItemMock,
|
||||
getWorkItemByOwnerRepo: getGitHubWorkItemByOwnerRepoMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/client/check/get-pr-checks'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/client/lookup/pull-request-push-target', async (importOriginal) => {
|
||||
return {
|
||||
...(await importOriginal<typeof PullRequestPushTargetModule>()),
|
||||
getPullRequestPushTarget: getPullRequestPushTargetMock
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock('../../github/client/check/get-pr-checks', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof GetPrChecksModule>()),
|
||||
getPRChecks: getGitHubPRChecksMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/client/check/rerun-pr-checks'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/client/check/rerun-pr-checks', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof RerunPrChecksModule>()),
|
||||
rerunPRChecks: rerunGitHubPRChecksMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/client/check/get-pr-check-details'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/client/check/get-pr-check-details', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof GetPrCheckDetailsModule>()),
|
||||
getPRCheckDetails: getGitHubPRCheckDetailsMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/client/fetch/get-pr-comments'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/client/fetch/get-pr-comments', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof GetPrCommentsModule>()),
|
||||
getPRComments: getGitHubPRCommentsMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/client/update/resolve-review-thread'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/client/update/resolve-review-thread', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof ResolveReviewThreadModule>()),
|
||||
resolveReviewThread: resolveGitHubReviewThreadMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/client/update/pr-file-viewed'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/client/update/pr-file-viewed', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof PrFileViewedModule>()),
|
||||
setPRFileViewed: setGitHubPRFileViewedMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/client/update/pr-details'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/client/update/pr-details', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof PrDetailsModule>()),
|
||||
updatePRTitle: updateGitHubPRTitleMock,
|
||||
updatePRDetails: updateGitHubPRDetailsMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/client/merge/merge-pr'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/client/merge/merge-pr', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof MergePrModule>()),
|
||||
mergePR: mergeGitHubPRMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/client/merge/pr-auto-merge'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/client/merge/pr-auto-merge', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof PrAutoMergeModule>()),
|
||||
setPRAutoMerge: setGitHubPRAutoMergeMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/client/update/pr-state'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/client/update/pr-state', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof PrStateModule>()),
|
||||
updatePRState: updateGitHubPRStateMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/client/update/pr-reviewers'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/client/update/pr-reviewers', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof PrReviewersModule>()),
|
||||
requestPRReviewers: requestGitHubPRReviewersMock,
|
||||
removePRReviewers: removeGitHubPRReviewersMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/client/create/add-pr-review-comment'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/client/create/add-pr-review-comment', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof AddPrReviewCommentModule>()),
|
||||
addPRReviewComment: addGitHubPRReviewCommentMock,
|
||||
addPRReviewCommentReply: addGitHubPRReviewCommentReplyMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/client/list/list-work-items'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/issues/issues', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof IssuesModule>()),
|
||||
listIssues: listGitHubIssuesMock,
|
||||
getIssue: getIssueMock
|
||||
}))
|
||||
|
||||
vi.mock('../../github/client/list/list-work-items', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof ListWorkItemsModule>()),
|
||||
listWorkItems: listGitHubWorkItemsMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/client/list/count-work-items'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/client/list/count-work-items', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof CountWorkItemsModule>()),
|
||||
countWorkItems: countGitHubWorkItemsMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/issue-create'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/issues/issue-create', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof IssueCreateModule>()),
|
||||
createIssue: createGitHubIssueMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/issue-update'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/issues/issue-update', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof IssueUpdateModule>()),
|
||||
updateIssue: updateGitHubIssueMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/issue-comment'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/issues/issue-comment', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof IssueCommentModule>()),
|
||||
addIssueComment: addGitHubIssueCommentMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/issue-field-options'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
vi.mock('../../github/issues/issue-field-options', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof IssueFieldOptionsModule>()),
|
||||
listLabels: listGitHubLabelsMock,
|
||||
listAssignableUsers: listGitHubAssignableUsersMock
|
||||
}))
|
||||
|
||||
vi.mock(import('../../github/client/lookup/get-pr-for-branch'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
getPRForBranch: getPRForBranchMock
|
||||
}))
|
||||
vi.mock('../../github/work-items/work-item-details', async (importOriginal) => {
|
||||
return {
|
||||
...(await importOriginal<typeof WorkItemDetailsModule>()),
|
||||
getWorkItemDetails: getGitHubWorkItemDetailsMock
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock('../../github/pull-requests/files/pull-request-file-contents', async (importOriginal) => {
|
||||
return {
|
||||
...(await importOriginal<typeof PullRequestFileContentsModule>()),
|
||||
getPRFileContents: getGitHubPRFileContentsMock
|
||||
}
|
||||
})
|
||||
|
||||
export {
|
||||
createHostedReviewMock,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { isRepoHidden } from '../../../shared/hidden-projects'
|
||||
import { commitProvenRepoKindChange } from '../../workspaces/catalog/folder-repo-git-conversion'
|
||||
import type { Repo } from '../../../shared/repo-types'
|
||||
import type { RuntimeRepoSelector } from '../workspaces/catalog/runtime-repo-selector'
|
||||
import type { GhAccountBinding } from '../../../shared/github/account-binding'
|
||||
import type { GhAccountBinding } from '../../../shared/github/accounts/account-binding'
|
||||
import { invalidateAuthorizedRootsCache } from '../../ipc/worktrees/removal/registered-worktree-roots-cache'
|
||||
import { prepareLocalWorktreeRootForRepo } from '../../workspaces/creation/worktree-root-preparation'
|
||||
import type { RuntimeStore } from '../construction/runtime-store-contract'
|
||||
|
||||
@@ -1,213 +0,0 @@
|
||||
// Exercise every domain's real store writers and announcements (design §9.4); phone reads must not re-read domains.
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { RuntimeClientEvent } from '../../../shared/runtime-client-events'
|
||||
import type { Repo } from '../../../shared/repo-types'
|
||||
import type { PRInfo } from '../../../shared/github/pull-request-types'
|
||||
import type { WslHostService } from '../../wsl/host-lifecycle/wsl-host-service'
|
||||
import { setWslHostService } from '../../wsl/host-lifecycle/wsl-host-service-instance'
|
||||
import { getGitHubPRCacheKeyCandidates } from '../../../shared/github/github-cache-key'
|
||||
import { toRuntimeExecutionHostId } from '../../../shared/execution-host'
|
||||
import {
|
||||
getWorktreeHostIdentity,
|
||||
hostWorktreeTarget
|
||||
} from '../../../shared/worktree/host-qualified-identity'
|
||||
import {
|
||||
prGroupOfReviewFact,
|
||||
WorkspaceReviewFactsSnapshotSchema,
|
||||
type WorkspaceReviewFact
|
||||
} from '../../../shared/sidebar-list/workspace-review-facts'
|
||||
import { fixture } from '../../persistence/loading-store/profile-writing/profile-state-delayed-authority-fixture'
|
||||
import { ProducerRevision } from './producer-revision'
|
||||
import { SidebarInputsFeed } from './sidebar-inputs-feed'
|
||||
import {
|
||||
sidebarInputsFeedDomains,
|
||||
type SidebarInputsFeedSources
|
||||
} from './sidebar-inputs-feed-domains'
|
||||
import { TestPhone } from './sidebar-inputs-feed.test-fixture'
|
||||
|
||||
const repo: Repo = { id: 'repo-1', path: '/r', displayName: 'r', badgeColor: 'blue', addedAt: 1 }
|
||||
const worktree = {
|
||||
id: 'repo-1::/r/a',
|
||||
repoId: repo.id,
|
||||
hostId: 'local',
|
||||
branch: 'refs/heads/feature',
|
||||
linkedPR: null
|
||||
} as const
|
||||
|
||||
async function host() {
|
||||
const { store } = await fixture()
|
||||
store.addRepo(repo)
|
||||
const clientEvents = new Set<(event: RuntimeClientEvent) => void>()
|
||||
const temporal = new Set<() => void>()
|
||||
const wslListeners = new Set<() => void>()
|
||||
const revisions = {
|
||||
activity: new ProducerRevision(),
|
||||
paired: new ProducerRevision(),
|
||||
creations: new ProducerRevision(),
|
||||
rows: new ProducerRevision(),
|
||||
detected: new ProducerRevision(),
|
||||
liveContent: new ProducerRevision()
|
||||
}
|
||||
// A WSL registry that only announces; this host has no WSL hosts.
|
||||
const wsl = {
|
||||
getStatuses: () => [],
|
||||
onStatusesChanged: (listener: () => void) => {
|
||||
wslListeners.add(listener)
|
||||
return () => wslListeners.delete(listener)
|
||||
}
|
||||
}
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the desktop domain reads only these two members.
|
||||
setWslHostService(wsl as unknown as WslHostService)
|
||||
const sources: SidebarInputsFeedSources = {
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the domains read only the members stubbed here.
|
||||
facts: {
|
||||
workspaceActivityFacts: { revision: revisions.activity },
|
||||
getWorkspaceActivityFacts: () => ({ revision: 0, facts: {} }),
|
||||
getSidebarTemporalSnapshot: () => ({ sessionId: null, retention: null }),
|
||||
onSidebarTemporalChange: (listener: () => void) => {
|
||||
temporal.add(listener)
|
||||
return () => temporal.delete(listener)
|
||||
},
|
||||
detectedCheckouts: {
|
||||
revision: revisions.detected,
|
||||
snapshot: () => ({}),
|
||||
watch: (listener: () => void) => revisions.detected.onChange(listener)
|
||||
},
|
||||
workspaceLiveContent: { revision: revisions.liveContent, snapshot: () => ({}) }
|
||||
} as unknown as SidebarInputsFeedSources['facts'],
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: as above.
|
||||
pairedServerRows: {
|
||||
revision: revisions.paired,
|
||||
snapshot: () => ({ servers: [] }),
|
||||
catalogs: () => []
|
||||
} as unknown as SidebarInputsFeedSources['pairedServerRows'],
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: as above.
|
||||
workspaceLifecycle: {
|
||||
revision: revisions.creations,
|
||||
creationsSnapshot: () => ({ creations: {} }),
|
||||
hints: () => ({})
|
||||
} as unknown as SidebarInputsFeedSources['workspaceLifecycle'],
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: as above; one cached worktree, already scanned.
|
||||
workspaceRows: {
|
||||
revision: revisions.rows,
|
||||
snapshot: () => ({ revision: 0, rows: {} }),
|
||||
resolvedWorktrees: () => [worktree],
|
||||
ready: async () => {}
|
||||
} as unknown as SidebarInputsFeedSources['workspaceRows'],
|
||||
repoIcons: { idsByRepo: () => ({}) },
|
||||
store: () => store,
|
||||
onClientEvent: (listener) => {
|
||||
clientEvents.add(listener)
|
||||
return () => clientEvents.delete(listener)
|
||||
}
|
||||
}
|
||||
const emit = (event: RuntimeClientEvent): void =>
|
||||
clientEvents.forEach((listener) => listener(event))
|
||||
const catalogEvent = (): void => emit({ type: 'reposChanged' })
|
||||
// Every public writer of what each domain reads.
|
||||
const writers: Record<string, Record<string, () => void>> = {
|
||||
activity: {
|
||||
'activity producer': () => revisions.activity.bump(),
|
||||
'paired server rows': () => revisions.paired.bump(),
|
||||
// Only a paired server's partition holds activity (its browser and chat tabs).
|
||||
'saved session': () =>
|
||||
store.patchWorkspaceSession({ activeTabId: 'tab-1' }, toRuntimeExecutionHostId('env-1'))
|
||||
},
|
||||
temporal: { 'retention owner': () => temporal.forEach((listener) => listener()) },
|
||||
creations: { 'lifecycle queue': () => revisions.creations.bump() },
|
||||
inProgress: { 'lifecycle queue': () => revisions.creations.bump() },
|
||||
workspaces: { 'workspace rows producer': () => revisions.rows.bump() },
|
||||
detected: { 'detected checkouts producer': () => revisions.detected.bump() },
|
||||
liveContent: { 'live content producer': () => revisions.liveContent.bump() },
|
||||
view: { 'ui write': () => store.updateUI({ groupBy: 'pr-status' }) },
|
||||
pairedServerHosts: { 'paired server rows': () => revisions.paired.bump() },
|
||||
pairedServerRows: { 'paired server rows': () => revisions.paired.bump() },
|
||||
desktop: {
|
||||
'catalog event': catalogEvent,
|
||||
'ui write': () => store.updateUI({ workspaceHostOrder: ['local'] }),
|
||||
'settings write': () =>
|
||||
store.updateSettings({
|
||||
showPinnedWorktreesInGroups: !store.getSettings().showPinnedWorktreesInGroups
|
||||
}),
|
||||
'saved session': () => store.patchWorkspaceSession({ activeWorktreeId: worktree.id }),
|
||||
'pin write': () =>
|
||||
store.setWorktreeMeta(hostWorktreeTarget({ id: worktree.id, hostId: 'local' }), {
|
||||
isPinned: true
|
||||
}),
|
||||
'WSL status': () => wslListeners.forEach((listener) => listener())
|
||||
},
|
||||
projectCatalog: {
|
||||
'catalog event': catalogEvent,
|
||||
'paired server rows': () => revisions.paired.bump(),
|
||||
'ui write': () => store.updateUI({ projectOrderBy: 'recent' }),
|
||||
'full save': () =>
|
||||
store.setWorktreeLineage(hostWorktreeTarget({ id: worktree.id, hostId: 'local' }), {
|
||||
worktreeId: worktree.id,
|
||||
worktreeInstanceId: 'a-1',
|
||||
parentWorktreeId: 'repo-1::/r/p',
|
||||
parentWorktreeInstanceId: 'p-1',
|
||||
origin: 'manual',
|
||||
capture: { source: 'manual-action', confidence: 'explicit' },
|
||||
createdAt: 1
|
||||
})
|
||||
},
|
||||
repoIcons: { 'catalog event': catalogEvent },
|
||||
review: {
|
||||
'PR cache save': () => store.setGitHubCache({ ...store.getGitHubCache(), pr: {} }),
|
||||
'workspace rows producer': () => revisions.rows.bump(),
|
||||
'paired server rows': () => revisions.paired.bump(),
|
||||
'catalog event': catalogEvent
|
||||
}
|
||||
}
|
||||
return { store, sources, writers }
|
||||
}
|
||||
|
||||
function feedReviewFact(value: unknown): WorkspaceReviewFact | null {
|
||||
const parsed = WorkspaceReviewFactsSnapshotSchema.shape.facts.valueType.safeParse(value)
|
||||
return parsed.success ? parsed.data : null
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
vi.spyOn(console, 'warn').mockImplementation(() => {})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
setWslHostService(null)
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
describe('sidebar inputs feed announcements', () => {
|
||||
it('follows a PR cache save on a quiet desktop into the phone’s PR grouping', async () => {
|
||||
const { store, sources } = await host()
|
||||
const events: { generation: string; revision: number }[] = []
|
||||
const feed = new SidebarInputsFeed(
|
||||
() => sidebarInputsFeedDomains(sources),
|
||||
(event) => events.push(event)
|
||||
)
|
||||
store.updateUI({ groupBy: 'pr-status' })
|
||||
const phone = new TestPhone(feed, 'conn-1')
|
||||
phone.refresh()
|
||||
await phone.settle()
|
||||
expect(phone.view().review).toBeUndefined()
|
||||
|
||||
// Nothing else happens on this desktop: no catalog event, no phone read, no metadata write.
|
||||
const before = events.length
|
||||
const [key] = getGitHubPRCacheKeyCandidates(repo, 'feature')
|
||||
store.setGitHubCache({
|
||||
...store.getGitHubCache(),
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: grouping reads only number and state.
|
||||
pr: { [key]: { data: { number: 7, state: 'merged' } as PRInfo, fetchedAt: 1 } }
|
||||
})
|
||||
await vi.waitFor(() => expect(events.length).toBeGreaterThan(before))
|
||||
const notice = events.at(-1)
|
||||
if (!notice) {
|
||||
throw new Error('the PR cache save announced nothing')
|
||||
}
|
||||
phone.notice(notice)
|
||||
await phone.settle()
|
||||
const fact = phone.view().review?.[getWorktreeHostIdentity(worktree)]
|
||||
expect(fact).toEqual({ provider: 'github', reviewState: 'merged' })
|
||||
expect(prGroupOfReviewFact(feedReviewFact(fact))).toBe('done')
|
||||
phone.disconnect()
|
||||
})
|
||||
})
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
import type { Repo } from '../../../../shared/repo-types'
|
||||
import { normalizeRuntimePathForComparison } from '../../../../shared/cross-platform-path'
|
||||
import { composeWorktreeId } from '../../../../shared/worktree/id'
|
||||
import type { PullRequestChange } from '../../../github/pull-request-changed-events'
|
||||
import type { PullRequestChange } from '../../../github/pull-requests/refresh/pull-request-changed-events'
|
||||
import { OrcaRuntimeWithGetStatus } from '../../hosts/runtime-status'
|
||||
|
||||
export abstract class RuntimeWorkspaceCatalogEvents extends OrcaRuntimeWithGetStatus {
|
||||
|
||||
Reference in New Issue
Block a user