Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 6 additions & 21 deletions config/focus-setting-read-baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@
2 src/renderer/src/components/sidebar/WorktreeList.tsx
1 src/renderer/src/components/sidebar/WorktreeRowOpenInSubMenu.tsx
1 src/renderer/src/components/sidebar/WorktreeVisibilityDialog.tsx
1 src/renderer/src/components/sidebar/add-repo-runtime-owner.ts
2 src/renderer/src/components/sidebar/delete-worktree-flow.ts
1 src/renderer/src/components/sidebar/linear-agent-skill-runtime.ts
2 src/renderer/src/components/sidebar/rendered-sidebar-worktree-order.ts
Expand All @@ -234,8 +233,6 @@
1 src/renderer/src/components/sidebar/use-workspace-reference-details.ts
1 src/renderer/src/components/sidebar/use-worktree-card-controller.ts
1 src/renderer/src/components/sidebar/use-worktree-card-review-details.ts
1 src/renderer/src/components/sidebar/useAddRepoCloneFlow.ts
1 src/renderer/src/components/sidebar/useCreateRepo.ts
2 src/renderer/src/components/sidebar/useSidebarProjectDrop.ts
1 src/renderer/src/components/sidebar/visible-worktree-options-from-state.ts
2 src/renderer/src/components/sidebar/visible-worktrees.ts
Expand All @@ -246,10 +243,8 @@
1 src/renderer/src/components/sidebar/worktree-card-secondary-rows.tsx
1 src/renderer/src/components/sidebar/worktree-filter-visibility.ts
2 src/renderer/src/components/sidebar/worktree-list/listing/use-filters.ts
2 src/renderer/src/components/sidebar/worktree-list/listing/use-folder-path-statuses.ts
1 src/renderer/src/components/sidebar/worktree-list/listing/use-section-rows.ts
1 src/renderer/src/components/sidebar/worktree-list/rows/ProjectGroupDialogs.tsx
1 src/renderer/src/components/sidebar/worktree-list/viewport/VirtualizedWorktreeViewport.tsx
1 src/renderer/src/components/sidebar/worktree-visibility-host-target.ts
1 src/renderer/src/components/skills/SkillsPage.tsx
7 src/renderer/src/components/status-bar/ClaudeSwitcherMenu.tsx
Expand Down Expand Up @@ -484,29 +479,20 @@
2 src/renderer/src/runtime/web-session-tabs-sync/global-session-subscription.ts
1 src/renderer/src/runtime/web-session-tabs-sync/tracking-decisions.ts
3 src/renderer/src/runtime/web-session-tabs-sync/use-web-session-tabs-sync.ts
2 src/renderer/src/store/folder-workspaces/folder-path-status-actions.ts
2 src/renderer/src/store/folder-workspaces/folder-workspace-catalog-actions.ts
6 src/renderer/src/store/folder-workspaces/folder-workspace-mutations.ts
1 src/renderer/src/store/folder-workspaces/folder-workspace-routing.ts
1 src/renderer/src/store/folder-workspaces/folder-workspace-mutations.ts
1 src/renderer/src/store/github/repository-routing.ts
2 src/renderer/src/store/github/visible-hosted-review-refresh-targets.ts
2 src/renderer/src/store/github/work-item-aggregate-actions.ts
3 src/renderer/src/store/github/work-item-fetch-actions.ts
2 src/renderer/src/store/github/work-item-routing.ts
9 src/renderer/src/store/index.ts
6 src/renderer/src/store/project-groups/nested-repository-operations.ts
2 src/renderer/src/store/project-groups/project-group-catalog-actions.ts
10 src/renderer/src/store/project-groups/project-group-mutations.ts
1 src/renderer/src/store/projects/project-host-routing.ts
1 src/renderer/src/store/projects/project-update.ts
2 src/renderer/src/store/repos/all-host-repo-catalog-actions.ts
3 src/renderer/src/store/project-groups/project-group-mutations.ts
1 src/renderer/src/store/repos/all-host-repo-catalog-actions.ts
1 src/renderer/src/store/repos/converted-ssh-browser-pages.ts
2 src/renderer/src/store/repos/owner-routing.ts
2 src/renderer/src/store/repos/repo-add-actions.ts
2 src/renderer/src/store/repos/repo-catalog-actions.ts
2 src/renderer/src/store/repos/repo-removal.ts
3 src/renderer/src/store/repos/repo-update.ts
2 src/renderer/src/store/repos/runtime-repo-catalog-actions.ts
1 src/renderer/src/store/repos/repo-update.ts
1 src/renderer/src/store/repos/runtime-repo-catalog-actions.ts
2 src/renderer/src/store/repos/safe-auto-fork-sync.ts
1 src/renderer/src/store/slices/browser-slice-test-harness.ts
1 src/renderer/src/store/slices/browser/browser-close-actions.ts
Expand Down Expand Up @@ -556,10 +542,9 @@
9 src/renderer/src/store/slices/linear/linear-slice-status-actions.ts
6 src/renderer/src/store/slices/linear/linear-team-actions.ts
2 src/renderer/src/store/slices/preflight.ts
1 src/renderer/src/store/slices/project-group-owner-routing.ts
1 src/renderer/src/store/slices/repo-host-identity.ts
1 src/renderer/src/store/slices/repo-reorder-host-split.ts
10 src/renderer/src/store/slices/repos.ts
4 src/renderer/src/store/slices/repos.ts
1 src/renderer/src/store/slices/runtime-status.ts
2 src/renderer/src/store/slices/settings-owner-hydration-publication.ts
5 src/renderer/src/store/slices/settings.ts
Expand Down
15 changes: 0 additions & 15 deletions config/owner-routing-baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
1 src/renderer/src/components/settings/RepositoryGitHubAccountSection.tsx
1 src/renderer/src/components/settings/RepositoryIconPicker.tsx
1 src/renderer/src/components/setup-guide/setup-guide-progress-readiness.ts
1 src/renderer/src/components/sidebar/add-repo-runtime-owner.ts
1 src/renderer/src/hooks/composer-state/provider-runtime-sync.ts
1 src/renderer/src/hooks/composer-state/quick-creation-execution.ts
1 src/renderer/src/lib/github-pr-start-point.ts
Expand All @@ -22,20 +21,6 @@
9 src/renderer/src/runtime/runtime-git-working-tree-client.ts
3 src/renderer/src/runtime/runtime-hooks-client.ts
3 src/renderer/src/runtime/runtime-repo-client.ts
1 src/renderer/src/store/folder-workspaces/folder-path-status-actions.ts
2 src/renderer/src/store/folder-workspaces/folder-workspace-catalog-actions.ts
3 src/renderer/src/store/folder-workspaces/folder-workspace-mutations.ts
1 src/renderer/src/store/folder-workspaces/folder-workspace-routing.ts
6 src/renderer/src/store/project-groups/nested-repository-operations.ts
2 src/renderer/src/store/project-groups/project-group-catalog-actions.ts
4 src/renderer/src/store/project-groups/project-group-mutations.ts
1 src/renderer/src/store/projects/project-host-routing.ts
1 src/renderer/src/store/repos/all-host-repo-catalog-actions.ts
2 src/renderer/src/store/repos/repo-add-actions.ts
2 src/renderer/src/store/repos/repo-catalog-actions.ts
1 src/renderer/src/store/repos/repo-removal.ts
1 src/renderer/src/store/repos/repo-update.ts
1 src/renderer/src/store/repos/runtime-repo-catalog-actions.ts
1 src/renderer/src/store/slices/diff-comment-persistence.ts
1 src/renderer/src/store/slices/preflight.ts
1 src/renderer/src/store/slices/worktree-visibility-owner-settings.ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ export function renderProjectSettingsSections(context: SettingsRenderContext): R
wslAvailable={terminal.windowsTerminalCapabilities.wslAvailable}
wslDistros={terminal.windowsTerminalCapabilities.wslDistros}
wslCapabilitiesLoading={terminal.windowsTerminalCapabilities.isLoading}
updateProject={model.updateProject}
updateProject={(projectId, updates) =>
model.updateProject(projectId, updates, getRepoExecutionHostId(repo))
}
/>
) : null}
</SettingsSection>
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/src/components/sidebar/AddRepoSteps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export function useRemoteRepo(
onGitRepoReady?: (repoId: string, executionHostId?: ExecutionHostId) => void | Promise<void>,
scanNestedRepos?: (
path: string,
connectionId?: string,
controls?: {
connectionId: string | undefined,
controls: {
scanId?: string
onProgress?: (scan: NestedRepoScanResult) => void
runtimeEnvironmentId?: string | null
runtimeEnvironmentId: string | null
}
) => Promise<NestedRepoScanResult | null>,
showNestedRepoReview?: (
Expand Down
14 changes: 7 additions & 7 deletions src/renderer/src/components/sidebar/ProjectAddedDialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const mocks = vi.hoisted(() => ({
closeModal: vi.fn(),
repos: [] as Repo[],
worktreesByRepo: {} as Record<string, unknown[]>,
fetchRepos: vi.fn(),
fetchReposForAllHosts: vi.fn(),
fetchWorktrees: vi.fn(),
setHideDefaultBranchWorkspace: vi.fn()
},
Expand Down Expand Up @@ -68,7 +68,7 @@ describe('ProjectAddedDialog', () => {
mocks.state.modalData = { repoId: 'repo-1' }
mocks.state.repos = [makeRepo()]
mocks.state.worktreesByRepo = {}
mocks.state.fetchRepos.mockResolvedValue(undefined)
mocks.state.fetchReposForAllHosts.mockResolvedValue(undefined)
mocks.state.fetchWorktrees.mockResolvedValue(true)
})

Expand Down Expand Up @@ -166,29 +166,29 @@ describe('ProjectAddedDialog', () => {

it('refreshes repos before closing a stale repo id', async () => {
mocks.state.repos = []
mocks.state.fetchRepos.mockImplementation(async () => {
mocks.state.fetchReposForAllHosts.mockImplementation(async () => {
mocks.state.repos = []
})
const { default: ProjectAddedDialog } = await import('./ProjectAddedDialog')

renderToStaticMarkup(<ProjectAddedDialog />)
await flushPromises()

expect(mocks.state.fetchRepos).toHaveBeenCalledTimes(1)
expect(mocks.state.fetchReposForAllHosts).toHaveBeenCalledTimes(1)
expect(mocks.state.closeModal).toHaveBeenCalledTimes(1)
})

it('waits for repo hydration and does not close when fetchRepos supplies the repo', async () => {
it('waits for repo hydration and does not close when fetchReposForAllHosts supplies the repo', async () => {
mocks.state.repos = []
mocks.state.fetchRepos.mockImplementation(async () => {
mocks.state.fetchReposForAllHosts.mockImplementation(async () => {
mocks.state.repos = [makeRepo()]
})
const { default: ProjectAddedDialog } = await import('./ProjectAddedDialog')

renderToStaticMarkup(<ProjectAddedDialog />)
await flushPromises()

expect(mocks.state.fetchRepos).toHaveBeenCalledTimes(1)
expect(mocks.state.fetchReposForAllHosts).toHaveBeenCalledTimes(1)
expect(mocks.state.closeModal).not.toHaveBeenCalled()
expect(mocks.finishProjectAddWithDefaultCheckout).not.toHaveBeenCalled()
})
Expand Down
7 changes: 4 additions & 3 deletions src/renderer/src/components/sidebar/ProjectAddedDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function ProjectAddedDialog(): null {
const modalData = useAppStore((s) => s.modalData as ProjectAddedModalData)
const closeModal = useAppStore((s) => s.closeModal)
const repos = useAppStore((s) => s.repos)
const fetchRepos = useAppStore((s) => s.fetchRepos)
const fetchReposForAllHosts = useAppStore((s) => s.fetchReposForAllHosts)
const fetchWorktrees = useAppStore((s) => s.fetchWorktrees)
const setHideDefaultBranchWorkspace = useAppStore((s) => s.setHideDefaultBranchWorkspace)
const handoffRunRef = useRef(0)
Expand Down Expand Up @@ -47,7 +47,8 @@ export default function ProjectAddedDialog(): null {
pendingRepoHydrationRef.current = repoId
let cancelled = false
void (async () => {
await fetchRepos()
// Why: no row yet names the new project's host, so look on every host.
await fetchReposForAllHosts()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Do not close the dialog after a superseded catalog load.

If another all-host load supersedes this call before remote catalogs are fetched, fetchReposForAllHosts() returns early. The subsequent lookup can miss a remote repo that the newer load is still fetching, so the dialog closes before its project handoff. Wait for an authoritative hydration result before treating the repo as absent.

if (cancelled) {
return
}
Expand Down Expand Up @@ -112,7 +113,7 @@ export default function ProjectAddedDialog(): null {
}, [
activeModal,
closeModal,
fetchRepos,
fetchReposForAllHosts,
fetchWorktrees,
repo,
repoId,
Expand Down
14 changes: 7 additions & 7 deletions src/renderer/src/components/sidebar/add-repo-runtime-owner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import {
toSshExecutionHostId,
type ExecutionHostId
} from '../../../../shared/execution-host'
import { getActiveRuntimeTarget, type RuntimeClientTarget } from '@/runtime/runtime-rpc-client'
import {
runtimeTargetForOwnerEnvironment,
type RuntimeClientTarget
} from '@/runtime/runtime-client-target'

export type CapturedRuntimeOwner = string | null | undefined

Expand Down Expand Up @@ -35,12 +38,9 @@ export function worktreeRefreshOptions(
}
}

/** The host the Add Project dialog picked; no picked server means this app. */
export function resolveAddRepoRuntimeTarget(
runtimeEnvironmentId: string | null | undefined,
settings: Parameters<typeof getActiveRuntimeTarget>[0]
runtimeEnvironmentId: string | null | undefined
): RuntimeClientTarget {
const environmentId = runtimeEnvironmentId?.trim()
return environmentId
? { kind: 'environment', environmentId }
: getActiveRuntimeTarget({ ...settings, activeRuntimeEnvironmentId: null })
return runtimeTargetForOwnerEnvironment(runtimeEnvironmentId ?? null)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let root: Root | null = null
let container: HTMLDivElement | null = null

function HookProbe(): null {
const result = useFolderWorkspaceComposerPathStatus(projectGroup, true)
const result = useFolderWorkspaceComposerPathStatus(projectGroup, true, null)
;(
globalThis as { __folderWorkspaceComposerPathStatusResult?: typeof result }
).__folderWorkspaceComposerPathStatusResult = result
Expand All @@ -53,7 +53,9 @@ describe('useFolderWorkspaceComposerPathStatus', () => {
vi.useFakeTimers()
vi.setSystemTime(20_000)
const request = { scope: 'project-group' as const, projectGroupId: projectGroup.id }
const cacheKey = useAppStore.getState().getFolderWorkspacePathStatusCacheKey(request)
const cacheKey = useAppStore
.getState()
.getFolderWorkspacePathStatusCacheKey(request, { runtimeEnvironmentId: null })
const fetchFolderWorkspacePathStatus = vi.fn().mockResolvedValue(null)
useAppStore.setState({
projectGroups: [projectGroup],
Expand Down Expand Up @@ -112,7 +114,10 @@ describe('useFolderWorkspaceComposerPathStatus', () => {
}
).__folderWorkspaceComposerPathStatusResult?.pathStatusProjectError
).toContain('/workspace/platform')
expect(fetchFolderWorkspacePathStatus).toHaveBeenCalledWith(request, { force: true })
expect(fetchFolderWorkspacePathStatus).toHaveBeenCalledWith(request, {
force: true,
runtimeEnvironmentId: null
})
})

it('unblocks creation when the first path status check settles without cache', async () => {
Expand Down Expand Up @@ -151,14 +156,19 @@ describe('useFolderWorkspaceComposerPathStatus', () => {
}
).__folderWorkspaceComposerPathStatusResult?.pathStatusBlocksCreate
).toBe(false)
expect(fetchFolderWorkspacePathStatus).toHaveBeenCalledWith(request, { force: true })
expect(fetchFolderWorkspacePathStatus).toHaveBeenCalledWith(request, {
force: true,
runtimeEnvironmentId: null
})
})

it('does not block creation for an unavailable path status', () => {
vi.useFakeTimers()
vi.setSystemTime(20_000)
const request = { scope: 'project-group' as const, projectGroupId: projectGroup.id }
const cacheKey = useAppStore.getState().getFolderWorkspacePathStatusCacheKey(request)
const cacheKey = useAppStore
.getState()
.getFolderWorkspacePathStatusCacheKey(request, { runtimeEnvironmentId: null })
useAppStore.setState({
projectGroups: [projectGroup],
fetchFolderWorkspacePathStatus: vi.fn().mockResolvedValue(null),
Expand Down Expand Up @@ -195,7 +205,9 @@ describe('useFolderWorkspaceComposerPathStatus', () => {
vi.useFakeTimers()
vi.setSystemTime(20_000)
const request = { scope: 'project-group' as const, projectGroupId: projectGroup.id }
const cacheKey = useAppStore.getState().getFolderWorkspacePathStatusCacheKey(request)
const cacheKey = useAppStore
.getState()
.getFolderWorkspacePathStatusCacheKey(request, { runtimeEnvironmentId: null })
useAppStore.setState({
projectGroups: [projectGroup],
fetchFolderWorkspacePathStatus: vi.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { ProjectGroup } from '../../../../shared/project-group-types'
export function useFolderWorkspaceComposerPathStatus(
projectGroup: ProjectGroup | null,
open: boolean,
runtimeEnvironmentId?: string | null
runtimeEnvironmentId: string | null
): {
pathStatusBlocksCreate: boolean
pathStatusProjectError: string | null
Expand Down Expand Up @@ -48,10 +48,7 @@ export function useFolderWorkspaceComposerPathStatus(
const [completedPathStatusRefreshKeys, setCompletedPathStatusRefreshKeys] = useState<
ReadonlySet<string>
>(() => new Set())
const pathStatusRouteOptions = useMemo(
() => ({ runtimeEnvironmentId: runtimeEnvironmentId ?? null }),
[runtimeEnvironmentId]
)
const pathStatusRouteOptions = useMemo(() => ({ runtimeEnvironmentId }), [runtimeEnvironmentId])
const pathStatusCacheKey = pathStatusRequest
? getFolderWorkspacePathStatusCacheKey(pathStatusRequest, pathStatusRouteOptions)
: null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useCallback } from 'react'
import type { useAppStore } from '@/store'
import type { Repo } from '../../../../shared/repo-types'
import { getRepoExecutionHostId } from '../../../../shared/execution-host'
import type { WorkspaceStatusDefinition, Worktree } from '../../../../shared/worktree/types'
import {
createWorktreeContextMenuDeleteIntent,
Expand Down Expand Up @@ -74,9 +75,10 @@ export function useWorktreeContextMenuCommands(args: {
if (!args.repo) {
return
}
const group = await args.createProjectGroup(name)
const hostId = getRepoExecutionHostId(args.repo)
const group = await args.createProjectGroup(name, hostId)
if (group) {
await args.moveProjectToGroup(args.repo.id, group.id)
await args.moveProjectToGroup(args.repo.id, group.id, undefined, hostId)
}
},
[args]
Expand All @@ -86,13 +88,18 @@ export function useWorktreeContextMenuCommands(args: {
if (!args.repo || args.repo.projectGroupId === groupId) {
return
}
void args.moveProjectToGroup(args.repo.id, groupId)
void args.moveProjectToGroup(
args.repo.id,
groupId,
undefined,
getRepoExecutionHostId(args.repo)
)
},
[args]
)
const handleRemoveProjectFromGroup = useCallback(() => {
if (args.repo) {
void args.moveProjectToGroup(args.repo.id, null)
void args.moveProjectToGroup(args.repo.id, null, undefined, getRepoExecutionHostId(args.repo))
}
}, [args])
const handleAssignWorkspaceStatus = useCallback(
Expand Down
6 changes: 1 addition & 5 deletions src/renderer/src/components/sidebar/useAddRepoCloneFlow.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useCallback, useEffect, useRef, useState, type Dispatch, type SetStateAction } from 'react'
import { toast } from 'sonner'
import { useAppStore } from '@/store'
import { callRuntimeRpc } from '@/runtime/runtime-rpc-client'
import type { AddRepoExistingWorkspaceSource } from '../../../../shared/telemetry-events'
import type { Repo } from '../../../../shared/repo-types'
Expand Down Expand Up @@ -132,10 +131,7 @@ export function useAddRepoCloneFlow({
setCloneError(null)
setCloneProgress(null)
try {
const target = resolveAddRepoRuntimeTarget(
activeRuntimeEnvironmentId,
useAppStore.getState().settings
)
const target = resolveAddRepoRuntimeTarget(activeRuntimeEnvironmentId)
const repo = sshTargetId?.trim()
? await window.api.repos.cloneRemote({
connectionId: sshTargetId.trim(),
Expand Down
Loading
Loading