From 154f639078470763fa788d31fac9b020d26b7825 Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Fri, 4 Sep 2026 12:01:42 +0200 Subject: Discard terminal artifact packets --- lua/clever_f/acquisition_service.lua | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'lua/clever_f') 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 -- cgit v1.2.3