Skip to content

Add thread & project token usage labels#492

Open
Samigos wants to merge 13 commits into
Dimillian:mainfrom
Samigos:thread-token-usage
Open

Add thread & project token usage labels#492
Samigos wants to merge 13 commits into
Dimillian:mainfrom
Samigos:thread-token-usage

Conversation

@Samigos

@Samigos Samigos commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add local thread token usage snapshot plumbing across Tauri app/daemon and frontend services
  • render thread and workspace token usage labels in sidebar lists
  • add Display settings toggles for thread token usage visibility, full count formatting, and excluding cache from totals
  • default the cache-excluded display mode to enabled

Validation

  • npm run typecheck
  • npm run test
  • cd src-tauri && cargo check
image image

@Samigos Samigos changed the title Add thread token usage totals with cache-excluded display option Add thread token usage labels Feb 23, 2026
@Samigos Samigos changed the title Add thread token usage labels Add thread & project token usage labels Feb 23, 2026
@Samigos

Samigos commented Feb 23, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3843032994

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/App.tsx Outdated
Comment on lines +1407 to +1411
Object.entries(threadsByWorkspace).forEach(([workspaceId, threads]) => {
const total = threads.reduce(
(sum, thread) => sum + getDisplayThreadTokenUsageTotal(tokenUsageByThread[thread.id]),
0,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Compute workspace token totals from full thread set

getWorkspaceTokenUsageLabel derives each project total from threadsByWorkspace, but that state only contains the first page of threads because listThreadsForWorkspaces truncates to THREAD_LIST_TARGET_COUNT before storing summaries. In any workspace with more than 20 threads, the workspace/worktree token label will systematically undercount usage, so the displayed “project” total can be materially wrong until users manually page in older threads.

Useful? React with 👍 / 👎.

Comment on lines +199 to +203
let walker = WalkBuilder::new(root)
.hidden(false)
.follow_links(false)
.require_git(false)
.build();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid walking entire sessions tree on each usage fetch

scan_thread_usage builds a filesystem walker over every sessions root and iterates every .jsonl file for each snapshot request, even when only a small threadIds subset is requested. Because sidebar thread-list refreshes trigger these snapshots, usage hydration cost scales with total session history size, which can make routine list/paging operations noticeably slow on long-lived workspaces.

Useful? React with 👍 / 👎.

@Dimillian

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@puls-com-leon-komarovsky

Copy link
Copy Markdown
Contributor

@Samigos is it possible to show actual costs in $$$?

@Samigos

Samigos commented Feb 24, 2026

Copy link
Copy Markdown
Contributor Author

@Samigos is it possible to show actual costs in $$$?

Looking into it right now

@shpoont

shpoont commented Feb 24, 2026

Copy link
Copy Markdown

Just probably should state somewhere that those are estimations and might differ from the actual bill. Other than that this feature would be super useful.

… thread-token-usage

# Conflicts:
#	src/features/threads/hooks/useThreadActions.test.tsx
#	src/features/threads/hooks/useThreadActions.ts
@Dimillian Dimillian closed this Mar 3, 2026
@Dimillian Dimillian reopened this Mar 3, 2026

@xkonjin xkonjin left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick review pass:

  • Main risk area here is auth/session state and stale credential handling.
  • Good to see test coverage move with the code; I’d still make sure it exercises the unhappy path around auth/session state and stale credential handling rather than only the happy path.
  • Before merge, I’d smoke-test the behavior touched by codex_monitor_daemon.rs, workspace.rs, lib.rs (+40 more) with malformed input / retry / rollback cases, since that’s where this class of change usually breaks.

@Samigos

Samigos commented Mar 9, 2026

Copy link
Copy Markdown
Contributor Author

@xkonjin You mean in case the user switch accounts?

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.

5 participants