Skip to content

feat(sources): honor source_task_status in sources list#693

Draft
abellotti wants to merge 1 commit intomainfrom
fix_source_list_connected_status
Draft

feat(sources): honor source_task_status in sources list#693
abellotti wants to merge 1 commit intomainfrom
fix_source_list_connected_status

Conversation

@abellotti
Copy link
Copy Markdown
Contributor

@abellotti abellotti commented Sep 10, 2025

Do not merge, this is a POC. Needs additional testing for different scenarios. single source, different source types, etc.

  • Used for showing the source specific status for the last connection. Was incorrectly showing failed when the scan job that targeted multiple sources and another source failed, when the specific source shown was successful.

Requires: quipucords/quipucords#3024

Summary by Sourcery

Add support for source-specific connection task status in the sources list view

Enhancements:

  • Add API constants and type fields for source_task_id and source_task_status
  • Update sources list view to use source_task_status for status labels and icons

Used for showing the source specific status for the last
connection. Was incorrectly showing failed when the scan job
that targeted multiple sources and another source failed, when
the specific source shown was successful.
@abellotti abellotti marked this pull request as draft September 10, 2025 18:29
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Sep 10, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR introduces dedicated task identifiers and statuses for each source connection, updating API constants, type definitions, and the SourcesList view to use the new source_task_status field, ensuring accurate per-source status display.

ER diagram for SourceConnectionType changes

erDiagram
    SOURCE_CONNECTION {
      number systems_count
      number systems_scanned
      number systems_failed
      number source_task_id
      string source_task_status
    }
Loading

Class diagram for updated SourceConnectionType

classDiagram
class SourceConnectionType {
  number systems_count
  number systems_scanned
  number systems_failed
  number source_task_id
  string source_task_status
}
Loading

File-Level Changes

Change Details Files
Extend API constants to include new task ID and status fields
  • Add API_RESPONSE_SOURCE_CONNECTION_TASK_ID and API_RESPONSE_SOURCE_CONNECTION_TASK_STATUS constants
  • Include new constants in apiTypes and export lists
src/constants/apiConstants.ts
Add source_task_id and source_task_status to SourceConnectionType
  • Define source_task_id as number
  • Define source_task_status as string
src/types/types.ts
Update SourcesListView to use source_task_status for UI
  • Replace usage of connection.status with connection.source_task_status for translation key
  • Update ContextIcon variant to use source_task_status
src/views/sources/viewSourcesList.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `src/views/sources/viewSourcesList.tsx:438` </location>
<code_context>
     const scanTime = (isPending && source.connection.start_time) || source.connection.end_time;

-    const statusString = t(`table.label_status_${source.connection.status}`, { context: 'sources' });
+    const statusString = t(`table.label_status_${source.connection.source_task_status}`, { context: 'sources' });
     return (
       <Button
</code_context>

<issue_to_address>
Consider fallback for missing source_task_status value.

If source_task_status is undefined or null, the translation key may be invalid. Please add a fallback value or explicit handling for this case.
</issue_to_address>

### Comment 2
<location> `src/views/sources/viewSourcesList.tsx:454` </location>
<code_context>
         }}
       >
-        <ContextIcon symbol={ContextIconVariant[source.connection.status]} /> {statusString}{' '}
+        <ContextIcon symbol={ContextIconVariant[source.connection.source_task_status]} /> {statusString}{' '}
         {helpers.getTimeDisplayHowLongAgo(scanTime)}
       </Button>
</code_context>

<issue_to_address>
Validate source_task_status against ContextIconVariant keys.

Validating source_task_status before using it as a key will help prevent runtime errors from unexpected values.
</issue_to_address>

### Comment 3
<location> `src/types/types.ts:45` </location>
<code_context>
   systems_count: number;
   systems_scanned: number;
   systems_failed: number;
+  source_task_id: number;
+  source_task_status: string;
 };

</code_context>

<issue_to_address>
Consider stricter typing for source_task_status.

Using a string literal union type or enum for source_task_status will help catch invalid values during development and make the code easier to maintain.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
  systems_count: number;
  systems_scanned: number;
  systems_failed: number;
  source_task_id: number;
  source_task_status: string;
};
=======
  systems_count: number;
  systems_scanned: number;
  systems_failed: number;
  source_task_id: number;
  source_task_status: SourceTaskStatus;
};

export type SourceTaskStatus = 'pending' | 'running' | 'completed' | 'failed';
>>>>>>> REPLACE

</suggested_fix>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

const scanTime = (isPending && source.connection.start_time) || source.connection.end_time;

const statusString = t(`table.label_status_${source.connection.status}`, { context: 'sources' });
const statusString = t(`table.label_status_${source.connection.source_task_status}`, { context: 'sources' });
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Consider fallback for missing source_task_status value.

If source_task_status is undefined or null, the translation key may be invalid. Please add a fallback value or explicit handling for this case.

}}
>
<ContextIcon symbol={ContextIconVariant[source.connection.status]} /> {statusString}{' '}
<ContextIcon symbol={ContextIconVariant[source.connection.source_task_status]} /> {statusString}{' '}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Validate source_task_status against ContextIconVariant keys.

Validating source_task_status before using it as a key will help prevent runtime errors from unexpected values.

Comment on lines 42 to 47
systems_count: number;
systems_scanned: number;
systems_failed: number;
source_task_id: number;
source_task_status: string;
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Consider stricter typing for source_task_status.

Using a string literal union type or enum for source_task_status will help catch invalid values during development and make the code easier to maintain.

Suggested change
systems_count: number;
systems_scanned: number;
systems_failed: number;
source_task_id: number;
source_task_status: string;
};
systems_count: number;
systems_scanned: number;
systems_failed: number;
source_task_id: number;
source_task_status: SourceTaskStatus;
};
export type SourceTaskStatus = 'pending' | 'running' | 'completed' | 'failed';

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