|
| 1 | +# Project Context |
| 2 | + |
| 3 | +- **Owner:** Frank (fboucher) |
| 4 | +- **Project:** NoteBookmark — bookmark and note-taking app; web + MAUI mobile |
| 5 | +- **Stack:** .NET 9, C#, Blazor Server, MAUI Blazor Hybrid, Razor Class Libraries, CSS |
| 6 | +- **Branch:** v-next |
| 7 | +- **Created:** 2026-04-03 |
| 8 | + |
| 9 | +## Key Projects |
| 10 | + |
| 11 | +- `NoteBookmark.BlazorApp` — Blazor Server web app (source of components to extract) |
| 12 | +- `NoteBookmark.SharedUI` — (to be created) Razor Class Library for shared components |
| 13 | +- MAUI app — (to be scaffolded) will reference SharedUI for its Blazor UI |
| 14 | + |
| 15 | +## Components to Extract (Issue #119) |
| 16 | + |
| 17 | +From `NoteBookmark.BlazorApp` into `NoteBookmark.SharedUI`: |
| 18 | +- Post list |
| 19 | +- Post detail |
| 20 | +- Note dialog |
| 21 | +- Search form |
| 22 | +- Settings form |
| 23 | +- Summary list |
| 24 | + |
| 25 | +## Active Backlog (UI-relevant) |
| 26 | + |
| 27 | +- #119 Extract NoteBookmark.SharedUI RCL (primary concern) |
| 28 | +- #120 MAUI scaffold — will consume SharedUI components |
| 29 | +- #123 Online-first MAUI data layer — needs UI data bindings |
| 30 | + |
| 31 | +## Learnings |
| 32 | + |
| 33 | +### Issue #119 — SharedUI RCL Extraction (completed) |
| 34 | + |
| 35 | +**Component structure found in BlazorApp:** |
| 36 | +All the "page" components (Posts, PostEditor, PostEditorLight, Search, Settings, Summaries, SummaryEditor) live in `Components/Pages/` and have `@page` and `@attribute [Authorize]` directives. Shared sub-components (NoteDialog, SuggestionList) live in `Components/Shared/`. MinimalLayout is a layout component in `Components/Layout/`. |
| 37 | + |
| 38 | +**Service injection patterns:** |
| 39 | +- All pages inject `PostNoteClient` — the HTTP client wrapper for the API |
| 40 | +- Search injects `ResearchService` (from NoteBookmark.AIServices) |
| 41 | +- SummaryEditor injects `SummaryService` (from NoteBookmark.AIServices) |
| 42 | +- Posts, Search, SuggestionList inject `IToastService` and `IDialogService` (FluentUI) |
| 43 | +- Settings had dead logging code (`ILogger<Settings>`) that was removed to avoid namespace ambiguity with `NoteBookmark.Domain.Settings` |
| 44 | + |
| 45 | +**PostNoteClient moved to SharedUI:** |
| 46 | +`PostNoteClient` was in `NoteBookmark.BlazorApp` namespace. It was moved to `NoteBookmark.SharedUI` since all its dependencies are in Domain and it's infrastructure code for the UI layer. The class only depends on `HttpClient` + `NoteBookmark.Domain`. |
| 47 | + |
| 48 | +**RCL SDK requires explicit Http.Json using:** |
| 49 | +A `Microsoft.NET.Sdk.Razor` project does not get the same implicit usings as a web project. Had to add `using System.Net.Http.Json;` explicitly to PostNoteClient.cs, and add `<FrameworkReference Include="Microsoft.AspNetCore.App" />` to the csproj. |
| 50 | + |
| 51 | +**Router wiring for RCL pages:** |
| 52 | +When pages with `@page` routes live in an RCL, the consuming BlazorApp needs two things: |
| 53 | +1. `Routes.razor`: `AdditionalAssemblies="new[] { typeof(SharedUI.PostNoteClient).Assembly }"` |
| 54 | +2. `Program.cs`: `.AddAdditionalAssemblies(typeof(SharedUI.PostNoteClient).Assembly)` on `MapRazorComponents` |
| 55 | + |
| 56 | +**SharedUI namespace organisation:** |
| 57 | +``` |
| 58 | +NoteBookmark.SharedUI/ |
| 59 | + PostNoteClient.cs → namespace NoteBookmark.SharedUI |
| 60 | + _Imports.razor → all common @using statements |
| 61 | + Components/ |
| 62 | + Layout/MinimalLayout.razor → namespace NoteBookmark.SharedUI.Components.Layout |
| 63 | + Pages/Posts.razor → namespace NoteBookmark.SharedUI.Components.Pages |
| 64 | + Pages/PostEditor.razor |
| 65 | + Pages/PostEditorLight.razor |
| 66 | + Pages/Search.razor |
| 67 | + Pages/Settings.razor |
| 68 | + Pages/Summaries.razor |
| 69 | + Pages/SummaryEditor.razor |
| 70 | + Shared/NoteDialog.razor → namespace NoteBookmark.SharedUI.Components.Shared |
| 71 | + Shared/SuggestionList.razor |
| 72 | +``` |
| 73 | + |
| 74 | +**Test project (BlazorApp.Tests) anticipated this:** |
| 75 | +The test project had a `TODO` comment pointing to this issue. After extraction, updated: |
| 76 | +- `NoteDialogTests.cs`: `using NoteBookmark.SharedUI.Components.Shared` |
| 77 | +- `SuggestionListTests.cs`: `using NoteBookmark.SharedUI.Components.Shared` |
| 78 | +- `MinimalLayoutTests.cs`: `using NoteBookmark.SharedUI.Components.Layout` |
| 79 | +- `BlazorTestContextExtensions.cs`: `using NoteBookmark.SharedUI` (for PostNoteClient) |
| 80 | +- Added `<ProjectReference>` to NoteBookmark.SharedUI in test .csproj |
| 81 | + |
| 82 | +--- |
| 83 | + |
| 84 | +## Run Complete — 2026-04-03 |
| 85 | + |
| 86 | +**Status:** ✅ COMPLETED |
| 87 | +**Branch:** squad/119-extract-sharedui |
| 88 | +**PR:** #129 (draft) |
| 89 | + |
| 90 | +All 11 components extracted, namespaces organized, BlazorApp wiring updated. Biggs' regression testing confirmed zero behavioral changes. Test suite created in `NoteBookmark.BlazorApp.Tests` with 20 passing tests and 5 skipped (NoteDialog, awaiting component refactor). Build green. Ready for Wedge to scaffold MAUI app (#120). |
| 91 | + |
| 92 | +**Cross-agent note:** Biggs identified component-level refactoring needed in NoteDialog (replace `Dialog.CloseAsync()` with `EventCallback<NoteDialogResult>` to eliminate cascade dependency and enable full test coverage). |
| 93 | + |
| 94 | +### Issue #119 — NoteDialog EventCallback Refactor (completed) |
| 95 | + |
| 96 | +**Why:** Biggs' regression tests for NoteDialog were all `[Fact(Skip = ...)]` because bUnit 2.x cannot |
| 97 | +cascade a null `FluentDialog`. `NoteDialog` called `Dialog.CloseAsync()` and `Dialog.Instance.Parameters.Title`, |
| 98 | +making it impossible to render without a live FluentUI dialog infrastructure. |
| 99 | + |
| 100 | +**What changed in NoteDialog:** |
| 101 | +- `FluentDialogHeader`, `FluentDialogBody`, `FluentDialogFooter` replaced with plain `<div>` wrappers |
| 102 | + (these structural components internally cascade-require `FluentDialog` too) |
| 103 | +- `[CascadingParameter] FluentDialog Dialog` made **nullable** (`FluentDialog?`) |
| 104 | +- `[Parameter] EventCallback<NoteDialogResult> OnClose` added — invoked on save, cancel, delete |
| 105 | +- `[Parameter] string? Title` added — used for standalone / MAUI usage |
| 106 | +- Title expression: `@(Dialog?.Instance?.Parameters?.Title ?? Title)` — works in both contexts |
| 107 | +- Close methods: invoke `OnClose` then `Dialog?.CloseAsync()`/`CancelAsync()` (dual-path for backward compat) |
| 108 | + |
| 109 | +**Posts.razor (caller):** No changes needed. It still opens NoteDialog via `ShowDialogAsync<NoteDialog>()`, |
| 110 | +which provides the Dialog cascade. `dialog.Result` still resolves via `Dialog?.CloseAsync()`. |
| 111 | + |
| 112 | +**NoteDialogResult** (already existed in `NoteBookmark.Domain`): |
| 113 | +```csharp |
| 114 | +public class NoteDialogResult { |
| 115 | + public string Action { get; set; } = "Save"; // "Save" | "Cancel" | "Delete" |
| 116 | + public Note? Note { get; set; } |
| 117 | +} |
| 118 | +``` |
| 119 | + |
| 120 | +**Test outcome:** 5 skipped → 5 passing. Full suite: 25/25 passing, 0 skipped. |
| 121 | + |
| 122 | +**MAUI compatibility:** NoteDialog now renders standalone without any FluentUI dialog host. |
| 123 | +Can be embedded inline with `OnClose` callback for Blazor Hybrid usage. |
0 commit comments