Skip to content

fix(frontend): Make parked connection requests visible and declinable - #5251

Closed
ashrafchowdury wants to merge 6 commits into
release/v0.106.0from
feat-agent-updated-interaction-dock
Closed

fix(frontend): Make parked connection requests visible and declinable #5251
ashrafchowdury wants to merge 6 commits into
release/v0.106.0from
feat-agent-updated-interaction-dock

Conversation

@ashrafchowdury

Copy link
Copy Markdown
Contributor

Context

When the agent asks for a connection in the playground chat (a parked request_connection client tool), the runner legitimately ends the stream. Every "in progress" signal in the chat was derived from stream status, so the UI looked idle: no working dots, a plain send button. Meanwhile the queue gate (isHitlPending) held every new message, so sends piled up as "1 queued" with no visible reason. Users read this as the agent being stuck and kept resending. There was also no way to refuse the request: the inline chip only offered Connect, and the timeout only arms after the popup opens, so an ignored request froze the conversation forever (a reload restored the same frozen state).

Changes

The paused run is now a first-class "waiting for you" state, following the existing ApprovalDock contract (the dock owns the actions, the inline row is a marker).

InteractionDock (new). A persistent card between the transcript and the composer: "The agent is waiting for you", with Connect and "Not now" buttons. It cannot scroll out of reach. "Not now" settles the parked call with {connected: false, reason: "declined"} (distinct from "cancelled", which means an abandoned popup), so the run resumes, the agent can respond gracefully, and queued messages release.

Shared OAuth flow. The popup flow (create connection, origin-validated callback, closed-popup poll, timeout backstop) moved from ConnectToolWidget into useConnectFlow. The dock runs the live parked call; the inline chip keeps the post-settle states (result chip, Retry). Both instances can be mounted for the same call, so every live-settle path now also checks meta.settled; a second addToolOutput for the same call is impossible.

The composer tells the truth while paused:

Before: placeholder "Ask the agent...", plain send button, pill "1 queued".
After: placeholder says the agent is waiting and new messages will be queued, the last turn shows a static "Waiting for your input" chip in the working-dots slot, and the pill reads "1 queued · waiting on you" (popover: "Held until you answer the agent").

isPendingClientToolInteraction is now exported from @agenta/playground, so the dock's visibility and the queue's hold derive from the same predicate and cannot disagree.

Tests / notes

  • @agenta/playground builds; all 198 package unit tests pass.
  • eslint clean on @agenta/oss and @agenta/playground; tsc reports no errors in touched files (the two ElicitationWidget errors are pre-existing on the branch).
  • The OAuth popup was not exercised end to end against a local stack; worth one manual pass.
  • Elicitation forms stay inline (they carry their own Decline/Dismiss); they get the composer waiting state but no dock card.

What to QA

  • Ask an agent to use a tool whose connection is missing (e.g. Telegram). The dock card appears above the composer, the last turn shows "Waiting for your input", and the placeholder changes.
  • Type a message while the request is pending. It queues; the pill says "1 queued · waiting on you" and the popover explains the hold.
  • Click "Not now". The run resumes, the agent acknowledges and continues, then the queued message sends.
  • Click Connect and finish the OAuth popup. The inline chip flips to "connected" and the run resumes. Closing the popup midway resumes the run as cancelled.
  • Reload the page while a request is pending. The dock reappears and both buttons still work (before this change, a reload restored a frozen chat).
  • Regression: tool approvals still pause into the ApprovalDock unchanged, and a normal streaming turn still shows the dots and the spinning stop button.

Previews

Before:
image.png
After:
image.png

- Added InteractionDock component to manage parked client-tool interactions, mirroring ApprovalDock's functionality.
- Introduced WaitingForInput component to indicate when the agent is waiting for user input.
- Updated AgentConversation to integrate InteractionDock and display waiting states appropriately.
- Enhanced QueuedMessages to reflect held messages when the interaction is pending.
- Refactored ConnectToolWidget to utilize useConnectFlow for managing connection states and actions.
- Added useConnectFlow hook to centralize connection logic for both InteractionDock and inline components.
- Updated state management to include isPendingClientToolInteraction for better handling of client-tool interactions.
@vercel

vercel Bot commented Jul 12, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment Jul 20, 2026 12:49pm

Request Review

@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. Frontend labels Jul 12, 2026
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds parked connect-interaction handling and waiting-state UI to agent chat. It also adds linear revision selection and agent-specific commit, deployment, navigation, workflow-state, and public export behavior in the playground.

Changes

Parked chat interactions

Layer / File(s) Summary
Shared connect-flow settlement
web/oss/src/components/AgentChatSlice/components/clientTools/useConnectFlow.ts
Centralizes OAuth connection creation, popup validation, cancellation, decline, timeout, retry, cleanup, and client-tool settlement.
Docked connect interaction UI
web/oss/src/components/AgentChatSlice/components/InteractionDock.tsx, web/oss/src/components/AgentChatSlice/components/clientTools/ConnectToolWidget.tsx
Detects pending connect interactions, renders docked controls, and delegates connection state to useConnectFlow.
Conversation waiting and queue wiring
web/oss/src/components/AgentChatSlice/AgentConversation.tsx, web/oss/src/components/AgentChatSlice/components/QueuedMessages.tsx
Adds waiting indicators, held queue messaging, parked interaction wiring, and HITL-specific composer text.

Playground agent revision UX

Layer / File(s) Summary
Linear revision selector
web/oss/src/components/Playground/Components/AgentRevisionSelector/index.tsx, web/oss/src/components/Playground/Components/Menus/SelectVariant/*, web/packages/agenta-entity-ui/src/selection/components/UnifiedEntityPicker/variants/TreeSelectPopupContent.tsx
Adds linear versioning labels and presentation, suppresses badges and search, and supports flattening a single revision-tree parent.
Agent workflow commit and navigation rules
web/oss/src/components/Playground/Components/Modals/CommitVariantChangesModal/index.tsx, web/oss/src/components/Playground/Components/PlaygroundVariantConfig/assets/PlaygroundVariantConfigHeader.tsx, web/oss/src/state/workflow/hooks.ts, web/oss/src/components/Sidebar/hooks/useSidebarConfig/index.tsx, web/packages/agenta-playground/src/*
Adds agent detection and naming, restricts agent commits to versions, disables agent deployment actions, excludes agents from Registry navigation, and re-exports pending client-tool state.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AgentConversation
  participant InteractionDock
  participant useConnectFlow
  participant OAuthPopup
  participant ClientTool
  AgentConversation->>InteractionDock: pass pending interaction
  InteractionDock->>useConnectFlow: runConnect, cancel, or decline
  useConnectFlow->>OAuthPopup: open and monitor OAuth flow
  OAuthPopup-->>useConnectFlow: validated completion message
  useConnectFlow->>ClientTool: settle output or error
  ClientTool-->>AgentConversation: update interaction state
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 60.00%.
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 summarizes the main UI change: parked connection requests are now visible and can be declined.
Description check ✅ Passed The description is directly related to the changeset and accurately describes the new dock, waiting state, and shared connection flow.
✨ 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 feat-agent-updated-interaction-dock

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.

@ashrafchowdury
ashrafchowdury changed the base branch from main to big-agents July 12, 2026 14:55
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:XXL This PR changes 1000+ lines, ignoring generated files. labels Jul 12, 2026

@mmabrouk mmabrouk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @ashrafchowdury I think it makes sense and it unifies the UI for approvals. The copy can be improved though.

@ardaerzin wdyt?

@ashrafchowdury

Copy link
Copy Markdown
Contributor Author

Updated the copy:

Connect Gmail to let the agent continue, or continue without the connection.

@mmabrouk
mmabrouk changed the base branch from big-agents to main July 18, 2026 15:54
- reframe default variant as history, nothing else changed
- hide the deployment option for the agent

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
web/oss/src/components/AgentChatSlice/components/clientTools/useConnectFlow.ts (1)

36-41: 📐 Maintainability & Code Quality | 🔵 Trivial

Unresolved TODO left in shipped code.

CONNECT_TIMEOUT_MS's bound is flagged as an open question ("NOTE for Mahmoud: confirm the bound") rather than a settled value. Worth confirming/closing before merge so a stale note doesn't linger in production code.

Want me to open a follow-up issue to track confirming this timeout, or help track down the referenced open question?


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6fdcc7dc-34f9-43c8-ba3c-585199dab1bd

📥 Commits

Reviewing files that changed from the base of the PR and between 3b0c0cb and 4cd8323.

📒 Files selected for processing (17)
  • web/oss/src/components/AgentChatSlice/AgentConversation.tsx
  • web/oss/src/components/AgentChatSlice/components/InteractionDock.tsx
  • web/oss/src/components/AgentChatSlice/components/QueuedMessages.tsx
  • web/oss/src/components/AgentChatSlice/components/clientTools/ConnectToolWidget.tsx
  • web/oss/src/components/AgentChatSlice/components/clientTools/useConnectFlow.ts
  • web/oss/src/components/Playground/Components/AgentRevisionSelector/index.tsx
  • web/oss/src/components/Playground/Components/Menus/SelectVariant/components/RevisionChildTitle.tsx
  • web/oss/src/components/Playground/Components/Menus/SelectVariant/index.tsx
  • web/oss/src/components/Playground/Components/Menus/SelectVariant/types.d.ts
  • web/oss/src/components/Playground/Components/Modals/CommitVariantChangesModal/index.tsx
  • web/oss/src/components/Playground/Components/PlaygroundVariantConfig/assets/PlaygroundVariantConfigHeader.tsx
  • web/oss/src/components/Sidebar/hooks/useSidebarConfig/index.tsx
  • web/oss/src/state/workflow/hooks.ts
  • web/packages/agenta-entity-ui/src/selection/components/UnifiedEntityPicker/variants/TreeSelectPopupContent.tsx
  • web/packages/agenta-playground/src/index.ts
  • web/packages/agenta-playground/src/state/execution/index.ts
  • web/packages/agenta-playground/src/state/index.ts

Comment on lines +19 to +22
* Settle on every terminal path (design §"Settle on every path"), so the run never hangs:
* success → {connected:true, integration, slug} · decline → {connected:false, reason:"declined"}
* · cancel/abandon → {connected:false, reason:"cancelled"} · timeout → {connected:false,
* reason:"timeout"} · failure → errorText.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Create-failure path violates the file's own "failure → errorText" contract.

The docstring promises failure → errorText, but the catch block's finish({connected: false, integration, slug, reason: message}) (Line 258) routes through the ConnectOutput/output branch of finish(), not the errorText branch. In fact, no call site in this file ever constructs {errorText: ...} — that branch of finish() (Lines 120-122) is dead code.

Practical effect: a genuine API/network failure while creating the connection settles as output: {connected:false, reason:"<raw error message>"}, indistinguishable in shape from a structured decline/cancel/timeout. Downstream, ConnectToolWidget distinguishes output-error state meaningfully elsewhere (deferredByRunner), so the agent/runner likely can't tell "user declined" apart from "connection creation actually failed."

🐛 Proposed fix
             } catch (err) {
                 if (settleParkedCall && !activeRef.current) return
                 const message = err instanceof Error ? err.message : "Connection failed."
                 // A create failure is terminal for the parked call: settle so the run resumes; for a
                 // manual retry just surface the reason with another Retry.
                 setPhase("error")
                 setErrorText(message)
-                if (settleParkedCall) finish({connected: false, integration, slug, reason: message})
+                if (settleParkedCall) finish({errorText: message})
             }

Also applies to: 251-259

Comment on lines +230 to 234
className={cn(
"tree-popup-compact pb-2",
flattenSingleParent ? "tree-popup-flat px-1.5 pt-2.5" : "px-2",
)}
>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Apply flattened layout classes only when the tree is actually flattened.

The class tree-popup-flat removes the left padding from leaf nodes. Currently, it is applied whenever the flattenSingleParent prop is true, even if the tree was not actually flattened (e.g., if treeData.length > 1). This would incorrectly strip the indentation from leaf nodes in a multi-parent tree.

Update the condition to ensure the styling is only applied when the tree data is successfully flattened.

🐛 Proposed fix
                     className={cn(
                         "tree-popup-compact pb-2",
-                        flattenSingleParent ? "tree-popup-flat px-1.5 pt-2.5" : "px-2",
+                        flattenSingleParent && treeData.length === 1 ? "tree-popup-flat px-1.5 pt-2.5" : "px-2",
                     )}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
className={cn(
"tree-popup-compact pb-2",
flattenSingleParent ? "tree-popup-flat px-1.5 pt-2.5" : "px-2",
)}
>
className={cn(
"tree-popup-compact pb-2",
flattenSingleParent && treeData.length === 1 ? "tree-popup-flat px-1.5 pt-2.5" : "px-2",
)}
>

@mmabrouk
mmabrouk changed the base branch from main to release/v0.106.0 July 25, 2026 14:29
@mmabrouk

Copy link
Copy Markdown
Member

@ashrafchowdury I think this is still relevant can you please resolve the conflicts and check whether still works and add it to the merge queue in the 106 thread

@ashrafchowdury

Copy link
Copy Markdown
Contributor Author

created new clean PR here: #5521 @mmabrouk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frontend size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants