diff --git a/.changeset/seven-zebras-grin.md b/.changeset/seven-zebras-grin.md new file mode 100644 index 00000000..9d9c420e --- /dev/null +++ b/.changeset/seven-zebras-grin.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Updated Timeline tooltips for `followup` messages and consolidated color retrieval code. diff --git a/webview-ui/src/components/chat/task-header/TaskTimeline.tsx b/webview-ui/src/components/chat/task-header/TaskTimeline.tsx index 50467298..48fc80cc 100644 --- a/webview-ui/src/components/chat/task-header/TaskTimeline.tsx +++ b/webview-ui/src/components/chat/task-header/TaskTimeline.tsx @@ -4,16 +4,7 @@ import { ClineMessage } from "@shared/ExtensionMessage" import { combineApiRequests } from "@shared/combineApiRequests" import { combineCommandSequences } from "@shared/combineCommandSequences" import TaskTimelineTooltip from "./TaskTimelineTooltip" -import { - COLOR_WHITE, - COLOR_GRAY, - COLOR_DARK_GRAY, - COLOR_BEIGE, - COLOR_BLUE, - COLOR_RED, - COLOR_PURPLE, - COLOR_GREEN, -} from "../colors" +import { getColor } from "./util" // Timeline dimensions and spacing const TIMELINE_HEIGHT = "18px" @@ -26,88 +17,6 @@ interface TaskTimelineProps { onBlockClick?: (messageIndex: number) => void } -const getBlockColor = (message: ClineMessage): string => { - if (message.type === "say") { - switch (message.say) { - case "task": - return COLOR_WHITE // White for system prompt - case "user_feedback": - return COLOR_WHITE // White for user feedback - case "text": - return COLOR_GRAY // Gray for assistant responses - case "tool": - if (message.text) { - try { - const toolData = JSON.parse(message.text) - if ( - toolData.tool === "readFile" || - toolData.tool === "listFilesTopLevel" || - toolData.tool === "listFilesRecursive" || - toolData.tool === "listCodeDefinitionNames" || - toolData.tool === "searchFiles" - ) { - return COLOR_BEIGE // Beige for file read operations - } else if (toolData.tool === "editedExistingFile" || toolData.tool === "newFileCreated") { - return COLOR_BLUE // Blue for file edit/create operations - } else if (toolData.tool === "webFetch") { - return COLOR_PURPLE // Purple for web fetch operations - } - } catch (e) { - // JSON parse error here - } - } - return COLOR_BEIGE // Default beige for tool use - case "command": - case "command_output": - return COLOR_PURPLE // Red for terminal commands - case "browser_action": - case "browser_action_result": - return COLOR_PURPLE // Purple for browser actions - case "completion_result": - return COLOR_GREEN // Green for task success - default: - return COLOR_DARK_GRAY // Dark gray for unknown - } - } else if (message.type === "ask") { - switch (message.ask) { - case "followup": - return COLOR_GRAY // Gray for user messages - case "plan_mode_respond": - return COLOR_GRAY // Gray for planning responses - case "tool": - // Match the color of the tool approval with the tool type - if (message.text) { - try { - const toolData = JSON.parse(message.text) - if ( - toolData.tool === "readFile" || - toolData.tool === "listFilesTopLevel" || - toolData.tool === "listFilesRecursive" || - toolData.tool === "listCodeDefinitionNames" || - toolData.tool === "searchFiles" - ) { - return COLOR_BEIGE // Beige for file read operations - } else if (toolData.tool === "editedExistingFile" || toolData.tool === "newFileCreated") { - return COLOR_BLUE // Blue for file edit/create operations - } else if (toolData.tool === "webFetch") { - return COLOR_PURPLE // Purple for web fetch operations - } - } catch (e) { - // JSON parse error here - } - } - return COLOR_BEIGE // Default beige for tool approvals - case "command": - return COLOR_PURPLE // Red for command approvals (same as terminal commands) - case "browser_action_launch": - return COLOR_PURPLE // Purple for browser launch approvals (same as browser actions) - default: - return COLOR_DARK_GRAY // Dark gray for unknown - } - } - return COLOR_WHITE // Default color -} - const TaskTimeline: React.FC = ({ messages, onBlockClick }) => { const containerRef = useRef(null) const scrollableRef = useRef(null) @@ -181,7 +90,7 @@ const TaskTimeline: React.FC = ({ messages, onBlockClick }) = style={{ width: BLOCK_WIDTH, height: "100%", - backgroundColor: getBlockColor(message), + backgroundColor: getColor(message), flexShrink: 0, cursor: "pointer", marginRight: BLOCK_GAP, diff --git a/webview-ui/src/components/chat/task-header/TaskTimelineTooltip.tsx b/webview-ui/src/components/chat/task-header/TaskTimelineTooltip.tsx index 28db6ffc..4a0a7026 100644 --- a/webview-ui/src/components/chat/task-header/TaskTimelineTooltip.tsx +++ b/webview-ui/src/components/chat/task-header/TaskTimelineTooltip.tsx @@ -1,18 +1,7 @@ import React from "react" import { ClineMessage } from "@shared/ExtensionMessage" -import { - COLOR_WHITE, - COLOR_GRAY, - COLOR_DARK_GRAY, - COLOR_BEIGE, - COLOR_BLUE, - COLOR_RED, - COLOR_PURPLE, - COLOR_GREEN, -} from "../colors" import { Tooltip } from "@heroui/react" - -// Color mapping for different message types +import { getColor } from "./util" interface TaskTimelineTooltipProps { message: ClineMessage @@ -73,7 +62,7 @@ const TaskTimelineTooltip = ({ message, children }: TaskTimelineTooltipProps) => } else if (message.type === "ask") { switch (message.ask) { case "followup": - return "User Message" + return "Assistant Message" case "plan_mode_respond": return "Planning Response" case "tool": @@ -162,89 +151,6 @@ const TaskTimelineTooltip = ({ message, children }: TaskTimelineTooltipProps) => return "" } - // Get color for the indicator based on message type - const getMessageColor = (message: ClineMessage): string => { - if (message.type === "say") { - switch (message.say) { - case "task": - return COLOR_WHITE // White for system prompt - case "user_feedback": - return COLOR_WHITE // White for user feedback - case "text": - return COLOR_GRAY // Gray for assistant responses - case "tool": - if (message.text) { - try { - const toolData = JSON.parse(message.text) - if ( - toolData.tool === "readFile" || - toolData.tool === "listFilesTopLevel" || - toolData.tool === "listFilesRecursive" || - toolData.tool === "listCodeDefinitionNames" || - toolData.tool === "searchFiles" - ) { - return COLOR_BEIGE // Beige for file read operations - } else if (toolData.tool === "editedExistingFile" || toolData.tool === "newFileCreated") { - return COLOR_BLUE // Blue for file edit/create operations - } else if (toolData.tool === "webFetch") { - return COLOR_PURPLE // Beige for web fetch operations - } - } catch (e) { - // JSON parse error here - } - } - return COLOR_BEIGE // Default beige for tool use - case "command": - case "command_output": - return COLOR_PURPLE // Red for terminal commands - case "browser_action": - case "browser_action_result": - return COLOR_PURPLE // Purple for browser actions - case "completion_result": - return COLOR_GREEN // Green for task success - default: - return COLOR_DARK_GRAY // Dark gray for unknown - } - } else if (message.type === "ask") { - switch (message.ask) { - case "followup": - return COLOR_GRAY // Gray for user messages - case "plan_mode_respond": - return COLOR_GRAY // Gray for planning responses - case "tool": - // Match the color of the tool approval with the tool type - if (message.text) { - try { - const toolData = JSON.parse(message.text) - if ( - toolData.tool === "readFile" || - toolData.tool === "listFilesTopLevel" || - toolData.tool === "listFilesRecursive" || - toolData.tool === "listCodeDefinitionNames" || - toolData.tool === "searchFiles" - ) { - return COLOR_BEIGE // Beige for file read operations - } else if (toolData.tool === "editedExistingFile" || toolData.tool === "newFileCreated") { - return COLOR_BLUE // Blue for file edit/create operations - } else if (toolData.tool === "webFetch") { - return COLOR_PURPLE // Purple for web fetch operations - } - } catch (e) { - // JSON parse error here - } - } - return COLOR_BEIGE // Default beige for tool approvals - case "command": - return COLOR_PURPLE // Red for command approvals (same as terminal commands) - case "browser_action_launch": - return COLOR_PURPLE // Purple for browser launch approvals (same as browser actions) - default: - return COLOR_DARK_GRAY // Dark gray for unknown - } - } - return COLOR_DARK_GRAY // Default dark gray - } - return ( minWidth: "10px", // Ensure fixed width minHeight: "10px", // Ensure fixed height borderRadius: "50%", - backgroundColor: getMessageColor(message), + backgroundColor: getColor(message), marginRight: "8px", display: "inline-block", flexShrink: 0, // Prevent shrinking when space is limited diff --git a/webview-ui/src/components/chat/task-header/util.ts b/webview-ui/src/components/chat/task-header/util.ts new file mode 100644 index 00000000..8ac1db20 --- /dev/null +++ b/webview-ui/src/components/chat/task-header/util.ts @@ -0,0 +1,91 @@ +import { ClineMessage } from "@shared/ExtensionMessage" +import { COLOR_WHITE, COLOR_GRAY, COLOR_DARK_GRAY, COLOR_BEIGE, COLOR_BLUE, COLOR_PURPLE, COLOR_GREEN } from "../colors" + +/** + * + * Get the color for a block or the indicator based on the message type + * + * @param message ClineMessage - The message to determine the color for + * @returns string - The color code for the block or indicator + */ +export const getColor = (message: ClineMessage): string => { + if (message.type === "say") { + switch (message.say) { + case "task": + return COLOR_WHITE // White for system prompt + case "user_feedback": + return COLOR_WHITE // White for user feedback + case "text": + return COLOR_GRAY // Gray for assistant responses + case "tool": + if (message.text) { + try { + const toolData = JSON.parse(message.text) + if ( + toolData.tool === "readFile" || + toolData.tool === "listFilesTopLevel" || + toolData.tool === "listFilesRecursive" || + toolData.tool === "listCodeDefinitionNames" || + toolData.tool === "searchFiles" + ) { + return COLOR_BEIGE // Beige for file read operations + } else if (toolData.tool === "editedExistingFile" || toolData.tool === "newFileCreated") { + return COLOR_BLUE // Blue for file edit/create operations + } else if (toolData.tool === "webFetch") { + return COLOR_PURPLE // Purple for web fetch operations + } + } catch (e) { + // JSON parse error here + } + } + return COLOR_BEIGE // Default beige for tool use + case "command": + case "command_output": + return COLOR_PURPLE // Red for terminal commands + case "browser_action": + case "browser_action_result": + return COLOR_PURPLE // Purple for browser actions + case "completion_result": + return COLOR_GREEN // Green for task success + default: + return COLOR_DARK_GRAY // Dark gray for unknown + } + } else if (message.type === "ask") { + switch (message.ask) { + case "followup": + return COLOR_GRAY // Gray for user messages + case "plan_mode_respond": + return COLOR_GRAY // Gray for planning responses + case "tool": + // Match the color of the tool approval with the tool type + if (message.text) { + try { + const toolData = JSON.parse(message.text) + if ( + toolData.tool === "readFile" || + toolData.tool === "listFilesTopLevel" || + toolData.tool === "listFilesRecursive" || + toolData.tool === "listCodeDefinitionNames" || + toolData.tool === "searchFiles" + ) { + return COLOR_BEIGE // Beige for file read operations + } else if (toolData.tool === "editedExistingFile" || toolData.tool === "newFileCreated") { + return COLOR_BLUE // Blue for file edit/create operations + } else if (toolData.tool === "webFetch") { + return COLOR_PURPLE // Purple for web fetch operations + } + } catch (e) { + // JSON parse error here + } + } + return COLOR_BEIGE // Default beige for tool approvals + case "command": + return COLOR_PURPLE // Red for command approvals (same as terminal commands) + case "browser_action_launch": + return COLOR_PURPLE // Purple for browser launch approvals (same as browser actions) + default: + return COLOR_DARK_GRAY // Dark gray for unknown + } + } + return COLOR_WHITE // Default color +}