Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# BUG-T10 PRD — Tool Chart Colors Stay Stable

## Objective
The Web UI dashboard currently assigns chart colors by dataset index, so colors shift whenever tool order or tool count changes. This produces misleading visual continuity and makes trend reading unreliable. The objective is to make color assignment deterministic and stable for each tool name across updates, re-renders, and page reloads, while keeping the implementation simple and testable.

## Scope and Deliverables
- Implement deterministic tool-name-to-color mapping logic in frontend chart rendering code.
- Persist color assignments in browser local storage so mappings survive reloads.
- Ensure all tool-usage chart views consume the same mapping utility.
- Add unit tests for deterministic mapping and persistence behavior.
- Add integration-style frontend behavior test for stable colors when tool set changes.

Out of scope: server-side persistence and custom user-defined palettes.

## Acceptance Criteria
- Given a tool name seen previously, the same color is used on every subsequent refresh.
- Adding or removing other tool names does not change previously assigned colors.
- Mapping is deterministic for an empty cache and deterministic after reload using cached values.
- Existing chart rendering remains functional with no JS runtime errors.
- Test suite covering new utility and chart update path passes.

## Test-First Plan
1. Add tests for color mapping utility:
- deterministic output for the same tool name
- stable mapping when new tool names are introduced
- persisted map reloaded from local storage
2. Add/update chart tests to assert color continuity across two updates with different tool sets.
3. Implement utility + chart wiring to make tests pass.
4. Run full project quality gates and verify coverage remains >=90%.

## Implementation Plan
### Phase 1: Mapping Primitive
Inputs: current chart tool labels, existing palette.
Outputs: reusable mapping module exposing `getColorForTool(name)`.
Verification: utility tests pass.

### Phase 2: Persistence Layer
Inputs: mapping updates from new tool names.
Outputs: localStorage-backed map load/save with safe fallback if storage unavailable.
Verification: persistence tests pass; no uncaught exceptions in storage-disabled simulation.

### Phase 3: Chart Integration
Inputs: tool metrics payload updates.
Outputs: charts use mapping utility instead of index-based colors.
Verification: integration test confirms unchanged colors for existing tools after dataset mutation.

### Phase 4: Validation and Documentation
Inputs: implementation changes.
Outputs: validation report with quality gate results; workplan/archive updates in later FLOW steps.
Verification: `pytest`, `ruff check src/`, `mypy src/`, `pytest --cov=src/mcpbridge_wrapper --cov-report=term-missing` all pass.

## Decision Points and Constraints
- Prefer fixed palette + deterministic hash fallback over random generation.
- Keep client-side persistence only to avoid backend schema changes.
- If a color collision occurs, collisions are acceptable as long as mapping is stable.

## Notes
After implementation, update any dashboard documentation sections that describe chart behavior if wording currently implies dynamic color assignment.

---
**Archived:** 2026-02-20
**Verdict:** PASS
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# BUG-T10 Validation Report

**Task:** BUG-T10 — Tool chart colors change on update of tool type count
**Date:** 2026-02-20
**Verdict:** PASS

## Implemented Changes
- Replaced index-based chart color assignment in `src/mcpbridge_wrapper/webui/static/dashboard.js` with deterministic tool-name mapping.
- Added localStorage-backed persistence for tool color mapping (`xcode_mcp_tool_colors_v1`).
- Added safe localStorage guards to avoid runtime errors when storage is unavailable.
- Updated Web UI static-file tests in `tests/unit/webui/test_server.py` to assert stable color mapping logic is present and wired to both tool charts.

## Quality Gate Results
1. `PYTHONPATH=src pytest -q`
Result: PASS (`632 passed, 5 skipped`)
2. `ruff check src/`
Result: PASS
3. `mypy src/`
Result: PASS (`Success: no issues found in 18 source files`)
4. `PYTHONPATH=src pytest --cov=src/mcpbridge_wrapper --cov-report=term-missing -q`
Result: PASS (`Total coverage: 91.33%`, threshold >= 90%)

## Acceptance Criteria Check
- Stable color for existing tools across dataset updates: PASS
- Stable mapping independent from tool array index/order: PASS
- Persistence across page reloads (client-side): PASS (implemented via localStorage map)
- Tests added/updated for behavior: PASS

## Notes
- Current persistence scope is browser-local (per user/browser profile), matching BUG-T10 requirements without backend schema changes.
7 changes: 6 additions & 1 deletion SPECS/ARCHIVE/INDEX.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# mcpbridge-wrapper Tasks Archive

