This plan outlines the implementation of the "Break" feature in the lock-in project, corresponding to the feature recently added to the hold-idiot-accountable (HIA) backend.
- Events:
BREAK_STARTandBREAK_STOPadded toEventType. - Payloads:
BREAK_START: Includesduration_secandnext_session(subject, duration, blocklist).BREAK_STOP: Includes optionalreason.
- Backend Behavior:
BREAK_STOPautomatically triggersSESSION_STARTwith thenext_sessiondetails stored duringBREAK_START.
- Update
EventTypeenum:export enum EventType { SESSION_START = "SESSION_START", SESSION_STOP = "SESSION_STOP", BREAK_START = "BREAK_START", BREAK_STOP = "BREAK_STOP", }
- Define
BreakStartSchemaandBreakStopSchema. - Update
SessionStateto support the new status and break data:export interface SessionState { status: 'IDLE' | 'FOCUSING' | 'BREAK'; subject?: string; startTime?: string; durationSec?: number; endTime?: string; blocklist?: string[]; // For Break state nextSession?: { subject: string; durationSec: number; }; }
- Implement
startBreak(durationSec: number, nextSession: { subject: string, planned_duration_sec: number, blocklist: string[] }). - Implement
stopBreak(reason?: string). - Update
getSessionStatusto parseactiveBreakfrom the HIA response and map it to the internalSessionState.
- Update
useSessionstate to includestatus. - Update
syncStatuseffect:- If
data.activeSessionis present ->status: 'FOCUSING'. - Else if
data.activeBreakis present ->status: 'BREAK'. - Else ->
status: 'IDLE'.
- If
- Map
activeBreakfields (started_at,duration_sec) tostartTime,durationSec, andendTime. - Expose
handleStartBreakandhandleStopBreak.
- Add a "Take a Break" button below "Commence Session".
- Default break duration: 10 minutes (add a small toggle or preset for this).
- When clicked, it calls
handleStartBreakusing current form values (subject, session duration, blocklist) as the "next session".
- New component inspired by
ActiveSession.tsx. - Displays "ON BREAK" in indigo/blue theme (as seen in HIA).
- Shows a countdown timer.
- Displays "Upcoming: [Subject]" to remind the user what's next.
- "Skip Break" button to end break early.
- Refactor the conditional rendering:
status === 'IDLE'->InitiationFormstatus === 'FOCUSING'->ActiveSessionstatus === 'BREAK'->BreakSession
- Phase 1: Foundations
- Update
lib/types.tsandlib/hia.ts. - Commit:
feat(api): add break event types and API methods - Push.
- Update
- Phase 2: Logic
- Update
hooks/useSession.ts. - Commit:
feat(hooks): update useSession to handle break state - Push.
- Update
- Phase 3: UI Components
- Create
components/BreakSession.tsx. - Update
components/InitiationForm.tsx. - Commit:
feat(ui): implement BreakSession and update InitiationForm - Push.
- Create
- Phase 4: Integration
- Update
app/page.tsx. - Final polish and testing.
- Commit:
feat(ui): integrate break feature into main page - Push.
- Update
Verified against HIA backend implementation details.