feat(tui-01): add snapshot phase, pending events, and cursor tracking to TuiState
Add three new fields to support the snapshot/live streaming protocol phase: - snapshotPhase: Boolean (true during initial snapshot) - pendingEvents: List<ServerMessage> (FIFO buffer during snapshot) - cursors: Map<String, Long> (per-session high-water marks for deduplication) All fields include KDoc documenting their invariants and purpose. Additive change only; all existing tests continue to pass.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.correx.apps.tui.state
|
||||
|
||||
import com.correx.apps.server.protocol.ServerMessage
|
||||
|
||||
enum class InputMode { ROUTER, NAVIGATE, FILTER, STEER }
|
||||
|
||||
enum class ToolDisplayStatus { REQUESTED, STARTED, COMPLETED, FAILED, REJECTED }
|
||||
@@ -33,6 +35,21 @@ data class TuiState(
|
||||
val providerType: ProviderType = ProviderType.LOCAL,
|
||||
val routerConnected: Boolean = false,
|
||||
val routerMessages: List<String> = emptyList(),
|
||||
/**
|
||||
* True from connect until SnapshotComplete observed. Reset to true on Disconnected.
|
||||
* When true, event-bearing messages are buffered in [pendingEvents]; snapshots are applied immediately.
|
||||
*/
|
||||
val snapshotPhase: Boolean = true,
|
||||
/**
|
||||
* FIFO buffer of event-bearing server messages received while snapshotPhase == true.
|
||||
* Drained atomically when snapshot phase completes.
|
||||
*/
|
||||
val pendingEvents: List<ServerMessage> = emptyList(),
|
||||
/**
|
||||
* Per-session high-water mark keyed by SessionId.value. Updated only on applied live events.
|
||||
* Used to deduplicate events during live streaming phase.
|
||||
*/
|
||||
val cursors: Map<String, Long> = emptyMap(),
|
||||
)
|
||||
|
||||
data class SessionSummary(
|
||||
|
||||
@@ -12,6 +12,14 @@ class RootReducerTest {
|
||||
|
||||
private val fixedClock: () -> Long = { 1000L }
|
||||
|
||||
@Test
|
||||
fun `TuiState defaults include snapshot phase, pending events, and cursors`() {
|
||||
val state = TuiState()
|
||||
assertEquals(true, state.snapshotPhase)
|
||||
assertEquals(emptyList<Any>(), state.pendingEvents)
|
||||
assertEquals(emptyMap<String, Long>(), state.cursors)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `SubmitInput in ROUTER mode emits StartSession effect and resets buffer`() {
|
||||
val initial = TuiState(inputMode = InputMode.ROUTER, inputBuffer = "my-workflow")
|
||||
|
||||
Reference in New Issue
Block a user