Skip to content

Fix bookmarklet saving the same post twice - #212

Merged
fboucher merged 1 commit into
v-nextfrom
bug/issue-211-bookmarklet-double-add
Oct 4, 2026
Merged

fboucher merged 1 commit into
v-nextfrom
bug/issue-211-bookmarklet-double-add

Conversation

@fboucher

@fboucher fboucher commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Requested by Frank · project thread

Fixes #211

Before: clicking the bookmarklet opened Quick Add and the post showed up twice in the library.

After: the bookmarklet saves exactly one post. Opening Quick Add again for a URL that is already saved shows the existing post instead of adding another copy.

The page is prerendered and then rendered again once the interactive circuit connects, and each pass called the extract-and-save API, which creates a new row every time.

How

  • QuickAdd.razor checks RendererInfo.IsInteractive and, while prerendering, only shows the progress spinner; the save runs once, in the interactive render. The MAUI app's BlazorWebView is always interactive, so it is unaffected.
  • POST /api/posts/extractPostDetails now looks up the URL first (new DataStorageService.GetPostByUrl) and returns the stored post if there is one. This also protects the Posts page and suggestion list, which call the same API. Re-adding an already read post returns that post rather than creating a fresh unread one.

Tests

  • QuickAddTests: new test renders the page in prerender mode and then interactive mode and asserts a single save; another asserts the prerender pass shows the spinner and does not save. Both fail on v-next and pass here. Existing tests now set an interactive renderer.
  • PostEndpointsTests: calling extract twice for the same URL returns the same post and stores one row (fails on v-next, passes here).
  • DataStorageServiceTests: GetPostByUrl found / not found.
  • Run locally: BlazorApp tests 63/63. API tests were run against a local Azurite (no Docker in the sandbox); the only failures were ExtractPostDetails_WithValidUrl_ReturnsOkWithPost, which needs to fetch docs.microsoft.com, and a cross-test data leak caused by sharing one emulator across test classes. CI uses per-class containers.

Existing posts already saved twice are not cleaned up (out of scope per the issue).

🤖 Generated with Claude Code

https://claude.ai/code/session_014Yup1wuZFURs47VNTrAK7g


Generated by Claude Code

The Quick Add page is rendered with InteractiveServer and prerendering, so
two component instances ran OnParametersSetAsync and each called
ExtractPostDetailsAndSave, which mints a new RowKey per call.

- QuickAdd skips the save while prerendering (RendererInfo.IsInteractive)
  and shows the progress spinner; the interactive render does the save.
- The extractPostDetails endpoint returns the existing post when one is
  already stored for the URL, so repeat requests never add a duplicate.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014Yup1wuZFURs47VNTrAK7g
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown

Code Coverage

Package Line Rate Branch Rate Health
NoteBookmark.AIServices 97% 64% ✔
NoteBookmark.Api 89% 80% ✔
NoteBookmark.BlazorApp 4% 10% ❌
NoteBookmark.Domain 93% 76% ✔
NoteBookmark.ServiceDefaults 96% 75% ✔
NoteBookmark.SharedUI 26% 33% ❌
Summary 58% (1172 / 2016) 51% (346 / 681) ❌

@fboucher
fboucher marked this pull request as ready for review October 4, 2026 11:56
@fboucher
fboucher merged commit 0af4ab2 into v-next Oct 4, 2026
1 check passed
@fboucher
fboucher deleted the bug/issue-211-bookmarklet-double-add branch October 4, 2026 13:39
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.

3 participants