@@ -19,6 +19,7 @@ export function FocusOverlay() {
1919 const {
2020 isFocusModeActive,
2121 activeFocusTaskId,
22+ pauseFocusSession,
2223 endFocusSession,
2324 cancelFocusSession,
2425 updateTaskTime,
@@ -31,6 +32,7 @@ export function FocusOverlay() {
3132 elapsedTime,
3233 isRunning,
3334 setIsRunning,
35+ toggleTimer,
3436 showSummary,
3537 setShowSummary,
3638 summaryNote,
@@ -39,25 +41,48 @@ export function FocusOverlay() {
3941 setShowCancelDialog,
4042 handleCloseAttempt,
4143 handleConfirmCancel,
44+
45+ // Editing props
46+ isEditing,
47+ editedTime,
48+ handleTimeEdit,
49+ isDirty,
50+ showConfirmResume,
51+ confirmTimeUpdate,
52+ cancelTimeUpdate,
4253 } = useFocusTimer ( {
4354 isFocusModeActive,
4455 task,
4556 cancelFocusSession,
57+ initialTime : task ?. totalTimeSpent || 0 ,
4658 } ) ;
4759
48- const formatTime = ( ms : number ) => {
49- const seconds = Math . floor ( ( ms / 1000 ) % 60 ) ;
50- const minutes = Math . floor ( ( ms / ( 1000 * 60 ) ) % 60 ) ;
51- const hours = Math . floor ( ms / ( 1000 * 60 * 60 ) ) ;
60+ const formatDuration = ( ms : number ) => {
61+ const totalSeconds = Math . floor ( ms / 1000 ) ;
62+ const minutes = Math . floor ( totalSeconds / 60 ) ;
63+ const seconds = totalSeconds % 60 ;
64+
65+ if ( minutes === 0 ) return `${ seconds } s` ;
66+ return `${ minutes } m ${ seconds } s` ;
67+ } ;
5268
53- const pad = ( num : number ) => num . toString ( ) . padStart ( 2 , "0" ) ;
54- return `${ pad ( hours ) } :${ pad ( minutes ) } :${ pad ( seconds ) } ` ;
69+ const handleBreak = ( ) => {
70+ if ( activeFocusTaskId ) {
71+ const finalTime = isDirty ? editedTime : elapsedTime ;
72+ const sessionDuration = finalTime - ( task ?. totalTimeSpent || 0 ) ;
73+ pauseFocusSession ( sessionDuration ) ;
74+ toast . info ( "Session paused" , {
75+ description : `Recorded ${ formatDuration ( sessionDuration ) } of focus time.` ,
76+ } ) ;
77+ }
5578 } ;
5679
5780 const handleFinish = ( ) => {
5881 if ( activeFocusTaskId ) {
82+ const finalTime = isDirty ? editedTime : elapsedTime ;
83+ const sessionDuration = finalTime - ( task ?. totalTimeSpent || 0 ) ;
5984 // Record time
60- updateTaskTime ( activeFocusTaskId , elapsedTime ) ;
85+ updateTaskTime ( activeFocusTaskId , sessionDuration ) ;
6186
6287 // Update status and description
6388 const updates : any = { status : "done" } ;
@@ -67,7 +92,7 @@ export function FocusOverlay() {
6792 updateTask ( activeFocusTaskId , updates ) ;
6893
6994 toast . success ( "Task completed!" , {
70- description : `Focused for ${ formatTime ( elapsedTime ) } ` ,
95+ description : `Total time focused: ${ formatDuration ( finalTime ) } ` ,
7196 } ) ;
7297 }
7398 endFocusSession ( ) ;
@@ -90,12 +115,21 @@ export function FocusOverlay() {
90115 taskDescription = { task . description }
91116 elapsedTime = { elapsedTime }
92117 isRunning = { isRunning }
93- onToggleTimer = { ( ) => setIsRunning ( ! isRunning ) }
118+ onToggleTimer = { toggleTimer }
119+ onBreak = { handleBreak }
94120 onEndSession = { ( ) => {
95121 setIsRunning ( false ) ;
96122 setShowSummary ( true ) ;
97123 } }
98124 onClose = { handleCloseAttempt }
125+
126+ // Editing props
127+ isEditing = { ! isRunning } // Always allow editing when paused
128+ editedTime = { editedTime }
129+ onTimeEdit = { handleTimeEdit }
130+ showConfirmResume = { showConfirmResume }
131+ onConfirmResume = { confirmTimeUpdate }
132+ onCancelResume = { cancelTimeUpdate }
99133 />
100134 ) : (
101135 < div className = "flex flex-col items-center justify-center h-full text-center max-w-2xl mx-auto" >
0 commit comments