Commit graph

1 commit

Author SHA1 Message Date
Rod Boev
87f6e93c14
fix(dashboard): distinguish unavailable RTK from zero stats in Docker (#1900)
## Description

When headroom runs in Docker without `rtk` installed, the dashboard
shows `0` for every RTK/context-tool metric instead of indicating the
tool is unavailable. The backend already distinguishes the two states
(`context_tool.available` is `false` when `get_rtk_path()` returns
`None`), but the dashboard frontend never checked that field.

This adds a `cliFilteringAvailable` computed property that reads
`context_tool.available` from the stats payload. When the tool is
absent, the headline summary shows "RTK not installed" instead of "RTK 0
this session (0.0%)", and the detailed stats row shows "not installed"
instead of a zero count. When the tool is present, behavior is
unchanged.

Closes #1831

## Type of Change

- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring (no functional changes)

## Changes Made

- Added `cliFilteringAvailable` computed property to the Alpine.js
dashboard data object, reading `stats.context_tool?.available`
- Headline savings line: shows "RTK not installed" (dimmed) when the
tool is absent instead of "RTK 0 this session (0.0%)"
- Detailed stats breakdown: shows "not installed" for the session row
and hides the lifetime row when the tool is absent
- 5 new tests covering the `installed` flag propagation through
`_context_tool_zero_payload`, `_read_rtk_lifetime_stats`, and the
availability logic

## Testing

- [x] Unit tests pass (`uv run pytest
tests/test_rtk_docker_availability.py`)
- [x] Linting passes (`uv run ruff check .`)
- [ ] Type checking passes — N/A, dashboard is HTML/JS
- [x] New tests added for new functionality when applicable
- [x] Manual testing performed

### Test Output

```text
tests/test_rtk_docker_availability.py .....   [100%]
5 passed in 0.15s
```

## Real Behavior Proof

- Environment: Windows 11, Python 3.12, headroom from source
- Exact command: `uv run pytest tests/test_rtk_docker_availability.py
-q`
- Observed result: `_read_rtk_lifetime_stats()` returns
`installed=False` when `get_rtk_path()` is None, and the dashboard
template conditionally renders "not installed" based on
`cliFilteringAvailable`
- Not tested: live Docker deployment with the dashboard served over HTTP
(Playwright dashboard tests are CI-only)

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] I have updated the CHANGELOG.md if applicable

## Additional Notes

CHANGELOG.md not updated: the CI/CD release pipeline generates it from
conventional commits per maintainer policy. The dashboard rendering
change is frontend-only and the backend `context_tool.available` field
was already present.
2026-07-08 19:13:23 -07:00