Skip to content

Commit b982197

Browse files
committed
Compromise-compromise.
1 parent 2eeae64 commit b982197

File tree

2 files changed

+56
-49
lines changed

2 files changed

+56
-49
lines changed

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

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import ChatTextArea from "./ChatTextArea"
3838
import TaskHeader from "./TaskHeader"
3939
import AutoApproveMenu from "./AutoApproveMenu"
4040
import SystemPromptWarning from "./SystemPromptWarning"
41+
import { useTaskSearch } from "../history/useTaskSearch"
4142
interface ChatViewProps {
4243
isHidden: boolean
4344
showAnnouncement: boolean
@@ -82,8 +83,23 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
8283
customModes,
8384
telemetrySetting,
8485
hasSystemPromptOverride,
86+
historyPreviewCollapsed, // Added historyPreviewCollapsed
8587
} = useExtensionState()
8688

89+
const { tasks } = useTaskSearch()
90+
91+
// Initialize expanded state based on the persisted setting (default to expanded if undefined)
92+
const [isExpanded, setIsExpanded] = useState(
93+
historyPreviewCollapsed === undefined ? true : !historyPreviewCollapsed,
94+
)
95+
96+
const toggleExpanded = useCallback(() => {
97+
const newState = !isExpanded
98+
setIsExpanded(newState)
99+
// Send message to extension to persist the new collapsed state
100+
vscode.postMessage({ type: "setHistoryPreviewCollapsed", bool: !newState })
101+
}, [isExpanded])
102+
87103
//const task = messages.length > 0 ? (messages[0].say === "task" ? messages[0] : undefined) : undefined) : undefined
88104
const task = useMemo(() => messages.at(0), [messages]) // 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 Cline.abort)
89105
const modifiedMessages = useMemo(() => combineApiRequests(combineCommandSequences(messages.slice(1))), [messages])
@@ -1227,18 +1243,31 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
12271243
)}
12281244
</>
12291245
) : (
1230-
<>
1231-
{taskHistory.length > 0 && <HistoryPreview showHistoryView={showHistoryView} />}
1232-
<div className="flex-1 min-h-0 overflow-y-auto flex flex-col justify-center p-10 gap-1 pb-[10px]">
1233-
{/* Show the task history if there are any for this workspace. */}
1234-
1235-
{telemetrySetting === "unset" && <TelemetryBanner />}
1246+
<div className="flex-1 min-h-0 overflow-y-auto flex flex-col gap-4">
1247+
{/* Moved Task Bar Header Here */}
1248+
{tasks.length !== 0 && (
1249+
<div className="flex items-center justify-end text-vscode-descriptionForeground w-full mx-auto max-w-[600px] px-5 pt-3">
1250+
<div className="flex items-center gap-1 cursor-pointer" onClick={toggleExpanded}>
1251+
{tasks.length < 10 && (
1252+
<span className={`font-medium text-xs `}>{t("history:recentTasks")}</span>
1253+
)}
1254+
<span
1255+
className={`codicon ${isExpanded ? "codicon-eye" : "codicon-eye-closed"} scale-90`}
1256+
/>
1257+
</div>
1258+
</div>
1259+
)}
1260+
<div className={`m-auto ${isExpanded ? "mt-0" : ""} p-10 pt-5"`}>
12361261
{showAnnouncement && <Announcement version={version} hideAnnouncement={hideAnnouncement} />}
12371262

1238-
{/* Always show the hero. */}
12391263
<RooHero />
1240-
{/* If the user has little task history, we can show the onboarding message */}
1241-
{taskHistory.length < 10 && (
1264+
{/* Always show the hero. */}
1265+
1266+
{telemetrySetting === "unset" && <TelemetryBanner />}
1267+
{/* Show the task history preview if expanded and tasks exist */}
1268+
{taskHistory.length > 0 && isExpanded && <HistoryPreview />}
1269+
{/* If the user has no task history, we can show the onboarding message */}
1270+
{taskHistory.length > -1 && (
12421271
<p className="ext-vscode-editor-foreground leading-tight font-vscode text-center">
12431272
<Trans
12441273
i18nKey="chat:about"
@@ -1255,11 +1284,10 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
12551284
/>
12561285
</p>
12571286
)}
1258-
1259-
{/* Finally, always show the tips */}
1260-
<RooTips cycle={false} />
1287+
{/* Finally, if there less than 3 tasks, we can show the tips */}
1288+
{tasks.length > -1 && <RooTips cycle={false} />}
12611289
</div>
1262-
</>
1290+
</div>
12631291
)}
12641292

12651293
{/*

webview-ui/src/components/history/HistoryPreview.tsx

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,23 @@
1-
import { memo, useState, useCallback } from "react"
1+
import { memo } from "react"
22

33
import { vscode } from "@/utils/vscode"
44
import { formatLargeNumber, formatDate } from "@/utils/format"
55
import { Button } from "@/components/ui"
66

77
import { useAppTranslation } from "@src/i18n/TranslationContext"
8-
import { useExtensionState } from "@src/context/ExtensionStateContext"
98
import { CopyButton } from "./CopyButton"
109
import { useTaskSearch } from "./useTaskSearch"
1110

1211
import { Trans } from "react-i18next"
1312
import { Coins } from "lucide-react"
1413

15-
type HistoryPreviewProps = {
16-
showHistoryView: () => void
17-
}
18-
const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
14+
const HistoryPreview = () => {
1915
const { tasks, showAllWorkspaces } = useTaskSearch()
20-
const { historyPreviewCollapsed } = useExtensionState() // Will add this state later
2116
const { t } = useAppTranslation()
22-
// Initialize expanded state based on the persisted setting (default to expanded if undefined)
23-
const [isExpanded, setIsExpanded] = useState(
24-
historyPreviewCollapsed === undefined ? true : !historyPreviewCollapsed,
25-
)
26-
27-
const toggleExpanded = useCallback(() => {
28-
const newState = !isExpanded
29-
setIsExpanded(newState)
30-
// Send message to extension to persist the new collapsed state
31-
vscode.postMessage({ type: "setHistoryPreviewCollapsed", bool: !newState })
32-
}, [isExpanded])
3317

3418
return (
3519
<>
3620
<div className="flex flex-col gap-3 shrink-0 mx-5">
37-
{tasks.length !== 0 && (
38-
<div className="flex items-center justify-between text-vscode-descriptionForeground w-full mx-auto max-w-[600px]">
39-
{/* Keep the history button, but maybe it should just show the full view? Or remove it if header is clicked? Let's keep it for now. */}
40-
<div className="font-bold">{t("chat:greeting")}</div>
41-
42-
<div className="flex items-center gap-1 cursor-pointer" onClick={toggleExpanded}>
43-
<span className="font-medium text-xs uppercase">
44-
{isExpanded ? "" : t("history:recentTasks")}
45-
</span>
46-
<span className={`codicon codicon-chevron-${isExpanded ? "up" : "down"} scale-90`} />
47-
</div>
48-
</div>
49-
)}
50-
5121
{tasks.length === 0 && (
5222
<>
5323
<p className="opacity-50 p-2 text-center my-0 mx-auto max-w-80">
@@ -66,14 +36,21 @@ const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
6636
/>
6737
</p>
6838

69-
<Button size="sm" variant="secondary" onClick={() => showHistoryView()} className="mx-auto">
39+
{/* The button to show history view will be moved to ChatView */}
40+
<Button
41+
size="sm"
42+
variant="secondary"
43+
onClick={() => {
44+
/* TODO: Implement or remove */
45+
}}
46+
className="mx-auto">
7047
<span className="codicon codicon-history size-[1rem]" />
7148
{t("history:viewAll")}
7249
</Button>
7350
</>
7451
)}
7552

76-
{tasks.length !== 0 && isExpanded && (
53+
{tasks.length !== 0 && (
7754
<>
7855
{tasks.slice(0, 3).map((item) => (
7956
<div
@@ -117,10 +94,12 @@ const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
11794
</div>
11895
</div>
11996
))}
120-
{/* Add a "View All" link below the preview list when expanded */}
97+
{/* The link to show history view will be moved to ChatView */}
12198
<div
12299
className="text-center text-xs text-vscode-descriptionForeground cursor-pointer hover:text-vscode-foreground mt-1"
123-
onClick={() => showHistoryView()}>
100+
onClick={() => {
101+
/* TODO: Implement or remove */
102+
}}>
124103
{t("history:viewAll")} ({tasks.length})
125104
</div>
126105
</>

0 commit comments

Comments
 (0)