Skip to content

Commit b5441ec

Browse files
Merge pull request #25 from IgniteUI/mstoyanova/rate-limit-message
Better status reports for runs (network errors, api limits, etc.)
2 parents a633e2e + f9e6a90 commit b5441ec

32 files changed

Lines changed: 3769 additions & 113 deletions

.githooks/pre-commit

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/sh
2-
# Pre-commit gate: block commits that don't type-check.
2+
# Pre-commit gate: block commits that don't type-check or fail the diagnostics fixtures.
33
# One-time setup per clone: git config core.hooksPath .githooks
4-
exec npm run --silent typecheck
4+
npm run --silent typecheck || exit 1
5+
exec npm run --silent diagnostics:test

CLAUDE.md

Lines changed: 135 additions & 4 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"scripts": {
88
"start": "node src/server.ts",
99
"typecheck": "tsc -p tsconfig.json && tsc -p web/tsconfig.json",
10+
"diagnostics:test": "node scripts/diagnostics-fixtures.mjs && node scripts/loop-store-check.mjs",
11+
"diagnostics:replay": "node scripts/replay-diagnostics.mjs",
12+
"exec:smoke": "node scripts/exec-smoke.mjs",
1013
"build:web": "esbuild web/main.ts --bundle --format=esm --outfile=public/vendor/app.js",
1114
"dev:web": "esbuild web/main.ts --bundle --format=esm --outfile=public/vendor/app.js --watch"
1215
},

