Repository navigation
fix(tasks): keep repos with a pending remote-identity probe in the picker - #10527
Conversation
…cker Task-repo eligibility filtered on `hasProjectRemoteIdentity`, which is populated by a background `git remote -v` probe. When the probe could not reach git — an SSH-hosted repo whose connection is not up yet, a cold launch — the repo silently vanished from the Tasks picker and stayed hidden for the full 5-minute negative-cache TTL, even after the host came back. GitHub repos were largely shielded because a persisted `upstream` satisfies the identity projection through a different route; GitLab and other providers depend on the probe. Distinguish unknown from settled instead of hiding both: - `probeGitRemoteIdentity` reports `resolved` / `no-remote` (git answered, no usable remote) / `unavailable` (never reached git). - Enrichment persists `gitRemoteIdentity: null` only on `no-remote`, mirroring the existing `upstream: null` "not a fork" marker. An unreachable host leaves the identity undefined. - Persistence keeps the explicit `null` instead of dropping it. - `getTaskEligibleRepos` keeps a repo whose identity is still pending; folders and settled remote-less repos stay filtered out.
📝 WalkthroughWalkthroughThe change introduces structured remote identity probe statuses and adapts legacy detection to them. Enrichment now persists explicit 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0fe75878-5c35-4891-b9cd-157799f99670
📒 Files selected for processing (10)
src/main/persistence.test.tssrc/main/persistence.tssrc/main/repo-git-remote-identity-enrichment.test.tssrc/main/repo-git-remote-identity-enrichment.tssrc/main/repo-git-remote-identity.test.tssrc/main/repo-git-remote-identity.tssrc/renderer/src/components/task-page-default-repo-selection.test.tssrc/renderer/src/components/task-page-default-repo-selection.tssrc/shared/project-host-setup-projection.test.tssrc/shared/project-host-setup-projection.ts
Addresses CodeRabbit review: the unavailable-on-error case only exercised the local git runner. Adds a connected-provider whose exec rejects, and an SSH repo git answered for with no remotes.
CodeRabbit review disposition1. Inline: "Exercise the SSH provider 2. Pre-merge check: "Description check" — ACTIONED. PR body now carries the template sections it was missing (Screenshots, Testing checklist, AI Review Report, Security Audit, Notes). 3. Pre-merge check: "Docstring Coverage 28.57% < 80%" — DECLINED, deliberately, on repo-policy grounds.
Raising coverage to 80% here would mean docstringing functions whose signatures already say everything —
I would rather keep those three load-bearing and leave the mechanical functions bare than dilute them to hit a ratio. |
… gains a remote Three independent reviewers flagged that the candidate filter's `!repo.gitRemoteIdentity` looks like an oversight next to the new null marker. Tightening it to `=== undefined` would silently stop detecting a remote added after the marker landed. Document that the re-probe is deliberate and pin the behavior with a test.
…cker (stablyai#10527) * fix(tasks): keep repos with a pending remote-identity probe in the picker Task-repo eligibility filtered on `hasProjectRemoteIdentity`, which is populated by a background `git remote -v` probe. When the probe could not reach git — an SSH-hosted repo whose connection is not up yet, a cold launch — the repo silently vanished from the Tasks picker and stayed hidden for the full 5-minute negative-cache TTL, even after the host came back. GitHub repos were largely shielded because a persisted `upstream` satisfies the identity projection through a different route; GitLab and other providers depend on the probe. Distinguish unknown from settled instead of hiding both: - `probeGitRemoteIdentity` reports `resolved` / `no-remote` (git answered, no usable remote) / `unavailable` (never reached git). - Enrichment persists `gitRemoteIdentity: null` only on `no-remote`, mirroring the existing `upstream: null` "not a fork" marker. An unreachable host leaves the identity undefined. - Persistence keeps the explicit `null` instead of dropping it. - `getTaskEligibleRepos` keeps a repo whose identity is still pending; folders and settled remote-less repos stay filtered out. * test(tasks): cover the SSH probe exec paths for remote-identity status Addresses CodeRabbit review: the unavailable-on-error case only exercised the local git runner. Adds a connected-provider whose exec rejects, and an SSH repo git answered for with no remotes. * test(tasks): pin that a settled no-remote repo still resolves once it gains a remote Three independent reviewers flagged that the candidate filter's `!repo.gitRemoteIdentity` looks like an oversight next to the new null marker. Tightening it to `=== undefined` would silently stop detecting a remote added after the marker landed. Document that the re-probe is deliberate and pin the behavior with a test.
The bug
getTaskEligibleReposfiltered onisGitRepoKind(repo) && hasProjectRemoteIdentity(repo). That identity comes from a backgroundgit remote -vprobe (detectGitRemoteIdentity, driven byrepo-git-remote-identity-enrichment.ts), and anullresult negative-caches forNO_IDENTITY_RETRY_TTL_MS(5 min).Launch the app before an SSH connection is up, and an SSH-hosted GitLab repo silently disappears from the Tasks picker — with no explanation, and it stays hidden for a full 5 minutes after the connection recovers.
This lands on non-GitHub providers specifically: GitHub repos are largely shielded because a persisted
upstreamsatisfies the identity projection through a different route. GitLab and everything else depend on the probe.It also violates the standing rule against visibility-gating on pending state — a repo whose identity is merely unknown was rendered indistinguishable from one that is genuinely ineligible.
The fix
Make "unknown" distinguishable from "settled", rather than hiding both:
repo-git-remote-identity.tsprobeGitRemoteIdentityreturnsresolved/no-remote(git answered, no usable remote) /unavailable(never reached git: SSH provider absent, git threw).detectGitRemoteIdentitystays as a thin wrapper forrepo-icon-autodetect.repo-git-remote-identity-enrichment.tsgitRemoteIdentity: nullonly onno-remote.unavailableleaves the identity undefined, so an unreachable host never marks a repo ineligible. Redundant no-remote rewrites are skipped so repo-list consumers do not churn.persistence.tssanitizeGitRemoteIdentitypreserves an explicitnull, mirroring the existingupstream: null"not a fork" marker in the same function. Without this the marker is dropped on save/hydrate and nothing is ever settled.project-host-setup-projection.tsisProjectRemoteIdentityPending— true only whilegitRemoteIdentity === undefinedand no other identity resolved.task-page-default-repo-selection.tsDeliberately not "show every repo": folders and repos settled as
no-remotestay filtered out. The negative-cache TTL is untouched — it now only delays identity resolution, not visibility.Note on rollout: existing persisted repos with no remote currently have
gitRemoteIdentityabsent, so they reappear in the picker until the next enrichment pass writes thenullmarker. That is the safe direction (visible while unknown) and self-corrects within one pass.Follow-up (not in this PR — flagged, not dropped)
The 5-minute negative cache is not invalidated when an SSH connection recovers. With this fix that is no longer a visibility bug, but an SSH repo that comes online still waits out a timer it earned while offline before its identity (and therefore its cross-host project grouping) resolves. Wiring cache invalidation to connection-recovery events is a separate concern and a separate change.
Verification
npx vitest run --config config/vitest.config.ts— 7 affected files, 476 tests, all pass; plusrepo-icon-autodetect,task-page-empty-state,task-page-cache-selectors(30 tests).npm run typecheckandnpm run lintboth clean.Every new test was revert-checked — source change backed out, test confirmed failing:
expected [] to deeply equal [ Array(2) ](pending repos vanish),expected [] to deeply equal [ 'git-pending' ],expected [ 'local-orca' ] to deeply equal [ 'local-orca', 'ssh-gitlab-pending' ].expected { …(3) } to be null— thenullmarker is dropped and the stale identity survives the reload.expected "vi.fn()" to be called with arguments: [ 'repo-1', …(1) ].leaves identity unresolved when the probe could not reach the hostfails withexpected "vi.fn()" to not be called at all, but actually been called 1 times. This is the test that pins the SSH case.The partial-identity test passes before and after — it is a guard against regressing the existing incomplete-identity exclusion, not a fix test.
Not runtime-verified: the real SSH-hosted-GitLab-with-connection-down scenario was not reproduced on hardware — this was validated on macOS through unit tests over the probe/enrichment/persistence/renderer seam, not against a live SSH host with a real GitLab remote. The
unavailablepath is covered by mockinggetSshGitProviderto returnundefined(provider not yet connected) and by a rejecting git exec.Screenshots
No visual change. This PR changes which repos pass an eligibility filter; it adds no new UI, no layout, no tokens, and no copy. The user-visible effect is that a repo that used to be absent from the existing Tasks project picker is now present in it, rendered by the unchanged existing picker component.
Testing
npm run lint— cleannpm run typecheck— cleannpm test(affected + adjacent:repo-git-remote-identity,repo-git-remote-identity-enrichment,persistence,project-host-setup-projection,task-page-default-repo-selection,repo-icon-autodetect) — 475 tests, all passnpm run build— covered by theverifyandcrash-survival (packaged build)CI jobs, both greenAI Review Report
Four independent AI reviewers were run over this branch in parallel (correctness/regressions, scope adversary, persistence compatibility, perf/platform/SSH), each reporting separately. None found a blocker. Scope of what they checked and what they found:
Fixes the stated issue.
getTaskEligibleRepos(task-page-default-repo-selection.ts:19) is the only eligibility gate; its single caller isTaskPage.tsx:3144, memoized onrepos. A pending repo now reaches the picker and, once selected, flows through the same unchangedgetTaskProjectPickerGroups/normalizeTaskRepoSelectionpath as any other repo — itsgetProjectIdentityKeyfalls back torepo:${id}, so it forms its own project group until the probe settles and it regroups. No downstream consumer was found that special-cases identity presence.No regression from the new explicit
null. Every read site ofrepo.gitRemoteIdentityinsrc/andmobile/uses optional chaining or a truthiness check, sonullbehaves exactly asundefineddid (SourceControl.tsx:1500-1542,project-host-setup-projection.ts:58-71,repo-icon-autodetect.ts:322-327,mobile/src/tasks/smart-source-paste-intent.ts:63-72,mobile/src/components/NewWorktreeModal.tsx:75). The only=== undefinedcomparison is the newisProjectRemoteIdentityPendingitself.Repo['gitRemoteIdentity']was already declaredGitRemoteIdentity | nullattypes.ts:268before this PR, and there is no zod/JSON-schema validator on the field.Forward/backward compatibility of the persisted marker. An older build reading
gitRemoteIdentity: nullhitsif (!value || typeof value !== 'object') return undefinedin its ownsanitizeGitRemoteIdentity— the key is dropped during hydrate, no crash, and the repo is treated as it always was. Downgrade therefore loses the marker rather than corrupting anything, and the next enrichment pass on a new build re-settles it. This build reading an older profile with the key absent treats it as pending, i.e. visible — the safe direction. The sanitizer change is a 4-line early return that mirrors the pre-existingsanitizeRepoUpstreamnull precedent atpersistence.ts:1306-1308; the surroundingsanitizeRepoUpdatesForPersistencebranch (persistence.ts:1391-1398) and thehydrateRepospread (persistence.ts:4631) already keyed on=== undefined, so no other null began surviving.No perf regression; the redundant-write guard is load-bearing.
enrichMissingRepoGitRemoteIdentitiesruns on therepos:list/projects:list/projectHostSetups:listIPC handlers (ipc/repos.ts:1144,1155,1171), which are hot.isSameUnenrichedRepotests!current.gitRemoteIdentity, which is falsy fornulltoo, so a settled repo remains a probe candidate. Without thegitRemoteIdentity === null && current?.gitRemoteIdentity === nullguard inwriteIdentity, every remote-less repo would re-settle after each TTL expiry, return a non-null repo fromupdateRepo, fireonChanged→notifyReposChanged→ renderer re-list → re-enrich, forever — a periodic disk write and full repo-list churn per repo. The guard is required, not an optimization. The renderer side adds oneisProjectRemoteIdentityPendingcall per repo inside an already-useMemo'd filter.False-
no-remoterisk (the one that would be worse than the bug). Settlingnullon a host that is merely unreachable would hide the repo permanently. Traced to a definitive answer: on the SSH path,SshGitProvider.exec(providers/ssh-git-provider.ts:826) forwards to relaygit.exec, which runsexecFileAsync('git', …)(relay/git-handler.ts:1195→:315,342);execFileAsyncrejects on non-zero exit, and a dropped connection rejects at the multiplexer. Neither can resolve with empty stdout.stdout === ''with a zero exit means the repo genuinely has no remotes. A provider that is not yet registered returnsundefinedfromgetSshGitProviderand is mapped tounavailable, notno-remote.Cross-platform. No platform-conditional code paths, no path-separator or key-modifier assumptions are added or changed.
git remote -vpredates the Git 2.25 baseline.getRepoLocationKeyis unchanged by this PR.Provider neutrality.
isProjectRemoteIdentityPendingis provider-neutral by construction — it delegates tohasProjectRemoteIdentity, which accepts either a provider identity or a generic git remote identity. GitHub repos usually settle earlier via the persistedupstream, which is why they were already shielded from this bug; that asymmetry is the pre-existing cause, not something introduced here. No GitHub-specific naming was used for a generic concept.Folder workspaces.
isGitRepoKindis evaluated first and short-circuits, so nokind: 'folder'workspace can enter through the new pending branch (pinned by theexcludes folders and settled remote-less repos even while others are pendingtest). Enrichment's candidate filter already excludes folders.Scope. The renderer-only alternative was challenged directly and does not work:
hasProjectRemoteIdentityreceives only the repo, and before this change "probe pending" and "no remote" were the same value, so no renderer-side predicate can separate them. Dropping the gate entirely fixes the symptom but permanently pollutes the picker with remote-less local repos, each as its own project group. An in-memory-only settled set would touch the same number of layers, add a second parallel channel, and re-flicker on every cold launch. Each of the five source files carries a change that is necessary and minimal (9, 34, 28, 12 and 10 changed lines);detectGitRemoteIdentitywas kept as a 6-line wrapper specifically sorepo-icon-autodetectdid not have to change. Nomax-linesdisable is added anywhere in the diff.What was NOT verified. Everything above is static analysis plus unit tests on macOS. The real scenario — an SSH-hosted GitLab repo with the connection down at launch — was not reproduced on hardware. The
unavailablepath is exercised by mocking an absent provider and by rejectingexecon both a connected provider and the local runner.Security Audit
No new attack surface. The change introduces no new command execution, no new user-controlled input, and no new IPC method —
git remote -vwas already being run with a fixed argv array on the same paths and hosts, at the same frequency, through the sameexecFile/relay dispatch. Argument handling is unchanged, so no shell interpolation or argv-injection vector is added. The one behavioral delta is that a probe error is now classified asunavailableinstead of being swallowed asnull, which is strictly more conservative: it declines to record a state it could not confirm. The persisted field gains one new value (null) that is already type-declared and is sanitized on both the write and hydrate paths, so a hostile or corrupted profile cannot smuggle an unexpected shape through — malformed objects still normalize to "absent". No secrets, auth, or credential handling is touched.Notes
gitRemoteIdentityabsent, so they reappear in the picker until the next enrichment pass writes thenullmarker. That is the safe direction (visible while unknown) and resolves within one pass.unavailablerather than settling, so it stays visible in the picker instead of silently disappearing. This is a deliberate consequence of the same "unknown is not ineligible" rule and is the safer of the two behaviors, but it is a behavior change worth knowing about.repo:<id>group keys, so the picker briefly shows two rows for one project and auto-selects both, then collapses to one group when the probes land. This is inherent to "show it while unknown" — a location-derived key would not merge them either, since the two checkouts have different paths, and excluding pending repos from the default selection would partly undo the fix (the repo would reappear but the user's tasks still would not). Accepted, and encoded inkeeps GitHub grouping intact while a pending-identity repo joins as its own project.main, none made worse here):probeGitRemoteIdentitybranches onconnectionIdalone, so aruntime:<envId>repo takes the local git branch and could resolve the wrong host's repo if the path happens to exist locally; the local probe passes notimeout, so a git wedged on a stale network mount never clearsinFlightProbesByLocationand stalls the serial sweep;areReposEqualcompares object-valued fields by reference against freshly-constructed hydrate output, so it never reports equal. Worth separate changes, not this one.repo-icon-autodetect.ts) still does not persist the marker the way its siblingupstream: nulldoes. Making it do so naively would be a reintroduction of this bug — that call site uses the collapsingdetectGitRemoteIdentitywrapper, so a repo added while its SSH host is down would be permanently stamped no-remote. It would have to move toprobeGitRemoteIdentityand write only onno-remote.