Skip to content

Conversation

@panicking
Copy link
Contributor

@panicking panicking commented Dec 21, 2025

src: Add deep link to error log source in explanation UI

This commit introduces a "View Full Report" button within the AI Error
Explanation UI. This allows users to navigate directly from the AI
summary to the specific location of the failure.

image image

Related to #61

@panicking panicking requested a review from a team as a code owner December 21, 2025 17:13
@panicking panicking force-pushed the add-link-support-error branch from 431ef38 to 441913b Compare December 21, 2025 22:03
@shenxianpeng shenxianpeng requested a review from Copilot December 25, 2025 16:11
@shenxianpeng shenxianpeng added the enhancement For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted label Dec 25, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds deep linking functionality to the AI Error Explanation UI, allowing users to navigate directly from the AI summary to the specific location of the failure in the build log or pipeline overview.

Key Changes

  • Introduced PipelineLogExtractor class to extract logs from failed pipeline steps and generate appropriate URLs
  • Updated ErrorExplanationAction to store and expose the URL for error source navigation
  • Added "View Build Log" buttons in both the standalone explanation page and console footer UI

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
src/main/java/io/jenkins/plugins/explain_error/PipelineLogExtractor.java New class that extracts pipeline step logs and generates URLs to error sources, with optional pipeline-graph-view integration
src/main/java/io/jenkins/plugins/explain_error/ErrorExplanationAction.java Added urlString field to store the error source URL and expose it via getter method
src/main/java/io/jenkins/plugins/explain_error/ErrorExplainer.java Integrated PipelineLogExtractor to capture URLs during error log extraction
src/main/java/io/jenkins/plugins/explain_error/ConsoleExplainErrorAction.java Updated to use PipelineLogExtractor and include URL in JSON response for AJAX requests
src/main/resources/io/jenkins/plugins/explain_error/ErrorExplanationAction/index.jelly Added "View Build Log" button that links to the error source URL
src/main/resources/io/jenkins/plugins/explain_error/ConsolePageDecorator/footer.jelly Added "View Build Log" button in the console footer explanation card
src/main/webapp/js/explain-error-footer.js Updated to handle URL from JSON response and set href attribute on the link element
src/test/java/io/jenkins/plugins/explain_error/ErrorExplanationActionTest.java Updated all test cases to use new constructor signature with urlString parameter
src/test/java/io/jenkins/plugins/explain_error/ErrorExplainerTest.java Updated test cases to pass urlString parameter to explainErrorText method
src/test/java/io/jenkins/plugins/explain_error/ConsolePageDecoratorTest.java Updated test to use new ErrorExplanationAction constructor signature
src/test/java/io/jenkins/plugins/explain_error/provider/TestProvider.java Removed unused List import
src/main/java/io/jenkins/plugins/explain_error/ConsolePageDecorator.java Removed unused StaplerRequest2 import
pom.xml Added workflow-api, workflow-job, and pipeline-graph-view dependencies to support pipeline log extraction
Comments suppressed due to low confidence (1)

src/main/java/io/jenkins/plugins/explain_error/ErrorExplanationAction.java:31

  • The urlString field is not initialized in the readResolve() method, which means it will be null when deserializing old ErrorExplanationAction instances that were saved before this field was added. This could cause NullPointerExceptions when accessing the URL in the UI. Consider initializing urlString to an empty string or a default console URL in readResolve().
    public Object readResolve() {
        if (providerName == null) {
            providerName = "Unknown";
        }
        return this;
    }

@shenxianpeng
Copy link
Member

image

I’m not sure this is strictly necessary, since users can already click the "Pipeline Overview" button to reach the same page (it navigates to the failed step by default).

From a UI perspective, a couple of points to consider:

  1. The button is quite long and behaves differently from other buttons—it resizes based on the window size.
  2. There’s no spacing between this button and the AI Error Explanation section.

If it really needs it, it might be better to align its style with existing buttons. For example:

image

@shenxianpeng shenxianpeng changed the title Add link support error Add deep link to AI Error Explanation UI Dec 25, 2025
@panicking
Copy link
Contributor Author

image I’m not sure this is strictly necessary, since users can already click the "Pipeline Overview" button to reach the same page (it navigates to the failed step by default).

From a UI perspective, a couple of points to consider:

  1. The button is quite long and behaves differently from other buttons—it resizes based on the window size.
  2. There’s no spacing between this button and the AI Error Explanation section.

If it really needs it, it might be better to align its style with existing buttons. For example:

image

I like your idea but I'm not good in this, can you give me some help to make it nicer?

@panicking
Copy link
Contributor Author

image I’m not sure this is strictly necessary, since users can already click the "Pipeline Overview" button to reach the same page (it navigates to the failed step by default). From a UI perspective, a couple of points to consider:
  1. The button is quite long and behaves differently from other buttons—it resizes based on the window size.
  2. There’s no spacing between this button and the AI Error Explanation section.

If it really needs it, it might be better to align its style with existing buttons. For example:
image

I like your idea but I'm not good in this, can you give me some help to make it nicer?

In general the idea is to post the link of ExplainError to mattermost and user click the reaso of the error, and if they need to take a look of the error code they can then get the link direct from there

@panicking
Copy link
Contributor Author

image

@panicking panicking force-pushed the add-link-support-error branch from 441913b to e8c06f6 Compare December 26, 2025 10:27
@shenxianpeng
Copy link
Member

The image I shared earlier was taken from the current Jenkins UI

image

The new button you posted looks better. Compared with the existing UI style, there are a few alignment and consistency issues:

  1. There’s no spacing between this button and the AI Error Explanation section.
  2. The button's curvature is circular; a square shape would be preferable.
  3. Refer to the current name in Jenkins(like View as plain text and View classic console); a name like "View failure output" (or something similar) might be more appropriate than the current name.

@panicking panicking force-pushed the add-link-support-error branch from e8c06f6 to bc8c41d Compare December 27, 2025 13:59
@panicking
Copy link
Contributor Author

panicking commented Dec 27, 2025

The image I shared earlier was taken from the current Jenkins UI

image The new button you posted looks better. Compared with the existing UI style, there are a few alignment and consistency issues:
  1. There’s no spacing between this button and the AI Error Explanation section.
  2. The button's curvature is circular; a square shape would be preferable.
  3. Refer to the current name in Jenkins(like View as plain text and View classic console); a name like "View failure output" (or something similar) might be more appropriate than the current name.
image

@shenxianpeng What about this change?

@panicking panicking force-pushed the add-link-support-error branch from bc8c41d to d74b430 Compare December 27, 2025 14:04
@panicking
Copy link
Contributor Author

@shenxianpeng everything look ok but I need to drop maxLines = 100. I need to check because in general for gradle build of mobile applicaiton, the lines neeed are more then 100 but in the same time the number of token needed can exceed the ai max token

@panicking panicking force-pushed the add-link-support-error branch from d74b430 to 1abcc82 Compare December 29, 2025 20:58
@shenxianpeng
Copy link
Member

Sorry for the late reply. I’m currently on vacation and have limited time to try out the changes on my laptop.

At first glance, I noticed that you introduced a new CSS file, and I wasn’t sure whether this is something we’re expected to create ourselves.

@panicking
Copy link
Contributor Author

Sorry for the late reply. I’m currently on vacation and have limited time to try out the changes on my laptop.

At first glance, I noticed that you introduced a new CSS file, and I wasn’t sure whether this is something we’re expected to create ourselves.

@shenxianpeng I get some of the type from the pipeline-graph view and icon is standard. @mawinter69 what is the right way here?

</div>
<pre id="explain-error-content" class="jenkins-!-margin-bottom-0 ${hasExplanation?'':'jenkins-hidden'}">${hasExplanation ? existingExplanation.explanation : ''}</pre>
<div class="jenkins-!-margin-top-3">
<a id="explain-error-url" href="${hasExplanation ? existingExplanation.urlString: ''}" class="build-status-pill ${hasExplanation?'':'jenkins-hidden'}" target="_self" >
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should try with jenkins-button jenkins-!-destructive-color and remove your own class.
That way you ensure that you get consistent UI elements out of the box that work with other color themes, e.g. dark-theme.
See also Buttons in design library. You can also apply that to links

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In complex pipeline we can find the node that generate the
error and just get that one back to the ErrorExplainer.

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
@panicking panicking force-pushed the add-link-support-error branch from 1abcc82 to 5d3d0ae Compare December 31, 2025 16:20
@panicking panicking requested a review from mawinter69 December 31, 2025 16:25
@panicking panicking force-pushed the add-link-support-error branch from 5d3d0ae to 72ad066 Compare December 31, 2025 23:48
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
This commit introduces a "View Full Report" button within the AI Error
Explanation UI. This allows users to navigate directly from the AI
summary to the specific location of the failure.

Key changes:
- Logic: Updated `PipelineLogExtractor` to generate a URL for the
  failed step. It attempts to construct a deep link to the
  `pipeline-graph-view` (e.g., `?selected-node=ID`) or falls back
  to the standard console output.
- Dependencies: Added `io.jenkins.plugins:pipeline-graph-view` as an
  optional dependency to support node-specific linking.
- UI: Added a "View Full Report" button in `footer.jelly` and
  `index.jelly` that links to the extracted URL.
- JavaScript: Updated `explain-error-footer.js` to handle the URL
  payload in the JSON response.
- Tests: Updated `ErrorExplainerTest`, `ErrorExplanationActionTest`,
  and `ConsolePageDecoratorTest` to match updated method signatures.

Style and Icons are get from standard jenkins style and icon plugin,
as suggested by Markus Winter

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
@panicking panicking force-pushed the add-link-support-error branch from 72ad066 to 9194a12 Compare January 2, 2026 06:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

src/main/java/io/jenkins/plugins/explain_error/ErrorExplanationAction.java:31

  • The readResolve method should handle backward compatibility for the new urlString field. When deserializing old ErrorExplanationAction instances that don't have the urlString field, it will be null. The method should initialize urlString to an empty string or a default value (like console URL) to prevent NullPointerException when the field is accessed in the UI templates.
    public Object readResolve() {
        if (providerName == null) {
            providerName = "Unknown";
        }
        return this;
    }

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@shenxianpeng shenxianpeng merged commit 26a5376 into jenkinsci:main Jan 3, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants