Skip to content

fix(coding-agent): show progress during /refine - #1035

Open
junhoyeo wants to merge 5 commits into
PrimeIntellect-ai:mainfrom
junhoyeo:fix/refine-progress-status
Open

fix(coding-agent): show progress during /refine#1035
junhoyeo wants to merge 5 commits into
PrimeIntellect-ai:mainfrom
junhoyeo:fix/refine-progress-status

Conversation

@junhoyeo

@junhoyeo junhoyeo commented Aug 9, 2026

Copy link
Copy Markdown

Summary

  • show an elapsed Refining loader while an explicit /refine session command is active
  • restart the loader timer when ownership changes between a model turn and refinement, including attach/resync reconciliation
  • let the configured interrupt key cancel /refine without clearing queued prompts or the editor draft

Compatibility

This is a TUI-only change that consumes the existing optional sessionActions.active snapshot. It adds no daemon command, event, response field, capability, or schema revision; clients attached to older daemons continue to degrade to the existing no-loader behavior.

Scope and prior work

This fixes the explicit interactive /refine path that can otherwise appear frozen during a long model-backed refinement. It deliberately does not add generic lifecycle state for automatic/background refinement.

#447 overlaps with the broader goal, but is currently conflicting and predates the session-action snapshot now on main. This PR is the minimal current-main alternative for the interactive slash-command path and does not revive #447's queue/core/protocol changes.

Validation

  • npx tsx ../../node_modules/vitest/dist/cli.js --run test/interactive-mode-status.test.ts test/interactive-mode-ctrl-c.test.ts (174 passed)
  • npx tsx ../../node_modules/vitest/dist/cli.js --run test/suite/agent-session-queue.test.ts -t "defers steer heartbeats while a non-streaming session command is running" (1 passed)
  • npm run check

Note

Show elapsed progress and allow cancellation during /refine in interactive mode

  • The interactive mode's working loader now activates during active /refine session commands (not just agent streaming), showing Refining · <elapsed> (Ctrl+C to cancel) in the status area.
  • A new workingLoaderKind field tracks whether the loader is owned by streaming or /refine, and the loader restarts when ownership changes.
  • Ctrl+C during an active /refine command now calls agentConnection.abort() and restores any queued prompts to the editor.
  • syncWorkingLoader() is called on session_action_update events and during initial snapshot rendering to keep loader state current.

Macroscope summarized 6f0b233.

@junhoyeo
junhoyeo marked this pull request as ready for review August 9, 2026 02:00
@junhoyeo junhoyeo changed the title fix(coding-agent): show progress during /refine fix(coding-agent): show progress during /refine Aug 9, 2026

@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: 3f747ebbe1

ℹ️ 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".

Comment thread packages/coding-agent/src/modes/interactive/interactive-mode.ts
@junhoyeo

junhoyeo commented Aug 9, 2026

Copy link
Copy Markdown
Author

@codex review

All previous findings have been addressed:

Finding Status
P2: Reconcile loader after applying initial snapshot ✅ Fixed in 0401ba71renderInitialMessages() now calls syncWorkingLoader() immediately after applyConnectionStateSnapshot(state). Regression test verifies invocation order.

Local gates pass:

  • tsgo -p tsconfig.build.json --noEmit: 0 errors
  • vitest --run test/interactive-mode-status.test.ts: 153/153 tests pass

@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: 0401ba71dc

ℹ️ 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".

void this.agentConnection.abortBash();
}
if (this.hasActiveRefineCommand()) {
void this.agentConnection.abort();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resume the preserved queue after cancelling refine

When /refine has a queued follow-up, this calls the generic AgentConnection.abort(), which maps to AgentSession.requestAbort() and sets _sessionInputPumpSuspended = true (agent-session.ts:6506-6509). Because this path deliberately neither clears/restores the queued prompts nor sends resume_queue, the refinement finishes but the preserved prompts remain suspended indefinitely until the user submits another prompt. Use a refinement-specific cancellation path or explicitly resume preserved queued work after cancellation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Valid. Fixed in 9aca6ba2.

When canceling /refine via Ctrl+C, interruptOrClearInput() now calls restoreQueuedMessagesToEditor({ abort: true }) in addition to abort(). This ensures queued follow-up prompts are restored to the editor instead of remaining suspended indefinitely.

The condition for queue restoration is expanded from isAgentStreaming() to isAgentStreaming() || hasActiveRefineCommand(), sharing the same queue-restoration path that already worked for streaming cancellation.

Test updated in 6f0b233d to verify the new behavior: restoreQueuedMessagesToEditor is now expected to be called when canceling refine with queued prompts.

@junhoyeo

junhoyeo commented Aug 9, 2026

Copy link
Copy Markdown
Author

@codex review

All findings from round 2 addressed:

Finding Status
P2: Resume preserved queue after canceling refine ✅ Fixed in 9aca6ba2interruptOrClearInput() now calls restoreQueuedMessagesToEditor({ abort: true }) for both streaming and refine cancellation, ensuring queued prompts are restored to the editor.

Local gates pass:

  • tsgo -p tsconfig.build.json --noEmit: 0 errors
  • vitest --run test/interactive-mode-ctrl-c.test.ts: 21/21 tests pass
  • vitest --run test/interactive-mode-status.test.ts: 153/153 tests pass
  • Biome check: no issues

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 6f0b233ddc

ℹ️ 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".

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