Module TerminalState

Module TerminalState 

Source
Expand description

§TerminalState Module (ApplicationState)

§RESPONSIBILITIES

Manages terminal instances state including terminal metadata, content, and unique identifier tracking.

§ARCHITECTURAL ROLE

TerminalState is part of the FeatureState module, representing terminal instances state organized by terminal ID.

§KEY COMPONENTS

  • TerminalState: Main struct containing active terminals map and counter
  • Default: Initialization implementation
  • Helper methods: Terminal manipulation utilities

§ERROR HANDLING

  • Thread-safe access via Arc<Mutex<...>>
  • Proper lock error handling with MapLockError helpers

§LOGGING

State changes are logged at appropriate levels (debug, info, warn, error).

§PERFORMANCE CONSIDERATIONS

  • Lock mutexes briefly and release immediately
  • Avoid nested locks to prevent deadlocks
  • Use Arc for shared ownership across threads
  • Use double mutex for terminals (outer for map, inner for each terminal)

§TODO

  • Add terminal validation invariants
  • Implement terminal lifecycle events
  • Add terminal metrics collection

Structs§

TerminalState
Active terminals state containing terminals by ID with next identifier counter.