Comments (5)
Test case: raw_ansi_output.log
from terminal-to-html.
Ooh interesting ๐๐ผ
from terminal-to-html.
I have a simplified reproduction based on that ๐๐ผ
You're on the money, the output is using CSI n D
/ CUB
/ Cursor Back
by n
characters to overwrite the progress bar, and each _bk;ts=โฆ
timestamp throughout the line is consuming one of those CUB
s.
I'll try to turn that into a test case and fix.
from terminal-to-html.
I wonder if this is also a bug in the agent's timestamping.
The timestamps in your raw_ansi_output.log
appear in patterns roughly like this:
Hello
<ESC>[0K
<ESC>_bk;ts=โฆ
<ESC>[5D
<ESC>[1B
<ESC>[1A
Which means:
Hello
โ ๐๐ผ some text already on the line<ESC>[0K
โย EL: Erase in Line (n=0: clear from cursor to the end of the line)<ESC>_bk;ts=โฆ
โย Buildkite start of line timestamp<ESC>[5D
โย CUB: Cursor Back (5 cells)<ESC>[1B
โย CUD: Cursor Down 1 line<ESC>[1A
โ CUU: Cursor Up 1 line
โฆ That's not where we should be putting a timestamp. The <ESC>[0K
is basically saying โI've overwritten part of this line, now ensure everything after the cursor is blanked, in case the old line was longerโ. So we're not at the start of a line.
It would be nice if it didn't cause rendering bugs, but that's a separate issue โ even if resolved, it would leave out of order timestamps etc.
from terminal-to-html.
In the agent a log Prefixer is used to prefix lines with ANSI timestamp, and here's it's detection of escape codes that indicate a new line:
// This regex matches "Erase in Line" escape characters:
// [K Clear from cursor to the end of the line
// [1K Clear from cursor to beginning of the line
// [2K Clear entire line
var lineBreakEscapeCharRegex = regexp.MustCompile(`^\[[012]?K`)
We can see [K Clear from cursor to the end of the line
is included intentionally, and also the equivalent [0K
is handled by the regexp character class.
Here's the Wikipedia description of [nK
:
Clears part of the screen. If n is 0 (or missing), clear from cursor to end of screen. If n is 1, clear from cursor to beginning of the screen. If n is 2, clear entire screen (and moves cursor to upper left on DOS ANSI.SYS). If n is 3, clear entire screen and delete all lines saved in the scrollback buffer (this feature was added for xterm and is supported by other terminal applications).
I imagine we want timestamps in the subset of cases where one of those clears the entire line; including perhaps [0K
when the cursor is at the start of the line but not when it's mid-line. But maybe just not at all.
Fortunately ansi-timestamps
is still in experiment status, so I think we have a bit more freedom to change this behaviour. /cc @moskyb
from terminal-to-html.
Related Issues (20)
- APC with standard ST terminator would break parser
- Published docker image HOT 3
- pkg.go.dev does not recognize your LICENSE HOT 1
- Support Buildkite log groups and expand/collapsing
- DECSC / DECRC should save more than cursor position
- Request to take ownership of the terminal Ruby gem HOT 6
- Prevent wrapping long lines on small screens HOT 4
- Support for terminal URLs HOT 2
- Incorrect output for `playwright` output - lines being incorrectly removed
- (feature request) Automatically add links for URLs HOT 1
- terminal-to-html imposes odd formatting on Terraform plans HOT 3
- Garbled output from Gradle HOT 8
- [Feature request] Add an option to customize title of output HTML HOT 1
- Dockerfile out of date?
- Add support to install with homebrew HOT 1
- Flaky test: TestRendererAgainstCases renders APC escapes as processing instructions
- Add the remaining 8-bit colors to the css
- Add checksum for an archive while downloading
- Ignore 2J & 3J "scrollback clear" codes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terminal-to-html.