Skip to content

perf(threads): limit history loading and reuse unchanged views - #1049

Merged
nixuuu merged 1 commit into
devfrom
fix/bound-lazy-content-cache
Nov 20, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/bound-lazy-content-cache

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 20, 2026

Copy link
Copy Markdown
Member

Change

  • Web and desktop show the loaded timeline immediately. Scrolling up to a gap reads one older page. “Show earlier work” loads the selected turn, including turns that span several pages. On mobile, a gesture toward the history edge loads at most one page.
  • Web, desktop and mobile keep the live stream open when an older page covers the changes already received. If the stream advanced past the page, the client replays from the page checkpoint to recover concurrent edits and deletions.
  • Desktop persists a bounded history tail. Web and desktop limit inactive expanded content to 32 items and 8 MiB and cancel obsolete reads on reset. An oversized result stays available while in use. Clients reuse the measured size of an unchanged snapshot when leaving a conversation.
  • Header-only updates preserve the timeline rows. Unchanged controls and heartbeats still run validation and connection diagnostics while avoiding redundant view updates.

Verification

  • Chromium on Linux, 2,160 items and 19 subagents. Opening the thread issued 0 older-page requests, down from 16 (453,590 response bytes). Checked scroll restoration, a multi-page turn, a quote, retry after a failed read and a timeline that fits on screen. Tested wide and narrow viewports in both themes.
  • Android emulator. A layout change after scrolling issued 0 history reads, down from 16. A gesture fetched one page on the existing stream. Twelve pairs of unchanged controls and heartbeats produced 0 React commits, down from 21. Sending a message and resuming from the background advanced and restored the live checkpoint.
  • With 4,608 synthetic items, 32 exits from an unchanged cached thread required 0 full encodings, down from 32. In a 10,000-item renderer probe, median header-update processing fell from 3.10 ms to 0.007 ms. Forty-eight expanded outputs of 512 KiB retained 7.5 MiB of inactive content, down from 24 MiB.
  • Targeted domain, history cache, gRPC replay, continuity, work-window and mobile synchronization checks passed, along with web, mobile and domain typechecks and repository lint on the edited files. The concurrent-deletion test compares a paged-and-resumed client with a continuously connected client.
  • Copy audit (§8) passed. The former idle “Loading earlier work…” label now reads “Show earlier work” and acts as a button. “Loading earlier work…” appears during a read and “Retry” after failure. The native equivalent uses the existing “Show earlier messages” button.
  • The Windows Electron and day-long Windows session remain unmeasured. Native testing used Android. Additional Expo ESLint reported pre-existing hook findings.

Fixes: #300
Fixes: #302
Fixes: #541
Fixes: #556
Fixes: #672
Fixes: #687

Page older work when the reader requests it. Keep a current live watch
open, and replay from the page checkpoint when a concurrent edit wins.

Bound expanded output and desktop history writes. Reuse measured cache
sizes and skip rebuilding the timeline for unchanged or header-only
updates.

Fixes: #300
Fixes: #302
Fixes: #541
Fixes: #556
Fixes: #672
Fixes: #687
@nixuuu
nixuuu enabled auto-merge (squash) November 20, 2026 05:47
@nixuuu
nixuuu merged commit 33303e3 into dev Nov 20, 2026
16 checks passed
@nixuuu
nixuuu deleted the fix/bound-lazy-content-cache branch November 20, 2026 05:54
nixuuu added a commit that referenced this pull request Nov 20, 2026
…1050)

## Change

This update preserves existing access when gateways and workers upgrade
and tightens how Canopy issues new credentials, approves connector
actions and serves private files.

- New desktop clients pair with an owner invitation. Previously paired
phones, desktops and workers keep their credentials and certificate
pins. Revoking a device closes its active streams.
- MCP approvals bind to the saved account, tool and arguments. Slack
deliveries and linked-computer reports check which conversation supplied
the data. An older approval with incomplete arguments requires a new
decision.
- Worker file changes and previews are scoped to the thread. Migrations
0180–0184 preserve each owner's existing valid image previews, including
historical images with only a saved path and hash. They also migrate
connector approvals and confirmed computer redirects.
- Compose isolates the worker network and runs database migrations
separately from the gateway's restricted PostgreSQL login. Web, Android
and SSH worker enrollment accept the one-use token through a prompt or
stdin.
- Release jobs check the source revision before using signing or
publication credentials. The updater checks the official manifest's
repository and tag. Independent manifest signatures still require a
publisher key.

## Rollout

Update the Compose file together with the gateway and worker images.
Existing remote workers using plain HTTP need HTTPS or an explicitly
trusted bootstrap origin. Desktop installations that only ever held a
worker credential need an owner invitation for UI access.

Configure the protected GitHub environments `release-automation`,
`release-signing` and `release-publication` before using the updated
release workflows. Move the existing deployment and signing credentials
as documented. At PR creation the repository listed only `github-pages`.
[Release
setup](https://github.com/itsoltech/canopy/blob/189be6983213442471579b2c2aceb0ded8a40fa0/docs/release.md)

## Verification

- At `189be698`, 238 targeted tests passed across 46 files on top of the
merged #1049. Six scoped typechecks and lint on the overlapping changes
passed.
- Upgraded the final Linux packages from schema 178 directly and from
179 after a PostgreSQL dump and restore. The original phone and desktop
sessions, pin and unused invitation remained usable. Revoked access
stayed revoked. Separate upgrade checks verified the worker credential,
saved OAuth login, connector grants and both peers of a paired gateway
link. With the worker offline, the phone retrieved the original GIF and
path-only PNG with identical bytes and MIME types.
- Compared production Chromium builds using 2,160 items and 19
subagents, with 48 measured openings per revision across two widths and
both themes. Median time to the visible last answer was 476.3 → 480.2 ms
at 1280 px and 415.8 → 415.4 ms at 390 px. Both revisions requested zero
older pages on open, one on scroll and eight for the selected multi-page
turn, keeping the same SSE connection. The 10,000-row header update
measured 4.49 → 4.53 µs. Inactive expanded content retained 7.5 MiB on
both revisions.
- Native Android kept the existing pairing after a cold start. A send
reached the worker once and the app resumed from its saved checkpoint
after returning from the background. Twelve pairs of unchanged controls
and heartbeats produced zero React commits on both revisions.
- Copy audit (§8) covered the enrollment instructions and image
fallback. The wizard now labels the separate token and tells the user
when to paste it. Inspected the web wizard with short, typical and
200-character names at desktop and phone widths in both themes and
exercised the same flow in the native Android app.

For the CI fixes on `0878d0e7`, 34 targeted tests passed across worker
Git reads, process limits, the thread file panel and subagent
permissions. A Git trace of 100 simultaneous status requests across 30
worktrees showed one filter lookup and one status process per worktree,
with up to four scans in flight. A subsequent cache hit spawned zero
processes. Forcing a refresh read the current filter configuration and
ran status again. An idle parent can still pass its default permissions
to a child or narrow them. An explicitly unknown turn ID is rejected.

Local coverage used Linux, Chromium and an Android emulator. Signed
packages, native Windows/macOS and iOS remain outside these results.
GitHub CI runs the full repository checks.

Fixes: #68

Related: #1049
nixuuu added a commit that referenced this pull request Nov 28, 2026
## Change

A fast jump through a thread could leave several “Show earlier work”
buttons on screen until the next upward gesture. Web and desktop now
fetch a page when a gap or the start of the loaded history comes within
240 CSS pixels of the reading area. The feed waits for its initial
position, then rechecks the current window after each page. Failed reads
expose the existing retry action.

When older rows turn out shorter than their estimates, the feed restores
the reading anchor before it decides whether to follow the end. This
keeps the same message on screen across consecutive reads.

## Verification

- Exercised the real thread route in Chromium with 96 turns and 1,112
items. After Home, five sequential reads filled all six visible gaps
with the first prompt moving less than one pixel. Also checked a fast
wheel gesture at 390 px wide.
- Approached a gap from each direction. Requests started with the gap
still offscreen and stopped outside the margin. A short thread with a
visible gap loaded on opening. An HTTP 503 paused automatic reads until
Retry.
- Kept an answer within half a CSS pixel of its position through four
pages of a 540-command turn. Closing the last work fold still resumed
following at the end.
- Web typecheck, lint on changed files and 15 existing history and
scroll tests passed locally. Repository-wide checks and selected builds
run in CI.

Fixes: #1049
Fixes: #781
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