diff --git a/apps/tui/src/main/kotlin/com/correx/apps/tui/TuiApp.kt b/apps/tui/src/main/kotlin/com/correx/apps/tui/TuiApp.kt index ccb730fe..0a82d8aa 100644 --- a/apps/tui/src/main/kotlin/com/correx/apps/tui/TuiApp.kt +++ b/apps/tui/src/main/kotlin/com/correx/apps/tui/TuiApp.kt @@ -56,7 +56,7 @@ fun main(args: Array) { state = next effects.forEach { effect -> effectScope.launch { - EffectDispatcher(ws, effectScope) { runner.quit() }.dispatch(effect) + EffectDispatcher(ws) { runner.quit() }.dispatch(effect) } } } diff --git a/apps/tui/src/main/kotlin/com/correx/apps/tui/reducer/Effect.kt b/apps/tui/src/main/kotlin/com/correx/apps/tui/reducer/Effect.kt index 6733fd5e..e46daaec 100644 --- a/apps/tui/src/main/kotlin/com/correx/apps/tui/reducer/Effect.kt +++ b/apps/tui/src/main/kotlin/com/correx/apps/tui/reducer/Effect.kt @@ -1,11 +1,8 @@ package com.correx.apps.tui.reducer import com.correx.apps.server.protocol.ClientMessage -import com.correx.core.events.types.SessionId sealed interface Effect { data class SendWs(val message: ClientMessage) : Effect - data class ConnectSession(val sessionId: SessionId) : Effect - data object DisconnectSession: Effect data object Quit : Effect } diff --git a/apps/tui/src/main/kotlin/com/correx/apps/tui/reducer/EffectDispatcher.kt b/apps/tui/src/main/kotlin/com/correx/apps/tui/reducer/EffectDispatcher.kt index fa787820..5d132850 100644 --- a/apps/tui/src/main/kotlin/com/correx/apps/tui/reducer/EffectDispatcher.kt +++ b/apps/tui/src/main/kotlin/com/correx/apps/tui/reducer/EffectDispatcher.kt @@ -1,18 +1,14 @@ package com.correx.apps.tui.reducer import com.correx.apps.tui.ws.TuiWsClient -import kotlinx.coroutines.CoroutineScope class EffectDispatcher( private val wsClient: TuiWsClient, - private val effectScope: CoroutineScope, private val onQuit: () -> Unit, ) { suspend fun dispatch(effect: Effect) { when (effect) { is Effect.SendWs -> wsClient.send(effect.message) - is Effect.ConnectSession -> wsClient.connectSession(effect.sessionId, effectScope) - Effect.DisconnectSession -> wsClient.disconnectSession() Effect.Quit -> onQuit() } } diff --git a/apps/tui/src/main/kotlin/com/correx/apps/tui/reducer/SessionsReducer.kt b/apps/tui/src/main/kotlin/com/correx/apps/tui/reducer/SessionsReducer.kt index 582878b0..bdd069d6 100644 --- a/apps/tui/src/main/kotlin/com/correx/apps/tui/reducer/SessionsReducer.kt +++ b/apps/tui/src/main/kotlin/com/correx/apps/tui/reducer/SessionsReducer.kt @@ -131,7 +131,7 @@ object SessionsReducer { return sessionState.copy( sessions = sessionState.sessions + summary, selectedId = selected, - ) to listOf(Effect.ConnectSession(msg.sessionId)) + ) to emptyList() } private fun processToolRejectedMessage( @@ -300,21 +300,19 @@ object SessionsReducer { sessions: SessionsState, msg: ServerMessage.SessionFailed, clock: () -> Long, - ): Pair> = touchSession( + ): Pair> = touchSession( sessions, msg.sessionId.value, "FAILED", clock, - ) to listOf(Effect.DisconnectSession) + ) to emptyList() private fun processSessionCompletedMessage( sessions: SessionsState, msg: ServerMessage.SessionCompleted, clock: () -> Long, - ): Pair> = - touchSession(sessions, msg.sessionId.value, "COMPLETED", clock) to listOf( - Effect.DisconnectSession, - ) + ): Pair> = + touchSession(sessions, msg.sessionId.value, "COMPLETED", clock) to emptyList() private fun processSessionPausedMessage( msg: ServerMessage.SessionPaused,