Skip to content
Closed
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
3 changes: 3 additions & 0 deletions src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,8 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
const machineId = vscode.env.machineId
const allowedCommands = vscode.workspace.getConfiguration("roo-cline").get<string[]>("allowedCommands") || []
const cwd = this.cwd
const workspaceTrustEnabled =
vscode.workspace.getConfiguration("security").get<boolean>("workspace.trust.enabled") ?? false

return {
version: this.context.extension?.packageJSON?.version ?? "",
Expand Down Expand Up @@ -1325,6 +1327,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
maxReadFileLine: maxReadFileLine ?? 500,
settingsImportedAt: this.settingsImportedAt,
showGreeting: showGreeting ?? true, // Ensure showGreeting is included in the returned state
workspaceTrustEnabled, // Add the workspace trust setting here
}
}

Expand Down
1 change: 1 addition & 0 deletions src/shared/ExtensionMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ export type ExtensionState = Pick<

renderContext: "sidebar" | "editor"
settingsImportedAt?: number
workspaceTrustEnabled?: boolean
}

export type { ClineMessage, ClineAsk, ClineSay }
Expand Down
36 changes: 23 additions & 13 deletions webview-ui/src/components/history/HistoryPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { memo } from "react"
import { memo, useEffect } from "react"

import { vscode } from "@/utils/vscode"
import { formatLargeNumber, formatDate } from "@/utils/format"
import { Button, Checkbox } from "@/components/ui"
import { useExtensionState } from "@/context/ExtensionStateContext" // Import the context hook

import { useAppTranslation } from "../../i18n/TranslationContext"
import { CopyButton } from "./CopyButton"
Expand All @@ -13,8 +14,15 @@ type HistoryPreviewProps = {
}
const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
const { tasks, showAllWorkspaces, setShowAllWorkspaces } = useTaskSearch()
const { workspaceTrustEnabled } = useExtensionState()
const { t } = useAppTranslation()

useEffect(() => {
if (!workspaceTrustEnabled) {
setShowAllWorkspaces(true)
}
}, [workspaceTrustEnabled, setShowAllWorkspaces])

