Skip to content

fix(mobile): open archived threads instantly from device cache - #423

Merged
nixuuu merged 1 commit into
devfrom
fix/mobile-archived-instant
Nov 9, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/mobile-archived-instant

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 9, 2026

Copy link
Copy Markdown
Member

Tapping Archived on mobile waited for the sidebar setting to reach the gateway. It now changes local disclosure state immediately, displays saved archive pages before the request starts, and refreshes them in the background. A cold cache displays compact row skeletons.

Archive rows, pagination cursors, and project/worker labels use a separate pairing-scoped persistent cache. Archive/unarchive/delete events update it incrementally; stale requests cannot resurrect changed rows. Unpair/revocation clears it. Active and archived rows share a windowed FlatList with stable keys and the existing reduced-motion-aware row/disclosure presets. Loaded pages survive collapse and restart, and scrolling loads the next page.

Scope and coordination

  • Follow-up: expose paginated archived history from linked peers in the gateway API. The existing archive endpoint is local-only. Linked-computer archive rows learned through overview events are persisted, retained through local refreshes and offline periods, and removed by explicit lifecycle/unlink events. This PR does not discover a peer's complete historical archive. Reconnect snapshots reconcile active rows, but an unseen peer deletion cannot be inferred from snapshot absence.
  • Web already toggles optimistically and prefetches archive rows, so no web component change was needed. The shared pager keeps its existing web behavior.
  • For perf/client-N: transcript thread-cache.ts and thread-cache-native.ts are unchanged. The archive uses the existing storage adapter in an independent namespace; session initialization/cleanup and overview event handling are the integration points.

Verification

  • Passed: bun install, bun run gen:check, full bun run typecheck, bun run lint, bun run format:check, and the production web build. Mobile/integration typechecks also passed after the final cache adjustment.
  • Full bun run check:tmp --timeout 30000 --retry 2: 1921 passed, 161 skipped, 1 failed across 343 files; temp-dir hygiene passed. The unchanged linked-timeouts.test.ts slow-live-read scenario failed after both retries (the test did not observe the expected peer read refresh). Earlier interrupted runs encountered plugin timeouts under concurrent exports and a config-sync cursor assertion race; both passed in this final full run. No unrelated gateway/test code was changed to suppress failures.
  • Initial isolated bun run check:tmp tests/integration/linked-timeouts.test.ts --timeout 30000: 6 passed, 1 failed in the same slow-live-read scenario; temp-dir hygiene passed.

The failing test is linked computer read deadlines and recovery > slow live reads time out without declaring the computer dead or repeating on every poll. Its polling assertion returned false where true was expected: the peer did not reach readState === "stale" within 20 seconds, or the next assertion did not observe a newer GetComputerUpdates request within 10 seconds (linked-timeouts.test.ts:160–161). Two additional isolated runs on this head both passed 7/7, without retries (78.46s and 78.31s); temp-dir hygiene passed in both.

Maintainer comparison: 7/7 on dev 4dfb2f85 and two consecutive 7/7 runs on head 5bac8ae3 under less load. Their confirmation: “on your head 5bac8ae passes 7/7 twice in a row on a less loaded run here, and 7/7 on dev. So it's load-related, not your change.” Changed code is confined to mobile cache/sidebar behavior and the shared archive pager; the gateway, linked listings, BFF transport, and this fixture are unchanged and do not import the changed archive modules. No unrelated code was changed to suppress the failure. Publication with the local load failure documented is explicitly authorized; CI remains the merge gate.

  • Eight focused disk-cache tests cover restart, local/peer ordering, cached pagination, filters, lifecycle/request races, pairing isolation, unpair write fencing, corrupt data, and bounded retention. No UI tests added.
  • Expo Doctor: 20/20; clean prebuild and iOS/Android JS/Hermes exports passed. No native dependency/config changes.
  • Fingerprints generated before/after with bunx [email protected] fingerprint:generate --platform <ios|android> --build-profile production --json --non-interactive: iOS 2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3, Android c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d; both unchanged.
  • Manual web browser check on an isolated port: light/dark at desktop and phone widths, 25 archive records with short/typical/long titles, paging, truncation and no horizontal overflow. With settings writes delayed by 2 seconds, the first observed animation frame already had the disclosure expanded and 20 cached rows. No native simulator/device interaction was performed.

