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:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user