Skip to content

Commit af39930

Browse files
committed
Revert webview changes
1 parent 8a1fa13 commit af39930

File tree

4 files changed

+32
-52
lines changed

4 files changed

+32
-52
lines changed

src/core/webview/webviewMessageHandler.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ import * as yaml from "yaml"
88

99
import {
1010
type Language,
11+
type ProviderSettings,
1112
type GlobalState,
1213
type ClineMessage,
13-
type ClineAsk,
1414
TelemetryEventName,
15-
RooCodeEventName,
1615
} from "@roo-code/types"
1716
import { CloudService } from "@roo-code/cloud"
1817
import { TelemetryService } from "@roo-code/telemetry"

src/shared/WebviewMessage.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
type ModeConfig,
77
type InstallMarketplaceItemOptions,
88
type MarketplaceItem,
9-
type ClineMessage,
109
marketplaceItemSchema,
1110
} from "@roo-code/types"
1211
import type { ShareVisibility } from "@roo-code/cloud"
@@ -218,7 +217,6 @@ export interface WebviewMessage {
218217
disabled?: boolean
219218
context?: string
220219
dataUri?: string
221-
askMessage?: ClineMessage
222220
askResponse?: ClineAskResponse
223221
apiConfiguration?: ProviderSettings
224222
images?: string[]

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

Lines changed: 30 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ 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"
109

1110
import { useDebounceEffect } from "@src/utils/useDebounceEffect"
1211
import { appendImages } from "@src/utils/imageUtils"
1312

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

1615
import { ClineSayBrowserAction, ClineSayTool, ExtensionMessage } from "@roo/ExtensionMessage"
1716
import { McpServer, McpTool } from "@roo/mcp"
@@ -23,7 +22,6 @@ import { getApiMetrics } from "@roo/getApiMetrics"
2322
import { AudioType } from "@roo/WebviewMessage"
2423
import { getAllModes } from "@roo/modes"
2524
import { ProfileValidator } from "@roo/ProfileValidator"
26-
import { getLatestTodo } from "@roo/todo"
2725

2826
import { vscode } from "@src/utils/vscode"
2927
import {
@@ -32,15 +30,16 @@ import {
3230
findLongestPrefixMatch,
3331
parseCommand,
3432
} from "@src/utils/command-validation"
33+
import { useTranslation } from "react-i18next"
3534
import { useAppTranslation } from "@src/i18n/TranslationContext"
3635
import { useExtensionState } from "@src/context/ExtensionStateContext"
37-
import { useAutoApprovalState } from "@src/hooks/useAutoApprovalState"
38-
import { useAutoApprovalToggles } from "@src/hooks/useAutoApprovalToggles"
3936
import { useSelectedModel } from "@src/components/ui/hooks/useSelectedModel"
4037
import RooHero from "@src/components/welcome/RooHero"
4138
import RooTips from "@src/components/welcome/RooTips"
4239
import RooCloudCTA from "@src/components/welcome/RooCloudCTA"
4340
import { StandardTooltip } from "@src/components/ui"
41+
import { useAutoApprovalState } from "@src/hooks/useAutoApprovalState"
42+
import { useAutoApprovalToggles } from "@src/hooks/useAutoApprovalToggles"
4443

4544
import TelemetryBanner from "../common/TelemetryBanner"
4645
import VersionIndicator from "../common/VersionIndicator"
@@ -56,6 +55,8 @@ import SystemPromptWarning from "./SystemPromptWarning"
5655
import ProfileViolationWarning from "./ProfileViolationWarning"
5756
import { CheckpointWarning } from "./CheckpointWarning"
5857
import QueuedMessages from "./QueuedMessages"
58+
import { getLatestTodo } from "@roo/todo"
59+
import { QueuedMessage } from "@roo-code/types"
5960

6061
export interface ChatViewProps {
6162
isHidden: boolean
@@ -76,16 +77,13 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
7677
ref,
7778
) => {
7879
const isMountedRef = useRef(true)
79-
8080
const [audioBaseUri] = useState(() => {
8181
const w = window as any
8282
return w.AUDIO_BASE_URI || ""
8383
})
84-
8584
const { t } = useAppTranslation()
8685
const { t: tSettings } = useTranslation("settings")
8786
const modeShortcutText = `${isMac ? "⌘" : "Ctrl"} + . ${t("chat:forNextMode")}, ${isMac ? "⌘" : "Ctrl"} + Shift + . ${t("chat:forPreviousMode")}`
88-
8987
const {
9088
clineMessages: messages,
9189
currentTaskItem,
@@ -163,10 +161,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
163161
const retryCountRef = useRef<Map<string, number>>(new Map())
164162
const MAX_RETRY_ATTEMPTS = 3
165163

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).
164+
// 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)
170165
const [clineAsk, setClineAsk] = useState<ClineAsk | undefined>(undefined)
171166
const [enableButtons, setEnableButtons] = useState<boolean>(false)
172167
const [primaryButtonText, setPrimaryButtonText] = useState<string | undefined>(undefined)
@@ -211,16 +206,13 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
211206
[apiConfiguration, organizationAllowList],
212207
)
213208

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.
209+
// UI layout depends on the last 2 messages
210+
// (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
218211
const lastMessage = useMemo(() => messages.at(-1), [messages])
219212
const secondLastMessage = useMemo(() => messages.at(-2), [messages])
220213

221-
// Setup sound hooks with use-sound.
214+
// Setup sound hooks with use-sound
222215
const volume = typeof soundVolume === "number" ? soundVolume : 0.5
223-
224216
const soundConfig = {
225217
volume,
226218
// useSound expects 'disabled' property, not 'soundEnabled'
@@ -265,11 +257,9 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
265257
if (lastMessage) {
266258
switch (lastMessage.type) {
267259
case "ask":
268-
// Reset user response flag when a new ask arrives to allow
269-
// auto-approval.
260+
// Reset user response flag when a new ask arrives to allow auto-approval
270261
userRespondedRef.current = false
271262
const isPartial = lastMessage.partial === true
272-
273263
switch (lastMessage.ask) {
274264
case "api_req_failed":
275265
playSound("progress_loop")
@@ -456,13 +446,11 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
456446
clearTimeout(autoApproveTimeoutRef.current)
457447
autoApproveTimeoutRef.current = null
458448
}
459-
460449
// Reset user response flag for new task
461450
userRespondedRef.current = false
462451

463452
// Clear message queue when starting a new task
464453
setMessageQueue([])
465-
466454
// Clear retry counts
467455
retryCountRef.current.clear()
468456
}, [task?.ts])
@@ -557,7 +545,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
557545
clearTimeout(autoApproveTimeoutRef.current)
558546
autoApproveTimeoutRef.current = null
559547
}
560-
561548
// Reset user response flag for new message
562549
userRespondedRef.current = false
563550

@@ -593,9 +580,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
593580
setSelectedImages([])
594581
return
595582
}
596-
597-
// Mark that user has responded - this prevents any pending
598-
// auto-approvals.
583+
// Mark that user has responded - this prevents any pending auto-approvals
599584
userRespondedRef.current = true
600585

601586
if (messagesRef.current.length === 0) {
@@ -1597,23 +1582,27 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
15971582
return
15981583
}
15991584

1600-
// Exit early if user has already responded.
1585+
// Exit early if user has already responded
16011586
if (userRespondedRef.current) {
16021587
return
16031588
}
16041589

16051590
const autoApproveOrReject = async () => {
1606-
// Check for auto-reject first (commands that should be denied).
1591+
// Check for auto-reject first (commands that should be denied)
16071592
if (lastMessage?.ask === "command" && isDeniedCommand(lastMessage)) {
1608-
// Get the denied prefix for the localized message.
1593+
// Get the denied prefix for the localized message
16091594
const deniedPrefix = getDeniedPrefix(lastMessage.text || "")
1610-
16111595
if (deniedPrefix) {
1612-
// Create the localized auto-deny message and send it with the rejection.
1596+
// Create the localized auto-deny message and send it with the rejection
16131597
const autoDenyMessage = tSettings("autoApprove.execute.autoDenied", { prefix: deniedPrefix })
1614-
vscode.postMessage({ type: "askResponse", askResponse: "noButtonClicked", text: autoDenyMessage })
1598+
1599+
vscode.postMessage({
1600+
type: "askResponse",
1601+
askResponse: "noButtonClicked",
1602+
text: autoDenyMessage,
1603+
})
16151604
} else {
1616-
// Auto-reject denied commands immediately if no prefix found.
1605+
// Auto-reject denied commands immediately if no prefix found
16171606
vscode.postMessage({ type: "askResponse", askResponse: "noButtonClicked" })
16181607
}
16191608

@@ -1623,13 +1612,12 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
16231612
return
16241613
}
16251614

1626-
// Then check for auto-approve.
1615+
// Then check for auto-approve
16271616
if (lastMessage?.ask && isAutoApproved(lastMessage)) {
1628-
// Special handling for follow-up questions.
1617+
// Special handling for follow-up questions
16291618
if (lastMessage.ask === "followup") {
1630-
// Handle invalid JSON.
1619+
// Handle invalid JSON
16311620
let followUpData: FollowUpData = {}
1632-
16331621
try {
16341622
followUpData = JSON.parse(lastMessage.text || "{}") as FollowUpData
16351623
} catch (error) {
@@ -1638,30 +1626,27 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
16381626
}
16391627

16401628
if (followUpData && followUpData.suggest && followUpData.suggest.length > 0) {
1641-
// Wait for the configured timeout before auto-selecting the first suggestion.
1629+
// Wait for the configured timeout before auto-selecting the first suggestion
16421630
await new Promise<void>((resolve) => {
16431631
autoApproveTimeoutRef.current = setTimeout(() => {
16441632
autoApproveTimeoutRef.current = null
16451633
resolve()
16461634
}, followupAutoApproveTimeoutMs)
16471635
})
16481636

1649-
// Check if user responded manually.
1637+
// Check if user responded manually
16501638
if (userRespondedRef.current) {
16511639
return
16521640
}
16531641

1654-
// Get the first suggestion.
1642+
// Get the first suggestion
16551643
const firstSuggestion = followUpData.suggest[0]
16561644

1657-
// Handle the suggestion click.
1645+
// Handle the suggestion click
16581646
handleSuggestionClickInRow(firstSuggestion)
16591647
return
16601648
}
16611649
} else if (lastMessage.ask === "tool" && isWriteToolAction(lastMessage)) {
1662-
// When auto-approval is enabled for write operations, there
1663-
// is a configurable delay (writeDelayMs) before automatically
1664-
// approving these changes.
16651650
await new Promise<void>((resolve) => {
16661651
autoApproveTimeoutRef.current = setTimeout(() => {
16671652
autoApproveTimeoutRef.current = null
@@ -1677,7 +1662,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
16771662
setEnableButtons(false)
16781663
}
16791664
}
1680-
16811665
autoApproveOrReject()
16821666

16831667
return () => {
@@ -1702,7 +1686,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
17021686
allowedCommands,
17031687
deniedCommands,
17041688
mcpServers,
1705-
autoApprovalEnabled,
17061689
isAutoApproved,
17071690
lastMessage,
17081691
writeDelayMs,

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)