Copy audit

  • Before: failed refresh showed Could not load archived threads.. After, when saved rows exist: Showing saved threads quietly explains their source, with Retry on failure; four words, sentence case, standard glossary, no punctuation or humor needed for a status.
  • Existing Could not load archived threads. + Retry, empty-state text, and Load more/Loading… remain. The retry action supplies the next step without exposing transport details.
  • Status is announced politely; disclosure exposes expanded state and an accessible label. The new note follows pagination controls so its appearance does not move them. No new terms, duplicate status facts, or color-only meaning. Short/typical/long thread titles checked on web at desktop and phone widths; mobile device layout remains unverified.

Related: #375

Open Archived locally before settings writes or network reads, restore pairing-scoped archive pages and metadata, and merge background refreshes into a windowed list.

Related: #375
@nixuuu
nixuuu merged commit 2ffb6f0 into dev Nov 9, 2026
9 checks passed
@nixuuu
nixuuu deleted the fix/mobile-archived-instant branch November 9, 2026 16:24
nixuuu added a commit that referenced this pull request Nov 15, 2026
## What jumped (Android recording, nightly)
Frames from the report, at 30 fps:
1. **Swipe snapped back**: releasing a committed swipe returned the row
to rest, and it sat there for about 0.5 s until the gateway update
removed it instantly.
2. **Counter out of step with its rows**: the archived rows come from
the saved cache, which the stream update changes in the same render.
`Archived · N` and "No archived threads" came from the pager, which
refetches after a 100 ms debounce. Archiving showed `Archived · 0` over
the new row. Unarchiving showed `Archived · 1` over "No archived
threads.", and then the whole section vanished in one frame.
3. Rows other than archived ones, the archived heading and the empty
state had no exit, so they disappeared abruptly while neighbours moved.

## Fix (mobile only)
- `ThreadArchiveSwipe`: a committed swipe slides the row off on
`motion.quick` with `smoothOut`, and the row stays off. With reduced
motion it only fades. The gateway update then removes the row, and the
cells below glide into place (`SidebarOrderCell` `LinearTransition` on
`fast`). A failed request or a confirmation dialog brings the row back.
`useThreadActions.commit()` returns the outcome; `run()` behaves as
before.
- `useArchivedThreads`: the count follows the rows it describes
(`saved?.totalCount ?? page.totalCount`). Row and counter now change in
the same frame, and the section's visibility uses the same value.
- `SettingsThreadList`: every leaving entry fades out (`rise.exiting`).
That covers active rows, the archived heading and status, and the empty
state. `LayoutAnimationConfig skipExiting` stops those exits when the
whole list unmounts (Threads/Bots switch).
- `useSettleThread` (overview): the archive/unarchive response, and the
response to Undo, carries the saved thread. It applies immediately when
the stream isn't live, else after 2 s without an echo. It uses the same
path as a stream `thread` event (saved archive cache `reconcile` +
overview upsert), so a swiped row never stays an empty slot. A response
whose archive state the list already shows is dropped. A later echo is a
no-op: `mergeArchivedThread` keeps a known row at its index and leaves
the count unchanged, and the overview upsert replaces the row in place.
The pager refetch that follows returns the same rows.
- No optimistic list mutation: the server echo is the only move, so
there is no double move. The pager's refetch, triggered by the same
update, matches the saved rows: same keyset order, and the row already
in place keeps its index.

The web sidebar takes rows and count from the same pager state, so it
was not affected and is unchanged.

## Checks
- `bun install`, mobile `typecheck`, `bun run lint`, `bun run
format:check`: clean.
- Native fingerprint (`@expo/fingerprint`, ios + android) compared
against `origin/dev`: all source hashes are identical. Only TS sources
changed; no native modules and no config-plugin changes, so this ships
over OTA.
- Device: not checked. The MacStudio device hub timed out (40 s), and
the EAS cloud simulators would need a new build.

## Copy audit (docs/copy.md §8)
No UI text added or changed.

Related: #549
Related: #423
nixuuu added a commit that referenced this pull request Nov 22, 2026
## Changes

- Align Archived above the mobile sidebar footer when the thread list is
short. On longer lists, the archive follows the inbox in the same
virtualized list.
- Reduce the space above Snoozed from 24 to 8 dp and keep its 48 dp
touch target.
- Use the existing motion preset for changes to the Archived header
position.

## Verification

- Passed mobile typecheck, lint on the edited files, and `git diff
--check`.
- Checked the layout geometry in Yoga with short, long, expanded,
archive-only, and archive-free lists.
- Native visual and interaction checks are pending. The Android device
tool could not verify ownership of the emulator runtime.
- UI copy is unchanged. Repository-wide checks run in GitHub CI.

Fixes: #423
Fixes: #1064
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.

1 participant