Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 27, 2025

Implements a complete recent predictions feature that displays the last 3-5 image predictions on the landing page, as requested in issue #XX.

Changes Made

Server-side (Node.js/Express)

  • Added in-memory storage to track recent predictions with a maximum of 5 entries
  • Modified the /api/upload/:language endpoint to save prediction results along with image data (base64), language, and timestamp
  • Added new /api/recent-predictions GET endpoint to fetch stored recent predictions
  • Implemented automatic cleanup to maintain only the most recent predictions

Client-side (Angular)

  • Created new RecentPredictionsComponent with responsive grid layout
  • Added RecentPredictionEntry TypeScript interface for type safety
  • Extended LanguagesApiService to include getRecentPredictions() method
  • Integrated the component into the main uploader page below the results section
  • Added automatic refresh functionality that updates recent predictions when new ones are made

UI/UX Features

  • Image Thumbnails: Displays base64-decoded images as clickable thumbnails
  • Prediction Details: Shows the top prediction label prominently
  • Metadata Display: Shows prediction language and formatted timestamp
  • Responsive Design: CSS Grid layout that adapts to different screen sizes
  • Loading States: Displays appropriate loading and empty state messages
  • Professional Styling: Clean card design with hover effects and proper spacing

Screenshots

Multiple Recent Predictions Display:
Recent Predictions Feature

The feature shows recent predictions in a clean grid layout with image thumbnails, prediction labels, language badges, and timestamps.

Testing

  • Added server-side test for the new /api/recent-predictions endpoint
  • Manually tested with multiple predictions to verify storage limit and display
  • Verified automatic refresh functionality when new predictions are made
  • Tested responsive layout on different screen sizes

This implementation provides users with a quick overview of their recent image classification attempts, improving the overall user experience of the EfficientNet playground.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-2.7.0.tar.gz
    • Triggering command: node scripts/install.js gpu download (http block)
  • https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v8/3.13.0/GPU-linux-3.13.0.tar.gz
    • Triggering command: node-pre-gyp (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Landing page: add component with recent images that been predict</issue_title>
<issue_description>Server side save recent 3-5 images with there prediction.

Expose end point to fetch recent predictions

client side add component showing recent predictions

</issue_description>

Comments on the Issue (you are @copilot in this section)

@ntedgi go for it let me know if you need help @ntedgi Yes please share your pr
Fixes #54

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: ntedgi <31243793+ntedgi@users.noreply.github.com>
Copilot AI changed the title [WIP] Landing page: add component with recent images that been predict Add recent predictions feature to landing page Sep 27, 2025
Copilot AI requested a review from ntedgi September 27, 2025 05:31
@ntedgi ntedgi requested a review from Copilot September 29, 2025 10:13
Copy link

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 a complete recent predictions feature that displays the last 3-5 image predictions on the landing page. The implementation includes both server-side storage of recent predictions and a client-side component to display them.

Key changes include:

  • Added in-memory storage on the server to track recent predictions with automatic cleanup
  • Created new API endpoint /api/recent-predictions to fetch stored predictions
  • Built Angular component with responsive grid layout to display recent predictions with thumbnails

Reviewed Changes

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

Show a summary per file
File Description
playground/server/server.js Added in-memory storage and /api/recent-predictions endpoint
playground/server/tests/server.test.js Added test for new recent predictions endpoint
playground/ui/src/app/recent-predictions/recent-predictions.component.ts New component to display recent predictions
playground/ui/src/app/recent-predictions/recent-predictions.component.html Template for recent predictions grid layout
playground/ui/src/app/recent-predictions/recent-predictions.component.scss Styling for responsive grid and card design
playground/ui/src/app/recent-predictions/recent-predictions.component.spec.ts Basic test setup for component
playground/ui/src/app/languages-api.service.ts Added method to fetch recent predictions
playground/ui/src/app/interfces/index.ts Added TypeScript interface for recent prediction entries
playground/ui/src/app/uploader/uploader.component.ts Added ViewChild reference and auto-refresh logic
playground/ui/src/app/uploader/uploader.component.html Integrated recent predictions component
playground/ui/src/app/app.module.ts Registered new component in module

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

styleUrls: ['./uploader.component.scss'],
})
export class UploaderComponent implements OnInit {
@ViewChild(RecentPredictionsComponent) recentPredictionsComponent: RecentPredictionsComponent;
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

The ViewChild should include a static flag or be made optional with undefined type. Consider using @ViewChild(RecentPredictionsComponent) recentPredictionsComponent?: RecentPredictionsComponent; to handle cases where the component might not be available.

Suggested change
@ViewChild(RecentPredictionsComponent) recentPredictionsComponent: RecentPredictionsComponent;
@ViewChild(RecentPredictionsComponent) recentPredictionsComponent?: RecentPredictionsComponent;

Copilot uses AI. Check for mistakes.
Comment on lines +37 to +39
setTimeout(() => {
this.recentPredictionsComponent.loadRecentPredictions();
}, 1000); // Small delay to ensure server has processed the prediction
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

Using a hardcoded 1000ms timeout is fragile and could lead to race conditions. Consider using a more reliable approach like waiting for the upload API response to complete, or implementing a proper callback/observable pattern.

Suggested change
setTimeout(() => {
this.recentPredictionsComponent.loadRecentPredictions();
}, 1000); // Small delay to ensure server has processed the prediction
this.recentPredictionsComponent.loadRecentPredictions();

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,88 @@
[recent-predictions-container] {
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

The CSS selector [recent-predictions-container] should use standard attribute selector syntax. Consider using a class selector .recent-predictions-container or proper attribute selector [recent-predictions-container] with quotes if this is intended as a custom attribute.

Suggested change
[recent-predictions-container] {
.recent-predictions-container {

Copilot uses AI. Check for mistakes.
const imageBase64 = fs.readFileSync(imagePath, { encoding: 'base64' });

const predictionEntry = {
id: Date.now() + Math.random(), // Simple unique ID
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

Using Date.now() + Math.random() for ID generation could potentially create collisions and is not guaranteed to be unique. Consider using a more robust ID generation method like crypto.randomUUID() or a proper UUID library.

Copilot uses AI. Check for mistakes.
@ntedgi ntedgi marked this pull request as ready for review October 5, 2025 04:59
@ntedgi ntedgi merged commit ecb1f2a into main Oct 5, 2025
2 checks passed
@ntedgi ntedgi deleted the copilot/fix-0d29d824-56ca-4b7d-bbb2-d8b604f33ef8 branch October 5, 2025 04:59
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.

Landing page: add component with recent images that been predict

2 participants