Skip to content

Models view dont wait for backend data to show the page.#525

Open
Felipedino wants to merge 1 commit intodevelopfrom
fix/models-scope-fetch
Open

Models view dont wait for backend data to show the page.#525
Felipedino wants to merge 1 commit intodevelopfrom
fix/models-scope-fetch

Conversation

@Felipedino
Copy link
Copy Markdown
Collaborator

This pull request improves the user experience when loading tasks in the models section by introducing a loading state and skeleton placeholders. Instead of blocking the entire page with a spinner, the UI now displays skeleton cards while tasks are being fetched, making the interface feel more responsive and polished. The loading state is managed via a new loadingTasks variable, which is propagated through context and component props.

Loading state management and UI improvements:

  • Added a loadingTasks state to the useSessions hook, set to true while tasks are being fetched and false once loading completes. This state is now included in the context and passed down to relevant components. [1] [2] [3] [4] [5] [6] [7]
  • Updated SelectOptionMenu to accept a loading prop and render six skeleton cards in place of options when loading is true, providing a smoother and more modern loading experience. [1] [2] [3] [4]

Simplification of initial loading logic:

  • Removed the global loading spinner and associated state from ModelsContent.jsx. The initial data fetching is now handled without blocking the entire page, relying on the new skeleton-based loading indicators for tasks. [1] [2] [3] [4]

Copilot AI review requested due to automatic review settings April 6, 2026 12:15
Copy link
Copy Markdown
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 perceived responsiveness in the Models section by introducing a task-level loading state and showing skeleton placeholders while tasks are fetched, instead of blocking the entire page behind a fullscreen spinner.

Changes:

  • Added a loadingTasks state to the models useSessions hook and propagated it through ModelsContext.
  • Updated SelectOptionMenu to accept a loading prop and render skeleton cards when loading.
  • Removed the initial fullscreen loading spinner from ModelsContent and switched to non-blocking initial fetch calls.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
DashAI/front/src/pages/models/ModelsContent.jsx Removes initial fullscreen spinner and triggers initial fetches on mount.
DashAI/front/src/hooks/models/useSessions.js Introduces loadingTasks state toggled during fetchTasks().
DashAI/front/src/components/threeSectionLayout/SelectOptionMenu.jsx Adds loading prop and skeleton-card rendering for loading state.
DashAI/front/src/components/models/ModelsContext.jsx Exposes loadingTasks via Models context provider.
DashAI/front/src/components/models/ModelCenterContent.jsx Passes loadingTasks to SelectOptionMenu for task selection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 38 to 42
useEffect(() => {
const loadInitialData = async () => {
await Promise.all([fetchDatasets(), fetchSessions(), fetchTasks()]);
setIsInitialLoading(false);
};
loadInitialData();
fetchDatasets();
fetchSessions();
fetchTasks();
}, []);
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

ModelsProvider already triggers initial fetchDatasets(), fetchSessions(), and fetchTasks() via its own useEffects (see components/models/ModelsContext.jsx). Calling them again here causes duplicate network requests and, with the new loadingTasks boolean, can create a race where loadingTasks becomes false while another fetchTasks() call is still in-flight. Consider removing this effect entirely (or at least fetchTasks) and letting the provider own the initial fetch logic so it runs exactly once.

Copilot uses AI. Check for mistakes.
Comment on lines 48 to 63
@@ -56,6 +58,8 @@ export function useSessions({ t }) {
variant: "error",
});
console.error("Failed to fetch tasks:", error);
} finally {
setLoadingTasks(false);
}
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

loadingTasks is a single boolean toggled in fetchTasks(). If fetchTasks() is invoked concurrently (which currently happens on Models page mount because both ModelsProvider and ModelsContent call it), the first request to finish will set loadingTasks to false even if a later request is still pending. To avoid incorrect UI state, either ensure fetchTasks() is only triggered from one place, or make loadingTasks concurrency-safe (e.g., track an in-flight counter or store a requestId in a ref and only clear loading for the latest request).

Copilot uses AI. Check for mistakes.
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