[Bug]: A project cloned from GitHub keeps a null repository identity after the clone finishes
Before submitting
- [x] I searched existing issues and did not find a duplicate. Open PR #17047 changes the same code path for a different symptom (a clone inside another repository picks up that repository's identity); see Code investigation.
- [x] I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Have a project for a GitHub repository, for example
pingdotgg/t3code, in one environment. - In another environment, add a project with clone from GitHub for the same repository, into a folder that is not inside another Git repository.
- Wait for the clone to finish, then look at the sidebar on a client connected to both environments.
Expected behavior
When the clone finishes, the new project gets the repository's identity and groups with the other pingdotgg/t3code project.
Actual behavior
The project keeps repositoryIdentity: null after the clone finishes. Clients group it by its folder path, so it shows as its own sidebar entry. It only joins the group after the server's cached null expires and something asks for that project's metadata again.
Timeline from one occurrence:
- 22:34:32: project created; its empty folder appears in the same second
- 22:34:50:
.git/configwritten by the clone - 22:34:52: the
project-clone-doneupdate runs and still sendsrepositoryIdentity: null
Impact
Minor bug or occasional failure
Version or commit
Source inspected: main @ 4d73e1d5cd
Environment
Server-side; does not depend on OS or client.
Code investigation
At the inspected commit, repository identity is cached in two layers:
RepositoryIdentityResolverkeeps anullresult for 1 minute;resolve(cwd, { refresh: true })bypasses it.ProjectEnrichmentServicehas its ownrepositoryIdentityCachekeyed by workspace root. A resolvednullcounts as a success and is kept for 1 minute. Clients read identity from this layer.
The clone flow:
createProjectcallsProjectService.create, which invalidates enrichment. The folder is still empty, so the next read resolvesnulland layer 2 caches it.onClonedcallsrepositoryIdentityResolver.resolve(root, { refresh: true }), which refreshes only layer 1, thenprojectService.update({ projectId }).ProjectService.updateinvalidates enrichment only when the workspace root changes, so the update reads the stalenullfrom layer 2 and sends it to clients.- With no identity,
deriveLogicalProjectKeyfalls back to the per-environment path key, so the project gets its own group.
#17047 adds ProjectEnrichmentService.refresh, which refreshes both layers and publishes the result, and calls it from onCloned. That covers this case too, but its test only covers the parent-repository case, not a project created with no identity that gains one when the clone lands.
Other refresh: true call sites I checked:
sourceControlPublishRepositoryhas the same gap: it refreshes only layer 1, so a project that gains a remote by publishing keeps its cachednulluntil layer 2 expires. #17047 leaves this unchanged.ThreadPullRequestServiceresolves a fresh identity only for a local comparison and does not publish it, so it is not affected.ThreadSettlementServiceandstorageCleanuppassrefresh: truetobranchPullRequest, not to the identity resolver.
Workaround
None needed in most cases: it fixes itself once the cached null expires (1 minute after it was resolved) and the project's metadata is read again, for example on a client reconnect.
[!NOTE] 🤖 Claude Opus 5.5 responding on behalf of Theo
Thanks for the report. One part of this is fixed on main in #22180. Please test on the nightly built from main on 2026-10-21, or on the next stable release. One part is still open: publishing a project to a remote keeps a cached null identity until the cache expires (sourceControlPublishRepository). If that part still matters to you, please open a new issue for that part only.