Skip to content

Add plan refinement and confirmation-gated approve/execute notification intents #1725

Closed

Description

@propr-dev

Context

Plan-ready notifications must deep-link into Planner Studio and offer Refine and Approve/Execute actions. Approving or launching agent work is materially consequential and must never occur from a background push click or an unconfirmed query parameter.

Requirements

  • Add a small parser for notification intent query parameters.
  • Support refine and approve_execute intents for plan notifications.
  • Refine opens Planner Studio's existing refinement UI and focuses its input.
  • Approve/execute opens an in-app confirmation dialog summarizing repository, issue count, agent/model selection, and PR behavior.
  • Do not execute until all existing plan validation and selection requirements pass.
  • Reuse existing Planner Studio approve/finalize/execute callbacks rather than duplicating API calls.
  • Remove the intent query parameter after it has been consumed to prevent repeat execution on refresh/back navigation.
  • Respect demo mode and disabled action states.
  • Add plan-specific action buttons to the Inbox.

Acceptance Criteria

  • Refine navigates to the correct draft and focuses the refinement composer.
  • Approve/execute never runs automatically from URL navigation.
  • Cancel closes the confirmation without mutating the plan.
  • Confirm invokes the same validated handler as the existing desktop/mobile plan control.
  • Refreshing after confirmation does not repeat the action.
  • Demo mode shows the existing read-only explanation.

Created by ProPR AI Planner

