Skip to content

Notes: Merge the sticky-notes into pinned notes - #497

Draft
mmtr wants to merge 7 commits into
trunkfrom
claude/sticky-note-context-menu-b83d9f
Draft

Notes: Merge the sticky-notes into pinned notes#497
mmtr wants to merge 7 commits into
trunkfrom
claude/sticky-note-context-menu-b83d9f

Conversation

@mmtr

@mmtr mmtr commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Fixes #344.

Proposed Changes

  • Removes the Guidelines-backed sticky notes: src/sticky-notes/, includes/sticky-notes/, their CSS, their tests, and the openstation_sticky_notes_available filter, the openStationConfig.stickyNotes.available flag and the openstation_sticky_notes_subscribe Heartbeat channel.
  • Adds a New note entry to the wallpaper right-click menu. It pins an empty paper note where the click landed and focuses its editor.
  • Adds a Move to Trash button to the note, alongside the colour, visibility and convert controls. It confirms first, then takes the same path as dragging the pin to the bin.
  • Fixes dragging anything onto the dock's Trash, which silently did nothing in the classic layout.
  • Fixes the Trash badge count, which never moved when a note was trashed.
  • Gives the os.wallpaper-context-menu filter a second argument, { x, y }, carrying the right-click position.

Why are these changes being made?

We had two wallpaper note surfaces, two CPTs, two Heartbeat channels and two visual languages, and only one of them worked.

Sticky notes rode Gutenberg's Guidelines experiment (the wp_guideline CPT and wp_guideline_type taxonomy). Gutenberg renamed that storage primitive to wp_knowledge in #79149 and dissolved the singleton into per-scope rows in #79263, so openstation_sticky_notes_is_available() has returned false on every site since. The layer stopped booting and its menu entry stopped appearing, which is why #344 no longer reproduces. Chasing an opt-in experiment that has already renamed its storage once buys us maintenance, not a feature.

Pinned notes win on everything else anyway: plugin-owned storage, server-side placement every viewer shares, a real delete path with Undo and Trash restore, colours, sharing with attribution, convert-to-post, and the test coverage.

The filter's new second argument is needed because onClick is invoked with a synthetic MouseEvent. Any item that places something on the wallpaper would read (0, 0) off the event. It is additive, so existing filters are unaffected.

The two bugs

The dock's Trash accepted nothing. recycle-bin-targets.ts resolved "the bin" through an ordered selector list and registered a drop target on the first match. But the bin is not one element: in the default classic layout the wallpaper tile (.os-file-tile[data-file-ref]) and the dock system tile ([data-system-id]) are both on screen, and the wallpaper tile won. The dock tile had no target, so a drag over it never highlighted and a release over it did nothing. This affected file and shortcut drags too, not just notes. Now every surface registers under its own id.

The Trash badge ignored notes. The badge keeps its count live by subscribing to os.<post-type>.changed for each type the bin captures, and wpd_note is in that list. Nothing on the notes side ever published it, so trashing a note moved the server's count while the dock kept whatever it had at boot. trashNoteWithUndo and convertNoteToPost now publish the same { source, action, ids } payload the files layer uses.

On the trash button's placement

It is in the note's footer, not next to the visibility and convert buttons in the top meta row. The pushpin is 56px wide, centred, jittered by up to 10px and painted above the paper's chrome, so it covers note-relative x 62–138. The right-aligned meta row already runs back to ~136 with three controls; a fourth lands under the pin, where document.elementFromPoint resolves to .os-pinned-note__pin and clicking does nothing. Measured in a browser both ways before choosing.

Per-desktop notes

An earlier revision of this branch scoped notes to a virtual desktop. That is reverted: notes are visible on every desktop, exactly as on trunk. No _wpd_note_desktop meta, no desktop field on the wire, no toggle.

No data migration

Sticky notes only existed on sites running Gutenberg with the experiment enabled, and the wp_guideline posts survive untouched. An importer would mean guessing at term scoping for a population that is almost certainly zero.

Testing Instructions

Run npm run build first.

New note on the wallpaper

  1. Open the shell at /wp-admin/index.php?desktop_mode_portal=1.
  2. Right-click an empty patch of wallpaper. Make sure a New note entry appears between New URL and Sort by.
  3. Click it. Make sure a paper note appears with its top-left at the click position, the pushpin animation plays, and the cursor lands in the note's editor.
  4. Type a few words, wait a second, then reload. Make sure the text and the position survived.
  5. Create two or three notes this way. Make sure each gets a visibly different paper tilt and pin angle. They start with empty text, so seeding the jitter from the text alone would give every one of them the identical tilt.
  6. Right-click near the right edge and pick New note. Make sure the note is not pushed off the right edge.
  7. Right-click near the bottom edge and pick New note. The note's pin and its top ~120px stay on screen; the rest is clipped (measured ~110px on a 900px-tall viewport). That is the existing clampPosition behaviour, unchanged here, but the menu makes it easier to reach than the Note Pad drag did.

Trash button on the note

  1. Hover a note you own. The top row carries the colour dot, the lock, and (with edit_posts) the convert button; the footer carries the trash button and the save-status chip.
  2. Click the trash button with the mouse. Make sure a "Move note to the Trash?" dialog appears, and confirming removes the note.
  3. Click the lock with the mouse too, and make sure it toggles. It sits next to the pushpin, which is painted on top of the paper's chrome.
  4. Hover someone else's public note. Make sure it has no trash button.

Drag to the Trash, from both surfaces

  1. Drag a note by its pushpin onto the Trash icon on the desktop. Make sure it highlights on hover, crumples on release, and an Undo toast appears.
  2. Drag another note onto the Trash in the dock. Make sure it highlights and trashes the same way. This is the case that silently did nothing before.
  3. Do the same with a desktop file or shortcut onto the dock Trash, to confirm the shared fix.

Trash badge

  1. Empty the Trash so the dock badge is gone: wp post delete $(wp post list --post_type=wpd_note --post_status=trash --format=ids) --force
  2. Note the badge (absent, or its current number).
  3. Drag a note to the Trash. Make sure the badge appears / increments by exactly one, immediately.
  4. Click Undo on the toast. Make sure it decrements back.
  5. Cross-check against the server: wp eval 'echo openstation_recycle_bin_count();' should match the badge at every step.
  6. Convert a note to a post (the convert button). Make sure the badge increments, since convert trashes the source note.

Notes are not desktop-scoped

  1. Create two desktops. Make sure every note you can see appears on both, and that no note carries a desktop toggle.

Nothing sticky left behind

  1. Install the Gutenberg plugin and enable Guidelines under Gutenberg → Experiments.
  2. Reload the shell. Make sure no second note surface appears, the wallpaper menu has no "New sticky note" entry, and the console is free of guideline REST 404s.

Automated

npm run test:js (3784), npm run test:php (2028), npm run lint, npm run lint:php, npm run typecheck, all green.

🤖 Generated with Claude Code

Open WordPress Playground Preview

Removes the Guidelines-backed sticky notes and folds the two things it
did better into pinned notes: a "New note" wallpaper context-menu entry
and per-desktop scoping.

Sticky notes rode Gutenberg's Guidelines experiment. Gutenberg renamed
that storage primitive from wp_guideline to wp_knowledge, so the
availability gate returned false everywhere and the layer never booted,
leaving one dead notes surface next to a working one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@mmtr mmtr self-assigned this Aug 5, 2026
@mmtr mmtr changed the title Notes: Merge the sticky-note surface into pinned notes Notes: Merge the sticky-notes into pinned notes Aug 5, 2026
mmtr and others added 5 commits August 5, 2026 15:23
…ontext-menu-b83d9f

# Conflicts:
#	docs/architecture.md
#	docs/javascript-reference.md
#	includes/render/assets.php
…tilt

Four fixes to the per-desktop work, all found in a real browser:

- Subscribe to DESKTOP_CREATED, and let one method own whether the
  toggle is present. It was built once at paint, gated on the desktop
  count, so adding a desktop mid-session never grew it in. A note bound
  while the session had one desktop was then stranded: hidden on the new
  desktop, with no control on the old one to unbind it, until a reload.

- Move the toggle from the meta row to the footer. The pushpin is 56px
  wide, centred, jittered by up to 10px and painted above the paper's
  chrome, so it covers note-relative x 62-138. A fourth control in the
  right-aligned meta row pushed the visibility lock underneath it, where
  elementFromPoint resolves to the pin and a click does nothing. Affects
  any owner with edit_posts on a multi-desktop session.

- Seed the paper jitter from the drop position when a note has no text.
  The wallpaper menu always creates empty notes and hashNoteSeed('')
  is a constant, so every note from the new primary creation path got
  an identical tilt and pin angle.

- Say what clampPosition actually guarantees in the testing steps: the
  vertical clamp reserves a fixed 120px against a note that is ~230px
  tall, so a note pinned near the bottom edge is clipped. Pre-existing
  and unchanged here, but the menu makes it much easier to reach.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…h button

Reverts the virtual-desktop binding. Notes are visible on every desktop
again, as on trunk: the `_wpd_note_desktop` meta, the `desktop` wire
field, the footer toggle and the DESKTOP_* wiring are all gone. The
wallpaper "New note" entry stays.

Three fixes on top:

- Register a bin drop target on every surface that represents the
  Trash, not just the first selector match. The classic layout renders
  the bin as a wallpaper tile AND a dock system tile at once, so
  resolving "the" bin to one element left the dock tile with nothing
  attached: dragging a note onto the dock Trash lit up nothing and did
  nothing on release. Files were affected the same way.

- Publish `os.wpd_note.changed` when a note is trashed, restored, or
  converted. The Recycle Bin badge counts deltas off that topic for
  every post type the bin captures, and `wpd_note` is one of them, so
  without it the server's count moved and the dock badge kept whatever
  it had at boot. Verified in a browser: badge and REST /count now
  agree after a drag-to-bin.

- Add a "Move to Trash" button to the note, next to the other actions.
  It confirms first, then takes the same path as drag-to-bin. It sits
  in the footer rather than the meta row because the pushpin covers
  note-relative x 62-138 and a fourth control in the right-aligned meta
  row lands underneath it, unreachable with a pointer.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ontext-menu-b83d9f

# Conflicts:
#	docs/architecture.md
#	docs/javascript-reference.md
It sat at a constant 0.75 opacity while the colour dot, visibility and
convert buttons fade in with the meta row, so every note carried a
permanently visible trash icon.

It can't live inside `.os-pinned-note__meta` and inherit that reveal
(the pushpin covers the meta row's left half), so the fade is repeated
on the button. Resting at 0.75 when revealed matches what a meta-row
button resolves to: the row fades to 1 and each button sits at 0.75
inside it.

The button's own :hover is scoped through the note. Bare
`.os-pinned-note__trash:hover` is (0,2,0) and the reveal rule is
(0,3,0), so it would never have reached full opacity — you are always
hovering the note when you hover its button.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@mmtr
mmtr marked this pull request as draft August 6, 2026 15:06
…ontext-menu-b83d9f

# Conflicts:
#	includes/render/assets.php
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.

Closing a sticky note doesn't delete it — the note reappears on the next desktop render

1 participant