Run Foundational Flows in Chat
## Problem When users encounter a failing pipeline, want to implement an issue, or need a code review, they have to navigate away from their conversation to trigger these actions manually. There's no way to naturally transition from getting help in chat to delegating a task to a foundational flow. ## Proposal Duo Chat recommends foundational flows when appropriate. When a user's request could benefit from a flow (e.g., "fix my pipeline", "implement this issue", "review this MR"), Duo presents the flow as a tool recommendation using the existing approve/deny mechanism. Users explicitly approve or deny the action, maintaining control while enabling seamless delegation. --- ## Core Requirements ### Flow Recommendation **Requirement:** When a user's request aligns with an available flow, Duo recommends it as a tool action requiring user approval. **Available Flows:** | Flow | Recommended when user wants to... | Status | |------|-----------------------------------|--------| | Fix Pipeline | Fix a failing pipeline | Phase 1 (sub-epic) | | Implement Issue | Create an MR that implements an issue | Planned | | Code Review | Perform a full code review on an MR | Planned | **Acceptance Criteria:** * Flow recommendations appear using the existing tool approve/deny UI * User must explicitly approve before the flow executes * User can deny and continue the conversation normally * Denying does not prevent Duo from helping in other ways (explaining, guiding, etc.) * Flow recommendations do not interfere with normal chat functionality * User's permissions are checked at approval time before the flow starts * User provides an explicit reference (pipeline URL, issue reference, MR reference) ### UX State for Flow Approval **Requirement:** Need a dedicated UX state for flow approval that fits the existing tool approval pattern. **Acceptance Criteria:** * Approval UI clearly identifies which flow is being recommended * Shows relevant context (pipeline URL, issue reference, MR reference) * Approve/Deny actions are prominent and clear * Matches existing tool approval visual patterns ### Session Widget **Requirement:** When a flow is approved and triggered from chat, users need inline visibility of its status. **Acceptance Criteria:** * Widget appears inline in the chat after user approves the flow * Shows distinct visual states: running, complete, failed, cancelled * Clicking the widget navigates to the session details * Widget updates in real-time as session status changes * Does not interrupt conversation flow (no new messages injected on status change) #### Session Widget Behavior 1. Widget shows completion * **Given** user approved a flow and it's running * **When** it completes successfully * **Then** the session widget updates to show completion 2. Widget shows failure * **Given** user approved a flow and it's running * **When** it fails * **Then** the session widget updates to show failure * **And** user can click widget to view details in the sessions page 3. Async execution * **Given** a flow is running after user approval * **When** the user sends another message * **Then** Duo responds normally to the new message * **And** the flow continues in the background * **And** the session widget remains visible and updates independently ## Scenarios #### Fix Pipeline 1. User asks to fix a pipeline * **Given** a user asks Duo to fix a pipeline (e.g., "fix my pipeline", "fix this build") * **When** Duo identifies a relevant pipeline * **Then** Duo recommends the Fix Pipeline flow via the approve/deny UI * **And** shows the pipeline reference in the approval prompt 2. User approves * **Given** Duo recommended the Fix Pipeline flow * **When** user clicks Approve * **Then** a session widget appears showing the flow is running * **And** Duo confirms the flow has started 3. User denies * **Given** Duo recommended the Fix Pipeline flow * **When** user clicks Deny * **Then** the flow does not execute * **And** Duo can continue helping in other ways #### Implement Issue 1. User asks to implement an issue * **Given** a user asks Duo to implement an issue (e.g., "implement this issue", "build this feature") * **When** Duo identifies a relevant issue * **Then** Duo recommends the Implement Issue flow via the approve/deny UI * **And** shows the issue reference in the approval prompt 2. User approves * **Given** Duo recommended the Implement Issue flow * **When** user clicks Approve * **Then** a session widget appears showing the flow is running 3. User denies * **Given** Duo recommended the Implement Issue flow * **When** user clicks Deny * **Then** the flow does not execute * **And** Duo can continue helping in other ways #### Code Review 1. User asks to review an MR * **Given** a user asks Duo to review an MR (e.g., "review this MR", "do a code review") * **When** Duo identifies a relevant MR * **Then** Duo recommends the Code Review flow via the approve/deny UI * **And** shows the MR reference in the approval prompt 2. User approves * **Given** Duo recommended the Code Review flow * **When** user clicks Approve * **Then** a session widget appears showing the flow is running 3. User denies * **Given** Duo recommended the Code Review flow * **When** user clicks Deny * **Then** the flow does not execute ## Out of Scope * Custom flows (only Fix Pipeline, Implement Issue, Code Review for this iteration) * Chaining multiple actions ("fix the pipeline then review the MR") * Detailed progress steps in chat * Modifying flow structure from chat * Duo answering questions about session/flow execution details * Automatic flow execution without user approval * Canceling a flow from the chat widget (cancel from sessions page) * Intent detection via the ideation issue is deferred ## Telemetry Requirements Will be amended to follow the audit template. | Metric | Description | |--------|-------------| | Approval rate | Approve vs. Deny ratio per flow type | | Flow trigger source | Chat vs. UI button (add attribute to current telemetry stream) | | Session widget click-through rate | How often users click the session widget to view details | ## Success Metrics Success metrics for phase 1 are qualitative. Numeric targets will be set post-launch once we have baseline data. * Users can successfully trigger flows from chat via the approve/deny mechanism * Chat-triggered flows have comparable success rates to button-triggered flows * High approval rate indicates Duo is recommending flows at appropriate times
epic