Skip to content

refactor(ai-providers): Cursor provider review follow-ups (#1624)#1627

Merged
datlechin merged 1 commit into
mainfrom
fix/cursor-provider-review-followups
Jun 8, 2026
Merged

refactor(ai-providers): Cursor provider review follow-ups (#1624)#1627
datlechin merged 1 commit into
mainfrom
fix/cursor-provider-review-followups

Conversation

@datlechin

Copy link
Copy Markdown
Member

Follow-up fixes for the Cursor AI provider merged in #1624, addressing review feedback. No behavior change to the happy paths; these harden the CLI sign-in lifecycle and add test coverage for the streaming logic.

Changes

  • Cancellable, non-blocking CLI sign-in. agent login previously ran via waitUntilExit() with no timeout or cancel path: closing the browser mid-flow left the UI stuck on "signing in" forever and parked a Swift concurrency worker thread on a live subprocess. CursorAgentCLI.run now drives completion from terminationHandler inside withTaskCancellationHandler, and CursorAgentService owns the sign-in task with a new cancelSignIn(). The settings sheet gets a Cancel button while signing in.
  • Testable SSE parsing. Extracted the inline event/dedup logic in CursorProvider.streamChat into a StreamParser struct and covered it with unit tests (delta ordering, the result fallback vs. skip-after-assistant dedup, blank/event lines, empty text).
  • Curated + fetched models. CursorProvider.fetchAvailableModels now returns the curated list first, then any extra models from /v1/models, so the curated models always appear even if the live list is sparse.
  • List status no longer stale. AISettingsView observes CursorAgentService.shared and refreshes it on appear, so a signed-in CLI user shows the right status without opening the detail sheet first.
  • timestamp_ms guard under test. Extracted CursorAgentProvider.incrementalText and added tests proving the consolidated final message (no timestamp) is skipped to avoid duplication.
  • CHANGELOG: added the missing (#1624) reference to the Cursor entry.

Tests

BUILD SUCCEEDED, swiftlint --strict clean on all touched files. New/updated Cursor suites pass: CursorProviderStreamParserTests, CursorAgentProviderTests (incl. the new incrementalText cases).

…Cursor login, testable SSE parser, curated+fetched models)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a462e9171e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return try await withTaskCancellationHandler {
try await withCheckedThrowingContinuation { continuation in
process.terminationHandler = { proc in
let data = (try? stdout.fileHandleForReading.readToEnd() ?? Data()) ?? Data()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Drain CLI output before waiting for termination

When agent status or agent login writes more than the OS pipe buffer to stdout/stderr, this waits to read the merged pipe until terminationHandler runs. The child can block while writing to the full pipe and therefore never terminate, so the handler never fires and status/sign-in await forever; the previous implementation drained the pipe concurrently while the process was still running.

Useful? React with 👍 / 👎.

@datlechin datlechin merged commit 27b7a7c into main Jun 8, 2026
3 checks passed
@datlechin datlechin deleted the fix/cursor-provider-review-followups branch June 8, 2026 12:07
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.

1 participant