Skip to content

Commit d5fc419

Browse files
committed
More cleanup
1 parent ae33ff1 commit d5fc419

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import removeMd from "remove-markdown"
66
import { VSCodeButton } from "@vscode/webview-ui-toolkit/react"
77
import useSound from "use-sound"
88
import { LRUCache } from "lru-cache"
9+
import { useTranslation } from "react-i18next"
910

1011
import { useDebounceEffect } from "@src/utils/useDebounceEffect"
1112
import { appendImages } from "@src/utils/imageUtils"
1213

13-
import type { ClineAsk, ClineMessage } from "@roo-code/types"
14+
import type { ClineAsk, ClineMessage, QueuedMessage } from "@roo-code/types"
1415

1516
import { ClineSayBrowserAction, ClineSayTool, ExtensionMessage } from "@roo/ExtensionMessage"
1617
import { McpServer, McpTool } from "@roo/mcp"
@@ -22,6 +23,7 @@ import { getApiMetrics } from "@roo/getApiMetrics"
2223
import { AudioType } from "@roo/WebviewMessage"
2324
import { getAllModes } from "@roo/modes"
2425
import { ProfileValidator } from "@roo/ProfileValidator"
26+
import { getLatestTodo } from "@roo/todo"
2527

2628
import { vscode } from "@src/utils/vscode"
2729
import {
@@ -30,16 +32,15 @@ import {
3032
findLongestPrefixMatch,
3133
parseCommand,
3234
} from "@src/utils/command-validation"
33-
import { useTranslation } from "react-i18next"
3435
import { useAppTranslation } from "@src/i18n/TranslationContext"
3536
import { useExtensionState } from "@src/context/ExtensionStateContext"
37+
import { useAutoApprovalState } from "@src/hooks/useAutoApprovalState"
38+
import { useAutoApprovalToggles } from "@src/hooks/useAutoApprovalToggles"
3639
import { useSelectedModel } from "@src/components/ui/hooks/useSelectedModel"
3740
import RooHero from "@src/components/welcome/RooHero"
3841
import RooTips from "@src/components/welcome/RooTips"
3942
import RooCloudCTA from "@src/components/welcome/RooCloudCTA"
4043
import { StandardTooltip } from "@src/components/ui"
41-
import { useAutoApprovalState } from "@src/hooks/useAutoApprovalState"
42-
import { useAutoApprovalToggles } from "@src/hooks/useAutoApprovalToggles"
4344

4445
import TelemetryBanner from "../common/TelemetryBanner"
4546
import VersionIndicator from "../common/VersionIndicator"
@@ -55,8 +56,6 @@ import SystemPromptWarning from "./SystemPromptWarning"
5556
import ProfileViolationWarning from "./ProfileViolationWarning"
5657
import { CheckpointWarning } from "./CheckpointWarning"
5758
import QueuedMessages from "./QueuedMessages"
58-
import { getLatestTodo } from "@roo/todo"
59-
import { QueuedMessage } from "@roo-code/types"
6059

6160
export interface ChatViewProps {
6261
isHidden: boolean
@@ -164,7 +163,10 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
164163
const retryCountRef = useRef<Map<string, number>>(new Map())
165164
const MAX_RETRY_ATTEMPTS = 3
166165

167-
// we need to hold on to the ask because useEffect > lastMessage will always let us know when an ask comes in and handle it, but by the time handleMessage is called, the last message might not be the ask anymore (it could be a say that followed)
166+
// We need to hold on to the ask because useEffect > lastMessage will always
167+
// let us know when an ask comes in and handle it, but by the time
168+
// handleMessage is called, the last message might not be the ask anymore
169+
// (it could be a say that followed).
168170
const [clineAsk, setClineAsk] = useState<ClineAsk | undefined>(undefined)
169171
const [enableButtons, setEnableButtons] = useState<boolean>(false)
170172
const [primaryButtonText, setPrimaryButtonText] = useState<string | undefined>(undefined)
@@ -209,13 +211,16 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
209211
[apiConfiguration, organizationAllowList],
210212
)
211213

212-
// UI layout depends on the last 2 messages
213-
// (since it relies on the content of these messages, we are deep comparing. i.e. the button state after hitting button sets enableButtons to false, and this effect otherwise would have to true again even if messages didn't change
214+
// UI layout depends on the last 2 messages (since it relies on the content
215+
// of these messages, we are deep comparing. i.e. the button state after
216+
// hitting button sets enableButtons to false, and this effect otherwise
217+
// would have to true again even if messages didn't change.
214218
const lastMessage = useMemo(() => messages.at(-1), [messages])
215219
const secondLastMessage = useMemo(() => messages.at(-2), [messages])
216220

217-
// Setup sound hooks with use-sound
221+
// Setup sound hooks with use-sound.
218222
const volume = typeof soundVolume === "number" ? soundVolume : 0.5
223+
219224
const soundConfig = {
220225
volume,
221226
// useSound expects 'disabled' property, not 'soundEnabled'
@@ -449,11 +454,13 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
449454
clearTimeout(autoApproveTimeoutRef.current)
450455
autoApproveTimeoutRef.current = null
451456
}
457+
452458
// Reset user response flag for new task
453459
userRespondedRef.current = false
454460

455461
// Clear message queue when starting a new task
456462
setMessageQueue([])
463+
457464
// Clear retry counts
458465
retryCountRef.current.clear()
459466
}, [task?.ts])
@@ -583,6 +590,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
583590
setSelectedImages([])
584591
return
585592
}
593+
586594
// Mark that user has responded - this prevents any pending auto-approvals
587595
userRespondedRef.current = true
588596

webview-ui/src/components/chat/QueuedMessages.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const QueuedMessages: React.FC<QueuedMessagesProps> = ({ queue, onRemove, onUpda
5252
<textarea
5353
ref={(textarea) => {
5454
if (textarea) {
55-
// Set cursor at the end
55+
// Set cursor at the end.
5656
textarea.setSelectionRange(
5757
textarea.value.length,
5858
textarea.value.length,

0 commit comments

Comments
 (0)