Skip to content

Add assistant message starring and fix Svelte state handling#25

Merged
0xGingi merged 1 commit intonanogpt-community:mainfrom
jcrabapple:analytics-speed-metrics
Jan 1, 2026
Merged

Add assistant message starring and fix Svelte state handling#25
0xGingi merged 1 commit intonanogpt-community:mainfrom
jcrabapple:analytics-speed-metrics

Conversation

@jcrabapple
Copy link
Copy Markdown

Summary

This PR adds support for starring assistant messages in the chat view and fixes a Svelte state-handling issue related to message.starred in src/routes/chat/[id]/message.svelte.

Changes

  • Add a star/unstar toggle button for assistant messages in src/routes/chat/[id]/message.svelte.
  • Track isStarred using $state plus a $effect that reacts to message.starred instead of capturing the initial message value in the state initializer.
  • Wire the star toggle to api.messages.setStarred with optimistic UI updates and rollback on failure.
  • Invalidate api.messages.getAllFromConversation after a successful update so other consumers stay in sync.

Rationale

Previously, the starred state logic referenced message directly inside the $state initializer, which caused Svelte to warn that the reference only captures the initial value. This PR moves that logic into a $effect, ensuring that isStarred always reflects the latest message.starred value.

The new star toggle provides a quick way for users to flag assistant messages as important, while keeping the UI responsive and consistent with server state.

Testing

  • Started the dev server with bun --bun run dev.
  • Opened a chat and generated assistant messages.
  • Verified that:
    • The star icon appears only on assistant messages with non-empty content and no error.
    • Clicking the star toggles its visual state between filled (starred) and muted (unstarred).
    • The starred state persists after a refresh (server round-trip).
    • No Svelte warnings about local state references to message are emitted at build/runtime.

Co-Authored-By: Warp agent@warp.dev

- Add star/unstar toggle for assistant messages with optimistic UI and server sync
- Track starred state via reactive effect instead of capturing initial message value to satisfy Svelte state rules

Co-Authored-By: Warp <agent@warp.dev>
@0xGingi 0xGingi merged commit 6b01cf2 into nanogpt-community:main Jan 1, 2026
3 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