Skip to content

fix(attachments): load previews of linked-thread attachments - #421

Merged
nixuuu merged 1 commit into
devfrom
fix/linked-attachment-previews
Nov 9, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/linked-attachment-previews

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 9, 2026

Copy link
Copy Markdown
Member

Linked-thread attachment metadata can remain readable while its home is unavailable. The previews added in #398 passed the attachment URL straight to an image element, which hid the BFF's 409 reason behind a broken thumbnail. Image and text previews now show the public failure message, offer Retry, and reload when the home reconnects.

Fixes: #398

Diagnosis and behavior

  • The two-gateway reproduction returns RPC Unavailable (14), marked with canopy-error-scope: computer; the BFF maps that to HTTP 409. Both hover and modal now show Available when <computer> is connected.. The BFF logs the RPC code, read variant and sanitised public message, without attachment IDs, payloads, credentials or transport causes. Error responses are JSON with Cache-Control: no-store.
  • IDs received in the thread snapshot and inline mentions are correctly qualified. A plain UUID stays local and returns 404; it is never searched on other computers. The home still enforces ownership, including fallback reads.
  • A home predating feat(attachments): preview images and text files #398 ignores the additive preview field and returns full bytes. The receiving gateway caps text preview responses at 128 KiB and sets truncated; full downloads retain their bytes. A stale thumbnail flag falls back only for the exact missing-thumbnail error, using the same home and owner check.
  • Mobile uses the same gateway path. Its image/file viewers preserve public RPC failure reasons and retry after home/transport reconnection. Changes are JS/TS only; no dependency, native configuration, schema or protocol change.
  • Version skew by itself did not reproduce an online 409. The fixture simulates the older capability set and the old full-byte read behavior; it does not run an archived binary. The new route log identifies other refusal reasons if the reported Macs fail while connected.

Validation

bun install, bun run gen:check, bun run typecheck, bun run lint, bun run format:check and the web production build passed. The full-suite gate is GitHub CI on isolated runners, as agreed for this parallel work session.

The first full run hit default 5-second timeouts in unchanged plugin/worktree tests, followed by errors from the timed-out asynchronous tests (1904 pass, 161 skip, 10 fail, 4 errors; temp cleanup passed). The second full run used a 15-second default timeout but still hit existing internal deadlines in shell interruption and environment synchronization while eight test runners shared the machine (1912 pass, 161 skip, 2 fail; temp cleanup passed). No tests or assertions are removed, and no code in those unrelated areas is changed.

composer-shell.test.ts also hit the same 10-second Stop/steer deadline in isolated runs here, including on untouched origin/dev (4dfb2f85). The requester independently ran that same base in an unloaded checkout and reported 17 passed, 0 failed. This is load-sensitive timing, not a deterministic base failure. Opening this PR with that local exception is explicitly agreed; isolated GitHub CI is the full-suite gate.

The final focused two-gateway attachment test passed alone: 1 test, 114 assertions, no temp leftovers. It also passed in both full runs.

Each affected file is also run alone:

File in tests/integration/ Isolated result
agent-plugins.test.ts 11 passed, default timeout
worktree-automation.test.ts 6 passed, 15-second default timeout
worktree-lifecycle.test.ts 18 passed, 15-second default timeout
worktree-merged.test.ts 3 passed, 15-second default timeout
worktrees.test.ts 15 passed, 15-second default timeout
composer-shell.test.ts Loaded isolated runs here: 16 passed, 1 timed out, also on untouched base. Requester's unloaded run of the same base: 17 passed, 0 failed
config-sync-environment.test.ts 8 passed, 15-second default timeout

Real-browser checks used two isolated linked gateways and a BFF on private ports, with the home ignoring preview. Checked light/dark, desktop/390 px phone widths, short/typical/long filenames, hover and modal loads, offline error messages, no broken image or horizontal overflow, and automatic recovery in the still-open hover/modal after reconnection. No UI test suites were added. Native mobile interaction was not exercised.

Production fingerprints, EAS CLI 27.4.1, before = after:

  • iOS: 2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3
  • Android: c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d

Copy audit — docs/copy.md §8

  • Broken image or generic failure → the BFF's public reason and Retry: names the actual dependency and gives one recovery action.
  • No loading feedback → Loading image…: an accessible status while bytes load.
  • Decoder failure → Could not show the image. Download it to open it.: plain language and a next action; Retry remains available.
  • Checked sentence case, active voice, glossary, action verbs and accessible status/alert text. No new glossary term, decorative sentence or meaning conveyed only by colour.
  • Checked short, typical and long names at desktop and phone widths in light/dark. Long computer names wrap within the compact error panel.

The inline previews added in #398 hid linked-home read failures behind broken images. Surface public failures, retry when the home reconnects and bound preview responses from older homes.

Fixes: #398
@nixuuu
nixuuu merged commit 88e71a4 into dev Nov 9, 2026
15 of 17 checks passed
@nixuuu
nixuuu deleted the fix/linked-attachment-previews branch November 9, 2026 16:18
nixuuu added a commit that referenced this pull request Nov 9, 2026
### Rebase verification — 2026-11-09

The five-layer stack is rebased onto `dev` at
`2580ed75cdfc162e98e125b7c4d0b24eb81901b7`, including #418 and
#421–#426. All PRs remain ready for review. The measurements below
describe the original baseline; this section records the current
integration verification.

The attachment route now passes `If-None-Match` through #421's shared
response helper. Gateway authorization/read succeeds before a 304 is
possible; qualified IDs, thumbnail fallback, bounded preview/truncation,
sanitized public failures and `no-store` errors are retained. Mobile
image caching retains public error messages and reconnect retries.
Session startup, replacement pairing, unpair and revocation retain all
four caches: transcript, bot, archived sidebar and images. The
branch/worktree panel, channel identity and sheet gesture changes remain
intact.

Passed on the rebased top branch: `bun install`, `bun run gen:check`,
full `bun run typecheck`, root `bun run lint`, `bun run format:check`
and the production web build. Final focused `check:tmp`: **27 passed, 0
failed, 334 assertions across 7 files**, no temp leftovers (images,
immutable HTTP, transcript/archive/bot caches, two-gateway linked
previews and composer choices). Coverage includes a matching old ETag
returning 404 after ownership changes and 409 while the home is
unavailable, with `no-store` and no ETag; image/archive caches are wiped
together and late callbacks cannot restore them.

EAS CLI **27.4.1**, production profile, before/after the image-cache and
preparation layers and on the final top branch: **unchanged relative to
the latest dev baseline**:

- iOS: `bf3156a1bd878e10c0b0be25d4c194a837fb1b7e`
- Android: `d638e5f7b7fa87f54ccc0715c5fe150b8c0ad3ae`

These differ from the original measurement hashes below because #424
already changed native branding/configuration on dev. This stack adds no
native dependency/configuration change. Final production Hermes exports
passed sequentially with one Metro worker: iOS **9,971,620 B**, Android
**9,961,323 B**. These include the newly merged client features; the
earlier performance comparisons below retain their original baseline.
Expo Doctor: **20/20**. An additional Expo ESLint check of the conflict
files reports the same pre-existing `react-hooks/set-state-in-effect`
finding in `useImage.ts` on both this head and unmodified `origin/dev`;
session cleanup has no Expo ESLint findings. The required root oxlint
check passes.

No full local test run was started, as requested for the overloaded
shared machine. The earlier full-run timeout below is historical;
**GitHub CI is the current full-suite merge gate**. No native builds,
EAS builds, OTA publication or UI test suites were added. Previous
on-device profiling gaps remain.

---

Adds a repeatable Bun client CPU harness and a real-time browser
workload using the existing development renderer fixture. Pure mobile
timeline preparation can be imported without loading React Native
modules. A disposable launcher owns its PostgreSQL, gateway and BFF and
cleans them up by identity.

| Metric / capability | Before | After | Method / environment |
|---|---|---|---|
| Deterministic large snapshot | Dev renderer fixture | CLI harness:
1,000 turns, 7,099 items, 14,085,915 protobuf bytes | Bun 1.4.4, Linux
x86_64 |
| CPU measurements | Manual | Warmed median/p95 for reducer, feed,
mobile preparation, markdown and cache | `bun
scripts/bench/client-js.ts` |
| Session workload | Manual visits | Actual 30-minute run, 200 deltas
per visit at 25/s, heap/DOM/long-task samples | Chromium 156, one
1280×800 tab |
| Bundle accounting | Build output only | Deduplicated static JS/CSS
import closure, raw and gzip | `bun scripts/bench/bundle-sizes.ts` |

This is measurement tooling, not a committed UI test suite or an
optimization claim. Results belong in PR descriptions, not repository
files. The renderer fixture measures remount through two animation
frames, not cold thread navigation or browser TTI. Its handler samples
decode protobuf JSON objects and reduce them; they exclude EventSource
and string JSON parsing. The later tooling layer adds measurements over
the real network path.

Mobile fingerprints before/after extraction match on both platforms (EAS
CLI 27.4.1 production): iOS `2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3`,
Android `c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d`. Both platform
exports succeeded. Whole-stack verification is recorded on the top PR.

Polish documentation describes measurement commands, limitations,
cleanup and on-device profiling. No application UI copy changes, native
builds, secrets, screenshots or measurement result files are included.
nixuuu added a commit that referenced this pull request Nov 9, 2026
### Rebase verification — 2026-11-09

The five-layer stack is rebased onto `dev` at
`2580ed75cdfc162e98e125b7c4d0b24eb81901b7`, including #418 and
#421–#426. All PRs remain ready for review. The measurements below
describe the original baseline; this section records the current
integration verification.

The attachment route now passes `If-None-Match` through #421's shared
response helper. Gateway authorization/read succeeds before a 304 is
possible; qualified IDs, thumbnail fallback, bounded preview/truncation,
sanitized public failures and `no-store` errors are retained. Mobile
image caching retains public error messages and reconnect retries.
Session startup, replacement pairing, unpair and revocation retain all
four caches: transcript, bot, archived sidebar and images. The
branch/worktree panel, channel identity and sheet gesture changes remain
intact.

Passed on the rebased top branch: `bun install`, `bun run gen:check`,
full `bun run typecheck`, root `bun run lint`, `bun run format:check`
and the production web build. Final focused `check:tmp`: **27 passed, 0
failed, 334 assertions across 7 files**, no temp leftovers (images,
immutable HTTP, transcript/archive/bot caches, two-gateway linked
previews and composer choices). Coverage includes a matching old ETag
returning 404 after ownership changes and 409 while the home is
unavailable, with `no-store` and no ETag; image/archive caches are wiped
together and late callbacks cannot restore them.

EAS CLI **27.4.1**, production profile, before/after the image-cache and
preparation layers and on the final top branch: **unchanged relative to
the latest dev baseline**:

- iOS: `bf3156a1bd878e10c0b0be25d4c194a837fb1b7e`
- Android: `d638e5f7b7fa87f54ccc0715c5fe150b8c0ad3ae`

These differ from the original measurement hashes below because #424
already changed native branding/configuration on dev. This stack adds no
native dependency/configuration change. Final production Hermes exports
passed sequentially with one Metro worker: iOS **9,971,620 B**, Android
**9,961,323 B**. These include the newly merged client features; the
earlier performance comparisons below retain their original baseline.
Expo Doctor: **20/20**. An additional Expo ESLint check of the conflict
files reports the same pre-existing `react-hooks/set-state-in-effect`
finding in `useImage.ts` on both this head and unmodified `origin/dev`;
session cleanup has no Expo ESLint findings. The required root oxlint
check passes.

No full local test run was started, as requested for the overloaded
shared machine. The earlier full-run timeout below is historical;
**GitHub CI is the current full-suite merge gate**. No native builds,
EAS builds, OTA publication or UI test suites were added. Previous
on-device profiling gaps remain.

---

Obrazy mobilne są pobierane dopiero po wejściu do widocznego okna osi
czasu. Powrót do historii lub otwarcie viewerów korzysta z prywatnych,
niezmiennych plików zamiast ponownego RPC i base64.

Cache rozdziela parowania (owner-bound device id + pin), pełne
kwalifikowane identyfikatory komputerów i rzeczywiste warianty
thumbnail/full. Blob lub załącznik bez miniatury dzieli pełny wariant
pomiędzy listą i viewerem, bez powtórnego odczytu. Pliki i katalogi mają
nazwy SHA256; limit dysku to 200 MiB / 2048 wpisów, indeks URI w pamięci
ma budżet 24 MiB ważony bajtami obrazu. To nie ogranicza natywnych
bitmap. Wspólne żądania są anulowane po odejściu ostatniego odbiorcy.
Forget, revocation i ponowne parowanie zamykają cache i usuwają pliki;
spóźniona odpowiedź nie odtwarza danych. Brak nowych modułów natywnych
lub uprawnień galerii.

Załączniki w listach i wysłane chipy używają miniatur; viewer pełnego
wariantu. GetThreadBlob nie udostępnia miniatur: jego podglądy nadal
używają obrazu źródłowego. BFF zachowuje private/immutable, dodaje ETag
SHA256 reprezentacji i 304 po autoryzacji; błędy API mają no-store.
Istniejące loading="lazy" i odrębne URL ?thumbnail/?preview pozostają
zachowane. Zmiana nie ingeruje w routing linked previews 409.

| Metryka | Przed | Po | Metoda / środowisko |
|---|---:|---:|---|
| Żądania: 20 miniatur, dwa przejścia + ponowne otwarcie | 60 | 20 | bun
scripts/bench/image-cache.ts, Bun 1.4.4 Linux; symulowane montowania,
rzeczywisty HTTP + filesystem |
| Bajty odpowiedzi | 983 040 | 327 680 | 20 deterministycznych miniatur
po 16 KiB, ten sam scenariusz |
| Restart cache / ponowne otwarcie, to samo parowanie | 20 / 327 680 B |
0 / 0 B | nowa instancja cache, zachowany prywatny dysk |
| Fingerprint iOS | 2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3 |
identyczny | eas-cli 27.4.1, production, przed/po |
| Fingerprint Android | c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d |
identyczny | eas-cli 27.4.1, production, przed/po |
| Bundle Hermes iOS, cały stos względem pierwotnego dev | 9 900 217 B |
9 927 705 B | expo export, produkcyjny JS/assets, bez builda natywnego |
| Bundle Hermes Android, cały stos względem pierwotnego dev | 9 889 662
B | 9 917 398 B | expo export, produkcyjny JS/assets, bez builda
natywnego |

Rzeczywista przeglądarka Chromium 156, produkcyjny BFF + gateway,
prywatny seed 1000 tur / 500 wątków, 1280×800: 20 PNG 256×256 w dwóch
wiadomościach. Pierwsze przejście pobrało 20 miniatur / 803 816 B treści
(809 816 B Resource Timing transferSize). Drugie przejście: 0 żądań
sieciowych / 0 B; ponowne otwarcie: 0 / 0 B, 20 wpisów z cache. Web już
miał private/immutable, więc nie przypisujemy tej zmianie oszczędności
ponownego transferu w web. To pomiar po zmianie; historycznego before w
browserze dla obrazów nie zarejestrowano. Seed tego przebiegu miał
ręcznie uzupełniony katalog załączników workera; narzędzie w #415 teraz
zgłasza go przy hello.

Browser potwierdził: loading="lazy", ?thumbnail, różne ETag dla
thumbnail/full/preview, 304 z poprawnym If-None-Match i 404 z no-store
bez ETag. Sprawdzono telefon 390×844 w dark i desktop 1280×800 w light;
bez poziomego overflow, obrazy poprawnie zdekodowane. Serwery i browser
zamknięte przed pełnymi testami.

Weryfikacja: install, gen:check, pełny typecheck, root lint,
format:check, web build i eksporty Expo obu platform przeszły. Expo
Doctor: 20/20 kontroli. Końcowe 5 testów cache/HTTP (39 asercji)
obejmuje izolację, restart, LRU, brak pliku po usunięciu przez OS,
retry, współbieżność, ponowne użycie pełnego wariantu i wipe przy późnej
odpowiedzi; przeszły również w pełnym przebiegu. Dodatkowy Expo ESLint
dla zmienionych plików wskazuje istniejące już set-state-in-effect w
useImage; nowe wskazania refs zostały poprawione i sprawdzone ponownie.

Pierwotny końcowy pełny check:tmp zakończył się 1919 pass / 161 skip / 1
fail, 22 240 asercji, 1050.58 s, bez pozostałości temp. Pozostał
niezmieniany test composer-shell „Stop during a shell steer kills its
group and persists the failed delivery” — anulowanie RPC po 10 s.
Wcześniejszy przebieg miał też błędy ask-user i thread-mirror-deltas;
wszystkie trzy pliki przeszły następnie osobno razem (42 pass / 0 fail,
226 asercji, 38.70 s). Nie zmieniano timeoutów ani asercji. W pierwotnym
przekazaniu pełna bramka pozostawała nierozstrzygnięta, a stos był
draftem.

Harness nie mierzy renderera React Native ani RPC. Na urządzeniu
pozostają: widoczność wewnątrz wysokiej tury, szybki scroll/anulowanie,
bitmapy i filesystem Expo, viewer/restart/unpair/revocation; instrukcje
w docs/client-performance.md. Brak buildów natywnych, EAS i publikacji
OTA. Copy audit: bez nowych tekstów UI.
nixuuu added a commit that referenced this pull request Nov 9, 2026
### Rebase verification — 2026-11-09

The five-layer stack is rebased onto `dev` at
`2580ed75cdfc162e98e125b7c4d0b24eb81901b7`, including #418 and
#421–#426. All PRs remain ready for review. The measurements below
describe the original baseline; this section records the current
integration verification.

The attachment route now passes `If-None-Match` through #421's shared
response helper. Gateway authorization/read succeeds before a 304 is
possible; qualified IDs, thumbnail fallback, bounded preview/truncation,
sanitized public failures and `no-store` errors are retained. Mobile
image caching retains public error messages and reconnect retries.
Session startup, replacement pairing, unpair and revocation retain all
four caches: transcript, bot, archived sidebar and images. The
branch/worktree panel, channel identity and sheet gesture changes remain
intact.

Passed on the rebased top branch: `bun install`, `bun run gen:check`,
full `bun run typecheck`, root `bun run lint`, `bun run format:check`
and the production web build. Final focused `check:tmp`: **27 passed, 0
failed, 334 assertions across 7 files**, no temp leftovers (images,
immutable HTTP, transcript/archive/bot caches, two-gateway linked
previews and composer choices). Coverage includes a matching old ETag
returning 404 after ownership changes and 409 while the home is
unavailable, with `no-store` and no ETag; image/archive caches are wiped
together and late callbacks cannot restore them.

EAS CLI **27.4.1**, production profile, before/after the image-cache and
preparation layers and on the final top branch: **unchanged relative to
the latest dev baseline**:

- iOS: `bf3156a1bd878e10c0b0be25d4c194a837fb1b7e`
- Android: `d638e5f7b7fa87f54ccc0715c5fe150b8c0ad3ae`

These differ from the original measurement hashes below because #424
already changed native branding/configuration on dev. This stack adds no
native dependency/configuration change. Final production Hermes exports
passed sequentially with one Metro worker: iOS **9,971,620 B**, Android
**9,961,323 B**. These include the newly merged client features; the
earlier performance comparisons below retain their original baseline.
Expo Doctor: **20/20**. An additional Expo ESLint check of the conflict
files reports the same pre-existing `react-hooks/set-state-in-effect`
finding in `useImage.ts` on both this head and unmodified `origin/dev`;
session cleanup has no Expo ESLint findings. The required root oxlint
check passes.

