fix(timeline): handle synced buckets where origin hostname contains underscores - #970
Conversation
…nderscores
The old regex /^([^_]+)_.*-synced-from-(.+)$/ failed for bucket ids like
'aw-watcher-android-synced-from-my_phone': [^_]+ consumed 'my_phone' as the
host separator, leaving no '-synced-from-' to match in the tail 'phone'.
Replace the regex with an indexOf('-synced-from-') search, which finds the
marker regardless of whether the origin hostname contains underscores. The base
part's optional '_<hostname>' suffix is then stripped separately.
Regression test added for the reported case from ActivityWatch#967.
Fixes ActivityWatch#967
Git-Session-Id: 400a
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #970 +/- ##
==========================================
+ Coverage 51.99% 52.08% +0.08%
==========================================
Files 48 48
Lines 2927 2932 +5
Branches 652 681 +29
==========================================
+ Hits 1522 1527 +5
+ Misses 1385 1322 -63
- Partials 20 83 +63 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Greptile SummaryThis PR corrects timeline labels for synced buckets whose origin hostname contains underscores.
Confidence Score: 5/5The PR appears safe to merge, with the reported synced-bucket label case handled without weakening output escaping. The new parsing correctly separates the bucket at the synced marker, preserves underscores in the remote hostname, strips the optional local hostname independently, and retains escaping for every interpolated value. Important Files Changed
Reviews (1): Last reviewed commit: "fix(timeline): handle synced buckets whe..." | Re-trigger Greptile |
|
CI-green and mergeable (Greptile 5/5) — waiting only on a maintainer click. This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted. |
Problem
Bucket IDs like
aw-watcher-android-synced-from-my_phonewere rendered incorrectly. The formatted label showedandroid-synced-from-myinstead of something likeaw-watcher-android (synced from my_phone).Closes #967
Root cause
The synced-bucket detection used a regex
/^([^_]+)_.*-synced-from-(.+)$/:[^_]+matches characters up to the first underscoreaw-watcher-android-synced-from-my_phone, the first_is inside the origin hostname (my_phone), so[^_]+consumedaw-watcher-android-synced-from-myphone, which doesn't contain-synced-from-, so the regex never matchedshortenBucketLabel(), which cut at the first_to yieldandroid-synced-from-myFix
Replace the regex with a direct
indexOf('-synced-from-')search. This detects the marker regardless of whether the origin hostname contains underscores. The base part's optional_<hostname>suffix is then stripped separately (needed for desktop buckets likeaw-watcher-window_host-synced-from-...).Changes
src/util/timelineLabels.ts: replace regex withindexOfapproachtest/unit/timelineLabels.test.node.ts: add regression for the reported caseAll 10 existing tests still pass; the new test covers the previously broken case.