Repository navigation
[3600 by Claude Opus 5.5] CLI: busy loop in events wait --follow --timeout 0, unknown task shown as Pending, and HTML responses treated as data - #3640
Conversation
…ull CLI suite passes (755 tests, 0 failures), including 13 new tests in `src/commands/cliResponseHardening.test.ts` that cover each point. Typecheck also passes. I also pointed the CLI at a local server that serves an HTML page, and every backend command named in point 3 now prints one line and exits 1.
1. `events wait --follow`: consecutive waits now start at least 1 second apart, and Ctrl-C still stops at once. In the test, a stub that answers immediately gets 2–3 requests in 2.5 s instead of more than 1000.
2. `task get <unknown>`: when the server returns an empty record (no history, no task info), it prints "Error: Task not found: <id>" and exits 1, with or without `--json`. This uses the same check `task inspect` already had.
3. HTML or non-JSON responses: the check lives in one place, the shared API client (`src/api/client.ts`).
- It rejects HTML pages, non-JSON bodies and malformed JSON, including HTML error pages such as a 404 or 502.
- The message is: "Error: The remote did not return a ProPR API response. Check the URL with `propr remote`." and the exit code is 1.
- `stats cost --csv` now accepts only a `text/csv` response.
- Empty 204 responses and JSON error bodies behave as before.
- I checked the server routes: the endpoints that send plain text are not ones the CLI calls.
4. `plan list`: now accepts `-l, --limit` (max 100, the server's limit) and `--offset`, and shows "Showing 1-10 of 197 plan(s)" with the exact command for the next page. Status uses the same labels as `plan get` ("PR Created", "Merged"). The server only pages by page number, so an offset that isn't a multiple of the limit fetches two pages and trims them. In that case `--json` keeps the same shape plus an `offset` field.
5. `repo list`: there's a new "PR title status" column (`on`/`off`), and "Visual previews" shows `image`, `image+video` or `off`. The long attachment-limit explanation now sits in a short list under the table, one line per repo with previews on. I kept it there because an existing test checks for that text and there is no `repo get` command to show it otherwise. It's still complete in `--json`.
6. `handoffs list`: prints a count line, a blank line between entries, states in words ("Agent exited", "Released by operator force") and an "Updated:" time in local time. `--json` still has the raw values. `handoffs inspect` uses the same formatting.
7. `remote-status`, durations and `login`:
- `remote-status`: shows an Indexing line, and reports "Some components require attention." when indexing is `failed` or `disconnected` or the server sends warnings. A partial or odd response no longer crashes with the `toLowerCase` TypeError.
- Durations: history durations read like "5m 40s", and steps under a second keep milliseconds.
- `login`: when a remote is configured, it now checks the token with the server's `/api/auth/user` endpoint.
- If the remote rejects the token (401), it isn't saved and the command exits 1.
- If the remote can't be reached or isn't a ProPR API, the token is saved and the CLI says it couldn't be verified.
- With no remote configured, it says the token wasn't verified.
Two behaviour choices you may want to revisit:
- Warnings in `remote-status`: any server warning now blocks "All systems operational." If some warnings are routine on your instances, that will show as degraded.
- `login` on a 403: the token is saved, exit code 0, and the CLI says the instance denied access to this account.
I also added short notes on login verification, the non-API error, plan paging and the follow spacing to `docs/docs/features/propr-cli.md`. I didn't create preview images: the changes are terminal text only, and the tests check that output directly.
|
/ultrafix goal=8 max=6 |
|
🔄 Ultrafix loop started (goal: 8/10, max cycles: 6) First action:
|
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR improves CLI response handling, pagination, event following, and terminal output with focused regression coverage. It needs localized corrections before merge, particularly in interactive login and non-JSON error handling. ✅ Bounded event following — Consecutive waits are spaced apart, and the added pause responds to cancellation. ✅ Offset pagination — Non-aligned offsets fetch and slice the two required server pages while preserving totals. ✅ Shared response validation — Successful HTML and malformed JSON responses are rejected centrally, with an explicit CSV exception. The supplied current-head status reports 31 passed, 26 neutral/skipped, and three pending checks. This review used static analysis only; no commands were run. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F1: 🔴 Interactive login retains rejected credentials
F2: 🔴 Non-JSON error responses bypass validation
SuggestionsThese are optional follow-ups and are not sent to No suggestions. ScoreThe implementation is focused and has useful coverage, but two changed behavior contracts remain incomplete. Both can be corrected locally; current checks show no failures, with three still pending. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 7a9f5bb
Summary of ChangesI fixed both findings. The full CLI suite passes (787 tests, 785 passed, 0 failed) and typecheck passes. A first full-suite run reported 17 failures, but those two files need the F1 – interactive login no longer saves a rejected token
F2 – error bodies that aren't JSON are rejected
New tests are in
The docs note added earlier on this branch already says a rejected token is not saved, which is now true for both login paths. Separate finding, not changed: Review digestRisk-tiered paths
Validation evidence
Diff size: 6 files changed, +202/−37 lines 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
…, 785 passed, 0 failed) and typecheck passes. A first full-suite run reported 17 failures, but those two files need the `--experimental-test-module-mocks` flag. With the flag they pass (52/52), and the full run above used it. I fixed both findings. The full CLI suite passes (787 tests, 785 passed, 0 failed) and typecheck passes. A first full-suite run reported 17 failures, but those two files need the `--experimental-test-module-mocks` flag. With the flag they pass (52/52), and the full run above used it. **F1 – interactive login no longer saves a rejected token** - `loginWithGithubCli` (`packages/cli/src/auth/githubLogin.ts`) has a new `persist` option, on by default. With it off, the function returns the token from `gh` without saving it. That covers all four places it used to save. - A new `completeLogin` in `verifyToken.ts` checks the token against the remote, saves it only if the check allows, and then prints the success lines and "Token saved to:". - `propr login` now uses `completeLogin` for both the explicit-token path and the interactive path, and the interactive path passes `persist: false`. If the remote rejects the token (401), nothing is written, the previously saved token stays, and the command exits 1 with "…rejected this token. It was not saved." - I removed the `alreadySaved` option, since nothing saves before the check any more. - The other callers of `loginWithGithubCli`, in `setupCommand.ts` and `setup/hostActions.ts`, still save straight away as before. **F2 – error bodies that aren't JSON are rejected** - In `packages/cli/src/api/client.ts`, `readErrorBody` now treats an empty body as before and passes a JSON object through as a normal API error. - Any other body (HTML, plain text, broken JSON, or a bare JSON value that isn't an object) now gets the "The remote did not return a ProPR API response" error. Before this change, plain text and broken JSON were silently turned into ordinary not-found or authentication errors. **New tests** are in `packages/cli/src/auth/loginPersistence.test.ts`: - Interactive login, both with an existing `gh` session and after `gh auth login`: on a rejection nothing is saved and the old token survives; on success the token is saved and the success lines print after the check. - Setup still saves by default. - The explicit-token path saves nothing on a rejection, and still saves when the remote can't be reached. - A plain-text 404, a broken-JSON 401 and a bare JSON string on a 500 all get the non-API error. - Empty error bodies and JSON error bodies still come back as ordinary API errors. The docs note added earlier on this branch already says a rejected token is not saved, which is now true for both login paths. **Separate finding, not changed:** `propr setup` still saves the token from `gh` without checking it against a remote. That code wasn't changed in this PR, so I left it alone. PR: #3640 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationReady to merge within the reviewed scope. The changes address the CLI hardening objectives with localized implementation and focused regression coverage. Current-head checks report 35 passed, none failed or pending, and 12 neutral/skipped. ✅ Interruptible follow throttling — Consecutive waits are spaced without delaying cancellation, and the added test exercises immediate responses and SIGINT. ✅ Rejected credentials remain unsaved — Both explicit-token and interactive login paths verify before persistence, preserving the previous credential on a JSON 401 response. ✅ Pagination matches the server contract — Offset windows correctly translate into page requests, including windows spanning two pages. This was a static review of the supplied diff and surrounding context; no commands or tests were run. Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S1: 🟢 Report success after persistenceIn S2: 🟢 Bound the complete verification requestThe new login verification inherits the API client’s existing timeout behavior: retries each receive a separate timeout, and the timer is cleared before reading the response body. A follow-up could enforce an overall verification deadline covering retries and body consumption. This would make login’s stated bounded-wait behavior more predictable; the underlying timeout limitation predates this PR. ScoreThe implementation is cohesive, includes relevant regression tests, and has no verified merge blockers. The supplied current-head checks are green. 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
events wait --follow --timeout 0, unknown task shown as Pending, and HTML responses treated as dataevents wait --follow --timeout 0, unknown task shown as Pending, and HTML responses treated as data
events wait --follow --timeout 0, unknown task shown as Pending, and HTML responses treated as dataevents wait --follow --timeout 0, unknown task shown as Pending, and HTML responses treated as data
AI Implementation Summary
Closes #3600
Branch:
3600/claude-opus-5-5-cli-busy-loop-in-events-w-20261117-0355-ov2Commits: ✅ Changes committed (0361613)
AI Processing Completed
Execution Details:
events wait --follow --timeout 0, unknown task shown as Pending, and HTML responses treated as data #3600Summary:
I've fixed all seven points from issue #3600 in
packages/cli. The full CLI suite passes (755 tests, 0 failures), including 13 new tests insrc/commands/cliResponseHardening.test.tsthat cover each point. Typecheck also passes. I also pointed the CLI at a local server that serves an HTML page, and every backend command named in point 3 now prints one line and exits 1.events wait --follow: consecutive waits now start at least 1 second apart, and Ctrl-C still stops at once. In the test, a stub that answers immediately gets 2–3 requests in 2.5 s instead of more than 1000.task get <unknown>: when the server returns an empty record (no history, no task info), it prints "Error: Task not found: " and exits 1, with or without--json. This uses the same checktask inspectalready had.src/api/client.ts).propr remote." and the exit code is 1.stats cost --csvnow accepts only atext/csvresponse.plan list: now accepts-l, --limit(max 100, the server's limit) and--offset, and shows "Showing 1-10 of 197 plan(s)" with the exact command for the next page. Status uses the same labels asplan get("PR Created", "Merged"). The server only pages by page number, so an offset that isn't a multiple of the limit fetches two pages and trims them. In that case--jsonkeeps the same shape plus anoffsetfield.repo list: there's a new "PR title status" column (on/off), and "Visual previews" showsimage,image+videooroff. The long attachment-limit explanation now sits in a short list under the table, one line per repo with previews on. I kept it there because an existing test checks for that text and there is norepo getcommand to show it otherwise. It's still complete in--json.handoffs list: prints a count line, a blank line between entries, states in words ("Agent exited", "Released by operator force") and an "Updated:" time in local time.--jsonstill has the raw values.handoffs inspectuses the same formatting.remote-status, durations andlogin:remote-status: shows an Indexing line, and reports "Some components require attention." when indexing isfailedordisconnectedor the server sends warnings. A partial or odd response no longer crashes with thetoLowerCaseTypeError.login: when a remote is configured, it now checks the token with the server's/api/auth/userendpoint.Two behaviour choices you may want to revisit:
remote-status: any server warning now blocks "All systems operational." If some warnings are routine on your instances, that will show as degraded.loginon a 403: the token is saved, exit code 0, and the CLI says the instance denied access to this account.I also added short notes on login verification, the non-API error, plan paging and the follow spacing to
docs/docs/features/propr-cli.md. I didn't create preview images: the changes are terminal text only, and the tests check that output directly.Review digest
Risk-tiered paths
packages/cli/src/auth/verifyToken.ts(added, +100/−0): auth-looking pathpackages/cli/src/api/client.ts(+58/−17)packages/cli/src/api/errors.ts(+23/−0)packages/cli/src/api/index.ts(+2/−0)packages/cli/src/api/plans.ts(+43/−0)packages/cli/src/api/stats.ts(+1/−1)packages/cli/src/api/system.ts(+11/−0)packages/cli/src/api/types.ts(+9/−0)packages/cli/src/commands/eventCommands.ts(+28/−3)packages/cli/src/commands/handoffCommands.ts(+33/−7)packages/cli/src/commands/planCommands.ts(+40/−10)packages/cli/src/commands/repoCommands.ts(+38/−5)packages/cli/src/commands/systemCommands.ts(+32/−2)packages/cli/src/commands/taskCommands.ts(+15/−1)packages/cli/src/index.ts(+8/−1)packages/cli/src/utils/apiErrorPresentation.ts(+5/−1)docs/docs/features/propr-cli.md(+4/−1)packages/cli/src/commands/cliResponseHardening.test.ts(added, +379/−0)packages/cli/src/commands/handoffCommands.test.ts(+5/−5)Validation evidence
Diff size: 19 files changed, +834/−54 lines
Detailed Logs:
0d89e303-4cd5-4b72-b308-0972101e4789Log files stored at:
/usr/src/app/logs/executions/issue-3600-2026-11-17T04-13-46-981Z-conversation.json/usr/src/app/logs/executions/issue-3600-2026-11-17T04-13-46-981Z-output.txtLatest Conversation Messages
This PR was created automatically by ProPR after processing issue #3600.
💡 Need changes?
Comment on this PR to request refinements — the AI agent monitors comments and will update the implementation based on your feedback. Keep iterating until you're satisfied!