Skip to content

feat: Shareable public collections via /c/{slug}#482

Merged
davila7 merged 5 commits intomainfrom
feat/shareable-collections
Mar 30, 2026
Merged

feat: Shareable public collections via /c/{slug}#482
davila7 merged 5 commits intomainfrom
feat/shareable-collections

Conversation

@davila7
Copy link
Copy Markdown
Owner

@davila7 davila7 commented Mar 29, 2026

Summary

  • DB migration: Adds share_slug (VARCHAR 20, unique) and is_public (boolean) to user_collections — already applied to Neon prod
  • API /api/collections/share: POST toggles sharing (auth required), GET fetches public collection data (no auth, only public-safe fields)
  • Public page /c/[slug]: Shows collection name, author, install command with copy button, components grouped by type, and CTA to sign up
  • Share button in MyComponentsView: generates 8-char slug, copies link to clipboard, shows "Shared" state in blue

Security

  • No clerk_user_id, email, or internal UUIDs exposed in public responses
  • Only component_type, component_path, component_name, component_category returned
  • SQL injection protected via parameterized queries
  • Slug is 8 random chars (656B+ combinations), not enumerable
  • Toggle share requires auth + ownership verification

Test plan

  • Go to /my-components, select a collection, click Share
  • Verify link is copied to clipboard
  • Open /c/{slug} in incognito — should show collection publicly
  • Verify no sensitive data in page source or network responses
  • Click Share again on same collection — should copy link again
  • Test install command is correct and copyable

Summary by cubic

Add shareable public collections at /c/{slug}. Users can share a collection and install it with one command; the Share button now copies the link if the collection is already public.

  • Area: Dashboard UI and API (dashboard/src/); new /api/collections/share (POST/GET), public page /c/[slug], Share button in MyComponentsView; pre-deploy build-checker at .claude/agents/build-checker.md; fixed esbuild parse error on the shared page.
  • DB/migrations: add share_slug and is_public to user_collections; ignore scripts/migrations/ in .gitignore.
  • UX fix: if a collection is already shared, clicking Share copies the link instead of disabling sharing.
  • API/Security: POST requires auth + ownership; GET returns only public-safe fields; author via @clerk/backend with CLERK_SECRET_KEY.
  • Components/docs/env: no new components in cli-tool/components/; no catalog regen (docs/components.json); no new env vars.

Written for commit b224f1e. Summary will update on new commits.

- Add share_slug and is_public columns to user_collections (migration 002)
- New API endpoint /api/collections/share: POST toggles sharing (auth),
  GET fetches public collection (no auth, only public-safe fields)
- New public page /c/[slug] with header, install command, component grid
  grouped by type, and CTA to create own collections
- Share button in MyComponentsView: generates link, copies to clipboard,
  shows shared state. Security reviewed: no leak of clerk_user_id, email,
  or internal UUIDs
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 29, 2026

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

Project Deployment Actions Updated (UTC)
aitmpl-dashboard Ready Ready Preview, Comment Mar 30, 2026 0:09am
claude-code-templates Ready Ready Preview, Comment Mar 30, 2026 0:09am

Request Review

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="dashboard/src/components/MyComponentsView.tsx">

<violation number="1" location="dashboard/src/components/MyComponentsView.tsx:587">
P1: The Share button currently toggles public state off on a second click, so users can unintentionally unshare a collection instead of copying the link again.</violation>
</file>

<file name="scripts/migrations/002_add_share_slug.sql">

<violation number="1" location="scripts/migrations/002_add_share_slug.sql:7">
P2: This creates a redundant index: `share_slug UNIQUE` already creates an index, so the extra `CREATE INDEX` duplicates it and adds avoidable write overhead.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name=".gitignore">

<violation number="1" location=".gitignore:76">
P1: Do not ignore the migrations directory; schema migrations should be versioned in git to keep environments reproducible and auditable.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

.crawl-output/

# Migrations (applied directly to Neon, not needed in repo)
scripts/migrations/
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 29, 2026

Choose a reason for hiding this comment

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

P1: Do not ignore the migrations directory; schema migrations should be versioned in git to keep environments reproducible and auditable.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .gitignore, line 76:

<comment>Do not ignore the migrations directory; schema migrations should be versioned in git to keep environments reproducible and auditable.</comment>

<file context>
@@ -72,6 +72,9 @@ openspec/
 .crawl-output/
 
+# Migrations (applied directly to Neon, not needed in repo)
+scripts/migrations/
+
 # Secrets and credentials
</file context>
Suggested change
scripts/migrations/
# scripts/migrations/
Fix with Cubic

When collection is already shared, clicking Share now copies the link
again instead of disabling sharing. Identified by cubic.
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.

1 participant