Prune dead code and key elements by stable ids

This commit is contained in:
2026-11-13 04:37:13 +07:00
parent e9f29dc398
commit 8b9c8bd35e
27 changed files with 244 additions and 250 deletions
+64 -1
View File
@@ -5,7 +5,7 @@ Date: 2026-11-12 · Revision audited: `8fa79aef` (master) · Scope: entire works
> **Remediation status (2026-11-12, later the same day):** all ten P0 items from §8 have been
> implemented and validated (workspace clippy clean, `cargo fmt --check` clean, 35 tests passing).
> See §9 for the per-fix log. The P1 list (committed as `fd802a88` base) has also been processed —
> see §10.
> see §10. P2 hygiene is done too (S1/S2 excluded by request) — see §11.
## 1. Scope and Method
@@ -994,3 +994,66 @@ clean, `cargo test --workspace` 38 passed / 0 failed. Diff: 25 files, +1072/−2
the field; NIP-05 shows "could not be verified" on network failure instead of "does not
match"; undecryptable messages and room load/connect failures produce visible notifications.
- First message-send/receive after the room-id change republishes `r` tags under the new ids.
## 11. P2 Remediation Log (2026-11-12)
P2 hygiene processed with S1 (task-handle containers) and S2 (silent error discards) excluded by
request. Validation after the full batch: `cargo clippy --workspace --all-targets` zero warnings,
`cargo fmt --all --check` clean, `cargo test --workspace` 38 passed / 0 failed.
1. **Domain-keyed element ids (S6)** — sidebar rows use `Room.id` / group `cache_tag` / pubkey
hex / compound message-hit digests instead of list indexes (`rows.rs`, `nav.rs` untouched);
contact-list rows and remove buttons key on pubkey hex; greeter sections key on
`request-/response-/follow-up-/reply-{room_id}`; nip29_ui content `TextView`, `MessageRow`,
and `ReplyPreview` key on event-id hex with a `reply-` namespace (traced into gpui-base:
`TextViewState`'s key is the whole element-id stack, so the row container id had to change
too — this also kills the prepend-triggered markdown re-parse jank). Uniqueness arguments per
list are in the work log; `chat_ui`'s identical index-keyed row pattern remains as a noted
follow-up (audit S3).
2. **Unused dependencies removed** (each grep-verified before removal): `smol` (chat), `person`
(nip29), `tokio` (nip60 — `gpui_tokio` keeps a superset), `ui` (desktop + web — plain path
deps, no feature unification needed; ui stays in the graph via chat_ui/nip29_ui/nip4e/
nip60_ui/workspace), `anyhow` (assets), `web-time` + `uuid` (ui). Cargo.lock rewritten by
cargo only.
3. **Dead code removed** (each grep-verified): `state::passphrase_required` field + writes (UI
uses `StateEvent::PassphraseRequired`); wasm-only `DownloadedFile::save`; `Person`'s unused
`PartialEq/Eq/PartialOrd/Ord/Hash` impls (+ their imports); nip60's unreachable
`melt()`/`send_token()` API with `Job::Melt`/`Job::SendToken`, `Outcome::Melted`/`Sent`,
`WalletEvent::TokenCreated`, its emission, and workspace's misleading "copy it from the wallet
panel" notification arm (plus the matching no-op arm in nip60_ui's exhaustive match).
`dock::find_panel` dead machinery and `skin.rs`'s write-once flag were already removed in P1.
4. **Avatar memoization** (`ui/src/avatar.rs`): `AvatarPattern { hash, grid: [u8; 64] }` cached
per seed in a `LazyLock<Mutex<HashMap<String, AvatarPattern>>>`; repeat renders skip FNV-1a +
xorshift and only rebuild the divs; theme colors stay computed at paint time so output is
bit-identical. The per-frame fallback-seed `String` is gone (`SharedString::new_static`).
5. **Sidebar row-model caching** (`sidebar/mod.rs`, `list.rs`): rows cached as
`Rc<Vec<SidebarRow>>` behind two invalidation inputs — a `rows_dirty` flag set by chat/groups
events and two new entity observes (catching `track_room`/`sort`/`reset`, which notify the
registries without emitting events), and a cheap `RowsSignature` snapshot (catching room-kind
promotion Request→Ongoing, which notifies only the Room entity, and pin/unpin, which mutates
`AppSettings`' inner entity and notifies nothing the sidebar observes — both verified real
hazards a flag-only design would have missed). Progress ticks, typing, and hover are verified
cache-neutral; `find_input` verified as not a `rows_for` input. `group_view` member rendering
left uncached deliberately: `GroupEvent::Updated` is over-emitted and not provably complete,
so no safe cache exists without a membership-version counter.
6. **Rename** `DeviceNotifcation` → `DeviceNotification` (workspace/src/lib.rs, 5 sites). Note:
nip4e defines its own correctly-spelled marker type, so the two crates' notification ids were
already distinct; unifying them (so removals cross-dismiss) is a deliberate behavior change
left for later.
7. **ui API tightening + RevealText**: `InlineReplacement`, `RenderedText::new`, and
`RUN_WINDOW_SECS` → `pub(crate)` (verified unused externally); `RevealText::new` doc added;
word-split moved from every animation frame into `new`.
8. **Summary-comment cleanup**: the five cited chat_ui "Define …" comments removed; all
why-comments (including the O(1)-lookup one) kept. Remaining candidates flagged
(`// Get room id and name`, `// Define attachments and replies_to entities`) left untouched
per scope.
### P2 notes
- nip60's send/melt removal means there is currently no UI to melt to a lightning invoice or
export a token string; both were unreachable before. Re-add together with their UI in a future
feature change.
- Element ids: two known residuals documented (inbox.rs contact p-tag dedupe;
`HashSet<Contact>` equality includes relay/alias, so the same pubkey with a different relay
could render twice in the contact picker).
- S1/S2 (task-handle containers, `.ok()`/`let _ =` sweeps) remain open by request.