fix(web): tolerate servers that predate git identity in project import (#10547)
Co-authored-by: Claude Code <[email protected]>
This commit is contained in:
1 parent
1d1bf50405
commit
62fbbe08aa
5 files changed
+73
-14
No files matched your search
@@ -24,6 +24,7 @@ import {
|
||||
resolveProviderInstanceEnabled,
|
||||
type AgentSessionImportSource,
|
||||
type AgentSessionProjectCandidate,
|
||||
type AgentSessionProjectGit,
|
||||
type AgentSessionScanResult,
|
||||
type ProviderInstanceConfig,
|
||||
} from "@t3tools/contracts";
|
||||
@@ -695,7 +696,7 @@ export const make = Effect.gen(function* () {
|
||||
const readGitIdentity = Effect.fn("AgentSessionScanner.readGitIdentity")(function* (
|
||||
directory: string,
|
||||
): Effect.fn.Return<
|
||||
| { readonly _tag: "Repository"; readonly git: AgentSessionProjectCandidate["git"] }
|
||||
| { readonly _tag: "Repository"; readonly git: AgentSessionProjectGit | null }
|
||||
| { readonly _tag: "Worktree" }
|
||||
| { readonly _tag: "NotGit" }
|
||||
> {
|
||||
@@ -1209,11 +1210,11 @@ export const make = Effect.gen(function* () {
|
||||
sources: Array<AgentSessionSource>;
|
||||
threadCount: number;
|
||||
lastActiveAtMs: number | null;
|
||||
git: AgentSessionProjectCandidate["git"];
|
||||
git: AgentSessionProjectGit | null;
|
||||
}
|
||||
>();
|
||||
const directoryKeys = new Map<string, string>();
|
||||
const gitIdentities = new Map<string, AgentSessionProjectCandidate["git"]>();
|
||||
const gitIdentities = new Map<string, AgentSessionProjectGit | null>();
|
||||
|
||||
for (const candidate of raw) {
|
||||
const expanded = expandHomePath(candidate.cwd.trim());
|
||||
|
||||
@@ -74,6 +74,12 @@ describe("partitionOnboardingProjects", () => {
|
||||
|
||||
expect(partitionOnboardingProjects([repo, folder, thin], now).recent).toEqual([repo]);
|
||||
});
|
||||
|
||||
it("selects candidates from servers that do not report git identity", () => {
|
||||
const { git: _git, ...legacy } = candidate("/projects/legacy");
|
||||
|
||||
expect(partitionOnboardingProjects([legacy], now).recent).toEqual([legacy]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("groupOnboardingProjects", () => {
|
||||
@@ -127,6 +133,17 @@ describe("groupOnboardingProjects", () => {
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("lists candidates without git identity as standalone repositories", () => {
|
||||
const { git: _git, ...legacy } = candidate("/code/legacy", { title: "legacy" });
|
||||
|
||||
const grouped = groupOnboardingProjects([legacy]);
|
||||
|
||||
expect(grouped.other).toEqual([]);
|
||||
expect(grouped.repositories.map((group) => [group.label, group.repository])).toEqual([
|
||||
["legacy", null],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveOnboardingProjectId", () => {
|
||||
|
||||
@@ -9,6 +9,8 @@ const DEFAULT_SELECTION_MIN_THREADS = 3;
|
||||
* Existing projects still need their agent history imported, so every scan
|
||||
* candidate is offered. The default selection is narrower: git repositories
|
||||
* active in the last 30 days with enough threads to look like real work.
|
||||
* Servers that predate the git scan omit `git`; their candidates are treated
|
||||
* as repositories so old computers still get a useful default selection.
|
||||
*/
|
||||
export function partitionOnboardingProjects<T extends AgentSessionProjectCandidate>(
|
||||
candidates: ReadonlyArray<T>,
|
||||
@@ -48,9 +50,10 @@ function latestActivity(left: string | null, right: string | null): string | nul
|
||||
/**
|
||||
* Group scan candidates for the onboarding picker. Clones of one repository
|
||||
* share a group keyed by their normalized origin URL. Repositories without an
|
||||
* origin get a group each. Directories that are not git repositories are
|
||||
* returned separately so the UI can fold them away by default. Groups sort by
|
||||
* most recent activity, newest first.
|
||||
* origin get a group each, as do candidates from servers that do not report
|
||||
* git identity. Directories that are not git repositories are returned
|
||||
* separately so the UI can fold them away by default. Groups sort by most
|
||||
* recent activity, newest first.
|
||||
*/
|
||||
export function groupOnboardingProjects<
|
||||
T extends Pick<
|
||||
@@ -66,16 +69,14 @@ export function groupOnboardingProjects<
|
||||
other.push(candidate);
|
||||
continue;
|
||||
}
|
||||
const key =
|
||||
candidate.git.remoteKey === null
|
||||
? `path:${candidate.path}`
|
||||
: `remote:${candidate.git.remoteKey}`;
|
||||
const git = candidate.git ?? { remoteKey: null, repository: null };
|
||||
const key = git.remoteKey === null ? `path:${candidate.path}` : `remote:${git.remoteKey}`;
|
||||
const existing = groups.get(key);
|
||||
if (existing === undefined) {
|
||||
groups.set(key, {
|
||||
key,
|
||||
label: candidate.git.repository ?? candidate.title,
|
||||
repository: candidate.git.repository,
|
||||
label: git.repository ?? candidate.title,
|
||||
repository: git.repository,
|
||||
candidates: [candidate],
|
||||
threadCount: candidate.threadCount,
|
||||
lastActiveAt: candidate.lastActiveAt,
|
||||
|
||||
Reference in new issue
Block a user