Spaces:
Running
Running
Fix old project reset after onboarding
Browse files- metrics.py +10 -0
- ui/__pycache__/__init__.cpython-310.pyc +0 -0
- ui/__pycache__/handlers.cpython-310.pyc +0 -0
- ui/__pycache__/handlers.cpython-313.pyc +0 -0
- ui/__pycache__/layout.cpython-313.pyc +0 -0
- ui/handlers.py +23 -5
- ui/layout.py +7 -3
metrics.py
CHANGED
|
@@ -373,3 +373,13 @@ class MetricsTracker:
|
|
| 373 |
"distracted": distracted_counts,
|
| 374 |
"idle": idle_counts
|
| 375 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 373 |
"distracted": distracted_counts,
|
| 374 |
"idle": idle_counts
|
| 375 |
}
|
| 376 |
+
|
| 377 |
+
def clear_all_data(self):
|
| 378 |
+
"""Clear all metrics data (for demo reset)."""
|
| 379 |
+
if self.use_memory:
|
| 380 |
+
self.memory_history = []
|
| 381 |
+
self.memory_streaks = {}
|
| 382 |
+
print("ℹ️ MetricsTracker: In-memory data cleared.")
|
| 383 |
+
else:
|
| 384 |
+
# Optional: Implement for SQLite if needed, but primarily for demo
|
| 385 |
+
pass
|
ui/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (137 Bytes). View file
|
|
|
ui/__pycache__/handlers.cpython-310.pyc
ADDED
|
Binary file (9.89 kB). View file
|
|
|
ui/__pycache__/handlers.cpython-313.pyc
CHANGED
|
Binary files a/ui/__pycache__/handlers.cpython-313.pyc and b/ui/__pycache__/handlers.cpython-313.pyc differ
|
|
|
ui/__pycache__/layout.cpython-313.pyc
CHANGED
|
Binary files a/ui/__pycache__/layout.cpython-313.pyc and b/ui/__pycache__/layout.cpython-313.pyc differ
|
|
|
ui/handlers.py
CHANGED
|
@@ -117,20 +117,28 @@ class UIHandlers:
|
|
| 117 |
|
| 118 |
def process_onboarding(self, project_description: str) -> tuple:
|
| 119 |
"""Process onboarding and generate tasks."""
|
|
|
|
|
|
|
|
|
|
| 120 |
if not self.focus_monitor.focus_agent:
|
| 121 |
-
return "❌ Please initialize agent first", self.get_task_dataframe(), 0
|
| 122 |
|
| 123 |
if not project_description.strip():
|
| 124 |
-
return "❌ Please describe your project", self.get_task_dataframe(), 0
|
| 125 |
|
| 126 |
# Generate tasks
|
| 127 |
tasks = self.focus_monitor.focus_agent.get_onboarding_tasks(project_description)
|
| 128 |
|
| 129 |
if not tasks:
|
| 130 |
-
return "❌ Failed to generate tasks. Check your AI provider configuration.", self.get_task_dataframe(), 0
|
| 131 |
|
| 132 |
-
#
|
|
|
|
| 133 |
self.task_manager.clear_all_tasks()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
for task in tasks:
|
| 135 |
self.task_manager.add_task(
|
| 136 |
title=task.get("title", "Untitled"),
|
|
@@ -138,7 +146,17 @@ class UIHandlers:
|
|
| 138 |
estimated_duration=task.get("estimated_duration", "30 min")
|
| 139 |
)
|
| 140 |
|
| 141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
def get_task_dataframe(self):
|
| 144 |
"""Get tasks as a list for display."""
|
|
|
|
| 117 |
|
| 118 |
def process_onboarding(self, project_description: str) -> tuple:
|
| 119 |
"""Process onboarding and generate tasks."""
|
| 120 |
+
# Default UI updates for failure cases (no change to timer/monitoring)
|
| 121 |
+
no_update = gr.update()
|
| 122 |
+
|
| 123 |
if not self.focus_monitor.focus_agent:
|
| 124 |
+
return "❌ Please initialize agent first", self.get_task_dataframe(), 0, no_update, no_update, no_update, no_update
|
| 125 |
|
| 126 |
if not project_description.strip():
|
| 127 |
+
return "❌ Please describe your project", self.get_task_dataframe(), 0, no_update, no_update, no_update, no_update
|
| 128 |
|
| 129 |
# Generate tasks
|
| 130 |
tasks = self.focus_monitor.focus_agent.get_onboarding_tasks(project_description)
|
| 131 |
|
| 132 |
if not tasks:
|
| 133 |
+
return "❌ Failed to generate tasks. Check your AI provider configuration.", self.get_task_dataframe(), 0, no_update, no_update, no_update, no_update
|
| 134 |
|
| 135 |
+
# Reset State (Demo Mode Reset)
|
| 136 |
+
# We clear everything to give the user a fresh start
|
| 137 |
self.task_manager.clear_all_tasks()
|
| 138 |
+
self.metrics_tracker.clear_all_data()
|
| 139 |
+
self.stop_monitoring() # Stop backend monitoring
|
| 140 |
+
|
| 141 |
+
# Add tasks to database
|
| 142 |
for task in tasks:
|
| 143 |
self.task_manager.add_task(
|
| 144 |
title=task.get("title", "Untitled"),
|
|
|
|
| 146 |
estimated_duration=task.get("estimated_duration", "30 min")
|
| 147 |
)
|
| 148 |
|
| 149 |
+
# Return success with UI resets
|
| 150 |
+
# Outputs: [onboard_status, task_table, progress_bar, monitor_timer, timer_toggle_btn, timer_active_state, demo_status]
|
| 151 |
+
return (
|
| 152 |
+
f"✅ Generated {len(tasks)} tasks! Go to Task Manager to start.",
|
| 153 |
+
self.get_task_dataframe(),
|
| 154 |
+
self.calculate_progress(),
|
| 155 |
+
gr.update(active=False), # Stop timer
|
| 156 |
+
gr.update(value="▶️ Start Auto-Check"), # Reset button label
|
| 157 |
+
False, # Reset timer state
|
| 158 |
+
"⏹️ Monitoring reset (New Project)" # Update status
|
| 159 |
+
)
|
| 160 |
|
| 161 |
def get_task_dataframe(self):
|
| 162 |
"""Get tasks as a list for display."""
|
ui/layout.py
CHANGED
|
@@ -50,6 +50,9 @@ def create_app(ui_handlers, pomodoro_timer: PomodoroTimer, launch_mode: str, ai_
|
|
| 50 |
# Auto-refresh timer for monitoring (default 30s)
|
| 51 |
monitor_timer = gr.Timer(value=monitor_interval, active=False)
|
| 52 |
|
|
|
|
|
|
|
|
|
|
| 53 |
# Dedicated 1-second timer for Pomodoro
|
| 54 |
pomodoro_ticker = gr.Timer(value=1, active=True)
|
| 55 |
|
|
@@ -322,11 +325,12 @@ def create_app(ui_handlers, pomodoro_timer: PomodoroTimer, launch_mode: str, ai_
|
|
| 322 |
app.load(fn=lambda: ui_handlers.initialize_agent(ai_provider), outputs=[init_status, ai_provider_display], api_name=False)
|
| 323 |
app.load(fn=ui_handlers.get_voice_status_ui, outputs=voice_status_display, api_name=False)
|
| 324 |
|
|
|
|
| 325 |
# Onboarding
|
| 326 |
generate_btn.click(
|
| 327 |
fn=ui_handlers.process_onboarding,
|
| 328 |
inputs=[project_input],
|
| 329 |
-
outputs=[onboard_status, task_table, progress_bar],
|
| 330 |
api_name=False
|
| 331 |
)
|
| 332 |
|
|
@@ -423,7 +427,7 @@ def create_app(ui_handlers, pomodoro_timer: PomodoroTimer, launch_mode: str, ai_
|
|
| 423 |
return gr.update(active=new_state), gr.update(value=btn_label), new_state
|
| 424 |
|
| 425 |
# We need a state to track timer status for the button label
|
| 426 |
-
timer_active_state
|
| 427 |
|
| 428 |
timer_toggle_btn.click(
|
| 429 |
fn=toggle_demo_timer,
|
|
@@ -458,7 +462,7 @@ def create_app(ui_handlers, pomodoro_timer: PomodoroTimer, launch_mode: str, ai_
|
|
| 458 |
btn_label = "▶️ Start Auto-Check" if active else "⏸️ Pause Auto-Check"
|
| 459 |
return gr.update(active=new_state), gr.update(value=btn_label), new_state
|
| 460 |
|
| 461 |
-
timer_active_state
|
| 462 |
|
| 463 |
timer_toggle_btn.click(
|
| 464 |
fn=toggle_local_timer,
|
|
|
|
| 50 |
# Auto-refresh timer for monitoring (default 30s)
|
| 51 |
monitor_timer = gr.Timer(value=monitor_interval, active=False)
|
| 52 |
|
| 53 |
+
# State to track timer status (Active by default in Demo, Inactive in Local)
|
| 54 |
+
timer_active_state = gr.State(value=(launch_mode == "demo"))
|
| 55 |
+
|
| 56 |
# Dedicated 1-second timer for Pomodoro
|
| 57 |
pomodoro_ticker = gr.Timer(value=1, active=True)
|
| 58 |
|
|
|
|
| 325 |
app.load(fn=lambda: ui_handlers.initialize_agent(ai_provider), outputs=[init_status, ai_provider_display], api_name=False)
|
| 326 |
app.load(fn=ui_handlers.get_voice_status_ui, outputs=voice_status_display, api_name=False)
|
| 327 |
|
| 328 |
+
# Onboarding
|
| 329 |
# Onboarding
|
| 330 |
generate_btn.click(
|
| 331 |
fn=ui_handlers.process_onboarding,
|
| 332 |
inputs=[project_input],
|
| 333 |
+
outputs=[onboard_status, task_table, progress_bar, monitor_timer, timer_toggle_btn, timer_active_state, demo_status],
|
| 334 |
api_name=False
|
| 335 |
)
|
| 336 |
|
|
|
|
| 427 |
return gr.update(active=new_state), gr.update(value=btn_label), new_state
|
| 428 |
|
| 429 |
# We need a state to track timer status for the button label
|
| 430 |
+
# timer_active_state is defined at top of function
|
| 431 |
|
| 432 |
timer_toggle_btn.click(
|
| 433 |
fn=toggle_demo_timer,
|
|
|
|
| 462 |
btn_label = "▶️ Start Auto-Check" if active else "⏸️ Pause Auto-Check"
|
| 463 |
return gr.update(active=new_state), gr.update(value=btn_label), new_state
|
| 464 |
|
| 465 |
+
# timer_active_state is defined at top of function
|
| 466 |
|
| 467 |
timer_toggle_btn.click(
|
| 468 |
fn=toggle_local_timer,
|