Skip to content

feat: show workflow runs retention time in the UI#445

Merged
stefinie123 merged 2 commits intoopenchoreo:mainfrom
stefinie123:deploy-fix
Mar 19, 2026
Merged

feat: show workflow runs retention time in the UI#445
stefinie123 merged 2 commits intoopenchoreo:mainfrom
stefinie123:deploy-fix

Conversation

@stefinie123
Copy link
Contributor

@stefinie123 stefinie123 commented Mar 19, 2026

Purpose

Show workflow runs retention time in the UI

image

Approach

This pull request adds support for displaying and propagating the workflow run retention time-to-live (TTL) in the OpenChoreo workflow system. It introduces a new field, ttlAfterCompletion, to both workflow entity types and ensures this retention information is fetched from the catalog and shown in the UI, improving transparency for users about how long workflow run data is retained.

API and Data Model Enhancements:

  • Added an optional ttlAfterCompletion field (a duration string, e.g., "10d1h30m") to both WorkflowEntityV1alpha1 and ClusterWorkflowEntityV1alpha1 interfaces to represent workflow run retention after completion. [1] [2]
  • Updated entity translation and provider logic to extract and propagate ttlAfterCompletion from backend workflow specs into catalog entities, ensuring the value is available throughout the stack. [1] [2] [3] [4] [5] [6] [7] [8]

Frontend and UI Improvements:

  • Added a new hook, useWorkflowRetention, to fetch the ttlAfterCompletion value from the catalog entity, and a utility, formatRetentionDuration, for displaying the duration in a human-readable format. [1] [2]
  • Updated the RunsTab component to display workflow run retention information via an info tooltip and a message in the empty state, using the fetched TTL value. [1] [2] [3] [4] [5]
  • Integrated the retention TTL into the main Workflows component, wiring the new hook and passing the value to RunsTab for display. [1] [2] [3]

These changes ensure that workflow retention policies are clearly communicated to users and consistently handled in both backend processing and frontend display.

Summary by CodeRabbit

  • New Features
    • Added workflow run retention support: workflows can specify how long completed runs are kept before automatic cleanup.
    • UI improvements: Runs tab now shows retention info via tooltip and empty-state messaging; refresh button spacing slightly adjusted.
    • New retention utilities: a hook to obtain retention for workflows and a formatter to display durations in human-readable form.

- Introduced a new optional field `ttlAfterCompletion` in both `ClusterWorkflowEntityV1alpha1` and `WorkflowEntityV1alpha1` interfaces to specify the time-to-live for completed WorkflowRun instances.
- Updated `OpenChoreoEntityProvider` to handle the new `ttlAfterCompletion` field during entity translation.
- Added a custom hook `useWorkflowRetention` to fetch the `ttlAfterCompletion` value from the catalog entity and format it for display in the UI.
- Enhanced `RunsTab` and `Workflows` components to utilize the retention TTL, providing users with information on run retention periods.

Signed-off-by: Stefinie Fernando <minolispencer@gmail.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

📝 Walkthrough

Walkthrough

Adds optional spec.ttlAfterCompletion?: string to ClusterWorkflow and Workflow entity schemas, propagates the field from provider to translated entities, exposes it via a new useWorkflowRetention hook and formatter, and surfaces formatted retention info in the RunsTab UI.

Changes

Cohort / File(s) Summary
Entity Schema Updates
plugins/catalog-backend-module-openchoreo/src/kinds/ClusterWorkflowEntityV1alpha1.ts, plugins/catalog-backend-module-openchoreo/src/kinds/WorkflowEntityV1alpha1.ts
Added optional spec.ttlAfterCompletion?: string to workflow entity interfaces.
Provider & Translation
plugins/catalog-backend-module-openchoreo/src/provider/OpenChoreoEntityProvider.ts, plugins/catalog-backend-module-openchoreo/src/utils/entityTranslation.ts
Read spec.ttlAfterCompletion from workflow resources and conditionally emit ttlAfterCompletion into translated entity specs; translation function signatures accept the new field.
Frontend Hook & Formatter
plugins/openchoreo-ci/src/hooks/useWorkflowRetention.ts, plugins/openchoreo-ci/src/hooks/index.ts
New useWorkflowRetention hook that fetches catalog entity by ref and returns ttlAfterCompletion; added formatRetentionDuration and re-exported both.
UI Components
plugins/openchoreo-ci/src/components/RunsTab/RunsTab.tsx, plugins/openchoreo-ci/src/components/Workflows/Workflows.tsx
RunsTab accepts retentionTtl prop, shows formatted retention tooltip and empty-state message; Workflows calls useWorkflowRetention and passes TTL to RunsTab.

