-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Add total API cost calculation to HistoryView component #2697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
| // Calculate total API cost for current tasks | ||
| const totalApiCost = useMemo(() => { | ||
| return tasks.reduce((sum, task) => { | ||
| const cost = typeof task.totalCost === "string" ? parseFloat(task.totalCost) : task.totalCost |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have a case where totalCost is a string?
i'm guessing the type is a string, but i'm a bit confused as to where it's being used since free model is 0 right? instead of some other string value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's more of a safeguard really, I can always change it
|
I like the idea of more visibility here, but I would love to complement the cost with some information about the amount of work accomplished for that spend (number of tasks is probably easiest). I know @sachasayan is also redesigning this area in #2806 - maybe he has some ideas too? Thank you! |
|
I have some questions about here about purpose, and whether this starts transitioning the view in question from a task management view to a project management view. Stats are fun but maybe there could be a specific view for project (workspace) level information rather than crowding the task management view? |
Yeah that's fair. I figured since the API costs for each task is already visible in the history view it would make sense to have a total, and I like being able to quickly get an overview over how much is spent within a project. But I'm open to moving it elsewhere. |
Maybe we could have a little ( i ) mouseover in the task list for the current workspace on the main screen? |
|
Hey @DonDawsy, thank you for your contribution. Sorry for the delay on reviewing your PR We'd like to implement a more robust cost management solution to handle this specific issue and we apologize that we took so long to let you know. We shifted to a clearer issue-first workflow. Please create an issue first if you'd like to revisit this. We appreciate your patience. |
Context
Adds a Total API Cost to the history view, makes it easy to quickly see how much is spent on a project.
Can view totals for both current project and all projects.
Implementation
It uses a React useMemo hook to compute the sum of the totalCost field from the filtered task list. The total is shown above the task list.
Screenshots
Before:

After:

Get in Touch
Discord: dondaws
Important
Adds total API cost calculation and display to
HistoryViewcomponent usinguseMemo.HistoryViewcomponent usinguseMemo.HistoryView.totalCostfromtasksarray, handling both string and number types.useMemoto optimize calculation based ontasksdependency.HistoryView.This description was created by
for 1bba837. It will automatically update as commits are pushed.