Skip to content

Refresh the Artifacts page on changes, not every 5 seconds - #441

Merged
abhishekgahlot2 merged 1 commit into
useagenthq:mainfrom
officialasishkumar:fix/artifacts-refresh-on-changes
Nov 11, 2026
Merged

abhishekgahlot2 merged 1 commit into
useagenthq:mainfrom
officialasishkumar:fix/artifacts-refresh-on-changes

Conversation

@officialasishkumar

@officialasishkumar officialasishkumar commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

By opening this pull request you agree to the Contributor License Agreement. On your first pull request a bot asks you to sign it with a one-line comment.

Fixes #289

The Artifacts page fetched the whole file list every 5 seconds (setInterval with REFRESH_MS = 5_000) for as long as it stayed open, background tabs included. That is 12 GET /api/artifacts a minute, even though artifact change events from the org stream already reload the list. Each poll also went through the same path as the Refresh button, so the icon spun and the button was disabled every 5 seconds with nobody touching it.

What changed

All code changes are in frontend/app/(library)/agent/artifacts/live-artifacts.tsx:

  • No timer. The interval is gone. The list reads again when:
    • an artifact change arrives on the org stream (as before)
    • the org stream opens, through useOrgChanges's open callback. The first open covers the gap between the server-rendered snapshot and the stream. Each reopen covers anything missed while the stream was down, including a backend that went away and came back.
    • the tab gets focus or becomes visible again, as use-automation-recovery.ts does for Automations
  • One read at a time. Changes that arrive while a read is in flight queue one follow-up read. A task that publishes five files in a row costs two requests, not five.
  • The icon spins only for a click. Refresh and the unavailable state's Try again pass { manual: true }. Every other read is quiet, the same rule Spin the Files refresh icon only on a manual refresh #397 set for the thread's Files panel. A click that lands during a quiet read still gets a fresh read after it, and the icon spins until that read is answered.

With no changes, focus or reconnects, the page now makes one request in its first minute (when the stream opens) and none after it.

Tests

New live-artifacts.interaction.test.tsx mounts LiveArtifacts under happy-dom. Requests go through the real backendFetch to a held fetch stub, and a stand-in EventSource lets the test open the stream and send change events in the backend's format:

  • mount sets no interval and makes no request before the stream opens (this fails if an interval comes back)
  • one read on open, one more after an error and reopen
  • a change event shows the new file. Four changes during one read give exactly two reads.
  • focus and visibilitychange each read once
  • a quiet read does not spin the icon. A click spins it and disables the button until the follow-up read is answered.

All five fail on main.

Checks with Bun 1.3.14:

  • cd frontend && bun run test: 1936 pass, 0 fail
  • cd frontend && bun run typecheck: passes
  • cd frontend && bunx biome lint on the two changed files: no findings

I did not run bun run build or open the page in a browser, so I have no screenshots or request counts from a real session. The before and after counts above come from the code and the tests.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

The Artifacts page downloaded the whole file list every 5 seconds for as
long as it stayed open, background tabs included, although artifact
change events from the org stream already reload it. Every one of those
polls also spun the refresh icon and disabled the button.

- The 5 second interval is gone. The list re-reads on an artifact change,
  each time the org stream opens (which covers the gap after the
  server-rendered snapshot and anything missed while the stream was
  down), and when the tab gets focus or becomes visible again, the way
  the Automations recovery hook covers changes made elsewhere.
- One read at a time: changes that arrive while a read is in flight
  queue a single follow-up read, so a burst of published files costs two
  requests instead of one per file.
- Only a click on Refresh (or Try again on the unavailable state) spins
  the icon. A click during a quiet read still gets a fresh read after it.

A new interaction test mounts the page under happy-dom with a held fetch
and a stand-in org stream. It checks that the page sets no interval and
reads nothing before the stream opens, then reads once on open and on
reopen, on a change, on focus and on visibility; that a burst of four
changes makes two reads; and that only a click spins the icon. Every
case fails on the old component.

Closes useagenthq#289
@abhishekgahlot2
abhishekgahlot2 merged commit 66b1599 into useagenthq:main Nov 11, 2026
21 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 11, 2026
@abhishekgahlot2

Copy link
Copy Markdown
Contributor

Merged, thanks @officialasishkumar. Reloading on the org change stream instead of every 5 seconds cuts idle requests, and it still picks up every artifact write.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refresh the Artifacts page on changes, not every 5 seconds

2 participants