Skip to content

fix(tasks): keep repos with a pending remote-identity probe in the picker - #10527

Merged
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/p2-task-repo-eligibility
Jul 25, 2026
Merged

brennanb2025 merged 3 commits into
mainfrom
brennanb2025/p2-task-repo-eligibility

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

The bug

getTaskEligibleRepos filtered on isGitRepoKind(repo) && hasProjectRemoteIdentity(repo). That identity comes from a background git remote -v probe (detectGitRemoteIdentity, driven by repo-git-remote-identity-enrichment.ts), and a null result negative-caches for NO_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 upstream satisfies 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:

layer change
repo-git-remote-identity.ts probeGitRemoteIdentity returns resolved / no-remote (git answered, no usable remote) / unavailable (never reached git: SSH provider absent, git threw). detectGitRemoteIdentity stays as a thin wrapper for repo-icon-autodetect.
repo-git-remote-identity-enrichment.ts Persist gitRemoteIdentity: null only on no-remote. unavailable leaves 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.ts sanitizeGitRemoteIdentity preserves an explicit null, mirroring the existing upstream: 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.ts New provider-neutral isProjectRemoteIdentityPending — true only while gitRemoteIdentity === undefined and no other identity resolved.
task-page-default-repo-selection.ts Eligible = git kind and (identity resolved or identity pending).

Deliberately not "show every repo": folders and repos settled as no-remote stay 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 gitRemoteIdentity absent, so they reappear in the picker until the next enrichment pass writes the null marker. 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; plus repo-icon-autodetect, task-page-empty-state, task-page-cache-selectors (30 tests). npm run typecheck and npm run lint both clean.

Every new test was revert-checked — source change backed out, test confirmed failing:

  • Revert the renderer gate → 3 fail: 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' ].
  • Revert the persistence sanitizer → expected { …(3) } to be null — the null marker is dropped and the stale identity survives the reload.
  • Revert the enrichment settle-write → expected "vi.fn()" to be called with arguments: [ 'repo-1', …(1) ].
  • Adversarial variant (settle on any failed probe — the naive fix) → leaves identity unresolved when the probe could not reach the host fails with expected "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 unavailable path is covered by mocking getSshGitProvider to return undefined (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 — clean
  • npm run typecheck — clean
  • npm 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 pass
  • npm run build — covered by the verify and crash-survival (packaged build) CI jobs, both green
  • Added tests that would catch regressions, each revert-checked (see Verification above and AI Review Report below)

AI 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 is TaskPage.tsx:3144, memoized on repos. A pending repo now reaches the picker and, once selected, flows through the same unchanged getTaskProjectPickerGroups / normalizeTaskRepoSelection path as any other repo — its getProjectIdentityKey falls back to repo:${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 of repo.gitRemoteIdentity in src/ and mobile/ uses optional chaining or a truthiness check, so null behaves exactly as undefined did (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 === undefined comparison is the new isProjectRemoteIdentityPending itself. Repo['gitRemoteIdentity'] was already declared GitRemoteIdentity | null at types.ts:268 before 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: null hits if (!value || typeof value !== 'object') return undefined in its own sanitizeGitRemoteIdentity — 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-existing sanitizeRepoUpstream null precedent at persistence.ts:1306-1308; the surrounding sanitizeRepoUpdatesForPersistence branch (persistence.ts:1391-1398) and the hydrateRepo spread (persistence.ts:4631) already keyed on === undefined, so no other null began surviving.

No perf regression; the redundant-write guard is load-bearing. enrichMissingRepoGitRemoteIdentities runs on the repos:list / projects:list / projectHostSetups:list IPC handlers (ipc/repos.ts:1144,1155,1171), which are hot. isSameUnenrichedRepo tests !current.gitRemoteIdentity, which is falsy for null too, so a settled repo remains a probe candidate. Without the gitRemoteIdentity === null && current?.gitRemoteIdentity === null guard in writeIdentity, every remote-less repo would re-settle after each TTL expiry, return a non-null repo from updateRepo, fire onChanged → 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 one isProjectRemoteIdentityPending call per repo inside an already-useMemo'd filter.

False-no-remote risk (the one that would be worse than the bug). Settling null on 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 relay git.exec, which runs execFileAsync('git', …) (relay/git-handler.ts:1195 → :315,342); execFileAsync rejects 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 returns undefined from getSshGitProvider and is mapped to unavailable, not no-remote.

Cross-platform. No platform-conditional code paths, no path-separator or key-modifier assumptions are added or changed. git remote -v predates the Git 2.25 baseline. getRepoLocationKey is unchanged by this PR.

Provider neutrality. isProjectRemoteIdentityPending is provider-neutral by construction — it delegates to hasProjectRemoteIdentity, which accepts either a provider identity or a generic git remote identity. GitHub repos usually settle earlier via the persisted upstream, 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. isGitRepoKind is evaluated first and short-circuits, so no kind: 'folder' workspace can enter through the new pending branch (pinned by the excludes folders and settled remote-less repos even while others are pending test). Enrichment's candidate filter already excludes folders.

Scope. The renderer-only alternative was challenged directly and does not work: hasProjectRemoteIdentity receives 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); detectGitRemoteIdentity was kept as a 6-line wrapper specifically so repo-icon-autodetect did not have to change. No max-lines disable 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 unavailable path is exercised by mocking an absent provider and by rejecting exec on 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 -v was already being run with a fixed argv array on the same paths and hosts, at the same frequency, through the same execFile/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 as unavailable instead of being swallowed as null, 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

  • Rollout is self-correcting. Existing persisted repos with no remote currently have gitRemoteIdentity absent, so they reappear in the picker until the next enrichment pass writes the null marker. That is the safe direction (visible while unknown) and resolves within one pass.
  • A repo whose local path has been deleted now probes as unavailable rather 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.
  • New transient at cold launch: two checkouts of the same project (e.g. a local and an SSH clone of one GitLab repo) that are both still pending get distinct 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 in keeps GitHub grouping intact while a pending-identity repo joins as its own project.
  • Pre-existing issues found nearby but deliberately left out of scope (all present on main, none made worse here): probeGitRemoteIdentity branches on connectionId alone, so a runtime:<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 no timeout, so a git wedged on a stale network mount never clears inFlightProbesByLocation and stalls the serial sweep; areReposEqual compares object-valued fields by reference against freshly-constructed hydrate output, so it never reports equal. Worth separate changes, not this one.
  • Deliberately not changed: the repo-creation path (repo-icon-autodetect.ts) still does not persist the marker the way its sibling upstream: null does. Making it do so naively would be a reintroduction of this bug — that call site uses the collapsing detectGitRemoteIdentity wrapper, so a repo added while its SSH host is down would be permanently stamped no-remote. It would have to move to probeGitRemoteIdentity and write only on no-remote.
  • Deferred follow-up (unchanged from above): the 5-minute negative cache is not invalidated on SSH connection recovery. This is safe to defer precisely because the visibility symptom is now fixed independently of it — a recovering repo is already in the picker and usable; only its cross-host project grouping waits out the remaining TTL. It is a resolution-latency issue, not a visibility one.

…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.
@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change introduces structured remote identity probe statuses and adapts legacy detection to them. Enrichment now persists explicit null values for no-remote results, preserves unavailable states, and prevents stale or redundant writes. Persistence tests cover round-tripping identities and null markers. Repository selection now treats unresolved probes as pending while excluding settled remote-less repositories, with expanded projection and selection tests.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately summarizes the main change: keeping repos with pending remote-identity probes visible.
Description check ✅ Passed The description matches the template and includes substantive content for Summary, Screenshots, Testing, AI Review Report, Security Audit, and Notes.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between e1eca7f and d69c611.

📒 Files selected for processing (10)
  • src/main/persistence.test.ts
  • src/main/persistence.ts
  • src/main/repo-git-remote-identity-enrichment.test.ts
  • src/main/repo-git-remote-identity-enrichment.ts
  • src/main/repo-git-remote-identity.test.ts
  • src/main/repo-git-remote-identity.ts
  • src/renderer/src/components/task-page-default-repo-selection.test.ts
  • src/renderer/src/components/task-page-default-repo-selection.ts
  • src/shared/project-host-setup-projection.test.ts
  • src/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.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

CodeRabbit review disposition

1. Inline: "Exercise the SSH provider exec failure path" (repo-git-remote-identity.test.ts:46) — ACTIONED in de50b997f2. Correct catch: the test named "remote git command fails" passed no connectionId, so it only exercised the local gitExecFileAsync branch. Renamed to reflect that, and added a connected-provider case whose exec rejects (asserting gitExecFileAsync was not called, so it cannot silently regress to the local path) plus a connected-provider case resolving empty stdout that must settle no-remote. Both revert-checked: flipping the catch to return no-remote fails them. Discussion: #10527 (comment)

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. AGENTS.md sets the opposite bar for this codebase:

Concise/Brief Non-obvious comments ONLY

  • DO NOT: be verbose, explain the obvious, walk through the code ("WHY not HOW")
  • DO: BE CONCISE. 1 LINE if possible

Raising coverage to 80% here would mean docstringing functions whose signatures already say everything — writeIdentity(store, snapshot, gitRemoteIdentity), getRepoLocationKey(repo), getCurrentRepo(store, id). That is precisely the "explain the obvious" this repo prohibits. The three places in this diff where the why is genuinely non-obvious are documented, and they are the ones a future reader can actually get wrong:

  • GitRemoteIdentityProbe — why no-remote and unavailable must not be collapsed (repo-git-remote-identity.ts:5-8)
  • isProjectRemoteIdentityPending — what "settled" means and why it is provider-neutral (project-host-setup-projection.ts:89-92)
  • the sanitizeGitRemoteIdentity null branch, the writeIdentity redundancy guard, and the enrichment settle rule — each carries a one-line // Why: at the point of the decision

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.
@brennanb2025
brennanb2025 merged commit baf2578 into main Jul 25, 2026
2 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant