Skip to content

Conversation

@dlab-anton
Copy link
Contributor

@dlab-anton dlab-anton commented May 5, 2025

Implementation Summary

Task stats are useful for many reasons and are the first step to overall usage stats. Here I wanted to solve the problem of not being able to easily see all the files that were modified during the task. Stats are stored in .json files and persisted with chat history.

Demonstration of prototype task statistics view through file interaction tracking system that:

Tracks File Operations:

  • Captures read, write, create, edit, and other file operations
  • Stores metadata like file path, operation type, timestamp, and success status

Screenshot:

task-stats

Displays Statistics in a Dedicated View:

  • Built a FileStatsView component that shows:
    • Total tool usage count
    • Lists of written files
    • Lists of read files
    • Operation counts by type

Integration Points:

  • Added to the ChatView.tsx:
    • File interactions extraction from messages
    • UI for toggling the stats view
  • Extended TaskHeader.tsx with a stats button
  • Added message handlers in webviewMessageHandler.ts for:
    • Requesting file interactions data
    • Updating file interaction history
    • Toggling the stats view

Storage & Persistence:

  • File interactions are stored with tasks in JSON files
  • Interactions are persisted along with task history
  • Interactions can be loaded for both active and historical tasks

How It Works

  • When file tools are used (read/write/etc.), the operation is recorded with metadata
  • These operations are stored in memory during the task and saved to disk
  • The UI can extract file operations directly from messages or load them from storage
  • The Stats View provides detailed information about file interactions for the current task

Key Components

  • FileInteraction type in WebviewMessage.ts
  • FileStatsView component for displaying statistics
  • The stats view toggle button in TaskHeader.tsx
  • File interaction extraction logic in ChatView.tsx
  • File interaction message handlers in webviewMessageHandler.ts

How Users Interact With It

Users can:

  • Click the stats button (graph icon) in the task header to toggle the stats view
  • See real-time updates of file operations as they happen
  • Review file operations after the task is completed
  • Click on files to open them directly in the editor

This implementation lays the foundation for a more comprehensive statistics tracking system in the future, which could include additional metrics like token usage, function calls, and other performance data. As well as aggregated tasks data on a dedicated statistics dashboard.


Important

Introduces file interaction tracking and statistics view in the UI, with backend support for storing and retrieving interaction data.

  • Behavior:
    • Tracks file operations (read, write, create, edit, etc.) and stores metadata like file path, operation type, timestamp, and success status.
    • Adds FileInteraction type in WebviewMessage.ts.
    • File interactions are stored with tasks in JSON files and can be loaded for both active and historical tasks.
  • UI Components:
    • Adds FileStatsView component to display file interaction statistics, including total tool usage count and lists of read and written files.
    • Integrates FileStatsView into ChatView.tsx and TaskHeader.tsx with a toggle button for viewing stats.
  • Integration:
    • Updates webviewMessageHandler.ts to handle messages for requesting and updating file interaction data.
    • Modifies listFilesTool.ts, readFileTool.ts, searchFilesTool.ts, and writeToFileTool.ts to include file interaction tracking logic.
  • Misc:
    • Adds FileInteractionTracker class in FileInteractionTracker.ts for managing file interactions.
    • Updates ExtensionStateContext.tsx to include file interaction state management.

This description was created by Ellipsis for e44b804. You can customize this summary. It will automatically update as commits are pushed.

…ation Summary\nWe've successfully implemented a file interaction tracking system for the VS Code extension that:\n\nTracks File Operations:\n\nCaptures read, write, create, edit, and other file operations\nStores metadata like file path, operation type, timestamp, and success status\nWorks with both file tools in the code\n\nDisplays Statistics in a Dedicated View:\n\nBuilt a FileStatsView component that shows:\n\nTotal tool usage count\nLists of written files\nLists of read files\nOperation counts by type\n\n\nIntegration Points:\n\nAdded to the ChatView.tsx:\n\nFile interactions extraction from messages\nUI for toggling the stats view\n\n\nExtended TaskHeader.tsx with a stats button\nAdded message handlers in webviewMessageHandler.ts for:\n\nRequesting file interactions data\nUpdating file interaction history\nToggling the stats view\n\n\nStorage & Persistence:\n\nFile interactions are stored with tasks in JSON files\nInteractions are persisted along with task history\nInteractions can be loaded for both active and historical tasks\n\n\nUser Interface:\n\nClean, organized stats view with collapsible sections\nFiles can be clicked to open them directly\nVisual indicators for different operation types\n\n\nHow It Works\n\nWhen file tools are used (read/write/etc.), the operation is recorded with metadata\nThese operations are stored in memory during the task and saved to disk\nThe UI can extract file operations directly from messages or load them from storage\nThe Stats View provides detailed information about file interactions for the current task\n\nKey Components\n\nFileInteraction type in WebviewMessage.ts\nFileStatsView component for displaying statistics\nThe stats view toggle button in TaskHeader.tsx\nFile interaction extraction logic in ChatView.tsx\nFile interaction message handlers in webviewMessageHandler.ts\n\nHow Users Interact With It\nUsers can:\n\nClick the stats button (graph icon) in the task header to toggle the stats view\nSee real-time updates of file operations as they happen\nReview file operations after the task is completed\nClick on files to open them directly in the editor\n\nThis implementation lays the foundation for a more comprehensive statistics tracking system in the future, which could include additional metrics like token usage, function calls, and other performance data.
@changeset-bot
Copy link

