Fix vscode returning invalid array object for history state on certain devices

This commit is contained in:
Saoud Rizwan
2024-08-17 11:24:08 -04:00
parent 26fb2780b5
commit 4f00f89bf3
4 changed files with 186 additions and 172 deletions

View File

@@ -2,7 +2,7 @@
"name": "claude-dev", "name": "claude-dev",
"displayName": "Claude Dev", "displayName": "Claude Dev",
"description": "Autonomous coding agent right in your IDE, capable of creating/editing files, executing commands, and more with your permission every step of the way.", "description": "Autonomous coding agent right in your IDE, capable of creating/editing files, executing commands, and more with your permission every step of the way.",
"version": "1.3.2", "version": "1.3.3",
"icon": "icon.png", "icon": "icon.png",
"engines": { "engines": {
"vscode": "^1.84.0" "vscode": "^1.84.0"

View File

@@ -447,7 +447,7 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
customInstructions, customInstructions,
themeName: vscode.workspace.getConfiguration("workbench").get<string>("colorTheme"), themeName: vscode.workspace.getConfiguration("workbench").get<string>("colorTheme"),
claudeMessages: this.claudeDev?.claudeMessages || [], claudeMessages: this.claudeDev?.claudeMessages || [],
taskHistory: (taskHistory || []).sort((a, b) => b.ts - a.ts), taskHistory: (taskHistory || []).filter((item) => item.ts && item.task).sort((a, b) => b.ts - a.ts),
shouldShowAnnouncement: lastShownAnnouncementId !== this.latestAnnouncementId, shouldShowAnnouncement: lastShownAnnouncementId !== this.latestAnnouncementId,
}, },
}) })

View File

@@ -69,54 +69,60 @@ const HistoryPreview = ({ taskHistory, showHistoryView }: HistoryPreviewProps) =
</div> </div>
<div style={{ padding: "0px 20px 0 20px" }}> <div style={{ padding: "0px 20px 0 20px" }}>
{taskHistory.slice(0, 3).map((item) => ( {taskHistory
<div key={item.id} className="history-preview-item" onClick={() => handleHistorySelect(item.id)}> .filter((item) => item.ts && item.task && item.totalCost)
<div style={{ padding: "12px" }}> .slice(0, 3)
<div style={{ marginBottom: "8px" }}> .map((item) => (
<span <div
key={item.id}
className="history-preview-item"
onClick={() => handleHistorySelect(item.id)}>
<div style={{ padding: "12px" }}>
<div style={{ marginBottom: "8px" }}>
<span
style={{
color: "var(--vscode-descriptionForeground)",
fontWeight: 500,
fontSize: "0.85em",
textTransform: "uppercase",
}}>
{formatDate(item.ts)}
</span>
</div>
<div
style={{ style={{
fontSize: "var(--vscode-font-size)",
color: "var(--vscode-descriptionForeground)", color: "var(--vscode-descriptionForeground)",
fontWeight: 500, marginBottom: "8px",
fontSize: "0.85em", display: "-webkit-box",
textTransform: "uppercase", WebkitLineClamp: 3,
WebkitBoxOrient: "vertical",
overflow: "hidden",
whiteSpace: "pre-wrap",
wordBreak: "break-word",
overflowWrap: "anywhere",
}}> }}>
{formatDate(item.ts)} {item.task}
</span> </div>
</div> <div style={{ fontSize: "0.85em", color: "var(--vscode-descriptionForeground)" }}>
<div <span>
style={{ Tokens: {item.tokensIn?.toLocaleString()} {item.tokensOut?.toLocaleString()}
fontSize: "var(--vscode-font-size)", </span>
color: "var(--vscode-descriptionForeground)", {" • "}
marginBottom: "8px", {item.cacheWrites && item.cacheReads && (
display: "-webkit-box", <>
WebkitLineClamp: 3, <span>
WebkitBoxOrient: "vertical", Cache: +{item.cacheWrites?.toLocaleString()} {" "}
overflow: "hidden", {item.cacheReads?.toLocaleString()}
whiteSpace: "pre-wrap", </span>
wordBreak: "break-word", {" • "}
overflowWrap: "anywhere", </>
}}> )}
{item.task} <span>API Cost: ${item.totalCost?.toFixed(4)}</span>
</div> </div>
<div style={{ fontSize: "0.85em", color: "var(--vscode-descriptionForeground)" }}>
<span>
Tokens: {item.tokensIn?.toLocaleString()} {item.tokensOut?.toLocaleString()}
</span>
{" • "}
{item.cacheWrites && item.cacheReads && (
<>
<span>
Cache: +{item.cacheWrites?.toLocaleString()} {" "}
{item.cacheReads?.toLocaleString()}
</span>
{" • "}
</>
)}
<span>API Cost: ${item.totalCost?.toFixed(4)}</span>
</div> </div>
</div> </div>
</div> ))}
))}
<div style={{ display: "flex", alignItems: "center", justifyContent: "center" }}> <div style={{ display: "flex", alignItems: "center", justifyContent: "center" }}>
<VSCodeButton <VSCodeButton
appearance="icon" appearance="icon"

View File

@@ -98,114 +98,68 @@ const HistoryView = ({ taskHistory, onDone }: HistoryViewProps) => {
</div> </div>
)} )}
{taskHistory.map((item, index) => ( {taskHistory
<div .filter((item) => item.ts && item.task && item.totalCost)
key={item.id} .map((item, index) => (
className="history-item"
style={{
cursor: "pointer",
borderBottom:
index < taskHistory.length - 1 ? "1px solid var(--vscode-panel-border)" : "none",
}}
onClick={() => handleHistorySelect(item.id)}>
<div <div
key={item.id}
className="history-item"
style={{ style={{
display: "flex", cursor: "pointer",
flexDirection: "column", borderBottom:
gap: "8px", index < taskHistory.length - 1
padding: "12px 20px", ? "1px solid var(--vscode-panel-border)"
position: "relative", : "none",
}}> }}
onClick={() => handleHistorySelect(item.id)}>
<div <div
style={{ style={{
display: "flex", display: "flex",
justifyContent: "space-between", flexDirection: "column",
alignItems: "center", gap: "8px",
padding: "12px 20px",
position: "relative",
}}> }}>
<span
style={{
color: "var(--vscode-descriptionForeground)",
fontWeight: 500,
fontSize: "0.85em",
textTransform: "uppercase",
}}>
{formatDate(item.ts)}
</span>
<VSCodeButton
appearance="icon"
onClick={(e) => {
e.stopPropagation()
handleDeleteHistoryItem(item.id)
}}
className="delete-button">
<span className="codicon codicon-trash"></span>
</VSCodeButton>
</div>
<div
style={{
fontSize: "var(--vscode-font-size)",
color: "var(--vscode-foreground)",
display: "-webkit-box",
WebkitLineClamp: 3,
WebkitBoxOrient: "vertical",
overflow: "hidden",
whiteSpace: "pre-wrap",
wordBreak: "break-word",
overflowWrap: "anywhere",
}}>
{item.task}
</div>
<div style={{ display: "flex", flexDirection: "column", gap: "4px" }}>
<div <div
style={{ style={{
display: "flex", display: "flex",
justifyContent: "space-between",
alignItems: "center", alignItems: "center",
gap: "4px",
flexWrap: "wrap",
}}> }}>
<span <span
style={{ style={{
color: "var(--vscode-descriptionForeground)",
fontWeight: 500, fontWeight: 500,
color: "var(--vscode-descriptionForeground)", fontSize: "0.85em",
textTransform: "uppercase",
}}> }}>
Tokens: {formatDate(item.ts)}
</span>
<span
style={{
display: "flex",
alignItems: "center",
gap: "3px",
color: "var(--vscode-descriptionForeground)",
}}>
<i
className="codicon codicon-arrow-up"
style={{
fontSize: "12px",
fontWeight: "bold",
marginBottom: "-2px",
}}
/>
{item.tokensIn?.toLocaleString()}
</span>
<span
style={{
display: "flex",
alignItems: "center",
gap: "3px",
color: "var(--vscode-descriptionForeground)",
}}>
<i
className="codicon codicon-arrow-down"
style={{
fontSize: "12px",
fontWeight: "bold",
marginBottom: "-2px",
}}
/>
{item.tokensOut?.toLocaleString()}
</span> </span>
<VSCodeButton
appearance="icon"
onClick={(e) => {
e.stopPropagation()
handleDeleteHistoryItem(item.id)
}}
className="delete-button">
<span className="codicon codicon-trash"></span>
</VSCodeButton>
</div> </div>
{item.cacheWrites && item.cacheReads && ( <div
style={{
fontSize: "var(--vscode-font-size)",
color: "var(--vscode-foreground)",
display: "-webkit-box",
WebkitLineClamp: 3,
WebkitBoxOrient: "vertical",
overflow: "hidden",
whiteSpace: "pre-wrap",
wordBreak: "break-word",
overflowWrap: "anywhere",
}}>
{item.task}
</div>
<div style={{ display: "flex", flexDirection: "column", gap: "4px" }}>
<div <div
style={{ style={{
display: "flex", display: "flex",
@@ -218,7 +172,7 @@ const HistoryView = ({ taskHistory, onDone }: HistoryViewProps) => {
fontWeight: 500, fontWeight: 500,
color: "var(--vscode-descriptionForeground)", color: "var(--vscode-descriptionForeground)",
}}> }}>
Cache: Tokens:
</span> </span>
<span <span
style={{ style={{
@@ -228,14 +182,14 @@ const HistoryView = ({ taskHistory, onDone }: HistoryViewProps) => {
color: "var(--vscode-descriptionForeground)", color: "var(--vscode-descriptionForeground)",
}}> }}>
<i <i
className="codicon codicon-database" className="codicon codicon-arrow-up"
style={{ style={{
fontSize: "12px", fontSize: "12px",
fontWeight: "bold", fontWeight: "bold",
marginBottom: "-1px", marginBottom: "-2px",
}} }}
/> />
+{item.cacheWrites?.toLocaleString()} {item.tokensIn?.toLocaleString()}
</span> </span>
<span <span
style={{ style={{
@@ -245,47 +199,101 @@ const HistoryView = ({ taskHistory, onDone }: HistoryViewProps) => {
color: "var(--vscode-descriptionForeground)", color: "var(--vscode-descriptionForeground)",
}}> }}>
<i <i
className="codicon codicon-arrow-right" className="codicon codicon-arrow-down"
style={{ fontSize: "12px", fontWeight: "bold", marginBottom: 0 }} style={{
fontSize: "12px",
fontWeight: "bold",
marginBottom: "-2px",
}}
/> />
{item.cacheReads?.toLocaleString()} {item.tokensOut?.toLocaleString()}
</span> </span>
</div> </div>
)} {item.cacheWrites && item.cacheReads && (
<div <div
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
marginTop: -2,
}}>
<div style={{ display: "flex", alignItems: "center", gap: "4px" }}>
<span
style={{ style={{
fontWeight: 500, display: "flex",
color: "var(--vscode-descriptionForeground)", alignItems: "center",
gap: "4px",
flexWrap: "wrap",
}}> }}>
API Cost: <span
</span> style={{
<span style={{ color: "var(--vscode-descriptionForeground)" }}> fontWeight: 500,
${item.totalCost?.toFixed(4)} color: "var(--vscode-descriptionForeground)",
</span> }}>
</div> Cache:
<VSCodeButton </span>
appearance="icon" <span
onClick={(e) => { style={{
e.stopPropagation() display: "flex",
handleExportMd(item.id) alignItems: "center",
}}> gap: "3px",
<div style={{ fontSize: "11px", fontWeight: 500, opacity: 1 }}> color: "var(--vscode-descriptionForeground)",
EXPORT .MD }}>
<i
className="codicon codicon-database"
style={{
fontSize: "12px",
fontWeight: "bold",
marginBottom: "-1px",
}}
/>
+{item.cacheWrites?.toLocaleString()}
</span>
<span
style={{
display: "flex",
alignItems: "center",
gap: "3px",
color: "var(--vscode-descriptionForeground)",
}}>
<i
className="codicon codicon-arrow-right"
style={{
fontSize: "12px",
fontWeight: "bold",
marginBottom: 0,
}}
/>
{item.cacheReads?.toLocaleString()}
</span>
</div> </div>
</VSCodeButton> )}
<div
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
marginTop: -2,
}}>
<div style={{ display: "flex", alignItems: "center", gap: "4px" }}>
<span
style={{
fontWeight: 500,
color: "var(--vscode-descriptionForeground)",
}}>
API Cost:
</span>
<span style={{ color: "var(--vscode-descriptionForeground)" }}>
${item.totalCost?.toFixed(4)}
</span>
</div>
<VSCodeButton
appearance="icon"
onClick={(e) => {
e.stopPropagation()
handleExportMd(item.id)
}}>
<div style={{ fontSize: "11px", fontWeight: 500, opacity: 1 }}>
EXPORT .MD
</div>
</VSCodeButton>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> ))}
))}
</div> </div>
</div> </div>
</> </>