Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/copilot_usage/vscode_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ class _VSCodeDiscoveryCache:
*newest_child_path* / *newest_child_id* store the most recently
modified immediate child at population time; re-stat'ing this single
sentinel on a hit detects new window directories added inside an
existing session. *child_ids* is recorded at population time and
retained for diagnostics but is not fully rescanned on cache hits.
existing session.

**Limitation:** only changes under the cached newest session directory
are detected by the sentinel. If a different (older) session directory
Expand All @@ -144,7 +143,6 @@ class _VSCodeDiscoveryCache:
"""

root_id: tuple[int, int] # (st_mtime_ns, st_size) of the logs root
child_ids: _ChildIds
newest_child_path: Path | None # most-recently-modified session dir
newest_child_id: tuple[int, int] | None # its identity at population
log_paths: tuple[Path, ...]
Expand Down Expand Up @@ -298,7 +296,6 @@ def _cached_discover_vscode_logs(base_path: Path | None) -> list[Path]:
found = sorted(candidate.glob(_GLOB_PATTERN))
_VSCODE_DISCOVERY_CACHE[candidate] = _VSCodeDiscoveryCache(
root_id=root_id,
child_ids=child_ids,
newest_child_path=newest_path,
newest_child_id=newest_id,
log_paths=tuple(found),
Expand Down
5 changes: 2 additions & 3 deletions tests/copilot_usage/test_vscode_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2716,7 +2716,6 @@ def test_cache_invalidated_on_root_mtime_change(self, tmp_path: Path) -> None:
cached = _VSCODE_DISCOVERY_CACHE[tmp_path]
_VSCODE_DISCOVERY_CACHE[tmp_path] = _VSCodeDiscoveryCache(
root_id=(cached.root_id[0] + 1_000_000_000, cached.root_id[1]),
child_ids=cached.child_ids,
newest_child_path=cached.newest_child_path,
newest_child_id=cached.newest_child_id,
log_paths=cached.log_paths,
Expand Down Expand Up @@ -2753,7 +2752,8 @@ def test_discovery_cache_populated(self, tmp_path: Path) -> None:
cached = _VSCODE_DISCOVERY_CACHE[tmp_path]
assert len(cached.log_paths) == 1
assert cached.root_id == safe_file_identity(tmp_path)
assert cached.child_ids == _scan_child_ids(tmp_path)
assert cached.newest_child_path is not None
assert cached.newest_child_id is not None

def test_new_window_under_existing_session_triggers_rediscovery(
self, tmp_path: Path
Expand Down Expand Up @@ -3267,7 +3267,6 @@ def test_field_reassignment_raises(self) -> None:
"""Assigning to a field after construction raises FrozenInstanceError."""
cache = _VSCodeDiscoveryCache(
root_id=(0, 0),
child_ids=frozenset(),
newest_child_path=None,
newest_child_id=None,
log_paths=(),
Expand Down
Loading