MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / ChatViewComponent

Function ChatViewComponent

webview-ui/src/components/chat/ChatView.tsx:66–1851  ·  view source on GitHub ↗
(
	{ isHidden, showAnnouncement, hideAnnouncement },
	ref,
)

Source from the content-addressed store, hash-verified

64const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0
65
66const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewProps> = (
67 { isHidden, showAnnouncement, hideAnnouncement },
68 ref,
69) => {
70 const [audioBaseUri] = useState(() => {
71 return (window as unknown as { AUDIO_BASE_URI?: string }).AUDIO_BASE_URI || ""
72 })
73
74 const { t } = useAppTranslation()
75 const modeShortcutText = `${isMac ? "⌘" : "Ctrl"} + . ${t("chat:forNextMode")}, ${isMac ? "⌘" : "Ctrl"} + Shift + . ${t("chat:forPreviousMode")}`
76
77 const {
78 clineMessages: messages,
79 currentTaskItem,
80 currentTaskTodos,
81 taskHistory,
82 apiConfiguration,
83 organizationAllowList,
84 mode,
85 setMode,
86 alwaysAllowModeSwitch,
87 customModes,
88 soundEnabled,
89 soundVolume,
90 messageQueue = [],
91 showWorktreesInHomeScreen,
92 telemetrySetting,
93 } = useExtensionState()
94
95 // Show a WarningRow when the user sends a message with a retired provider.
96 const [showRetiredProviderWarning, setShowRetiredProviderWarning] = useState(false)
97
98 // When the provider changes, clear the retired-provider warning.
99 const providerName = apiConfiguration?.apiProvider
100 useEffect(() => {
101 setShowRetiredProviderWarning(false)
102 }, [providerName])
103
104 const messagesRef = useRef(messages)
105
106 useEffect(() => {
107 messagesRef.current = messages
108 }, [messages])
109
110 // Leaving this less safe version here since if the first message is not a
111 // task, then the extension is in a bad state and needs to be debugged (see
112 // Cline.abort).
113 const task = useMemo(() => messages.at(0), [messages])
114
115 const latestTodos = useMemo(() => {
116 // First check if we have initial todos from the state (for new subtasks)
117 if (currentTaskTodos && currentTaskTodos.length > 0) {
118 // Check if there are any todo updates in messages
119 const messageBasedTodos = getLatestTodo(messages)
120 // If there are message-based todos, they take precedence (user has updated them)
121 if (messageBasedTodos && messageBasedTodos.length > 0) {
122 return messageBasedTodos
123 }

Callers

nothing calls this directly

Calls 15

useAppTranslationFunction · 0.90
useExtensionStateFunction · 0.90
getLatestTodoFunction · 0.90
getCompletionCheckpointFunction · 0.90
findLastFunction · 0.90
isRetiredProviderFunction · 0.90
useSelectedModelFunction · 0.90
appendImagesFunction · 0.90
useDebounceEffectFunction · 0.90
batchConsecutiveFunction · 0.90
useScrollLifecycleFunction · 0.90
getAllModesFunction · 0.90

Tested by

no test coverage detected