Skip to content

Conversation

@IlinJoy
Copy link
Collaborator

@IlinJoy IlinJoy commented Sep 21, 2025

Type of PR 🍩

  • Feature
  • Bugfix
  • Hotfix
  • Refactoring
  • Documentation
  • Infrastructure

Changes Introduced 🥯

  • Implemented:
    • add history database integration

Self-Check ✅

  • No console errors (except API requests)
  • 80%+ test coverage
  • Documentation updated (if relevant)
  • Package.json scripts updated (if relevant)

@netlify
Copy link

netlify bot commented Sep 21, 2025

Deploy Preview for vatruzhka ready!

Name Link
🔨 Latest commit 7f33f73
🔍 Latest deploy log https://app.netlify.com/projects/vatruzhka/deploys/68d078944c227f000871bb3f
😎 Deploy Preview https://deploy-preview-35--vatruzhka.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@gemini-code-assist
Copy link

Summary of Changes

Hello @IlinJoy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a robust history feature, enabling the application to persist and display a log of all executed API requests. By integrating with Supabase, the system now dynamically fetches and renders past request details, enhancing user experience by providing a comprehensive overview of their API interactions. This change moves away from static mock data, making the history functionality fully operational and data-driven.

Highlights

  • Database Integration: Implemented Supabase integration to store and retrieve API request history, replacing static mock data with dynamic database fetching.
  • History Display: The history page now dynamically fetches and displays actual request history from the database, providing a real-time log of API interactions.
  • Data Persistence: Each executed API request is now automatically saved to the database, including comprehensive details like status, headers, body, and timing metrics.
  • Header Handling: Headers are now stored as stringified JSON in the database and parsed back into objects for display, ensuring data integrity and consistency across the application.
  • Timestamp Formatting: A new utility has been introduced to format timestamps, improving the readability and presentation of historical request data in the UI.
  • Supabase Client Management: Centralized the Supabase client creation for both history insertion and authentication, leading to improved consistency and reduced code redundancy.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully integrates request history with a Supabase backend. The changes are well-structured, introducing new utility functions for fetching and saving history, and updating components to use real data instead of mocks. However, I've identified a few critical issues related to error handling and data fetching that could lead to runtime crashes. Additionally, there are some high-severity bugs in response handling and URL generation. I've also included some medium-severity suggestions to improve code clarity and maintainability, such as fixing a typo and reorganizing the Supabase client setup. Please review the detailed comments for suggestions on how to address these points.

const locale = useLocale();
const routeUrl = generateRouteUrl(method, url, locale, body, headers);

const parsedHeaders = parse(HeadersSchema, JSON.parse(headers));

Choose a reason for hiding this comment

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

critical

Parsing the headers string with JSON.parse and then with valibot's parse can throw an exception if the headers string is not valid JSON or if the parsed object does not conform to the HeadersSchema. This would crash the component and stop the list of history items from rendering. You should wrap this logic in a try...catch block to handle potential parsing errors gracefully, for example by defaulting to an empty headers object.

Suggested change
const parsedHeaders = parse(HeadersSchema, JSON.parse(headers));
let parsedHeaders: Record<string, string> = {};
try {
parsedHeaders = parse(HeadersSchema, JSON.parse(headers));
} catch (error) {
console.error('Failed to parse history item headers:', error);
}

Comment on lines 204 to 215
if (proxyResponse.error) {
throw new Error(proxyResponse.error);
}

if (!result.ok) {
throw new Error(`HTTP ${result.status.toString()}: ${result.statusText}`);
}

set({
response: {
status: proxyResponse.status,
statusText: getReasonPhrase(proxyResponse.status),
headers: proxyResponse.headers,
body: proxyResponse.body,
timestamp,
duration,
requestSize,
responseSize,
},
response: { ...dataForSave, statusText: getReasonPhrase(proxyResponse.status), error: error?.message },
isLoading: false,
});

Choose a reason for hiding this comment

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

high

Throwing an error when result.ok is false causes the execution to jump to the catch block. The catch block then sets a generic error response, losing all the details from the actual HTTP response (like status code, headers, and body) that have already been received and parsed. This prevents the user from seeing the actual error response from the server. Non-2xx responses are valid HTTP responses and should be handled gracefully by setting them in the state, not by throwing an exception that leads to loss of information.

Suggested change
if (proxyResponse.error) {
throw new Error(proxyResponse.error);
}
if (!result.ok) {
throw new Error(`HTTP ${result.status.toString()}: ${result.statusText}`);
}
set({
response: {
status: proxyResponse.status,
statusText: getReasonPhrase(proxyResponse.status),
headers: proxyResponse.headers,
body: proxyResponse.body,
timestamp,
duration,
requestSize,
responseSize,
},
response: { ...dataForSave, statusText: getReasonPhrase(proxyResponse.status), error: error?.message },
isLoading: false,
});
if (proxyResponse.error) {
throw new Error(proxyResponse.error);
}
set({
response: { ...dataForSave, statusText: getReasonPhrase(proxyResponse.status), error: error?.message },
isLoading: false,
});

@@ -0,0 +1,8 @@
export const formateTimestamp = (locale: string, timestamp: string) =>

Choose a reason for hiding this comment

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

medium

There is a typo in the function name formateTimestamp. It should be formatTimestamp. This should be corrected here and in all places where it's used for consistency and to avoid confusion.

Suggested change
export const formateTimestamp = (locale: string, timestamp: string) =>
export const formatTimestamp = (locale: string, timestamp: string) =>


import { createClient } from '@/utils/supabase/client';

export const supabase = createClient();

Choose a reason for hiding this comment

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

medium

This file creates and exports a singleton supabase client instance. However, the filename history-insert.ts is very specific and doesn't reflect that it's providing a general-purpose client instance. This instance is also used in AuthProvider. To improve code organization and clarity, it's better to define and export this singleton from a more general file, like @/utils/supabase/client.ts. Other parts of the app can then import the singleton from a single, clear source.

@github-actions github-actions bot requested a review from Sepulator September 21, 2025 22:13
@IlinJoy IlinJoy merged commit 4de9768 into develop Sep 21, 2025
6 checks passed
@IlinJoy IlinJoy deleted the feat/history-integration branch September 21, 2025 22:15
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