Skip to content

[Part 2/6] feat(telemetry): add activity detector with user interaction tracking#8111

Merged
jacob314 merged 4 commits intogoogle-gemini:mainfrom
eLyiN:split/activity-detector
Sep 18, 2025
Merged

[Part 2/6] feat(telemetry): add activity detector with user interaction tracking#8111
jacob314 merged 4 commits intogoogle-gemini:mainfrom
eLyiN:split/activity-detector

Conversation

@eLyiN
Copy link
Copy Markdown
Contributor

@eLyiN eLyiN commented Sep 9, 2025

Summary

Adds activity detection capabilities for user interaction tracking, enabling activity-aware telemetry recording. The ActivityDetector tracks user activity across different interaction types and provides APIs to check current activity state.

Dependencies

⚠️ This PR depends on:

Review Order: Please review Part 1 (#8110) first, then this PR.

Related PRs - Enhanced Performance Monitoring Split

This is Part 2 of 6 in the split implementation of #2127:

Changes in This PR

ActivityTypes (packages/core/src/telemetry/activity-types.ts)

  • Defines different types of user activities: KEYBOARD, MOUSE, SYSTEM, IDLE
  • Provides TypeScript enums for type-safe activity tracking
  • Foundation for categorizing different user interaction patterns

ActivityDetector (packages/core/src/telemetry/activity-detector.ts)

  • Core activity tracking: Records user activities with timestamps and types
  • Activity state checking: isUserActive() API to check if user is currently active
  • Configurable timeouts: Define how long to consider user active after last interaction (default: 30 seconds)
  • Memory efficient: Automatic cleanup of old activity records
  • Thread-safe: Uses Maps with proper cleanup to prevent memory leaks

Enhanced Exports (packages/core/src/telemetry/index.ts)

  • Exports ActivityDetector class and related APIs
  • Exports ActivityType enum for type-safe usage

@eLyiN eLyiN requested a review from a team as a code owner September 9, 2025 20:24
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @eLyiN, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request lays foundational groundwork for enhanced performance monitoring by introducing mechanisms to track user activity. It provides core components for detecting and categorizing user interactions, which will be crucial for understanding system performance in relation to user engagement without affecting existing functionality.

Highlights

  • New Telemetry Components: Introduces ActivityType enum and ActivityDetector class to track user activity states for future performance monitoring.
  • ActivityType Enum: Defines various user activity types such as USER_INPUT_START, TOOL_CALL_SCHEDULED, and STREAM_END.
  • ActivityDetector: Implements logic to track user activity timing and state transitions with a configurable idle timeout.
  • Comprehensive Testing: Includes 18 new unit tests to ensure the correct functionality of the ActivityDetector and its global functions.
  • API Exposure: The new APIs are exposed minimally via the telemetry index, with no changes to CLI or runtime behavior elsewhere.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an ActivityDetector and an ActivityType enum to track user activity for future performance monitoring. The implementation is clean and comes with a comprehensive set of unit tests. The new APIs are correctly exposed through the main telemetry index file. I have one suggestion regarding the global activity detector's initialization logic to prevent potential bugs related to configuration.

@gemini-cli gemini-cli bot added kind/enhancement priority/p2 Important but can be addressed in a future release. labels Sep 9, 2025
@eLyiN eLyiN changed the title feat(telemetry): add activity types and detector with tests [Part 2/4] feat(telemetry): add activity detector with user interaction tracking Sep 9, 2025
@eLyiN eLyiN marked this pull request as draft September 9, 2025 21:02
@eLyiN eLyiN changed the title [Part 2/4] feat(telemetry): add activity detector with user interaction tracking [Part 2/6] feat(telemetry): add activity detector with user interaction tracking Sep 9, 2025
@eLyiN eLyiN force-pushed the split/activity-detector branch from cc94d31 to 41ce061 Compare September 10, 2025 06:08
@eLyiN eLyiN marked this pull request as ready for review September 10, 2025 06:09
@eLyiN
Copy link
Copy Markdown
Contributor Author

eLyiN commented Sep 10, 2025

@jacob314 ready for review

Copy link
Copy Markdown
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

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

approved once the minor comments are addressed. Not a huge fan of this requiring an initialize method and being nullable unless there is a strong case for it.

@eLyiN eLyiN force-pushed the split/activity-detector branch 2 times, most recently from b093665 to fede57a Compare September 11, 2025 14:58
@eLyiN eLyiN requested a review from jacob314 September 11, 2025 14:59
Prevents subtle bug where first call to recordUserActivity locks in the default idle threshold, causing later initializeActivityDetector(customTimeout) to be ignored.

recordUserActivity now only acts on an existing global detector (mirrors isUserActive); initialization is explicit to ensure correct configuration.

Updates the unit test to assert no implicit initialization occurs.
… and improve tests

Remove the initializeActivityDetector function and ensure the global activity detector is eagerly created. Update tests to use fake timers consistently.
@eLyiN eLyiN force-pushed the split/activity-detector branch from fede57a to f2ba1ea Compare September 15, 2025 19:00
Copy link
Copy Markdown
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

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

lgtm

@jacob314 jacob314 added this pull request to the merge queue Sep 17, 2025
Merged via the queue into google-gemini:main with commit 407373d Sep 18, 2025
40 of 42 checks passed
nagendrareddy10 pushed a commit to nagendrareddy10/gemini-cli that referenced this pull request Sep 22, 2025
yashv6655 added a commit to yashv6655/gemini-cli that referenced this pull request Sep 22, 2025
giraffe-tree pushed a commit to giraffe-tree/gemini-cli that referenced this pull request Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority/p2 Important but can be addressed in a future release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants