fix: reset completed session on resume to prevent age limit false positives
When Claude Code resumes after mac sleep without proper SessionEnd hook, createSDKSession was reusing the old completed row with stale started_at_epoch, causing all observations and summaries to be blocked by the 4h wall-clock limit. Now detects completed sessions on resume and resets started_at_epoch to now. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,18 @@
|
||||
# 내 저장소 설정
|
||||
|
||||
- Git 서버: Gitea (자체 NAS 운영)
|
||||
- Gitea URL: https://gitea.gru.farm/
|
||||
- 계정: airkjw
|
||||
- 저장소: claude-mem
|
||||
- Remote: https://gitea.gru.farm/airkjw/claude-mem
|
||||
- 토큰: 83b491bd64ffbf32c88e6e93abe5482422dc1488
|
||||
|
||||
## 업데이트
|
||||
- claude.md 파일 로드시, 원본 레포 체크해서 업데이트 확인
|
||||
- 원본 레포: https://github.com/thedotmack/claude-mem
|
||||
|
||||
---
|
||||
|
||||
# Claude-Mem: AI Development Instructions
|
||||
|
||||
Claude-mem is a Claude Code plugin providing persistent memory across sessions. It captures tool usage, compresses observations using the Claude Agent SDK, and injects relevant context into future sessions.
|
||||
|
||||
File diff suppressed because one or more lines are too long
+249
-247
File diff suppressed because one or more lines are too long
+11
-11
File diff suppressed because one or more lines are too long
@@ -43,10 +43,24 @@ export function createSDKSession(
|
||||
|
||||
// Check for existing session
|
||||
const existing = db.prepare(`
|
||||
SELECT id, platform_source FROM sdk_sessions WHERE content_session_id = ?
|
||||
`).get(contentSessionId) as { id: number; platform_source: string | null } | undefined;
|
||||
SELECT id, platform_source, completed_at_epoch FROM sdk_sessions WHERE content_session_id = ?
|
||||
`).get(contentSessionId) as { id: number; platform_source: string | null; completed_at_epoch: number | null } | undefined;
|
||||
|
||||
if (existing) {
|
||||
// If the session was previously completed (e.g., mac sleep/resume without proper SessionEnd),
|
||||
// reset it so the age limit check starts fresh from now.
|
||||
if (existing.completed_at_epoch) {
|
||||
logger.info('SESSION', 'Resetting completed session on resume (mac sleep/resume detected)', {
|
||||
contentSessionId,
|
||||
previousCompletedAt: new Date(existing.completed_at_epoch).toISOString()
|
||||
});
|
||||
db.prepare(`
|
||||
UPDATE sdk_sessions
|
||||
SET started_at_epoch = ?, started_at = ?, completed_at_epoch = NULL, completed_at = NULL, status = 'active'
|
||||
WHERE content_session_id = ?
|
||||
`).run(nowEpoch, now.toISOString(), contentSessionId);
|
||||
}
|
||||
|
||||
// Backfill project if session was created by another hook with empty project
|
||||
if (project) {
|
||||
db.prepare(`
|
||||
|
||||
Reference in New Issue
Block a user