Add Kodu announcement

This commit is contained in:
Saoud Rizwan
2024-08-24 21:42:20 -04:00
parent df4e8e7afc
commit 0298e7af7f
8 changed files with 107 additions and 59 deletions

View File

@@ -320,7 +320,7 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
await this.clearTask() await this.clearTask()
await this.postStateToWebview() await this.postStateToWebview()
break break
case "didShowAnnouncement": case "didCloseAnnouncement":
await this.updateGlobalState("lastShownAnnouncementId", this.latestAnnouncementId) await this.updateGlobalState("lastShownAnnouncementId", this.latestAnnouncementId)
await this.postStateToWebview() await this.postStateToWebview()
break break
@@ -377,6 +377,7 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
await this.updateGlobalState("koduEmail", email) await this.updateGlobalState("koduEmail", email)
await this.updateGlobalState("apiProvider", "kodu") await this.updateGlobalState("apiProvider", "kodu")
await this.postStateToWebview() await this.postStateToWebview()
await this.postMessageToWebview({ type: "action", action: "koduAuthenticated" })
this.claudeDev?.updateApi({ apiProvider: "kodu", koduApiKey: apiKey }) this.claudeDev?.updateApi({ apiProvider: "kodu", koduApiKey: apiKey })
} }

View File

@@ -12,6 +12,7 @@ export interface ExtensionMessage {
| "settingsButtonTapped" | "settingsButtonTapped"
| "historyButtonTapped" | "historyButtonTapped"
| "didBecomeVisible" | "didBecomeVisible"
| "koduAuthenticated"
| "koduCreditsFetched" | "koduCreditsFetched"
state?: ExtensionState state?: ExtensionState
images?: string[] images?: string[]

View File

@@ -9,7 +9,7 @@ export interface WebviewMessage {
| "newTask" | "newTask"
| "askResponse" | "askResponse"
| "clearTask" | "clearTask"
| "didShowAnnouncement" | "didCloseAnnouncement"
| "selectImages" | "selectImages"
| "exportCurrentTask" | "exportCurrentTask"
| "showTaskWithId" | "showTaskWithId"

View File

@@ -59,7 +59,6 @@ const App: React.FC = () => {
// don't update showAnnouncement to false if shouldShowAnnouncement is false // don't update showAnnouncement to false if shouldShowAnnouncement is false
if (message.state!.shouldShowAnnouncement) { if (message.state!.shouldShowAnnouncement) {
setShowAnnouncement(true) setShowAnnouncement(true)
vscode.postMessage({ type: "didShowAnnouncement" })
} }
setDidHydrateState(true) setDidHydrateState(true)
break break
@@ -77,6 +76,10 @@ const App: React.FC = () => {
setShowSettings(false) setShowSettings(false)
setShowHistory(false) setShowHistory(false)
break break
case "koduAuthenticated":
setShowSettings(true)
setShowHistory(false)
break
} }
break break
} }
@@ -127,7 +130,11 @@ const App: React.FC = () => {
showAnnouncement={showAnnouncement} showAnnouncement={showAnnouncement}
selectedModelSupportsImages={selectedModelInfo.supportsImages} selectedModelSupportsImages={selectedModelInfo.supportsImages}
selectedModelSupportsPromptCache={selectedModelInfo.supportsPromptCache} selectedModelSupportsPromptCache={selectedModelInfo.supportsPromptCache}
hideAnnouncement={() => setShowAnnouncement(false)} hideAnnouncement={() => {
vscode.postMessage({ type: "didCloseAnnouncement" })
setShowAnnouncement(false)
}}
apiConfiguration={apiConfiguration}
/> />
</> </>
)} )}

View File