No full local test run was started, as requested for the overloaded
shared machine. The earlier full-run timeout below is historical;
**GitHub CI is the current full-suite merge gate**. No native builds,
EAS builds, OTA publication or UI test suites were added. Previous
on-device profiling gaps remain.

---

Reuses prepared timeline entries for unchanged turns, makes sibling item
grouping linear, and avoids encoding/writing an identical immutable
snapshot repeatedly. New snapshot revisions still serialize and persist;
failed writes remain retryable, eviction allows a later resave, and
unpair/close fences remain intact.

| Metric | Before | After | Method / environment |
|---|---:|---:|---|
| Prepare 5,000 sibling items, median / p95 | 39.198 / 43.052 ms | 1.954
/ 3.728 ms | Bun 1.4.4, 10 samples after 5 warmups |
| Save the same immutable 14,085,915-byte snapshot, median | 30.218 ms |
<0.001 ms | Warm duplicates; in-memory storage adapter, no disk |
| Save a new immutable snapshot, median | 28.767 ms | 28.841 ms | Same
adapter; serialization still required |
| Cold cache load/decode, median | 21.348 ms | 20.932 ms | New cache per
sample, same encoded bytes; no disk |
| iOS Hermes bundle | 9,900,217 B | 9,901,992 B | Sequential `expo
export --platform ios` |
| Android Hermes bundle | 9,889,662 B | 9,891,426 B | Sequential `expo
export --platform android` |

CPU harness: deterministic 1,000-turn / 7,099-item snapshot on Linux
x86_64, Ryzen 5 5600X, shared 15.5 GiB machine. The before and after
control runs were consecutive while repository checks ran; this is not
an exclusive-CPU lab result. The grouping instrumentation retains
999/1,000 group arrays after one item changes. That is reference
retention, not a measured React render count.

Native fingerprints, EAS CLI 27.4.1, production profile, before = after:
- iOS: `2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3`
- Android: `c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d`

Only JS/TS changes; no native build, dependency, EAS build or OTA
publication. The exports establish bundle sizes, not runtime FPS.

Validation: durable bounded mobile cache integration cases passed (4
tests, 34 assertions), including retry, concurrent duplicate saves, disk
eviction/resave and close fencing. Whole-stack checks are recorded on
the top PR. No UI tests or changed UI copy.

Additional Expo ESLint check: 18 errors and 1 warning on both the frozen
baseline and this branch, all in unchanged files (effects/ref rules and
Expo Updates namespace imports). The required root oxlint check is
clean. These existing Expo lint findings were not suppressed or folded
into this performance change.

The table records the isolated preparation change measured before the
image-cache layer was added. Original cumulative final Hermes sizes,
including that layer: iOS 9,927,705 B and Android 9,917,398 B; both
native fingerprints were identical to that baseline. The image-cache
measurements and limitations are in #419. Original full-suite status is
recorded on #416: one unchanged composer-shell timeout remained
unresolved at that handoff.

On-device work remains: React Native commit/render counts, Hermes JS/UI
frame times, real filesystem read/write latency, variable-height
FlatList window tuning, and native bitmap/process memory after repeated
image-viewer visits. `docs/client-performance.md` gives the workload and
profiling procedure. This layer leaves FlatList settings and image
viewer behavior unchanged relative to #419.
nixuuu added a commit that referenced this pull request Nov 9, 2026
### Rebase verification — 2026-11-09

The five-layer stack is rebased onto `dev` at
`2580ed75cdfc162e98e125b7c4d0b24eb81901b7`, including #418 and
#421–#426. All PRs remain ready for review. The measurements below
describe the original baseline; this section records the current
integration verification.

The attachment route now passes `If-None-Match` through #421's shared
response helper. Gateway authorization/read succeeds before a 304 is
possible; qualified IDs, thumbnail fallback, bounded preview/truncation,
sanitized public failures and `no-store` errors are retained. Mobile
image caching retains public error messages and reconnect retries.
Session startup, replacement pairing, unpair and revocation retain all
four caches: transcript, bot, archived sidebar and images. The
branch/worktree panel, channel identity and sheet gesture changes remain
intact.

Passed on the rebased top branch: `bun install`, `bun run gen:check`,
full `bun run typecheck`, root `bun run lint`, `bun run format:check`
and the production web build. Final focused `check:tmp`: **27 passed, 0
failed, 334 assertions across 7 files**, no temp leftovers (images,
immutable HTTP, transcript/archive/bot caches, two-gateway linked
previews and composer choices). Coverage includes a matching old ETag
returning 404 after ownership changes and 409 while the home is
unavailable, with `no-store` and no ETag; image/archive caches are wiped
together and late callbacks cannot restore them.

EAS CLI **27.4.1**, production profile, before/after the image-cache and
preparation layers and on the final top branch: **unchanged relative to
the latest dev baseline**:

- iOS: `bf3156a1bd878e10c0b0be25d4c194a837fb1b7e`
- Android: `d638e5f7b7fa87f54ccc0715c5fe150b8c0ad3ae`

These differ from the original measurement hashes below because #424
already changed native branding/configuration on dev. This stack adds no
native dependency/configuration change. Final production Hermes exports
passed sequentially with one Metro worker: iOS **9,971,620 B**, Android
**9,961,323 B**. These include the newly merged client features; the
earlier performance comparisons below retain their original baseline.
Expo Doctor: **20/20**. An additional Expo ESLint check of the conflict
files reports the same pre-existing `react-hooks/set-state-in-effect`
finding in `useImage.ts` on both this head and unmodified `origin/dev`;
session cleanup has no Expo ESLint findings. The required root oxlint
check passes.

No full local test run was started, as requested for the overloaded
shared machine. The earlier full-run timeout below is historical;
**GitHub CI is the current full-suite merge gate**. No native builds,
EAS builds, OTA publication or UI test suites were added. Previous
on-device profiling gaps remain.

---

Adds synthetic seeded data and a scripted worker so client measurements
can use a real gateway/BFF/EventSource path without inference or an
existing developer stack. The worker only produces synthetic answers;
credentials stay in process memory. Scripts clean up their own
servers/container and require a disk-backed TMPDIR.

| Metric / coverage | Before | After | Method / environment |
|---|---|---|---|
| Private database dataset | Empty | 500 threads; one with 1,000 turns
and 7,099 items | New disposable PostgreSQL only |
| Very long single answer | Moderate fixture answers | Last answer
repeated 64 times; configurable 1–100 in dev fixture | `answerRepeat=64`
|
| Streaming producer | In-process synthetic updates | 200 deltas at 25/s
over worker → gateway → BFF → SSE | Scripted worker, no CLI/model |
| Snapshot handler coverage | JSON-object decoder/reducer | Actual
EventSource arrival + string JSON parse + protobuf decode + state apply
| `probeThreadSnapshot(id,20)` |
| Navigation coverage | Renderer remount | SPA thread paint/focus-ready
proxy | `probeThreadNavigation(path)` |
| Bundle attribution | SvelteKit node numbers | Route names, all
layouts, shell and deduplicated JS/CSS closure | Generated SvelteKit
manifests |

`probeThreadStream(id)` sends a message and is intended exclusively for
the disposable synthetic thread. Both probes request incremental SSE,
ignore heartbeat frames when waiting for the first snapshot, and stream
completion follows the submitted turn's terminal state (including
coalesced updates). The seed gives threads a provider session identity
so submitted turns can start. BFF coalescing reduces the number of
delivered messages. Handler timing excludes rendering; the normal thread
page can remain subscribed to inspect the same stream. A sampled run
delivered 49 coalesced delta messages in 8.10 seconds, with handler
median / p95 of 0.2 / 0.3 ms on Chromium 156, Linux x86_64, 1280×800. It
generated 200 producer deltas at 25/s without inference.

This layer adds measurement coverage, not a production performance
claim. Navigation paint/focus readiness is not browser TTI. Cold FCP
depends on build/cache state. Native render counts, native UI frames,
filesystem latency and image bitmap memory still require an on-device
profile. No UI test suite was added. Polish `docs/client-performance.md`
documents commands and limits; whole-stack verification and measured
browser results are recorded on the top PR.

Fresh-launch verification after the tooling correction: a newly created
disposable database and production BFF accepted one synthetic message,
delivered 45 coalesced `itemDelta` events plus `itemCompleted` /
`turnFinished`, and persisted the turn as completed. No manual database
updates were needed. The bounded SSE capture intentionally stopped at
its 15-second curl deadline after completion; that deadline is not a
stream failure.
nixuuu added a commit that referenced this pull request Nov 9, 2026
### Rebase verification — 2026-11-09

The five-layer stack is rebased onto `dev` at
`2580ed75cdfc162e98e125b7c4d0b24eb81901b7`, including #418 and
#421–#426. All PRs remain ready for review. The measurements below
describe the original baseline; this section records the current
integration verification.

The attachment route now passes `If-None-Match` through #421's shared
response helper. Gateway authorization/read succeeds before a 304 is
possible; qualified IDs, thumbnail fallback, bounded preview/truncation,
sanitized public failures and `no-store` errors are retained. Mobile
image caching retains public error messages and reconnect retries.
Session startup, replacement pairing, unpair and revocation retain all
four caches: transcript, bot, archived sidebar and images. The
branch/worktree panel, channel identity and sheet gesture changes remain
intact.

Passed on the rebased top branch: `bun install`, `bun run gen:check`,
full `bun run typecheck`, root `bun run lint`, `bun run format:check`
and the production web build. Final focused `check:tmp`: **27 passed, 0
failed, 334 assertions across 7 files**, no temp leftovers (images,
immutable HTTP, transcript/archive/bot caches, two-gateway linked
previews and composer choices). Coverage includes a matching old ETag
returning 404 after ownership changes and 409 while the home is
unavailable, with `no-store` and no ETag; image/archive caches are wiped
together and late callbacks cannot restore them.

EAS CLI **27.4.1**, production profile, before/after the image-cache and
preparation layers and on the final top branch: **unchanged relative to
the latest dev baseline**:

- iOS: `bf3156a1bd878e10c0b0be25d4c194a837fb1b7e`
- Android: `d638e5f7b7fa87f54ccc0715c5fe150b8c0ad3ae`

These differ from the original measurement hashes below because #424
already changed native branding/configuration on dev. This stack adds no
native dependency/configuration change. Final production Hermes exports
passed sequentially with one Metro worker: iOS **9,971,620 B**, Android
**9,961,323 B**. These include the newly merged client features; the
earlier performance comparisons below retain their original baseline.
Expo Doctor: **20/20**. An additional Expo ESLint check of the conflict
files reports the same pre-existing `react-hooks/set-state-in-effect`
finding in `useImage.ts` on both this head and unmodified `origin/dev`;
session cleanup has no Expo ESLint findings. The required root oxlint
check passes.

No full local test run was started, as requested for the overloaded
shared machine. The earlier full-run timeout below is historical;
**GitHub CI is the current full-suite merge gate**. No native builds,
EAS builds, OTA publication or UI test suites were added. Previous
on-device profiling gaps remain.

---

Reduces allocations while retaining unchanged feed rows and loads the
bot settings editor only when it is first opened. Provider discovery and
the dynamic import run concurrently; the existing loading/error dialog,
generation fence and close animation remain in place. Web and the
Electron renderer share this build.

| Metric | Before | After | Method / environment |
|---|---:|---:|---|
| FeedBuilder unchanged 1,000-turn history, median / p95 | 25.829 /
37.331 ms | 16.725 / 31.636 ms | 30 Bun samples after 5 warmups; shared
machine with checks running |
| Initial shell JS, raw / gzip | 1,049,359 / 376,536 B | 978,327 /
348,632 B | Production static import closure |
| Thread route JS, raw / gzip | 1,602,296 / 565,283 B | 1,567,887 /
552,802 B | `/threads/[threadId]`, shell + layouts + page, deduplicated
|
| General settings JS, raw / gzip | 1,078,406 / 389,672 B | 1,007,374 /
361,768 B | `/settings/general`, same accounting |
| Bot conversation JS, raw / gzip | 1,230,361 / 443,477 B | 1,201,264 /
433,818 B | `/bots/[botId]`, same accounting |
| Initial shell CSS, raw / gzip | 241,576 / 39,106 B | 240,383 / 38,685
B | Production static import closure |
| Renderer remount, two-frame proxy | 20.3 ms | 17.8 ms | One warmed run
per revision, isolated 1,000-turn fixture |
| Streaming update + render/layout, mean / p95 | 18.58 / 24.6 ms | 12.89
/ 17.3 ms | Same fixture and deterministic 200 updates; not network
latency |
| Scroll frame mean / max | 16.67 / 16.8 ms | 16.66 / 16.8 ms | 80
scroll steps; zero frames over threshold in either run |
| Production cold first paint / FCP | 128 / 300 ms | 128 / 264 ms |
Single sample per origin, cold HTTP cache, 500-thread sidebar |
| Production first feed + focus-ready observation | 1,044.9 ms | 668 ms
| Tool-attachment upper bound, single sample; not precise TTI |
| Real SSE delta handler, median / p95 | 0.2 / 0.3 ms | 0.3 / 0.4 ms |
One ~8.2-second turn, 200 producer deltas at 25/s, JSON.parse + decode +
reducer only |

Environment: Bun 1.4.4, Linux x86_64, Ryzen 5 5600X, shared 15.5 GiB
memory, Chromium 156 at 1280×800. JS data: 1,000 turns, 7,099 items,
14,085,915 protobuf bytes. CPU comparisons use identical deterministic
input; no exclusive-CPU claim. Dynamic imports and highlighter grammars
are excluded from initial static closure totals.

The browser samples are descriptive measurements on a shared machine,
not statistically significant navigation or SSE speedup claims. BFF
coalescing delivered 49 delta messages before and 36 after in the
sampled network turns. The SSE reducer was not optimized here. Initial
real snapshots were 24-turn pages, not all 1,000 turns; their sampled
payloads differ after synthetic turns, so no snapshot speedup is
claimed.

Visual verification: real seeded thread with a 64× long answer, desktop
1280×800 and phone 390×844, light and dark, streaming, anchored
composer, lazy bot editor initial open/close/reopen and error display.
No horizontal document overflow observed. A visible completed answer
retained exactly the same viewport y coordinate (-465.664 px) throughout
a subsequent 8.2-second streamed turn while reading history. The fixture
stayed at zero bottom gap after streaming. Motion code and tokens are
unchanged; reduced-motion emulation was not available through the shared
browser tool and was not runtime-verified.

The existing timeline virtualizer limits mounted articles, but a single
huge answer still creates all its Markdown DOM and the 500-row sidebar
eventually mounts in full (26,215 total elements in the settled seeded
production page). The isolated fixture's mounted element count was 164
before / 114 after at sampled positions; variable visible rows make this
unsuitable as a DOM-reduction claim. These are remaining candidates, not
fixed problems in this PR.

Original validation: `bun install`, `gen:check`, full `typecheck`, root
`lint`, `format:check`, production web build and both Expo exports
passed. The original final full `check:tmp` finished with 1,919 pass /
161 skip / 1 fail, 22,240 assertions, 1,050.58 seconds, no temp
leftovers. The unchanged composer-shell test “Stop during a shell steer
kills its group and persists the failed delivery” hit a 10-second RPC
cancellation in both original final full runs; its focused retry passed.
At that handoff, the full gate was unresolved and the stack was draft.
No timeout, assertion or backend changes were made to obtain a pass. No
UI test suite was added.

| Actual 30-minute session | Before | After | Method / limitation |
|---|---:|---:|---|
| Duration | 1,801.418 s | 1,801.638 s | Same 1,000-turn fixture, 25
producer updates/s within each visit |
| Completed cycles / updates | 204 / 40,800 | 187 / 37,400 | Shared
host; the full test suite ran during the after-session |
| Handler median / p95 | 1.3 / 2.6 ms | 2.1 / 3.7 ms | Protobuf
JSON-object decode + reducer; excludes network/render |
| Long tasks / total duration | 1,444 / 131.895 s | 3,894 / 305.815 s |
Includes reset, stream and scroll; unequal concurrent load |
| Chromium heap counter, first → last | 109 → 364 MB | 342 → 462 MB |
Coarse/cached counter; no forced GC, different starting heaps |
| DOM first / last / range | 688 / 563 / 533–752 | 554 / 686 / 516–725 |
Entire isolated fixture page |

The long run was worse under its recorded conditions; it is not evidence
of a performance win. The concurrent suite took 1,580 seconds versus
1,029 seconds in the earlier successful run, confirming substantially
different observed runtime conditions without proving the cause of
either result. Heap counter growth cannot establish retained memory or
the absence of leaks; a DevTools memory profile with controlled GC
remains necessary. No memory improvement is claimed.

A subsequent short control without the full suite, using the same
1,000-turn fixture (after first, then before), recorded:

| Short session metric | Before | After | Method / limitation |
|---|---:|---:|---|
| Duration / cycles / updates | 126.187 s / 13 / 2,600 | 124.428 s / 14
/ 2,800 | One ~2-minute sample each; no own test suite, shared host |
| Long tasks / total duration | 174 / 16.882 s | 32 / 6.642 s | About
13.4 vs 2.3 long tasks/cycle; no exclusive-CPU claim |
| Handler median / p95 | 0.7 / 1.5 ms | 2.1 / 3.4 ms | Reducer timing
remains worse in this sample; no handler win claimed |

The short control did not reproduce the long-task regression and does
not establish long-session memory stability. A controlled CPU/memory
profile remains open before claiming an overall long-session
improvement. The paired Bun harness and bundle accounting are the
primary evidence for this change.

Failure follow-up: unchanged ask-user, composer-shell and
thread-mirror-deltas files passed together (42 tests, 226 assertions, 0
failures, clean temp directory, 38.70 seconds). The subsequent full run
passed ask-user and mirror cases but repeated the composer-shell
timeout. This does not establish the cause or make the full gate green.

The final stack includes the focused image-cache layer #419. Browser
validation on that final stack: 20 real thumbnails, 803,816 body bytes
on first pass, zero additional network requests/body bytes on a second
pass or reopening the thread. Existing web immutable caching already
provided repeat reuse; no additional web transfer improvement is
claimed. ETag/304, distinct variants and no-store 404 were observed.
Mobile final Hermes bundles are iOS 9,927,705 B / Android 9,917,398 B,
with unchanged production fingerprints. Final route bundle accounting is
identical to the table above.

The five focused cache and immutable HTTP checks passed (39 assertions),
including in the final full run. Expo Doctor passed 20/20 checks. All
owned benchmark servers and browser tabs were closed before the final
full checks.

Copy audit: no changed application UI text. No UI test suite was added.
Polish documentation records row equality, lazy loading and the
measurement method. This does not change FlatList tuning, markdown
parsing, native image memory, Electron main-process caches or
synchronization semantics.
nixuuu added a commit that referenced this pull request Nov 9, 2026
Adds opt-in channel counters and a repeatable two-gateway restart
scenario, with no payload, identifier or secret retention. Disabled
metrics do no CPU sampling or extra instrumentation serialization.
Polish docs describe the measurement boundaries. Later stack layers
extend the workload and add isolated-process CPU profiling.

### Measurement

