Skip to content

Feat/connect threads api#118

Open
Uday9909 wants to merge 3 commits intoc2siorg:mainfrom
Uday9909:feat/connect-threads-api
Open

Feat/connect threads api#118
Uday9909 wants to merge 3 commits intoc2siorg:mainfrom
Uday9909:feat/connect-threads-api

Conversation

@Uday9909
Copy link

Replaced the static placeholder data in the Threads component with real data from the /threads backend endpoint.

Previously, the component rendered hardcoded mock thread objects. This PR integrates the centralized api module to fetch actual GDB thread output from the server and render it safely.

Changes made:

  • Removed hardcoded thread array

  • Added API call to /threads

  • Added loading and error states

  • Rendered raw GDB output inside a

     block

  • Added safe handling for empty / "No threads" responses

  • Ensured no React warnings or console errors

…d shared axios instance

- Added shared api.js module
- Introduced VITE_API_BASE_URL via .env
- Removed hardcoded backend URLs across components

Fixes c2siorg#83
- Replaced static placeholder data
- Integrated API call
- Added loading and error states
- Render raw GDB output safely

useEffect(() => {
fetchThreadsData();
}, [refresh]);

Choose a reason for hiding this comment

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

Since this component performs async requests inside useEffect, we should consider adding cleanup using AbortController to prevent state updates on unmounted components and avoid race conditions when refresh changes rapidly.

fetchThreadsData();
}, [refresh]);

const hasThreads = threads && !threads.toLowerCase().includes("no threads");

Choose a reason for hiding this comment

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

While threads && ... protects against null or undefined, it doesn't protect against Type Errors. If the backend ever returns a non-string value (e.g., a number, a boolean, or an object), the application will throw a TypeError because .toLowerCase() does not exist on those types.

I suggest something along the following lines:

const hasThreads = 
  typeof threads === "string" && 
  threads.trim().length > 0 && 
  !threads.toLowerCase().includes("no threads");

@Rasesh2005
Copy link

@Uday9909 Great Work centralising the API, I have added some comments @Shubh942 Could look into if they are valid improvements, rest the PR looks great , I verified that it is passing all tests on npm and flask.

@Uday9909
Copy link
Author

Uday9909 commented Mar 1, 2026

@Uday9909 Great Work centralising the API, I have added some comments @Shubh942 Could look into if they are valid improvements, rest the PR looks great , I verified that it is passing all tests on npm and flask.

Good catches both — updated with AbortController cleanup and typeof guard.
Appreciate the review.

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