@@ -23,6 +23,9 @@ export class Session {
2323
2424 /** Callbacks to be notified when session ID is found/changed */
2525 private sessionFoundCallbacks : ( ( sessionId : string ) => void ) [ ] = [ ] ;
26+
27+ /** Keep alive interval reference for cleanup */
28+ private keepAliveInterval : NodeJS . Timeout ;
2629
2730 constructor ( opts : {
2831 api : ApiClient ,
@@ -54,10 +57,19 @@ export class Session {
5457
5558 // Start keep alive
5659 this . client . keepAlive ( this . thinking , this . mode ) ;
57- setInterval ( ( ) => {
60+ this . keepAliveInterval = setInterval ( ( ) => {
5861 this . client . keepAlive ( this . thinking , this . mode ) ;
5962 } , 2000 ) ;
6063 }
64+
65+ /**
66+ * Cleanup resources (call when session is no longer needed)
67+ */
68+ cleanup = ( ) : void => {
69+ clearInterval ( this . keepAliveInterval ) ;
70+ this . sessionFoundCallbacks = [ ] ;
71+ logger . debug ( '[Session] Cleaned up resources' ) ;
72+ }
6173
6274 onThinkingChange = ( thinking : boolean ) => {
6375 this . thinking = thinking ;
@@ -113,14 +125,21 @@ export class Session {
113125
114126 /**
115127 * Consume one-time Claude flags from claudeArgs after Claude spawn
116- * Currently handles : --resume (with or without session ID)
128+ * Handles : --resume (with or without session ID), --continue
117129 */
118130 consumeOneTimeFlags = ( ) : void => {
119131 if ( ! this . claudeArgs ) return ;
120132
121133 const filteredArgs : string [ ] = [ ] ;
122134 for ( let i = 0 ; i < this . claudeArgs . length ; i ++ ) {
123- if ( this . claudeArgs [ i ] === '--resume' ) {
135+ const arg = this . claudeArgs [ i ] ;
136+
137+ if ( arg === '--continue' ) {
138+ logger . debug ( '[Session] Consumed --continue flag' ) ;
139+ continue ;
140+ }
141+
142+ if ( arg === '--resume' ) {
124143 // Check if next arg looks like a UUID (contains dashes and alphanumeric)
125144 if ( i + 1 < this . claudeArgs . length ) {
126145 const nextArg = this . claudeArgs [ i + 1 ] ;
@@ -137,9 +156,10 @@ export class Session {
137156 // --resume at the end of args
138157 logger . debug ( '[Session] Consumed --resume flag (no session ID)' ) ;
139158 }
140- } else {
141- filteredArgs . push ( this . claudeArgs [ i ] ) ;
159+ continue ;
142160 }
161+
162+ filteredArgs . push ( arg ) ;
143163 }
144164
145165 this . claudeArgs = filteredArgs . length > 0 ? filteredArgs : undefined ;
0 commit comments