Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | import { AiHydroMessage } from "@shared/ExtensionMessage"
import { COLOR_BEIGE, COLOR_BLUE, COLOR_DARK_GRAY, COLOR_GRAY, COLOR_GREEN, COLOR_PURPLE, COLOR_WHITE } from "../colors"
/**
*
* Get the color for a block or the indicator based on the message type
*
* @param message AiHydroMessage - The message to determine the color for
* @returns string - The color code for the block or indicator
*/
export const getColor = (message: AiHydroMessage): 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
}
|