[AI] fix
This commit is contained in:
@@ -3,6 +3,7 @@ import os
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
class SessionManager:
|
class SessionManager:
|
||||||
@@ -11,17 +12,26 @@ class SessionManager:
|
|||||||
self.tasks_directory.mkdir(exist_ok=True)
|
self.tasks_directory.mkdir(exist_ok=True)
|
||||||
self.current_session: Optional[Dict] = None
|
self.current_session: Optional[Dict] = None
|
||||||
self.session_dirty = False
|
self.session_dirty = False
|
||||||
|
# Keep track of last session creation time to prevent duplicates
|
||||||
|
self._last_session_time = 0
|
||||||
|
|
||||||
def create_session(self, task_id: str, project_id: str) -> Dict:
|
def create_session(self, task_id: str, project_id: str) -> Dict:
|
||||||
"""
|
"""
|
||||||
Create a new work session.
|
Create a new work session.
|
||||||
"""
|
"""
|
||||||
session_id = datetime.now().strftime("%Y%m%dT%H%M%S")
|
# Ensure unique session ID even if called rapidly
|
||||||
|
current_time = time.time()
|
||||||
|
if current_time <= self._last_session_time:
|
||||||
|
current_time = self._last_session_time + 0.001 # Add small increment
|
||||||
|
|
||||||
|
self._last_session_time = current_time
|
||||||
|
session_id = datetime.fromtimestamp(current_time).strftime("%Y%m%dT%H%M%S%f")[:-3] # Include milliseconds
|
||||||
|
|
||||||
session = {
|
session = {
|
||||||
"session_id": session_id,
|
"session_id": session_id,
|
||||||
"task_id": task_id,
|
"task_id": task_id,
|
||||||
"project_id": project_id,
|
"project_id": project_id,
|
||||||
"started_at": datetime.now().isoformat(),
|
"started_at": datetime.fromtimestamp(current_time).isoformat(),
|
||||||
"duration_seconds": 0,
|
"duration_seconds": 0,
|
||||||
"window_details": {},
|
"window_details": {},
|
||||||
"distractions": [],
|
"distractions": [],
|
||||||
|
|||||||
@@ -37,11 +37,19 @@ def register_session_listener(callback: Callable[[str], None]) -> None:
|
|||||||
except:
|
except:
|
||||||
pass # Already registered
|
pass # Already registered
|
||||||
|
|
||||||
|
# Corrected CreateWindow call with all required parameters
|
||||||
hwnd = win32gui.CreateWindow(
|
hwnd = win32gui.CreateWindow(
|
||||||
wndclass.lpszClassName,
|
wndclass.lpszClassName, # lpClassName
|
||||||
"Session Watcher",
|
"Session Watcher", # lpWindowName
|
||||||
0, 0, 0, 0, 0,
|
0, # dwStyle
|
||||||
0, hinst, None
|
0, # x
|
||||||
|
0, # y
|
||||||
|
0, # nWidth
|
||||||
|
0, # nHeight
|
||||||
|
0, # hWndParent
|
||||||
|
0, # hMenu
|
||||||
|
hinst, # hInstance
|
||||||
|
None # lParam
|
||||||
)
|
)
|
||||||
|
|
||||||
# Register for session notifications
|
# Register for session notifications
|
||||||
|
|||||||
Reference in New Issue
Block a user