Skip to content

feat: Add copy-to-clipboard for AI markdown export - #2

Open
faizan7800 wants to merge 4 commits into
vinay-patel22:mainfrom
faizan7800:feat/copy-ai-export-to-clipboard
Open

feat: Add copy-to-clipboard for AI markdown export#2
faizan7800 wants to merge 4 commits into
vinay-patel22:mainfrom
faizan7800:feat/copy-ai-export-to-clipboard

Conversation

@faizan7800

Copy link
Copy Markdown

What

Adds a "Copy to Clipboard" button next to the AI Snapshot export, so the
markdown handoff can go straight into an LLM chat without a download → open → copy round trip.

Why

The AI export already targets LLM tools (per the README's ai-handoff focus),
but currently the only output is a file download. Copy-to-clipboard removes
a step for the most common use case.

Changes

  • js/export-manager.js: new copyToClipboard(type) method, reuses the
    existing startExportWorker pipeline and just writes the result to the
    clipboard instead of triggering a download
  • js/event-handlers.js: wires the new button's click event
  • index.html: adds the Copy button next to AI Snapshot
  • Fixed a duplicate setExportButtonsState method definition that was
    silently overriding the version handling the new button's disabled state

Testing

Tested locally via npx serve ., in Chrome and Firefox:

  • Copy button enables/disables in sync with other export buttons
  • Copied content matches the AI markdown download exactly
  • Empty state (no files) shows the correct toast, doesn't throw
  • Clipboard permission denial shows a clear error toast

- Adds a Copy button next to AI Snapshot for quick paste into LLM chats
- Reuses existing export worker/blob pipeline, just swaps download for clipboard write
- Fixes a duplicate setExportButtonsState definition that was silently overriding button state logic
@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
code-snapshot Error Error Jul 25, 2026 6:35am

@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

Deployment failed with the following error:

The `vercel.json` schema validation failed with the following message: should NOT have additional property `public`

Learn More: https://vercel.com/docs/concepts/projects/project-configuration

@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

@fezan-dot is attempting to deploy a commit to the vinaypatel22's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vinay-patel22

Copy link
Copy Markdown
Owner

Thanks for the PR. Could you please share screenshots or a short screen recording demonstrating the changes? I'd like to verify both the UI and the functionality before reviewing the code.

@faizan7800

Copy link
Copy Markdown
Author
code-snapshot-pr.mp4

Here's a quick demo:

  1. Before loading files — Copy button disabled along with the rest

  2. After dropping a folder — all export buttons enabled

  3. Clicking Copy — loading state shown, then success toast

  4. Pasted clipboard content matches the AI markdown export format

@vinay-patel22 vinay-patel22 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Issues Found - Blocking Review

1. Duplicate setExportButtonsState Method Definition

Looking at the diff in js/export-manager.js, the original setExportButtonsState method is moved but not consolidated. The final code contains two definitions of the same method:

// First definition: lines ~172-189 (inside copyToClipboard's scope)
setExportButtonsState(disabled) {
  const hasExportFiles = this.filterManager.getExportFiles().length > 0;
  // ... implementation

// Second definition: lines ~245-268 (moved to end, now deleted in diff)
// This one gets silently overridden

Issue: JavaScript silently uses the last-defined method. Only one works; the other is dead code. The PR description says this "fixed" a duplicate, but the diff shows it was moved, not removed.

Ask: Can you clarify what happened? Did you intend to remove one of these, or consolidate them? Please show both final definitions side-by-side so we can verify only one remains.


2. Missing Null-Safety on Blob Conversion

In copyToClipboard():

const text = await blob.text();
await navigator.clipboard.writeText(text);

If blob.text() fails or returns null/undefined, navigator.clipboard.writeText(null) will silently fail or throw an uncaught error.

Suggestion:

const text = await blob.text();
if (!text) {
  throw new Error("Failed to export content");
}
await navigator.clipboard.writeText(text);

3. Inconsistent Timeout Delays

  • Original startExport() re-enables buttons after 1000ms: setTimeout(() => {...}, 1000)
  • New copyToClipboard() re-enables buttons after 500ms: setTimeout(() => {...}, 500)

Why the difference? This should either:

  • Use the same constant (preferred)
  • Include a comment explaining why clipboard is faster

4. Unrelated Change to vercel.json

The PR removes "public": true from vercel.json. Since this is a privacy-focused tool, this change deserves explanation in the PR description. Is this intentional? If so, document the reason.


- Add null-safety check on blob.text() in copyToClipboard
- Consolidate button re-enable delay into shared UI_CONSTANTS.BUTTON_REENABLE_DELAY_MS
- Remove stray comment
- Keep vercel.json public property removed
@faizan7800

Copy link
Copy Markdown
Author

Thanks for the detailed review — addressed everything:

  1. Duplicate method — confirmed the current file has only one
    setExportButtonsState definition (includes copyAiBtn in the button
    array). The earlier confusion was from messy commit history showing a
    "move" instead of a clean delete-then-add — apologies for that.

  2. Null-safety — added the check you suggested before calling
    clipboard.writeText.

  3. Timeout inconsistency — consolidated both delays into a shared
    UI_CONSTANTS.BUTTON_REENABLE_DELAY_MS (1000ms). No good reason for
    them to differ, so I standardized rather than justifying a difference.

  4. vercel.json — yes, intentional. The original file had "public": true,
    which was causing the deployment schema error (should NOT have additional property 'public'). That key only affects whether the deployment is
    publicly listed on Vercel's own dashboard — unrelated to the app's local-only
    privacy model, so removing it doesn't change any user-facing behavior.
    Happy to split this into its own PR if you'd rather review it separately
    from the clipboard feature — let me know.

Also, re: the current failing Vercel check — that's now a different issue
("Authorization required to deploy"), not the schema error. Since I'm
deploying from a fork, Vercel needs a team member to authorize preview
deployments from external contributors. That's on your end if you want the
preview to run; it shouldn't block merging on its own.

@vinay-patel22 vinay-patel22 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please revert the changes made to vercel.json

@faizan7800

Copy link
Copy Markdown
Author

Hi, I reverted the changes made to vercel.json you can check

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