frame.go RawHistoryFolder
1package ports
2
3import (
4 "time"
5
6 renderer "github.com/bnema/vev-vt"
7 "github.com/bnema/vev/internal/domain"
8)
9
10// HandshakeTimeout bounds every transport handshake from connect through the
11// first committed publication.
12const HandshakeTimeout = 15 * time.Second
13
14// ProtocolVersion is the current vev IPC wire protocol version.
15const ProtocolVersion uint16 = 29
16
17// MaxFrameLen is the largest permitted frame length, including the type byte
18// and excluding the four-byte length prefix.
19const MaxFrameLen = 16 << 20
20
21// MsgType identifies the kind of payload carried by a Frame.
22type MsgType uint8
23
24// Frame message types. Client-originated messages occupy 1–13 and 15;
25// server-originated messages occupy 16–23 and 25–31. Values 14 and 24 remain
26// reserved for future extensions. Route metadata/navigation messages use the
27// post-26 range.
28const (
29 MsgHello MsgType = 1
30 MsgInput MsgType = 2
31 MsgResize MsgType = 3
32 MsgDetach MsgType = 4
33 MsgPing MsgType = 5
34 MsgList MsgType = 6
35 MsgKill MsgType = 7
36 MsgTheme MsgType = 8
37 MsgAck MsgType = 9
38 MsgImagePush MsgType = 10
39 MsgClientNotice MsgType = 11
40 MsgCommand MsgType = 12
41 MsgOutputResetRequest MsgType = 13
42 MsgRemotePreviewRequest MsgType = 15
43
44 MsgWelcome MsgType = 16
45 MsgError MsgType = 17
46 MsgOutput MsgType = 18
47 MsgDetached MsgType = 19
48 MsgPong MsgType = 20
49 MsgSessions MsgType = 21
50 MsgCommandResult MsgType = 22
51 MsgNavigationAction MsgType = 23
52 MsgAttachTarget MsgType = 25
53 MsgRemotePreviewResponse MsgType = 26
54 // Route navigation metadata/control frames occupy the post-26 server range;
55 // 14 and 24 remain reserved for compatibility with older peers.
56 MsgCommittedRouteIdentity MsgType = 27
57 MsgRecentRouteSnapshot MsgType = 28
58 MsgNavigateRecentRoute MsgType = 29
59 MsgRouteNavigationFailure MsgType = 30
60 MsgRoutePosition MsgType = 31
61)
62
63// Frame is the unit of exchange over a Transport: a typed, length-delimited
64// message. It lives in ports (rather than an ipc adapter) so usecases and
65// adapters can share it without either depending on a concrete transport
66// implementation.
67type Frame struct {
68 Type MsgType
69 Payload []byte
70}
71
72// NavigationCapabilities advertises the bounded client routes available to a
73// directly attached daemon.
74type NavigationCapabilities uint8
75
76const (
77 NavigationCapabilityHomePicker NavigationCapabilities = 1 << iota
78 NavigationCapabilityBack
79)
80
81// StartupOverlay selects the one startup overlay opened by a navigation route.
82type StartupOverlay uint8
83
84const (
85 StartupOverlayNone StartupOverlay = iota
86 StartupOverlaySessionPicker
87)
88
89// NavigationAction is a server request for one bounded client route transition.
90type NavigationAction uint8
91
92const (
93 NavigationOpenHomePicker NavigationAction = 1
94 NavigationBack NavigationAction = 2
95)
96
97// RemotePreviewSchemaVersion is independent from the attachment IPC version.
98const RemotePreviewSchemaVersion uint16 = 1
99
100// RemotePreviewStatus is a closed response taxonomy. Terminal contents are
101// never carried in an error response.
102type RemotePreviewStatus uint8
103
104const (
105 RemotePreviewOK RemotePreviewStatus = iota
106 RemotePreviewUnavailable
107 RemotePreviewNoSuchTarget
108 RemotePreviewStale
109 RemotePreviewMalformed
110 RemotePreviewTooLarge
111)
112
113// RemotePreviewRequest asks the owning daemon for an in-memory live viewport.
114type RemotePreviewRequest struct {
115 Version uint16
116 Target domain.RemoteSessionTarget
117 Width uint16
118 Height uint16
119}
120
121// RemotePreview is a bounded row-major styled-cell viewport. It is a
122// process-memory DTO and is never persisted, logged, or traced.
123type RemotePreview struct {
124 Version uint16
125 Status RemotePreviewStatus
126 LifecycleID domain.SessionLifecycleID
127 TabID domain.TabStableID
128 Revision uint64
129 Width uint16
130 Height uint16
131 Cells []renderer.Cell
132}