Sequence Diagram(s)

sequenceDiagram
    participant UI as Workflows Component
    participant Hook as useWorkflowRetention Hook
    participant API as Catalog API
    participant Backend as Catalog Backend
    participant RunsTab as RunsTab Component

    UI->>Hook: call useWorkflowRetention(workflowName, kind, namespace)
    activate Hook
    Hook->>API: catalogApi.getEntityByRef(workflowRef)
    activate API
    API->>Backend: fetch workflow entity
    activate Backend
    Backend-->>API: return WorkflowEntityV1alpha1 with spec.ttlAfterCompletion
    deactivate Backend
    API-->>Hook: entity data
    deactivate API
    Hook->>Hook: extract entity.spec.ttlAfterCompletion into ttl state
    deactivate Hook
    Hook-->>UI: return retentionTtl
    UI->>RunsTab: pass retentionTtl prop
    activate RunsTab
    RunsTab->>RunsTab: formatRetentionDuration(retentionTtl)
    RunsTab->>RunsTab: render tooltip & empty-state message
    deactivate RunsTab
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • jhivandb
  • sameerajayasoma
  • kaviththiranga

Poem

🐰
I sniffed the TTL in flight,
A ticking carrot, soft and bright,
When runs are done, they hop away,
Clean fields until another day,
Hooray for tidy runs — oh what delight! 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description covers Purpose, Approach with detailed technical explanations and UI screenshot, but is missing required sections including Goals, User stories, Release note, Documentation, Training, Certification, Marketing, Tests, Security checks, Samples, and Test environment. Add missing required sections from the template: Goals, User stories, Release note, Documentation, Training, Certification, Marketing, Automation tests, Security checks, Samples, Test environment, and Learning sections.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly describes the main change: adding workflow runs retention time display in the UI, matching the primary objective of this PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@plugins/openchoreo-ci/src/components/RunsTab/RunsTab.tsx`:
- Around line 86-103: The InfoOutlinedIcon used as the Tooltip trigger is not
keyboard-focusable; wrap the icon in a focusable control like Material-UI's
IconButton and supply an aria-label so keyboard and screen-reader users can open
the tooltip. Locate the block that checks retentionTtl and uses
formatRetentionDuration and replace the raw InfoOutlinedIcon with an IconButton
(containing InfoOutlinedIcon) that has a meaningful aria-label (e.g., "Retention
period info") and preserves the existing styling (fontSize/color/margin) so the
Tooltip still attaches to the interactive element.

In `@plugins/openchoreo-ci/src/hooks/useWorkflowRetention.ts`:
- Around line 24-44: The fetchTtl function can leave stale TTL state when the
lookup fails or returns no entity; modify fetchTtl to clear the stored TTL by
calling setTtl(undefined) whenever the entityNamespace is missing, when
catalogApi.getEntityByRef throws, or when no entity/spec/ttlAfterCompletion is
found (i.e., any early return or catch path). Update the logic around
entityNamespace, the post-getEntityByRef block, and the catch handler in
fetchTtl (and reference ignore, catalogApi.getEntityByRef, workflowKind,
namespace, workflowName, setTtl) so that any unresolved lookup explicitly resets
TTL instead of leaving previous values.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a809cef2-d8b1-40c0-94de-6f4562dca32c

📥 Commits

Reviewing files that changed from the base of the PR and between 70b99f1 and 782b441.

📒 Files selected for processing (8)
  • plugins/catalog-backend-module-openchoreo/src/kinds/ClusterWorkflowEntityV1alpha1.ts
  • plugins/catalog-backend-module-openchoreo/src/kinds/WorkflowEntityV1alpha1.ts
  • plugins/catalog-backend-module-openchoreo/src/provider/OpenChoreoEntityProvider.ts
  • plugins/catalog-backend-module-openchoreo/src/utils/entityTranslation.ts
  • plugins/openchoreo-ci/src/components/RunsTab/RunsTab.tsx
  • plugins/openchoreo-ci/src/components/Workflows/Workflows.tsx
  • plugins/openchoreo-ci/src/hooks/index.ts
  • plugins/openchoreo-ci/src/hooks/useWorkflowRetention.ts

- Replaced InfoOutlinedIcon with an IconButton in the RunsTab component for better accessibility and styling.
- Updated useWorkflowRetention hook to ensure TTL is set correctly based on entity existence and ignore flag.

Signed-off-by: Stefinie Fernando <minolispencer@gmail.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@plugins/openchoreo-ci/src/hooks/useWorkflowRetention.ts`:
- Around line 71-77: The current duration formatting pushes days, hours and
sometimes minutes (variables days, hours, minutes) resulting in "10 days 1 hour"
for "10d1h30m"; change the logic in useWorkflowRetention (the formatter in
plugins/openchoreo-ci/src/hooks/useWorkflowRetention.ts) to only show the
largest non-zero unit: if days > 0 push only the days string (with proper
pluralization) and return; else if hours > 0 push only the hours string; else
push minutes (or fall back to duration) so the output for "10d1h30m" becomes "10
days" and matches the documented concise example.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0cc3a522-0071-4099-bb08-1dd7f612c8b4

