Skip to content

[fix] Prevent approval resume after Stop - #6579

Merged
mmabrouk merged 1 commit into
release/v0.115.0from
fix/v115-stop-voided-resume
Sep 5, 2026
Merged

[fix] Prevent approval resume after Stop#6579
mmabrouk merged 1 commit into
release/v0.115.0from
fix/v115-stop-voided-resume

Conversation

@mmabrouk

@mmabrouk mmabrouk commented Sep 5, 2026

Copy link
Copy Markdown
Member

Context

On mobile, approving a tool and immediately pressing Stop could still start the approved command. The Stop request fenced and cancelled the parked execution, but the approval response could release its automatic resume while that cancel request was in flight, creating a new execution after the user had stopped.

Changes

The mobile Stop path now voids any pending approval resume synchronously before it sends the durable cancel request. The shared conversation hook exposes that marker-only action separately from aborting the local stream, so the UI can preserve its server-first cancellation flow.

Both conversation hosts also preserve an explicitly consumed or voided approval marker when a stream errors. This prevents an error update from making an already stopped approval eligible for automatic resume again.

Tests

  • pnpm lint-fix (24 tasks passed across the full web lint graph)
  • pnpm --filter @agenta/chat exec vitest run tests/unit/hooks/useAgentConversation.test.ts (12 passed)
  • pnpm --filter @agenta/oss exec vitest run src/components/AgentChatSlice/hooks/useAgentChatSession.test.ts (8 passed)
  • Normal local browser flows passed on mobile and desktop. The long-running command was stopped, the composer returned to Send, and the next message completed.
  • Controlled mobile and desktop browser races held both the real approval transition and cancel responses, released approval while cancel remained in flight, and observed only the initial invoke before an explicit next message.

What to QA

  • On mobile, approve a long-running command and press Stop as soon as the approval closes. The command must not finish, and the composer must return to Send.
  • Repeat while delaying the approval transition response until after Stop. Releasing the response must not issue another invoke.
  • On desktop, repeat approve then immediate Stop and confirm the next message sends normally.

@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
agenta-documentation Ready Ready Preview Sep 5, 2026 3:17pm UTC

Request Review

@mmabrouk

mmabrouk commented Sep 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

— Codex

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Team

Run ID: 6349342e-d570-42d6-867d-0459b802dbcc

📥 Commits

Reviewing files that changed from the base of the PR and between 480e020 and df97b83.

📒 Files selected for processing (5)
  • web/mobile/src/features/chat/LiveConversation.tsx
  • web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.test.ts
  • web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.ts
  • web/packages/agenta-chat/src/hooks/useAgentConversation.ts
  • web/packages/agenta-chat/tests/unit/hooks/useAgentConversation.test.ts

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where stopping a live conversation could allow a pending approval or client-tool action to resume unexpectedly.
    • Improved cancellation behavior while a stop request is processing, including when the conversation stream encounters an error.
    • Ensured pending approval resumes are discarded promptly when users stop the conversation.
    • Prevented delayed approval responses from starting a new interaction after cancellation.

Walkthrough

Changes

The chat flow now invalidates pending approval resumes before stop or stream-error handling. The conversation hook exposes voidPendingResume, the session hook preserves consumed gates, and the mobile stop handler invokes the helper before cancellation. Tests cover delayed interaction writes, cancellation races, and missing project identifiers.

Pending resume cancellation

Layer / File(s) Summary
Conversation resume gate
web/packages/agenta-chat/src/hooks/useAgentConversation.ts, web/packages/agenta-chat/tests/unit/hooks/useAgentConversation.test.ts
The conversation hook exposes voidPendingResume, preserves voided markers during stream errors, and invokes the helper before aborting. Tests cover deferred approval interaction writes.
Session gate integration
web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.ts, web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.test.ts
The session hook voids the live gate at stop start and preserves that state after stream errors. Tests verify that automatic approval resumption remains disabled during cancellation and when projectId is null.
Mobile stop wiring
web/mobile/src/features/chat/LiveConversation.tsx
The mobile stop handler calls voidPendingResume before setting the stopping latch and issuing the durable stop. Its dependency array includes the new callback.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to df97b

Stopping a chat now reliably prevents a delayed approval response from starting a new execution, including when cancellation cannot be sent. The updated behavior is covered by targeted session and delayed-resume tests, with no remaining merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 5…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: preventing approval resume after Stop.
Description check ✅ Passed The description directly explains the Stop race, implementation changes, tests, and QA coverage.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/v115-stop-voided-resume

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Team

Run ID: df547a00-d4d9-4520-9636-d0480d1d8bdf

📥 Commits

Reviewing files that changed from the base of the PR and between 5c4c2ef and 005d111.

📒 Files selected for processing (5)
  • web/mobile/src/features/chat/LiveConversation.tsx
  • web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.test.ts
  • web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.ts
  • web/packages/agenta-chat/src/hooks/useAgentConversation.ts
  • web/packages/agenta-chat/tests/unit/hooks/useAgentConversation.test.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review.

Comment thread web/packages/agenta-chat/src/hooks/useAgentConversation.ts Outdated
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@mmabrouk I will review pull request #6579.

⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mmabrouk
mmabrouk force-pushed the fix/v115-stop-voided-resume branch from 005d111 to 139da66 Compare September 5, 2026 15:05
@mmabrouk

mmabrouk commented Sep 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

— Codex

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Team

Run ID: 3bb1f1af-0b3d-4801-b349-1ba63c33cb10

📥 Commits

Reviewing files that changed from the base of the PR and between 005d111 and 139da66.

📒 Files selected for processing (3)
  • web/mobile/src/features/chat/LiveConversation.tsx
  • web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.ts
  • web/packages/agenta-chat/src/hooks/useAgentConversation.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review.

Comment thread web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.ts Outdated
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@mmabrouk I will review pull request #6579.

⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mmabrouk
mmabrouk force-pushed the fix/v115-stop-voided-resume branch from 139da66 to df97b83 Compare September 5, 2026 15:16
@mmabrouk

mmabrouk commented Sep 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

— Codex

@mmabrouk

mmabrouk commented Sep 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

Final-head re-review requested for df97b832af; the prior finding was resolved with the pre-guard fence and null-project regression.

— Codex

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@mmabrouk I will run a complete final-head review for #6579, including commit df97b832af.

⚠️ Action not completed

Pull request is closed.

@mmabrouk
mmabrouk merged commit 7496c66 into release/v0.115.0 Sep 5, 2026
45 of 46 checks passed
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@mmabrouk The review cannot run because pull request #6579 is closed. Reopen the pull request, then request @coderabbitai review.

You are interacting with an AI system.

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