Skip to content

Fix usage history: modality, outputs, fees, and MCP assets - #47

Open
eliteprox wants to merge 12 commits into
feat/mcp-assets-schemafrom
fix/usage-history-modality
Open

Fix usage history: modality, outputs, fees, and MCP assets#47
eliteprox wants to merge 12 commits into
feat/mcp-assets-schemafrom
fix/usage-history-modality

Conversation

@eliteprox

@eliteprox eliteprox commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Usage history was reading OpenMeter pipeline as a first-party pipeline id (text-to-imaget2i). Live-runner tickets now write the price unit there (fixed), so the pill collapsed to "f" and the detail pane fell through to JSON. This PR fixes that and the related history surfaces that depended on it.

Depends on #50 (Drizzle mcp_assets schema + migration). Land that first, then rebase this branch and drop the duplicated db/ / drizzle/ files.

  • Infer modality from capability metadata. Persistent live jobs (hour / live) resolve as realtime. Unknown batch tickets stay unknown instead of looking like live video.
  • History is a rolling 7-day window, paged in chunks of 50. Output joins query every gateway_request_id / eventId on the page (chunked, not capped at 50 recent assets).
  • Exact ID match wins. Orchestrator 8-hex tickets may join a single same-capability MCP job_* asset in a 15-minute window; ambiguous candidates are skipped.
  • MCP Auth0 sub hashes to the same eu_ principal as Console so assets and history share a tenant.
  • Display ticket fees from wei + ETH/USD with a compact figure and a tooltip for the exact value when it differs.
  • Image preview in the request drawer shows a loader until the asset is ready.

Test plan

  • Open /home History: live-runner rows (e.g. livepeer-example/fal-gpt-image-2) show a t2i pill, not f or fixed
  • Persistent live / hour tickets show realtime; unknown batch apps show unknown, not a live session
  • Scroll / load more through older than 50 rows within the last 7 days; outputs still attach by request id
  • Open a text-to-image request: Capability, Modality t2i, Format PNG, Dimensions 1024 x 1024, and an image preview
  • Open an edit / i2v / whisper request: modality is edit / i2v / asr and the preview kind follows
  • video-understanding / ASR rows are text, not a video player
  • Two same-model jobs within 15 minutes do not steal each other's preview
  • Cost column shows a readable USD amount; hover shows the exact figure when it was rounded
  • Search history by modality (t2i) still filters
  • First-party tickets with a real pipeline name (text-to-image, live-video-to-video) still map to t2i / v2v

@vercel

vercel Bot commented Sep 4, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
console Ready Ready Preview Sep 5, 2026 3:19am UTC

Request Review

@eliteprox

Copy link
Copy Markdown
Collaborator Author

Not super satisfied with Infer modality from capability metadata, but this works until we get time to improve the runner side for pricing

Live-runner tickets store the price unit (fixed) as pipeline, so history
abbreviated it to "f". Infer modality from capability/fal metadata instead.
- Updated `resolveActivityCapability` to default to "realtime" for persistent live jobs without a media modality.
- Added tests to verify that unresolved tickets and signed-ticket rows are correctly identified as "realtime".
- Introduced new mappings for the "live" pipeline to "realtime" modality in relevant functions and types.
- Updated dev mock data to include the "hour" pipeline with associated properties.

This commit improves the handling of live job modalities, ensuring accurate representation in the system.
- Added support for Neon Postgres in the MCP asset management system, allowing for persistent storage of asset data.
- Updated the asset handling functions to include new fields such as `providerRequestId` and improved error handling during asset persistence.
- Enhanced the `listAssets`, `rememberAsset`, and `forgetAssets` functions to interact with the Neon database.
- Introduced a new test suite to validate the integration with Neon, ensuring correct functionality when the database URL is set.

This commit improves the asset management capabilities by leveraging a robust database solution, enhancing data persistence and retrieval.
- Bump version of `@pymthouse/gateway-web` to 0.3.3 in package.json and pnpm-lock.yaml.
- Enhance error handling in `buildRawMcpServer` to log asset store errors and return user-friendly messages.
- Modify `forgetAssets` function to accept an object for input, allowing for more flexible asset deletion options.
- Introduce new utility functions for error logging and public error messages related to asset store access.
- Update tests to cover new functionality and ensure robust error handling.

This commit improves the asset management system by refining error handling and enhancing the flexibility of asset deletion operations.
- Introduced `jobOutputsForPrincipal` function to fetch and associate job output URLs and provider request IDs with account requests.
- Updated the `GET` handler in `route.ts` to include output URLs in the response for account requests.
- Modified `AccountActivityRow` and related types to accommodate new fields for output URLs and provider request IDs.
- Added tests to ensure correct mapping of signed tickets to activity rows, verifying the integration of output URLs and provider request IDs.

This commit improves the account request handling by linking job outputs, enhancing the data returned to users.
…t logic

- Renamed `jobOutputsForPrincipal` to `attachOutputsToTickets` to better reflect its functionality.
- Updated the implementation to directly attach outputs to ticket items based on their gateway request IDs and event IDs.
- Introduced a new utility function `matchTicketOutputs` to handle the mapping of ticket requests to asset outputs, improving the accuracy of output attachment.
- Added comprehensive tests for the new matching logic to ensure correct functionality and integration.

This commit enhances the account request handling by streamlining the process of associating outputs with tickets, improving data accuracy and retrieval efficiency.
- Updated `CallsTable` to use consistent column widths for compact density settings.
- Introduced `ethUsdPrice` field in `SignedTicketRequestRow` for better ticket pricing accuracy.
- Replaced `microsToUsdDisplay` with `requestFeeDisplay` in `signed-ticket-activity` for improved fee formatting.
- Added new utility functions in `request-fee-display.ts` to handle USD conversion and formatting.
- Implemented tests for fee display functions to ensure accurate representation of ticket costs.

This commit improves the handling of fee displays and enhances the accuracy of ticket pricing in the console.
- Added a `Tooltip` component to `CallDetailDrawer` and `CallsTable` for displaying exact cost values when they differ from the displayed cost.
- Updated `requestFeeDisplay` to return both display and exact cost values, improving the accuracy of cost representation.
- Modified `AccountActivityRow` to include a new `costExact` field for full-precision cost.
- Enhanced tests for fee display functions to ensure correct formatting and representation of costs.

This commit improves the user experience by providing additional context for cost values in the console.
- Updated the dollar division calculation in `formatUsdFromWei` to use `BigInt(10) ** BigInt(24)` for improved precision.
- This change ensures accurate conversion of Wei to USD, enhancing the reliability of cost representation in the console.
- Introduced a `PreviewLoader` component to display a loading spinner while images are being loaded in the `ImagePreview` component.
- Updated the `ImagePreview` to manage loading state, enhancing user experience by providing visual feedback during image loading.
- Ensured that the image opacity transitions smoothly based on the loading state, improving the overall aesthetic of the component.
Chunk gateway-id lookups instead of slicing to 50, keep unknown batch
jobs from looking like live video, and hash MCP Auth0 subs to the same
eu_ principal as Console so assets cannot land in a different tenant.
Match ensureSchema so PR 47 does not depend on a follow-up index change.
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.

1 participant