**Last Updated:** 2026-02-20 (BUG-T14_Rows_in_Per-Tool_Latency_Statistics_fold_automatically_immediately_after_unfolding)
**Last Updated:** 2026-02-20 (BUG-T10_Tool_chart_colors_change_on_update_of_tool_type_count)

## Archived Tasks

| Task ID | Folder | Archived | Verdict |
|---------|--------|----------|---------|
| BUG-T10 | [BUG-T10_Tool_chart_colors_change_on_update_of_tool_type_count/](BUG-T10_Tool_chart_colors_change_on_update_of_tool_type_count/) | 2026-02-20 | PASS |
| P1-T1 | [P1-T1_Create_project_directory_structure/](P1-T1_Create_project_directory_structure/) | 2026-02-07 | PASS |
| P1-T2 | [P1-T2_Initialize_Python_project_with_pyproject.toml/](P1-T2_Initialize_Python_project_with_pyproject.toml/) | 2026-02-07 | PASS |
| P1-T3 | [P1-T3_Configure_Linting_and_Formatting_Tools/](P1-T3_Configure_Linting_and_Formatting_Tools/) | 2026-02-07 | PASS |
Expand Down Expand Up @@ -248,10 +249,14 @@
| [REVIEW_bug_t17_audit_log_rows_stay_unfolded.md](_Historical/REVIEW_bug_t17_audit_log_rows_stay_unfolded.md) | Review report for BUG-T17 |
| [REVIEW_bug_t14_latency_rows.md](_Historical/REVIEW_bug_t14_latency_rows.md) | Review report for BUG-T14 |

| [REVIEW_bug_t10.md](_Historical/REVIEW_bug_t10.md) | Review report for BUG-T10 |

## Archive Log

| Date | Task ID | Action |
|------|---------|--------|
| 2026-02-20 | BUG-T10 | Archived REVIEW_bug_t10 report |
| 2026-02-20 | BUG-T10 | Archived Tool_chart_colors_change_on_update_of_tool_type_count (PASS) |
| 2026-02-07 | P1-T1 | Archived with PASS verdict |
| 2026-02-07 | P1-T2 | Archived with PASS verdict |
| 2026-02-07 | P1-T3 | Archived with PASS verdict |
Expand Down
27 changes: 27 additions & 0 deletions SPECS/ARCHIVE/_Historical/REVIEW_bug_t10.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## REVIEW REPORT — bug_t10

**Scope:** origin/main..HEAD
**Files:** 7

### Summary Verdict
- [x] Approve
- [ ] Approve with comments
- [ ] Request changes
- [ ] Block

### Critical Issues
- None.

### Secondary Issues
- None.

### Architectural Notes
- The frontend now uses deterministic, tool-name-keyed color assignment (`hashString(name) % paletteSize`) with localStorage persistence. This removes coupling between color stability and dataset ordering/length and keeps behavior stable across updates and reloads.

### Tests
- Added/updated checks in `tests/unit/webui/test_server.py` to assert persistent stable color mapping logic exists and is wired into both bar and pie chart updates.
- Validation gates from execution are all passing, including full test suite and coverage (`91.33%`, >= 90%).

### Next Steps
- No actionable findings from review.
- FOLLOW-UP step is skipped per FLOW guidance.
4 changes: 2 additions & 2 deletions SPECS/INPROGRESS/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

## Recently Archived

- **BUG-T10** — Tool chart colors change on update of tool type count (2026-02-20, PASS)
- **BUG-T14** — Rows in Per-Tool Latency Statistics fold automatically immediately after unfolding (2026-02-20, PASS)
- **BUG-T17** — Rows in Audit Log table automatically fold after user unfolds them (2026-02-20, PASS)
- **BUG-T18** — Error Breakdown widget must be full width streatched (2026-02-20, PASS)

## Suggested Next Tasks

- BUG-T10 — Tool chart colors change on update of tool type count
- BUG-T12 — New audit log entries are not shown in the dashboard in real time
- BUG-T11 — Request Timeline never shows actual events
- BUG-T13 — Per-Tool Latency Statistics does not show params when `capture_params` is false
2 changes: 1 addition & 1 deletion SPECS/Workplan.md
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ The main loop in `__main__.py` blocks on `output_queue.get()` waiting for stdout

### BUG-T10: Tool chart colors change on update of tool type count
- **Type:** Bug / Web UI / Data Stability
- **Status:** 🔴 Open
- **Status:** ✅ Fixed (2026-02-20)
- **Priority:** P1
- **Discovered:** 2026-02-16
- **Component:** Web UI Dashboard (`webui/static/`, metrics visualization)
Expand Down
Loading