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
173 changes: 77 additions & 96 deletions webview-ui/src/components/chat/Announcement.tsx
Original file line number Diff line number Diff line change
@@ -1,113 +1,94 @@
import { VSCodeButton, VSCodeLink } from "@vscode/webview-ui-toolkit/react"
import { memo } from "react"
import { useAppTranslation } from "@/i18n/TranslationContext"
import { useState, memo } from "react"
import { Trans } from "react-i18next"
import { VSCodeLink } from "@vscode/webview-ui-toolkit/react"

import { useAppTranslation } from "@src/i18n/TranslationContext"
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@src/components/ui"

interface AnnouncementProps {
hideAnnouncement: () => void
}
/*
You must update the latestAnnouncementId in ClineProvider 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 = ({ hideAnnouncement }: AnnouncementProps) => {
const { t } = useAppTranslation()

const discordLink = (
<VSCodeLink
href="https://discord.gg/roocode"
onClick={(e) => {
e.preventDefault()
window.postMessage(
{ type: "action", action: "openExternal", data: { url: "https://discord.gg/roocode" } },
"*",
)
}}>
Discord
</VSCodeLink>
)
/**
* You must update the `latestAnnouncementId` in ClineProvider for new
* announcements to show to users. This new id will be compared with what's 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 redditLink = (
<VSCodeLink
href="https://reddit.com/r/RooCode"
onClick={(e) => {
e.preventDefault()
window.postMessage(
{ type: "action", action: "openExternal", data: { url: "https://reddit.com/r/RooCode" } },
"*",
)
}}>
Reddit
</VSCodeLink>
)
const Announcement = ({ hideAnnouncement }: AnnouncementProps) => {
const { t } = useAppTranslation()
const [open, setOpen] = useState(true)

return (
<div className="flex flex-col justify-center absolute top-0 bottom-0 left-0 right-0 z-50 p-10 bg-black/50">
<div
style={{
backgroundColor: "var(--vscode-editor-background)",
borderRadius: "3px",
padding: "12px 16px",
margin: "5px 15px 5px 15px",
position: "relative",
flexShrink: 0,
}}>
<VSCodeButton
appearance="icon"
onClick={hideAnnouncement}
title={t("chat:announcement.hideButton")}
style={{ position: "absolute", top: "8px", right: "8px" }}>
<span className="codicon codicon-close"></span>
</VSCodeButton>
<h2 style={{ margin: "0 0 8px" }}>{t("chat:announcement.title")}</h2>

<p style={{ margin: "5px 0px" }}>{t("chat:announcement.description")}</p>

<h3 style={{ margin: "12px 0 5px", fontSize: "14px" }}>{t("chat:announcement.whatsNew")}</h3>
<ul style={{ margin: "5px 0" }}>
<li>
•{" "}
<Trans
i18nKey="chat:announcement.feature1"
components={{
bold: <b />,
code: <code />,
}}
/>
</li>
<li>
•{" "}
<Trans
i18nKey="chat:announcement.feature2"
components={{
bold: <b />,
code: <code />,
}}
/>
</li>
<li>
•{" "}
<Trans
i18nKey="chat:announcement.feature3"
components={{
bold: <b />,
code: <code />,
}}
/>
</li>
</ul>
<Dialog
open={open}
onOpenChange={(open) => {
setOpen(open)

<p style={{ margin: "10px 0px 0px" }}>
if (!open) {
hideAnnouncement()
}
}}>
<DialogContent className="max-w-96">
<DialogHeader>
<DialogTitle>{t("chat:announcement.title")}</DialogTitle>
<DialogDescription>{t("chat:announcement.description")}</DialogDescription>
</DialogHeader>
<div>
<h3>{t("chat:announcement.whatsNew")}</h3>
<ul className="space-y-2">
<li>
•{" "}
<Trans i18nKey="chat:announcement.feature1" components={{ bold: <b />, code: <code /> }} />
</li>
<li>
•{" "}
<Trans i18nKey="chat:announcement.feature2" components={{ bold: <b />, code: <code /> }} />
</li>
<li>
•{" "}
<Trans i18nKey="chat:announcement.feature3" components={{ bold: <b />, code: <code /> }} />
</li>
</ul>
<Trans
i18nKey="chat:announcement.detailsDiscussLinks"
components={{
discordLink: discordLink,
redditLink: redditLink,
}}
components={{ discordLink: <DiscordLink />, redditLink: <RedditLink /> }}
/>
</p>
</div>
</div>
</div>
</DialogContent>
</Dialog>
)
}

const DiscordLink = () => (
<VSCodeLink
href="https://discord.gg/roocode"
onClick={(e) => {
e.preventDefault()
window.postMessage(
{ type: "action", action: "openExternal", data: { url: "https://discord.gg/roocode" } },
"*",
)
}}>
Discord
</VSCodeLink>
)

const RedditLink = () => (
<VSCodeLink
href="https://reddit.com/r/RooCode"
onClick={(e) => {
e.preventDefault()
window.postMessage(
{ type: "action", action: "openExternal", data: { url: "https://reddit.com/r/RooCode" } },
"*",
)
}}>
Reddit
</VSCodeLink>
)

export default memo(Announcement)
64 changes: 14 additions & 50 deletions webview-ui/src/components/chat/AutoApproveMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useCallback, useMemo, useState } from "react"
import { Trans } from "react-i18next"
import { VSCodeCheckbox, VSCodeLink } from "@vscode/webview-ui-toolkit/react"

import { cn } from "@/lib/utils"
import { vscode } from "@src/utils/vscode"
import { useExtensionState } from "@src/context/ExtensionStateContext"
import { useAppTranslation } from "@src/i18n/TranslationContext"
Expand Down Expand Up @@ -118,23 +119,13 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {

return (
<div
style={{
padding: "0 15px",
userSelect: "none",
borderTop: isExpanded
? `0.5px solid color-mix(in srgb, var(--vscode-titleBar-inactiveForeground) 20%, transparent)`
: "none",
overflowY: "auto",
...style,
}}>
className={cn(
"px-[15px] select-none overflow-y-auto",
isExpanded && "border-t-[0.5px] border-vscode-titleBar-inactiveForeground-20",
)}
style={style}>
<div
style={{
display: "flex",
alignItems: "center",
gap: "8px",
padding: isExpanded ? "8px 0" : "8px 0 0 0",
cursor: "pointer",
}}
className={`flex items-center gap-2 cursor-pointer ${isExpanded ? "py-2" : "pt-2 pb-0"}`}
onClick={toggleExpanded}>
<div onClick={(e) => e.stopPropagation()}>
<VSCodeCheckbox
Expand All @@ -146,49 +137,22 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
}}
/>
</div>
<div
style={{
display: "flex",
alignItems: "center",
gap: "4px",
flex: 1,
minWidth: 0,
}}>
<span
style={{
color: "var(--vscode-foreground)",
flexShrink: 0,
}}>
{t("chat:autoApprove.title")}
</span>
<span
style={{
color: "var(--vscode-descriptionForeground)",
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
flex: 1,
minWidth: 0,
}}>
<div className="flex items-center gap-1 flex-1 min-w-0">
<span className="text-vscode-foreground flex-shrink-0">{t("chat:autoApprove.title")}</span>
<span className="text-vscode-descriptionForeground overflow-hidden text-ellipsis whitespace-nowrap flex-1 min-w-0">
{enabledActionsList || t("chat:autoApprove.none")}
</span>
<span
className={`codicon codicon-chevron-${isExpanded ? "down" : "right"}`}
style={{
flexShrink: 0,
marginLeft: isExpanded ? "2px" : "-2px",
}}
className={`codicon codicon-chevron-${isExpanded ? "down" : "right"} flex-shrink-0 ${
isExpanded ? "ml-0.5" : "ml-[-2px]"
}`}
/>
</div>
</div>

{isExpanded && (
<div className="flex flex-col gap-2">
<div
style={{
color: "var(--vscode-descriptionForeground)",
fontSize: "12px",
}}>
<div className="text-vscode-descriptionForeground text-xs">
<Trans
i18nKey="chat:autoApprove.description"
components={{
Expand Down
Loading