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: 2 additions & 3 deletions src/copilot_usage/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
render_session_detail,
render_summary,
)
from copilot_usage.vscode_parser import get_vscode_summary
from copilot_usage.vscode_report import render_vscode_summary

__all__: Final[list[str]] = [
"main",
Expand Down Expand Up @@ -592,9 +594,6 @@ def live(ctx: click.Context, path: Path | None) -> None:
)
def vscode(vscode_logs: Path | None) -> None:
"""Show usage from VS Code Copilot Chat logs."""
from copilot_usage.vscode_parser import get_vscode_summary
from copilot_usage.vscode_report import render_vscode_summary

c = Console()
_print_version_header(target=c)
summary = get_vscode_summary(vscode_logs)
Expand Down
18 changes: 18 additions & 0 deletions tests/copilot_usage/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4064,3 +4064,21 @@ def test_vscode_header_and_body_same_console(
assert "Copilot Usage" in output
assert f"v{__version__}" in output
assert "VS Code Copilot Chat" in output


# ---------------------------------------------------------------------------
# Regression: vscode imports are module-level (not deferred)
# ---------------------------------------------------------------------------


def test_vscode_imports_are_module_level() -> None:
"""``get_vscode_summary`` and ``render_vscode_summary`` are module-level imports.

Regression test for GitHub issue #1183: the ``vscode`` command previously
used lazy in-function imports, which deferred ``ImportError`` discovery to
invocation time instead of failing fast at process start.
"""
import copilot_usage.cli as cli_module

assert hasattr(cli_module, "get_vscode_summary")
assert hasattr(cli_module, "render_vscode_summary")
Loading