-
Notifications
You must be signed in to change notification settings - Fork 0
Add sidebar to dashboard and fix broken /notes route #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lishaduck
wants to merge
15
commits into
loro-redo
Choose a base branch
from
pr-8
base: loro-redo
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
558457d
Add sidebar to dashboard and fix broken /notes route
ParkerH27 bf14a89
Fix signup/login redirect serialization error
ParkerH27 98a22ba
Merge local main (with sidebar fixes) into pr-8
ParkerH27 0b0b728
Add sleek history panel for Loro version tracking
ParkerH27 331c6e1
Make toolbar compact and responsive for smaller screens
ParkerH27 3b651af
Add live-synced per-user history tracking with Loro CRDTs
ParkerH27 f2e76b9
Add debug logging for real-time sync troubleshooting
ParkerH27 cc22295
Fix SSE connection drops with keep-alive mechanism
ParkerH27 62b06e1
feat: add collapsible sidebar with toggle button and dropdown toolbar
ParkerH27 88491ca
refactor: centralize sidebar state management with Svelte context, re…
ParkerH27 d03ccb4
fix: Update sidebar collapse button class from `btn-sq` to `btn-square`.
ParkerH27 32f5f5d
start cleaning
lishaduck 9a47db6
feat: versions and times and shtuffies
lishaduck f599191
feat: enhance sidebar logic
lishaduck a8e469e
feat: improve history
lishaduck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,178 @@ | ||
| <script lang="ts"> | ||
| import { Clock, RotateCcw, User } from "@lucide/svelte"; | ||
| import type { LoroNoteManager } from "$lib/loro.ts"; | ||
| import { onMount } from "svelte"; | ||
|
|
||
| interface Props { | ||
| manager: LoroNoteManager | undefined; | ||
| isOpen: boolean; | ||
| onClose: () => void; | ||
| } | ||
|
|
||
| let { manager, isOpen, onClose }: Props = $props(); | ||
|
|
||
| interface HistoryEntry { | ||
| version: number; | ||
| timestamp: Date; | ||
| preview: string; | ||
| } | ||
|
|
||
| let history = $state<HistoryEntry[]>([]); | ||
| let selectedVersion = $state<number | null>(null); | ||
| let unsubscribe: (() => void) | null = null; | ||
|
|
||
| // Load history from Loro document | ||
| function loadHistory() { | ||
| if (!manager) { | ||
| history = []; | ||
| return; | ||
| } | ||
|
|
||
| history = manager.getHistory(); | ||
| } | ||
|
|
||
| // Subscribe to live updates | ||
| $effect(() => { | ||
| if (manager && isOpen) { | ||
| loadHistory(); | ||
|
|
||
| // Subscribe to document changes for live updates | ||
| unsubscribe = manager.subscribeToHistory(() => { | ||
| loadHistory(); | ||
| }); | ||
| } | ||
|
|
||
| return () => { | ||
| if (unsubscribe) { | ||
| unsubscribe(); | ||
| unsubscribe = null; | ||
| } | ||
| }; | ||
| }); | ||
|
|
||
| function restoreVersion(version: number) { | ||
| // TODO: Implement version restoration using Loro's checkout functionality | ||
| console.log("Restoring version:", version); | ||
| } | ||
|
|
||
| function formatTime(date: Date): string { | ||
| const now = new Date(); | ||
| const diff = now.getTime() - date.getTime(); | ||
| const minutes = Math.floor(diff / 60000); | ||
| const hours = Math.floor(diff / 3600000); | ||
| const days = Math.floor(diff / 86400000); | ||
|
|
||
| if (minutes < 1) return "Just now"; | ||
| if (minutes < 60) return `${minutes}m ago`; | ||
| if (hours < 24) return `${hours}h ago`; | ||
| return `${days}d ago`; | ||
| } | ||
| </script> | ||
|
|
||
| {#if isOpen} | ||
| <div | ||
| class="fixed inset-y-0 right-0 z-50 flex w-80 flex-col border-l border-base-content/10 bg-base-100 shadow-xl" | ||
| > | ||
| <!-- Header --> | ||
| <div | ||
| class="flex items-center justify-between border-b border-base-content/10 p-4" | ||
| > | ||
| <div class="flex items-center gap-2"> | ||
| <Clock class="h-5 w-5 text-primary" /> | ||
| <h2 class="text-lg font-semibold">Version History</h2> | ||
| </div> | ||
| <button | ||
| onclick={onClose} | ||
| class="btn btn-circle btn-ghost btn-sm" | ||
| aria-label="Close history" | ||
| > | ||
| ✕ | ||
| </button> | ||
| </div> | ||
|
|
||
| <!-- History List --> | ||
| <div class="flex-1 overflow-y-auto p-4"> | ||
| {#if history.length === 0} | ||
| <div class="flex h-full items-center justify-center text-center"> | ||
| <div> | ||
| <Clock class="mx-auto mb-2 h-12 w-12 text-base-content/30" /> | ||
| <p class="text-sm text-base-content/60">No history available</p> | ||
| </div> | ||
| </div> | ||
| {:else} | ||
| <div class="space-y-2"> | ||
| {#each history as entry, i (entry.version)} | ||
| <button | ||
| onclick={() => (selectedVersion = entry.version)} | ||
| class={[ | ||
| "w-full rounded-lg border p-3 text-left transition-all", | ||
| selectedVersion === entry.version | ||
| ? "border-primary bg-primary/10" | ||
| : "border-base-content/10 hover:border-primary/50 hover:bg-base-200", | ||
| ].join(" ")} | ||
| > | ||
| <!-- Version Header --> | ||
| <div class="mb-2 flex items-center justify-between"> | ||
| <div class="flex items-center gap-2"> | ||
| {#if entry.author} | ||
| <div | ||
| class="flex h-6 w-6 items-center justify-center rounded-full bg-primary text-xs font-medium text-primary-content" | ||
| > | ||
| {entry.author[0].toUpperCase()} | ||
| </div> | ||
| <span class="text-sm font-medium">{entry.author}</span> | ||
| {:else} | ||
| <User class="h-4 w-4 text-base-content/50" /> | ||
| <span class="text-sm text-base-content/60">Unknown</span> | ||
| {/if} | ||
| </div> | ||
| <span class="text-xs text-base-content/50"> | ||
| {formatTime(entry.timestamp)} | ||
| </span> | ||
| </div> | ||
|
|
||
| <!-- Preview --> | ||
| <p class="line-clamp-2 text-xs text-base-content/70"> | ||
| {entry.preview || "Empty document"} | ||
| </p> | ||
|
|
||
| <!-- Version Number --> | ||
| <div class="mt-2 flex items-center justify-between"> | ||
| <span class="font-mono text-xs text-base-content/50"> | ||
| v{entry.version} | ||
| </span> | ||
| {#if i === 0} | ||
| <span | ||
| class="rounded-full bg-success/20 px-2 py-0.5 text-xs font-medium text-success" | ||
| > | ||
| Current | ||
| </span> | ||
| {/if} | ||
| </div> | ||
| </button> | ||
| {/each} | ||
| </div> | ||
| {/if} | ||
| </div> | ||
|
|
||
| <!-- Actions --> | ||
| {#if selectedVersion !== null && selectedVersion !== history[0]?.version} | ||
| <div class="border-t border-base-content/10 p-4"> | ||
| <button | ||
| onclick={() => restoreVersion(selectedVersion)} | ||
| class="btn w-full btn-primary" | ||
| > | ||
| <RotateCcw class="h-4 w-4" /> | ||
| Restore This Version | ||
| </button> | ||
| </div> | ||
| {/if} | ||
| </div> | ||
|
|
||
| <!-- Backdrop --> | ||
| <button | ||
| onclick={onClose} | ||
| class="fixed inset-0 z-40 bg-black/20 backdrop-blur-sm" | ||
| aria-label="Close history panel" | ||
| ></button> | ||
| {/if} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.