Skip to content

Fix occasional assembly mislogging - #1696

Open
SeradedStripes wants to merge 1 commit into
hackclub:mainfrom
SeradedStripes:fix-occasional-assembly-mislogging
Open

Fix occasional assembly mislogging#1696
SeradedStripes wants to merge 1 commit into
hackclub:mainfrom
SeradedStripes:fix-occasional-assembly-mislogging

Conversation

@SeradedStripes

Copy link
Copy Markdown
Contributor

Summary of the problem

Editors like Zed Sometimes send "RGBDS Assembly" as the language for .asm files. Since that string isn't in languages.yml or languges_custom.yml, it was stored as is, instead of mapping to Assembly.

Describe your changes

Previously, normalize_direct_heartbeat only fell back to extension detection when the client language was blank or unknown. Now it also falls back whenever the client language isn't recognized.

Comes with 2 tests to verify unrecognized client languages are replaced using extension detection and one to verify recognized languages are still preserved.

Screenshots / Media

N/A

@SeradedStripes
SeradedStripes force-pushed the fix-occasional-assembly-mislogging branch from 5163a95 to 8751485 Compare September 7, 2026 11:40
@SeradedStripes
SeradedStripes force-pushed the fix-occasional-assembly-mislogging branch from 8751485 to f24b68d Compare September 7, 2026 11:40
@SeradedStripes SeradedStripes reopened this Sep 7, 2026
@SeradedStripes
SeradedStripes marked this pull request as ready for review September 7, 2026 11:53
@greptile-apps

greptile-apps Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR changes direct heartbeat normalization so unrecognised client-provided language names fall back to entity-based detection and adds service-level regression coverage.

  • Corrects values such as RGBDS Assembly for .asm files.
  • Preserves configured client languages during normal direct ingestion.
  • Needs to preserve the semantics of resolved last-language placeholders.

Confidence Score: 4/5

The PR should not merge until resolved last-language placeholders are protected from being replaced using the current entity's extension.

The new recognition gate runs after placeholder resolution, so an unrecognised historical language can be replaced with an unrelated extension-derived language and alter both stored metadata and deduplication identity; the added preservation test also cannot detect unconditional fallback.

Files Needing Attention: app/services/heartbeat_ingest.rb, test/services/heartbeat_ingest_test.rb

Important Files Changed

Filename Overview
app/services/heartbeat_ingest.rb Adds recognition-gated language inference, but also reinterprets unrecognised values resolved from the last-language placeholder.
test/services/heartbeat_ingest_test.rb Covers the reported RGBDS case, although the preservation case does not distinguish preservation from extension fallback.
Prompt To Fix All With AI
### Issue 1
app/services/heartbeat_ingest.rb:107-108
**Placeholder language gets overwritten**

When `<<LAST_LANGUAGE>>` resolves to an unrecognised historical value, this check discards that value and infers a language from the current entity instead. For example, after an `RGBDS Assembly` heartbeat, a `.py` heartbeat using the placeholder is stored as Python rather than the requested last language. This also changes the heartbeat identity used for deduplication.

### Issue 2
test/services/heartbeat_ingest_test.rb:839-840
**Preservation test cannot distinguish fallback**

This test uses `language: "Assembly"` with an `.asm` entity, so it still passes if the implementation discards the recognised client language and falls back to extension detection. Use a recognised language that differs from the extension-derived language so the test actually verifies preservation.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "Fall back to extension detection for unr..." | Re-trigger Greptile

Comment on lines +107 to +108
known_language = attrs[:language] if LanguageUtils.find_name(attrs[:language])
inferred = LanguageUtils.fill_missing_language(known_language, entity: attrs[:entity])

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 Placeholder language gets overwritten

When <<LAST_LANGUAGE>> resolves to an unrecognised historical value, this check discards that value and infers a language from the current entity instead. For example, after an RGBDS Assembly heartbeat, a .py heartbeat using the placeholder is stored as Python rather than the requested last language. This also changes the heartbeat identity used for deduplication.

Knowledge Base Used: Heartbeat tracking and ingestion

Prompt To Fix With AI
This is a comment left during a code review.
Path: app/services/heartbeat_ingest.rb
Line: 107-108

Comment:
**Placeholder language gets overwritten**

When `<<LAST_LANGUAGE>>` resolves to an unrecognised historical value, this check discards that value and infers a language from the current entity instead. For example, after an `RGBDS Assembly` heartbeat, a `.py` heartbeat using the placeholder is stored as Python rather than the requested last language. This also changes the heartbeat identity used for deduplication.

**Knowledge Base Used:** [Heartbeat tracking and ingestion](https://app.greptile.com/mahadk/-/custom-context/knowledge-base/hackclub/hackatime/-/docs/heartbeat-tracking.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +839 to +840
entity: "src/main.asm",
language: "Assembly",

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.

P2 Preservation test cannot distinguish fallback

This test uses language: "Assembly" with an .asm entity, so it still passes if the implementation discards the recognised client language and falls back to extension detection. Use a recognised language that differs from the extension-derived language so the test actually verifies preservation.

Prompt To Fix With AI
This is a comment left during a code review.
Path: test/services/heartbeat_ingest_test.rb
Line: 839-840

Comment:
**Preservation test cannot distinguish fallback**

This test uses `language: "Assembly"` with an `.asm` entity, so it still passes if the implementation discards the recognised client language and falls back to extension detection. Use a recognised language that differs from the extension-derived language so the test actually verifies preservation.

---

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.

1 participant