Skip to content

feat: re-run and follow runtime calls from the workspace - #189

Merged
voliva merged 2 commits into
polkadot-api:mainfrom
sharmis-tp:feat/rerun-runtime-call
Oct 16, 2026
Merged

voliva merged 2 commits into
polkadot-api:mainfrom
sharmis-tp:feat/rerun-runtime-call

Conversation

@sharmis-tp

Copy link
Copy Markdown
Contributor

Closes #161

Runtime call entries in the workspace ran once, pinned to the block they were queried at. They can now be refreshed:

  • Re-run runs the call again at the latest best block.
  • Follow keeps the value updated as new best blocks arrive, as suggested in the issue: only one call is in flight, and when it completes it runs again at the newest best block if that changed meanwhile. A chain with short block times gets at most one call per call duration instead of one per block. Turning Follow off also drops any pending catch-up run.
  • The entry shows which block its value comes from, and the block on the Runtime Calls result page follows the same result.

How

runtimeCallToWorkspaceEntry drives the call from a stream of block hashes: the queried block, the latest best block on each re-run, and best blocks while following. While following, throttle(() => runDone$, { leading: true, trailing: true }) emits the first new best block, then reopens only when the current call finishes, carrying the newest best block. All runs go through concatMap, so they never overlap. The entry status is derived from the shared result$, and RuntimeCallResult now carries the blockHash it ran at.

Testing

  • I simulated the same operator chain with a new best block every 100 ms and calls taking 300 to 500 ms: 40 best blocks produced 10 to 11 calls, never more than one in flight, each at the newest best block, and none after Follow was turned off.
  • I also tested live against Polkadot Asset Hub (smoldot) on a dev build:
    • With Follow on, the entry tracked the ~2 s best blocks (25 updates in 50 s).
    • With Follow off, it stopped.
    • Re-run jumped to the latest best block.
  • pnpm build (tsc + vite) passes and Prettier is clean. pnpm lint currently crashes on main as well (TypeScript 7 with typescript-eslint), so I couldn't run ESLint.
2-following

@vercel

vercel Bot commented Oct 15, 2026

Copy link
Copy Markdown

@sharmis-tp is attempting to deploy a commit to the Streamsphere Labs Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
papi-console Ready Ready Preview Oct 16, 2026 6:34am UTC

Request Review

@voliva voliva 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.

Thanks! So far looks good to me.

I think we would also need to have the "follow" toggle available in RuntimeCallResultContent

}
aria-label="Follow best blocks"
aria-pressed={follow}
className={twMerge("h-7 w-7", follow && "text-primary")}

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.

text-primary isn't that different from the default. We didn't want to make the pink polkadot color the primary either as that was way too much pink in all UI elements of the page, so we put it into a custom tailwind color instead. And I personally think it looks nice as an indicator for active in this case.

Suggested change
className={twMerge("h-7 w-7", follow && "text-primary")}
className={twMerge("h-7 w-7", follow && "text-polkadot")}

@sharmis-tp

Copy link
Copy Markdown
Contributor Author

Thanks! Both done

@voliva voliva 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.

Awesome thank you very much 🚀

@voliva
voliva merged commit a0ec355 into polkadot-api:main Oct 16, 2026
2 checks passed
@sharmis-tp

Copy link
Copy Markdown
Contributor Author

Thanks for the reviews and the merge, @voliva! I've enjoyed working on the console (#188 and #189) and I'd like to keep going. If Polkadot-API has room for a contractor, I'd be glad to help with forklift (fork, reorg and pruned-branch scenarios are close to what I did in #188) or with the console, and I can start with a small paid task. @josepot, I've also reached out to you directly.

This branch was successfully deployed

1 active deployment
Preview — 6f67685e Deployed Oct 16, 2026 by vercel[bot]
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.

Re-run (or sync?) runtime call from workspace

2 participants