Refactor database hooks to add new session tracking features

- Introduced `getSessionById` method in HooksDatabase to retrieve session details by ID.
- Updated context, new, save, and summary hooks to utilize the new `getSessionById` method.
- Enhanced session management by adding `worker_port` and `prompt_counter` columns to relevant tables.
- Improved logging in WorkerService to provide clearer output during session initialization and processing.
- Removed redundant error logging in favor of more informative console logs.
This commit is contained in:
Alex Newman
2025-10-17 16:42:23 -04:00
parent be936d8413
commit 015b38c763
8 changed files with 147 additions and 100 deletions
+19
View File
@@ -209,6 +209,25 @@ export class HooksDatabase {
return stmt.all(project, limit) as any[];
}
/**
* Get session by ID
*/
getSessionById(id: number): {
id: number;
sdk_session_id: string | null;
project: string;
user_prompt: string;
} | null {
const stmt = this.db.prepare(`
SELECT id, sdk_session_id, project, user_prompt
FROM sdk_sessions
WHERE id = ?
LIMIT 1
`);
return stmt.get(id) as any || null;
}
/**
* Find active SDK session for a Claude session
*/