From f34f99a8523f122ec5860e093c392e8ef19e9d3e Mon Sep 17 00:00:00 2001 From: abose Date: Sat, 25 Jul 2026 20:53:16 +0530 Subject: [PATCH] feat(ai): add "Enable AI" command, strings and tour guard Groundwork in the public repo for a user-facing AI kill switch; the preference, command registration and menu wiring live in phoenix-pro, which is where the AI feature itself lives. - new view.enableAI command id, following the existing view.enable* family (view.enableSelectionView, view.enableQuickView) that the View menu already uses for capability toggles - CMD_VIEW_ENABLE_AI label, DESCRIPTION_ENABLE_AI pref description and the confirm-dialog strings for both toggle directions. Disabling AI removes a whole surface of the editor and enabling it starts talking to AI services, so neither direction is a single unconfirmed click. - phoenix-tour skips its AI step outright when the user has turned AI off, instead of reporting "AI sidebar tab missing" telemetry for a tab that is legitimately gone. Checked before the tab lookup so the window between disabling AI and the restart that removes the tab skips the whole step rather than half of it. --- src/command/Commands.js | 3 +++ .../Phoenix/phoenix-tour.js | 20 +++++++++++++++++++ src/nls/root/strings.js | 10 ++++++++++ 3 files changed, 33 insertions(+) diff --git a/src/command/Commands.js b/src/command/Commands.js index caa7c4bd14..e62ff0e073 100644 --- a/src/command/Commands.js +++ b/src/command/Commands.js @@ -303,6 +303,9 @@ define(function (require, exports, module) { /** Opens the terminal panel */ exports.VIEW_TERMINAL = "view.terminal"; // Terminal/main.js _showTerminal() + /** Toggles whether AI features are enabled */ + exports.VIEW_ENABLE_AI = "view.enableAI"; // phoenix-pro aiEnabled.js _handleToggleEnableAI() + /** Toggles line numbers visibility */ exports.TOGGLE_LINE_NUMBERS = "view.toggleLineNumbers"; // EditorOptionHandlers.js _getToggler() diff --git a/src/extensionsIntegrated/Phoenix/phoenix-tour.js b/src/extensionsIntegrated/Phoenix/phoenix-tour.js index 6635a58205..944e224c28 100644 --- a/src/extensionsIntegrated/Phoenix/phoenix-tour.js +++ b/src/extensionsIntegrated/Phoenix/phoenix-tour.js @@ -40,6 +40,7 @@ define(function (require, exports, module) { CommandManager = require("command/CommandManager"), Commands = require("command/Commands"), WorkspaceManager = require("view/WorkspaceManager"), + PreferencesManager = require("preferences/PreferencesManager"), CentralControlBar = require("view/CentralControlBar"); const TOUR_STORAGE_KEY = "phoenixOnboardingTourState"; @@ -89,6 +90,17 @@ define(function (require, exports, module) { const STEP2_PEEK_HOLD_MS = 2000; const SIDEBAR_AI_TAB_ID = "ai"; + /** + * True when the user has deliberately turned AI off (see the `enableAI` + * preference owned by phoenix-pro). The tab is legitimately absent in that + * case, so step 2 skips itself instead of reporting a missing-tab error. + * The pref is undefined in builds without phoenix-pro, hence the explicit + * `=== false` check rather than a falsy test. + */ + function _isAIDisabledByUser() { + return PreferencesManager.get("enableAI") === false; + } + function _markComplete() { _state.version = CURRENT_TOUR_VERSION; _saveState(_state); @@ -391,6 +403,14 @@ define(function (require, exports, module) { _detachStepClickMetric(); _cancelStep2AIPeek(); _ensureSidebarVisible(); + if (_isAIDisabledByUser()) { + // The user turned AI off — there is nothing to introduce, so skip the + // whole step rather than half of it. Checked before the tab lookup so + // this also covers the window between disabling AI and the restart + // that actually removes the tab, where the tab is still in the DOM. + _runStep3(); + return; + } const $tab = $('.sidebar-tab[data-tab-id="ai"]'); if (!$tab.length) { logger.reportError(new Error("phoenix-tour: AI sidebar tab missing at step 2")); diff --git a/src/nls/root/strings.js b/src/nls/root/strings.js index b4bbf0b8de..0a3c898f71 100644 --- a/src/nls/root/strings.js +++ b/src/nls/root/strings.js @@ -1199,6 +1199,7 @@ define({ "CMD_VIEW_TOGGLE_INSPECTION": "Lint Files on Save", "CMD_VIEW_TOGGLE_PROBLEMS": "Problems", "CMD_VIEW_TERMINAL": "Terminal", + "CMD_VIEW_ENABLE_AI": "Enable AI", "CMD_WORKINGSET_SORT_BY_ADDED": "Sort by Added", "CMD_WORKINGSET_SORT_BY_NAME": "Sort by Name", "CMD_WORKINGSET_SORT_BY_TYPE": "Sort by Type", @@ -2019,6 +2020,7 @@ define({ "DESCRIPTION_INDENT_GUIDES_ENABLED": "true to show indent guide lines, else false.", "DESCRIPTION_HIDE_FIRST": "true to show the first Indent Guide line else false.", "DESCRIPTION_CSS_COLOR_PREVIEW": "true to display color previews in the gutter, else false.", + "DESCRIPTION_ENABLE_AI": "true to enable AI features, false to disable AI entirely.", // Emmet "DESCRIPTION_EMMET": "true to enable Emmet, else false.", @@ -2489,6 +2491,14 @@ define({ "AI_UPSELL_DIALOG_TITLE": "Continue with {0}?", "AI_UPSELL_DIALOG_MESSAGE": "You’ve discovered {0}. To proceed, you’ll need an AI subscription or credits.", + // Enable/disable AI toggle + "AI_DISABLE_CONFIRM_TITLE": "Disable AI?", + "AI_DISABLE_CONFIRM_MESSAGE": "This turns off all AI features. The AI panel will be removed and {APP_NAME} will stop connecting to AI services.

Restart {APP_NAME} for this to take effect.", + "AI_DISABLE_CONFIRM_BTN": "Disable AI", + "AI_ENABLE_CONFIRM_TITLE": "Enable AI?", + "AI_ENABLE_CONFIRM_MESSAGE": "This turns AI features back on and restores the AI panel.

Restart {APP_NAME} for this to take effect.", + "AI_ENABLE_CONFIRM_BTN": "Enable AI", + // AI CHAT PANEL "AI_CHAT_TITLE": "Claude Code", "AI_CHAT_SURPRISE_ME_USER_MSG": "Surprise me!",