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 @@ -43,6 +43,7 @@ export class PearAiHandler extends BaseProvider implements SingleCompletionHandl
throw new Error("PearAI API key not found. Please login to PearAI.")
} else {
vscode.commands.executeCommand("pearai.checkPearAITokens", undefined)
vscode.commands.executeCommand("pearai-roo-cline.pearaiTokensValidated")
}
this.options = options

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.pearaiTokensValidated", async () => {
const provider = await ClineProvider.getInstance()
if (provider) {
provider.postMessageToWebview({ type: "action", action: "pearaiTokensValidated" })
}
}),
)

// 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"
| "pearaiTokensValidated"
invoke?: "newChat" | "sendMessage" | "primaryButtonClick" | "secondaryButtonClick" | "setChatBoxMessage"
state?: ExtensionState
images?: string[]
Expand Down
22 changes: 15 additions & 7 deletions webview-ui/src/components/chat/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,12 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
return false
}, [modifiedMessages, clineAsk, enableButtons, primaryButtonText])

const pearAiModels = usePearAiModels(apiConfiguration)

const { selectedModelInfo, selectedProvider } = useMemo(() => {
return normalizeApiConfiguration(apiConfiguration, pearAiModels)
}, [apiConfiguration, pearAiModels])

const handleChatReset = useCallback(() => {
// Only reset message-specific state, preserving mode.
setInputValue("")
Expand Down Expand Up @@ -361,10 +367,15 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
// There is no other case that a textfield should be enabled.
}
}

if (selectedProvider === "pearai") {
return
}

handleChatReset()
}
},
[messages.length, clineAsk, handleChatReset],
[messages.length, clineAsk, handleChatReset, selectedProvider],
)

const handleSetChatBoxMessage = useCallback(
Expand Down Expand Up @@ -483,12 +494,6 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
startNewTask()
}, [startNewTask])

const pearAiModels = usePearAiModels(apiConfiguration)

const { selectedModelInfo } = useMemo(() => {
return normalizeApiConfiguration(apiConfiguration, pearAiModels)
}, [apiConfiguration, pearAiModels])

const selectImages = useCallback(() => {
vscode.postMessage({ type: "selectImages" })
}, [])
Expand All @@ -507,6 +512,9 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
textAreaRef.current?.focus()
}
break
case "pearaiTokensValidated":
handleChatReset()
break
}
break
case "selectedImages":
Expand Down
Loading