📥 Commits

Reviewing files that changed from the base of the PR and between 782b441 and a36a317.

📒 Files selected for processing (2)
  • plugins/openchoreo-ci/src/components/RunsTab/RunsTab.tsx
  • plugins/openchoreo-ci/src/hooks/useWorkflowRetention.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/openchoreo-ci/src/components/RunsTab/RunsTab.tsx

Comment on lines +71 to +77
if (days > 0) parts.push(`${days} ${days === 1 ? 'day' : 'days'}`);
if (hours > 0) parts.push(`${hours} ${hours === 1 ? 'hour' : 'hours'}`);
if (minutes > 0 && days === 0)
parts.push(`${minutes} ${minutes === 1 ? 'minute' : 'minutes'}`);

return parts.length > 0 ? parts.join(' ') : duration;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Formatter output is inconsistent with its documented example.

For input 10d1h30m, current logic returns 10 days 1 hour, while the function docs describe a concise output like 10 days. Aligning behavior with the docs will keep tooltip/empty-state copy consistent.

💡 Proposed fix
-  const parts: string[] = [];
-  if (days > 0) parts.push(`${days} ${days === 1 ? 'day' : 'days'}`);
-  if (hours > 0) parts.push(`${hours} ${hours === 1 ? 'hour' : 'hours'}`);
-  if (minutes > 0 && days === 0)
-    parts.push(`${minutes} ${minutes === 1 ? 'minute' : 'minutes'}`);
-
-  return parts.length > 0 ? parts.join(' ') : duration;
+  if (days > 0) return `${days} ${days === 1 ? 'day' : 'days'}`;
+  if (hours > 0) return `${hours} ${hours === 1 ? 'hour' : 'hours'}`;
+  if (minutes > 0) return `${minutes} ${minutes === 1 ? 'minute' : 'minutes'}`;
+  return duration;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/openchoreo-ci/src/hooks/useWorkflowRetention.ts` around lines 71 -
77, The current duration formatting pushes days, hours and sometimes minutes
(variables days, hours, minutes) resulting in "10 days 1 hour" for "10d1h30m";
change the logic in useWorkflowRetention (the formatter in
plugins/openchoreo-ci/src/hooks/useWorkflowRetention.ts) to only show the
largest non-zero unit: if days > 0 push only the days string (with proper
pluralization) and return; else if hours > 0 push only the hours string; else
push minutes (or fall back to duration) so the output for "10d1h30m" becomes "10
days" and matches the documented concise example.

@stefinie123 stefinie123 merged commit 1306d45 into openchoreo:main Mar 19, 2026
6 checks passed
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.

2 participants