Skip to content

[aw][test audit] render_detail: untested branches in _build_event_details — SESSION_SHUTDOWN falsy type and TOOL_EXECUTION mod [Content truncated due to length] #860

@microsasa

Description

@microsasa

Summary

Two code branches in render_detail._build_event_details are never exercised by the current test suite, so regressions there can't be caught by CI.


Gap 1 — SESSION_SHUTDOWN with shutdownType=None

Location: src/copilot_usage/render_detail.py:156

case EventType.SESSION_SHUTDOWN:
    if (data := _safe_event_data(ev, ev.as_session_shutdown)) is None:
        return ""
    return f"type={data.shutdownType}" if data.shutdownType else ""

SessionShutdownData.shutdownType is typed str | None, so the field is legitimately absent in some real events. When the field is None or "", the function returns "".

TestBuildEventDetails.test_session_shutdown_details only exercises the truthy case (shutdownType="routine"). The else branch (shutdownType is None"") has zero test coverage.

Expected test: An EVENT_TYPE.SESSION_SHUTDOWN event with a SessionShutdownData whose shutdownType is None (or omitted from the raw data dict) should make _build_event_details return "".


Gap 2 — TOOL_EXECUTION_COMPLETE with non-None model field

Location: src/copilot_usage/render_detail.py:149–150

if data.model:
    parts.append(f"model={data.model}")

ToolExecutionData.model is optional. When present it should appear in the detail string as model=<name>. All three existing TestBuildEventDetails tests for TOOL_EXECUTION_COMPLETE omit the model field from the raw dict, so the truthy branch is never reached.

Expected test: A TOOL_EXECUTION_COMPLETE event whose raw data includes "model": "claude-sonnet-4" should produce a details string containing "model=claude-sonnet-4".


Regression risk

Both are display-path branches — a silent regression would cause incorrect or missing information in copilot-usage session <id> detail output without failing any test. The branches are simple enough that a single parametrized test covers each case.

Generated by Test Suite Analysis · ● 8.6M ·

Metadata

Metadata

Assignees

No one assigned

    Labels

    awCreated by agentic workflowaw-dispatchedIssue has been dispatched to implementertest-auditTest coverage gaps

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions