From db7b46f60fe83543fff8e28d8c9052a8efdf69e8 Mon Sep 17 00:00:00 2001 From: gsxdsm Date: Tue, 30 Jun 2026 17:20:42 -0700 Subject: [PATCH] FN-7310: add task planner chat tab Add a dedicated task-detail Chat surface for planner-model conversations separate from Activity steering. - Add task-scoped planner chat session creation and routing with planning-model overrides. - Render a new top-level Chat tab next to Activity, including streaming responses, tool-call cards, and retry/error states. - Cover planner chat tab ordering, session reuse, route validation, manager dispatch, and dashboard documentation. Files changed: .changeset/fn-7310-planner-chat.md | 7 + docs/dashboard-guide.md | 3 +- packages/dashboard/app/api/legacy.ts | 35 +++ .../dashboard/app/components/TaskDetailModal.tsx | 40 ++- .../app/components/TaskPlannerChatTab.css | 149 ++++++++++ .../app/components/TaskPlannerChatTab.tsx | 322 +++++++++++++++++++++ ...etailModal.responsive-and-dependencies.test.tsx | 13 +- .../__tests__/TaskDetailModal.test-helpers.ts | 3 + .../components/__tests__/TaskDetailModal.test.tsx | 58 ++++ .../__tests__/TaskPlannerChatTab.test.tsx | 193 ++++++++++++ .../dashboard/src/__tests__/chat-manager.test.ts | 65 +++++ .../dashboard/src/__tests__/chat-routes.test.ts | 106 +++++++ packages/dashboard/src/chat.ts | 132 ++++++++- .../dashboard/src/routes/register-chat-routes.ts | 68 +++++ 14 files changed, 1181 insertions(+), 13 deletions(-) Fusion-Task-Id: FN-7310 Fusion-Task-Lineage: a276c356-599e-4495-9879-472d157d95e5 Co-authored-by: Fusion (runfusion.ai) --- .changeset/fn-7310-planner-chat.md | 7 + docs/dashboard-guide.md | 3 +- packages/dashboard/app/api/legacy.ts | 35 ++ .../app/components/TaskDetailModal.tsx | 40 ++- .../app/components/TaskPlannerChatTab.css | 149 ++++++++ .../app/components/TaskPlannerChatTab.tsx | 322 ++++++++++++++++++ ...Modal.responsive-and-dependencies.test.tsx | 13 +- .../__tests__/TaskDetailModal.test-helpers.ts | 3 + .../__tests__/TaskDetailModal.test.tsx | 58 ++++ .../__tests__/TaskPlannerChatTab.test.tsx | 193 +++++++++++ .../src/__tests__/chat-manager.test.ts | 65 ++++ .../src/__tests__/chat-routes.test.ts | 106 ++++++ packages/dashboard/src/chat.ts | 132 ++++++- .../src/routes/register-chat-routes.ts | 68 ++++ 14 files changed, 1181 insertions(+), 13 deletions(-) create mode 100644 .changeset/fn-7310-planner-chat.md create mode 100644 packages/dashboard/app/components/TaskPlannerChatTab.css create mode 100644 packages/dashboard/app/components/TaskPlannerChatTab.tsx create mode 100644 packages/dashboard/app/components/__tests__/TaskPlannerChatTab.test.tsx diff --git a/.changeset/fn-7310-planner-chat.md b/.changeset/fn-7310-planner-chat.md new file mode 100644 index 0000000000..472492131e --- /dev/null +++ b/.changeset/fn-7310-planner-chat.md @@ -0,0 +1,7 @@ +--- +"@runfusion/fusion": minor +--- + +summary: Add a task-detail Chat tab for planner-model conversations. +category: feature +dev: Adds task-scoped planner chat session routing and a dedicated TaskPlannerChatTab separate from Activity steering. diff --git a/docs/dashboard-guide.md b/docs/dashboard-guide.md index e784f0d580..64ecf08841 100644 --- a/docs/dashboard-guide.md +++ b/docs/dashboard-guide.md @@ -1042,6 +1042,7 @@ Inspect task definition, logs, review feedback, comments, artifacts, workflow ou - Editable tasks with descriptions show **Summarize as title** beside the read-mode title; it asks AI to generate a concise title from the description and saves it without opening the edit form. - The **Summary** tab appears first for `done` tasks and is their default landing tab. It shows the recorded completion summary, changed-file/merge stats when available, completed steps, workflow results, retry counts, and a token usage & cost section broken down by model from the already-loaded task detail; unpriced models show cost as unavailable rather than `$0`. Non-`done` tasks still open on **Activity** by default. - The **Activity → Current** segment includes an expand/collapse control that lets the transcript and composer fill the task-detail modal, then restores the normal header, tabs, and action footer when collapsed. +- The top-level **Chat** tab appears immediately after **Activity** and starts a task-scoped planner-model conversation. It uses the task's effective planning model, persists messages in a resumable chat session, shows starter prompts for common planning questions, can render structured planner questions, and converts only explicit operator steering intent through the scoped steering tool. Activity remains the primary operational transcript/feed/raw-log surface. - Task-detail Activity steering comments are persisted as user comments/steering guidance and surfaced to every relevant agent lane: live executor sessions receive steering injection, while planner, reviewer (spec/plan/code), and merger agents (standard and clean-room AI merge/review) receive the latest user comments in their next prompt/pass. - The priority chip in task metadata is an inline picker: you can change priority directly without entering full edit mode. - Execution mode has a read-mode inline lightning-bolt toggle for Fast mode on/off without opening the full edit form. @@ -1117,7 +1118,7 @@ Recommended workflow: ordinary chains stay as `Blocks N` so noise stays low, hig ### Activity → Raw Logs view - + The **Activity** tab is the first task-detail tab and presents a segmented control for **Current**, **Feed**, and **Raw Logs**. Current contains the live, chat-styled transcript of task agent output. Consecutive entries are grouped by role and labeled as Planner, Executor, Reviewer, or Merger; legacy log rows without an agent role use the neutral Agent fallback. Agent group headers and user message headers show a small muted relative timestamp (for example, “just now”, “1m ago”, or “2h ago”) based on the transcript timestamp, while agent group metadata still includes the entry count. Consecutive text/message chunks inside a role group render as one continuous markdown bubble, while consecutive tool/tool-result/tool-error rows collapse into one expandable, compact tool-call summary that stays collapsed by default and mirrors regular Chat's dense treatment; the summary stays single-line/ellipsis-friendly on desktop and mobile, counts tool invocations, lists deduped tool names with overflow, and shows an error count when failures are present, while the expanded body pairs each call with its result or error in dense entry cards. Thinking entries render in a collapsible block that starts expanded. The transcript opens at the latest output whenever the tab loads or becomes active, then follows new live output when you are already near the bottom while preserving your scroll position when you review older messages. When older task-agent history exists, scrolling to the top or selecting **Load previous messages** prepends earlier transcript entries without moving the message you were reading. When you scroll away from the bottom of a populated transcript, a sticky **Latest** button appears inside the transcript so you can jump back to the newest message and resume live follow. For non-`done` tasks, the **Steering comment** composer sends guidance through the same steering path used by comments, including active planning/triage, `in-progress`, and `in-review` sessions, plus live CLI-agent sessions reported by the session bridge; an `in-review` Activity Current message or Comments-tab task comment re-engages an executor unless an open PR blocks moving the task back, and other messages are still saved as queued guidance when no session is currently live. Feed and Raw Logs do not show a steering composer. On a `done` task, the composer switches to **Refinement request** copy; sending starts a refinement task using the typed text as feedback and shows a success toast with the new task ID, while the current task detail modal remains on the completed task. The task-detail Activity Current segment keeps the composer pinned and visible on mobile and desktop while the transcript scrolls internally; its textarea placeholder reads “Steer the currently executing agent” for steering mode and switches to refinement copy for completed tasks, with the same inline, icon-only send affordance to the right of the input at every breakpoint. In the composer, plain **Enter** sends, **Shift+Enter** inserts a newline, and **Cmd/Ctrl+Enter** remains a supported send shortcut. The **Raw Logs** segment is designed for debugging long-running and tool-heavy sessions, while legacy links that requested the former top-level Logs tab land on Activity → Feed: diff --git a/packages/dashboard/app/api/legacy.ts b/packages/dashboard/app/api/legacy.ts index 518da8e1d1..aedcf8208c 100644 --- a/packages/dashboard/app/api/legacy.ts +++ b/packages/dashboard/app/api/legacy.ts @@ -9815,6 +9815,11 @@ export interface ChatMessageListResponse { messages: ChatMessage[]; } +export interface TaskPlannerChatSessionInput { + modelProvider?: string; + modelId?: string; +} + export interface ChatRoomListResponse { rooms: ChatRoom[]; } @@ -9900,6 +9905,36 @@ export function fetchChatSession(id: string, projectId?: string): Promise(withProjectId(`/chat/sessions/${encodeURIComponent(id)}`, projectId)); } +export function ensureTaskPlannerChatSession( + taskId: string, + input: TaskPlannerChatSessionInput = {}, + projectId?: string, +): Promise { + const normalizedTaskId = taskId.trim(); + if (!normalizedTaskId) { + throw new Error("taskId is required"); + } + const normalizedProvider = input.modelProvider?.trim(); + const normalizedModelId = input.modelId?.trim(); + if ((normalizedProvider && !normalizedModelId) || (!normalizedProvider && normalizedModelId)) { + throw new Error("Both modelProvider and modelId must be provided together, or neither should be provided"); + } + + /* + FNXC:TaskDetailPlannerChat 2026-06-30-22:30: + Task planner chat uses a task-scoped session seam instead of the generic agent-chat creator so it can bind the conversation to the task and planning model without requiring a real executor/reviewer agent or turning the message into steering. + */ + return api( + withProjectId(`/chat/task-planner/${encodeURIComponent(normalizedTaskId)}/session`, projectId), + { + method: "POST", + body: JSON.stringify({ + ...(normalizedProvider && normalizedModelId ? { modelProvider: normalizedProvider, modelId: normalizedModelId } : {}), + }), + }, + ); +} + /** Update a chat session (title, status) */ export function updateChatSession( id: string, diff --git a/packages/dashboard/app/components/TaskDetailModal.tsx b/packages/dashboard/app/components/TaskDetailModal.tsx index a4068c5c08..d045f87e3d 100644 --- a/packages/dashboard/app/components/TaskDetailModal.tsx +++ b/packages/dashboard/app/components/TaskDetailModal.tsx @@ -33,6 +33,7 @@ import { PrPanel } from "./PrPanel"; import { PrCreateModal } from "./PrCreateModal"; import { TaskComments } from "./TaskComments"; import { TaskChatTab } from "./TaskChatTab"; +import { TaskPlannerChatTab } from "./TaskPlannerChatTab"; import { TaskReviewTab } from "./TaskReviewTab"; import { MergeDetails } from "./MergeDetails"; import { TaskChangesTab } from "./TaskChangesTab"; @@ -191,18 +192,21 @@ function formatDurationCompact(ageMs: number): string { return `${minutes}m`; } -type TabId = "summary" | "definition" | "chat" | "logs" | "changes" | "review" | "pr" | "comments" | "model" | "workflow" | "documents" | "stats" | "routing" | "retries" | "terminal" | `plugin-${string}`; +type TabId = "summary" | "definition" | "chat" | "planner-chat" | "logs" | "changes" | "review" | "pr" | "comments" | "model" | "workflow" | "documents" | "stats" | "routing" | "retries" | "terminal" | `plugin-${string}`; type ActivitySegment = "current" | "feed" | "raw-logs"; /* FNXC:TaskDetailActivityTab 2026-06-30-00:00: The existing task activity/steering surface keeps the stable internal `chat` tab id for deep-link/plugin compatibility, but its top-level user-facing label is Activity. Activity is the implicit default for active task columns; done tasks keep Summary as their omitted-initial-tab landing surface so completed work still opens on the completion report while Activity remains first in tab order. +FNXC:TaskDetailPlannerChat 2026-06-30-22:30: +Task detail now separates Activity from planner-model Chat. `chat` remains the legacy Activity id for old links and Activity → Current/Feed/Raw Logs/steering, while `planner-chat` is the new top-level Chat tab for task-aware planning conversation and must render immediately after Activity. + FNXC:TaskDetailActivity 2026-06-30-15:50: -Only an omitted initial tab is the implicit default. Preserve explicit `initialTab="chat"` requests from plugins and task-detail entrypoints so existing links continue to open Activity → Current. Legacy `initialTab="logs"` now routes to Activity → Feed, and Raw Logs remains an Activity segment, because the legacy top-level Logs tab must not return while the later planner-model Chat tab remains out of scope. +Only an omitted initial tab is the implicit default. Preserve explicit `initialTab="chat"` requests from plugins and task-detail entrypoints so existing links continue to open Activity → Current. Legacy `initialTab="logs"` now routes to Activity → Feed, and Raw Logs remains an Activity segment. FNXC:TaskDetailActivity 2026-06-30-21:55: -The first Activity segment keeps the stable Current label for legacy segment tests and links, but its embedded composer labels the operational steering-comment affordance explicitly. Do not reuse this segment as the future planner-model Chat conversation; that belongs to a later top-level tab. +The first Activity segment keeps the stable Current label for legacy segment tests and links, but its embedded composer labels the operational steering-comment affordance explicitly. Do not reuse this segment as planner-model Chat conversation; that belongs to the `planner-chat` top-level tab. */ function resolveDefaultTab(initialTab: TabId | undefined, column: ColumnId): TabId { if (initialTab === "retries") { @@ -512,8 +516,8 @@ export function TaskDetailContent({ autoMergeEnabled: autoMergeEnabledProp, onOpenWorkflowEditor, /** - * FNXC:TaskDetailActivityTab 2026-06-30-00:00: - * The Activity tab is still addressed as `chat` internally so existing callers and deep links do not break while the label/order changes ahead of the future planner Chat tab. + * FNXC:TaskDetailPlannerChat 2026-06-30-22:30: + * The Activity tab is still addressed as `chat` internally so existing callers and deep links do not break; the visible Chat tab uses `planner-chat` for planner-model conversation. */ initialTab, mobileHeaderMode = "close", @@ -3149,8 +3153,8 @@ export function TaskDetailContent({ <>
{/* - FNXC:TaskDetailActivityTab 2026-06-30-00:00: - The existing task activity/steering surface is now labelled Activity and always renders first. Keep the `chat` tab id because a later subtask will add the separate planner-model Chat surface; this rename must not break existing `initialTab="chat"` callers. + FNXC:TaskDetailPlannerChat 2026-06-30-22:30: + The existing task activity/steering surface is labelled Activity and always renders first with the legacy `chat` tab id. The adjacent `planner-chat` tab is the separate planner-model Chat destination, so `initialTab="chat"` remains Activity while visible Chat opens task-aware planning conversation. */} + {task.column === "done" && (
+ ) : activeTab === "planner-chat" ? ( +
+ +
) : activeTab === "chat" ? (
{/* - FNXC:TaskDetailActivity 2026-06-30-15:50: - Activity owns the existing steering/current view, Feed, and Raw Logs inside one segmented control. The later planner-model Chat tab is intentionally out of scope, so the stable top-level tab id remains `chat`, legacy `logs` callers land on Feed, and Raw Logs is the only segment that enables raw agent-log fetching. + FNXC:TaskDetailPlannerChat 2026-06-30-22:30: + Activity owns the existing steering/current view, Feed, and Raw Logs inside one segmented control. The stable Activity tab id remains `chat`, legacy `logs` callers land on Feed, and Raw Logs is the only segment that enables raw agent-log fetching. Planner-model conversation belongs to the separate `planner-chat` tab and must not route into steering comments. FNXC:TaskDetailActivity 2026-06-30-21:55: - The first Activity segment keeps the stable Current label for legacy segment tests and links, but its embedded composer labels the operational steering-comment affordance explicitly. Do not reuse this segment as the future planner-model Chat conversation; that belongs to a later top-level tab. + The first Activity segment keeps the stable Current label for legacy segment tests and links, but its embedded composer labels the operational steering-comment affordance explicitly. Do not reuse this segment as planner-model Chat conversation. */}
+ ))} +
+
+ ) : ( + messages.map((message) => { + const toolCalls = extractToolCalls(message); + return ( +
+
+ {message.role === "user" ? t("taskDetail.plannerChat.user", "You") : t("taskDetail.plannerChat.assistant", "Planner")} +
+ {message.content && ( +
+ {message.content} +
+ )} + {toolCalls.map((toolCall, index) => { + const parsedQuestion = parseQuestionToolCall(toolCall); + if (!parsedQuestion) return null; + const answered = message.id !== "streaming-assistant" && message !== messages[messages.length - 1]; + return ( + void sendMessageContent(answerText)} + /> + ); + })} +
+ ); + }) + )} + + +
+