feat: add Pipeline Graph View integration for AI Explain#191
Draft
shenxianpeng wants to merge 2 commits into
Draft
feat: add Pipeline Graph View integration for AI Explain#191shenxianpeng wants to merge 2 commits into
shenxianpeng wants to merge 2 commits into
Conversation
Add an 'Explain Error' button to the Pipeline Graph View page that appears when a failed node is selected. The feature reuses the existing ErrorExplanationAction caching mechanism (shows cached explanation when available, generates a new one otherwise). New files: - GraphViewExplainErrorAction: RunAction2 with AJAX endpoints for checking node failure status and triggering AI explanations - GraphViewExplainErrorActionFactory: TransientActionFactory that injects the action into all runs (only when pipeline-graph-view is installed) - PipelineGraphViewDecorator: PageDecorator that injects JS into the /stages page - explain-error-graph-view.js: Frontend logic for monitoring node selection, showing/hiding the Explain button, and displaying results - GraphViewExplainErrorActionTest: 13 unit tests covering build status checks, node status queries, cache hits, and force-new generation Modified files: - PipelineLogExtractor: added extractNodeLog(String nodeId) method to extract logs from a specific flow node by ID
| org.jenkinsci.plugins.workflow.job.WorkflowRun pipelineRun = | ||
| rule.buildAndAssertSuccess(job); | ||
|
|
||
| GraphViewExplainErrorAction pipelineAction = new GraphViewExplainErrorAction(pipelineRun); |
| * Returns JSON with buildingStatus: 0 = SUCCESS, 1 = RUNNING, 2 = FINISHED and FAILURE. | ||
| */ | ||
| @RequirePOST | ||
| public void doCheckBuildStatus(StaplerRequest2 req, StaplerResponse2 rsp) { |
- PipelineGraphViewDecorator.isPluginActive(): fix regex to match URLs with trailing slash like /job/xxx/1/stages/ (the PageDecorator renders as a Tab with trailing slash). Also add null check for Stapler.getCurrentRequest2(). - explain-error-graph-view.js: wrap history.pushState and history.replaceState to dispatch a custom 'urlchange' event, since the Pipeline Graph View plugin uses replaceState for node selection (which does not fire popstate). Reduce polling interval from 1500ms to 500ms as a fallback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an Explain Error button to the Pipeline Graph View page that appears when a user selects a failed node. The feature reuses the existing
ErrorExplanationActioncaching mechanism — showing a cached explanation when available, generating a new AI explanation otherwise.Changes
New files
GraphViewExplainErrorAction.javaRunAction2providing AJAX endpoints:doCheckBuildStatus,doCheckNodeStatus,doExplainNodeErrorGraphViewExplainErrorActionFactory.javaTransientActionFactorythat injects the action into all runs (only whenpipeline-graph-viewis installed)PipelineGraphViewDecorator.javaPageDecoratorthat injects JS/CSS into the*/stagespageexplain-error-graph-view.js?selected-node=URL parameter changes, shows/hides the Explain button based on node failure status, displays explanation panel with regenerate/close controlsGraphViewExplainErrorActionTest.javaModified files
PipelineLogExtractor.javaextractNodeLog(String nodeId)method to extract log output from a specific flow node by its IDBehavior
Button placement: The button is injected into the top-right action bar (next to Run/Replay buttons) on the Pipeline Graph View (
*/stages) page.Activation logic:
ErrorActionor a descendant withErrorAction) does the button become visible.Caching: Same as the existing Console integration:
ErrorExplanationActionexists for the run, it is returned directly (with a "previously generated" note).forceNew=truetriggers a fresh AI call.Graceful degradation: When
pipeline-graph-viewis not installed, no action is injected and no JS is loaded.Testing
Full
mvn verifypasses with zero SpotBugs errors.