fix: renameAlias data corruption, empty sessionId match, NaN threshold

- Fix renameAlias() leaving orphaned newAlias key on save failure,
  causing in-memory data corruption with both old and new keys present
- Add sessionPath validation to setAlias() to reject empty/null paths
- Guard getSessionById() against empty string matching all sessions
  (startsWith('') is always true in JavaScript)
- Fix suggest-compact.js NaN comparison when COMPACT_THRESHOLD env var
  is set to a non-numeric value — falls back to 50 instead of silently
  disabling the threshold check
- Sync suggest-compact.js to .cursor/ copy
This commit is contained in:
Affaan Mustafa
2026-02-12 14:30:10 -08:00
parent 6e5b45ed28
commit 63be081741
4 changed files with 84 additions and 3 deletions

View File

@@ -27,7 +27,8 @@ async function main() {
// or parent PID as fallback
const sessionId = process.env.CLAUDE_SESSION_ID || String(process.ppid) || 'default';
const counterFile = path.join(getTempDir(), `claude-tool-count-${sessionId}`);
const threshold = parseInt(process.env.COMPACT_THRESHOLD || '50', 10);
const rawThreshold = parseInt(process.env.COMPACT_THRESHOLD || '50', 10);
const threshold = Number.isFinite(rawThreshold) ? rawThreshold : 50;
let count = 1;