Skip to content

feat: add pipeline graph view node explain entrypoint#186

Closed
shenxianpeng wants to merge 10 commits into
mainfrom
feature/pipeline-graph-view-explain
Closed

feat: add pipeline graph view node explain entrypoint#186
shenxianpeng wants to merge 10 commits into
mainfrom
feature/pipeline-graph-view-explain

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented May 30, 2026

Copy link
Copy Markdown
Member

Summary

Adds "Explain selected step" button and AI explanation display to the Pipeline Graph View, enabling per-node error explanations.

Changes

New Files

  • StepErrorExplanationAction.java - Hidden RunAction2 that caches per-node AI explanations in a LinkedHashMap<String, Entry>
  • explain-error-graph.js - JavaScript that injects "Explain selected step" button into the pipeline graph view app bar, detects selected node from URL params, and sends AJAX requests to the new explainNodeError endpoint
  • ConsolePageDecoratorUriTest.java - URI matching tests for pipeline graph view pages

Modified Files

  • ConsoleExplainErrorAction.java - New doExplainNodeError() endpoint that extracts a specific node's log and explains it; refactored doCheckBuildStatus; added getOrCreateStepAction() and parseMaxLines() helpers
  • ConsolePageDecorator.java - Extended to recognize pipeline graph view pages (/stages and /pipeline-overview) and check that the pipeline-graph-view plugin is installed
  • ErrorExplainer.java - New explainErrorText() overload with storeBuildAction parameter to avoid overwriting console-level explanations when explaining nodes
  • PipelineLogExtractor.java - New extractNodeLog() method with node-log resolution (direct log, error origin, parent with log, descendant collection)
  • UsageEvent.java - New PIPELINE_GRAPH_NODE entry point
  • footer.jelly - Conditionally loads explain-error-graph.js vs explain-error-footer.js based on page type

Test Updates

  • ConsoleExplainErrorActionTest - Tests for node explanation caching, parent node fallback, missing nodeId validation, and build status (including UNSTABLE/ABORTED)
  • PipelineLogExtractorTest - Tests for selected node extraction, parent node fallback, missing node, and non-pipeline runs
  • MetricsUsageRecorderTest - Coverage for PIPELINE_GRAPH_NODE entry point

Architecture

  1. ConsolePageDecorator detects pipeline graph view pages by URL match AND verifies pipeline-graph-view plugin is installed
  2. The button is injected into #console-pipeline-overflow-root in the app bar
  3. Node ID is read from ?selected-node= URL parameter
  4. Explanation output appears in the shared explain-error-container footer card
  5. Explanations are cached per-node in StepErrorExplanationAction to avoid redundant API calls

Testing

  • Manual: Button only appears on FAILURE builds with pipeline-graph-view installed
  • Manual: Button disabled when no node selected or build running
  • Manual: Node explanations cached independently from console explanations
  • Unit tests cover all key scenarios

When navigating from pipeline overview to a failed step via
pushState (SPA navigation without full page reload), the
'Explain selected step' button was not created. The history
listeners only called updateGraphExplainButton() (which expects
an existing button) but never called installGraphExplainButton()
to create it.

Fix: call installGraphExplainButton() alongside
updateGraphExplainButton() in pushState, replaceState, and
popstate handlers. Also call installGraphExplainButton() after
MutationObserver setup in observeGraphViewChanges() to handle
already-rendered DOM.
…eline Graph View

Two issues fixed:

1. Clicking 'Explain selected step' no longer briefly shows the console-level
   explanation before replacing it with the node-level result. The Jelly now
   skips pre-populating the container on graph view pages since graph view
   uses per-node StepErrorExplanationAction, not console-level
   ErrorExplanationAction.

2. Clicking the regenerate arrow no longer collapses the explanation card to
   a tiny window during regeneration. The existing explanation content now
   stays visible while the spinner runs, keeping the card at full size until
   the new result replaces it.
@shenxianpeng shenxianpeng requested a review from a team as a code owner May 30, 2026 04:19
@shenxianpeng shenxianpeng marked this pull request as draft May 30, 2026 04:24
…hiding

- Make StepErrorExplanationAction.Entry fields non-final and add no-arg
  constructor for XStream deserialization. Previously the cache was lost
  on page reload, causing every click to re-generate the AI explanation.

- Add doGetNodeExplanation endpoint (cache-only lookup, no AI call)
  so the JS can auto-display previously generated explanations when
  a node is selected in the pipeline graph view.

- Add isSelectedNodeFailed() DOM-based detection: hide the Explain
  button when the user selects a green/success step instead of a
  failure step.

- Add tests for the new getNodeExplanation endpoint.
- Fix RTL layout shift after clicking Explain selected step by removing
  display:contents override on pipeline-graph-view overflow root; insert
  the button as a sibling instead.

- Prevent Explain selected step button from appearing for green/success
  nodes by checking isSelectedNodeFailed() in installGraphExplainButton()
  and returning false when the active tree item is not yet in the DOM.

- Remove the '[Note: This is a previously generated explanation...]'
  footnote from cached responses. The UI already provides a reload button
  for generating new explanations.
@shenxianpeng shenxianpeng deleted the feature/pipeline-graph-view-explain branch June 3, 2026 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant