Skip to content

Feat: AI Credit History tab for AI credits widget (#100)#102

Open
blueogin wants to merge 7 commits into
mainfrom
feat/ai-credits/history-tab
Open

Feat: AI Credit History tab for AI credits widget (#100)#102
blueogin wants to merge 7 commits into
mainfrom
feat/ai-credits/history-tab

Conversation

@blueogin

@blueogin blueogin commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Description

  • Adds a top-level History tab to the AI credits widget (Buy / Manage / History), moving credit history out of the Manage UsageLog card.
  • Loads history from the paginated AntSeed GET /v1/accounts/:account/credit-history endpoint with source / status / date filters and load-more pagination.
  • History filters and fetched results live in widget-level state (useAiCreditsHistory) so they persist when switching tabs.
  • Updates history rows to card layout (icon, title/date, amount/status, tooltip), and removes the deprecated Manage UsageLog.

Closes #100

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • PR title matches follow: (Feature|Bug|Chore) Task Name
  • My code follows the style guidelines of this project
  • I have followed all the instructions described in the initial task (check Definitions of Done)
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have added reference to a related issue in the repository
  • I have added a detailed description of the changes proposed in the pull request. I am as descriptive as possible, assisting reviewers as much as possible.
  • I have added screenshots related to my pull request (for frontend tasks)
  • I have pasted a gif showing the feature.
  • @mentions of the person or team responsible for reviewing proposed changes

blueogin added 7 commits July 15, 2026 09:40
…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.
@blueogin
blueogin requested review from a team and L03TJ3 July 20, 2026 20:00
@sirpy
sirpy requested a review from Copilot July 21, 2026 05:50

Copilot AI 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.

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 new HistoryTab UI with source/status/date filters + load-more pagination.
  • Updates backend client/types to support CreditHistoryResponse and the new /profile + /credit-history endpoints; removes the legacy Manage UsageLog.
  • 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 }),
])
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.

Feat: AI Credit History tab for AI credits widget

2 participants