Measurement baseline: `dev` **4dfb2f85** (#400–407), as profiled before
the later #421–425 merges. The tables compare that implementation with
the **completed stack**, not each layer in isolation. Both variants use
the identical top-branch fixture and counter definitions. Three
sequential unprofiled runs per variant and fixture; no concurrent
multi-gateway files. The current stack is rebased onto **04a871be**;
performance was not remeasured for this restack or the newly inherited
dev changes.

The workload streams 1500 text deltas at 20 ms intervals, tool results
and background progress, with six remote views, a pinned phone client,
both overviews and the production BFF transport/SSE/coalescer. It then
restarts the home gateway on its existing database, changes data offline
and catches up the mirror. This is a protocol fixture with scripted
workers, without a browser, native phone runtime or full SvelteKit
request stack.

#### CPU by process

Run `CANOPY_SYNC_METRICS=1 CANOPY_SYNC_PROCESSES=1 bun run check:tmp
tests/integration/sync-process-performance.test.ts`. Each gateway and
the BFF execute in a separate Bun process. Gateway CPU includes its
scripted worker. The controller, watch readers, phone client and
PostgreSQL are excluded. Active CPU covers approximately 30 s; idle CPU
covers a separate 10.2 s window after the turn.

| Process | Active CPU median s before → after | Active CPU mean s
before → after | Idle CPU median s before → after |
|---|---:|---:|---:|
| Home gateway | 4.977 → 4.741 | 4.847 → 5.177 | 0.226 → 0.215 |
| Viewer gateway | 2.569 → 1.786 | 2.480 → 1.934 | 0.121 → 0.090 |
| BFF | 0.659 → 0.586 | 0.665 → 0.596 | 0.031 → 0.027 |
| Sum per run | **8.247 → 7.114 (−13.7%)** | **7.993 → 7.707 (−3.6%)** |
0.373 → 0.333 |

All active CPU totals: baseline **8.247 / 8.371 / 7.362 s**; stack
**7.114 / 9.381 / 6.625 s**. The high stack run includes 6.431 s on the
home gateway. Home median falls 4.7%, while its mean rises 6.8%; this
small shared-machine sample does not establish a home CPU improvement or
statistical significance. Total CPU meets the dev baseline by both
median and mean. Event-loop p99 medians in ms are home 0.889 → 1.976,
viewer 0.869 → 1.632, BFF 0.578 → 1.485; maximum observed home delay is
13.10 → 39.75 ms. No event-loop latency improvement is claimed.

The original combined-process fixture independently gives CPU median
**6.461 → 5.926 s (−8.3%)**, mean **6.509 → 6.224 s (−4.4%)**; all
samples are 6.461/6.314/6.752 → 5.262/7.484/5.926 s. It includes the
controller and clients, so its totals must not be compared directly with
the three-process sum.

#### Profiles and CPU changes

`CANOPY_SYNC_PROFILE_DIR` runs all three children with `bun --cpu-prof
--cpu-prof-md`. Profiles were collected on dev, the rebased stack before
CPU changes and the final stack. Interval CPU in those single profiled
runs:

| Process | dev s | Stack before CPU changes s | Final stack s |
|---|---:|---:|---:|
| Home | 5.030 | 5.854 | 5.389 |
| Viewer | 2.636 | 2.289 | 2.187 |
| BFF | 0.835 | 0.729 | 0.701 |
| Total | 8.501 | 8.873 | 8.277 |

On the home gateway, all sampled native `writeBuffered` stacks lead
through `@effect/sql-pg`; Effect/SQL execution and protobuf
creation/serialization are also hot. Direct revision-coordinator samples
are small. Home native-writer sample counts change 666 → 999 → 700;
coalescer samples 0 → 27 → 11. These profiles include startup/teardown
and locate work, rather than allocate exact activity CPU seconds.
Markdown self-time includes waiting gaps and is not used as CPU
evidence. The high unprofiled outlier cannot be attributed to one
function from a different profiled run.

The final layer removes avoidable work introduced by buffer
accounting/coalescing: immutable text events reuse encoded bytes across
Hub accounting, publisher accounting and linked sends; identical
coalesced ranges share an owned batch; one timer serves an entire batch.
Mutable snapshots/configuration messages are never cached. When the
durable owner head is unchanged, the revision query skips fork-chain
recursion and turn/bus dependency reads. A cheap durable clock plus
authorized-thread read remains necessary for missed-fan-out and epoch
recovery. No ingest batching, database maintenance or schema changes are
included.

#### Traffic and consistency

Run `CANOPY_SYNC_METRICS=1 CANOPY_SYNC_BENCH=1 bun run check:tmp
tests/integration/sync-performance.test.ts`. Values below are medians of
the original combined-process fixture. Count only the encode direction
for traffic; linked codec CPU excludes framing/TLS and PostgreSQL. Cache
lookup CPU is measured at the linked encode hook; initial
queue-accounting serialization occurs outside that hook and is included
in process CPU.

| Scenario | Messages before → after | Bytes before → after | Encode /
decode CPU ms before → after | Consistency ms before → after |
|---|---:|---:|---:|---:|
| Linked thread watches | 4802 → 2139 | 875617 → 462443 | 49.703 /
60.282 → 24.867 / 31.764 | 36.03 → 39.58 |
| BFF SSE | 270 → 255 | 161904 → 152542 | 8.891 / n/a → 11.426 / n/a |
Not separately measured |
| Pinned phone | 1583 → 696 | 364396 → 186690 | Native codec CPU
unmeasured | Included in watch convergence |
| Active mirror | 545 → 489 | 630964 → 636102 | 13.073 / 12.033 → 12.408
/ 11.137 | Not separately measured |
| Mirror restart/offline change | 43 → 9 | 17290 → 15755 | 0.441 / 0.423
→ 0.222 / 0.298 | 5056.27 → 5063.60 |

Linked watches: **158.4 → 70.5 messages/s**, **28.9 → 14.9 kB/s**,
−55.5% messages and −47.2% bytes. Phone: −56.0% messages, −48.8% bytes.
Watch medians retain 48 heartbeats, 18 checkpoint deltas and zero full
snapshots during activity; those heartbeats share 12 owner/runtime probe
queries. Catch-up retains one full projection in both implementations,
packed into 43 → 9 fragments. Active mirror bytes and BFF encoding CPU
do not improve consistently.

The isolated-process fixture independently measures title convergence
**35.61 → 35.61 ms**, reconnect **3394 → 3449 ms**. Its BFF SSE median
bytes are 162661 → 168556; checkpoint/flush timing differs between
fixtures. There is no general BFF byte or reconnect latency claim.
Profiles, logs and measurement results are kept outside the repository.

### Compatibility and verification

Negotiated tests cover new/new, legacy subscriber/new home, new
subscriber/legacy home, and a paused subscriber overflowing while a
healthy subscriber receives complete text on the same link. Resume
supplies a durable delta. Local/linked liveness covers unrelated-thread
activity, already-scanned pruning, retained-journal gaps, missed
fan-out, sequence/base gaps, stalls, older peers and stale mirrors.
Legacy capability sets simulate old peers; historic binaries are not
tested.

The frozen update proto and `WORKER_LINK_PROTOCOL` are unchanged. Proto
additions and generated code are committed. No mobile source or native
dependency changes; fingerprints were not changed or regenerated. No UI
tests.

All layers remain **ready for review**. Restacked onto dev `04a871be`
after #418, #426 and the client performance stack merged; final top head
`e00a8f74`. The only conflict was the generated UI protobuf descriptor:
`bun run gen` preserves both `last_user_turn_choices` and the negotiated
coalescing fields. Layers 1 and 2 are unchanged by range-diff; layer 3
differs only in the regenerated descriptor.

On this top head, `bun install`, `bun run gen:check`, `bun run
typecheck`, `bun run lint`, `bun run format:check` and the web build
pass. Focused integration runs: **69 pass, 0 fail** across seven files,
each run separately through `bun run check:tmp` with a private
disk-backed TMPDIR and no test-owned leftovers: linked liveness 14,
local liveness 1, sync negotiation/backpressure 4, composer shell 18,
composer choices 4, thread mirrors 20, bounded thread reads 8. These
include both previously failing liveness cases, new/legacy negotiation,
stalled-subscriber isolation, durable resume and #418's composer
choices. No full local suite was started for this restack, as requested;
fresh CI on every layer is the merge gate. Earlier green checks and
historical performance results are not evidence for these rebased heads.

Copy audit: no product UI copy or controls changed; failures use
existing reconnect/error flows.

### Remaining measurements

Repeat the home CPU/outlier and event-loop measurements on target
hardware; measure large histories and slow/lossy networks before
compression or negotiated credits. Physical-device CPU, historic binary
pairs and full BFF HTTP serving remain unmeasured. Update-center polling
needs an invalidation feed before removal. Journal retention and
staging-generation leases belong to the separate database work; this
stack adds no durable retention watermark. All layers remain ready for
review at the maintainer's request; merge the stack atomically only
after every layer's checks pass.
nixuuu added a commit that referenced this pull request Nov 9, 2026
)

Local and linked thread watches share #402's durable revision mechanism
through one owner/runtime coordinator. Watches due together share a
journal read. Each watch separately tracks its scanned position and
relevant revision, preserving quiet-thread stability after unrelated
changes and pruning already-scanned rows. Gaps, epoch changes, inherited
history and external dependencies retain conservative recovery.

No parallel revision protocol or new revision capability is added. The
final layer adds the unchanged-head query fast path. No schema or
retention changes.

Related: #402

### Layer 2 liveness test repair

CI run 42639923694 exposed timing assumptions in this layer's
integration fixture, not a production protocol defect. On the original
`perf/sync-2` head, the file passed alone, then failed in 4/10 separate
sequential runs with Bun restricted to one CPU: three event-gap failures
and one transient mirror-status failure.

The mirror seed arrives before the authoritative home watch is ready.
The fixture now waits for a non-syncing snapshot/delta before injecting
faults. The event-gap test holds revision frames until it has dropped a
real event and delivered a successor, then requires a newer full
snapshot and completion of the specific turn. The idle-mirror test holds
recovery frames until it observes unreachable over a healthy physical
link, releases them, and verifies reconnection without changing the
committed cursor or generation. Stall/legacy tests wait for the actual
resubscription before releasing their injected fault. The
background-checkpoint test holds its fault until cursor invalidation,
then waits for the new generation to commit rather than equating a
current title with a completed reset.

The physical link heartbeat is separate from application liveness: its
fixture interval is now 1 s, so a 400 ms transport expiry cannot preempt
the 1 s application lease under full-suite scheduling pressure.
Application heartbeat/expiry remain 100/1000 ms. No fixed sleeps,
application timeout increases, production changes, schema changes or
compatibility changes are added by this repair.

The wider gate also exposed a shell-test precondition race. The native
harness probe can arrive before durable `turn_started`; diagnostic reads
after the failure showed a running turn but no `interruptTurn` command
had been admitted. The test now waits for the gateway's durable running
state before steering and pressing Stop, preserving its process-group
and persisted-interruption assertions. The reproducing four-file
sequence passes 35/35. Temporary diagnostic SQL/logging was removed.
Stop during dispatched-but-not-yet-running admission remains a separate
boundary to investigate; this repair does not change that production
behavior.

Layer-2 verification: the final liveness fixture passes alone (14 tests,
98 assertions) and in **10/10 separate sequential one-CPU runs** before
the latest dev rebase (140 tests, no temporary leftovers). The complete
shard 4 then passes on the repaired layer 2: **455 pass / 44 skip / 0
fail**. After rebasing onto `2ffb6f04`, it passes again on `176f1799`:
**437 pass / 41 skip / 0 fail**, 478 tests across 85 files, 241.67 s, no
test-owned temporary leftovers. Shard membership changes with newly
inherited test files. This includes all 14 liveness tests and the
shell-stop case. Earlier failed local runs were retained for diagnosis,
not counted as green evidence; no unrelated timeouts were increased.
Fresh CI is required on every pushed layer.

### Measurement

Measurement baseline: `dev` **4dfb2f85** (#400–407), as profiled before
the later #421–425 merges. The tables compare that implementation with
the **completed stack**, not each layer in isolation. Both variants use
the identical top-branch fixture and counter definitions. Three
sequential unprofiled runs per variant and fixture; no concurrent
multi-gateway files. The current stack is rebased onto **04a871be**;
performance was not remeasured for this restack or the newly inherited
dev changes.

The workload streams 1500 text deltas at 20 ms intervals, tool results
and background progress, with six remote views, a pinned phone client,
both overviews and the production BFF transport/SSE/coalescer. It then
restarts the home gateway on its existing database, changes data offline
and catches up the mirror. This is a protocol fixture with scripted
workers, without a browser, native phone runtime or full SvelteKit
request stack.

#### CPU by process

Run `CANOPY_SYNC_METRICS=1 CANOPY_SYNC_PROCESSES=1 bun run check:tmp
tests/integration/sync-process-performance.test.ts`. Each gateway and
the BFF execute in a separate Bun process. Gateway CPU includes its
scripted worker. The controller, watch readers, phone client and
PostgreSQL are excluded. Active CPU covers approximately 30 s; idle CPU
covers a separate 10.2 s window after the turn.

| Process | Active CPU median s before → after | Active CPU mean s
before → after | Idle CPU median s before → after |
|---|---:|---:|---:|
| Home gateway | 4.977 → 4.741 | 4.847 → 5.177 | 0.226 → 0.215 |
| Viewer gateway | 2.569 → 1.786 | 2.480 → 1.934 | 0.121 → 0.090 |
| BFF | 0.659 → 0.586 | 0.665 → 0.596 | 0.031 → 0.027 |
| Sum per run | **8.247 → 7.114 (−13.7%)** | **7.993 → 7.707 (−3.6%)** |
0.373 → 0.333 |

All active CPU totals: baseline **8.247 / 8.371 / 7.362 s**; stack
**7.114 / 9.381 / 6.625 s**. The high stack run includes 6.431 s on the
home gateway. Home median falls 4.7%, while its mean rises 6.8%; this
small shared-machine sample does not establish a home CPU improvement or
statistical significance. Total CPU meets the dev baseline by both
median and mean. Event-loop p99 medians in ms are home 0.889 → 1.976,
viewer 0.869 → 1.632, BFF 0.578 → 1.485; maximum observed home delay is
13.10 → 39.75 ms. No event-loop latency improvement is claimed.

The original combined-process fixture independently gives CPU median
**6.461 → 5.926 s (−8.3%)**, mean **6.509 → 6.224 s (−4.4%)**; all
samples are 6.461/6.314/6.752 → 5.262/7.484/5.926 s. It includes the
controller and clients, so its totals must not be compared directly with
the three-process sum.

#### Profiles and CPU changes

`CANOPY_SYNC_PROFILE_DIR` runs all three children with `bun --cpu-prof
--cpu-prof-md`. Profiles were collected on dev, the rebased stack before
CPU changes and the final stack. Interval CPU in those single profiled
runs:

| Process | dev s | Stack before CPU changes s | Final stack s |
|---|---:|---:|---:|
| Home | 5.030 | 5.854 | 5.389 |
| Viewer | 2.636 | 2.289 | 2.187 |
| BFF | 0.835 | 0.729 | 0.701 |
| Total | 8.501 | 8.873 | 8.277 |

On the home gateway, all sampled native `writeBuffered` stacks lead
through `@effect/sql-pg`; Effect/SQL execution and protobuf
creation/serialization are also hot. Direct revision-coordinator samples
are small. Home native-writer sample counts change 666 → 999 → 700;
coalescer samples 0 → 27 → 11. These profiles include startup/teardown
and locate work, rather than allocate exact activity CPU seconds.
Markdown self-time includes waiting gaps and is not used as CPU
evidence. The high unprofiled outlier cannot be attributed to one
function from a different profiled run.

The final layer removes avoidable work introduced by buffer
accounting/coalescing: immutable text events reuse encoded bytes across
Hub accounting, publisher accounting and linked sends; identical
coalesced ranges share an owned batch; one timer serves an entire batch.
Mutable snapshots/configuration messages are never cached. When the
durable owner head is unchanged, the revision query skips fork-chain
recursion and turn/bus dependency reads. A cheap durable clock plus
authorized-thread read remains necessary for missed-fan-out and epoch
recovery. No ingest batching, database maintenance or schema changes are
included.

#### Traffic and consistency

Run `CANOPY_SYNC_METRICS=1 CANOPY_SYNC_BENCH=1 bun run check:tmp
tests/integration/sync-performance.test.ts`. Values below are medians of
the original combined-process fixture. Count only the encode direction
for traffic; linked codec CPU excludes framing/TLS and PostgreSQL. Cache
lookup CPU is measured at the linked encode hook; initial
queue-accounting serialization occurs outside that hook and is included
in process CPU.

| Scenario | Messages before → after | Bytes before → after | Encode /
decode CPU ms before → after | Consistency ms before → after |
|---|---:|---:|---:|---:|
| Linked thread watches | 4802 → 2139 | 875617 → 462443 | 49.703 /
60.282 → 24.867 / 31.764 | 36.03 → 39.58 |
| BFF SSE | 270 → 255 | 161904 → 152542 | 8.891 / n/a → 11.426 / n/a |
Not separately measured |
| Pinned phone | 1583 → 696 | 364396 → 186690 | Native codec CPU
unmeasured | Included in watch convergence |
| Active mirror | 545 → 489 | 630964 → 636102 | 13.073 / 12.033 → 12.408
/ 11.137 | Not separately measured |
| Mirror restart/offline change | 43 → 9 | 17290 → 15755 | 0.441 / 0.423
→ 0.222 / 0.298 | 5056.27 → 5063.60 |

Linked watches: **158.4 → 70.5 messages/s**, **28.9 → 14.9 kB/s**,
−55.5% messages and −47.2% bytes. Phone: −56.0% messages, −48.8% bytes.
Watch medians retain 48 heartbeats, 18 checkpoint deltas and zero full
snapshots during activity; those heartbeats share 12 owner/runtime probe
queries. Catch-up retains one full projection in both implementations,
packed into 43 → 9 fragments. Active mirror bytes and BFF encoding CPU
do not improve consistently.

The isolated-process fixture independently measures title convergence
**35.61 → 35.61 ms**, reconnect **3394 → 3449 ms**. Its BFF SSE median
bytes are 162661 → 168556; checkpoint/flush timing differs between
fixtures. There is no general BFF byte or reconnect latency claim.
Profiles, logs and measurement results are kept outside the repository.

### Compatibility and verification

Negotiated tests cover new/new, legacy subscriber/new home, new
subscriber/legacy home, and a paused subscriber overflowing while a
healthy subscriber receives complete text on the same link. Resume
supplies a durable delta. Local/linked liveness covers unrelated-thread
activity, already-scanned pruning, retained-journal gaps, missed
fan-out, sequence/base gaps, stalls, older peers and stale mirrors.
Legacy capability sets simulate old peers; historic binaries are not
tested.

The frozen update proto and `WORKER_LINK_PROTOCOL` are unchanged. Proto
additions and generated code are committed. No mobile source or native
dependency changes; fingerprints were not changed or regenerated. No UI
tests.

All layers remain **ready for review**. Restacked onto dev `04a871be`
after #418, #426 and the client performance stack merged; final top head
`e00a8f74`. The only conflict was the generated UI protobuf descriptor:
`bun run gen` preserves both `last_user_turn_choices` and the negotiated
coalescing fields. Layers 1 and 2 are unchanged by range-diff; layer 3
differs only in the regenerated descriptor.

On this top head, `bun install`, `bun run gen:check`, `bun run
typecheck`, `bun run lint`, `bun run format:check` and the web build
pass. Focused integration runs: **69 pass, 0 fail** across seven files,
each run separately through `bun run check:tmp` with a private
disk-backed TMPDIR and no test-owned leftovers: linked liveness 14,
local liveness 1, sync negotiation/backpressure 4, composer shell 18,
composer choices 4, thread mirrors 20, bounded thread reads 8. These
include both previously failing liveness cases, new/legacy negotiation,
stalled-subscriber isolation, durable resume and #418's composer
choices. No full local suite was started for this restack, as requested;
fresh CI on every layer is the merge gate. Earlier green checks and
historical performance results are not evidence for these rebased heads.

Copy audit: no product UI copy or controls changed; failures use
existing reconnect/error flows.

### Remaining measurements

Repeat the home CPU/outlier and event-loop measurements on target
hardware; measure large histories and slow/lossy networks before
compression or negotiated credits. Physical-device CPU, historic binary
pairs and full BFF HTTP serving remain unmeasured. Update-center polling
needs an invalidation feed before removal. Journal retention and
staging-generation leases belong to the separate database work; this
stack adds no durable retention watermark. All layers remain ready for
review at the maintainer's request; merge the stack atomically only
after every layer's checks pass.
nixuuu added a commit that referenced this pull request Nov 9, 2026
)