public/css/app.css

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,32 @@ igc-grid.runs-grid igc-grid-toolbar-exporter {
244244
.pill.success { background:rgba(43,179,104,.15); color:var(--green); }
245245
.pill.error { background:rgba(224,106,85,.16); color:var(--red); }
246246
.pill.build-error { background:rgba(202,162,60,.18); color:var(--amber); }
247+
/* Provider-side outcomes: the run didn't fail, the provider did — amber, not red, so
248+
they read as "not your code" at a glance. Kept in sync with src/status-meta.ts. */
249+
.pill.rate-limited,
250+
.pill.provider-down,
251+
.pill.no-credits,
252+
.pill.auth,
253+
.pill.timed-out { background:rgba(202,162,60,.18); color:var(--amber); }
254+
.pill.other { background:rgba(142,166,164,.15); color:var(--steel); }
255+
256+
/* Diagnostics. A resolved one is good news and a superseded one is not, so they must
257+
not look alike — muted-green vs muted-grey with a strikethrough title. */
258+
.diag { border-left:3px solid var(--amber); padding:.35rem .6rem; margin:.35rem 0; background:rgba(202,162,60,.07); }
259+
.diag .diag-title { color:var(--amber); font-weight:600; }
260+
.diag .diag-advice { color:var(--ink); margin-top:.15rem; }
261+
.diag .diag-detail { color:var(--steel); font-family:var(--mono); font-size:.72rem; margin-top:.25rem; overflow-wrap:anywhere; white-space:pre-wrap; }
262+
.diag .diag-meta { color:var(--steel); font-size:.7rem; margin-top:.2rem; }
263+
.diag.suspected { border-left-style:dashed; }
264+
.diag.resolved { border-left-color:var(--green); background:rgba(43,179,104,.06); opacity:.75; }
265+
.diag.resolved .diag-title { color:var(--green); }
266+
.diag.superseded { border-left-color:var(--steel); background:transparent; opacity:.6; }
267+
.diag.superseded .diag-title { color:var(--steel); text-decoration:line-through; }
268+
.diag-chip { color:var(--amber); margin-left:.35rem; }
269+
270+
/* Matrix-level aggregate banner. */
271+
.mx-banner { border:1px solid rgba(202,162,60,.5); background:rgba(202,162,60,.12); color:var(--amber);
272+
padding:.5rem .75rem; border-radius:6px; margin:.5rem 0; font-size:.8rem; }
247273
.pill.test-failed { background:rgba(224,106,85,.16); color:var(--red); }
248274
.pill.running { background:rgba(202,162,60,.16); color:var(--amber); }
249275
.detail { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:1rem 1.6rem;

run.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ $envFlags = @()
167167
foreach ($v in $keyVars) {
168168
if (Test-Path "env:$v") { $envFlags += @('-e', $v) }
169169
}
170+
# Non-secret tunables: diagnostics tunables (src/config.ts): forwarded when set so a run can be tuned, and so DIAGNOSTICS_STREAM_DEBUG=1 can be used to answer which stream provider errors actually arrive on. Values are plain numbers/flags, not secrets.
171+
$diagVars = @('DIAGNOSTICS_STREAM_DEBUG', 'AGENT_STALL_MS', 'AGENT_LOOP_REPEATS', 'DIAGNOSTIC_AGGREGATE_THRESHOLD', 'AGENT_TIMEOUT_MS')
172+
foreach ($v in $diagVars) {
173+
if (Test-Path "env:$v") { $envFlags += @('-e', "$v=$((Get-Item "env:$v").Value)") }
174+
}
170175
if ($mcAbs) { $envFlags += @('-e', 'MATRIX_CONFIG=/matrix-config.json') }
171176
if ($Validate) { $envFlags += @('-e', 'MATRIX_VALIDATE=1') }
172177

run.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,12 @@ KEY_VARS=(ANTHROPIC_API_KEY OPENAI_API_KEY OPENROUTER_API_KEY GOOGLE_GENERATIVE_
147147
# A matrix config may name a custom env var to hold its key via "apiKeyEnv"; forward
148148
# that var too (else loadMatrixConfig can't resolve it and the run goes out keyless).
149149
if [[ -n "$MATRIX_CONFIG_FILE" ]]; then
150-
CUSTOM_KEY_ENV="$(grep -oE '"apiKeyEnv"[[:space:]]*:[[:space:]]*"[^"]+"' "$MATRIX_CONFIG_FILE" | head -1 | sed -E 's/.*:[[:space:]]*"([^"]+)".*/\1/')"
150+
# `|| true` is load-bearing: apiKeyEnv is OPTIONAL, and under `set -euo pipefail` a
151+
# grep that matches nothing exits 1, pipefail propagates it out of the substitution
152+
# and the script dies right here with no output at all. Every committed example
153+
# config happens to carry the field, which is why this hid — a config that omits it
154+
# (entirely legal: apiKey > apiKeyEnv > PROVIDER_ENV) made run.sh exit 1 silently.
155+
CUSTOM_KEY_ENV="$(grep -oE '"apiKeyEnv"[[:space:]]*:[[:space:]]*"[^"]+"' "$MATRIX_CONFIG_FILE" | head -1 | sed -E 's/.*:[[:space:]]*"([^"]+)".*/\1/' || true)"
151156
if [[ -n "$CUSTOM_KEY_ENV" ]]; then
152157
if [[ "$CUSTOM_KEY_ENV" =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]]; then
153158
dup=0; for v in "${KEY_VARS[@]}"; do [[ "$v" == "$CUSTOM_KEY_ENV" ]] && dup=1; done
@@ -163,6 +168,11 @@ ENVFLAGS=()
163168
for v in "${KEY_VARS[@]}"; do
164169
[[ -n "${!v:-}" ]] && ENVFLAGS+=(-e "$v")
165170
done
171+
# Non-secret tunables: diagnostics tunables (src/config.ts): forwarded when set so a run can be tuned, and so DIAGNOSTICS_STREAM_DEBUG=1 can be used to answer which stream provider errors actually arrive on. Values are plain numbers/flags, not secrets.
172+
DIAG_VARS=(DIAGNOSTICS_STREAM_DEBUG AGENT_STALL_MS AGENT_LOOP_REPEATS DIAGNOSTIC_AGGREGATE_THRESHOLD AGENT_TIMEOUT_MS)
173+
for v in "${DIAG_VARS[@]}"; do
174+
[[ -n "${!v:-}" ]] && ENVFLAGS+=(-e "$v=${!v}")
175+
done
166176
[[ -n "$MATRIX_CONFIG_FILE" ]] && ENVFLAGS+=(-e "MATRIX_CONFIG=/matrix-config.json")
167177
[[ "$VALIDATE" == 1 ]] && ENVFLAGS+=(-e "MATRIX_VALIDATE=1")
168178

0 commit comments

Comments
 (0)