Skip to content

Conversation

@bajtos
Copy link
Contributor

@bajtos bajtos commented Jan 7, 2026

Update the demo app to show remaining egress allowances for each data set where the FilBeam service is enabled.

Screenshot showing the new version in practice:

Screenshot 2026-01-13 at 11 02 14
version 2 using FolderSync icon Screenshot 2026-01-07 at 12 24 56
version 1 using RefreshCw icon Screenshot 2026-01-07 at 12 11 31

@bajtos bajtos requested review from juliangruber and pyropy January 7, 2026 11:12
@github-project-automation github-project-automation bot moved this to 📌 Triage in FS Jan 7, 2026
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 7, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
⛔ Deployment terminated
View logs
synapse-dev c0bbd0e Commit Preview URL

Branch Preview URL
Jan 07 2026, 12:14 PM

</TooltipTrigger>
<TooltipContent>
<p>Cache miss egress quota remaining</p>
</TooltipContent>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The icons aren't clear to me, at first I assumed the globe would stand for global traffic. Otoh, this is just a demo app, so we don't have to get the UX exaclty right.

Proposals:

  • Use icon ⬇️ for egress
  • Replace icons with text

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I share your concerns.

How do you feel about the updated version using "folder sync" for the cache-miss egress quota?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I prefered the previous version, but don't have a strong opinion

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Icons, "folder sync" one in particular, definitely seem a bit confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in ac134f7.

🌐 Egress remaining: 98.42 GiB delivery · 43.31 GiB cache-miss

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you like me to add tooltips for "delivery" and "cache-miss" to explain what these labels mean (traffic from the client to Filbeam, traffic from FilBeam to the SP).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine like this

@rjan90 rjan90 moved this from 📌 Triage to 🔎 Awaiting review in FS Jan 7, 2026
@rjan90 rjan90 added this to the M4: Filecoin Service Liftoff milestone Jan 7, 2026
Signed-off-by: Miroslav Bajtoš <[email protected]>
Comment on lines +22 to +24
function getFilBeamStatsBaseUrl(chainId: number): string {
return chainId === 314 ? 'https://stats.filbeam.com' : 'https://calibration.stats.filbeam.com'
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move this helper to synapse-core, to avoid duplication between synapse-react and synapse-sdk?

/**
* Get the base stats URL for the current network
*/
private _getStatsBaseUrl(): string {
return this._network === 'mainnet' ? 'https://stats.filbeam.com' : 'https://calibration.stats.filbeam.com'
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes make a filbeam file or folder in core and move this there

@rjan90 rjan90 moved this from 🔎 Awaiting review to ✔️ Approved by reviewer in FS Jan 7, 2026
@rvagg
Copy link
Collaborator

rvagg commented Jan 8, 2026

This seems fine to me and I appreciate the AGENTS.md edits but I'm going to leave it to @hugomrdias to review

@rvagg rvagg removed their request for review January 8, 2026 08:04
@BigLep BigLep moved this from ✔️ Approved by reviewer to 🔎 Awaiting review in FS Jan 8, 2026
- Change format to "Egress remaining: X GiB delivery · Y GiB cache-miss"
- Remove FolderSync icon, keep Globe icon with tooltip "This data set is using CDN"
- Use binary units (KiB, MiB, GiB, TiB) instead of decimal units

Co-Authored-By: Claude Code <[email protected]>
Signed-off-by: Miroslav Bajtoš <[email protected]>
@bajtos bajtos requested review from juliangruber and pyropy January 13, 2026 10:12
@bajtos
Copy link
Contributor Author

bajtos commented Jan 13, 2026

I addressed the review comments, this PR is ready for another round of reviews. 🙏🏻

Copy link
Member

@pyropy pyropy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏻

Comment on lines +45 to +55
export function formatBytes(bytes: bigint | number): string {
const num = typeof bytes === 'bigint' ? Number(bytes) : bytes
if (num === 0) return '0 B'

const units = ['B', 'KiB', 'MiB', 'GiB', 'TiB']
const k = 1024
const i = Math.floor(Math.log(num) / Math.log(k))
const value = num / k ** i

return `${value.toFixed(2).replace(/\.?0+$/, '')} ${units[i]}`
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +22 to +24
function getFilBeamStatsBaseUrl(chainId: number): string {
return chainId === 314 ? 'https://stats.filbeam.com' : 'https://calibration.stats.filbeam.com'
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes make a filbeam file or folder in core and move this there

Comment on lines +26 to +51
async function fetchDataSetEgressQuota(chainId: number, dataSetId: bigint): Promise<DataSetEgressQuota | undefined> {
const baseUrl = getFilBeamStatsBaseUrl(chainId)
const url = `${baseUrl}/data-set/${dataSetId}`

try {
const response = await fetch(url)
if (!response.ok) {
console.error(`Failed to fetch data set egress quota: ${response.status} ${response.statusText}`)
return undefined
}

const data = (await response.json()) as Record<string, unknown>

if (typeof data.cdnEgressQuota !== 'string' || typeof data.cacheMissEgressQuota !== 'string') {
console.error('Unexpected response body from FilBeam Stats API:', data)
return undefined
}

return {
cdnEgressQuota: BigInt(data.cdnEgressQuota),
cacheMissEgressQuota: BigInt(data.cacheMissEgressQuota),
}
} catch (err) {
console.error('Cannot fetch data set egress quotas from FilBeam Stats API', err)
return undefined
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same move to core pls use the request lib we use for sp client and make proper error

Comment on lines +93 to +94
const egressQuota = dataSet.cdn ? await fetchDataSetEgressQuota(chainId, dataSet.dataSetId) : undefined

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not sold on put this inside useDataSets its already pretty heavy and we are rethinking the apis for costs and balances right now.

</TooltipContent>
</Tooltip>
<span className="flex items-center gap-1 text-sm text-muted-foreground">
<Tooltip>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would make a custom tooltip component wrapping the globe icon with all the cdn info, using a hook to fetch the data.

check the other hooks that use tanstack query to wrap fetchDataSetEgressQuota

@github-project-automation github-project-automation bot moved this from 🔎 Awaiting review to ⌨️ In Progress in FS Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ⌨️ In Progress

Development

Successfully merging this pull request may close these issues.

7 participants