Repository navigation
fix(ssh): reconnecting a stopped managed host keeps the server's project groups #29962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,8 @@ import type { SshTargetOrcadClaims } from './ssh-target-orcad-claims' | |
| export type OrcadServerRepository = Pick<Repo, 'id' | 'path'> & { | ||
| connectionId?: string | null | ||
| executionHostId?: string | null | ||
| /** Proves the server holds this group: its record, not this desktop's copy, wins on relink. */ | ||
| projectGroupId?: string | null | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -78,16 +80,56 @@ async function serverHeldRepositoriesToLink( | |
| return state.state === 'committed' ? held.otherId : [...held.otherId, ...held.sameId] | ||
| } | ||
|
|
||
| /** The source the cutover was cut from: the real store less any project it linked. */ | ||
| /** | ||
| * Source groups the server's projects sit in, and their ancestors, renamed there perhaps since: | ||
| * re-importing this desktop's retained copy would conflict with the server's. An ancestor the | ||
| * server may lack still moves while a moving row needs it. | ||
| */ | ||
| function serverHeldProjectGroups( | ||
| payload: OrcadMigrationSourceCutover['manifest']['payload'], | ||
| linkedRepositoryIds: ReadonlySet<string>, | ||
| server: readonly OrcadServerRepository[] | ||
| ): string[] { | ||
| const parentById = new Map(payload.projectGroups.map((group) => [group.id, group.parentGroupId])) | ||
| const held = new Set(server.flatMap((repo) => (repo.projectGroupId ? [repo.projectGroupId] : []))) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift 🔎 Supported by static analysis🏁 Script executed: set -eu
printf '%s\n' '--- changed file ---'
nl -ba src/main/ssh/orcad-migration-repository-link.ts | sed -n '1,240p'
printf '%s\n' '--- relevant symbols ---'
rg -n -F --glob '*.ts' -e 'projectGroupId' -e 'repo.list' -e 'projectGroup' src/main/ssh src/main/persistence/migrating-orcad-catalog || test "$?" -eq 1
printf '%s\n' '--- base to head diff ---'
git diff --stat 432c6d0735acb4752eb18aabed0a61455cad9ba8 0a87349964a181266caea786b6fb54f2d951d89e -- src/main/ssh/orcad-migration-repository-link.ts
git diff --unified=25 432c6d0735acb4752eb18aabed0a61455cad9ba 0a87349964a181266caea786b6fb54f2d951d89e -- src/main/ssh/orcad-migration-repository-link.ts
printf '%s\n' '--- catalog files ---'
rg --files src/main/ssh src/main/persistence/migrating-orcad-catalog | sort | sed -n '1,240p'Repository: stablyai/orca Length of output: 41831 🏁 Script executed: set -eu
printf '%s\n' '--- catalog client contract ---'
nl -ba src/main/ssh/orcad-migration-catalog-client.ts | sed -n '130,205p'
printf '%s\n' '--- source catalog ---'
nl -ba src/main/persistence/migrating-orcad-catalog/orcad-source-catalog.ts
printf '%s\n' '--- group-related source declarations ---'
rg -n -F --glob '*.ts' --glob '!*.test.ts' -e 'listProjectGroups' -e 'getProjectGroups' -e 'projectGroups' -e 'project-group' -e 'projectGroup' src/main src/shared | sed -n '1,320p'
printf '%s\n' '--- all repo.list references ---'
rg -n -F --glob '*.ts' -e 'repo.list' -e 'repoList' src | sed -n '1,240p'Repository: stablyai/orca Length of output: 41334 🏁 Script executed: set -eu
printf '%s\n' '--- project-group RPC and handlers ---'
rg --files src/main/runtime/rpc/methods src/main/ipc/repos | rg 'project.group|project-group|repo\.ts|folder-workspace'
for f in src/main/runtime/rpc/methods/project-group.ts src/main/ipc/repos/project-group-handlers.ts src/main/runtime/rpc/methods/repo.ts; do
if test -f "$f"; then
printf '\n--- %s ---\n' "$f"
nl -ba "$f" | sed -n '1,260p'
fi
done
printf '%s\n' '--- project-group and move persistence symbols ---'
rg -n -F --glob '*.ts' --glob '!*.test.ts' -e 'moveProjectToGroup' -e 'deleteProjectGroup' -e 'deleteProject' -e 'projectGroup.list' -e 'projectGroup.create' -e 'projectGroup.update' src/main src/shared | sed -n '1,280p'
printf '%s\n' '--- project group types ---'
nl -ba src/shared/project-group-types.ts | sed -n '1,180p'Repository: stablyai/orca Length of output: 22418 🏁 Script executed: set -eu
printf '%s\n' '--- project-group persistence operations ---'
nl -ba src/main/persistence/tracking-repos/project-group-operations.ts | sed -n '1,190p'
printf '%s\n' '--- runtime project-group controller ---'
nl -ba src/main/runtime/runtime-project-group-controller.ts | sed -n '1,210p'
printf '%s\n' '--- runtime visibility implementation ---'
rg -n -F --glob '*.ts' --glob '!*.test.ts' -e 'listVisibleProjectGroups' -e 'visibleProjectGroups' src/main | sed -n '1,160p'Repository: stablyai/orca Length of output: 15151 🏁 Script executed: set -eu
printf '%s\n' '--- retained-source visibility ---'
nl -ba src/main/ssh/orcad-retained-source.ts | sed -n '90,145p'
printf '%s\n' '--- runtime visible catalog ---'
nl -ba src/main/runtime/runtime-visible-catalog.ts | sed -n '1,100p'
printf '%s\n' '--- moveProjectToGroup implementation ---'
nl -ba src/main/persistence/restoring-sessions/folder-workspace-operations.ts | sed -n '235,285p'
printf '%s\n' '--- projectGroup.list client consumers ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'projectGroup.list' src/main src/renderer src/shared | sed -n '1,180p'Repository: stablyai/orca Length of output: 11602 🏁 Script executed: set -eu
printf '%s\n' '--- destination group import and duplicate handling ---'
nl -ba src/main/persistence/migrating-orcad-catalog/orcad-catalog-records.ts | sed -n '1,135p'
nl -ba src/main/persistence/migrating-orcad-catalog/orcad-catalog-records.ts | sed -n '145,190p'
printf '%s\n' '--- migration manifest export filtering ---'
nl -ba src/main/ssh/orcad-migration-manifest-export.ts | sed -n '35,78p'Repository: stablyai/orca Length of output: 9450 Include standalone server groups when relinking.
|
||
| const withAncestors = (ids: (string | null | undefined)[], stopAt: ReadonlySet<string>) => { | ||
| const out = new Set<string>() | ||
| while (ids.length > 0) { | ||
| const id = ids.pop() | ||
| if (id && !out.has(id) && !stopAt.has(id) && parentById.has(id)) { | ||
| out.add(id) | ||
| ids.push(parentById.get(id)) | ||
| } | ||
| } | ||
| return out | ||
| } | ||
| const candidates = withAncestors([...held], new Set()) | ||
| const needed = withAncestors( | ||
| [ | ||
| ...payload.repositories | ||
| .filter((repo) => !linkedRepositoryIds.has(repo.id)) | ||
| .map((repo) => repo.projectGroupId), | ||
| ...payload.folderWorkspaces.map((workspace) => workspace.projectGroupId), | ||
| ...payload.projectGroups | ||
| .filter((group) => !candidates.has(group.id)) | ||
| .map((group) => group.parentGroupId) | ||
| ], | ||
| held | ||
| ) | ||
| return [...candidates].filter((id) => !needed.has(id)) | ||
| } | ||
|
|
||
| /** The source the cutover was cut from: the real store less any project or group it linked. */ | ||
| export function linkedOrcadMigrationSource( | ||
| store: Store, | ||
| cutover: Pick< | ||
| OrcadMigrationSourceCutover, | ||
| 'sshTargetId' | 'destinationEnvironmentId' | 'linkedRepositoryIds' | ||
| 'sshTargetId' | 'destinationEnvironmentId' | 'linkedRepositoryIds' | 'linkedProjectGroupIds' | ||
| > | ||
| ): (() => OrcadDeltaSourceStore) | undefined { | ||
| const linked = cutover.linkedRepositoryIds ?? [] | ||
| if (linked.length === 0) { | ||
| const linkedGroups = cutover.linkedProjectGroupIds ?? [] | ||
| if (linked.length === 0 && linkedGroups.length === 0) { | ||
| return undefined | ||
| } | ||
| return () => { | ||
|
|
@@ -103,7 +145,8 @@ export function linkedOrcadMigrationSource( | |
| folderWorkspaceIds: new Set(), | ||
| projectGroupIds: new Set() | ||
| }, | ||
| cutover.destinationEnvironmentId | ||
| cutover.destinationEnvironmentId, | ||
| new Set(linkedGroups) | ||
| ) | ||
| } | ||
| } | ||
|
|
@@ -190,11 +233,8 @@ export async function linkServerHeldRepositories(args: { | |
| if (cutover.phase !== 'source-fenced' && cutover.phase !== 'destination-staged') { | ||
| return cutover | ||
| } | ||
| const linked = await serverHeldRepositoriesToLink( | ||
| cutover, | ||
| args.destination, | ||
| await args.serverRepositories() | ||
| ) | ||
| const serverRepositories = await args.serverRepositories() | ||
| const linked = await serverHeldRepositoriesToLink(cutover, args.destination, serverRepositories) | ||
| if (linked.length === 0) { | ||
| return cutover | ||
| } | ||
|
|
@@ -203,7 +243,21 @@ export async function linkServerHeldRepositories(args: { | |
| // The relinked manifest is cut from the source as fenced, so it must still be that source. | ||
| source.verifyFence(cutover) | ||
| const linkedRepositoryIds = [...new Set([...(cutover.linkedRepositoryIds ?? []), ...linked])] | ||
| const view = linkedOrcadMigrationSource(args.store, { ...cutover, linkedRepositoryIds })?.() | ||
| const linkedProjectGroupIds = [ | ||
| ...new Set([ | ||
| ...(cutover.linkedProjectGroupIds ?? []), | ||
| ...serverHeldProjectGroups( | ||
| cutover.manifest.payload, | ||
| new Set(linkedRepositoryIds), | ||
| serverRepositories | ||
| ) | ||
| ]) | ||
| ] | ||
| const linkedIds = { | ||
| linkedRepositoryIds, | ||
| ...(linkedProjectGroupIds.length > 0 ? { linkedProjectGroupIds } : {}) | ||
| } | ||
| const view = linkedOrcadMigrationSource(args.store, { ...cutover, ...linkedIds })?.() | ||
| const target = args.store.getSshTarget(cutover.sshTargetId) | ||
| if (!view || !target) { | ||
| throw new Error('orcad_migration_source_fence_lost') | ||
|
|
@@ -219,7 +273,7 @@ export async function linkServerHeldRepositories(args: { | |
| updatedAt: (args.now ?? (() => new Date()))().toISOString(), | ||
| manifestSha256: manifest.manifestSha256, | ||
| manifest, | ||
| linkedRepositoryIds, | ||
| ...linkedIds, | ||
| // The retained rows still hold the linked projects, so the baseline is the whole fenced source. | ||
| sourceBaselineFingerprint: | ||
| cutover.sourceBaselineFingerprint ?? orcadCatalogFingerprint(cutover.manifest.payload) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Keep a server-renamed group out of later delta exports.
If a later project is assigned to a linked group renamed on the server, treating that group only as a moved group lets the delta source include its stale desktop row when the project needs it.
orcadSourceStoreWithoutreceives noserverGroupIdshere, so the manifest export does not remove the row. The delta can then conflict with the server group and block the project move. Preserve the server record when it still exists, and handle a deleted server group separately.