Skip to content
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

Timeline category colors #609

Merged
merged 7 commits into from
Aug 19, 2024

Conversation

davidfraser
Copy link
Contributor

@davidfraser davidfraser commented Aug 15, 2024

This is a first draft of supporting using category colors for the main Timeline view.
It still contains some verbose logging...

See ActivityWatch/activitywatch#573 which was a request for this which was closed stale, and #257 which listed it as follow-up work.


🚀 This description was created by Ellipsis for commit 6f5581b

Summary:

Introduced category-based coloring for timeline events in src/util/color.ts and updated src/visualizations/VisTimeline.vue to apply these colors.

Key points:

  • Added getCategoryColorFromEvent in src/util/color.ts for category-based event coloring.
  • Updated src/visualizations/VisTimeline.vue to use getCategoryColorFromEvent for event colors.
  • Handles bucket types: currentwindow, web.tab.current, afkstatus, app.editor, general.stopwatch.
  • Introduced verbose logging in getCategoryColorFromString for debugging.

Generated with ❤️ by ellipsis.dev

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to e196a24 in 16 seconds

More details
  • Looked at 63 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_sICZrxzAXYYCxAZ3


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

src/util/color.ts Outdated Show resolved Hide resolved
@davidfraser
Copy link
Contributor Author

I've also checked running tests, and they pass - though I haven't added new tests for this code:

Test Suites: 7 passed, 7 total
Tests:       16 passed, 16 total
Snapshots:   2 passed, 2 total
Time:        109.462 s
Ran all test suites in 2 projects.

@davidfraser davidfraser marked this pull request as draft August 15, 2024 13:18
Copy link
Member

@ErikBjare ErikBjare left a comment

Choose a reason for hiding this comment

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

This looks pretty good!

I might forget about this PR, but I'd love to see it merge, so do ping me when you're ready for review/merge!

Copy link

codecov bot commented Aug 17, 2024

Codecov Report

Attention: Patch coverage is 7.69231% with 12 lines in your changes missing coverage. Please review.

Project coverage is 25.98%. Comparing base (e6ad4cd) to head (cd3fee8).
Report is 1 commits behind head on master.

Files Patch % Lines
src/util/color.ts 7.69% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #609      +/-   ##
==========================================
- Coverage   26.13%   25.98%   -0.15%     
==========================================
  Files          27       27              
  Lines        1630     1643      +13     
  Branches      273      292      +19     
==========================================
+ Hits          426      427       +1     
+ Misses       1178     1157      -21     
- Partials       26       59      +33     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@RTnhN
Copy link

RTnhN commented Aug 19, 2024

@davidfraser I just tried this, and it works great on my machine. I think that it is a good solution to #604. I would be happy with merging something like it.

@davidfraser davidfraser marked this pull request as ready for review August 19, 2024 13:31
@davidfraser davidfraser changed the title WIP: Timeline category colors Timeline category colors Aug 19, 2024
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Reviewed everything up to 6f5581b in 52 seconds

More details
  • Looked at 48 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. src/util/color.ts:130
  • Draft comment:
    Loading classes on every call can be inefficient. Consider caching the result of loadClasses() to improve performance.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is misplaced as it refers to a potential optimization in getCategoryColorFromString, not getCategoryColorFromEvent. The comment should be associated with the function where loadClasses() is actually called. Since the comment is not relevant to the line it is placed on, it should be removed.
    I might be missing the context in which the comment was added. Perhaps the tool mistakenly placed it on the wrong line, but the suggestion itself could still be valid for another part of the code.
    Even if the suggestion is valid, it is not relevant to the line it is placed on. The comment should be removed from this location and potentially added to the correct location if necessary.
    Remove the comment as it is not relevant to the line it is placed on. It refers to a different function and is misplaced.
2. src/util/color.ts:136
  • Draft comment:
    Consider documenting why getColorFromString is used for afkstatus instead of getCategoryColorFromString for consistency.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The getCategoryColorFromEvent function in color.ts uses getCategoryColorFromString for most cases, except for afkstatus where it uses getColorFromString. This inconsistency should be clarified or documented.
3. src/visualizations/VisTimeline.vue:119
  • Draft comment:
    Consider implementing flooding or another method to handle short events for improved performance, as suggested by the TODO comment.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is suggesting a performance improvement based on a TODO in the code. However, the diff does not change the logic related to short events, so the comment is not directly related to the changes made in this PR. The comment is more of a suggestion for future work rather than a necessary change for this PR.
    The comment might be useful for future improvements, but it does not address a specific issue in the current PR. It could be seen as informative rather than actionable for this specific change.
    While the comment is informative, it does not point out a necessary change for the current PR. It is more of a suggestion for future consideration.
    The comment should be removed as it does not address a necessary change in the current PR and is more of a suggestion for future improvements.

Workflow ID: wflow_TSTSzmbKpBbwET09


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@davidfraser
Copy link
Contributor Author

This looks pretty good!

I might forget about this PR, but I'd love to see it merge, so do ping me when you're ready for review/merge!

Thanks @ErikBjare ! I'm happy with this from my side - just changed some quoting to please the linter - so shout with any other things you think should be addressed...

src/util/color.ts Outdated Show resolved Hide resolved
Copy link
Member

@ErikBjare ErikBjare left a comment

Choose a reason for hiding this comment

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

I found one issue, but tbh I don't know what to do about it, so I'm going to just leave that comment there and maybe deal with it before release.

@ErikBjare ErikBjare merged commit 0cf7831 into ActivityWatch:master Aug 19, 2024
8 checks passed
@ErikBjare
Copy link
Member

Thanks a lot for this contribution @davidfraser! ❤️

I must admit I am a bit shocked it was this easy the whole time, some excellent low-hanging fruit you picked!

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.

3 participants