return (
<div className="flex flex-col gap-3 shrink-0 mx-5">
<div className="flex items-center justify-between text-vscode-descriptionForeground">
Expand All @@ -26,17 +34,19 @@ const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
{t("history:viewAll")}
</Button>
</div>
<div className="flex items-center gap-2 mb-2">
<Checkbox
id="show-all-workspaces"
checked={showAllWorkspaces}
onCheckedChange={(checked) => setShowAllWorkspaces(checked === true)}
variant="description"
/>
<label htmlFor="show-all-workspaces" className="text-xs text-vscode-foreground cursor-pointer">
{t("history:showAllWorkspaces")}
</label>
</div>
{workspaceTrustEnabled && (
<div className="flex items-center gap-2 mb-2">
<Checkbox
id="show-all-workspaces"
checked={showAllWorkspaces}
onCheckedChange={(checked) => setShowAllWorkspaces(checked === true)}
variant="description"
/>
<label htmlFor="show-all-workspaces" className="text-xs text-vscode-foreground cursor-pointer">
{t("history:showAllWorkspaces")}
</label>
</div>
)}
{tasks.slice(0, 3).map((item) => (
<div
key={item.id}
Expand Down Expand Up @@ -85,7 +95,7 @@ const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
</>
)}
</div>
{showAllWorkspaces && item.workspace && (
{showAllWorkspaces && workspaceTrustEnabled && item.workspace && (
<div className="flex flex-row gap-1 text-vscode-descriptionForeground text-xs mt-1">
<span className="codicon codicon-folder scale-80" />
<span>{item.workspace}</span>
Expand Down
36 changes: 23 additions & 13 deletions webview-ui/src/components/history/HistoryView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { memo, useState } from "react"
import React, { memo, useState, useEffect } from "react"
import { DeleteTaskDialog } from "./DeleteTaskDialog"
import { BatchDeleteTaskDialog } from "./BatchDeleteTaskDialog"
import prettyBytes from "pretty-bytes"
Expand All @@ -11,6 +11,7 @@ import { formatLargeNumber, formatDate } from "@/utils/format"
import { cn } from "@/lib/utils"
import { Button, Checkbox } from "@/components/ui"
import { useAppTranslation } from "@/i18n/TranslationContext"
import { useExtensionState } from "@/context/ExtensionStateContext" // Import the context hook

import { Tab, TabContent, TabHeader } from "../common/Tab"
import { useTaskSearch } from "./useTaskSearch"
Expand All @@ -35,12 +36,19 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
setShowAllWorkspaces,
} = useTaskSearch()
const { t } = useAppTranslation()
const { workspaceTrustEnabled } = useExtensionState()

const [deleteTaskId, setDeleteTaskId] = useState<string | null>(null)
const [isSelectionMode, setIsSelectionMode] = useState(false)
const [selectedTaskIds, setSelectedTaskIds] = useState<string[]>([])
const [showBatchDeleteDialog, setShowBatchDeleteDialog] = useState<boolean>(false)

useEffect(() => {
if (!workspaceTrustEnabled) {
setShowAllWorkspaces(true)
}
}, [workspaceTrustEnabled, setShowAllWorkspaces])

// Toggle selection mode
const toggleSelectionMode = () => {
setIsSelectionMode(!isSelectionMode)
Expand Down Expand Up @@ -156,17 +164,19 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
</VSCodeRadio>
</VSCodeRadioGroup>

<div className="flex items-center gap-2">
<Checkbox
id="show-all-workspaces-view"
checked={showAllWorkspaces}
onCheckedChange={(checked) => setShowAllWorkspaces(checked === true)}
variant="description"
/>
<label htmlFor="show-all-workspaces-view" className="text-vscode-foreground cursor-pointer">
{t("history:showAllWorkspaces")}
</label>
</div>
{workspaceTrustEnabled && (
<div className="flex items-center gap-2">
<Checkbox
id="show-all-workspaces-view"
checked={showAllWorkspaces}
onCheckedChange={(checked) => setShowAllWorkspaces(checked === true)}
variant="description"
/>
<label htmlFor="show-all-workspaces-view" className="text-vscode-foreground cursor-pointer">
{t("history:showAllWorkspaces")}
</label>
</div>
)}

{/* Select all control in selection mode */}
{isSelectionMode && tasks.length > 0 && (
Expand Down Expand Up @@ -436,7 +446,7 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
</div>
)}

{showAllWorkspaces && item.workspace && (
{showAllWorkspaces && workspaceTrustEnabled && item.workspace && (
<div className="flex flex-row gap-1 text-vscode-descriptionForeground text-xs">
<span className="codicon codicon-folder scale-80" />
<span>{item.workspace}</span>
Expand Down
3 changes: 3 additions & 0 deletions webview-ui/src/context/ExtensionStateContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export interface ExtensionStateContextType extends ExtensionState {
setPinnedApiConfigs: (value: Record<string, boolean>) => void
togglePinnedApiConfig: (configName: string) => void
setShowGreeting: (value: boolean) => void
workspaceTrustEnabled: boolean
}

export const ExtensionStateContext = createContext<ExtensionStateContextType | undefined>(undefined)
Expand Down Expand Up @@ -165,6 +166,7 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
terminalZshOhMy: false, // Default Oh My Zsh integration setting
terminalZshP10k: false, // Default Powerlevel10k integration setting
terminalZdotdir: false, // Default ZDOTDIR handling setting
workspaceTrustEnabled: false, // Add default value for the new property
})

const [didHydrateState, setDidHydrateState] = useState(false)
Expand Down Expand Up @@ -243,6 +245,7 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode

const contextValue: ExtensionStateContextType = {
...state,
workspaceTrustEnabled: state.workspaceTrustEnabled ?? false,
didHydrateState,
showWelcome,
theme,
Expand Down