Skip to content

perf(cli): project recent-results fields in checks get#1353

Merged
thebiglabasky merged 3 commits into
mainfrom
claude/vibrant-jones-e65571
Jun 18, 2026
Merged

perf(cli): project recent-results fields in checks get#1353
thebiglabasky merged 3 commits into
mainfrom
claude/vibrant-jones-e65571

Conversation

@thebiglabasky

Copy link
Copy Markdown
Contributor

Affected Components

  • CLI
  • Test

Notes for the Reviewer

Now that the backend supports a fields query parameter on GET /v2/check-results/{checkId} (checkly/monorepo#2384, merged), this is a small additive optimization for the human-facing checks get <id> path.

The default checks get screen only renders a narrow recent-results table, yet it was fetching full result bodies (metadata, assets, apiCheckResult, browserCheckResult, …). Asking the API for those wide payloads is unnecessary and can trigger slow paths for result-heavy checks. This change asks the API only for the columns the table actually renders.

What changed

  • rest/check-results.ts: added a CheckResultField union matching the backend-supported field names, extended ListCheckResultsParams with fields?: CheckResultField[], and normalized the array to a comma-separated fields=... query string in getAll() rather than relying on Axios array serialization (backend accepts both fields=id,startedAt and repeated params; the comma form is the most predictable across HTTP clients).
  • commands/checks/get.ts: passes a fixed internal projection — id, startedAt, runLocation, hasErrors, hasFailures, isDegraded, responseTime — for detail/markdown output. These are exactly what formatResults() and resolveResultStatus() read.

Deliberate product/API choices

  • No new public flag. checks get aggregates check details, status, analytics, error groups, and results, so a generic --fields/mode flag would be ambiguous. The projection is internal and fixed. Help output is unchanged.
  • JSON output intentionally omits fields so existing --output json consumers keep full results entries (backwards compatibility). Locked in by a test.
  • --result <id> drilldown is unchanged — it uses the v1 detail endpoint and needs the full result payload for the detail renderer.
  • The --include-attempts window query is also untouched and still requests full payloads.
  • Additive and backwards-compatible: the default backend response is unchanged when fields is omitted.

Tests added

  • rest/__tests__/check-results.spec.tsfields array serializes to a comma-separated string; omitted when absent; other params pass through.
  • commands/__tests__/checks-get-results-projection.spec.ts — default + markdown request the projection (with limit/nextId unchanged); cursor forwarded; --output json does not send fields; --result uses checkResults.get and never calls getAll.

Verification

  • Focused Vitest (new specs + existing checks-get attempts/flags): green.
  • eslint, prepare:dist (tsc typecheck), prepack (oclif manifest): all clean.
  • checks get --help smoke: no new flag, output intact.
  • Not run: a live staging checks get <id> call (needs a real check ID + authenticated request). Suggested manual check: CHECKLY_ENV=staging checkly checks get <id> and confirm the outgoing request includes fields=id,startedAt,runLocation,hasErrors,hasFailures,isDegraded,responseTime while terminal output is unchanged.

🤖 Generated with Claude Code

The default `checks get <id>` screen only renders a narrow recent-results
table, but it was fetching full result bodies (metadata, assets,
apiCheckResult, browserCheckResult, ...) from /v2/check-results, which can
trigger slow paths for result-heavy checks. Now that the backend supports a
`fields` query parameter (checkly/monorepo#2384), request only the columns the
table needs.

- rest: add CheckResultField union, extend ListCheckResultsParams with
  `fields?`, and normalize the array to a comma-separated query string in
  getAll() rather than relying on Axios array serialization.
- checks get: pass a fixed internal projection (id, startedAt, runLocation,
  hasErrors, hasFailures, isDegraded, responseTime) for detail/markdown output.
  No new public flag is added; the projection is internal and fixed.
- JSON output intentionally omits `fields` to preserve full `results` entries
  for existing consumers.
- --result drilldown and the --include-attempts window query are unchanged and
  still request full payloads.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@thebiglabasky thebiglabasky requested review from hwartig and sorccu June 17, 2026 14:52
hwartig
hwartig previously approved these changes Jun 17, 2026
Comment thread packages/cli/src/rest/check-results.ts
@thebiglabasky thebiglabasky enabled auto-merge (squash) June 17, 2026 15:15
@thebiglabasky thebiglabasky disabled auto-merge June 17, 2026 15:15
@thebiglabasky thebiglabasky enabled auto-merge (squash) June 18, 2026 07:50
thebiglabasky and others added 2 commits June 18, 2026 09:50
The two `test-global-files-bundling-*/should include global files` tests
omitted the `DEFAULT_TEST_TIMEOUT` (180s) that every sibling test in
playwright-check.spec.ts passes, so they fell back to vitest's 5000ms default.
`parseProject()` does real bundling + tar work that exceeds 5s on the slower
windows-latest-x64 CI runner, timing out reliably there (it stays just under 5s
on Linux, which is why main looked green). Pass the timeout like the rest of the
file.

Unrelated to the recent-results projection change, but folded in here because it
was blocking this PR's required `test - windows-latest-x64` check and a rerun
did not clear it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@thebiglabasky thebiglabasky merged commit 730778a into main Jun 18, 2026
25 of 29 checks passed
@thebiglabasky thebiglabasky deleted the claude/vibrant-jones-e65571 branch June 18, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants