diff --git a/.changeset/fn-8533-mobile-planning-comments.md b/.changeset/fn-8533-mobile-planning-comments.md new file mode 100644 index 0000000000..de11f705fc --- /dev/null +++ b/.changeset/fn-8533-mobile-planning-comments.md @@ -0,0 +1,7 @@ +--- +"@runfusion/fusion": patch +--- + +summary: Keep Planning Mode selected-text comments reachable in the mobile action rail. +category: fix +dev: Mobile uses the plan footer at up to 768px; wider layouts retain the selection-adjacent trigger. diff --git a/docs/dashboard-guide.md b/docs/dashboard-guide.md index cf027bd054..6010aab427 100644 --- a/docs/dashboard-guide.md +++ b/docs/dashboard-guide.md @@ -2257,4 +2257,4 @@ Custom workflow authors can add optional explanatory copy beneath each column na ## Planning Mode contextual comments -In plan review, select text inside the rendered plan and choose **Add comment to selection**. Enter a suggestion to capture the selected quote and suggestion as a pending contextual comment. You can remove individual comments before choosing **Submit comments**; Fusion sends the ordered batch through the existing Planning Mode revision generation, so the agent revises the quoted areas while preserving unaffected plan content. A successful revised-plan update clears the batch; a failed submission retains it for retry. +In plan review, select text inside the rendered plan and choose **Add comment to selection**. On mobile widths through 768px, the selection action appears in the bottom plan-action rail beside **Refine** and **Proceed with plan**; at 769px and wider it stays beside the selected plan content. Enter a suggestion to capture the selected quote and suggestion as a pending contextual comment. You can remove individual comments before choosing **Submit comments**; Fusion sends the ordered batch through the existing Planning Mode revision generation, so the agent revises the quoted areas while preserving unaffected plan content. A successful revised-plan update clears the batch; a failed submission retains it for retry. diff --git a/packages/dashboard/app/components/PlanningModeModal.css b/packages/dashboard/app/components/PlanningModeModal.css index 03201e7ed1..6e0f74927f 100644 --- a/packages/dashboard/app/components/PlanningModeModal.css +++ b/packages/dashboard/app/components/PlanningModeModal.css @@ -1774,6 +1774,10 @@ its established Refine and Proceed action hierarchy. margin-top: var(--space-lg); } +.planning-add-comment--mobile { + display: none; +} + .planning-comment-editor, .planning-comment-tray { display: flex; @@ -1880,6 +1884,22 @@ Refine/Proceed actions share one compact bottom baseline; equal footer/button he plan actions, and a token-sized bottom inset keep all three controls inline without extra space. */ @media (max-width: 768px) { + /* + FNXC:PlanningComments 2026-07-31-00:00: + A selected quote needs a reachable mobile action beside Refine and Proceed, not a control lost + in the scrollable document. At 769px and above the selection-adjacent document trigger stays + canonical. These established 768px/1024px media boundaries are permitted; new dimensions use + only existing design tokens. + */ + .planning-add-comment--document { + display: none; + } + + .planning-add-comment--mobile { + display: inline-flex; + margin-top: 0; + } + .planning-comment-tray li { grid-template-columns: minmax(0, 1fr) auto; } diff --git a/packages/dashboard/app/components/PlanningModeModal.tsx b/packages/dashboard/app/components/PlanningModeModal.tsx index 6bec530ecd..6a1f153eaf 100644 --- a/packages/dashboard/app/components/PlanningModeModal.tsx +++ b/packages/dashboard/app/components/PlanningModeModal.tsx @@ -667,6 +667,24 @@ export function PlanningModeModal({ isOpen, onClose, onTaskCreated, onTasksCreat const planDocumentRef = useRef(null); const commentInputRef = useRef(null); const addCommentTriggerRef = useRef(null); + const mobileAddCommentTriggerRef = useRef(null); + const restoreCommentTriggerFocusRef = useRef(false); + + const focusAddCommentTrigger = useCallback(() => { + const isMobile = window.matchMedia?.("(max-width: 768px)").matches ?? false; + (isMobile ? mobileAddCommentTriggerRef : addCommentTriggerRef).current?.focus(); + }, []); + + /* + FNXC:PlanningComments 2026-07-23-09:30: + Closing the conditional comment editor unmounts its trigger during the state transition. Restore focus only in the post-render effect, after Cancel or Add comment remounts the desktop or mobile trigger. + */ + useEffect(() => { + if (!isCommentEditorOpen && restoreCommentTriggerFocusRef.current) { + restoreCommentTriggerFocusRef.current = false; + focusAddCommentTrigger(); + } + }, [focusAddCommentTrigger, isCommentEditorOpen]); useEffect(() => { // A batch belongs to one visible session; never carry comments into another plan. @@ -2617,10 +2635,10 @@ export function PlanningModeModal({ isOpen, onClose, onTaskCreated, onTasksCreat if (!quote || !suggestion) return; setContextualComments((comments) => [...comments, { quote, suggestion }]); setCommentDraft(""); - setSelectedPlanQuote(null); + // FNXC:PlanningComments 2026-07-23-09:30: Keep the quote while closing the editor so its conditional trigger remounts and can receive restored focus after adding a comment. + restoreCommentTriggerFocusRef.current = true; setIsCommentEditorOpen(false); window.getSelection()?.removeAllRanges(); - addCommentTriggerRef.current?.focus(); }, [commentDraft, selectedPlanQuote]); const handleSubmitContextualComments = useCallback(async () => { @@ -2909,7 +2927,7 @@ export function PlanningModeModal({ isOpen, onClose, onTaskCreated, onTasksCreat