mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-17 13:32:18 +00:00
fix(sessions): prefer exact IDs over newer prefix matches
This commit is contained in:
1 parent
d2ef268059
commit
01ac0ca4e6
3 files changed
+87
-3
No files matched your search
@@ -167,9 +167,11 @@ function buildSessionRecord(sessionPath, metadata) {
|
||||
};
|
||||
}
|
||||
|
||||
function sessionMatchesId(metadata, normalizedSessionId) {
|
||||
function sessionMatchesId(metadata, normalizedSessionId, exact = false) {
|
||||
const filename = metadata.filename;
|
||||
const shortIdMatch = metadata.shortId !== 'no-id' && metadata.shortId.startsWith(normalizedSessionId);
|
||||
const shortIdMatch = metadata.shortId !== 'no-id' && (exact
|
||||
? metadata.shortId === normalizedSessionId
|
||||
: metadata.shortId.startsWith(normalizedSessionId));
|
||||
const filenameMatch = filename === normalizedSessionId || filename === `${normalizedSessionId}.tmp`;
|
||||
const noIdMatch = metadata.shortId === 'no-id' && filename === `${normalizedSessionId}-session.tmp`;
|
||||
|
||||
@@ -216,7 +218,11 @@ function getMatchingSessionCandidates(normalizedSessionId) {
|
||||
}
|
||||
}
|
||||
|
||||
matches.sort((a, b) => b.modifiedTime - a.modifiedTime);
|
||||
// All exact aliases share priority; keep newest-first ordering for ties.
|
||||
matches.sort((a, b) =>
|
||||
Number(sessionMatchesId(b, normalizedSessionId, true)) - Number(sessionMatchesId(a, normalizedSessionId, true)) ||
|
||||
b.modifiedTime - a.modifiedTime
|
||||
);
|
||||
return matches;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user