Skip to content

Feature: warning for similar tags#2064

Open
hanbeex wants to merge 3 commits into
jrnl-org:developfrom
hanbeex:feat/check-similar-tags
Open

Feature: warning for similar tags#2064
hanbeex wants to merge 3 commits into
jrnl-org:developfrom
hanbeex:feat/check-similar-tags

Conversation

@hanbeex
Copy link
Copy Markdown

@hanbeex hanbeex commented Mar 4, 2026

Description

This PR adds a fuzzy tag similarity warning when writing a new journal entry. If any tag in the new entry closely resembles an existing tag in the journal, jrnl prints a warning suggesting the user double-check for typos.

Motivation: Tag typos silently fragment what should be a single tag group. For example, accidentally writing @works instead of @work results in two separate tags that are hard to notice and tedious to fix later. Surfacing this immediately after writing to make it easy to catch and correct.

What it does:

  • Before creating the new entry, the current set of existing tags is captured
  • After saving, the new entry's tags are compared against existing ones using difflib.get_close_matches with a similarity cutoff of 0.8
  • A warning is printed for each new tag that is suspiciously close to an existing one
  • Only tags sharing the same leading symbol are compared, so intentionally distinct tag namespaces (e.g. @ for people, # for topics) don't produce false positives — this also means custom tagsymbols from the config file are handled correctly
  • The warning is non-blocking: the entry is always saved, no confirmation prompt is shown

Only outputs a warning and doesn't ask 'Are you sure?' to the user Some similar-looking tags are perfectly meaningful to keep separate. For example, @health and @wealth, @friend and @fiend, or @hiking and @biking are all ≥80% similar but represent distinct concepts. Asking "are you sure?" every time would be more annoying than helpful.

Example output:

$ jrnl Today I finished the @works report

┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃  The tag '@works' is similar to: @work                                                                                                                       ┃
┃                                                                                                                                                                                            ┃
┃  Was this intentional? If not, re-open the entry with 'jrnl --edit' to fix it.                                                              ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

Files changed:

  • jrnl/controller.py - added _check_similar_tags() helper and hooked it into append_mode
  • jrnl/messages/MsgText.py - added SimilarTagsFound warning message
  • tests/unit/test_controller.py - added TestCheckSimilarTags with 8 unit tests
  • docs/usage.md - documented the warning and explained why no confirmation is shown
  • jrnl/__version__.py / pyproject.toml - fixed a pre-existing version string mismatch (v4.3 vs 4.3) that was causing 6 BDD test failures on the develop branch

Checklist

@hanbeex hanbeex changed the title Feat/check similar tags Feature: warning for similar tags Mar 5, 2026
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