Three performance fixes identifying from profiling in Firefox. Using a test scenario of viewing "Run integration tests with Docker (docker-latest)" from https://code.forgejo.org/forgejo/runner, on a specific commit (`620f116a5f`), and expanding "Run all tests". This scenario renders 111,465 lines of log output into the browser (although many are hidden in groups).
- `const ansi_up = new AnsiUp();` creates an internal table of colour palettes on every call; so don't do it on every line. Shaves time spent in `createLogLine` from 1388ms -> 1022ms.
- `createLogLine` used DOM manipulation to create the line count, timestamp, log line, and seconds fields, which is slow when it needs to be performed at scale; so, replace it with building up the line element as text and using a single `innerHTML` parsing call. Shaves time spent in `createLogLine` from 1022ms -> 731ms.
- When processing logs, invoke `await scheduler.yield()` every 1000 lines.
- This allows the browser to not appear frozen, and to perform layout and render log lines very quickly.
- Disabled if `scheduler.yield` is not supported (primarily [Safari](https://caniuse.com/mdn-api_scheduler_yield))
- Downside: if you were to expand a log step, see the browser operating & available for interactions immediately, and Ctrl-F to search for contents, not all contents will be rendered on-screen yet.
There's still a reasonable amount of CPU time being spent on this operation, but the `scheduler.yield()` makes the browser feel snappy to interact with and log lines fill in quickly.
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/13597
Reviewed-by: Andreas Ahlenstorf <aahlenst@noreply.codeberg.org>
Job logs now render OSC 8 hyperlink escape sequences as clickable links in the Actions log viewer, so the Forgejo log has clickable links. A workflow step opts in by emitting the OSC 8 sequence (`ESC ] 8 ; ; <url> ESC \ <text> ESC ] 8 ; ; ESC \`), which is the same escape code terminals already use for links.
Hardens the anchors `ansi_up` emits: adds `rel="noopener noreferrer nofollow"` and `target="_blank"`, and drops any link whose scheme is not http or https.
## Checklist
### Tests for JavaScript changes
- I added test coverage for JavaScript changes...
- [x] in `web_src/js/*.test.js` if it can be unit tested.
- [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server.
### Documentation
- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [x] I did not document these changes and I do not expect someone else to do it.
### Release notes
- [x] This change will be noticed by a Forgejo user or admin (feature, bug fix, performance, etc.). I suggest to include a release note for this change.
- [ ] This change is not visible to a Forgejo user or admin (refactor, dependency upgrade, etc.). I think there is no need to add a release note for this change.
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/13085
Reviewed-by: Andreas Ahlenstorf <aahlenst@noreply.codeberg.org>
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
- Remove all [ConEMU OSC commands](https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC) from the output of Forgejo action logs when rendering.
- The regex is constructed as followed: Match the prefix `ESC ] 9 ;`. Then matches any number of digits, then match everything up to and including `ST` (this is either `ESC\` or `BELL`).
- Resolvesforgejo/forgejo#9244
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9875
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>