Skip to content

feat: Add pause/resume functionality for runner sessions (instead of session termination on break) #243

@masa10-f

Description

@masa10-f

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

  1. Add fields to WorkSession model (models.py):

    paused_at: datetime | None = SQLField(default=None)
    total_paused_minutes: int = SQLField(default=0)
  2. Add new API endpoints (work_sessions.py):

    • POST /work-sessions/pause - Pause current session
    • POST /work-sessions/resume - Resume paused session
  3. Add service methods (services.py):

    • pause_session() - Set paused_at timestamp
    • resume_session() - Calculate paused duration, add to total_paused_minutes, clear paused_at
  4. Update time calculation:

    • Modify checkout_session() to exclude total_paused_minutes from actual_minutes

Frontend Changes

  1. Update use-runner.ts hook:

    • Add isPaused state
    • Add pause() and resume() functions
  2. Update runner-page.tsx:

    • Show pause/resume button instead of break
    • Display paused state UI (dimmed timer, "Paused" indicator)
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions