Skip to content

Improve admin UX with confirmations and fix analytics edge cases - #6

Merged
injoon5 merged 1 commit into
mainfrom
claude/codebase-audit-wno3h5
Aug 16, 2026
Merged

Improve admin UX with confirmations and fix analytics edge cases#6
injoon5 merged 1 commit into
mainfrom
claude/codebase-audit-wno3h5

Conversation

@injoon5

@injoon5 injoon5 commented Aug 16, 2026

Copy link
Copy Markdown
Owner

This PR improves the admin interface with user confirmations for destructive actions and fixes several edge cases in analytics tracking and UI behavior.

Key Changes

Admin Delete Confirmations

  • Added confirmation dialogs to all destructive delete operations (pastes, links, files) with consistent messaging
  • Confirmations inform users that analytics history is preserved
  • Implemented as reusable confirmDelete submit functions across multiple forms

Analytics Tracking Fixes

  • Fixed race condition where page's deferred track() write could land after beacon, creating duplicate visitor rows
  • Added PURGE_VISITOR statement to clean up rows that couldn't be migrated due to existing fingerprint identity
  • Updated migration logic to use UPDATE OR IGNORE to gracefully handle conflicts
  • Added error handling to beacon endpoint so storage hiccups don't prevent fingerprint cookie assignment
  • Added retry logic for deferred page track writes with purge cleanup

UI/UX Improvements

  • Fixed disabled/busy link button behavior: now drops href and prevents navigation instead of navigating mid-flight
  • Improved graph wheel scroll behavior to only prevent default when pan actually moves (fixes edge scrolling)
  • Fixed device labels in analytics to display title-case ("Mobile", "Desktop", "Bot") for consistency with other lists
  • Improved paste form body field handling with proper state management using untrack to prevent unwanted resets during typing

Documentation & Validation

  • Updated image key regex to accept manually-written keys with dots and dashes, not just hex
  • Clarified comments around analytics batch operations and race conditions
  • Fixed file download page to avoid repeating file size in metadata
  • Updated quick links form hint to clarify these are for share cards/structured data, not page body buttons
  • Improved admin layout comments for clarity

Notable Implementation Details

The analytics fix uses a three-statement batch: migrate old identity to fingerprint identity, purge any rows that couldn't migrate, then ensure home row exists. This handles the case where the fingerprint identity already has a row for the same (day, slug) pair, which would normally cause a primary key conflict.

The paste form body field uses Svelte's untrack to prevent the derived initial value from resetting the body on every keystroke while still allowing it to seed when the selected paste changes.

https://claude.ai/code/session_01DwxzS8U3YVf6NyDqSaHsAE

…cs dedupe, and polish

Functional bugs:
- FileForm: add missing `bind:this` on the file input. Without it the
  "Choose a file" button was a no-op (only the field label and drag-drop
  worked) and the remove button couldn't clear the native input, so a
  "removed" file was still uploaded on submit.
- IdentityForm: the quick-links hint described the wrong field order
  (icon | label | url) and the wrong destination (:::links buttons). The
  field parses label | href | icon and feeds the share card and JSON-LD,
  not the on-page link buttons. Corrected the hint.
- PasteForm: the character counter was bound to a derived prop, so it
  froze at the initial length while typing. Bind the textarea to local
  state (re-seeded on selection change via untrack) so it counts live.
- analytics/beacon: the visitor-identity migration (UPDATE onto the
  visitors PK) could collide when the page's deferred track() write
  landed after the beacon, aborting the batch and dropping the
  fingerprint cookie. Switch to UPDATE OR IGNORE plus a purge of leftover
  rows, and stop the batch failure from failing the beacon. Adds a
  regression test.

Polish:
- Analytics: title-case device labels (Mobile/Desktop/Bot) to match the
  lists beside them.
- Download page: stop printing the file size twice.
- w.js: the contribution-graph wheel handler no longer traps page scroll
  at the pan's edges (releases the wheel when the pan can't move).
- Consistent delete confirmation on link, paste, and file deletes.
- Button: an `<a>` variant now drops its href and stops taking
  focus/clicks when busy or disabled.
- imageKeysIn: match the `[\w.-]` key characters the renderer accepts so
  a manually-written key isn't GC'd out from under a live document.
- Refresh two stale nav comments.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DwxzS8U3YVf6NyDqSaHsAE
@injoon5
injoon5 merged commit dabeb31 into main Aug 16, 2026
1 check 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