Conversation
bf2fffe to
f1efbe8
Compare
stalep
left a comment
There was a problem hiding this comment.
The storageBuffer is never reset. This means it would grow and cause a memory leak.
The close() method should perhaps flush the barrierBuffer?
There are several tests thats commented out which should be there and there are other tests that's redundant with the inclusion of jansi imo?
| flushIndex = writeIndex;//TODO testing if fixes double write | ||
| if (barrierBuffer.size() > 0) { | ||
| byte[] data = barrierBuffer.toByteArray(); | ||
| System.out.println("DEBUG: Capturing to Storage buffer: " + new String(data, StandardCharsets.UTF_8)); |
There was a problem hiding this comment.
Should change this to a logger if needed?
| superWrite(barrierBuffer.toByteArray(), 0, barrierBuffer.size()); | ||
| barrierBuffer.reset(); | ||
|
|
||
| System.out.println("DEBUG: Capturing to Storage buffer: " + new String(data, StandardCharsets.UTF_8)); |
There was a problem hiding this comment.
Should change this to a logger if needed?
| stream.flush(); | ||
|
|
||
| String buffered = stream.getBuffered(); | ||
| System.out.println("Captured: " + buffered); |
There was a problem hiding this comment.
Should change this to a logger if needed?
4a953a7 to
d516c1f
Compare
|
You seem to have included the commit I've made to fix the CI. I think it's best to keep those pr's separate. Can you please revert that an only have the changes for the issue you try to fix? |
a268dbb to
af5038b
Compare
|
There are still behavioral changes I think it's important that you look more into:
Removing
Pre-filtering before jansi: You're manually filtering null bytes, SHIFT_IN/OUT, #ESC, and ESC=/ESC> before passing to jansi. Consider which of these jansi already handles in strip mode and which are genuinely needed. If you need the pre-filtering, add a comment explaining why. Test coverage: You removed many tests that verified observable behavior (e.g., filter_K_noDigit, filter_all, filter_head, filter_tail, filter_questionMark_1h). The implementation changed, but the expected output for a given input Smaller things are commented out sout() lines which can be removed etc. Good luck! :) |
b3c5126 to
3c0cbeb
Compare
Added new Jansi version and modified the code as per the new version Refined escape sequence handling by adding a storage buffer which returns the data stored in the orignal buffer stream Added checks for Buffers to avoid OOM error and removed redundant test cases Fixed the stoageBuffer issue. Only the latest 20kb is returned.Also added reset() method
3c0cbeb to
bb1ea29
Compare
|
I explored replacing the custom ANSI stripping logic in EscapeFilteredStream with JLine's Jansi library (AnsiOutputStream in strip mode). Here is what I found: What Jansi handles Limitations: Non-ANSI Filtering: Jansi only looks for ESC sequences. We must still manually loop to filter Null bytes, Shift In, and Shift Out which aren't ANSI codes. Backspace (\b) — The zshShellTest failed. In zsh, the terminal sends something like e\b to redraw characters on screen. Our custom implementation stripped this correctly, but Jansi just passes it through as-is. I added a manual backspace handler but it only works when e and \b arrive in the same chunk. Because Jansi processes data byte by byte, they often arrive in separate flushes and the fix doesn't hold. RunTest.ctrlCTail and RunTest.watch_invoke_count - These tests append lines to a file and expect lines[0]="!", lines[1]="foo", lines[2]="bar". With Jansi, '!' was getting pushed to lines[1] instead of lines[0]. |
That may appear to be a fix for the observed issue in the test but that would unfortunately be a breaking change for users who rely on qDup to reliably emit each line of output from the remote session. There are use cases where a blank line in the output has meaning to the user. For example, a blank line can be used to separate logical chunks of data and We need to ensure qDup faithfully exposes the output of the commands used in the session to all parts of the user's script. |
…y. Now writing directly to jansistream
|
Fixed two test failures — RunTest was emitting empty lines due to Jansi flushing \r\n in separate chunks, and ZshShellTest was failing due to backspace characters arriving in a different chunk than the character they were meant to delete. Also cleaned up the implementation by removing the intermediate barrier buffer, with filtered data now written directly downstream via superWrite. |
Modified the escape filter stream code y adding another buffer to store the data and pass it to getBuffered() method before reseting the original buffer.