Skip to content

Show node state colors in workflow invocation graph minimap#22335

Open
ahmedhamidawan wants to merge 10 commits intogalaxyproject:devfrom
ahmedhamidawan:sync_invocation_minimap_with_step_colors
Open

Show node state colors in workflow invocation graph minimap#22335
ahmedhamidawan wants to merge 10 commits intogalaxyproject:devfrom
ahmedhamidawan:sync_invocation_minimap_with_step_colors

Conversation

@ahmedhamidawan
Copy link
Copy Markdown
Member

In the invocation graph view, the minimap previously rendered all steps in a flat primary color regardless of their execution state.

Here, we've made the minimap reflect the same state-based colors used in the graph node headers.

  • The state-to-color mapping is driven by CSS custom properties on the minimap canvas element.
  • Also added borders to the minimap nodes since some of the state colors are very light and hence, hard to see.
sync_invocation_minimap_with_step_colors.mp4

Fixes #21086 (once the 3rd item there is also complete of course)

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

ahmedhamidawan and others added 3 commits March 31, 2026 17:30
In the invocation graph view, the minimap previously rendered all steps in a flat primary color regardless of their execution state.

Here, we've made the minimap reflect the same state-based colors used in the graph node headers.

- The state-to-color mapping is driven by CSS custom properties on the minimap canvas element.
- Also added borders to the minimap nodes since some of the state colors are very light and hence, hard to see.
Before this change, they would appear in the default node-header color.
import type { useWorkflowStateStore } from "@/stores/workflowEditorStateStore";
import type { Step } from "@/stores/workflowStepStore";

const stateNames = [
Copy link
Copy Markdown
Member

@mvdbeek mvdbeek Apr 1, 2026

Choose a reason for hiding this comment

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

Can we re-use states ? We want something shared ideally derived from the API schema. Note these seem to be dataset states too, those don't seem right for coloring steps ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have reused the graphStepStates as set on the client for invocation graph steps in the useInvocationGraph composable.

ahmedhamidawan and others added 2 commits April 3, 2026 10:22
"hidden" was in the GraphStep state union but is unreachable — it appears in neither JobState, DatasetState, nor InvocationStepState in the API schema, so no code path in updateStep or initializeGraphInput can ever set it. Removing it from graphStepStates also drops the now-dead --state-color-hidden CSS variable.

Also adds vitest coverage for all reachable step state cases: no invocation step (queued), no matching job summary (waiting), single- and all-instance job states, and the populated_state fallback mappings (scheduled/ready→queued, resubmitted→new, failed→error, deleting→deleted).

Co-Authored-By: Claude <noreply@anthropic.com>
import { provideScopedWorkflowStores } from "./workflowStores";

/** All possible states for an Invocation Graph step, derived from job states,
* input dataset states, and subworkflow scheduling states. */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How could you include dataset states in the graph ? Also my previous comment applies, don't redefine this here, use API-defined states please (components["schemas"]["JobState"], components["schemas"]["InvocationState"]), .

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would expect invocation states as well here ?

Copy link
Copy Markdown
Member Author

@ahmedhamidawan ahmedhamidawan Apr 8, 2026

Choose a reason for hiding this comment

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

How could you include dataset states in the graph ?

The reason dataset states are included is because workflow inputs are also GraphSteps, and we set the state of an input dataset/collection graph step based on its state.

--view-color: #{fade-out($brand-dark, 0.8)};
--view-outline-color: #{$brand-info};

// Invocation state colors
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there no type-safe way to do this? If we add a new state the catch all undefined is going to be used without any compile-time warning.

@mvdbeek mvdbeek marked this pull request as draft April 7, 2026 12:22
@mvdbeek mvdbeek moved this from Needs Review to In Progress in Galaxy Dev - weeklies Apr 7, 2026
ahmedhamidawan and others added 4 commits April 10, 2026 14:09
Replace the hand-maintained `graphStepStates` string array and its derived type with a proper schema-derived union: `JobState | DatasetState | InvocationStepState`, covering the three code paths that set a step's state (tool/collection steps, data input steps, subworkflow steps respectively). Drop the `graphStepStates` export entirely — the type is the authority now. In `canvasDraw.ts`, eliminate the dependent `stateNames` array by switching to a lazy `lookupStateColor` helper that reads `--state-color-{state}` CSS variables on first use and caches them, so any state defined in CSS is automatically picked up without a manual list.
Type `iconClasses` as `Record<GraphStepState, ...>` so TypeScript enforces exhaustive coverage of all step states. Fill in icons for all states in the full `JobState | DatasetState | InvocationStepState` union, using `states.ts` conventions as reference. Tighten `getHeaderClass` to accept `GraphStepState | undefined` instead of `string`, removing the cast at the call site. Expand `statePlaceholders` with `upload`, `setting_metadata`, `failed_metadata`, and `stop`.
Replaces the implicit `undefined` on `GraphStep.state` with an explicit `"uninitialized"` sentinel, making `state` a required field. New steps are initialized to `"uninitialized"` with `headerClass` set immediately. `updateStep` now starts fresh each call (`newState = undefined`) and falls back to the previous state via `newState ?? graphStep.state` if nothing could be determined, rather than silently inheriting it as the starting value.

Co-Authored-By: Claude <noreply@anthropic.com>
- add paused, skipped, uninitialized to $galaxy-state-bg
- generate --state-color-* CSS custom properties via :root @each (str-replace handles setting_metadata → setting-metadata)
- remove the 12 hardcoded --state-color-* vars from WorkflowMinimap.vue
- drop the lookupStateColor("undefined") catch-all; fall back to nodeColor directly
- update canvasDraw tests to reflect the removed undefined fallback

Co-Authored-By: Claude <noreply@anthropic.com>
@ahmedhamidawan ahmedhamidawan marked this pull request as ready for review April 10, 2026 21:24
@ahmedhamidawan
Copy link
Copy Markdown
Member Author

@mvdbeek I have added commits now that use schema defined types for Graph Step states (of all sorts; input steps, tool steps, subworkflows etc.) which are computed in the client in useInvocationGraph.

The state scss colors defined in base.scss are the single source now as well.

return { stepPosition: positions } as unknown as ReturnType<typeof useWorkflowStateStore>;
}

const STATE_COLORS = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems like a code smell ? Why is that in the test file ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The test is just making sure the correct (mocked in the test) color is set on the minimap node. I have replaced those raw color values with mock strings. And I have also annotated the test better.

@ahmedhamidawan ahmedhamidawan moved this from In Progress to Needs Review in Galaxy Dev - weeklies Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

More improvements to Invocation View Step Displays!

3 participants