Skip to content

refine: panel poll budgets (scan ~152s, apply ~120s) are hardcoded and can expire before the relay's REFINE_AGENT_TIMEOUT_MS #4

Description

@jamieb72-afk

Summary

transitions-refine (v0.3.34) lets me raise the relay's agent budget via REFINE_AGENT_TIMEOUT_MS, but the injected panel has its own hardcoded poll budgets that can't be raised. On a large repo where an agent scan legitimately takes a few minutes, the panel reports failure while the relay goes on to complete the job successfully.

The two client-side budgets

Both live in the panel code (built from demo.html into /inject.js):

  • Scan: for(let i=0;i<520;i++) with the 120ms→300ms ramp ≈ 152s, then throw new Error("scan timed out").
  • Apply/Accept: for(let i=0;i<240&&!settled;i++) at 500ms ≈ 120s.

The Refine-click poll loop is unbounded client-side, so it's fine — it's bounded by the relay.

Repro / real-world case

Next.js 16 app, ~4k files. Relay started with REFINE_AGENT_TIMEOUT_MS=600000 and REFINE_AGENT_CMD='claude -p ...'. A grouping scan takes ~3.5 min of agent time. Result:

  • Relay log: ✓ scan f81ca478 — 8 group(s) (success)
  • Panel (already gave up at ~152s): "Couldn't group — agent offline"

So the failure mode misleads twice: the panel calls a slow-but-succeeding agent "offline", and raising the documented env var doesn't help because the browser side expires first.

Suggestion

Make the panel budgets follow the relay's budget instead of being fixed constants — e.g.:

  • have /inject.js template the poll bounds from REFINE_AGENT_TIMEOUT_MS at build time in buildInjectModule() (the relay already knows the value), or
  • expose it via /health (which the panel already consults) and size the loops from that.

Either keeps zero-config defaults identical while letting the existing env var govern both halves.

Workaround (for anyone else hitting this)

Patch the two loop bounds in the npx cache's demo.html (i<520i<2000, i<240i<1200) and restart the relay — works, but is silently lost on every version bump.

Happy to PR the buildInjectModule() templating approach if you'd take it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions