summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorJackson Moore <jacksonmoore@tuta.io>2026-09-04 12:01:42 +0200
committerJackson Moore <jacksonmoore@tuta.io>2026-09-04 12:01:42 +0200
commit154f639078470763fa788d31fac9b020d26b7825 (patch)
tree18631ade5694a03bd82ee0436c5e03533cef1d8f /lua
parentbd73a648242afb055d03406a87b67c156e087da2 (diff)
Discard terminal artifact packets
Diffstat (limited to 'lua')
-rw-r--r--lua/clever_f/acquisition_service.lua23
1 files changed, 22 insertions, 1 deletions
diff --git a/lua/clever_f/acquisition_service.lua b/lua/clever_f/acquisition_service.lua
index 99edf83..707f568 100644
--- a/lua/clever_f/acquisition_service.lua
+++ b/lua/clever_f/acquisition_service.lua
@@ -301,6 +301,27 @@ function AcquisitionService:started_scope_count()
return service_records[self].started_scope_count
end
+function M.is_terminal_artifact(packet)
+ packet = domain.InputPacket.from_table(packet)
+ if packet.kind ~= domain.InputPacketKind.RAW_BYTES then
+ return false
+ end
+ local bytes = packet:bytes()
+ return #bytes == 3
+ and bytes[1] == 0x80
+ and bytes[2] == 0xfd
+ and bytes[3] == 0x60
+end
+
+local function read_input_packet(host)
+ while true do
+ local packet = domain.InputPacket.from_table(host:read_input())
+ if not M.is_terminal_artifact(packet) then
+ return packet
+ end
+ end
+end
+
local function direct_preview_settings(policy_service)
if type(policy_service.sample_direct_preview) == "function" then
return policy_service:sample_direct_preview()
@@ -356,7 +377,7 @@ function AcquisitionService:acquire(descriptor, context, position, count, macro_
record.host:show_prompt(M.PROMPT)
end
record.transitions:BeginAcquisition(request.context, request.descriptor)
- scope:set_input_packet(domain.InputPacket.from_table(record.host:read_input()))
+ scope:set_input_packet(read_input_packet(record.host))
return request
end