Repository navigation
Stop cloud sessions on cancel and read the v3 PR url - #15
TheOnlyFusionCube merged 2 commits into
Conversation
Cancelling a handoff job only posted a "please stop" chat message, so
the remote session kept running. Add stopCloudSession, which DELETEs
the session (v1: /v1/sessions/{session_id}; v3:
/v3/organizations/{org_id}/sessions/{devin_id}) through the same
validated apiRequest path, and use it in cancel. The report says
whether the remote stop was confirmed; API failures are tolerated.
getCloudSession read the PR url from pull_requests[0].url, but v3
returns {pr_url, pr_state}. Check pr_url first, keeping v1's
pull_request.url and the old accessor as fallbacks.
Adds tests/cloud.test.mjs with mocked fetch (no network).
TheOnlyFusionCube
left a comment
There was a problem hiding this comment.
The v3 pr_url fallback and reuse of PR #11's validated, no-redirect request path look good. However, cloud cancellation needs a correctness fix before merge: cmdCancel marks the job permanently cancelled before attempting DELETE and swallows DELETE failures. If the API key is absent, validation rejects the endpoint, the network fails, or the remote session continues running, local status will never refresh it (refreshCloudJob only refreshes active jobs). This can conceal an actively billing cloud session. Please record an explicit cancel_pending / remote_stop_failed state (or otherwise retain a refreshable active status), preserve the API error/diagnostic, and confirm termination with a follow-up GET or documented definitive response before reporting remoteStopped: true. Add command-level tests for successful stop, API failure, missing key, and subsequent status/retry behavior; the current tests only exercise stopCloudSession and renderCancelReport independently. Also investigate the HOL Scanner delta: main/PR #14/#16 have one high, but this PR reports two highs (all 98/100). Do not weaken the scanner or treat the second high as baseline without identifying it.
|
|
||
| // null: no remote stop attempted; false: attempted but not confirmed. | ||
| let remoteStopped = null; | ||
| if (job.kind === "handoff" && job.cloudSessionId && getCloudConfig().available) { |
There was a problem hiding this comment.
Blocking: cancellation is recorded as terminal before remote termination. When this condition is false or DELETE rejects, the cloud session may keep running, but status refresh skips cancelled jobs. Keep failed/unconfirmed termination retryable and report a diagnostic; cover this path with an end-to-end command test.
cancel no longer marks a cloud handoff cancelled before the DELETE and no longer swallows its failure. The job is set to cancel_pending first (active, so status keeps refreshing it), and becomes cancelled only after a follow-up GET shows the session exit, error, or suspended. The DELETE response alone is never trusted. Failures keep a short diagnostic in errorMessage (no key or API URL) and the report says how to retry. status settles a cancel_pending job once the session is observed stopped. --json keeps remoteStopped (true only when confirmed) and adds the resulting status and remoteStatus. Adds command-level tests against a local fake Devin API (success, API failure and retry, missing key, status settling, service key v3 path) and renames fake keys in tests/cloud.test.mjs to placeholders.
|
Thanks, agreed on both points. I've pushed a follow-up commit (no rebase).
Failures keep a redacted diagnostic in Tests: command-level tests against a local fake Devin API cover success, API failure and retry, a missing key, The second scanner high was a fake key at |
TheOnlyFusionCube
left a comment
There was a problem hiding this comment.
Re-review: the prior blocker is addressed. cancel_pending is active/refreshable and retryable; remote termination is not declared successful from DELETE alone, but from GET showing exit/error/suspended. API errors retain sanitized diagnostics, and command-level tests cover v1/v3, missing key, failed DELETE/retry, status settlement, and local-only cancellation. The v3 pr_url fix retains PR #11's validated/no-redirect API path. Latest Test CI passes. The HOL scanner remains failing at repository level; its extra finding in the earlier PR revision was a fake test key, now replaced with a placeholder. Keep the scanner enabled and fix its remaining baseline finding separately. Follow-up recommended: address the separately disclosed session-end hook cancellation of --wait handoffs without stopping the remote session. Approved.
a9c4837
into
TheOnlyFusionCube:main
Re-file of the former #3, as requested in #4, rebased onto current main. It now goes through the validated request path from #11.
What was wrong
/devin:cancelon a cloud handoff only sent a "please stop" chat message, so the remote session could keep running and spending ACUs.getCloudSessionread the PR url frompull_requests[0].url. v3SessionResponse.pull_requestsitems are{pr_url, pr_state}, with nourl, so service-key sessions never reported their PR.What changed
stopCloudSessionsends DELETE to a documented terminate endpoint:/v1/sessions/{session_id}/v3/organizations/{org_id}/sessions/{devin_id}resolveApiBaseandapiRequest, so theDEVIN_API_URLvalidation and the no-redirect rule apply.cancelnow calls it and reports whether the remote stop was confirmed.--jsongains aremoteStoppedfield.pull_request.url(v1),pull_requests[0].pr_url(v3), then the old.urlas a fallback.How tested
tests/cloud.test.mjs, using a mockedglobalThis.fetchwith no network calls. It covers:DEVIN_API_URL, which makes no requestnode --test: 76/76.