Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: CI
permissions:
contents: read

permissions:
contents: read

on:
push:
branches: [main]
Expand Down
7 changes: 0 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/components/CookieConsent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import { useState } from 'react';
import { AnimatePresence, motion } from 'framer-motion';
import { Button } from './ui/Button';

/**
* Reads the stored cookie consent preference from localStorage.
* Returns true (show consent) when no preference has been saved yet.
*
* @returns True if the consent banner should be displayed, false otherwise
*/
function getInitialConsentState(): boolean {
try {
const hasConsented = localStorage.getItem('docugen-cookie-consent');
Expand Down
4 changes: 4 additions & 0 deletions src/components/ShareButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ export function ShareButtons({
},
];

/**
* Copies the share URL to the clipboard.
* Silently logs an error if the Clipboard API is unavailable.
*/
Comment on lines +69 to +72

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Align JSDoc with behavior and preserve error context in catch.

The new JSDoc is inaccurate: this path is not “silent,” and the catch handles more than just Clipboard API unavailability. Also, catch { ... } drops stack/context, which makes debugging harder.

Suggested update
   /**
    * Copies the share URL to the clipboard.
-   * Silently logs an error if the Clipboard API is unavailable.
+   * Logs a copy failure when writing to the clipboard fails.
    */
   const handleCopyLink = async () => {
     try {
       await navigator.clipboard.writeText(url);
-    } catch {
-      console.error('Failed to copy link');
+    } catch (error) {
+      console.error('Failed to copy link', error);
     }
   };

As per coding guidelines, "Handle runtime errors properly — avoid empty catch blocks; always log the error or re-throw to preserve stack traces".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/ShareButtons.tsx` around lines 69 - 72, Update the JSDoc for
the function that copies the share URL to the clipboard (e.g.,
copyShareUrlToClipboard) to accurately describe that failures are logged rather
than "silent", and change the empty catch to capture the error (catch (err)) and
log the error with context via the existing logger or console (preserving stack
and message) instead of swallowing it; ensure the catch message mentions the
action (copying share URL) and the error object is included so debugging
information is retained.

const handleCopyLink = async () => {
try {
await navigator.clipboard.writeText(url);
Expand Down
12 changes: 10 additions & 2 deletions src/components/UploadDemo.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import { render, screen, fireEvent } from '@testing-library/react';
import { describe, it, expect } from 'vitest';
import { UploadDemo } from './UploadDemo';

function createFileList(file: File) {
return {
0: file,
length: 1,
item: (index: number) => (index === 0 ? file : null),
};
}

describe('UploadDemo', () => {
it('renders drag and drop zone initially', () => {
render(<UploadDemo />);
Expand All @@ -23,7 +31,7 @@ describe('UploadDemo', () => {

fireEvent.drop(dropzone as Element, {
dataTransfer: {
files: [file],
files: createFileList(file),
},
});
});
Expand All @@ -35,7 +43,7 @@ describe('UploadDemo', () => {

fireEvent.drop(dropzone as Element, {
dataTransfer: {
files: [file],
files: createFileList(file),
},
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/UploadDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function UploadDemo() {
(e: React.DragEvent) => {
e.preventDefault();
setIsDragging(false);
const droppedFile = e.dataTransfer.files[0];
const droppedFile = e.dataTransfer.files.item(0);
if (droppedFile && (droppedFile.name.endsWith('.md') || droppedFile.name.endsWith('.mdx'))) {
setFile(droppedFile);
simulateUpload();
Expand Down
Loading