Skip to content

fix(bots): show a paired server bot's uploaded picture once the server comes back - #46204

Merged
AmethystLiang merged 9 commits into
mainfrom
fix/bot-avatar-remote-retry
Nov 27, 2026
Merged

AmethystLiang merged 9 commits into
mainfrom
fix/bot-avatar-remote-retry

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

A bot that lives on a paired server can have its own uploaded picture. If this computer asked for that picture before the server was connected (for example right after launch), the bot kept showing just its first letter until you reopened the view. The same happened to the small faces in a group's Items list. Now the picture is asked for again as soon as the server is back, and a failed attempt never hides a picture that was already showing.

Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​672 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​672
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​263 $\color{#cf222e}{\Huge{\mathbf{−}}}$​54 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​209

What Changed

  • useBotAvatarLook no longer reads an uploaded picture while the bot's server is away; a picture already loaded still shows.
  • When the server comes back, the picture is read again (new useBotHostGeneration, bumped by the existing came-back signal).
  • The come-back is counted before the bot listing shows the server as live, so every view that reads as the server returns shares one read instead of starting a second one.
  • An upload's version is a hash of its bytes, so a picture that loaded once is kept and never read again, even if a later read for the same version fails. A failed read is dropped. An empty answer (null or an empty file) is read again on the next come-back.
  • A failed read leaves whatever is showing alone, so it can't replace a picture with the letter.
  • Every avatar on screen takes a picture as soon as any read loads it into the shared cache, and its own empty or failed answer never hides it, so a header and a group row always agree.
  • Group Items row faces with no picture read again when their server comes back (as a listing change, or only through its event stream), take a picture as soon as any other view loads it, and ignore late replies from reads that were superseded.

The bot's saved picture was never lost: the server still has it. Only the view on this computer stopped trying.

Why

At launch a paired server's bots show from the last saved list while the server is still connecting. The picture read for each row failed, the row stored "no picture", and nothing re-ran the read while the row stayed mounted. Views opened later (like the bot's Home tab) read it fine, which is why the picture showed in one place and not the other.

A timed retry was rejected because it keeps calling a server that is away. Saving the pictures with the offline list was rejected for now because it adds stored image data to every paired list. Checked against how comparable products handle this.

Linked Issue

N/A (maintainer, reported directly)

Visual Proof

N/A: no new visuals. The fix is about when an existing picture loads after a server reconnects, which a still image can't show. The hook test below drives the away and back sequence and fails on the old code.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns

bot-avatar-image.test.ts drives the hook through the real server listing: away then back shows the picture; a failed read is retried on come-back; a loaded picture is kept and not re-read; null and empty-string answers are re-read on come-back; a row mounted while away shows an already loaded picture. bot-group-face-pictures.test.ts drives the real Items panel store next to a header avatar: null and failed faces recover on come-back without Back or reopen; recovery through the event stream alone; a face takes the header's picture; a late reply from before the come-back can't replace the current picture; a row waiting offline and a header share one read; a picture read before a come-back is kept when the read after it fails. Also: a mounted header and row both show the picture whichever of the reads before and after the come-back answers first, with an empty or failed answer from the other; a header whose read failed takes the picture a newly drawn row reads; a row read started as the server comes back is not retired and read again later while the window wrongly says hidden. The recovery tests fail on the old code; the keep-a-loaded-picture ones guard against the retry re-reading or dropping a picture. CI runs both files (local runs could not start on this overloaded machine).

Performance

None worth measuring: each bot picture adds two cheap store subscriptions that only re-render when the server's state changes, and an open group Items panel adds two listeners that fire only when a server comes back or a picture loads. Reads drop while a server is away; on come-back there is at most one read per bot with an uploaded picture that has not loaded yet, and none for pictures that already loaded.

Risk

Level: Low

Renderer only; no saved data, settings or server changes. Worst case, a picture that fails to load while the server is connected stays on the letter until the server reconnects or the view reopens, which is the old behavior. Plain revert backs it out.

AI Disclosure

Review

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review
Walkthrough

The avatar cache now tracks host generations and retains successful reads. The avatar hook uses cached pictures while a host is away and retries eligible reads after a generation change. Grouped face pictures respond to cached uploads and host-return events. Tests cover retries, shared reads, and preservation of successful pictures.

Merge Risk: Low · previous review e058c

This PR makes bot avatars recover after a paired server reconnects. In a rare ordering, a header avatar can stay on its initial letter while another view of the same bot shows the uploaded picture. The effect is cosmetic and limited to that case. It is low risk and mergeable, ideally with the small fix applied.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a paired server bot's uploaded picture now appears once the server comes back. It uses the fix(bots) convention and matches the raw summary, which covers retrying avat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description follows the repository template and covers the required sections. The ELI5 explains the bug and fix in plain language. What Changed lists the mechanism: the away-state read skip, the g…
Full details: Title check

Explanation

The title names the main change: a paired server bot's uploaded picture now appears once the server comes back. It uses the fix(bots) convention and matches the raw summary, which covers retrying avatar reads after reconnect and keeping loaded pictures.

Full details: Description check

Explanation

The description follows the repository template and covers the required sections. The ELI5 explains the bug and fix in plain language. What Changed lists the mechanism: the away-state read skip, the generation counter, the came-back ordering, hash-keyed caching, and the group Items row recovery. Why explains the rejected alternatives (timed retry, persisting pictures with the offline list). Testing names both test files and the scenarios they cover. Performance and Risk are filled in with a risk level and a revert path. The Linked Issue section says N/A (maintainer, reported directly). The template says outside contributors must link an issue, and the author is a maintainer, so this is acceptable. The author's manual testing box is unchecked, and the text says local runs could not start, so manual verification is not confirmed. The Visual Proof N/A includes a reason. The AI Disclosure section is empty, and the Agent skill upstream boundary checkbox is not ticked. The Checklist is not reflected in the body. The PR-level description is substantive and mostly complete, so the check passes.

Finishing Touches

Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5c7a96d4-0859-4237-8383-ff1ad8ace1a8
Commits

Reviewing files that changed from the base of the PR and between 99e5a86 and 160c736.

Files selected for processing: 3

  • src/renderer/src/components/bots/bot-avatar-image.test.ts
  • src/renderer/src/components/bots/bot-avatar-image.ts
  • src/renderer/src/lib/bot-host-link-read.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@AmethystLiang
AmethystLiang force-pushed the fix/bot-avatar-remote-retry branch from 22f55c9 to 762c77a Compare November 25, 2026 00:13
…r comes back

A picture read while the bot's paired server was away failed and the row kept its initial
until it remounted. The avatar hook now skips reads while the server is away, shows a picture
already loaded from the shared cache, and reads again when the server comes back. A failed read
never replaces a shown picture; an empty answer is read again after a come-back. The shared
cache API used by group faces follows the same rules.
@AmethystLiang
AmethystLiang force-pushed the fix/bot-avatar-remote-retry branch from 762c77a to 2273b5e Compare November 25, 2026 00:20
…er come-back

- Count a host's come-back before its listing publishes it live, so a read a view sends while the
  listing publishes is one of this return, not a stale one replaced by a second read.
- A picture read for a version stays cached even when a later same-version read took its place.
- An empty-string answer stays retryable on come-back, like null.
- Group Items row faces with no image re-read when their host comes back (listing or event stream),
  take a picture any other view loads, and drop replies from superseded reads.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6725a284-356a-4965-9538-10c9829303c2
Commits

Reviewing files that changed from the base of the PR and between 2273b5e and e058c9a.

Files selected for processing: 8

  • src/renderer/src/components/bots/bot-avatar-image.test.ts
  • src/renderer/src/components/bots/bot-avatar-image.ts
  • src/renderer/src/components/bots/items/bot-group-face-pictures.test.ts
  • src/renderer/src/components/bots/items/bot-group-face-pictures.ts
  • src/renderer/src/components/bots/items/bot-group-face-recovery.ts
  • src/renderer/src/lib/bot-catalog-snapshot.ts
  • src/renderer/src/lib/bot-host-link-read.ts
  • src/renderer/src/lib/bot-host-listing.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

… keeps reads of this return

- A mounted avatar hook hears each picture that lands in the shared cache for its bot and version,
  and its own empty or failed answer never hides one, so a header and a group row converge.
- A group row read started as the listing publishes a returning host is of that return: the
  come-back callback no longer retires it and starts a second read later.
…t version answers empty

The picture a mounted avatar shows is bound to its host, bot and version, and an empty answer for
the same version no longer replaces it, whatever the bot's shared cache slot holds by then.
@AmethystLiang
AmethystLiang merged commit 6b68f10 into main Nov 27, 2026
55 checks passed
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