Skip to content

fix: deduplicate default session path between cli and parser (#850)#858

Merged
microsasa merged 1 commit intomainfrom
fix/850-dedupe-default-session-path-9ace1a89fe449e2d
Apr 8, 2026
Merged

fix: deduplicate default session path between cli and parser (#850)#858
microsasa merged 1 commit intomainfrom
fix/850-dedupe-default-session-path-9ace1a89fe449e2d

Conversation

@microsasa
Copy link
Copy Markdown
Owner

Closes #850

Summary

cli._interactive_loop duplicated the default session-state path (Path.home() / ".copilot" / "session-state") instead of reusing the constant from parser.py. This created a latent bug: if the canonical default changed in one place but not the other, the Watchdog file observer would silently monitor the wrong directory.

Changes

  • parser.py: Rename _DEFAULT_BASEDEFAULT_SESSION_PATH (public Final constant), add to __all__
  • cli.py: Import DEFAULT_SESSION_PATH from parser, replace hardcoded literal
  • test_cli.py: Update two existing tests to monkeypatch the new name in both parser and cli modules
  • test_parser.py: Add TestDefaultSessionPath with two guards:
    1. Value matches Path.home() / ".copilot" / "session-state"
    2. Name is present in parser.__all__

No behaviour change — pure DRY refactor.

Generated by Issue Implementer · ● 10.9M ·

Rename _DEFAULT_BASE → DEFAULT_SESSION_PATH (public, exported) in
parser.py and import it in cli.py, replacing the hardcoded duplicate.
Update existing tests to patch the new name in both modules. Add
tests asserting the constant value and __all__ membership.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 8, 2026 08:48
@microsasa microsasa added the aw Created by agentic workflow label Apr 8, 2026
@microsasa microsasa enabled auto-merge April 8, 2026 08:48
Copy link
Copy Markdown

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 removes a duplicated default session-state directory path in the CLI by reusing a single canonical constant from the parser module, preventing silent divergence between the Watchdog observer path and session discovery.

Changes:

  • Exported DEFAULT_SESSION_PATH as a public Final constant from copilot_usage.parser and included it in parser.__all__.
  • Updated copilot_usage.cli._interactive_loop to use DEFAULT_SESSION_PATH instead of a hardcoded Path.home() / ".copilot" / "session-state" literal.
  • Updated and added tests to patch and assert the new exported constant.

Reviewed changes

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

File Description
src/copilot_usage/parser.py Introduces/export renaming to DEFAULT_SESSION_PATH and uses it for discovery/cache roots.
src/copilot_usage/cli.py Deduplicates the default session path by importing and using DEFAULT_SESSION_PATH.
tests/copilot_usage/test_cli.py Updates monkeypatching to patch DEFAULT_SESSION_PATH in both parser and CLI modules.
tests/copilot_usage/test_parser.py Adds guards verifying DEFAULT_SESSION_PATH value and presence in parser.__all__.

@microsasa microsasa added the aw-quality-gate-approved Quality gate approved the PR label Apr 8, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Low-impact DRY refactor — promotes _DEFAULT_BASE to public DEFAULT_SESSION_PATH, eliminates a duplicated path literal in cli.py, and adds guard tests. All CI checks green. Auto-approving for merge.

@microsasa microsasa merged commit 51c0a52 into main Apr 8, 2026
8 checks passed
@microsasa microsasa deleted the fix/850-dedupe-default-session-path-9ace1a89fe449e2d branch April 8, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aw Created by agentic workflow aw-quality-gate-approved Quality gate approved the PR

Projects

None yet

2 participants