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

"Cursor" editor and WSL2 OS not properly parsed from user-agent string #718

Open
Ocyss opened this issue Dec 18, 2024 · 5 comments
Open
Labels
bug Something isn't working effort:1 prio b

Comments

@Ocyss
Copy link

Ocyss commented Dec 18, 2024

Describe the bug
Currently, Wakapi is unable to properly detect and display Windows Subsystem for Linux (WSL) as the operating system and Cursor as the editor, while WakaTime supports both. This affects the accuracy of tracking and reporting development activity.

Expected behavior:

  • WSL should be properly detected and displayed as the operating system
  • Cursor editor should be recognized and tracked separately from VS Code

Actual behavior:

  • WSL environment is not properly identified
  • Cursor editor activities might be misclassified or not tracked correctly

Sample heartbeat data showing the environment:

[{
        "branch": "",
        "category": "coding",
        "cursorpos": 1,
        "type": "file",
        "lineno": 19,
        "lines": 19,
        "time": 1734507017.1071126,
        "user_agent": "wakatime/v1.106.1 (linux-5.15.167.4-microsoft-standard-WSL2-unknown) go1.23.3 cursor/1.93.1 vscode-wakatime/24.9.2"
    },
    {
        "branch": "main",
        "category": "coding",
        "cursorpos": 11,
        "type": "file",
        "language": "Vue.js",
        "lineno": 165,
        "lines": 168,
        "project_root_count": 6,
        "time": 1734507047.4709089,
        "user_agent": "wakatime/v1.106.1 (linux-5.15.167.4-microsoft-standard-WSL2-unknown) go1.23.3 cursor/1.93.1 vscode-wakatime/24.9.2"
    }]

System information

  • Wakapi version: v2.12.2 @ postgres
  • Operating system: WSL2 (Arch Linux) on Windows
    • Linux distro: Arch Linux 20240721.0.248532
    • Kernel: 5.15.167.4-microsoft-standard-WSL2
@muety
Copy link
Owner

muety commented Dec 18, 2024

Thanks for reporting this!

Given the above heartbeats, the editor is properly recognized as "Cursor" for me... 🤔 Can you send a screenshot that depicts the wrongly detected editor or possibly even an excerpt from your database's heartbeats table?

Regarding WSL: I'd actually argue resolving the OS to "Linux" is correct, because even though you're running Linux in a WSL 2 VM, it's still a Linux kernel and OS underneath (e.g. you wouldn't want to show "VirtualBox" as the OS when running Linux in a VirtualBox VM). But I'm open to be convinced otherwise. What does WakaTime show in this case?

@Ocyss
Copy link
Author

Ocyss commented Dec 19, 2024

Thanks for reporting this!

Given the above heartbeats, the editor is properly recognized as "Cursor" for me... 🤔 Can you send a screenshot that depicts the wrongly detected editor or possibly even an excerpt from your database's heartbeats table?

Regarding WSL: I'd actually argue resolving the OS to "Linux" is correct, because even though you're running Linux in a WSL 2 VM, it's still a Linux kernel and OS underneath (e.g. you wouldn't want to show "VirtualBox" as the OS when running Linux in a VirtualBox VM). But I'm open to be convinced otherwise. What does WakaTime show in this case?

Hi, thanks for your reply, I will be happy to provide relevant contextual data. This is a great project that allows me to master my own data.

image

image

Database json summary snippet
[
  {
    "id": 190684,
    "user_id": "Ocyss_04",
    "language": "Vue.js",
    "is_write": "t",
    "editor": "Vscode",
    "operating_system": "Linux",
    "machine": "Qwin",
    "user_agent": "wakatime/v1.106.1 (linux-5.15.167.4-microsoft-standard-WSL2-unknown) go1.23.3 cursor/1.93.1 vscode-wakatime/24.9.2",
    "time": "2024/12/18 15:06:46.366",
    "hash": "82c9a0744d3b2d95",
    "origin": "",
    "origin_id": "",
    "created_at": "2024/12/18 15:07:53.012",
    "lines": 184,
    "line_no": 163,
    "cursor_pos": 55,
    "line_deletions": 0,
    "line_additions": 0,
    "project_root_count": 6
  },
  {
    "id": 190685,
    "user_id": "Ocyss_04",
    "language": "Vue.js",
    "is_write": "t",
    "editor": "Vscode",
    "operating_system": "Linux",
    "machine": "Qwin",
    "user_agent": "wakatime/v1.106.1 (linux-5.15.167.4-microsoft-standard-WSL2-unknown) go1.23.3 cursor/1.93.1 vscode-wakatime/24.9.2",
    "time": "2024/12/18 15:06:51.562",
    "hash": "33f1b461d9a4232b",
    "origin": "",
    "origin_id": "",
    "created_at": "2024/12/18 15:07:53.012",
    "lines": 184,
    "line_no": 163,
    "cursor_pos": 55,
    "line_deletions": 0,
    "line_additions": 0,
    "project_root_count": 6
  },
  {
    "id": 190686,
    "user_id": "Ocyss_04",
    "language": "Vue.js",
    "is_write": "t",
    "editor": "Vscode",
    "operating_system": "Linux",
    "machine": "Qwin",
    "user_agent": "wakatime/v1.106.1 (linux-5.15.167.4-microsoft-standard-WSL2-unknown) go1.23.3 cursor/1.93.1 vscode-wakatime/24.9.2",
    "time": "2024/12/18 15:10:11.471",
    "hash": "d854777972fa5d82",
    "origin": "",
    "origin_id": "",
    "created_at": "2024/12/18 15:10:13.135",
    "lines": 103,
    "line_no": 61,
    "cursor_pos": 91,
    "line_deletions": 0,
    "line_additions": 0,
    "project_root_count": 6
  }
]

Regarding the OS detection, the underlying system is indeed consistent with Linux, so detecting it as Linux is technically correct. However, I recently migrated from WakaTime, where the operating system was identified as WSL. I believe this identification is more precise - whether it's for my own reference or for others reviewing the data, it clearly shows that I'm developing on WSL in Windows, Rather than just developing on Linux or Windows.

Running Linux in VirtualBox should indeed be identified as Linux from both a technical and user perspective since it's a complete and native Linux environment. However, WSL uses a specially optimized and modified kernel by Windows, making it a distinct case.

image

@muety
Copy link
Owner

muety commented Dec 19, 2024

Thanks for all the details, this will help me debug the issue a lot better. Last question regarding the heartbeats shown above: have they been generated while coding or as part of a data import from WakaTime?

@muety muety changed the title Feature Request: Add support for WSL and Cursor Editor detection "Cursor" editor and WSL2 OS not properly parsed from user-agent string Dec 19, 2024
@muety muety added bug Something isn't working prio b effort:1 labels Dec 19, 2024
@Ocyss
Copy link
Author

Ocyss commented Dec 19, 2024

Thanks for all the details, this will help me debug the issue a lot better. Last question regarding the heartbeats shown above: have they been generated while coding or as part of a data import from WakaTime?

I cloned the project for testing and found it's a version-related issue. Using the latest code, the editor displays correctly as Cursor. However, when I switched to the 2.12.2 tag, the editor was incorrectly shown as VSCode. Currently, my server is running Docker 2.12.2.

@muety
Copy link
Owner

muety commented Dec 19, 2024

Oh, right, my bad! I remembered to have fixed this issue (see b96db4e), but forgot that this change isn't yet included in a release. I'll go about the WSL issue and a few minor other ones in the upcoming days and then push a new release.

With the new version, all new heartbeats will have the correct editor set. To fix the editor also for already existing data retroactively, you can run the following query and afterwards do Regenerate Summaries under Settings.

update heartbeats set editor = 'Cursor' where editor = 'Vscode' and user_agent like '%cursor%';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working effort:1 prio b
Projects
None yet
Development

No branches or pull requests

2 participants