Summary
Currently, when a user takes a break during a runner session, the session is completely terminated. This requires the user to go through the full checkout flow (KPT input, etc.) and start a new session after the break.
A more natural workflow would be to simply pause the timer during breaks without ending the session.
Current Behavior
Work Start → Break Button → Checkout Dialog → Session Ends → Must start new session
- Break triggers
checkout_session() with decision='break'
- Session's
ended_at is set, marking session as complete
- User must create a new session to continue working
Relevant code:
apps/api/src/humancompiler_api/services.py:1161-1290 - checkout_session method
apps/web/src/components/runner/break-dialog.tsx - Break dialog UI
apps/web/src/components/runner/runner-page.tsx:221-233 - Break handler
Proposed Behavior
Work Start → Break Button → Timer Pauses → Resume Button → Same session continues
- Break should pause the timer without ending the session
- User can resume the same session after the break
- Paused time should be excluded from
actual_minutes calculation
- Full checkout flow only when actually finishing work
Implementation Plan
Backend Changes
-
Add fields to WorkSession model (models.py):
paused_at: datetime | None = SQLField(default=None)
total_paused_minutes: int = SQLField(default=0)
-
Add new API endpoints (work_sessions.py):
POST /work-sessions/pause - Pause current session
POST /work-sessions/resume - Resume paused session
-
Add service methods (services.py):
pause_session() - Set paused_at timestamp
resume_session() - Calculate paused duration, add to total_paused_minutes, clear paused_at
-
Update time calculation:
- Modify
checkout_session() to exclude total_paused_minutes from actual_minutes
Frontend Changes
-
Update use-runner.ts hook:
- Add
isPaused state
- Add
pause() and resume() functions
-
Update runner-page.tsx:
- Show pause/resume button instead of break
- Display paused state UI (dimmed timer, "Paused" indicator)
-
Update or replace break-dialog.tsx:
- Simple confirmation without KPT input for pause
- Or remove dialog entirely for instant pause
Database Migration
- Add
paused_at and total_paused_minutes columns to work_sessions table
Additional Considerations
Related
Summary
Currently, when a user takes a break during a runner session, the session is completely terminated. This requires the user to go through the full checkout flow (KPT input, etc.) and start a new session after the break.
A more natural workflow would be to simply pause the timer during breaks without ending the session.
Current Behavior
checkout_session()withdecision='break'ended_atis set, marking session as completeRelevant code:
apps/api/src/humancompiler_api/services.py:1161-1290-checkout_sessionmethodapps/web/src/components/runner/break-dialog.tsx- Break dialog UIapps/web/src/components/runner/runner-page.tsx:221-233- Break handlerProposed Behavior
actual_minutescalculationImplementation Plan
Backend Changes
Add fields to
WorkSessionmodel (models.py):Add new API endpoints (
work_sessions.py):POST /work-sessions/pause- Pause current sessionPOST /work-sessions/resume- Resume paused sessionAdd service methods (
services.py):pause_session()- Setpaused_attimestampresume_session()- Calculate paused duration, add tototal_paused_minutes, clearpaused_atUpdate time calculation:
checkout_session()to excludetotal_paused_minutesfromactual_minutesFrontend Changes
Update
use-runner.tshook:isPausedstatepause()andresume()functionsUpdate
runner-page.tsx:Update or replace
break-dialog.tsx:Database Migration
paused_atandtotal_paused_minutescolumns towork_sessionstableAdditional Considerations
Related