Commit0671cd11Recorded10 Aug 2026Repositorysigil-irc

feat(irc-ws): add irc-ws-receive-line raw transport for Enclave

Message

irc-ws-receive-line returns the WebSocket payload for one IRC command per frame directly, instead of routing opaque Enclave stream tickets through the parsed IRC queue. It unwraps a ws-message (text) or accepts a raw string, and latches the session dead only on a genuine close.

The ws-message unwrap is required because (sigil websocket) ws-receive is on the MESSAGE path (binary frames must flow for the terminal stream relay); imports (sigil websocket connection) for ws-message? / ws-message-type.

Provenance: the irc-ws-receive-line function is prior-session work from the 2026-08-06..08-10 Slate/Enclave remote-terminal investigation; committed during cleanup, not authored here. The ws-message-unwrap branch was added by this session's terminal-stream work.

Changed
 packages/sigil-irc-websocket/src/sigil/irc/websocket.sgl | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)
Diff
packages/sigil-irc-websocket/src/sigil/irc/websocket.sglmodified
@@ -11,7 +11,7 @@
11
(sigil math)
12
(sigil string)
13
(sigil struct)
−14
(sigil websocket)
+14
(sigil websocket connection)
15
(sigil irc message))
16
17
(export
@@ -51,7 +51,8 @@
51
irc-ws-part
52
irc-ws-quit
53
−54
irc-ws-receive)
+54
irc-ws-receive
+55
irc-ws-receive-line)
56
57
(begin
58
@@ -561,6 +562,33 @@
562
(irc-ws-command session "QUIT")))
563
(irc-ws-close session))
564
+565
(define (irc-ws-receive-line session)
+566
(: irc-ws-session? -> any?)
+567
;; Enclave sends one IRC command per WebSocket text message. Return that
+568
;; transport payload directly: routing it through the parsed IRC queue is
+569
;; both unnecessary and unsafe for opaque stream tickets in native builds.
+570
(let ((websocket (irc-ws-session-websocket session)))
+571
(if (not websocket)
+572
'closed
+573
(let ((message (ws-receive websocket)))
+574
(cond
+575
;; This is the raw transport API. Preserve the WebSocket text
+576
;; payload exactly; callers that consume IRC lines already own
+577
;; CRLF splitting. Besides avoiding duplicate work, this keeps
+578
;; opaque Enclave stream tickets out of the generic line helper.
+579
;; ws-receive is back on the MESSAGE path (binary frames must
+580
;; flow for the terminal stream relay), so unwrap text here.
+581
((and (ws-message? message)
+582
(eq? (ws-message-type message) 'text))
+583
(ws-message-data message))
+584
((string? message) message)
+585
;; Latch the session dead ONLY on a genuine close. This relies
+586
;; on ws-receive returning #f while an async socket is opening.
+587
((eq? message 'closed)
+588
(set-irc-ws-session-state! session 'disconnected)
+589
'closed)
+590
(else message))))))
+591
592
(define (irc-ws-receive session)
593
(: irc-ws-session? -> any?)
594
(let ((queued (pop-message! session)))