Skip to content

fix: treat watchdog as always-on hard dependency (#31)#33

Merged
microsasa merged 2 commits intomainfrom
fix/31-watchdog-always-on-31306306cc2edd94
Mar 14, 2026
Merged

fix: treat watchdog as always-on hard dependency (#31)#33
microsasa merged 2 commits intomainfrom
fix/31-watchdog-always-on-31306306cc2edd94

Conversation

@microsasa
Copy link
Owner

Closes #31

Problem

watchdog>=4 is listed as a hard production dependency in pyproject.toml, but two places treat it as optional:

  1. Dead except ImportError guard in _start_observer — unreachable because watchdog is always installed
  2. Misleading README — tells users to run uv add watchdog for a feature that's always active
  3. _stop_observer getattr dance — unnecessary indirection since the watchdog API is always present

Solution (Option B — always-on)

  • cli.py: Import Observer at module top level; remove try/except ImportError in _start_observer; simplify _stop_observer to call .stop() / .join() directly
  • README.md: Replace conditional phrasing with "The display auto-refreshes when session files change (2-second debounce)."
  • implementation.md / plan.md: Remove "if watchdog is installed" language from docs

Tests

  • Added test_start_observer_returns_running_observer — asserts _start_observer returns a non-None, alive observer for an existing directory, then cleans up via _stop_observer

Generated by Issue Implementer ·

Warning

⚠️ Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • astral.sh
  • pypi.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "astral.sh"
    - "pypi.org"

See Network Configuration for more information.

- Move Observer import to module top level, remove dead except ImportError guard
- Simplify _stop_observer to call .stop()/.join() directly (no getattr dance)
- Fix README: remove misleading 'uv add watchdog' conditional phrasing
- Update implementation.md and plan.md docs to remove optional language
- Add test_start_observer_returns_running_observer unit test

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aligns the codebase and documentation with the fact that watchdog>=4 is a hard production dependency, removing now-dead “optional dependency” handling and clarifying auto-refresh behavior.

Changes:

  • Simplifies watchdog observer lifecycle in the CLI by importing Observer at module scope and removing dead ImportError/getattr indirection.
  • Updates README and internal docs to describe auto-refresh as always-on (with the existing 2s debounce).
  • Adds a unit test to assert _start_observer returns a running observer and cleans it up via _stop_observer.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/copilot_usage/cli.py Makes watchdog observer usage unconditional and simplifies start/stop logic.
tests/copilot_usage/test_cli.py Adds coverage for starting/stopping the watchdog observer.
README.md Removes misleading optional-install instructions for watchdog.
src/copilot_usage/docs/plan.md Removes “if watchdog is installed” phrasing from the plan.
src/copilot_usage/docs/implementation.md Updates the observer description to match always-on behavior and existing directory check.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Use object types for observer (watchdog has no type stubs) with
type: ignore on method calls. Fixes CI failure on PR #33.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsasa microsasa marked this pull request as ready for review March 14, 2026 07:42
@microsasa microsasa merged commit d880fd7 into main Mar 14, 2026
4 checks passed
@microsasa microsasa deleted the fix/31-watchdog-always-on-31306306cc2edd94 branch March 16, 2026 07:08
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.

[aw][code health] watchdog hard-dep treated as optional: dead ImportError guard and misleading README

2 participants