Skip to content

fix(timeline): handle synced buckets where origin hostname contains underscores - #970

Open
TimeToBuildBob wants to merge 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/synced-label-hostname-underscores
Open

fix(timeline): handle synced buckets where origin hostname contains underscores#970
TimeToBuildBob wants to merge 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/synced-label-hostname-underscores

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Problem

Bucket IDs like aw-watcher-android-synced-from-my_phone were rendered incorrectly. The formatted label showed android-synced-from-my instead of something like aw-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 underscore
  • For aw-watcher-android-synced-from-my_phone, the first _ is inside the origin hostname (my_phone), so [^_]+ consumed aw-watcher-android-synced-from-my
  • The rest was just phone, which doesn't contain -synced-from-, so the regex never matched
  • The code fell through to shortenBucketLabel(), which cut at the first _ to yield android-synced-from-my

Fix

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 like aw-watcher-window_host-synced-from-...).

Changes

  • src/util/timelineLabels.ts: replace regex with indexOf approach
  • test/unit/timelineLabels.test.node.ts: add regression for the reported case

All 10 existing tests still pass; the new test covers the previously broken case.

…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

codecov Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.08%. Comparing base (a2ca625) to head (842a17a).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@greptile-apps

greptile-apps Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR corrects timeline labels for synced buckets whose origin hostname contains underscores.

  • Replaces the underscore-dependent regular expression with explicit synced-marker parsing.
  • Separately removes the source bucket’s optional hostname suffix.
  • Adds a regression test for aw-watcher-android-synced-from-my_phone.

Confidence Score: 5/5

The 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

Filename Overview
src/util/timelineLabels.ts Updates synced-bucket parsing while preserving label shortening, wrapping, and HTML escaping.
test/unit/timelineLabels.test.node.ts Adds focused coverage for a synced origin hostname containing an underscore.

Reviews (1): Last reviewed commit: "fix(timeline): handle synced buckets whe..." | Re-trigger Greptile

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

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.

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.

Timeline: synced bucket labels truncate the origin hostname at the first underscore

1 participant