Repository navigation
fix(tickets): the drawer reads a file's link again when a read brought none CU-86agmkyyu - #3350
Conversation
…t none CU-86agmkyyu The hub signs a ticket's HubSpot files on each read of the timeline, under a 2 s budget, and keeps no link it failed to sign. A read that misses the budget returns the file without a link, and the drawer then draws a chip it can neither show nor download. Nothing read the timeline again while the drawer stayed open, so the chip kept no link until the card was reopened, the tab was shown again or the ticket stream reconnected. A read that brings a file without a link is now followed by up to three more, 2, 4 and 8 seconds apart. The count lives on the query, so every drawer on the ticket shares it and a read that a newer one replaced does not move it. Failed reads count toward the three. A file not seen before without a link starts the three over; one that keeps coming without a link does not.
🦩 flamingo Code Review✅ Tests and checks passed on this commit (8 lanes). 2 findings: 🔴 0 action required · 🟠 0 recommended · 🔵 2 informational Advisory: findings do not block the merge. Rules cited:
🔵 Informational (2)
✅ What this change does well
Inline comments: 2 new 2 possible problems checked and ruled out
🧪 Tests and mutationTests per lane
Checks
Docker is installed but not running (start Docker Desktop or The vitest lane ran the 30 tests of use-ticket-engagements.test.tsx: all pass. Lint:types held 4 errors, all in openframe-message-attachments.test.tsx, which this change does not touch. No Stryker in openframe-frontend-core, so mutation is a gap; the PR reports 30 hand mutants, 27 killed, the 3 survivors equivalent. 1 gap (not tested here):
🤖 Prompt for AI agents: fix every findingNext: commit a suggestion, or hand a comment's prompt to your coding agent. React 👍 on a finding that helped and 👎 on one that is wrong: the reviewer learns from both. Review again. New commits are not reviewed until you ask:
Or comment Updated 2026-12-04 17:03 UTC · reviewed from Oleksandr Koltunov's machine |
🦩 flamingo Code Review / security✅ No findings on the current head. Advisory: findings do not block the merge.
1 possible problem checked and ruled out
Review again. New commits are not reviewed until you ask:
Or comment Updated 2026-12-04 17:08 UTC · reviewed from Oleksandr Koltunov's machine |
… CU-86agmkyyu The re-read budget remembered every file it had seen without a link for as long as any file on the ticket stayed without one. So beside a file that never gets a link, a file that got its link and lost it on a later read (a stream event, a reopened tab) was read again no more. A file now starts the re-reads over when it loses its link again after a run is over. During a run it does not, so a file that keeps losing and getting its link cannot extend one. The tests call act() without awaiting a synchronous callback, which the type-aware lint pass (lint:types) requires.
yevhenii-flamingo
left a comment
There was a problem hiding this comment.
Two small follow-ups on the re-read logic.
…client's retries CU-86agmkyyu A failed re-read was retried by the host's QueryClient (three times in the browser by default) before it counted, so three re-reads could send twelve requests. A read during a run is no longer retried; the first load and any read after a run keep the client's own retry, its per-key defaults included. The tests run on a default QueryClient now, and the contract moves into one JSDoc on relinkInterval.
…agmkyyu ef3e1ba turned the retries off for every read during a run, so a read the re-reads did not send (a stream invalidation, a refetch on focus, mount or reconnect) lost the client's retries too. refetchInterval's reads carry nothing that sets them apart from the others. The re-reads now run on a timer of their own, scheduled from the query cache on each result, and carry a fetch meta that the retry option checks: a re-read is not retried, and every read that sends its own request keeps the client's retry. A re-read is not sent while the tab is hidden, the device is offline or another read is on its way. The query hash comes from the client, so a host's queryKeyHashFn is honoured.
…-86agmkyyu The JSDoc says drawers open on the ticket together share the count, and each drawer subscribes to the query cache, so every result schedules the re-reads once per drawer. Two tests now pin it: two drawers send one run of three re-reads, and closing one keeps the other's run going.
…ook CU-86agmkyyu LOGIC-001: the budget's transition (a file new or relapsed after a run starts the count over, the wait follows the result count) is now nextRelink in relink-budget.ts, from the previous budget, the files without a link and the result count to the next budget and wait. It builds a new budget instead of editing the one it was given. scheduleRelink keeps the WeakMap keyed by the query, the timer and its guard. relink-budget.test.ts covers the transition without rendering: the delays, the drop once every file is linked, a restart during and after a run and the run it starts, a relapse during the run and on its last read, the same result passed twice, and the budget left as it was.
The library side of the Help Center upload fix in flamingo-stack/multi-platform-hub#2088, under Attachment Support (Images + Any File Type). With #2088 the hub keeps a ticket's HubSpot files as references and signs them on each read of the timeline, within a 2 s budget, keeping no link it failed to sign. In the live check of #2088, the drawer's first read, about 20 s after the ticket was created, brought the file without a link: a chip with no thumbnail and no Download button. Nothing read the timeline again while the drawer stayed open, so the chip stayed that way until the card was reopened, the tab was shown again or the ticket stream reconnected.
The drawer reads again while a file has no link
useTicketEngagements: a read that brings a file without a link is followed by up to three more, 2, 4 and 8 seconds apart. A read in which every file has its link stops them. The hook schedules them itself, from the query cache on each result of the query:refetchInterval's reads carry nothing that sets them apart from the others, and the retry cap below needs that.WeakMapkeyed by the TanStackQuery, counted from itsdataUpdateCount + errorUpdateCount. So drawers open on the ticket together share it, a drawer reopened while a read is on its way keeps it, and a read that a newer one replaced (a stream invalidation cancels the read in flight) does not move it. The query hasgcTime: 0, so a drawer opened after the last one closed starts over.retrychecks: it is not retried, so a run sends at most three requests. Every read that sends its own request (the first load, a ticket-stream invalidation, a focus, mount or reconnect refetch, a read after a run) keeps the host's retry, read fromqueryClient.defaultQueryOptions({ queryKey }): global and per-key defaults, query-core's three in the browser when nothing is set (the hub sets three).nextRelink(budget, unlinked, results)inrelink-budget.ts, beside the hook;scheduleRelinkkeeps only theWeakMapkeyed by the query, the timer and its guard.Not in this PR
Checks
use-ticket-engagements.test.tsx, 32 tests on a defaultQueryClient:queryKeyHashFn;retry: 1, a retry function,retry: falseand per-key defaults say;relink-budget.test.ts, 9 table tests onnextRelinkthat render nothing: the 2/4/8 s waits and the stop, the budget dropped once every file is linked, a new file during and after a run, a relapse during a run (its last read included) and after it, the wait picked from the result count, the same result twice (two drawers), the given budget left unchanged.relink-budget.ts(no mutation tool in this package): 33 killed. The 3 survivors are equivalent: one stops marking unlinked files a second time, which the loop before it already marks; one drops the idle check, and query-core then joins the read in flight without a request of its own; one schedules on every update of the query, and an update without a result comes during a read whose result schedules again.npm run type-check,npm run lint:types, the fast ESLint pass and Prettier, on the changed files: clean. vitestsrc/components/tickets: 4 files, 54 tests pass.Change-Set: fix-help-center-upload-links
Change set
flamingo-stack/openframe-oss-lib#3350: these pull requests are one change, reviewed together.Linked work
Linked by the
Depends-On/Change-Setlines in these descriptions; this block is maintained by the hub.