Skip to content

fix(research): retain approved application names - #1431

Merged
ErikBjare merged 2 commits into
ActivityWatch:masterfrom
TimeToBuildBob:fix/research-retain-app-names
Sep 7, 2026
Merged

fix(research): retain approved application names#1431
ErikBjare merged 2 commits into
ActivityWatch:masterfrom
TimeToBuildBob:fix/research-retain-app-names

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Why

Lund/IIIEE has now confirmed the Research Edition data contract: application
names (including browser identity) may be stored, but browser URLs may not be
stored and must be reduced to study categories instead. The current build does
the opposite for desktop apps by replacing their names with categories.

This selects the already-designed retain-names branch before the next Research
Edition release. Tracking context: ErikBjare/bob#1108.

What changed

  • leave research_app_category_map empty in release builds, so the watcher
    keeps approved app names while still dropping non-browser titles and URLs;
  • keep the URL/title category map, so recognized browsers retain only their app
    identity plus a study-category title;
  • derive the web UI preset from exact app aliases as well as stored category
    labels, so Top Applications can show Word/Spotify/Teams while Top Categories still uses the study taxonomy;
  • allow retained app names through the fail-closed export sanitizer while it
    continues to reject every URL and every non-category window title;
  • apply that sanitizer to the manylinux Research build too, closing the third
    build-matrix gap.

Unknown app names remain visible and Uncategorized; the preset deliberately
does not use a catch-all that would overlap every specific category rule.

Validation

  • 45 passed across scripts/tests/test_*.py
  • Ruff lint and format checks pass on the changed Python files
  • rustfmt --check --edition 2021 passes
  • release workflow parses as YAML
  • live pinned-watcher contract test proves:
    • Microsoft Word is retained while its raw title/URL are dropped;
    • Safari + a private Google Docs URL becomes {app: Safari, title: Work & Productivity} with no URL.

@greptile-apps

greptile-apps Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR updates the Research Edition data flow to retain approved application names while continuing to remove URLs and raw window titles.

  • Leaves the watcher application-category map explicitly empty, including during upgrades from configurations with legacy mappings.
  • Generates web UI category rules from both study-category labels and exact application aliases.
  • Allows retained application names through the export sanitizer while preserving URL and title safeguards.
  • Applies export sanitization across all Research Edition release targets.
  • Adds regression coverage for watcher storage, preset categorization, legacy configuration upgrades, and the release build matrix.

The previous finding about legacy application mappings surviving an upgrade is fully addressed by emitting an explicit empty research_app_category_map.

Confidence Score: 5/5

The PR appears safe to merge, with the prior upgrade-path defect fully corrected and no new actionable issues identified.

The explicit empty application-category table replaces stale legacy mappings during the key-by-key configuration merge, while the accompanying tests verify retained application names and continued removal of raw browser content. No outstanding previous finding or accepted new issue remains.

Important Files Changed

Filename Overview
scripts/patch_research_edition_config.py Enables browser categorization while explicitly clearing legacy application mappings so approved names remain stored.
scripts/emit_research_category_preset.py Generates exact case-insensitive category rules covering both stored category labels and approved application aliases.
scripts/research_edition/export_sanitize.rs Permits application names while continuing to reject URLs and non-category current-window titles.
.github/workflows/release.yml Applies export sanitization to the previously uncovered manylinux Research Edition build.
scripts/tests/test_patch_research_edition_config.py Covers explicit legacy-map clearing and validates the pinned watcher’s intended storage contract.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Window event] --> B[Research watcher filter]
    B -->|Non-browser application| C[Retain app name]
    B -->|Recognized browser| D[Retain browser identity]
    D --> E[Replace title with study category]
    C --> F[Remove raw title and URL]
    E --> G[Remove URL]
    F --> H[Export sanitizer]
    G --> H
    H --> I[Rewrite hostname and bucket identity]
    I --> J[Research export]
    C --> K[Web UI preset]
    E --> K
    K --> L[Study taxonomy views]
Loading

Reviews (2): Last reviewed commit: "fix(research): emit explicit empty app-c..." | Re-trigger Greptile

f"[research_category_map]\n{entries}\n\n"
f"[research_app_category_map]\n{app_entries}"
)
block = f"research_enabled = true\n\n[research_category_map]\n{entries}"

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 Stale app map survives

The generated post-#137 defaults omit research_app_category_map. Because these defaults are merged into the watcher configuration key by key, an upgrade from an earlier Research Edition can retain its previously populated app map. Those installations will continue replacing application names with categories, so this fix will not retain application names for existing participants. Add an empty table to explicitly clear the old map.

Suggested change
block = f"research_enabled = true\n\n[research_category_map]\n{entries}"
block = (
"research_enabled = true\n\n"
f"[research_category_map]\n{entries}\n\n"
"[research_app_category_map]"
)

…remnants

An upgrade from an earlier Research Edition may have a populated
research_app_category_map saved in the user's config. Because research_defaults
is merged into [aw-watcher-window] key-by-key, omitting the empty table left
legacy entries intact and continued replacing app names with categories,
defeating the primary behavior change of this PR.

Add the empty [research_app_category_map] section to the post-ActivityWatch#137 block so the
watcher's key-by-key merge resets the key on upgrade.

Also update the post-ActivityWatch#137 test to assert the empty map is present (not absent),
and add a dedicated test that verifies the section header appears in the raw
defaults string.

Addresses Greptile 4/5 P1 finding (stale app map survives upgrade).
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

@greptileai review

@ErikBjare
ErikBjare merged commit e36a4e4 into ActivityWatch:master Sep 7, 2026
19 checks passed
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.

2 participants