Commit graph

6 commits

Author SHA1 Message Date
Mathieu Fenniak
c431769ff6 fix(perf): improve performance of viewing long actions logs (#13597)
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>
2026-07-24 17:32:10 +02:00
Dax Kelson
4fe694fef7 feat: render OSC 8 sequences safely (#13085)
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>
2026-07-06 05:20:09 +02:00
Gusted
0869e0e08a fix: don't show ConEmu OSC escape sequences (#9875)
- 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`).
- Resolves forgejo/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>
2025-10-31 07:24:23 +01:00
silverwind
5feef6d5c0
Update JS dependencies (#26586)
- Update all JS dependencies
- Adapt `ansi_up` import for ESM
- Tested Mermaid and Ansi rendering
2023-08-19 10:18:39 +02:00
silverwind
fdab4e3d84
Add custom ansi colors and CSS variables for them (#25546)
Use our existing color palette to map to the 16 basic ansi colors. This
is backwards-compatible because it aliases the existing color names.

Side note: I think the colors in `console.css` for console file
rendering are incomplete, but fixing those is out of scope here imo.

Before and after:

<img width="542" alt="Screenshot 2023-06-28 at 00 26 12"
src="https://github.com/go-gitea/gitea/assets/115237/86d41884-bc47-4e85-8aec-621eb7320f0b">

<img width="546" alt="Screenshot 2023-06-28 at 00 28 24"
src="https://github.com/go-gitea/gitea/assets/115237/39fa3b37-d49e-49b1-b6bc-390ac8ca24b2">

---------

Co-authored-by: Giteabot <teabot@gitea.io>
2023-06-28 15:38:55 +02:00
silverwind
93cd579269
Switch to ansi_up for ansi rendering in actions (#25401)
Fixes: https://github.com/go-gitea/gitea/issues/24777
2023-06-22 02:15:19 +00:00