Remap swapped macOS WakaTime Zed heartbeats - #1616
Conversation
Greptile SummaryThe PR extracts heartbeat field and language corrections into a dedicated remapper, then applies the macOS WakaTime/Zed correction to direct and imported ingestion.
Confidence Score: 4/5The PR should not merge until affected Zed Preview user agents are included in the remapping condition. A supported Zed Preview user-agent format falls within the affected client versions but cannot satisfy the literal Zed product match, leaving its entity and project swapped after ingestion. Files Needing Attention: app/lib/heartbeat_payload_remapper.rb and test/lib/heartbeat_payload_remapper_test.rb Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Direct or imported heartbeat] --> B[Resolve user agent]
B --> C{Affected Zed and macOS WakaTime versions?}
C -->|Yes| D[Swap entity and project]
C -->|No| E[Preserve fields]
D --> F[Resolve placeholders and infer language]
E --> F
F --> G[Validate and generate fields hash]
G --> H[(Persist heartbeat)]
Prompt To Fix All With AI### Issue 1
app/lib/heartbeat_payload_remapper.rb:28
**Zed Preview remapping is skipped**
When an affected client identifies itself as `ZedPreview`, the literal `Zed/` lookup returns no version and skips the field correction, causing persisted filenames and project names to remain swapped and language inference to use the project name.
```suggestion
zed_version = product_version(user_agent, "Zed") || product_version(user_agent, "ZedPreview")
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "Extract heartbeat payload remapping" | Re-trigger Greptile |
| def self.remap_macos_wakatime_zed_fields!(attributes, user_agent:) | ||
| return unless attributes[:type] == "app" | ||
|
|
||
| zed_version = product_version(user_agent, "Zed") |
There was a problem hiding this comment.
Zed Preview remapping is skipped
When an affected client identifies itself as ZedPreview, the literal Zed/ lookup returns no version and skips the field correction, causing persisted filenames and project names to remain swapped and language inference to use the project name.
| zed_version = product_version(user_agent, "Zed") | |
| zed_version = product_version(user_agent, "Zed") || product_version(user_agent, "ZedPreview") |
Knowledge Base Used: Heartbeat Ingest
Prompt To Fix With AI
This is a comment left during a code review.
Path: app/lib/heartbeat_payload_remapper.rb
Line: 28
Comment:
**Zed Preview remapping is skipped**
When an affected client identifies itself as `ZedPreview`, the literal `Zed/` lookup returns no version and skips the field correction, causing persisted filenames and project names to remain swapped and language inference to use the project name.
```suggestion
zed_version = product_version(user_agent, "Zed") || product_version(user_agent, "ZedPreview")
```
**Knowledge Base Used:** [Heartbeat Ingest](https://app.greptile.com/mahadk/-/custom-context/knowledge-base/hackclub/hackatime/-/docs/heartbeat-ingest.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Summary of the problem
macos-wakatime versions before 5.28.5-alpha.1 swapped Zed project names and filenames after Zed 0.162.0 changed its title format.
Closes #1586
Describe your changes
Remap affected direct and imported heartbeats using the Zed and macos-wakatime versions in their plugin metadata. Keep unaffected versions unchanged and infer language from the corrected filename.
Move heartbeat-specific field and language corrections into a dedicated payload remapper so ingestion remains focused on orchestration and persistence.
Screenshots / Media
No visual changes.