Feat: AI Credit History tab for AI credits widget (#100)#102
Open
blueogin wants to merge 7 commits into
Open
Conversation
…tion to operator consent requests and implementing credit history retrieval functionality. Update types and response structures for improved credit management and user experience.
…I changes. Changed endpoint from `/credit` to `/profile` for fetching payer wallet information, enhancing clarity in the widget's functionality.
…new endpoint for credit history retrieval. Update the buyer address resolution logic to utilize the credit history entries, improving accuracy in buyer identification. Remove unused buyerAddress property from types for cleaner code.
… payer field from requests and responses. Update the adapter and backend client to reflect these changes, ensuring cleaner code and improved consistency in consent management.
…y allowing access to filtered and paginated AI credit funding history. Update documentation and component structure to reflect the new tab, while removing the deprecated UsageLog component for improved clarity and functionality.
…es in widget behavior, including new and modified screenshots for various states.
…cators for funding status and entry icons. Refactor amount summary logic to improve clarity and display of credit history. Update UI structure for better user experience, including dynamic status labels and improved loading/error handling.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new top-level History tab to packages/ai-credits-widget, moving credit history out of the Manage UI and switching history loading to the paginated /v1/accounts/:account/credit-history endpoint, with Storybook + Playwright coverage for the new state.
Changes:
- Introduces
useAiCreditsHistory(widget-level state) and a newHistoryTabUI with source/status/date filters + load-more pagination. - Updates backend client/types to support
CreditHistoryResponseand the new/profile+/credit-historyendpoints; removes the legacy ManageUsageLog. - Adds a Storybook QA story and Playwright smoke test for the History tab state.
Reviewed changes
Copilot reviewed 14 out of 27 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/widgets/ai-credits-widget/states.spec.ts | Adds a Playwright smoke test + screenshot for the new History tab story. |
| packages/ui/src/components/Icon.tsx | Adds icons needed by the new History row design (plus/arrows/more). |
| packages/ai-credits-widget/src/widgetRuntimeContract.ts | Extends widget tab union to include history. |
| packages/ai-credits-widget/src/useAiCreditsHistory.ts | New hook managing filters + pagination state and calling getCreditHistory. |
| packages/ai-credits-widget/src/components/manage/UsageLog.tsx | Removes the deprecated Manage-tab history card implementation. |
| packages/ai-credits-widget/src/components/index.ts | Exports HistoryTab and removes UsageLog export. |
| packages/ai-credits-widget/src/components/history/HistoryTab.tsx | New History tab UI: filters, rows, error/empty/loading states, load-more. |
| packages/ai-credits-widget/src/backendTypes.ts | Adds credit-history query/response types; updates account credit response shape. |
| packages/ai-credits-widget/src/backendClient.ts | Implements getCreditHistory, updates production endpoints, and updates view-building logic. |
| packages/ai-credits-widget/src/AiCreditsWidget.tsx | Wires up the History tab and keeps history state persistent across tab switches. |
| packages/ai-credits-widget/src/adapter.ts | Updates tab/status logic to treat History as a non-buy tab alongside Manage. |
| examples/storybook/src/stories/helpers/aiCreditsWidgetStories.tsx | Adds a HistoryTab QA story helper with activeTab: 'history'. |
| examples/storybook/src/stories/ai-credits-widget/AiCreditsWidgetQA.stories.tsx | Exposes the new HistoryTab story in the QA story set. |
| examples/storybook/src/stories/ai-credits-widget/AiCreditsWidget.mdx | Updates docs to reflect the new History tab and endpoints. |
Comment on lines
+5
to
+7
| export const HISTORY_PAGE_SIZE = 10 | ||
| export const HISTORY_DEFAULT_FROM = '2026-01-01' | ||
| export const HISTORY_DEFAULT_TO = '2030-12-31' |
Comment on lines
+42
to
+46
| function sourceLabel(source: CreditHistorySource): string { | ||
| if (source === 'deposit') return 'G$ deposit' | ||
| if (source === 'streamUpdate') return 'Stream update' | ||
| return 'Stream credit' | ||
| } |
Comment on lines
685
to
690
| const normalizedPayer = normalizeAddress(payer) | ||
| const [credit, outstanding] = await Promise.all([ | ||
| const [credit, outstanding, history] = await Promise.all([ | ||
| backend.getAccountCredit(payer), | ||
| backend.getOutstanding(payer), | ||
| backend.getCreditHistory(payer, { limit: MAX_HISTORY_LIMIT, offset: 0 }), | ||
| ]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
UsageLogcard.GET /v1/accounts/:account/credit-historyendpoint with source / status / date filters and load-more pagination.useAiCreditsHistory) so they persist when switching tabs.UsageLog.Closes #100
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: