The reference port recomputed the inverse DCT cosine tables once per output
pixel — for a 32x24 decode that's ~43k redundant cos() calls. This change
lifts the tables out of the inner loop and caches them across decodes
keyed by (size, componentCount) so subsequent placeholders at the same
target size skip cosine evaluation entirely.
Additional wins:
- AC coefficients unpack into pre-sized DoubleArrays (no ArrayList<Double>
boxing, no post-hoc copy)
- truncated hashes are rejected up-front via a single length check instead
of mid-stream
- LPQA -> sRGB uses an inline branch clamp instead of a
min/max/round/coerceIn chain
Tests: 12 unit tests cover determinism across repeated decodes, cache
clearing, alpha preservation, aspect-ratio preservation both directions,
average-color drift bounds, truncated input rejection, and round-tripping
base64 vs. raw bytes. All green.
Bench: new ThumbHashBenchmark exercises opaque decode, alpha decode,
warm- and cold-cache decode, aspect-ratio probe, and the full
decodeKeepAspectRatio pipeline so the perf delta is visible on device.
Adds a parallel ThumbHash placeholder everywhere BlurHash is already used.
Remote events now carry both hashes; renderers prefer thumbhash when
available and fall back to blurhash. The MIP-04 `thumbhash` imeta field
that was previously reserved-but-unused is now wired end-to-end.
- New ThumbHash encoder/decoder in commons/commonMain (no new Gradle dep)
- New ThumbhashTag and thumbhash accessors/builders across NIP-17, 68,
71, 94, 95, 99, the experimental profile gallery, and MIP-04
- RichTextParser + MediaContentModels carry a thumbhash field alongside
blurhash so every downstream composable can pick its preferred placeholder
- New ThumbHashFetcher (Android + Desktop) registered with Coil, plus a
small placeholderModel(thumbhash, blurhash) helper centralising the
"prefer thumbhash, fall back to blurhash" rule
- Rename BlurhashMetadataCalculator -> PreviewMetadataCalculator; the
calculator decodes the bitmap / video thumbnail once and runs both
encoders on the same pixels to keep upload cost flat
- DesktopMediaMetadata, MediaUploadResult, and FileHeader now surface
both hashes through the NIP-96, Blossom, NIP-95, MIP-04, NIP-17 DM,
Classifieds, picture, video, and long-form upload paths
- Round-trip unit test for the ThumbHash port
The list event only stores content-discovery feeds (kind-5300 DVMs),
not every DVM, so the old name was misleading. Rename the wire-level
type to reflect what's actually in it.
- Quartz: package nip51Lists.favoriteDvmList -> favoriteAlgoFeedsList;
class FavoriteDvmListEvent -> FavoriteAlgoFeedsListEvent.
- DSL helpers renamed: favoriteDvm/favoriteDvms builder extensions ->
favoriteAlgoFeed/favoriteAlgoFeeds; TagArray.favoriteDvmList/Set ->
favoriteAlgoFeedsList/Set.
- create/add/remove parameter names dvm -> feed, publicDvms/privateDvms
-> publicFeeds/privateFeeds; public/private accessors
publicFavoriteDvms/privateFavoriteDvms -> publicFavoriteAlgoFeeds/
privateFavoriteAlgoFeeds. ALT string updated.
- EventFactory + LocalCache dispatch branches + AccountSettings backup
field type + FavoriteDvmListState + FavoriteDvmListDecryptionCache all
import the new type. Internal amethyst-side classes
(FavoriteDvmListState, FavoriteDvmListDecryptionCache), the top-nav
filter classes (FavoriteDvm*, AllFavoriteDvms*) and the orchestrator
keep their names — they still deal with content-discovery DVMs
specifically, and the narrower rename here is scoped to the Nostr
wire format the user was asking about.
- Quartz test renamed + rewired. Build + tests green on both modules.
PdfRenderer.Page.render() only accepts ARGB_8888 bitmaps; RGB_565 is
silently rejected (the renderer produces no output), which is why the
preview card and viewer both stopped showing anything. Go back to
ARGB_8888 and update the memory estimates in the comments. The other
perf wins from 49e913b (FilterQuality.Medium, 4096 hi-res cap, 1.5x
threshold, remembered ImageBitmap wrapper) are unaffected and stay.
The main cost during a live pan/zoom is the GPU re-sampling the page
bitmap every frame under the zoomable modifier's transform. Three
changes bring that cost down substantially:
- Bitmap.Config.RGB_565 instead of ARGB_8888. PDFs are opaque, so the
alpha channel is unused. Halves texture memory and GPU upload
bandwidth; visually identical.
- HI_RES_MAX_DIM_PX lowered from 6144 to 4096. 4096 stays within the
common GPU texture-size limit, keeping rendering hardware-accelerated
on mid-range devices. Peak bitmap is now ~24 MB (A4, RGB_565) instead
of ~107 MB (ARGB_8888, 6144).
- FilterQuality.Medium (bilinear) instead of High (bicubic/Mitchell).
High is recomputed per frame during pan/zoom and is the main source
of jitter on multi-megapixel sources. At 3072-4096 px base resolution
bilinear is effectively indistinguishable.
- HI_RES_ZOOM_THRESHOLD raised from 1.2 to 1.5 so we don't trigger a
costly re-render for marginal zoom levels where the base is fine.
- Cache the ImageBitmap wrapper via remember to avoid per-recomposition
allocations.
PdfRenderer.Page.getWidth()/getHeight() return the page size in
PostScript points (1/72"), so for a standard A4 that's 595 x 842
"pixels" passed to cappedRenderSize. The old early-return kept native
dimensions whenever longest <= targetDim (which was always), so the
base bitmap was 595 x 842 regardless of what we asked for — effectively
72 DPI. Zoom-aware re-renders hit the same early return and also
stayed tiny, which is why double-tap produced no visible improvement.
Remove the early return: since PDFs are vector, always rescale the
point dimensions so the longest side equals targetDim. Base renders
now produce ~3072 px bitmaps and the hi-res path actually goes to
6144 px when zoomed.
- User-facing rename. All user-visible strings switch from "favourite"
to "favorite" (American spelling) and from "DVM(s)" to "Feed
Algorithm(s)": settings entry, spinner group label, empty state,
banner messages, menu accessibility labels. Code identifiers still
reference NIP-90's "DVM" protocol name since that's the wire spec.
- Cold-start race. When the app relaunches with a persisted
TopFilter.FavoriteDvm, the AppDefinitionEvent may not be in cache
yet. mergeInterests was filtering out any favorite whose
AppDefinitionEvent didn't yet advertise kind 5300, so the spinner
didn't include a chip matching the persisted selection — it
showed "Select an option" while the orchestrator quietly fired the
RPC with no UI to ground it. Always include every favorite; the
5300 check at add time (in FavoriteDvmToggle) is enough.
SubcomposeAsyncImage was being called with just the URL (or local
File), so Coil auto-sized the decode target to the composable's
layout bounds. In the feed that's desirable — a small thumbnail
decode — but in the zoomable dialog the composable is fillMaxWidth
(~screen width), and pinch-zooming then GPU-upscales the already
downsampled bitmap, producing the same blurriness the PDF viewer
had before.
Add a fullResolution: Boolean = false flag to UrlImageView and
LocalImageView. When true, swap the model for an ImageRequest with
size(Size.ORIGINAL) so Coil decodes at the image's native
dimensions. Feed call sites keep the default (fast, sampled). Both
dialog call sites in ZoomableContentDialog now pass
fullResolution = true, so pinch-zoom shows native pixels.
The existing blurhash/aspect-ratio placeholder path already covers
the brief high-res load window in the dialog.
The zoomable library's onDoubleTap callback is not wired by default,
so double-tapping the PDF page did nothing — no scale change, no
hi-res re-render. Pass an onDoubleTap handler that calls
zoomState.toggleScale(2.5x, tapPosition). The scale animation runs
through the same Animatable snapshotFlow already observes, so the
debounced hi-res render kicks in automatically once the animation
settles.
Putting HomeDvmStatusBanner inside the top-bar Column meant the
SecondaryTabRow shifted up/down every time the banner appeared or
disappeared (filter selection, refresh, response arrival). Annoying.
Move the banner into a Box that wraps the HorizontalPager and align
it to TopCenter so it floats over the feed:
- topBar Column is back to just HomeTopBar + SecondaryTabRow; tabs
no longer reflow when the banner toggles.
- BannerCard takes a Modifier and gets tonalElevation + shadowElevation
+ a slightly stronger surface tint so it reads as a floating overlay
rather than part of the scaffold chrome.
Base bitmap stays at 3072 px for the initial render. When the user
zooms past 1.2x and scale settles for 200 ms, asynchronously re-render
the current page at (VIEWER_MAX_DIM_PX * scale) capped at 6144 px
(~100 MB peak for an A4 page). Swap the hi-res bitmap in while zoomed;
revert to base when scale drops back under threshold or the page
leaves composition. Only the currently-focused page gets the hi-res
treatment.
Also apply FilterQuality.High to the Image composable in both the
viewer and the preview card so any residual GPU upscaling uses
bicubic-ish sampling instead of bilinear.
Factored the render path into a shared renderPageCatching() helper.
Selecting a DVM with a long name (or any long-named filter) made
the Text in the top-nav spinner wrap to two lines, pushing the
ExpandMore icon out of the visible area. The Column holding the
Text had no width constraint and the Text itself had no maxLines.
- Constrain the Column with `Modifier.weight(1f, fill = false)` so
it reserves space for the icon instead of consuming it.
- Add `maxLines = 1, overflow = TextOverflow.Ellipsis` to every
text path in the spinner (primary label, geohash city-loading,
AroundMe location labels). Single-line + ellipsis for all filter
types, icon always visible.
- Wrap pager + controls Row in a Box(fillMaxSize) and align the Row to
TopCenter so the back/share buttons sit at the top of the screen,
matching ZoomableContentDialog's layout. They were previously
vertically centered.
- Raise VIEWER_MAX_DIM_PX from 2048 to 3072 so pinch-zoomed pages stay
legible. A4-sized pages now render at ~26 MB each (ARGB_8888).
- Replace the unbounded mutableStateMapOf page cache with a tiny
LinkedHashMap-based LRU (PAGE_CACHE_SIZE = 3) to keep total bitmap
memory around 80 MB regardless of PDF length. The cache only feeds
produceState's initial value, so it doesn't need to be a snapshot
state.
DisposableEffect(handleState) captured handleState as a property
delegate, so onDispose read the *current* delegated value at dispose
time. When the async load transitioned handleState from null to the
new handle, the previous DisposableEffect(null) was forgotten and its
onDispose fired — reading the freshly-created handle via the delegate
and closing it immediately. That left the dialog stuck on the loading
spinner (page renders bailed out due to the closed flag) and double-
closed the renderer on dismiss.
Capture the handle as a local val before DisposableEffect so the
lambda closes the specific handle that was current at effect creation.
PagerState's saveable reads the pageCount lambda during composition
teardown, which runs *after* DisposableEffect.onDispose has already
closed the PdfRenderer. That triggered
IllegalStateException("Document already closed") the first time the
dialog was dismissed.
Store pageCount as a stored val sampled at handle construction instead
of re-querying the renderer. Also add a @Volatile closed flag so the
PdfPageView render coroutine bails out if it wakes up after close();
existing catch clause still swallows any narrow race.
These derivations iterate every tag and parse every iMeta, so running
them on each recomposition churns through feed scrolls. Cache them in
remember(note) alongside the other per-note derivations.
Two distinct bugs with the same symptom ("clicking the star doesn't
seem to do anything"):
1. LocalCache didn't know how to route kind 10090. FavoriteDvmListEvent
was missing from LocalCache's event-type dispatch, so after
Account.followFavoriteDvm signs and publishes the event, the
cache silently dropped it — never updated favoriteDvmListNote,
so account.favoriteDvmList.flow never re-emitted, so the star's
filled/outlined state (and the spinner chip) never flipped. Add
`is FavoriteDvmListEvent -> consumeBaseReplaceable(...)`.
2. DvmTopBar's toggle never rendered. The Home feed passes the DVM's
hex event id via Route.ContentDiscovery, so LoadNote(baseNoteHex)
returns a plain Note, not the AddressableNote the toggle needs
(the `is AddressableNote` guard was always false). Derive the
AddressableNote from the loaded AppDefinitionEvent.address() so
the toggle shows up with the correct backing object.
Replace tint-only selection with Surface background + primaryContainer
color so the selected icon is clearly visible in the workspace editor.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Shorten "Single Pane" to "Single" in SegmentedButton to prevent wrapping
- Add 8dp left margin before checkmark in workspace card
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
PinnedNavBarState now takes WorkspaceManager reference. Pin/unpin
actions update the active workspace's singlePaneScreens list,
making sidebar customization and workspace editing the same action.
- PinnedNavBarState.syncToWorkspace() updates active workspace on pin/unpin
- PinnedNavBarState.loadFromWorkspace() loads from active workspace
- Remove separate DesktopPreferences.pinnedNavItems persistence
- Workspace is the single source of truth for nav bar screens
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Change Workspace.singlePaneScreen (single string) to
singlePaneScreens (list of typeKey strings). First screen is
the default. On workspace switch, loads the screen list into
PinnedNavBarState and navigates to the first screen.
- Add SinglePaneScreensEditor to workspace editor dialog
- Add PinnedNavBarState.loadFromList() for workspace-driven nav
- Backward compat: load old "singlePaneScreen" format as single-item list
- Cmd+Shift+S captures current deck columns as singlePaneScreens
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1. DVM response timeout. FavoriteDvmOrchestrator now times out after
20s if neither a 6300 response nor any 7000 status arrives, and
sets errorMessage = "timeout" on the snapshot so the home banner
switches from the "Asking…" spinner to a Retry button instead of
hanging forever.
2. Tests. FavoriteDvmListEventTest covers create/add/remove round
trips and the fixed-empty d-tag invariant; FavoriteDvmTopNavFilter
match by id and by `a` address; FilterHomePostsByDvmIdsTest covers
the two-relay-set split (content fetch on user relays, listen on
DVM relays) and the multi-requestId merge case.
Also registered kind 10090 in EventFactory so Quartz can deserialise
FavoriteDvmListEvent (required for the round-trip tests and for
reading the list back from relays).
3. Merged "All favourite DVMs" chip. New TopFilter.AllFavoriteDvms
that unions every favourite's latest 6300 response into one feed.
AllFavoriteDvmsFeedFlow uses flatMapLatest over the favourite-list
flow so subscriptions rewire when the user adds/removes a DVM.
FavoriteDvmTopNavPerRelayFilterSet now carries Set<HexKey>
requestIds (was a single nullable) so the filter can subscribe to
N kind 6300/7000 streams in one REQ per DVM relay. Banner renders
"Asking your favourite DVMs for feeds…" while all are pending and
a single Retry-all on collective error; pull-to-refresh re-issues
every DVM's kind-5300.
- PdfFetcher now reuses Amethyst.instance.diskCache (Coil) via
openSnapshot/openEditor instead of a custom cacheDir folder. PDFs share
the same LRU budget as images and benefit from automatic eviction.
- PdfPreviewCard now respects accountViewModel.settings.showImages():
when disabled, shows a lightweight "Tap to load PDF" placeholder and
only downloads+renders after the user opts in.
- Both the card thumbnail (1600px) and viewer page (2048px) bitmaps are
capped to a maximum longest-side dimension, preventing OOM on very
large or unusually tall PDF pages.
- PdfViewerDialog holds the cache snapshot for the dialog's lifetime so
the underlying file can't be evicted mid-view, and closes it in
DisposableEffect alongside the renderer and ParcelFileDescriptor.
Collapse the per-media, per-blurhash and grid-of-blurhash variants into a
single ContentWarningGate that takes a backdrop slot and a sizing
modifier. Callers choose the backdrop (single blurhash, grid of
blurhashes, or none).
Remove the isSensitive field from MediaUrl{Image,Video}; it was a
rendering concern leaked into a media model. Sensitivity is now only
expressed to the gate. Picture/Video feeds and their display variants
compute isSensitive + reasons themselves and wrap with the gate.
ZoomableContentView keeps a default internal gate (fires when
content.contentWarning != null) so the 14 callers that don't need
grid-level handling still get the blurhash overlay automatically.
Also rename collectPictureReasons to collectContentWarningReasons.
Adds MediaUrlPdf / PdfSegment to the rich-text pipeline so PDF URLs
(detected by .pdf extension, NIP-92 imeta m tag, or application/pdf
Content-Type) render a card showing the first page, filename, and page
count. Tapping opens a full-screen HorizontalPager over every page
rendered on demand with PdfRenderer. Long-press surfaces the existing
share menu. Uses only the built-in Android PdfRenderer; no new
dependencies. Desktop continues to fall back to a clickable link.
Putting the star back where the user actually sees DVMs first — the
Discover Content card. Two changes that together stop the layout
from breaking:
- FavoriteDvmToggle now uses ClickableBox + small Icon (no IconButton
padding) so it occupies the same compact footprint as LikeReaction.
Adding it to LeftPictureLayout's title row no longer inflates the
row height.
- DVMCard's title row now holds only the name (weight 1) plus the
star toggle on the right. LikeReaction and ZapReaction move down
to the bottom row, pushed to the far right with a Spacer(weight 1)
so the amount/personalised chips stay on the left.
Multi-image picture posts now show one warning covering the whole grid
instead of one per image (which required tapping each individually). The
warning backdrop is a grid of the images' blurhashes, and the overlay
lists any distinct reasons collected from both the event's content-warning
tag and per-imeta content-warning fragments as chips. Preloads every
image in the grid while the warning is visible.
Adds a dismissible top-of-screen banner to the Pinned Notes, Bookmarks,
Old Bookmarks, and Bookmark Set (detail) screens that appears when one
or more listed items have been deleted by their author (kind-5 deletion,
pubkey-matched via DeletionIndex). Tapping "Remove from list" rewrites
the underlying list event (NIP-51 kind 10001/10003/30001/30003) with
the deleted entries stripped out and broadcasts it once.
The scan is scoped to each screen's loaded list (typically <20 items)
and runs only while composed, so it avoids the performance hit of
hooking Account.deletedEventBundles, which fires for every kind-5
deletion in the firehose. Public and private (NIP-44 encrypted)
bookmarks are both cleaned in a single resign() call per list.
- Remove FavoriteDvmToggle from DVMCard's title row; the extra
IconButton was expanding the row and pushing the title down so
the whole Discover→DVMs card layout looked broken. The toggle
stays on the DvmContentDiscoveryScreen top bar, which was the
user's expected place to follow/unfollow.
- Add a "Favourite DVMs" page under Settings (Route.EditFavoriteDvms,
modelled after the Blossom servers settings) listing each
favourited content-discovery DVM with its avatar/name/description
and a delete button. Tapping a row opens the DVM detail screen.
Empty state points users to Discover for adding more.
- Pass contentScale through to ContentWarningOverBlurhash so grid cells
(ContentScale.Crop) use fillMaxSize instead of forcing the image's
native aspect ratio, keeping the blurhash and overlay within the cell.
- Clip the overlay to its bounds to stop the icon/button from drawing
over neighboring cells or other components.
- Preload the image through Coil while the warning is visible so the
image is cached by the time the user taps "Show anyway".
Two issues from the first pass:
1. Response routing. The kind-5300 request goes to the DVM's own
inbox/used relays, but `filterHomePostsByDvmIds` was subscribing
for kind 6300/7000 on the user's outbox/proxy relays. Most DVMs
only publish their replies on their own relays, so the listen
subscription would silently miss every response.
Fix: `Account.requestDVMContentDiscovery` now exposes the relay
set the request was sent to, the orchestrator stores it on the
snapshot as `responseRelays`, and `FavoriteDvmTopNavPerRelayFilterSet`
carries two distinct relay sets — `contentFetches` (user's outbox,
for the actual notes) and `listenRelays` (DVM's relays, for the
6300/7000 reply subscription). `filterHomePostsByDvmIds` issues
each on the right relay.
2. Pull-to-refresh. Swiping down on Home only re-rendered the cached
feed. When a `TopFilter.FavoriteDvm` is active it now also calls
`orchestrator.refresh(addr)` so a fresh kind-5300 request is
published to the DVM.
Only NIP-90 content discovery (kind 5300) DVMs can produce a feed.
Other DVM types (image generation, translation, search, etc.) would
silently hang the home banner waiting for a 6300 reply that will
never come.
Defence in depth:
- FavoriteDvmToggle hides itself when the AppDefinitionEvent doesn't
advertise kind 5300, so users can't favourite the wrong type.
- TopNavFilterState.mergeInterests filters out any list entry whose
AppDefinitionEvent doesn't include kind 5300, so a stale or
cross-client entry won't surface as a Home chip.
When a kind-5 deletion event arrives for a note that is currently pinned,
rewrite the user's PinListEvent to drop the deleted entries and broadcast
the new list. Mirrors the existing deletedNotes() pattern used by
peopleLists, followLists, and labeledBookmarkLists in Account.
Previously the Pinned Notes screen silently hid deleted posts via the
FeedContentState deletion filter, leaving orphan entries in the pin list
that the user had no way to clean up.
Adds MediaCallEventListener on the images/videos OkHttpClient. For each
call it records DNS, TCP, TLS, TTFB, total time, connection reuse, and
the dispatcher queue depth at call start.
Release builds log only when a call is slow (>= 1.5s), was queued by
the dispatcher (saturation of maxRequests / maxRequestsPerHost), or
failed. Debug builds log every call.
Purpose: give us signal on whether the new 16/host + 128/total limits
are still the ceiling, and whether remaining latency is DNS, TLS, or
server-side.
https://claude.ai/code/session_01PUbqGyUc6oq6V1MdmLi8sw
OkHttp's default dispatcher caps inflight requests per host at 5 and
total inflight at 64. Amethyst feeds typically pull most media from a
single host (e.g. a primary Blossom/imgproxy server), so that per-host
cap serialized feed loading — the browser-feels-faster effect.
- Give the images/videos factory a dedicated Dispatcher (16 per host,
128 total on device; 5/64 on emulator).
- Give it a larger ConnectionPool (32 idle, 5 min keep-alive) so HTTP/2
connections to the common media host stay warm across scrolls and
avoid repeated TLS handshakes.
- Extract isEmulator() to a shared helper used by both the relay and
image/video factories.
The relay factory is untouched (already tuned for websockets).
https://claude.ai/code/session_01PUbqGyUc6oq6V1MdmLi8sw