Skip to content

Conversation

buneeIsSlo
Copy link
Contributor

@buneeIsSlo buneeIsSlo commented Aug 19, 2025

Overview

Adds pin/unpin for chats, shows a dedicated “Pinned” section in the sidebar and drawer history, and keeps pinned chats ordered by most recently pinned. Pinned chats are excluded from date-based groups.

Changes made

  • Database

    • Add pinned boolean DEFAULT false NOT NULL
    • Add pinned_at timestamptz NULL
  • API

    • New route: POST /api/toggle-chat-pin
    • Body: { chatId: string, pinned: boolean }
    • Updates pinned and pinned_at accordingly; does not bump updated_at
  • UI

    • sidebar-item-menu.tsx: Pin/Unpin item (uses togglePinned), icons from lucide-react
    • app-sidebar.tsx: New “Pinned” section above grouped lists; uses pinnedChats (or a local useMemo if not exposed)
    • history/utils.ts: groupChatsByDate skips pinned to avoid duplicates
    • drawer-history.tsx: Pin/Unpin button in each row; “Pinned” section above groups; date shows updated_at || created_at

Behavior

  • Ordering
    • Pinned section: most recently pinned first (pinned_at DESC)
    • Unpinned groups: unchanged, ordered by updated_at buckets
  • Edit semantics
    • Pinning does not change updated_at
    • Title edits still bump updated_at for unpinned items

Migration

  • Run once:
ALTER TABLE public.chats
  ADD COLUMN IF NOT EXISTS pinned boolean NOT NULL DEFAULT false,
  ADD COLUMN IF NOT EXISTS pinned_at timestamptz NULL;

Manual testing

  • Pin a chat from sidebar menu → appears in “Pinned” section, vanishes from time groups
  • Unpin a chat → disappears from “Pinned”, reappears in correct time group
  • Multiple pinned chats are ordered by most recently pinned
  • Drawer history: pin/unpin button works and UI updates without reload
  • Search mode: doesn’t duplicate items; groups skip pinned as expected
  • Guest vs auth: API gracefully succeeds even if Supabase disabled (no-DB deployments)

Notes

  • Perf: pin/unpin avoids re-sorting entire list; pinned slice is sorted at read-time and memoized; date groups skip pinned upfront.

Previews

In Sidebar:
sidebar.mp4
In Command & Drawer history:
command+drawer.mp4

Copy link

vercel bot commented Aug 19, 2025

@buneeIsSlo is attempting to deploy a commit to the zola Team on Vercel.

A member of the Team first needs to authorize it.

@buneeIsSlo buneeIsSlo marked this pull request as ready for review August 19, 2025 09:25
Copy link

vercel bot commented Aug 19, 2025

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

Project Deployment Preview Comments Updated (UTC)
zola-anfe Ready Ready Preview Comment Aug 19, 2025 0:36am

@buneeIsSlo
Copy link
Contributor Author

@ibelick, do you need to make any additional changes?

@ibelick
Copy link
Owner

ibelick commented Aug 21, 2025

@buneeIsSlo really cool work, appreciate the PR!

@ibelick ibelick merged commit 8905fe6 into ibelick:main Aug 21, 2025
12 checks passed
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.

2 participants