From 060ef74efa2fbb3dee2b75278aea813074a9f85e Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Sun, 6 Apr 2025 14:01:33 -0400 Subject: [PATCH] Add deep links to settings sections --- webview-ui/src/App.tsx | 10 +++++- .../src/components/chat/AutoApproveMenu.tsx | 6 +++- .../src/components/chat/ChatTextArea.tsx | 6 +++- webview-ui/src/components/chat/ChatView.tsx | 33 ++++++++++++------- .../src/components/common/TelemetryBanner.tsx | 6 +++- .../src/components/settings/SettingsView.tsx | 14 +++++++- webview-ui/src/i18n/locales/ca/chat.json | 1 + webview-ui/src/i18n/locales/de/chat.json | 1 + webview-ui/src/i18n/locales/en/chat.json | 1 + webview-ui/src/i18n/locales/es/chat.json | 1 + webview-ui/src/i18n/locales/fr/chat.json | 1 + webview-ui/src/i18n/locales/hi/chat.json | 1 + webview-ui/src/i18n/locales/it/chat.json | 1 + webview-ui/src/i18n/locales/ja/chat.json | 1 + webview-ui/src/i18n/locales/ko/chat.json | 1 + webview-ui/src/i18n/locales/pl/chat.json | 1 + webview-ui/src/i18n/locales/pt-BR/chat.json | 1 + webview-ui/src/i18n/locales/tr/chat.json | 1 + webview-ui/src/i18n/locales/vi/chat.json | 1 + webview-ui/src/i18n/locales/zh-CN/chat.json | 1 + webview-ui/src/i18n/locales/zh-TW/chat.json | 1 + 21 files changed, 74 insertions(+), 16 deletions(-) diff --git a/webview-ui/src/App.tsx b/webview-ui/src/App.tsx index 59a40472518..b6ddc1883eb 100644 --- a/webview-ui/src/App.tsx +++ b/webview-ui/src/App.tsx @@ -46,6 +46,8 @@ const App = () => { const settingsRef = useRef(null) const switchTab = useCallback((newTab: Tab) => { + setCurrentSection(undefined) + if (settingsRef.current?.checkUnsaveChanges) { settingsRef.current.checkUnsaveChanges(() => setTab(newTab)) } else { @@ -53,15 +55,19 @@ const App = () => { } }, []) + const [currentSection, setCurrentSection] = useState(undefined) + const onMessage = useCallback( (e: MessageEvent) => { const message: ExtensionMessage = e.data if (message.type === "action" && message.action) { const newTab = tabsByMessageAction[message.action] + const section = message.values?.section as string | undefined if (newTab) { switchTab(newTab) + setCurrentSection(section) } } @@ -104,7 +110,9 @@ const App = () => { {tab === "prompts" && switchTab("chat")} />} {tab === "mcp" && switchTab("chat")} />} {tab === "history" && switchTab("chat")} />} - {tab === "settings" && setTab("chat")} />} + {tab === "settings" && ( + switchTab("chat")} targetSection={currentSection} /> + )} { }, [alwaysApproveResubmit, setAlwaysApproveResubmit]) const handleOpenSettings = useCallback(() => { - window.postMessage({ type: "action", action: "settingsButtonClicked" }) + window.postMessage({ + type: "action", + action: "settingsButtonClicked", + values: { section: "autoApprove" }, + }) }, []) // Map action IDs to their specific handlers diff --git a/webview-ui/src/components/chat/ChatTextArea.tsx b/webview-ui/src/components/chat/ChatTextArea.tsx index 6f82da00d72..2c9c2fbc836 100644 --- a/webview-ui/src/components/chat/ChatTextArea.tsx +++ b/webview-ui/src/components/chat/ChatTextArea.tsx @@ -1028,7 +1028,11 @@ const ChatTextArea = forwardRef( ]} onChange={(value) => { if (value === "settingsButtonClicked") { - vscode.postMessage({ type: "loadApiConfiguration", text: value }) + vscode.postMessage({ + type: "loadApiConfiguration", + text: value, + values: { section: "providers" }, + }) } else { vscode.postMessage({ type: "loadApiConfigurationById", text: value }) } diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index 85ce7cd1cbc..1b33c2003f6 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -32,7 +32,7 @@ import { getAllModes } from "../../../../src/shared/modes" import TelemetryBanner from "../common/TelemetryBanner" import { useAppTranslation } from "@/i18n/TranslationContext" import removeMd from "remove-markdown" - +import { Trans } from "react-i18next" interface ChatViewProps { isHidden: boolean showAnnouncement: boolean @@ -1006,17 +1006,28 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
- Still initializing checkpoint... If this takes too long, you can{" "} - { - e.preventDefault() - window.postMessage({ type: "action", action: "settingsButtonClicked" }, "*") + { + e.preventDefault() + window.postMessage( + { + type: "action", + action: "settingsButtonClicked", + values: { section: "checkpoints" }, + }, + "*", + ) + }} + className="inline px-0.5" + /> + ), }} - className="inline px-0.5"> - disable checkpoints in settings - {" "} - and restart your task. + />
), diff --git a/webview-ui/src/components/common/TelemetryBanner.tsx b/webview-ui/src/components/common/TelemetryBanner.tsx index 8d96359aca4..b27c6a1efbc 100644 --- a/webview-ui/src/components/common/TelemetryBanner.tsx +++ b/webview-ui/src/components/common/TelemetryBanner.tsx @@ -40,7 +40,11 @@ const TelemetryBanner = () => { } const handleOpenSettings = () => { - window.postMessage({ type: "action", action: "settingsButtonClicked" }) + window.postMessage({ + type: "action", + action: "settingsButtonClicked", + values: { section: "advanced" }, // Link directly to advanced settings with telemetry controls + }) } return ( diff --git a/webview-ui/src/components/settings/SettingsView.tsx b/webview-ui/src/components/settings/SettingsView.tsx index 0171537b9e0..ca5b3e38283 100644 --- a/webview-ui/src/components/settings/SettingsView.tsx +++ b/webview-ui/src/components/settings/SettingsView.tsx @@ -78,9 +78,10 @@ type SectionName = (typeof sectionNames)[number] type SettingsViewProps = { onDone: () => void + targetSection?: string } -const SettingsView = forwardRef(({ onDone }, ref) => { +const SettingsView = forwardRef(({ onDone, targetSection }, ref) => { const { t } = useAppTranslation() const extensionState = useExtensionState() @@ -316,6 +317,17 @@ const SettingsView = forwardRef(({ onDone }, const scrollToSection = (ref: React.RefObject) => ref.current?.scrollIntoView() + // Scroll to target section when specified + useEffect(() => { + if (targetSection) { + const sectionObj = sections.find((section) => section.id === targetSection) + if (sectionObj && sectionObj.ref.current) { + // Use setTimeout to ensure the scroll happens after render + setTimeout(() => scrollToSection(sectionObj.ref), 500) + } + } + }, [targetSection, sections]) + return ( diff --git a/webview-ui/src/i18n/locales/ca/chat.json b/webview-ui/src/i18n/locales/ca/chat.json index 12dc8ec2638..4dbe0095471 100644 --- a/webview-ui/src/i18n/locales/ca/chat.json +++ b/webview-ui/src/i18n/locales/ca/chat.json @@ -94,6 +94,7 @@ "checkpoint": { "initial": "Punt de control inicial", "regular": "Punt de control", + "initializingWarning": "Encara s'està inicialitzant el punt de control... Si això triga massa, pots desactivar els punts de control a la configuració i reiniciar la teva tasca.", "menu": { "viewDiff": "Veure diferències", "restore": "Restaurar punt de control", diff --git a/webview-ui/src/i18n/locales/de/chat.json b/webview-ui/src/i18n/locales/de/chat.json index fdfcd433c66..5b19c8cca95 100644 --- a/webview-ui/src/i18n/locales/de/chat.json +++ b/webview-ui/src/i18n/locales/de/chat.json @@ -94,6 +94,7 @@ "checkpoint": { "initial": "Initialer Checkpoint", "regular": "Checkpoint", + "initializingWarning": "Checkpoint wird noch initialisiert... Falls dies zu lange dauert, kannst du Checkpoints in den Einstellungen deaktivieren und deine Aufgabe neu starten.", "menu": { "viewDiff": "Unterschiede anzeigen", "restore": "Checkpoint wiederherstellen", diff --git a/webview-ui/src/i18n/locales/en/chat.json b/webview-ui/src/i18n/locales/en/chat.json index 77c887d8bae..73f7afd51c2 100644 --- a/webview-ui/src/i18n/locales/en/chat.json +++ b/webview-ui/src/i18n/locales/en/chat.json @@ -92,6 +92,7 @@ "checkpoint": { "initial": "Initial Checkpoint", "regular": "Checkpoint", + "initializingWarning": "Still initializing checkpoint... If this takes too long, you can disable checkpoints in settings and restart your task.", "menu": { "viewDiff": "View Diff", "restore": "Restore Checkpoint", diff --git a/webview-ui/src/i18n/locales/es/chat.json b/webview-ui/src/i18n/locales/es/chat.json index 028cf52766a..2181c94d7ba 100644 --- a/webview-ui/src/i18n/locales/es/chat.json +++ b/webview-ui/src/i18n/locales/es/chat.json @@ -94,6 +94,7 @@ "checkpoint": { "initial": "Punto de control inicial", "regular": "Punto de control", + "initializingWarning": "Todavía inicializando el punto de control... Si esto tarda demasiado, puedes desactivar los puntos de control en la configuración y reiniciar tu tarea.", "menu": { "viewDiff": "Ver diferencias", "restore": "Restaurar punto de control", diff --git a/webview-ui/src/i18n/locales/fr/chat.json b/webview-ui/src/i18n/locales/fr/chat.json index 281bee9ae11..dc42265a3b3 100644 --- a/webview-ui/src/i18n/locales/fr/chat.json +++ b/webview-ui/src/i18n/locales/fr/chat.json @@ -94,6 +94,7 @@ "checkpoint": { "initial": "Point de contrôle initial", "regular": "Point de contrôle", + "initializingWarning": "Initialisation du point de contrôle en cours... Si cela prend trop de temps, tu peux désactiver les points de contrôle dans les paramètres et redémarrer ta tâche.", "menu": { "viewDiff": "Voir les différences", "restore": "Restaurer le point de contrôle", diff --git a/webview-ui/src/i18n/locales/hi/chat.json b/webview-ui/src/i18n/locales/hi/chat.json index bc34296d963..e4cadd005e3 100644 --- a/webview-ui/src/i18n/locales/hi/chat.json +++ b/webview-ui/src/i18n/locales/hi/chat.json @@ -94,6 +94,7 @@ "checkpoint": { "initial": "प्रारंभिक चेकपॉइंट", "regular": "चेकपॉइंट", + "initializingWarning": "चेकपॉइंट अभी भी आरंभ हो रहा है... अगर यह बहुत समय ले रहा है, तो आप सेटिंग्स में चेकपॉइंट को अक्षम कर सकते हैं और अपने कार्य को पुनः आरंभ कर सकते हैं।", "menu": { "viewDiff": "अंतर देखें", "restore": "चेकपॉइंट पुनर्स्थापित करें", diff --git a/webview-ui/src/i18n/locales/it/chat.json b/webview-ui/src/i18n/locales/it/chat.json index 84e86dc7147..cd7b7c268ca 100644 --- a/webview-ui/src/i18n/locales/it/chat.json +++ b/webview-ui/src/i18n/locales/it/chat.json @@ -97,6 +97,7 @@ "checkpoint": { "initial": "Checkpoint iniziale", "regular": "Checkpoint", + "initializingWarning": "Inizializzazione del checkpoint in corso... Se questa operazione richiede troppo tempo, puoi disattivare i checkpoint nelle impostazioni e riavviare l'attività.", "menu": { "viewDiff": "Visualizza differenze", "restore": "Ripristina checkpoint", diff --git a/webview-ui/src/i18n/locales/ja/chat.json b/webview-ui/src/i18n/locales/ja/chat.json index 15e47418121..e4be11617ce 100644 --- a/webview-ui/src/i18n/locales/ja/chat.json +++ b/webview-ui/src/i18n/locales/ja/chat.json @@ -94,6 +94,7 @@ "checkpoint": { "initial": "初期チェックポイント", "regular": "チェックポイント", + "initializingWarning": "チェックポイントの初期化中... 時間がかかりすぎる場合は、設定でチェックポイントを無効にしてタスクを再開できます。", "menu": { "viewDiff": "差分を表示", "restore": "チェックポイントを復元", diff --git a/webview-ui/src/i18n/locales/ko/chat.json b/webview-ui/src/i18n/locales/ko/chat.json index 0ab7b4e8cea..b92c1b6de2e 100644 --- a/webview-ui/src/i18n/locales/ko/chat.json +++ b/webview-ui/src/i18n/locales/ko/chat.json @@ -94,6 +94,7 @@ "checkpoint": { "initial": "초기 체크포인트", "regular": "체크포인트", + "initializingWarning": "체크포인트 초기화 중... 시간이 너무 오래 걸리면 설정에서 체크포인트를 비활성화하고 작업을 다시 시작할 수 있습니다.", "menu": { "viewDiff": "차이점 보기", "restore": "체크포인트 복원", diff --git a/webview-ui/src/i18n/locales/pl/chat.json b/webview-ui/src/i18n/locales/pl/chat.json index 3ab92c4e572..1fc9fc81486 100644 --- a/webview-ui/src/i18n/locales/pl/chat.json +++ b/webview-ui/src/i18n/locales/pl/chat.json @@ -94,6 +94,7 @@ "checkpoint": { "initial": "Początkowy punkt kontrolny", "regular": "Punkt kontrolny", + "initializingWarning": "Trwa inicjalizacja punktu kontrolnego... Jeśli to trwa zbyt długo, możesz wyłączyć punkty kontrolne w ustawieniach i uruchomić zadanie ponownie.", "menu": { "viewDiff": "Zobacz różnice", "restore": "Przywróć punkt kontrolny", diff --git a/webview-ui/src/i18n/locales/pt-BR/chat.json b/webview-ui/src/i18n/locales/pt-BR/chat.json index ef1c9f701b4..ec444d3b986 100644 --- a/webview-ui/src/i18n/locales/pt-BR/chat.json +++ b/webview-ui/src/i18n/locales/pt-BR/chat.json @@ -94,6 +94,7 @@ "checkpoint": { "initial": "Ponto de verificação inicial", "regular": "Ponto de verificação", + "initializingWarning": "Ainda inicializando ponto de verificação... Se isso demorar muito, você pode desativar os pontos de verificação nas configurações e reiniciar sua tarefa.", "menu": { "viewDiff": "Ver diferenças", "restore": "Restaurar ponto de verificação", diff --git a/webview-ui/src/i18n/locales/tr/chat.json b/webview-ui/src/i18n/locales/tr/chat.json index 43cf456af01..6cd7de384d9 100644 --- a/webview-ui/src/i18n/locales/tr/chat.json +++ b/webview-ui/src/i18n/locales/tr/chat.json @@ -94,6 +94,7 @@ "checkpoint": { "initial": "İlk Kontrol Noktası", "regular": "Kontrol Noktası", + "initializingWarning": "Kontrol noktası hala başlatılıyor... Bu çok uzun sürerse, ayarlar bölümünden kontrol noktalarını devre dışı bırakabilir ve görevinizi yeniden başlatabilirsiniz.", "menu": { "viewDiff": "Farkları Görüntüle", "restore": "Kontrol Noktasını Geri Yükle", diff --git a/webview-ui/src/i18n/locales/vi/chat.json b/webview-ui/src/i18n/locales/vi/chat.json index 0d893db8f15..0cb305133a0 100644 --- a/webview-ui/src/i18n/locales/vi/chat.json +++ b/webview-ui/src/i18n/locales/vi/chat.json @@ -94,6 +94,7 @@ "checkpoint": { "initial": "Điểm kiểm tra ban đầu", "regular": "Điểm kiểm tra", + "initializingWarning": "Đang khởi tạo điểm kiểm tra... Nếu quá trình này mất quá nhiều thời gian, bạn có thể vô hiệu hóa điểm kiểm tra trong cài đặt và khởi động lại tác vụ của bạn.", "menu": { "viewDiff": "Xem khác biệt", "restore": "Khôi phục điểm kiểm tra", diff --git a/webview-ui/src/i18n/locales/zh-CN/chat.json b/webview-ui/src/i18n/locales/zh-CN/chat.json index 78c1e20781b..7e7ace29ee9 100644 --- a/webview-ui/src/i18n/locales/zh-CN/chat.json +++ b/webview-ui/src/i18n/locales/zh-CN/chat.json @@ -94,6 +94,7 @@ "checkpoint": { "initial": "初始检查点", "regular": "检查点", + "initializingWarning": "正在初始化检查点...如果耗时过长,你可以在设置中禁用检查点并重新启动任务。", "menu": { "viewDiff": "查看差异", "restore": "恢复检查点", diff --git a/webview-ui/src/i18n/locales/zh-TW/chat.json b/webview-ui/src/i18n/locales/zh-TW/chat.json index 5d8d4aef235..b86ea259c4e 100644 --- a/webview-ui/src/i18n/locales/zh-TW/chat.json +++ b/webview-ui/src/i18n/locales/zh-TW/chat.json @@ -94,6 +94,7 @@ "checkpoint": { "initial": "初始檢查點", "regular": "檢查點", + "initializingWarning": "正在初始化檢查點...如果耗時過長,你可以在設定中停用檢查點並重新啟動任務。", "menu": { "viewDiff": "檢視差異", "restore": "還原檢查點",