Real-Time Cost Ticker During Job Execution #22

Open
opened 2026-03-20 22:26:52 +00:00 by replit · 0 comments
Owner

What & Why

Visitors pay in sats but currently have no visibility into the running cost until the job completes. A live cost ticker — showing tokens consumed and estimated sats cost as Timmy streams his response — gives visitors transparency, builds trust, and makes the Workshop feel like a real economic engine.

Done looks like

  • While a job is in executing state, a small cost ticker appears in the Workshop near the active job indicator
  • Ticker updates as streaming tokens arrive: '~1,247 tokens · ~4 sats'
  • Token count tracked server-side on the streaming response and included in job_progress WebSocket events
  • Final cost shown on job completion with actual vs estimated comparison ('Estimated: 4 sats · Actual: 3.8 sats')
  • Cost calculation reuses the existing pricing module
  • Ticker hidden for free chat

Out of scope

  • Per-request cost history chart (that's the performance dashboard)
  • Changing actual pricing or billing logic
  • Cost breakdown by model or tool call

Tasks

  1. Token streaming count — Track cumulative token count during response streaming server-side; include in job_progress WebSocket events.
  2. Cost estimation — Use existing pricing module to convert token count to estimated sats; include in the progress event.
  3. Cost ticker UI — Small ticker component that appears on job execute start, updates on job_progress events, shows final vs estimated on job_complete.

Relevant files

  • artifacts/api-server/src/lib/agent.ts
  • artifacts/api-server/src/lib/pricing.ts
  • artifacts/api-server/src/routes/jobs.ts
  • artifacts/api-server/src/routes/events.ts
  • the-matrix/js/ui.js
  • the-matrix/js/websocket.js
## What & Why Visitors pay in sats but currently have no visibility into the running cost until the job completes. A live cost ticker — showing tokens consumed and estimated sats cost as Timmy streams his response — gives visitors transparency, builds trust, and makes the Workshop feel like a real economic engine. ## Done looks like - While a job is in `executing` state, a small cost ticker appears in the Workshop near the active job indicator - Ticker updates as streaming tokens arrive: '~1,247 tokens · ~4 sats' - Token count tracked server-side on the streaming response and included in `job_progress` WebSocket events - Final cost shown on job completion with actual vs estimated comparison ('Estimated: 4 sats · Actual: 3.8 sats') - Cost calculation reuses the existing pricing module - Ticker hidden for free chat ## Out of scope - Per-request cost history chart (that's the performance dashboard) - Changing actual pricing or billing logic - Cost breakdown by model or tool call ## Tasks 1. **Token streaming count** — Track cumulative token count during response streaming server-side; include in `job_progress` WebSocket events. 2. **Cost estimation** — Use existing pricing module to convert token count to estimated sats; include in the progress event. 3. **Cost ticker UI** — Small ticker component that appears on job execute start, updates on `job_progress` events, shows final vs estimated on `job_complete`. ## Relevant files - `artifacts/api-server/src/lib/agent.ts` - `artifacts/api-server/src/lib/pricing.ts` - `artifacts/api-server/src/routes/jobs.ts` - `artifacts/api-server/src/routes/events.ts` - `the-matrix/js/ui.js` - `the-matrix/js/websocket.js`
replit added the backendworkshopfrontendlightning labels 2026-03-20 22:26:52 +00:00
gemini was assigned by Rockachopa 2026-03-22 23:37:38 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: replit/timmy-tower#22