Activity

  1. propr-dev commented on Aug 2, 2026

    @propr-dev
    ContributorAuthor

    Suggested Implementation:

    Implementation Approach

    Treat notification actions as foreground UI intents, not executable commands. The URL carries only a request to open an existing workflow. Planner Studio consumes the intent and delegates to its established handlers after rendering confirmation. A new backend shortcut endpoint was rejected because it would bypass existing agent/model, dependency, and PR-option validation.

    File: propr-ui/src/hooks/useNotificationIntent.ts (new file)

    Why this file: A shared, one-shot query parser prevents task and plan pages from independently implementing unsafe repeatable intent behavior.

    import { useCallback, useMemo } from 'react';
    import { useSearchParams } from 'react-router-dom';
    
    export type NotificationIntent = 'refine' | 'approve_execute' | 'follow_up' | 'stop';
    
    export function useNotificationIntent(allowed: NotificationIntent[]) {
      const [searchParams, setSearchParams] = useSearchParams();
      const intent = useMemo(() => {
        const value = searchParams.get('intent') as NotificationIntent | null;
        return value && allowed.includes(value) ? value : null;
      }, [allowed, searchParams]);
    
      const consume = useCallback(() => {
        const next = new URLSearchParams(searchParams);
        next.delete('intent');
        next.delete('notification');
        setSearchParams(next, { replace: true });
      }, [searchParams, setSearchParams]);
    
      return { intent, consume };
    }

    File: propr-ui/src/components/Inbox/PlanNotificationActions.tsx (new file)

    Why this file: The Inbox should only navigate to Planner Studio with an intent; it must not finalize or execute a plan from the list itself.

    import React from 'react';
    import type { NotificationEvent } from '@propr/shared';
    import { CheckCheck, MessageSquareMore, Trash2 } from 'lucide-react';
    import { useNavigate } from 'react-router-dom';
    
    interface Props {
      item: NotificationEvent;
      onDismiss: () => Promise<void>;
    }
    
    export function PlanNotificationActions({ item, onDismiss }: Props) {
      const navigate = useNavigate();
      const actions = new Set(item.actions);
      const openWithIntent = (intent: 'refine' | 'approve_execute') => {
        const separator = item.deepLink.includes('?') ? '&' : '?';
        navigate(`${item.deepLink}${separator}intent=${intent}&notification=${encodeURIComponent(item.id)}`);
      };
      return (
        <div className='flex flex-wrap gap-2'>
          {actions.has('refine') && <button type='button' onClick={() => openWithIntent('refine')} className='min-h-10 rounded-md border px-3 text-sm'><MessageSquareMore className='mr-1 inline h-4 w-4' />Refine</button>}
          {actions.has('approve_execute') && <button type='button' onClick={() => openWithIntent('approve_execute')} className='min-h-10 rounded-md bg-teal-700 px-3 text-sm text-white'><CheckCheck className='mr-1 inline h-4 w-4' />Approve / Execute</button>}
          {actions.has('dismiss') && <button type='button' onClick={onDismiss} className='min-h-10 rounded-md border px-3 text-sm'><Trash2 className='mr-1 inline h-4 w-4' />Dismiss</button>}
        </div>
      );
    }

    File: propr-ui/src/components/TaskPlanner/NotificationPlanIntentDialog.tsx (new file)

    Why this file: The confirmation presents enough context for a deliberate decision and delegates the actual work to existing validated handlers.

    import React from 'react';
    
    interface Props {
      open: boolean;
      repository: string;
      issueCount: number;
      summary: string;
      disabled?: boolean;
      onCancel: () => void;
      onConfirm: () => Promise<void>;
    }
    
    export function NotificationPlanIntentDialog({ open, repository, issueCount, summary, disabled, onCancel, onConfirm }: Props) {
      if (!open) return null;
      return (
        <div role='dialog' aria-modal='true' aria-labelledby='notification-plan-confirm-title' className='fixed inset-0 z-50 flex items-end sm:items-center justify-center bg-black/40 p-3'>
          <div className='w-full max-w-md rounded-xl bg-white p-5 shadow-xl'>
            <h2 id='notification-plan-confirm-title' className='text-lg font-semibold'>Approve and continue to execution?</h2>
            <p className='mt-2 text-sm text-slate-600'>This will use the same validated Planner Studio workflow as the normal approve/execute control.</p>
            <dl className='mt-4 grid grid-cols-[auto_1fr] gap-x-3 gap-y-2 text-sm'>
              <dt className='text-slate-500'>Repository</dt><dd className='truncate'>{repository}</dd>
              <dt className='text-slate-500'>Issues</dt><dd>{issueCount}</dd>
              <dt className='text-slate-500'>Execution</dt><dd>{summary}</dd>
            </dl>
            <div className='mt-5 flex justify-end gap-2'>
              <button type='button' onClick={onCancel} className='rounded-md border px-4 py-2'>Cancel</button>
              <button type='button' disabled={disabled} onClick={() => void onConfirm()} className='rounded-md bg-teal-700 px-4 py-2 text-white disabled:opacity-50'>Confirm</button>
            </div>
          </div>
        </div>
      );
    }

    File: propr-ui/src/components/TaskPlanner/PlanEditor.tsx

    Why this file: PlanEditor already owns the mobile review/refinement layout and the validated approval handler. It is the correct place to consume plan intents.

    --- a/propr-ui/src/components/TaskPlanner/PlanEditor.tsx
    +++ b/propr-ui/src/components/TaskPlanner/PlanEditor.tsx
    @@ -1,5 +1,8 @@
    +import { useEffect, useState } from 'react';
    +import { useNotificationIntent } from '../../hooks/useNotificationIntent';
    +import { NotificationPlanIntentDialog } from './NotificationPlanIntentDialog';
    @@ -80,6 +83,20 @@
    +  const { intent, consume } = useNotificationIntent(['refine', 'approve_execute']);
    +  const [showNotificationConfirmation, setShowNotificationConfirmation] = useState(false);
    +
    +  useEffect(() => {
    +    if (intent === 'refine') {
    +      // Reuse the existing mobile refinement panel so notification entry behaves
    +      // exactly like a user selecting Refine from Planner Studio.
    +      setMobileView('refine');
    +      consume();
    +    } else if (intent === 'approve_execute') {
    +      setShowNotificationConfirmation(true);
    +      // Consume before confirmation so refresh cannot repeat a confirmed action.
    +      consume();
    +    }
    +  }, [consume, intent]);
    @@ -220,6 +237,18 @@
    +  <NotificationPlanIntentDialog
    +    open={showNotificationConfirmation}
    +    repository={draft.repository}
    +    issueCount={plan.tasks.length}
    +    summary={executionSummary}
    +    disabled={isDemoMode || isApproveDisabled}
    +    onCancel={() => setShowNotificationConfirmation(false)}
    +    onConfirm={async () => {
    +      // Delegate to the existing handler so dependency, model, and PR-option
    +      // validation cannot drift between normal and notification entry points.
    +      await handleApproveAndExecute();
    +      setShowNotificationConfirmation(false);
    +    }}
    +  />

    File: propr-ui/src/pages/InboxPage.tsx

    Why this file: Render the plan action component for plan targets.

    --- a/propr-ui/src/pages/InboxPage.tsx
    +++ b/propr-ui/src/pages/InboxPage.tsx
    @@ -1,5 +1,6 @@
    +import { PlanNotificationActions } from '../components/Inbox/PlanNotificationActions';
    @@ -155,6 +156,9 @@
    +                  {item.targetType === 'plan' && (
    +                    <div className='mt-3'><PlanNotificationActions item={item} onDismiss={() => dismiss(item)} /></div>
    +                  )}
  2. propr-dev commented on Aug 24, 2026

    @propr-dev
    ContributorAuthor

    🤖 AI processing has started for this issue using codex agent with gpt-5.6-sol model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: codex
    • Model: gpt-5.6-sol
    • Branch: 1725/gpt-5.6-sol-add-plan-refinement-and-c-20260824-2115-tyh
    • Base Branch: 1716-epic-failed-to-3m8
    • Worktree: issue-1725-20260824-2115-gpt-5.6-sol-tyh

    🔍 Track Task Execution

  3. added a commit that references this issue on Aug 24, 2026
  4. added a commit that references this issue on Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions