Can we introduce pinned threads?

merged…
osebo28d ago

Can we introduce pinned threads?

7 repliesoldestnewest
Osebotfable-5-128d ago

Plan for pinned threads:

  • Data: threads.pinned_at timestamptz (null = not pinned), migration drizzle/0015_thread_pinned.sql. A timestamp instead of a boolean so several pins keep a stable order (latest pin on top).
  • Ordering: listThreads sorts pinned threads first (pinned_at desc nulls last, then updated_at desc), so pins float to the top of the workspace home, the manage page's list and the live search/status filters alike.
  • Who can pin: the workspace owner only. Pinning is curation of the workspace's front page, so I'm not giving it to thread creators (who can otherwise delete / share their own threads). canPinThread in lib/session.ts.
  • API: PATCH /api/threads/[id] learns { pinned: boolean } next to the existing { public }; GET /api/threads returns pinnedAt.
  • UI: a "Pin thread" / "Unpin thread" item in the thread page's Manage menu (components/thread-menu.tsx, single tap, no arming since it's reversible and harmless), a small framed "pinned" chip with a pin glyph in the thread status row and in the thread list's meta line, and pinned rows get a quiet marker in the list.

I'll mock the list + menu up with a static page against globals.css and attach screenshots.

Osebotfable-5-128d ago

Implemented and typechecked (commit 54b1cc3, not pushed yet):

  • threads.pinned_at + drizzle/0015_thread_pinned.sql; listThreads orders by pinned_at desc nulls last, updated_at desc (verified the generated SQL with toSQL()).
  • PATCH /api/threads/[id] now takes { public?, pinned? } (at least one); pinned requires a workspace owner (canPinThread in lib/session.ts), public keeps the creator-or-owner rule. GET /api/threads returns pinnedAt.
  • Manage menu: "Pin thread" / "Unpin thread" item (owners only, single tap) above Delete.
  • PinnedBadge (components/bits.tsx): framed chip with a new own "pin" glyph, shown in the thread list meta and the thread page status row.

Setting up Chromium for a mockup screenshot of the list + menu next.

Osebotfable-5-128d agothreadide@54b1cc3

Pinned threads are in, pushed on thread/814ce095 (54b1cc3).

What it does

  • A workspace owner opens a thread's Manage menu and taps Pin thread (or Unpin). The thread then sits at the top of the workspace's list; several pins order latest-pin-first, everything else keeps the usual most-recently-active order. Pins still obey search, the status filter and who-may-read.
  • A framed "pinned" chip (new own pin glyph) shows in the list's meta line and in the thread page's status row, so a 3-day-old thread above a 12-minute-old one isn't confusing.

Decisions worth knowing

  • Owner-only on purpose: pinning curates the workspace's front page, so thread creators don't get it (they keep share/delete on their own threads). One-line change in canPinThread if you'd rather let creators pin too.
  • pinned_at is a timestamp, not a boolean, to give pins a stable order.
  • No separate "Pinned" section, no tinted rows: just ordering plus the chip, keeping the list quiet.

Changes: db/schema.ts + drizzle/0015_thread_pinned.sql (nullable pinned_at), lib/data.ts (ordering, setThreadPinned), lib/session.ts (canPinThread), PATCH /api/threads/[id] takes { pinned } next to { public }, GET /api/threads returns pinnedAt, components/thread-menu.tsx (Pin/Unpin item), components/bits.tsx (PinnedBadge), components/pulp-icons.tsx ("pin" glyph), components/thread-list.tsx, app/threads/[id]/page.tsx, app/globals.css.

Verified: typecheck clean; generated SQL checked via toSQL(); screenshots below are the real components rendered against globals.css (the app can't run in the sandbox). Not exercised live: the PATCH round trip and the page refresh after pinning. The migration applies on the production deploy of the merge.

Thread list mockup: the pinned thread (3d old) sits above newer ones with the framed "pinned" chip first in its meta line
Thread list mockup: the pinned thread (3d old) sits above newer ones with the framed "pinned" chip first in its meta line
Thread page mockup: "pinned" chip in the status row and the owner's Manage menu with Unpin thread above Delete
Thread page mockup: "pinned" chip in the status row and the owner's Manage menu with Unpin thread above Delete
Thread list at 390px: the chip still fits before the status badge
Thread list at 390px: the chip still fits before the status badge
oseboasked Osebot28d ago

You could just show the pinned icon in the thread list and on the thread itself

Osebotfable-5-128d ago

Dropping the framed "pinned" chip for a bare pin glyph: PinnedBadge → PinnedIcon (just the own "pin" glyph in muted ink, with the tooltip kept), in the same two places (thread list meta line, thread page status row). The .badge.pinned CSS goes; a small .pin-mark rule aligns the glyph with the text. Screenshot after.

Osebotfable-5-128d agothreadide@2f10a8e

Done: the framed "pinned" chip is gone, it's just the pin glyph now (pushed as 2f10a8e on thread/814ce095).

  • PinnedBadge → PinnedIcon in components/bits.tsx: the own pin glyph in muted ink inside span.pin-mark, with the tooltip ("Pinned by a workspace owner: stays at the top of the list") and an aria-label, no word and no frame.
  • Thread list meta line: 14px glyph before the status badge. Thread page status row: 16px glyph after the status badge.
  • .badge.pinned CSS replaced by a two-line .pin-mark rule in app/globals.css.

Everything else from the first pass (owner-only Pin/Unpin in the Manage menu, pinned_at ordering, migration 0015) is unchanged. Typecheck clean; screenshots below are the real components against globals.css.

Thread list: the pinned thread (3d old) on top with just the pin glyph before its status badge
Thread list: the pinned thread (3d old) on top with just the pin glyph before its status badge
Thread page status row: pin glyph next to the status badge, no chip
Thread page status row: pin glyph next to the status badge, no chip
Thread list at 390px
Thread list at 390px
Osebot28d ago

Merged threadide #165 by @osebo (merge, cdca073).