fix(web/claw): fetch an image again for a card the mirror rebuilt
android / debug (push) Successful in 2m31s
ci / docker (push) Successful in 2m3s
ci / web (push) Successful in 15s
ci / publish-edge-images (deploy/docker/claw.Dockerfile, rhema-claw) (push) Successful in 2m3s
android / release (push) Successful in 2m13s
ci / checks (push) Successful in 1m7s
ci / test (push) Successful in 39s
ci / chart (push) Successful in 5s
ci / publish-edge-images (deploy/docker/ui.Dockerfile, rhema-claw-ui) (push) Successful in 13s
ci / publish-edge-chart (push) Successful in 3s
android / debug (push) Successful in 2m31s
ci / docker (push) Successful in 2m3s
ci / web (push) Successful in 15s
ci / publish-edge-images (deploy/docker/claw.Dockerfile, rhema-claw) (push) Successful in 2m3s
android / release (push) Successful in 2m13s
ci / checks (push) Successful in 1m7s
ci / test (push) Successful in 39s
ci / chart (push) Successful in 5s
ci / publish-edge-images (deploy/docker/ui.Dockerfile, rhema-claw-ui) (push) Successful in 13s
ci / publish-edge-chart (push) Successful in 3s
A page read, a mirror reset, or a turn folding into the record builds new card objects, and the pass that fetches image bytes remembered attachment ids, so a rebuilt card whose bytes had not landed was never asked for again. The guard now rides the card object: a new card gets its fetch, and the useClaw cache answers a repeat with the blob it already holds, so nothing is requested twice. The object URL also lands on every card naming the id, not only the first. A page's open tail is dropped and re-read with the turn's beginning above it, which can leave two cards for one attachment, and the second stayed blank.
This commit is contained in:
1 parent
ea6edfe67a
commit
70b53665d5
3 files changed
+23
-16
No files matched your search
+14
-11
@@ -121,9 +121,12 @@ const {
|
||||
// for weeks costs nothing up front and still reaches its first message.
|
||||
const olderAvailable = ref(true)
|
||||
|
||||
// Attachment ids this page already tried to fetch; a failed fetch is
|
||||
// not retried until the stream resets and clears the set.
|
||||
const attemptedAttachments = new Set<string>()
|
||||
// The cards this page already tried to fetch. Keyed by the card object
|
||||
// rather than the attachment id: a page read, a mirror reset, or a live
|
||||
// turn folding into a record builds new cards, and a new card deserves
|
||||
// its fetch — the useClaw cache answers a repeat with the blob it
|
||||
// already holds, so a retry costs no request.
|
||||
let attemptedAttachments = new WeakSet<object>()
|
||||
|
||||
// Image cards need their bytes before they can render: fetched as the
|
||||
// card appears, not on any timer. code/file fetch on download instead.
|
||||
@@ -139,8 +142,8 @@ const attemptedAttachments = new Set<string>()
|
||||
function requestAttachmentImages(): void {
|
||||
const fetchAttachment = (attachment: AttachmentCard) => {
|
||||
const { id, media, url } = attachment
|
||||
if (media !== 'image' || url !== null || attemptedAttachments.has(id)) return
|
||||
attemptedAttachments.add(id)
|
||||
if (media !== 'image' || url !== null || attemptedAttachments.has(attachment)) return
|
||||
attemptedAttachments.add(attachment)
|
||||
claw
|
||||
.attachmentUrl(id)
|
||||
.then((fetched) => transcript.setAttachmentUrl(id, fetched))
|
||||
@@ -156,8 +159,8 @@ function requestAttachmentImages(): void {
|
||||
} else if (item.kind === 'sent') {
|
||||
for (const image of item.images) {
|
||||
const { id, url } = image
|
||||
if (id === null || url !== null || attemptedAttachments.has(id)) continue
|
||||
attemptedAttachments.add(id)
|
||||
if (id === null || url !== null || attemptedAttachments.has(image)) continue
|
||||
attemptedAttachments.add(image)
|
||||
claw
|
||||
.attachmentUrl(id)
|
||||
.then((fetched) => transcript.setSentImageUrl(id, fetched))
|
||||
@@ -709,7 +712,7 @@ function resubscribe(): void {
|
||||
stream = null
|
||||
transcript.reset()
|
||||
olderAvailable.value = true
|
||||
attemptedAttachments.clear()
|
||||
attemptedAttachments = new WeakSet<object>()
|
||||
notices.value = []
|
||||
streamStatus.value = 'connecting'
|
||||
threadRevision = null
|
||||
@@ -732,7 +735,7 @@ function resubscribe(): void {
|
||||
onReset: () => {
|
||||
transcript.reset()
|
||||
olderAvailable.value = true
|
||||
attemptedAttachments.clear()
|
||||
attemptedAttachments = new WeakSet<object>()
|
||||
requestAttachmentImages()
|
||||
},
|
||||
onStatus: (status) => {
|
||||
@@ -742,7 +745,7 @@ function resubscribe(): void {
|
||||
// is. Only the attachment set is cleared — a fetch that failed
|
||||
// during the outage should retry against the recovered stream.
|
||||
if (status === 'reconnecting') {
|
||||
attemptedAttachments.clear()
|
||||
attemptedAttachments = new WeakSet<object>()
|
||||
requestAttachmentImages()
|
||||
}
|
||||
if (status === 'open') void refreshSessions()
|
||||
@@ -764,7 +767,7 @@ async function loadThread(): Promise<void> {
|
||||
// the new one under it would duplicate every turn.
|
||||
transcript.reset()
|
||||
olderAvailable.value = true
|
||||
attemptedAttachments.clear()
|
||||
attemptedAttachments = new WeakSet<object>()
|
||||
try {
|
||||
const page = await claw.history(key)
|
||||
if (key !== activeKey.value) return
|
||||
|
||||
Reference in new issue
Block a user