Skip to content

Conversation

@adamrefaey
Copy link
Collaborator

Change

This pull request introduces several changes to improve code maintainability and consistency, focusing on refactoring query keys into a centralized QueryKey enum, updating query-related logic, and enhancing the functionality of report-related features. The most significant changes include replacing hardcoded query keys with QueryKey constants, adding a new useToggleReportBookmark hook, and updating various components to use these improvements.

Refactoring Query Keys:

  • Replaced hardcoded query keys with constants from the new QueryKey enum in frontend/src/common/utils/constants.ts to ensure consistency and reduce duplication. This affects multiple files, including useChat.ts, useReports.ts, and several page components. [1] [2] [3] [4] [5]

Report Bookmarking Enhancements:

  • Added a useToggleReportBookmark hook in useReports.ts to encapsulate the logic for toggling the bookmark status of reports and updating relevant caches. This replaces the inline bookmark toggling logic previously scattered across components.
  • Updated HomePage.tsx, ReportsListPage.tsx, and ReportDetailPage.tsx to use the new useToggleReportBookmark hook, simplifying the components and ensuring consistent cache updates. [1] [2] [3]

Query Cache Management:

  • Improved cache invalidation for queries related to reports (Reports, LatestReports, and ReportDetail) in multiple components, ensuring that changes (e.g., toggling bookmarks, deleting reports) are properly reflected across the app. [1] [2] [3]

Minor Refactoring:

  • Adjusted import paths for consistency, such as updating relative paths in perplexity.service.ts.
  • Updated HomePage.tsx to use the onClose callback for the UploadModal component, improving its behavior.

These changes collectively improve the maintainability, readability, and functionality of the codebase.

Does this PR introduce a breaking change?

{...}

What needs to be documented once your changes are merged?

{...}

Additional Comments

{...}

@adamrefaey adamrefaey requested review from GuidoBR and Copilot May 2, 2025 09:17
@adamrefaey adamrefaey self-assigned this May 2, 2025

This comment was marked as outdated.

@adamrefaey adamrefaey requested a review from Copilot May 2, 2025 09:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves code consistency and maintainability by refactoring query keys into a centralized enum, introducing a new hook for toggling report bookmarks, and enhancing cache invalidation across multiple report-related pages.

  • Refactors query keys using the new QueryKey enum.
  • Implements the useToggleReportBookmark hook to encapsulate bookmark toggling and cache updating logic.
  • Updates several components and services to adopt these centralized changes.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
frontend/src/pages/Reports/ReportsListPage.tsx Replaces inline bookmark toggle logic with useToggleReportBookmark hook and updates query keys.
frontend/src/pages/Reports/ReportDetailPage.tsx Uses QueryKey enum for queries, updates query invalidation, and streamlines UploadModal behavior.
frontend/src/pages/Processing/ProcessingPage.tsx Incorporates QueryKey enum and consistent cache invalidation patterns.
frontend/src/pages/Home/HomePage.tsx Switches to useToggleReportBookmark hook and removes redundant local logic.
frontend/src/common/utils/constants.ts Adds new QueryKey enum entries for Chat and report-related queries.
frontend/src/common/hooks/useReports.ts Refactors query keys and introduces useToggleReportBookmark hook.
frontend/src/common/hooks/useChat.ts Updates query key usage using the new QueryKey enum.
backend/src/services/perplexity.service.ts Adjusts import path for LabValue to use a relative path consistent with the structure.

@GuidoBR GuidoBR merged commit e9e5bb9 into main May 2, 2025
2 checks passed
@adamrefaey adamrefaey deleted the ADE-215 branch May 2, 2025 14:17
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.

3 participants