refactor(protocol): share the echo acknowledgement delay
The client's round-trip correction copied the daemon's 50 ms echo acknowledgement delay as a separate literal. Both now use protocol.EchoAckDelay.
- commit
- 8442b743fe08c946e327593ebe8546e05d2525a3
- author
- brice · · 2026-10-08 06:01 UTC
- parent
- 706193c
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +12 -9
M internal/protocol/session.go +6 -0
| @@ -229,6 +229,12 @@ func (c ViewContext) Validate() error { | |||
| 229 | 229 | return domain.ValidatePaneStableID(c.FocusedPaneID) | |
| 230 | 230 | } | |
| 231 | 231 | ||
| 232 | + | // EchoAckDelay is how long sequenced input must have been applied before the | |
| 233 | + | // daemon acknowledges it in Output.Echo. Like mosh's ECHO_TIMEOUT, it gives the | |
| 234 | + | // PTY time to echo the input, so the screen published with the acknowledgement | |
| 235 | + | // already contains that echo. Clients remove it from round-trip samples. | |
| 236 | + | const EchoAckDelay = 50 * time.Millisecond | |
| 237 | + | ||
| 232 | 238 | type Output struct { | |
| 233 | 239 | Epoch uint64 | |
| 234 | 240 | Base uint64 | |
| @@ -229,6 +229,12 @@ func (c ViewContext) Validate() error { | |||||
| 229 | return domain.ValidatePaneStableID(c.FocusedPaneID) | 229 | return domain.ValidatePaneStableID(c.FocusedPaneID) | ||
| 230 | } | 230 | } | ||
| 231 | 231 | ||||
| 232 | + | // EchoAckDelay is how long sequenced input must have been applied before the | |||
| 233 | + | // daemon acknowledges it in Output.Echo. Like mosh's ECHO_TIMEOUT, it gives the | |||
| 234 | + | // PTY time to echo the input, so the screen published with the acknowledgement | |||
| 235 | + | // already contains that echo. Clients remove it from round-trip samples. | |||
| 236 | + | const EchoAckDelay = 50 * time.Millisecond | |||
| 237 | + | ||||
| 232 | type Output struct { | 238 | type Output struct { | ||
| 233 | Epoch uint64 | 239 | Epoch uint64 | ||
| 234 | Base uint64 | 240 | Base uint64 | ||
M internal/usecase/client/predictive_echo.go +3 -4
| @@ -47,10 +47,9 @@ const ( | |||
| 47 | 47 | echoGlitchRepairCount = 10 | |
| 48 | 48 | echoGlitchRepairMinInterval = 150 * time.Millisecond | |
| 49 | 49 | ||
| 50 | - | // echoServerDelay is the daemon's echo acknowledgement delay | |
| 51 | - | // (usecase/daemon echoAckDelay). It is removed from each round-trip | |
| 52 | - | // sample so the thresholds compare network time, as mosh's SRTT does. | |
| 53 | - | echoServerDelay = 50 * time.Millisecond | |
| 50 | + | // echoServerDelay is removed from each round-trip sample so the | |
| 51 | + | // thresholds compare network time, as mosh's SRTT does. | |
| 52 | + | echoServerDelay = protocol.EchoAckDelay | |
| 54 | 53 | ||
| 55 | 54 | // maxEchoSent bounds the send-time history used for round-trip samples. | |
| 56 | 55 | maxEchoSent = 256 | |
| @@ -47,10 +47,9 @@ const ( | |||||
| 47 | echoGlitchRepairCount = 10 | 47 | echoGlitchRepairCount = 10 | ||
| 48 | echoGlitchRepairMinInterval = 150 * time.Millisecond | 48 | echoGlitchRepairMinInterval = 150 * time.Millisecond | ||
| 49 | 49 | ||||
| 50 | - | // echoServerDelay is the daemon's echo acknowledgement delay | 50 | + | // echoServerDelay is removed from each round-trip sample so the |
| 51 | - | // (usecase/daemon echoAckDelay). It is removed from each round-trip | 51 | + | // thresholds compare network time, as mosh's SRTT does. |
| 52 | - | // sample so the thresholds compare network time, as mosh's SRTT does. | 52 | + | echoServerDelay = protocol.EchoAckDelay |
| 53 | - | echoServerDelay = 50 * time.Millisecond | |||
| 54 | 53 | ||||
| 55 | // maxEchoSent bounds the send-time history used for round-trip samples. | 54 | // maxEchoSent bounds the send-time history used for round-trip samples. | ||
| 56 | maxEchoSent = 256 | 55 | maxEchoSent = 256 | ||
M internal/usecase/daemon/echo_ack.go +3 -5
| @@ -5,13 +5,11 @@ import ( | |||
| 5 | 5 | "time" | |
| 6 | 6 | ||
| 7 | 7 | "github.com/bnema/vev/internal/ports" | |
| 8 | + | "github.com/bnema/vev/internal/protocol" | |
| 8 | 9 | ) | |
| 9 | 10 | ||
| 10 | - | // echoAckDelay is how long sequenced input must have been applied before the | |
| 11 | - | // daemon acknowledges it in Output.Echo. Like mosh's ECHO_TIMEOUT, it gives the | |
| 12 | - | // PTY time to echo the input, so the screen published with the acknowledgement | |
| 13 | - | // already contains whatever echo the input produced. | |
| 14 | - | const echoAckDelay = 50 * time.Millisecond | |
| 11 | + | // echoAckDelay is the protocol's echo acknowledgement delay. | |
| 12 | + | const echoAckDelay = protocol.EchoAckDelay | |
| 15 | 13 | ||
| 16 | 14 | // maxPendingEchoes bounds the per-attachment input history. Acknowledgements | |
| 17 | 15 | // are cumulative, so dropping the oldest entry only delays its confirmation to | |
| @@ -5,13 +5,11 @@ import ( | |||||
| 5 | "time" | 5 | "time" | ||
| 6 | 6 | ||||
| 7 | "github.com/bnema/vev/internal/ports" | 7 | "github.com/bnema/vev/internal/ports" | ||
| 8 | + | "github.com/bnema/vev/internal/protocol" | |||
| 8 | ) | 9 | ) | ||
| 9 | 10 | ||||
| 10 | - | // echoAckDelay is how long sequenced input must have been applied before the | 11 | + | // echoAckDelay is the protocol's echo acknowledgement delay. |
| 11 | - | // daemon acknowledges it in Output.Echo. Like mosh's ECHO_TIMEOUT, it gives the | 12 | + | const echoAckDelay = protocol.EchoAckDelay |
| 12 | - | // PTY time to echo the input, so the screen published with the acknowledgement | |||
| 13 | - | // already contains whatever echo the input produced. | |||
| 14 | - | const echoAckDelay = 50 * time.Millisecond | |||
| 15 | 13 | ||||
| 16 | // maxPendingEchoes bounds the per-attachment input history. Acknowledgements | 14 | // maxPendingEchoes bounds the per-attachment input history. Acknowledgements | ||
| 17 | // are cumulative, so dropping the oldest entry only delays its confirmation to | 15 | // are cumulative, so dropping the oldest entry only delays its confirmation to | ||