Skip to content

[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

Merged
integry merged 2 commits into
3595-epic-0-9-h9lfrom
3600/claude-opus-5-5-cli-busy-loop-in-events-w-20261117-0355-ov2
Nov 17, 2026
Merged

integry merged 2 commits into
3595-epic-0-9-h9lfrom
3600/claude-opus-5-5-cli-busy-loop-in-events-w-20261117-0355-ov2

Conversation

@propr-dev

@propr-dev propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI Implementation Summary

Closes #3600

Branch: 3600/claude-opus-5-5-cli-busy-loop-in-events-w-20261117-0355-ov2
Commits: ✅ Changes committed (0361613)


AI Processing Completed

Execution Details:

Summary:
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 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: " 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.

Review digest

Risk-tiered paths

  • High risk (1 file)
    • packages/cli/src/auth/verifyToken.ts (added, +100/−0): auth-looking path
  • Normal risk (15 files)
    • packages/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)
  • Low risk (3 files)
    • 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

  • No repository validation commands ran.

Diff size: 19 files changed, +834/−54 lines

Detailed Logs:

  • Conversation: 248 messages
  • Session: 0d89e303-4cd5-4b72-b308-0972101e4789

Log files stored at:

  • conversation: /usr/src/app/logs/executions/issue-3600-2026-11-17T04-13-46-981Z-conversation.json
  • output: /usr/src/app/logs/executions/issue-3600-2026-11-17T04-13-46-981Z-output.txt
Latest Conversation Messages
ASSISTANT: [content unavailable]

ASSISTANT: 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 in `src/commands/cliResponseHardening.test.ts` that cover each...


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!

…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.
@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

/ultrafix goal=8 max=6
Triggered automatically by the requested execution settings.

@propr-dev propr-dev Bot added the ultrafix label Nov 17, 2026
@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

🔄 Ultrafix loop started (goal: 8/10, max cycles: 6)

First action: /review

💡 Tip: Remove the ultrafix label from this PR to stop further ultrafix cycles.

@propr-dev

propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The 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 blockers

Every finding below was introduced by this PR and must be resolved before merging.

F1: 🔴 Interactive login retains rejected credentials

  • Category: correctness

  • Required behavior: Login verification must prevent a remotely rejected token from being saved and must verify before reporting success.

  • Evidence: packages/cli/src/index.ts:374–381 and packages/cli/src/auth/verifyToken.ts:reportLoginVerification

    1. A user runs interactive propr login with a configured remote.
    2. Both successful paths in the supplied githubLogin.ts context save the obtained token before returning it.
    3. The changed caller prints the authentication result and token-save location, then invokes verification with alreadySaved: true.
    4. The remote returns JSON HTTP 401. Verification returns save: false, but the caller only exits with code 1; the rejected credential remains stored.

    The new verification therefore reports failure after committing the credential, contrary to the documented behavior. The explicit-token branch checks before saving, but that protection does not cover either interactive path. The added tests exercise the reporting helper rather than persistence through interactive login. static trace: verified against both supplied githubLogin.ts save paths and the changed caller.

  • Minimum fix: Allow interactive login to obtain a token without persisting it, verify it, and save only when the verification outcome permits saving. Print success afterward and preserve previously stored credentials on rejection.

F2: 🔴 Non-JSON error responses bypass validation

  • Category: requirement

  • Required behavior: The shared API client must reject non-JSON and malformed JSON responses with the prescribed non-API diagnostic, while preserving valid JSON error responses.

  • Evidence: packages/cli/src/api/client.ts:readErrorBody

    1. A misconfigured remote returns HTTP 404 with Content-Type: text/plain and body Not found, or HTTP 401 with malformed JSON.
    2. Neither response matches the HTML checks.
    3. JSON.parse fails, but the catch returns undefined.
    4. createApiError converts the response into an ordinary not-found or authentication error, so the CLI presents a resource/authentication diagnosis instead of the required remote-URL diagnostic.

    This leaves the advertised non-JSON rejection incomplete for unsuccessful responses. Existing tests cover HTML error responses and malformed successful responses, so they do not exercise this branch. static trace: traced the parsing catch through request into createApiError; no test was executed.

  • Minimum fix: Reject non-empty, non-JSON or malformed error bodies with InvalidApiResponseError; retain the existing handling for empty errors and valid JSON error bodies. Add cases for plain-text and malformed-JSON HTTP errors.

Suggestions

These are optional follow-ups and are not sent to /fix.

No suggestions.

Score

The 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

  • Model: GPT-6 Astra
  • Time: 53s
  • Tokens: 65,873 (64,704 in / 1,169 out)
  • Cost: $0.58

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F1 F2

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 7a9f5bb

Addressed 1 AI review comment (IDs: 6938404524)

Addressed findings F1, F2

Summary of Changes

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.

Review digest

Risk-tiered paths

  • High risk (2 files)
    • packages/cli/src/auth/githubLogin.ts (+14/−8): auth-looking path
    • packages/cli/src/auth/verifyToken.ts (+35/−4): auth-looking path
  • Normal risk (2 files)
    • packages/cli/src/api/client.ts (+11/−8)
    • packages/cli/src/index.ts (+11/−15)
  • Low risk (2 files)
    • packages/cli/src/auth/loginPersistence.test.ts (added, +129/−0)
    • packages/cli/src/commands/cliResponseHardening.test.ts (+2/−2)

Validation evidence

  • No repository validation commands ran.

Diff size: 6 files changed, +202/−37 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 8m 32s
  • Tokens: 2,019,634 (2,004,118 in / 15,516 out)
  • Cost: $1.04
  • Subscription usage: Weekly +1%

View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 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
@propr-dev

propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

Ready 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 blockers

No merge blockers.

Suggestions

These are optional follow-ups and are not sent to /fix.

S1: 🟢 Report success after persistence

In packages/cli/src/auth/verifyToken.ts, completeLogin calls reportLoginVerification before saving, so “Authentication successful” or “Token saved” can precede a persistence failure. Consider buffering those messages until setGithubToken succeeds, and testing a rejected save. This is a non-blocking reporting improvement because the save failure still propagates to the command’s error handler.

S2: 🟢 Bound the complete verification request

The 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.

Score

The implementation is cohesive, includes relevant regression tests, and has no verified merge blockers. The supplied current-head checks are green.
Score: 9/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 44s
  • Tokens: 67,198 (66,475 in / 723 out)
  • Cost: $0.59

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix S1 S2

🤖 Review by ProPR

@propr-dev propr-dev Bot removed the ultrafix label Nov 17, 2026
@propr-dev propr-dev Bot changed the title 🔨 [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 ✅⑨ [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 Nov 17, 2026
@integry
integry merged commit 2145582 into 3595-epic-0-9-h9l Nov 17, 2026
50 checks passed
@propr-dev propr-dev Bot changed the title ✅⑨ [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 [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 Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant