fix: keep imported thread candidates distinct
This commit is contained in:
@@ -2021,7 +2021,7 @@ function buildDeviceImportCandidateId(input: {
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join("-");
|
||||
return `import-${slugify(signature)}`;
|
||||
return `import-${slugifyWithHash(signature)}`;
|
||||
}
|
||||
|
||||
function normalizeDeviceImportCandidate(
|
||||
@@ -2316,6 +2316,12 @@ function slugify(value: string) {
|
||||
.slice(0, 48) || `item-${randomBytes(2).toString("hex")}`;
|
||||
}
|
||||
|
||||
function slugifyWithHash(value: string) {
|
||||
const base = slugify(value).slice(0, 40);
|
||||
const hash = createHash("sha1").update(value).digest("hex").slice(0, 8);
|
||||
return `${base || "item"}-${hash}`;
|
||||
}
|
||||
|
||||
const aiRolePriority: Record<AiAccountRole, number> = {
|
||||
primary: 0,
|
||||
backup: 1,
|
||||
@@ -7144,8 +7150,8 @@ function parseDeviceImportResolutionReply(
|
||||
function buildImportedThreadProject(device: Device, candidate: DeviceImportCandidate) {
|
||||
const projectId =
|
||||
candidate.codexThreadRef?.trim() && candidate.codexFolderRef?.trim()
|
||||
? slugify(`${device.id}-${candidate.codexFolderRef}-${candidate.codexThreadRef}`)
|
||||
: slugify(`${device.id}-${candidate.folderName}-${candidate.threadId}`);
|
||||
? slugifyWithHash(`${device.id}-${candidate.codexFolderRef}-${candidate.codexThreadRef}`)
|
||||
: slugifyWithHash(`${device.id}-${candidate.folderName}-${candidate.threadId}`);
|
||||
const now = nowIso();
|
||||
return normalizeProject({
|
||||
id: projectId,
|
||||
|
||||
Reference in New Issue
Block a user