Skip to content

feat(playground): add lifecycle actions for One playgrounds - #840

Open
johnleider wants to merge 3 commits into
masterfrom
cursor/playground-lifecycle-actions-216d
Open

feat(playground): add lifecycle actions for One playgrounds#840
johnleider wants to merge 3 commits into
masterfrom
cursor/playground-lifecycle-actions-216d

Conversation

@johnleider

Copy link
Copy Markdown
Member

Summary

Implements playground lifecycle actions (favorite/pinned/locked/visibility/delete/fork) for v0play, enabling owners to manage their saved playgrounds and non-owners to fork public playgrounds.

Fixes #828

Changes

Composable API (useOnePlaygrounds.ts)

New exports:

  • currentMeta - reactive state for favorite/pinned/locked/visibility
  • currentOwner - owner user ID from API responses
  • isOwner - computed that compares current user to owner
  • patchMeta({ favorite?, pinned?, locked?, visibility?, title? }) - partial POST for meta-only updates
  • destroy() - DELETE with guards (throws if favorite or locked)
  • fork(getContent) - create owned copy with defaults, navigate to new playground

Updated:

  • create() now accepts { visibility } option
  • save() passes visibility through to create

UI

Save Dialog (PlaygroundSaveDialog.vue):

  • Added visibility toggle (Public/Private) when creating new playgrounds
  • Default remains public, user can choose private before save

File Menu (PlaygroundMenuBar.vue):

  • Owner actions (when linked + owner):
    • Make Public/Private toggle
    • Favorite/Unfavorite toggle
    • Pin/Unpin toggle
    • Lock/Unlock toggle
    • Delete (with confirm, disabled when favorited or locked)
  • Non-owner action (when linked + not owner):
    • Fork (creates owned copy, navigates to new playground)

Icons (icons.ts):

  • Added: star, star-outline, pin, pin-outline, lock, lock-open, visibility-public, visibility-private, delete, fork

API Notes

  • Uses partial POST from api#99 - only sends changed fields
  • Meta patches are separate from content autosave to avoid races
  • Fork creates with defaults: favorite/pinned/locked false, visibility public
  • Delete requires unfavorite + unlock first (guards match play behavior)

Testing Checklist

  • Linked owner playground: toggle favorite/pin/lock/visibility → partial POST; reload preserves values
  • Create can be private; Open → Saved still opens private owned playgrounds
  • Non-owner on public playground: Fork creates owned copy, navigates to new ID
  • Delete confirms; success clears association; favorite/locked cannot delete
  • Content autosave and meta patch do not clobber each other
  • Unlinked (hash-only) playground: lifecycle actions hidden
Open in Web Open in Cursor 

- Add owner tracking and isOwner computed to useOnePlaygrounds
- Add patchMeta for partial meta updates (favorite/pinned/locked/visibility)
- Add destroy for DELETE with favorite/locked guards
- Add fork for creating owned copy of non-owned playgrounds
- Add visibility control to save dialog for initial create
- Add lifecycle actions to File menu: visibility, favorite, pin, lock, delete (owner); fork (non-owner)
- Register icons: star, pin, lock, eye-off, delete, fork

Fixes #828
@johnleider johnleider added the enhancement New feature or request label Aug 12, 2026
@johnleider johnleider added this to the v1.0.x milestone Aug 12, 2026
API returns owner: { id: string } not userId. Update:
- OnePlayground interface to use owner?: { id: string }
- remember() to use playground.owner?.id
- usePlaygroundFiles setCurrent to pass owner when loading from route
- VuetifyPlayground type to include owner field
- openSaved in Open dialog to pass owner

Also verified:
- clearCurrent + navigateToRoot preserves REPL content/hash
- patchMeta only sends meta fields, not content
@johnleider
johnleider marked this pull request as ready for review August 12, 2026 23:55
Replace File-menu native buttons and the homemade autosave switch
with Button.Root / Switch. Confirm timers use useTimer (3s, one-shot)
and stop when the menu closes. Save-dialog visibility uses Button.Group.
useOnePlaygrounds compares with isUndefined / isNullOrUndefined.
johnleider added a commit that referenced this pull request Aug 13, 2026
Replace the AGENTS.md inventory dump with a v0-vs-native/homemade
if/then (file stays under 10k). Point at SKILL.md, PHILOSOPHY.md,
and .claude/rules/. Skill description now fires on native button,
homemade timer, and homemade overlay so the #840 misses load it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

playground: One lifecycle UI - visibility, lock, fork, pin, favorite, delete

2 participants