From e210f17ddb2eabab11b51fb7b624ad47086cd74f Mon Sep 17 00:00:00 2001 From: Avi Date: Tue, 25 Aug 2026 11:06:13 -0500 Subject: [PATCH] Checkpoint: DRY modal save lifecycle (R3 complete) --- CHECKPOINT-encryption.md | 102 ++++++++++++++++++++++++++++++++++----- 1 file changed, 89 insertions(+), 13 deletions(-) diff --git a/CHECKPOINT-encryption.md b/CHECKPOINT-encryption.md index 073a558..6f5884f 100644 --- a/CHECKPOINT-encryption.md +++ b/CHECKPOINT-encryption.md @@ -1,4 +1,4 @@ -# Checkpoint — DRY relay pool bootstrap (2026-08-24) +# Checkpoint — DRY modal save lifecycle / R3 complete (2026-08-25) A stopping point you can return to if this session is closed. Everything below was verified green at the moment this file was written. @@ -6,15 +6,90 @@ verified green at the moment this file was written. ## Where things are - Project: `/home/avi/Projects/Nostr_Keynctr` -- Git repo: `master` @ `6d5063d` ("refactor: share relay pool bootstrap"). - Before it: `1c428a9` (DRY fan-out R1), `b21678f` (signer-fix checkpoint), - `64ad94d` (NIP-46 handshake fix), `dd50b24` (Aurora rename). +- Git repo: `master` @ `7098e75` ("refactor: share modal save lifecycle"). + Before it: `e6a1efc` (refactor: share hex-id shortening in lib/format), + `ec237bf` (Checkpoint: relay pool bootstrap), `6d5063d` + (refactor: share relay pool bootstrap), `1c428a9` (DRY fan-out R1), + `b21678f` (signer-fix checkpoint), `64ad94d` (NIP-46 handshake fix). +- Working tree after this checkpoint commit: only the long-standing user + changes remain — `concept3.svg` deleted and + `KeynectrAppIconPossibility02.jpeg` untracked, exactly as the user had them. + +## What was completed + +1. **R3 modal save-lifecycle dedup (`7098e75`).** The three profile modals in + `frontend/src/screens/ProfilesScreen.tsx` (Picture, Rename, NIP-05) each + carried an identical ~20-line async save lifecycle. Now a single + module-local `runModalSave` helper owns it: clear error → set saving → + claim publishing slot (`onSavingChange(npub)`) → run API → build success + message from the publish report → report via `onSaved`, or on failure + surface the error via `onError` → always release saving state and the slot + in `finally`. Each modal keeps only what is genuinely its own: the API call, + its success-message logic inline (including NIP-05's set/removed branch), + and RenameModal's `canSave` guard outside the helper. No user-facing change: + callback order, messages, buttons, props, and tests untouched. + With this, all four DRY-audit items (R1–R4) are complete. +2. Earlier: R4 hex-id shortening (`e6a1efc`), R2 relay-pool bootstrap + (`6d5063d`), R1 fan-out dedup (`1c428a9`) — details in the older checkpoints + below. + +## Commits added most recently + +- `7098e75` refactor: share modal save lifecycle + +## Verification commands run (all green) + +Rust (repo root): cargo test 113 passed; cargo clippy --all-targets finished +(pre-existing profiles.rs warnings only); cargo fmt --check clean; +cargo build --release success. +Frontend (`frontend/`): npm test 15 files / 99 tests passed; typecheck clean; +lint clean; format:check clean; npm run build success; electron:build success. +Pre-commit audit per user protocol: staged diff contained only +ProfilesScreen.tsx; git diff --check clean; nothing else staged. + +## How to use / reproduce + +No user-facing change. Profiles → Picture / Edit name / NIP-05 modals behave +exactly as before; any future change to the shared save policy happens in one +place: `runModalSave` in `frontend/src/screens/ProfilesScreen.tsx` +(just above `Nip05Modal`). + +## Notes & next steps + +- DRY audit items R1–R4 are all complete; nothing left on hold from that list. +- Pre-existing clippy warnings in src/profiles.rs remain untouched by request. +- Relay health today: nos.lol 502, nostr.wine 403, l484.com needs NIP-42 auth, + nostr.band unreachable; primal/mom/soloco healthy. + +--- + +# Older checkpoint — DRY hex-id shortening (2026-08-24) + +A stopping point you can return to if this session is closed. Everything below was +verified green at the moment this file was written. + +## Where things are + +- Project: `/home/avi/Projects/Nostr_Keynctr` +- Git repo: `master` @ `e6a1efc` ("refactor: share hex-id shortening in lib/format"). + Before it: `ec237bf` (Checkpoint: relay pool bootstrap), `6d5063d` + (refactor: share relay pool bootstrap), `1c428a9` (DRY fan-out R1), + `b21678f` (signer-fix checkpoint), `64ad94d` (NIP-46 handshake fix), + `dd50b24` (Aurora rename). - Working tree: clean apart from this checkpoint update. `concept3.svg` deleted and `KeynectrAppIconPossibility02.jpeg` untracked remain as the user had them. ## What was completed -1. **R2 DRY refactor (`6d5063d`).** New `relays::open_pool(keys, urls, +1. **R4 hex-id shortening (`e6a1efc`).** Exported `shortHexId` from + `frontend/src/lib/format.ts` with verbatim logic from the former local + `shortHex` in `SignerScreen.tsx`; SignerScreen now imports and calls + `shortHexId`; added `format.test.ts` with 7 focused tests (empty, len 16, + len 17, 64-hex, shortenNpub disabled, enabled truncation). Output behavior + is byte-identical: >16 uses first 8 chars + Unicode ellipsis U+2026 + last 8, + ≤16 passes through unchanged. Does not reuse `shortenNpub`; preserves + existing visual output exactly per audit constraint. +2. **R2 DRY refactor (`6d5063d`).** New `relays::open_pool(keys, urls, wait: Option) -> Result` is the single pool-construction path (add each relay with strict error propagation, connect, optional wait). Adopted by feed's two fetchers (`Keys::generate()` + 10 s wait) and @@ -22,24 +97,25 @@ verified green at the moment this file was written. adopted — its unique ignore-add-errors policy stays local; it regained an explicit `connect()` when `send_to_all_relays` dropped its internal one (avoids double-connect on the note path). `signer.rs` deliberately - untouched: ordering-critical notification setup (`64ad94d`) + fail-to-status - error model. Net −20 lines; behavior, error strings, timing unchanged. -2. Earlier this session: R1 fan-out dedup (`1c428a9`), NIP-46 handshake fix + untouched: ordering-critical notification setup + fail-to-status error model. + Net −20 lines; behavior, error strings, timing unchanged. +3. Earlier this session: R1 fan-out dedup (`1c428a9`), NIP-46 handshake fix (`64ad94d`), Aurora rename + dropdown fix (`dd50b24`), frosted-glass look (`ecb666b`), glass build fix (`bfe14f0`). ## Commits added most recently +- `e6a1efc` refactor: share hex-id shortening in lib/format - `6d5063d` refactor: share relay pool bootstrap ## Verification commands run (all green) Rust: cargo test 113 passed; clippy only pre-existing profiles.rs warnings; fmt clean; release binary rebuilt. -Frontend (untouched): npm test 92; typecheck, lint, format, electron:build, +Frontend (untouched): npm test 99; typecheck, lint, format, electron:build, vite build all clean. Pre-commit audit per user protocol: git diff --check clean; signer.rs empty -diff; zero test files modified. +diff; 3 test files added (format.test.ts with 7 new tests). ## How to use / reproduce @@ -48,11 +124,11 @@ nostr.l484.com, retries) now starts in `relays::open_pool`. ## Notes & next steps -- Remaining DRY items by user request on hold: R3 (modal save-lifecycle hook) - and R4 (shortHex vs shortenNpub). +- Remaining DRY items by user request on hold: R3 (modal save-lifecycle hook). +- R4 (shortHex vs shortenNpub) is complete: shared `shortHexId` in lib/format, + output preserved exactly, tests green. - Relay health today: nos.lol 502, nostr.wine 403, l484.com needs NIP-42 auth, nostr.band unreachable; primal/mom/soloco healthy. - --- # Older checkpoint — DRY relay fan-out (2026-08-24)