@@ -1,13 +1,16 @@
import { VSCodeButton, VSCodeLink } from "@vscode/webview-ui-toolkit/react" import { VSCodeButton, VSCodeLink } from "@vscode/webview-ui-toolkit/react"
import { vscode } from "../utils/vscode"
import { ApiConfiguration } from "../../../src/shared/api"
interface AnnouncementProps { interface AnnouncementProps {
version: string version: string
hideAnnouncement: () => void hideAnnouncement: () => void
apiConfiguration?: ApiConfiguration
} }
/* /*
You must update the latestAnnouncementId in ClaudeDevProvider for new announcements to show to users. This new id will be compared with whats in state for the 'last announcement shown', and if it's different then the announcement will render. As soon as an announcement is shown, the id will be updated in state. This ensures that announcements are not shown more than once, even if the user doesn't close it themselves. You must update the latestAnnouncementId in ClaudeDevProvider for new announcements to show to users. This new id will be compared with whats in state for the 'last announcement shown', and if it's different then the announcement will render. As soon as an announcement is shown, the id will be updated in state. This ensures that announcements are not shown more than once, even if the user doesn't close it themselves.
*/ */
const Announcement = ({ version, hideAnnouncement }: AnnouncementProps) => { const Announcement = ({ version, hideAnnouncement, apiConfiguration }: AnnouncementProps) => {
return ( return (
<div <div
style={{ style={{
@@ -26,24 +29,34 @@ const Announcement = ({ version, hideAnnouncement }: AnnouncementProps) => {
<h3 style={{ margin: "0 0 8px" }}> <h3 style={{ margin: "0 0 8px" }}>
🎉{" "}New in v{version} 🎉{" "}New in v{version}
</h3> </h3>
<ul style={{ margin: "0 0 8px", paddingLeft: "20px" }}> <ul style={{ margin: "0 0 8px", paddingLeft: "20px" }}>
<li>Task history is here! New tasks will automatically save so you can always resume them later</li>
<li> <li>
Adds support for{" "} Excited to announce that{" "}
<VSCodeLink href="https://www.anthropic.com/news/prompt-caching" style={{ display: "inline" }}> <VSCodeLink href="https://kodu.ai" style={{ display: "inline" }}>
Prompt Caching Kodu
</VSCodeLink>{" "} </VSCodeLink>{" "}
to make requests up to 90% cheaper and 85% faster (currently only available through Anthropic API is offering $10 free credits to help new users get the most out of Claude Dev with high rate limits
for Claude 3.5 Sonnet and Claude 3.0 Haiku) and prompt caching! Stay tuned for some exciting updates like easier billing and deploying live
websites.
{apiConfiguration?.koduApiKey === undefined && (
<VSCodeButton
appearance="secondary"
onClick={() => vscode.postMessage({ type: "didClickKoduSignIn" })}
style={{
transform: "scale(0.8)",
transformOrigin: "left center",
margin: "4px 0 2px 0",
}}>
Claim $10 Free Credits
</VSCodeButton>
)}
</li> </li>
<li> <li>
Paste images in chat and turn mockups into fully functional applications or fix bugs with Added "Always allow read-only operations" setting to let Claude read files and view directories
screenshots without needing to hit Allow.
</li>
<li>
You can now add custom instructions to the end of the system prompt (e.g. "Always use Python",
"Speak in Spanish")
</li> </li>
<li>Added sliding window context management to keep tasks going past 200k tokens.</li>
</ul> </ul>
<p style={{ margin: "0" }}> <p style={{ margin: "0" }}>
Follow me for more updates!{" "} Follow me for more updates!{" "}

View File

@@ -165,9 +165,9 @@ const ApiOptions: React.FC<ApiOptionsProps> = ({
)} )}
{selectedProvider === "kodu" && ( {selectedProvider === "kodu" && (
<>
{apiConfiguration?.koduApiKey !== undefined ? (
<div> <div>
{apiConfiguration?.koduApiKey !== undefined ? (
<>
<div style={{ marginBottom: 5, marginTop: 3 }}> <div style={{ marginBottom: 5, marginTop: 3 }}>
<span style={{ color: "var(--vscode-descriptionForeground)" }}> <span style={{ color: "var(--vscode-descriptionForeground)" }}>
Signed in as {apiConfiguration?.koduEmail || "Unknown"} Signed in as {apiConfiguration?.koduEmail || "Unknown"}
@@ -192,21 +192,8 @@ const ApiOptions: React.FC<ApiOptionsProps> = ({
}}> }}>
Add Credits Add Credits
</VSCodeButton> </VSCodeButton>
<p </>
style={{
fontSize: "12px",
marginTop: "7px",
color: "var(--vscode-descriptionForeground)",
}}>
Kodu is recommended for its high rate limits and access to the latest features like
prompt caching.
<VSCodeLink href="https://kodu.ai/" style={{ display: "inline", fontSize: "12px" }}>
Learn more about Kodu here.
</VSCodeLink>
</p>
</div>
) : ( ) : (
<div>
<div style={{ margin: "4px 0px" }}> <div style={{ margin: "4px 0px" }}>
<VSCodeButton <VSCodeButton
appearance="primary" appearance="primary"
@@ -214,19 +201,21 @@ const ApiOptions: React.FC<ApiOptionsProps> = ({
Sign in to Kodu Sign in to Kodu
</VSCodeButton> </VSCodeButton>
</div> </div>
)}
<p <p
style={{ style={{
fontSize: 12, fontSize: 12,
marginTop: 5, marginTop: 6,
color: "var(--vscode-descriptionForeground)", color: "var(--vscode-descriptionForeground)",
}}> }}>
This will open your browser to sign in to Kodu. You will be redirected back to the Kodu is recommended for its high rate limits and access to the latest features like prompt
extension after signing in. caching.
<VSCodeLink href="https://kodu.ai/" style={{ display: "inline", fontSize: "12px" }}>
Learn more about Kodu here.
</VSCodeLink>
</p> </p>
</div> </div>
)} )}
</>
)}
{selectedProvider === "bedrock" && ( {selectedProvider === "bedrock" && (
<div style={{ display: "flex", flexDirection: "column", gap: 5 }}> <div style={{ display: "flex", flexDirection: "column", gap: 5 }}>

View File

@@ -16,6 +16,7 @@ import HistoryPreview from "./HistoryPreview"
import TaskHeader from "./TaskHeader" import TaskHeader from "./TaskHeader"
import Thumbnails from "./Thumbnails" import Thumbnails from "./Thumbnails"
import { HistoryItem } from "../../../src/shared/HistoryItem" import { HistoryItem } from "../../../src/shared/HistoryItem"
import { ApiConfiguration } from "../../../src/shared/api"
interface ChatViewProps { interface ChatViewProps {
version: string version: string
@@ -28,6 +29,7 @@ interface ChatViewProps {
selectedModelSupportsPromptCache: boolean selectedModelSupportsPromptCache: boolean
hideAnnouncement: () => void hideAnnouncement: () => void
showHistoryView: () => void showHistoryView: () => void
apiConfiguration?: ApiConfiguration
} }
const MAX_IMAGES_PER_MESSAGE = 20 // Anthropic limits to 20 images const MAX_IMAGES_PER_MESSAGE = 20 // Anthropic limits to 20 images
@@ -43,6 +45,7 @@ const ChatView = ({
selectedModelSupportsPromptCache, selectedModelSupportsPromptCache,
hideAnnouncement, hideAnnouncement,
showHistoryView, showHistoryView,
apiConfiguration,
}: ChatViewProps) => { }: ChatViewProps) => {
//const task = messages.length > 0 ? (messages[0].say === "task" ? messages[0] : undefined) : undefined) : undefined //const task = messages.length > 0 ? (messages[0].say === "task" ? messages[0] : undefined) : undefined) : undefined
const task = messages.length > 0 ? messages[0] : undefined // leaving this less safe version here since if the first message is not a task, then the extension is in a bad state and needs to be debugged (see ClaudeDev.abort) const task = messages.length > 0 ? messages[0] : undefined // leaving this less safe version here since if the first message is not a task, then the extension is in a bad state and needs to be debugged (see ClaudeDev.abort)
@@ -486,7 +489,13 @@ const ChatView = ({
/> />
) : ( ) : (
<> <>
{showAnnouncement && <Announcement version={version} hideAnnouncement={hideAnnouncement} />} {showAnnouncement && (
<Announcement
version={version}
hideAnnouncement={hideAnnouncement}
apiConfiguration={apiConfiguration}
/>
)}
<div style={{ padding: "0 20px", flexGrow: taskHistory.length > 0 ? undefined : 1 }}> <div style={{ padding: "0 20px", flexGrow: taskHistory.length > 0 ? undefined : 1 }}>
<h2>What can I do for you?</h2> <h2>What can I do for you?</h2>
<p> <p>

View File

@@ -31,23 +31,51 @@ const WelcomeView: React.FC<WelcomeViewProps> = ({ apiConfiguration, setApiConfi
<VSCodeLink <VSCodeLink
href="https://www-cdn.anthropic.com/fed9cc193a14b84131812372d8d5857f8f304c52/Model_Card_Claude_3_Addendum.pdf" href="https://www-cdn.anthropic.com/fed9cc193a14b84131812372d8d5857f8f304c52/Model_Card_Claude_3_Addendum.pdf"
style={{ display: "inline" }}> style={{ display: "inline" }}>
Claude 3.5 Sonnet's agentic coding capabilities. Claude 3.5 Sonnet's agentic coding capabilities
</VSCodeLink>{" "} </VSCodeLink>{" "}
I am prompted to think through tasks step-by-step and have access to tools that let me create & edit and access to tools that let me create & edit files, explore complex projects, and execute terminal
files, explore complex projects, and execute terminal commands (with your permission, of course). commands (with your permission, of course).
</p> </p>
<b>To get started, this extension needs an API key for Claude 3.5 Sonnet:</b> <b>To get started, this extension needs an API provider for Claude 3.5 Sonnet.</b>
<div style={{ marginTop: "15px" }}> <div
style={{
display: "flex",
alignItems: "center",
backgroundColor: "var(--vscode-editor-inactiveSelectionBackground)",
color: "var(--vscode-editor-foreground)",
padding: "6px 8px",
borderRadius: "3px",
margin: "8px 0px",
fontSize: "12px",
}}>
<i
className="codicon codicon-info"
style={{
marginRight: "6px",
fontSize: "16px",
color: "var(--vscode-infoIcon-foreground)",
}}></i>
<span>
Explore Claude's capabilities with $10 free credits from{" "}
<VSCodeLink href="https://kodu.ai" style={{ display: "inline" }}>
Kodu
</VSCodeLink>
</span>
</div>
<div style={{ marginTop: "10px" }}>
<ApiOptions <ApiOptions
apiConfiguration={apiConfiguration} apiConfiguration={apiConfiguration}
setApiConfiguration={setApiConfiguration} setApiConfiguration={setApiConfiguration}
showModelOptions={false} showModelOptions={false}
/> />
{apiConfiguration?.apiProvider !== "kodu" && (
<VSCodeButton onClick={handleSubmit} disabled={disableLetsGoButton} style={{ marginTop: "3px" }}> <VSCodeButton onClick={handleSubmit} disabled={disableLetsGoButton} style={{ marginTop: "3px" }}>
Let's go! Let's go!
</VSCodeButton> </VSCodeButton>
)}
</div> </div>
</div> </div>
) )