changeset-bot bot commented May 5, 2025

⚠️ No Changeset found

Latest commit: e3f3203

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label May 5, 2025
@dlab-anton dlab-anton marked this pull request as draft May 5, 2025 12:38
@dosubot dosubot bot added the enhancement New feature or request label May 5, 2025
const fullInteraction = {
...interaction,
taskId,
timestamp: interaction.timestamp || Date.now()
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using the nullish coalescing operator (??) instead of || when providing a default timestamp. For example, use interaction.timestamp ?? Date.now() to avoid accidental fallback when timestamp is 0.

Suggested change
timestamp: interaction.timestamp || Date.now()
timestamp: interaction.timestamp ?? Date.now()

@adamhill
Copy link
Contributor

adamhill commented May 5, 2025

@dlab-anton Cool! seeing this would be nice for soft-debugging a persons flow and results.

Could you please include a screenshot of when you click the graph icon? What does the FileVStatsiew.tsx component look like? Include shots any other major drill down actions that can occur.

The pic you posted is just a single image of the pane showing the button. But nothing else showing the UI if you click on it. (If you meant upload a video or a animated GIF / PNG, it did not work)

Thanks!

@dlab-anton
Copy link
Contributor Author

dlab-anton commented May 5, 2025

@dlab-anton Cool! seeing this would be nice for soft-debugging a persons flow and results.

Could you please include a screenshot of when you click the graph icon? What does the FileVStatsiew.tsx component look like? Include shots any other major drill down actions that can occur.

The pic you posted is just a single image of the pane showing the button. But nothing else showing the UI if you click on it. (If you meant upload a video or a animated GIF / PNG, it did not work)

Thanks!

task-stats

Thanks for letting me know, hopefully this gif works better. Please let me know if it does not load.

Regarding the UI, it is still not decided if such a view should sit underneath, replace, go inside of the task header. The current layout replaces ChatView through react virtuoso.

@samhvw8
Copy link
Contributor

samhvw8 commented May 5, 2025

Good work!

But can you leverage this https://github.com/RooVetGit/Roo-Code/blob/main/src/core/context-tracking/FileContextTracker.ts?

From this Service, we already have tracking for file edits, mentions, etc., but we haven't virtualized it to the frontend yet.

@dlab-anton
Copy link
Contributor Author

Good work!

But can you leverage this https://github.com/RooVetGit/Roo-Code/blob/main/src/core/context-tracking/FileContextTracker.ts?

From this Service, we already have tracking for file edits, mentions, etc., but we haven't virtualized it to the frontend yet.

Nice! I didn't see that service, and yeah it's no problem at all. I'd update it to include more types so we have granularity over read/write/edit tracking maybe. But unless I'm missing something the conversion would be fast.

@sachasayan
Copy link
Contributor

Hey @dlab-anton: With all of these task stats PRs, I'm thinking breaking out task stats into their own full-screen view might be the way to go rather than stuffing them into the existing UI. Thoughts? And thoughts on best way to achieve this?

@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap May 5, 2025
@hannesrudolph hannesrudolph moved this from PR [Pre Approval Review] to New in Roo Code Roadmap May 5, 2025
@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap May 5, 2025
@hannesrudolph hannesrudolph moved this from PR [Pre Approval Review] to New in Roo Code Roadmap May 5, 2025
@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap May 5, 2025
@dlab-anton
Copy link
Contributor Author

dlab-anton commented May 6, 2025

Hey @dlab-anton: With all of these task stats PRs, I'm thinking breaking out task stats into their own full-screen view might be the way to go rather than stuffing them into the existing UI. Thoughts? And thoughts on best way to achieve this?

If me ...

edit: made a quick mock-up // not sure how much I like it but may be useful.

task-header-2

My decision to roll out the chart PR first was just operations not design priority, I figure we can put charts in the existing UI first. And if it works and people like it, then we sophisticate that by adding an additional stats screen. If we add the stats screen first it would be empty and if we combine then its a big PR. So maybe

  1. roll out charts
  2. roll out task stats new full-page view with cards + tool tracking

@samhvw8
Copy link
Contributor

samhvw8 commented May 6, 2025

@dlab-anton can we do something like this ?

above textarea, and click to expand or send it to editor panel ?

image

@dlab-anton
Copy link
Contributor Author

@dlab-anton can we do something like this ?

That's very interesting. Are ALL files modified throughout task put there? Does it go into overflow '...' after awhile? Or does it only show the file currently working on there?

@sachasayan
Copy link
Contributor

I think we're going to hold off on this one right now, there's too much other UI work to do in this area. Let's revisit it as we clean up the rest of the UI here.

@sachasayan sachasayan closed this May 6, 2025
@github-project-automation github-project-automation bot moved this from PR [Pre Approval Review] to Done in Roo Code Roadmap May 6, 2025
@dlab-anton
Copy link
Contributor Author

dlab-anton commented May 6, 2025

I think we're going to hold off on this one right now, there's too much other UI work to do in this area. Let's revisit it as we clean up the rest of the UI here.

Hi Sacha, I posted a mockup at the same time you closed the PR so I'm not sure if you saw it. It's worth looking at so it can mull in the back if your mind. ^^

task-header-2

I will hold off on further work on task header until the other work is done.

@sachasayan
Copy link
Contributor

I saw it, looks awesome, I think right now there's a question of managing technical debt with additions like these when we need to clean up the rest of the UI. It's not a no, it's a "...let's return to this in a bit."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants