Skip to content

Conversation

@MAVRICK-1
Copy link
Member

This pull request introduces improvements to database initialization, Docker configuration, and frontend reliability and user experience. The most significant change is the automatic creation of the target PostgreSQL database if it does not exist, streamlining local and Docker-based development setup. Other notable changes include enhancements to frontend logout logic to preserve user preferences, increased disk threshold for backend health checks, and improved robustness of frontend dependency installation.

Backend: Database Initialization

  • Automatically checks for the existence of the target PostgreSQL database and creates it if missing during startup, using the new parseDatabaseURL helper in connection.go. This simplifies setup, especially in Docker environments. [1] [2] [3]

Docker Configuration

  • Removes the frontend service healthcheck and simplifies dependency configuration in docker-compose.yml, making service startup more reliable and less dependent on timing issues.
  • Raises backend disk usage threshold from 90% to 98% in docker-compose.yml for improved tolerance before triggering alerts.

Frontend: Reliability and User Experience

  • Improves the logout logic in useAuth.ts to clear all local storage except for theme and "do not show again" preferences, ensuring user settings persist after logout. [1] [2]
  • Adds explicit clearing of username, password, and "remember me" state in the login form after credential expiration, enhancing security and user experience.
  • Adds a retry loop to the frontend Dockerfile’s npm install step, improving resilience against transient installation failures.

@github-actions github-actions bot removed the backend label Nov 10, 2025
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 implements improvements to logout functionality, adds database auto-creation capability, and adjusts Docker configuration for better reliability.

  • Preserves user preferences (theme and "do not show again" settings) during logout
  • Adds automatic database creation if it doesn't exist on backend initialization
  • Implements retry logic for npm install and adjusts Docker service dependencies

Reviewed Changes

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

Show a summary per file
File Description
frontend/src/hooks/useAuth.ts Modified logout functions to preserve theme and "do not show again" preferences in localStorage while clearing other data
frontend/src/components/login/LoginForm.tsx Added form field reset after credential decryption errors
frontend/Dockerfile Added retry logic (3 attempts) for npm install to handle transient failures
docker-compose.yml Removed frontend healthcheck and service_healthy dependency condition; increased disk threshold from 90% to 98%
backend/postgresql/Database/connection.go Added automatic database creation logic that checks for database existence and creates it if missing

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

COPY frontend/package.json frontend/package-lock.json ./
RUN rm -rf node_modules package-lock.json || true
RUN npm install --legacy-peer-deps
RUN for i in 1 2 3; do npm install --legacy-peer-deps && break || (echo "npm install failed, retrying..." && sleep 5); done
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

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

The retry loop uses the shell's exit status from npm install, but if npm install fails on all 3 attempts, the loop will exit with the last failure's exit code. However, Docker will still continue to the next step because the for loop itself returns success (exit 0) after completing all iterations.

To fail the build when all retries are exhausted, add:

RUN for i in 1 2 3; do npm install --legacy-peer-deps && break || (echo "npm install failed, retrying..." && sleep 5); done || exit 1

Or better yet:

RUN for i in 1 2 3; do npm install --legacy-peer-deps && break || { [ $i -eq 3 ] && exit 1 || (echo "npm install failed, retrying..." && sleep 5); }; done
Suggested change
RUN for i in 1 2 3; do npm install --legacy-peer-deps && break || (echo "npm install failed, retrying..." && sleep 5); done
RUN for i in 1 2 3; do npm install --legacy-peer-deps && break || { [ $i -eq 3 ] && exit 1 || (echo "npm install failed, retrying..." && sleep 5); }; done

Copilot uses AI. Check for mistakes.
@MAVRICK-1
Copy link
Member Author

/approve

@kubestellar-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MAVRICK-1

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@clubanderson
Copy link
Contributor

Thank you for this - lets get a review on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants