Skip to content

Commit f69ea0a

Browse files
committed
fix: resolve PR issues
- Consolidate duplicate Announcement modal rendering logic - Remove unrelated formatting changes (semicolon and trailing comma) - Add translations for all non-English locales - Extract version indicator into reusable VersionIndicator component - Update tests to work with new component structure
1 parent b2ac59d commit f69ea0a

File tree

20 files changed

+78
-35
lines changed

20 files changed

+78
-35
lines changed

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { getApiMetrics } from "@roo/getApiMetrics"
2121
import { AudioType } from "@roo/WebviewMessage"
2222
import { getAllModes } from "@roo/modes"
2323
import { ProfileValidator } from "@roo/ProfileValidator"
24-
import { Package } from "@roo/package"
2524

2625
import { vscode } from "@src/utils/vscode"
2726
import { validateCommand } from "@src/utils/command-validation"
@@ -33,6 +32,7 @@ import RooHero from "@src/components/welcome/RooHero"
3332
import RooTips from "@src/components/welcome/RooTips"
3433

3534
import TelemetryBanner from "../common/TelemetryBanner"
35+
import VersionIndicator from "../common/VersionIndicator"
3636
import { useTaskSearch } from "../history/useTaskSearch"
3737
import HistoryPreview from "../history/HistoryPreview"
3838
import Announcement from "./Announcement"
@@ -1367,15 +1367,20 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
13671367
return (
13681368
<div className={isHidden ? "hidden" : "fixed top-0 left-0 right-0 bottom-0 flex flex-col overflow-hidden"}>
13691369
{/* Version indicator in top-right corner */}
1370-
<button
1371-
onClick={() => setShowAnnouncementModal(true)}
1372-
className="absolute top-2 right-2 text-xs text-vscode-descriptionForeground hover:text-vscode-foreground transition-colors cursor-pointer px-2 py-1 rounded border border-vscode-panel-border hover:border-vscode-focusBorder z-10"
1373-
aria-label={t("chat:versionIndicator.ariaLabel", { version: Package.version })}>
1374-
v{Package.version}
1375-
</button>
1376-
1377-
{showAnnouncement && <Announcement hideAnnouncement={hideAnnouncement} />}
1378-
{showAnnouncementModal && <Announcement hideAnnouncement={() => setShowAnnouncementModal(false)} />}
1370+
<VersionIndicator onClick={() => setShowAnnouncementModal(true)} className="absolute top-2 right-2 z-10" />
1371+
1372+
{(showAnnouncement || showAnnouncementModal) && (
1373+
<Announcement
1374+
hideAnnouncement={() => {
1375+
if (showAnnouncementModal) {
1376+
setShowAnnouncementModal(false)
1377+
}
1378+
if (showAnnouncement) {
1379+
hideAnnouncement()
1380+
}
1381+
}}
1382+
/>
1383+
)}
13791384
{task ? (
13801385
<>
13811386
<TaskHeader

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

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,23 @@ vi.mock("../AutoApproveMenu", () => ({
6161
default: () => null,
6262
}))
6363

64+
vi.mock("@src/components/common/VersionIndicator", () => ({
65+
default: function MockVersionIndicator({ onClick, className }: { onClick: () => void; className?: string }) {
66+
// eslint-disable-next-line @typescript-eslint/no-require-imports
67+
const React = require("react")
68+
return React.createElement(
69+
"button",
70+
{
71+
onClick,
72+
className,
73+
"aria-label": "chat:versionIndicator.ariaLabel",
74+
"data-testid": "version-indicator",
75+
},
76+
"v3.21.5",
77+
)
78+
},
79+
}))
80+
6481
vi.mock("@src/components/modals/Announcement", () => ({
6582
default: function MockAnnouncement({ hideAnnouncement }: { hideAnnouncement: () => void }) {
6683
// eslint-disable-next-line @typescript-eslint/no-require-imports
@@ -1136,20 +1153,18 @@ describe("ChatView - Version Indicator Tests", () => {
11361153
})
11371154

11381155
it("version indicator has correct styling classes", () => {
1139-
const { getByLabelText } = renderChatView()
1156+
const { getByTestId } = renderChatView()
11401157

11411158
// First hydrate state
11421159
mockPostMessage({
11431160
clineMessages: [],
11441161
})
11451162

1146-
// Check styling classes
1147-
const versionButton = getByLabelText(/version/i)
1148-
expect(versionButton.className).toContain("absolute")
1149-
expect(versionButton.className).toContain("top-2")
1150-
expect(versionButton.className).toContain("right-2")
1151-
expect(versionButton.className).toContain("text-xs")
1152-
expect(versionButton.className).toContain("cursor-pointer")
1163+
// Check styling classes - the VersionIndicator component receives className prop
1164+
const versionButton = getByTestId("version-indicator")
1165+
expect(versionButton).toBeInTheDocument()
1166+
// The className is passed as a prop to VersionIndicator
1167+
expect(versionButton.className).toContain("absolute top-2 right-2 z-10")
11531168
})
11541169

11551170
it("version indicator has proper accessibility attributes", () => {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from "react"
2+
import { useTranslation } from "react-i18next"
3+
import { Package } from "@roo/package"
4+
5+
interface VersionIndicatorProps {
6+
onClick: () => void
7+
className?: string
8+
}
9+
10+
const VersionIndicator: React.FC<VersionIndicatorProps> = ({ onClick, className = "" }) => {
11+
const { t } = useTranslation()
12+
13+
return (
14+
<button
15+
onClick={onClick}
16+
className={`text-xs text-vscode-descriptionForeground hover:text-vscode-foreground transition-colors cursor-pointer px-2 py-1 rounded border border-vscode-panel-border hover:border-vscode-focusBorder ${className}`}
17+
aria-label={t("chat:versionIndicator.ariaLabel", { version: Package.version })}>
18+
v{Package.version}
19+
</button>
20+
)
21+
}
22+
23+
export default VersionIndicator

webview-ui/src/i18n/locales/ca/chat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,6 @@
312312
"status": "Estat de l'índex"
313313
},
314314
"versionIndicator": {
315-
"ariaLabel": "Version {{version}} - Click to view release notes"
315+
"ariaLabel": "Versió {{version}} - Feu clic per veure les notes de llançament"
316316
}
317317
}

webview-ui/src/i18n/locales/de/chat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,6 @@
312312
"status": "Index-Status"
313313
},
314314
"versionIndicator": {
315-
"ariaLabel": "Version {{version}} - Click to view release notes"
315+
"ariaLabel": "Version {{version}} - Klicken Sie, um die Versionshinweise anzuzeigen"
316316
}
317317
}

webview-ui/src/i18n/locales/es/chat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,6 @@
312312
"status": "Estado del índice"
313313
},
314314
"versionIndicator": {
315-
"ariaLabel": "Version {{version}} - Click to view release notes"
315+
"ariaLabel": "Versión {{version}} - Haz clic para ver las notas de la versión"
316316
}
317317
}

webview-ui/src/i18n/locales/fr/chat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,6 @@
312312
"status": "Statut de l'index"
313313
},
314314
"versionIndicator": {
315-
"ariaLabel": "Version {{version}} - Click to view release notes"
315+
"ariaLabel": "Version {{version}} - Cliquez pour voir les notes de version"
316316
}
317317
}

webview-ui/src/i18n/locales/hi/chat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,6 @@
312312
"status": "इंडेक्स स्थिति"
313313
},
314314
"versionIndicator": {
315-
"ariaLabel": "Version {{version}} - Click to view release notes"
315+
"ariaLabel": "संस्करण {{version}} - रिलीज़ नोट्स देखने के लिए क्लिक करें"
316316
}
317317
}

webview-ui/src/i18n/locales/id/chat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,6 @@
318318
"status": "Status indeks"
319319
},
320320
"versionIndicator": {
321-
"ariaLabel": "Version {{version}} - Click to view release notes"
321+
"ariaLabel": "Versi {{version}} - Klik untuk melihat catatan rilis"
322322
}
323323
}

webview-ui/src/i18n/locales/it/chat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,6 @@
312312
"status": "Stato indice"
313313
},
314314
"versionIndicator": {
315-
"ariaLabel": "Version {{version}} - Click to view release notes"
315+
"ariaLabel": "Versione {{version}} - Clicca per visualizzare le note di rilascio"
316316
}
317317
}

0 commit comments

Comments
 (0)