Skip to content

Fix Artifacts dropdown to show options conditionally#1425

Merged
deep1401 merged 1 commit intomainfrom
fix/artifacts-dropdown
Mar 2, 2026
Merged

Fix Artifacts dropdown to show options conditionally#1425
deep1401 merged 1 commit intomainfrom
fix/artifacts-dropdown

Conversation

@deep1401
Copy link
Copy Markdown
Member

@deep1401 deep1401 commented Mar 2, 2026

  • Also fixes the artifacts button not appearing when there's no artifacts but there are saved models

Summary by CodeRabbit

  • Bug Fixes
    • Improved menu item visibility logic to conditionally display dataset and model viewing options only when the corresponding data is available, providing a cleaner interface.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 2, 2026

📝 Walkthrough

Walkthrough

A single component file was modified to adjust conditional rendering logic for a dropdown menu. The visibility of the Artifacts dropdown and its child menu items (View Datasets, View Models) now depends on different data properties than previously implemented.

Changes

Cohort / File(s) Summary
UI Conditional Rendering
src/renderer/components/Experiment/Tasks/JobsList.tsx
Updated dropdown visibility logic: Artifacts dropdown now renders based on generated_datasets or models instead of artifacts or artifacts_dir. View Datasets menu item conditionally renders only when generated_datasets is truthy; View Models only renders when models is truthy.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing conditional rendering of Artifacts dropdown options.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/artifacts-dropdown

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

Copy link
Copy Markdown
Contributor

@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.

🧹 Nitpick comments (1)
src/renderer/components/Experiment/Tasks/JobsList.tsx (1)

336-347: Strengthen conditions for dataset and model menu items.

Lines 336 and 343 render menu entries based on loose truthiness checks. Menu items will appear for empty arrays and may expose no-op actions when callbacks are undefined.

Verify that generated_datasets and models are populated before rendering menu items, and ensure handlers are present:

Suggested refactor
-                        {job?.job_data?.generated_datasets && (
+                        {onViewJobDatasets && job?.job_data?.generated_datasets && (
                           <MenuItem
                             onClick={() => onViewJobDatasets?.(job?.id)}
                           >
                             View Datasets
                           </MenuItem>
                         )}
-                        {job?.job_data?.models && (
+                        {onViewJobModels && job?.job_data?.models && (
                           <MenuItem onClick={() => onViewJobModels?.(job?.id)}>
                             View Models
                           </MenuItem>
                         )}

Additionally, address the broader type safety issue: jobs is typed as any[] (line 26), which violates the coding guideline to "Avoid any in TypeScript; define interfaces for all props and API responses to ensure type safety". Define a proper Job interface with explicit typing for job_data, generated_datasets, and models fields.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/renderer/components/Experiment/Tasks/JobsList.tsx` around lines 336 -
347, The menu items render on loose truthiness; update the conditionals in
JobsList so that you only render the "View Datasets" MenuItem when
job.job_data?.generated_datasets is an array with length > 0 and
onViewJobDatasets is a defined function, and likewise only render "View Models"
when job.job_data?.models is an array with length > 0 and onViewJobModels
exists; also replace the any[] jobs prop with a concrete Job interface (include
job.id, job_data with generated_datasets: any[] and models: any[] at minimum)
and use that interface for the component props and any local job variables to
remove the any and ensure proper typing for these checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/renderer/components/Experiment/Tasks/JobsList.tsx`:
- Around line 336-347: The menu items render on loose truthiness; update the
conditionals in JobsList so that you only render the "View Datasets" MenuItem
when job.job_data?.generated_datasets is an array with length > 0 and
onViewJobDatasets is a defined function, and likewise only render "View Models"
when job.job_data?.models is an array with length > 0 and onViewJobModels
exists; also replace the any[] jobs prop with a concrete Job interface (include
job.id, job_data with generated_datasets: any[] and models: any[] at minimum)
and use that interface for the component props and any local job variables to
remove the any and ensure proper typing for these checks.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86cdafc and 6b50beb.

📒 Files selected for processing (1)
  • src/renderer/components/Experiment/Tasks/JobsList.tsx

@deep1401 deep1401 merged commit 4f933a4 into main Mar 2, 2026
4 of 5 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