Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/api/providers/pearai/pearai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class PearAiHandler extends BaseProvider implements SingleCompletionHandl
constructor(options: ApiHandlerOptions) {
super()
if (!options.pearaiApiKey) {
vscode.commands.executeCommand("pearai-roo-cline.PearAIKeysNotFound", undefined)
vscode.window.showErrorMessage("PearAI API key not found.", "Login to PearAI").then(async (selection) => {
if (selection === "Login to PearAI") {
const extensionUrl = `${vscode.env.uriScheme}://pearai.pearai/auth`
Expand Down
9 changes: 9 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ export function activate(context: vscode.ExtensionContext) {
}),
)

context.subscriptions.push(
vscode.commands.registerCommand("pearai-roo-cline.PearAIKeysNotFound", async () => {
const provider = await ClineProvider.getInstance()
if (provider) {
provider.postMessageToWebview({ type: "action", action: "PearAIKeysNotFound" })
}
}),
)

// context.subscriptions.push(
// vscode.commands.registerCommand("roo-cline.mcpButtonClicked", () => {
// sidebarProvider.postMessageToWebview({ type: "action", action: "mcpButtonClicked" })
Expand Down
1 change: 1 addition & 0 deletions src/shared/ExtensionMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export interface ExtensionMessage {
| "historyButtonClicked"
| "promptsButtonClicked"
| "didBecomeVisible"
| "PearAIKeysNotFound"
invoke?: "newChat" | "sendMessage" | "primaryButtonClick" | "secondaryButtonClick" | "setChatBoxMessage"
state?: ExtensionState
images?: string[]
Expand Down
19 changes: 18 additions & 1 deletion webview-ui/src/components/chat/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
const apiMetrics = useMemo(() => getApiMetrics(modifiedMessages), [modifiedMessages])

const [inputValue, setInputValue] = useState("")
const [lastInputValue, setLastInputValue] = useState("")
const textAreaRef = useRef<HTMLTextAreaElement>(null)
const [textAreaDisabled, setTextAreaDisabled] = useState(false)
const [selectedImages, setSelectedImages] = useState<string[]>([])
const [lastInputImages, setLastInputImages] = useState<string[]>([])

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

const handleChatReset = useCallback(() => {
// Only reset message-specific state, preserving mode.
setLastInputValue(inputValue)
setLastInputImages(selectedImages)
setInputValue("")
setTextAreaDisabled(true)
setSelectedImages([])
Expand All @@ -336,7 +340,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
// setPrimaryButtonText(undefined)
// setSecondaryButtonText(undefined)
disableAutoScrollRef.current = false
}, [])
}, [inputValue, selectedImages])

const handleSendMessage = useCallback(
(text: string, images: string[]) => {
Expand Down Expand Up @@ -507,6 +511,13 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
textAreaRef.current?.focus()
}
break
case "PearAIKeysNotFound":
setInputValue(lastInputValue)
setTextAreaDisabled(false)
setSelectedImages(lastInputImages)
setEnableButtons(true)
disableAutoScrollRef.current = true
break
}
break
case "selectedImages":
Expand Down Expand Up @@ -547,6 +558,12 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
handleSetChatBoxMessage,
handlePrimaryButtonClick,
handleSecondaryButtonClick,
lastInputValue,
lastInputImages,
setInputValue,
setTextAreaDisabled,
setSelectedImages,
setEnableButtons,
],
)

Expand Down
Loading