Commit 0c9d8bd
fix(#87): address Copilot review on metrics insights
Three findings, all valid:
1. The prev-window stats slice was un-trimmed. GetStatsHistory takes
a lower bound only, so prevRaw spanned both windows; the `prevOnly`
index list I computed was promptly discarded with `_ = prevOnly`,
so every prev-window aggregate was actually a union aggregate and
the resulting delta_pct was ~0 % regardless of actual change.
Fixed by collapsing prevRaw to entries strictly before `since`.
2. APIMetricsLogErrorsHandler returned HTTP 403 when the user lacked
`logs:view`, but the README and the frontend's loadLogErrors() both
expected the structured {available:false, reason:…} envelope, so
users without log access saw the generic "Failed to load log lines"
error instead of the documented hint. Switched to the envelope.
3. escapeJSArg only handled the JS string context (\\ and '), but the
value is interpolated into a double-quoted HTML onclick attribute,
so an embedded " could break out and a < could start a new tag.
Hardened to also escape &<>" — defence in depth on the source-IP
path where values flow from agent-collected data.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent e3f2235 commit 0c9d8bd
2 files changed
Lines changed: 36 additions & 10 deletions
Lines changed: 21 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
96 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
97 | 102 | | |
98 | | - | |
| 103 | + | |
99 | 104 | | |
100 | 105 | | |
101 | 106 | | |
102 | 107 | | |
103 | 108 | | |
104 | | - | |
105 | | - | |
106 | 109 | | |
107 | 110 | | |
108 | 111 | | |
| |||
434 | 437 | | |
435 | 438 | | |
436 | 439 | | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
437 | 444 | | |
438 | | - | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
439 | 452 | | |
440 | 453 | | |
441 | 454 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1866 | 1866 | | |
1867 | 1867 | | |
1868 | 1868 | | |
1869 | | - | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
1870 | 1877 | | |
1871 | | - | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
1872 | 1885 | | |
1873 | 1886 | | |
1874 | 1887 | | |
| |||
0 commit comments