Skip to content

Commit 79fabfb

Browse files
chat-freeze-2 (#72)
1 parent e7fc70b commit 79fabfb

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

src/api/providers/pearai/pearai.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class PearAiHandler extends BaseProvider implements SingleCompletionHandl
2929
constructor(options: ApiHandlerOptions) {
3030
super()
3131
if (!options.pearaiApiKey) {
32+
vscode.commands.executeCommand("pearai-roo-cline.PearAIKeysNotFound", undefined)
3233
vscode.window.showErrorMessage("PearAI API key not found.", "Login to PearAI").then(async (selection) => {
3334
if (selection === "Login to PearAI") {
3435
const extensionUrl = `${vscode.env.uriScheme}://pearai.pearai/auth`

src/extension.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,15 @@ export function activate(context: vscode.ExtensionContext) {
157157
}),
158158
)
159159

160+
context.subscriptions.push(
161+
vscode.commands.registerCommand("pearai-roo-cline.PearAIKeysNotFound", async () => {
162+
const provider = await ClineProvider.getInstance()
163+
if (provider) {
164+
provider.postMessageToWebview({ type: "action", action: "PearAIKeysNotFound" })
165+
}
166+
}),
167+
)
168+
160169
// context.subscriptions.push(
161170
// vscode.commands.registerCommand("roo-cline.mcpButtonClicked", () => {
162171
// sidebarProvider.postMessageToWebview({ type: "action", action: "mcpButtonClicked" })

src/shared/ExtensionMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export interface ExtensionMessage {
6666
| "historyButtonClicked"
6767
| "promptsButtonClicked"
6868
| "didBecomeVisible"
69+
| "PearAIKeysNotFound"
6970
invoke?: "newChat" | "sendMessage" | "primaryButtonClick" | "secondaryButtonClick" | "setChatBoxMessage"
7071
state?: ExtensionState
7172
images?: string[]

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
8888
const apiMetrics = useMemo(() => getApiMetrics(modifiedMessages), [modifiedMessages])
8989

9090
const [inputValue, setInputValue] = useState("")
91+
const [lastInputValue, setLastInputValue] = useState("")
9192
const textAreaRef = useRef<HTMLTextAreaElement>(null)
9293
const [textAreaDisabled, setTextAreaDisabled] = useState(false)
9394
const [selectedImages, setSelectedImages] = useState<string[]>([])
95+
const [lastInputImages, setLastInputImages] = useState<string[]>([])
9496

9597
// 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)
9698
const [clineAsk, setClineAsk] = useState<ClineAsk | undefined>(undefined)
@@ -327,6 +329,8 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
327329

328330
const handleChatReset = useCallback(() => {
329331
// Only reset message-specific state, preserving mode.
332+
setLastInputValue(inputValue)
333+
setLastInputImages(selectedImages)
330334
setInputValue("")
331335
setTextAreaDisabled(true)
332336
setSelectedImages([])
@@ -336,7 +340,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
336340
// setPrimaryButtonText(undefined)
337341
// setSecondaryButtonText(undefined)
338342
disableAutoScrollRef.current = false
339-
}, [])
343+
}, [inputValue, selectedImages])
340344

341345
const handleSendMessage = useCallback(
342346
(text: string, images: string[]) => {
@@ -507,6 +511,13 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
507511
textAreaRef.current?.focus()
508512
}
509513
break
514+
case "PearAIKeysNotFound":
515+
setInputValue(lastInputValue)
516+
setTextAreaDisabled(false)
517+
setSelectedImages(lastInputImages)
518+
setEnableButtons(true)
519+
disableAutoScrollRef.current = true
520+
break
510521
}
511522
break
512523
case "selectedImages":
@@ -547,6 +558,12 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
547558
handleSetChatBoxMessage,
548559
handlePrimaryButtonClick,
549560
handleSecondaryButtonClick,
561+
lastInputValue,
562+
lastInputImages,
563+
setInputValue,
564+
setTextAreaDisabled,
565+
setSelectedImages,
566+
setEnableButtons,
550567
],
551568
)
552569

0 commit comments

Comments
 (0)