Skip to content

Remap swapped macOS WakaTime Zed heartbeats - #1616

Open
skyfallwastaken wants to merge 2 commits into
mainfrom
fix/macos-wakatime-swapped-filenames
Open

Remap swapped macOS WakaTime Zed heartbeats#1616
skyfallwastaken wants to merge 2 commits into
mainfrom
fix/macos-wakatime-swapped-filenames

Conversation

@skyfallwastaken

Copy link
Copy Markdown
Member

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.

Copilot AI lite review requested due to automatic review settings August 20, 2026 13:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR extracts heartbeat field and language corrections into a dedicated remapper, then applies the macOS WakaTime/Zed correction to direct and imported ingestion.

  • Swaps entity and project for affected Zed and macOS WakaTime version combinations.
  • Re-infers language from the corrected filename while preserving legacy import hashes.
  • Adds unit and ingestion coverage for corrected and unaffected versions.

Confidence Score: 4/5

The 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

Filename Overview
app/lib/heartbeat_payload_remapper.rb Introduces version-gated field correction and language remapping, but omits the supported ZedPreview product alias.
app/services/heartbeat_ingest.rb Integrates the remapper into direct and imported normalization while preserving raw-source compatibility hashing.
app/lib/language_utils.rb Moves heartbeat-specific authoritative and fallback language policy out while retaining general language lookup utilities.
test/lib/heartbeat_payload_remapper_test.rb Covers normal affected and unaffected Zed products and language correction, but not the existing ZedPreview alias.
test/services/heartbeat_ingest_test.rb Adds durable-state coverage for direct and imported remapping and unaffected version boundaries.

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)]
Loading
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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 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.

Suggested change
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.

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.

Remap heartbeats for macos-wakatime swapped filenames

2 participants