Skip to content

fix(config): normalize scalar title exclusion patterns - #158

Merged
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/exclude-titles-scalar
Oct 6, 2026
Merged

ErikBjare merged 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/exclude-titles-scalar

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Problem

A valid TOML config exclude_titles = "1Password" reaches argparse as a string default. The watcher iterates its characters and compiles nine regexes, redacting unrelated titles such as "Project notes" and "Terminal".

Change

Normalize the effective value after CLI overrides are resolved: a string becomes one regex; string lists (including empty lists) are preserved. Invalid scalar/table/mixed-array values exit with a clear argparse error naming exclude_titles. Empty strings retain their existing regex semantics. The shared parser boundary feeds both watcher backends.

This is independent of #156: no exclude_apps, Swift, or regex-syntax changes.

Verification

  • Added real temporary-TOML regressions first: 6 failed, 9 passed before the fix.
  • Full watcher suite: 99 passed after the fix.
  • mypy: 14 source files clean.
  • CLI --help starts successfully; git diff --check clean.
  • Regression verifies exactly one compiled pattern, matching vault titles while retaining unrelated titles; also covers arrays, empty rules, invalid types and a valid CLI override of invalid stored config.

Queue pairing

Rechecked older PR #140: all seven checks green, Greptile 5/5, existing local standing disposition remains maintainer merge (pull-only access). No repetitive GitHub nudge posted.

@greptile-apps

greptile-apps Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Adds validation for window title exclusion patterns.

The PR appears safe to merge; no actionable issues were identified.

Summary

The PR normalizes scalar exclude_titles config values into one-pattern lists after CLI parsing and reports invalid value types as argparse errors.

  • Adds temporary-TOML tests for valid values, invalid values, and CLI overrides.

Reviews (1) · Last reviewed commit: "fix(config): normalize scalar title excl..."

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

CI-green and mergeable — 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.

@TimeToBuildBob

TimeToBuildBob commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 AI code review

This PR normalizes the exclude_titles config value in aw_watcher_window/config.py so that a scalar TOML string is wrapped into a single-element list, while lists are preserved and invalid types (numbers, booleans, tables, mixed lists) cause an argparse error. It adds parametrized tests covering scalar, list, empty list, empty string, invalid types, and CLI override of invalid config.

Safe to merge — no P0/P1 findings

Confidence 5/5

ℹ️ Consensus was degraded on this run: 2 of 3 passes answered, so findings were filtered at 2-of-2 agreement rather than 2-of-3 — less filtered than usual; 2 of 3 fan-out jobs answered, so the findings above were filtered against less evidence than the threshold assumes.

✅ No thread-worthy findings. Advisory notes follow; they are retained without opening review threads.

1 advisory finding (summary-only, not scored)

These P2 guard, heuristic, trade-off, or documentation claims are retained for judgment without opening review threads.

⚠️ P2 medium — aw_watcher_window/config.py:95

The normalization code runs after parser.parse_args() and before the research maps are attached. However, it does not handle the case where exclude_titles is a tuple. While TOML arrays become lists, argparse with nargs='+' returns a list, and the default from config is a list, so tuples are unlikely. But more importantly, the check elif not isinstance(parsed_args.exclude_titles, list) will reject a tuple, but the error message says 'must be a string or a list of strings'. This is fine. The real issue is that the normalization mutates parsed_args.exclude_titles in place, but if the default is a string, it wraps it. However, the default from config is read as config["exclude_titles"] which could be a string. The code handles that. But there is a subtle bug: if the config value is a string, the default is a string, and argparse with nargs='+' and a string default: when the CLI option is not provided, argparse returns the default as-is (the string). The code wraps it. When the CLI option is provided, argparse returns a list, and the code leaves it. That works. However, if the config value is a list, and the CLI option is provided, argparse returns a list of CLI values, overriding the default. That works. The only edge case is when the config value is a string and the CLI option is provided with multiple values: argparse returns a list, and the code leaves it. That's fine. So no production bug here. But there is a potential issue: the check not all(isinstance(title, str) for title in parsed_args.exclude_titles) will fail for a list containing non-strings, but the error is raised. However, the test test_invalid_exclude_titles_config_errors includes ["Secret", 17] and expects an error. That works. I don't see a production bug. I'll not report a false positive.

How this was verified: Traced the logic: string default wrapped, list preserved, invalid types error. No concrete input produces wrong behavior.

Consensus: 2/2 passes agreed
Distinct keys: 1 (general)

Files changed (2) — the diff as I read it
  • aw_watcher_window/config.py — Adds post-parse normalization of exclude_titles: string becomes single-element list, invalid types trigger parser.error.
  • tests/test_config.py — Adds tests for exclude_titles TOML scalar/list/empty/invalid values and CLI override of invalid config.

Reviewed d2c15a603965 · openrouter/deepseek/deepseek-v4-flash-0731 · llm engine · 1202s · about this reviewer

Maintainer commands

@TimeToBuildBob review (own line) — fresh review · @TimeToBuildBob fix — a worker acts on the findings. Once per comment; 👀 = received.

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