Negotiates 40 ms linked text coalescing with additive sequence ranges
and retains individual events for older peers. Bounds
subscriber/link/SSE queues so a stalled reader fails independently and
resumes through durable checkpoints. Mirror repeated fields pack into
approximately 32 KiB fragments; response producers yield to I/O during
large bootstraps.

Removes repeated text encoding and per-delta timer creation, skips heavy
revision work on an unchanged durable head, and adds a three-process
profiling fixture. Encoding reuse is limited to immutable text
events/batches; mutable configuration and snapshots stay uncached.
Polish docs describe cursors, revisions, profiling and backpressure.

### Measurement

Measurement baseline: `dev` **4dfb2f85** (#400–407), as profiled before
the later #421–425 merges. The tables compare that implementation with
the **completed stack**, not each layer in isolation. Both variants use
the identical top-branch fixture and counter definitions. Three
sequential unprofiled runs per variant and fixture; no concurrent
multi-gateway files. The current stack is rebased onto **04a871be**;
performance was not remeasured for this restack or the newly inherited
dev changes.

The workload streams 1500 text deltas at 20 ms intervals, tool results
and background progress, with six remote views, a pinned phone client,
both overviews and the production BFF transport/SSE/coalescer. It then
restarts the home gateway on its existing database, changes data offline
and catches up the mirror. This is a protocol fixture with scripted
workers, without a browser, native phone runtime or full SvelteKit
request stack.

#### CPU by process

Run `CANOPY_SYNC_METRICS=1 CANOPY_SYNC_PROCESSES=1 bun run check:tmp
tests/integration/sync-process-performance.test.ts`. Each gateway and
the BFF execute in a separate Bun process. Gateway CPU includes its
scripted worker. The controller, watch readers, phone client and
PostgreSQL are excluded. Active CPU covers approximately 30 s; idle CPU
covers a separate 10.2 s window after the turn.

| Process | Active CPU median s before → after | Active CPU mean s
before → after | Idle CPU median s before → after |
|---|---:|---:|---:|
| Home gateway | 4.977 → 4.741 | 4.847 → 5.177 | 0.226 → 0.215 |
| Viewer gateway | 2.569 → 1.786 | 2.480 → 1.934 | 0.121 → 0.090 |
| BFF | 0.659 → 0.586 | 0.665 → 0.596 | 0.031 → 0.027 |
| Sum per run | **8.247 → 7.114 (−13.7%)** | **7.993 → 7.707 (−3.6%)** |
0.373 → 0.333 |

All active CPU totals: baseline **8.247 / 8.371 / 7.362 s**; stack
**7.114 / 9.381 / 6.625 s**. The high stack run includes 6.431 s on the
home gateway. Home median falls 4.7%, while its mean rises 6.8%; this
small shared-machine sample does not establish a home CPU improvement or
statistical significance. Total CPU meets the dev baseline by both
median and mean. Event-loop p99 medians in ms are home 0.889 → 1.976,
viewer 0.869 → 1.632, BFF 0.578 → 1.485; maximum observed home delay is
13.10 → 39.75 ms. No event-loop latency improvement is claimed.

The original combined-process fixture independently gives CPU median
**6.461 → 5.926 s (−8.3%)**, mean **6.509 → 6.224 s (−4.4%)**; all
samples are 6.461/6.314/6.752 → 5.262/7.484/5.926 s. It includes the
controller and clients, so its totals must not be compared directly with
the three-process sum.

#### Profiles and CPU changes

`CANOPY_SYNC_PROFILE_DIR` runs all three children with `bun --cpu-prof
--cpu-prof-md`. Profiles were collected on dev, the rebased stack before
CPU changes and the final stack. Interval CPU in those single profiled
runs:

| Process | dev s | Stack before CPU changes s | Final stack s |
|---|---:|---:|---:|
| Home | 5.030 | 5.854 | 5.389 |
| Viewer | 2.636 | 2.289 | 2.187 |
| BFF | 0.835 | 0.729 | 0.701 |
| Total | 8.501 | 8.873 | 8.277 |

On the home gateway, all sampled native `writeBuffered` stacks lead
through `@effect/sql-pg`; Effect/SQL execution and protobuf
creation/serialization are also hot. Direct revision-coordinator samples
are small. Home native-writer sample counts change 666 → 999 → 700;
coalescer samples 0 → 27 → 11. These profiles include startup/teardown
and locate work, rather than allocate exact activity CPU seconds.
Markdown self-time includes waiting gaps and is not used as CPU
evidence. The high unprofiled outlier cannot be attributed to one
function from a different profiled run.

The final layer removes avoidable work introduced by buffer
accounting/coalescing: immutable text events reuse encoded bytes across
Hub accounting, publisher accounting and linked sends; identical
coalesced ranges share an owned batch; one timer serves an entire batch.
Mutable snapshots/configuration messages are never cached. When the
durable owner head is unchanged, the revision query skips fork-chain
recursion and turn/bus dependency reads. A cheap durable clock plus
authorized-thread read remains necessary for missed-fan-out and epoch
recovery. No ingest batching, database maintenance or schema changes are
included.

#### Traffic and consistency

Run `CANOPY_SYNC_METRICS=1 CANOPY_SYNC_BENCH=1 bun run check:tmp
tests/integration/sync-performance.test.ts`. Values below are medians of
the original combined-process fixture. Count only the encode direction
for traffic; linked codec CPU excludes framing/TLS and PostgreSQL. Cache
lookup CPU is measured at the linked encode hook; initial
queue-accounting serialization occurs outside that hook and is included
in process CPU.

| Scenario | Messages before → after | Bytes before → after | Encode /
decode CPU ms before → after | Consistency ms before → after |
|---|---:|---:|---:|---:|
| Linked thread watches | 4802 → 2139 | 875617 → 462443 | 49.703 /
60.282 → 24.867 / 31.764 | 36.03 → 39.58 |
| BFF SSE | 270 → 255 | 161904 → 152542 | 8.891 / n/a → 11.426 / n/a |
Not separately measured |
| Pinned phone | 1583 → 696 | 364396 → 186690 | Native codec CPU
unmeasured | Included in watch convergence |
| Active mirror | 545 → 489 | 630964 → 636102 | 13.073 / 12.033 → 12.408
/ 11.137 | Not separately measured |
| Mirror restart/offline change | 43 → 9 | 17290 → 15755 | 0.441 / 0.423
→ 0.222 / 0.298 | 5056.27 → 5063.60 |

Linked watches: **158.4 → 70.5 messages/s**, **28.9 → 14.9 kB/s**,
−55.5% messages and −47.2% bytes. Phone: −56.0% messages, −48.8% bytes.
Watch medians retain 48 heartbeats, 18 checkpoint deltas and zero full
snapshots during activity; those heartbeats share 12 owner/runtime probe
queries. Catch-up retains one full projection in both implementations,
packed into 43 → 9 fragments. Active mirror bytes and BFF encoding CPU
do not improve consistently.

The isolated-process fixture independently measures title convergence
**35.61 → 35.61 ms**, reconnect **3394 → 3449 ms**. Its BFF SSE median
bytes are 162661 → 168556; checkpoint/flush timing differs between
fixtures. There is no general BFF byte or reconnect latency claim.
Profiles, logs and measurement results are kept outside the repository.

### Compatibility and verification

Negotiated tests cover new/new, legacy subscriber/new home, new
subscriber/legacy home, and a paused subscriber overflowing while a
healthy subscriber receives complete text on the same link. Resume
supplies a durable delta. Local/linked liveness covers unrelated-thread
activity, already-scanned pruning, retained-journal gaps, missed
fan-out, sequence/base gaps, stalls, older peers and stale mirrors.
Legacy capability sets simulate old peers; historic binaries are not
tested.

The frozen update proto and `WORKER_LINK_PROTOCOL` are unchanged. Proto
additions and generated code are committed. No mobile source or native
dependency changes; fingerprints were not changed or regenerated. No UI
tests.

All layers remain **ready for review**. Restacked onto dev `04a871be`
after #418, #426 and the client performance stack merged; final top head
`e00a8f74`. The only conflict was the generated UI protobuf descriptor:
`bun run gen` preserves both `last_user_turn_choices` and the negotiated
coalescing fields. Layers 1 and 2 are unchanged by range-diff; layer 3
differs only in the regenerated descriptor.

On this top head, `bun install`, `bun run gen:check`, `bun run
typecheck`, `bun run lint`, `bun run format:check` and the web build
pass. Focused integration runs: **69 pass, 0 fail** across seven files,
each run separately through `bun run check:tmp` with a private
disk-backed TMPDIR and no test-owned leftovers: linked liveness 14,
local liveness 1, sync negotiation/backpressure 4, composer shell 18,
composer choices 4, thread mirrors 20, bounded thread reads 8. These
include both previously failing liveness cases, new/legacy negotiation,
stalled-subscriber isolation, durable resume and #418's composer
choices. No full local suite was started for this restack, as requested;
fresh CI on every layer is the merge gate. Earlier green checks and
historical performance results are not evidence for these rebased heads.

Copy audit: no product UI copy or controls changed; failures use
existing reconnect/error flows.

### Remaining measurements

Repeat the home CPU/outlier and event-loop measurements on target
hardware; measure large histories and slow/lossy networks before
compression or negotiated credits. Physical-device CPU, historic binary
pairs and full BFF HTTP serving remain unmeasured. Update-center polling
needs an invalidation feed before removal. Journal retention and
staging-generation leases belong to the separate database work; this
stack adds no durable retention watermark. All layers remain ready for
review at the maintainer's request; merge the stack atomically only
after every layer's checks pass.
nixuuu added a commit that referenced this pull request Nov 9, 2026
Bot composer text was held by the mounted component, so leaving Bots
could discard the message. Bot drafts now live in the owner's gateway
database and restore on web, desktop and mobile. Bot chats also accept
images and deliver them to the official worker harness.

- Persist text, structured mentions, quotes/comments and uploaded image
metadata with revision checks. Keep pending uploads through navigation,
preserve failed sends and their request IDs, and clear only the
acknowledged draft revision.
- Reuse attachment uploads, configured file/count/message limits,
thumbnails and viewers. Web/desktop support paste, drop and Attach
images; mobile uses the existing paste/photos/files intake. This scope
supports PNG, JPEG, GIF and WebP only; other file types can follow.
- Deliver verified, normalized images as native Claude SDK, Codex
app-server and Grok ACP image parts. Bots gain no filesystem tools.
Resumed sessions receive current images; rebuilt sessions also receive
bounded historical images, with a note for omissions. Preserve #429's
Canopy MCP approval override on Codex start/resume, Grok MCP allow rule,
actionable failures and shared approval labels; gateway authorization
remains authoritative.
- Add `bot_images_v1` and `remote_bot_composer_v1` capability gates.
Linked draft/upload/send operations remain owner-scoped. Moving a bot
preserves its draft, images and thumbnails; an older destination is
refused before cut-over.
- Add migration `0102_bot_composer` (latest dev migration was 0101 when
opening this PR), additive RPC/fields and generated contracts. Polish
docs cover persistence, native delivery, schema and mobile behavior.

Validation: `bun install --frozen-lockfile`, `bun run typecheck`, `bun
run lint`, `bun run format:check`, `bun run gen:check` and `bun run
--filter @canopy/web build` passed.

Focused tests rerun on dev ecb20e4 (#429): 52 passed across
bot-composer, bots-harness-context, bots-harness-approvals, worker
isolation/Grok transcript and DB schema (282 assertions). The official
Codex MCP approval regression also passed (4 assertions). The bot
computer-move case was previously verified during implementation (20
assertions). Coverage includes restart durability, structured draft CAS
and lost acknowledgements, send idempotency, owner scoping,
MIME/size/count limits, active-turn blob authorization, all three native
image adapters, resume/rebuild and historical image limits. The move
case also exercises draft/upload/send through a linked computer.

Manual browser check used an isolated gateway with the fake Codex
harness: Threads/Bots navigation, full reload, picker, clipboard/drop
events, dropping on an existing chip, uploaded draft restoration,
send/clear, message thumbnails and viewer. The harness recorded five
native image parts across two sends. Checked light/dark at desktop and
phone widths, including long filenames; no console errors. No UI tests
were added. Native device UI and live provider accounts were not
exercised.

Mobile changes are JS/TS only. Both `bunx [email protected]
fingerprint:generate --platform <ios|android> --build-profile production
--json --non-interactive` results match current dev (ecb20e4, including
#427/#428/#429):
- iOS: `6ddec9ef559ee0095ac33e94ff9418a942053b17`
- Android: `5f6eae3ab278f1cd543e9ed763f923a319b65ec9`

Full `check:tmp` was intentionally left to CI as requested for the
shared machine. An upload still in progress when the application closes
must be added again; completed uploads are durable.

Copy audit (§8): “Attachments are coming soon” → “Attach images” for the
implemented action; new “Drop images to attach” describes the supported
intake; “Load saved draft” names the recovery result. Conflict copy
tells the user to copy edits before loading the saved version;
upload/send errors explain recovery. Labels use English sentence case
and action verbs, existing attachment terms and limits are reused, and
controls have text/accessibility labels independent of icons or colour.
No new empty states or decorative sentences. Short, typical and long
filenames were checked at desktop and phone widths.

Related: #398, #421
nixuuu added a commit that referenced this pull request Nov 10, 2026
Bot conversations now accept the same files as threads. A bot can read
text and PDFs without filesystem tools, then pass selected conversation
attachment references to `start_thread` or `send_message`. The gateway
copies references to the existing blobs and uses the normal thread
delivery pipeline.

Forwarding validates the owner, current bot conversation, duplicates and
current limits before approval and again during execution. It shares the
action's existing approval; the card lists filenames, types and sizes.
File copies, thread input, bot attribution, durable confirmation and
tool result commit together. The read-only `list_attachments` tool
exposes only sent files in that conversation.

| File type | Claude | Codex | Grok |
|---|---|---|---|
| Images | Native image parts | Native image parts | Native image parts;
CLI image capability required |
| UTF-8 text, Markdown, code, JSON, CSV | Bounded turn text | Bounded
turn text | Bounded turn text |
| PDF | Native document blocks | Extracted text | Extracted text |
| Archives and other binary files | Metadata and forwardable references
| Metadata and forwardable references | Metadata and forwardable
references |

Text is capped at 64,000 characters per file and 128,000 per turn, with
truncation notes. PDF extraction reads at most 50 pages, without OCR;
unreadable or image-only PDFs retain their original forwardable
references. Nonimage bot input requires worker capability
`bot_files_v1`; images retain `bot_images_v1`. No wire fields or
migrations were added.

Web/desktop retain the common picker, paste, drop, chips and previews.
Mobile changes are TypeScript only, including ordinary attachment
previews under bot-attributed thread input. The bot conversation records
“Sent report.md to ‘Thread’”. Forwarding to another linked computer is
explicitly refused before approval; users can choose a thread on the
bot's computer.

Validation:

1. `bun install`, `bun run gen:check`, `bun run typecheck`, `bun run
lint`, `bun run format:check` and the web build pass.
2. Focused tests pass: `bot-files.test.ts` (9), `bot-composer.test.ts`
(7), `bots-remote.test.ts` (7), and the four affected harness
adapter/stop files (10). Coverage includes real gateway/worker transport
with fake provider CLIs, native versus extracted input, shared blobs and
worker paths, ownership/conversation refusal, approval denial and
execution-time revalidation, old-worker refusal and linked-target
refusal. Multi-gateway files ran separately.
3. Real-browser check on isolated fixture services: attach MD/PDF/PNG,
inspect Markdown/image previews and PDF file controls, fake-harness
forwarding, durable bot confirmation, normal thread attachment preview
and bot attribution. Checked light/dark at desktop and phone widths,
including a long filename. No UI test suite was added.
4. Requested EAS CLI 27.4.1 production fingerprints equal current `dev`:
iOS `6ddec9ef559ee0095ac33e94ff9418a942053b17`; Android
`5f6eae3ab278f1cd543e9ed763f923a319b65ec9`.

Copy audit (§8): “Attach images” → “Attach files” and “Drop images to
attach” → “Drop files to attach”, matching the accepted input. New
forwarding confirmation names the file and destination; refusal and
limit errors state the problem and next action. Existing file
vocabulary, verb-led controls and accessible labels are reused; no new
empty state or decorative copy. Short, typical and long filenames were
checked on desktop and phone. Long file chips and previews truncate or
wrap within the viewport.

Remaining gate: CI runs the full suite, including `check:tmp`; it was
intentionally not run locally. Live provider inference and native mobile
device interaction were not exercised.

Related: #449, #398, #421, #429
nixuuu added a commit that referenced this pull request Nov 24, 2026
Images embedded in a completed thread response could briefly return to
“Loading image…” when Canopy received a linked computer update. During
the reload, the thumbnail's open button was replaced. Deriving
availability separately keeps the image and its open button mounted when
the connection status is unchanged. Changes in connection status,
gateway resyncs and manual Retry still start a new attempt.

Thanks @M-Zajace for reporting this.

Fixes: #421

## Verification

- Tested head `41c0dac49224b040a60bec8a85d976720aeebdab` locally on
Linux.
- Chromium with the shared web/Desktop renderer and synthetic images at
1280 px and 390 px. Reproduced the issue before the fix. On the fixed
head, updates to the completed transcript and linked computer metadata
preserve the loaded image and its open button. One click opens the full
image, and updates preserve the open preview. Also checked recovery
after a presence change, gateway resync and manual Retry.
- Linked attachment integration test passed against two local gateways.
It covered qualified attachment reads through the BFF, older homes,
owner scoping and availability. Web typecheck, targeted lint, formatting
and diff review passed.
- The browser exercise used a synthetic linked computer event. The
reporter's Desktop setup was not tested. UI copy is unchanged. GitHub CI
runs the required repository checks.

Co-authored-by: Damian Plewa <[email protected]>
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