6.1 KiB
Disable Suggested Rules Setting — Tech Spec
See PRODUCT.md for user-visible behavior.
Context
Rule suggestions are inline chip views shown at the bottom of an AI block after the agent response completes. The feature is gated by FeatureFlag::SuggestedRules.
Relevant files:
app/src/settings/ai.rs—AISettingssettings group; all Active AI toggles (prompt_suggestions_enabled_internal,code_suggestions_enabled_internal, etc.) follow the samedefine_settings_group!+ getter pattern.app/src/ai/blocklist/block.rs (2137–2189)—handle_complete_outputcreatesSuggestionChipViewinstances for each suggested rule. The checkif FeatureFlag::SuggestedRules.is_enabled()guards the entire block.app/src/settings_view/ai_page.rs—AIFactWidgetrenders the Knowledge section. Contains theToggleRulesandToggleWarpDriveContexttoggle rows.
The pattern for an opt-out Active AI setting already exists verbatim for Prompt Suggestions (prompt_suggestions_enabled_internal / is_prompt_suggestions_enabled) and Code Suggestions.
Proposed Changes
1. New setting (app/src/settings/ai.rs)
Add rule_suggestions_enabled_internal: RuleSuggestionsEnabled to the define_settings_group!(AISettings, …) macro:
rule_suggestions_enabled_internal: RuleSuggestionsEnabled {
type: bool,
default: true,
supported_platforms: SupportedPlatforms::ALL,
sync_to_cloud: SyncToCloud::Globally(RespectUserSyncSetting::Yes),
private: false,
toml_path: "agents.warp_agent.active_ai.rule_suggestions_enabled",
description: "Controls whether the agent suggests rules to save after responses.",
feature_flag: FeatureFlag::SuggestedRules,
}
The feature_flag field causes the setting to be excluded from the user-facing JSON schema when SuggestedRules is not enabled for the current build channel.
Add the getter to impl AISettings:
pub fn is_rule_suggestions_enabled(&self, app: &warpui::AppContext) -> bool {
self.is_active_ai_enabled(app) && *self.rule_suggestions_enabled_internal
}
This follows the same pattern as is_prompt_suggestions_enabled and is_code_suggestions_enabled.
2. Enforcement in handle_complete_output (app/src/ai/blocklist/block.rs)
Change the guard from:
if FeatureFlag::SuggestedRules.is_enabled() {
to:
if FeatureFlag::SuggestedRules.is_enabled()
&& AISettings::as_ref(ctx).is_rule_suggestions_enabled(ctx)
{
This is the single chokepoint where SuggestionChipView::new_rule_chip instances are created. No other code path renders rule-suggestion chips.
3. UI toggle in AIFactWidget (app/src/settings_view/ai_page.rs)
- Add
rule_suggestions_toggle: SwitchStateHandletoAIFactWidget. - Add
RuleSuggestionsEnabledto theuse crate::settings::{…}import block. - Add
ToggleRuleSuggestionsvariant toAISettingsPageAction. - Add a handler for
ToggleRuleSuggestionsinhandle_actionthat callssettings.rule_suggestions_enabled_internal.toggle_and_save_value(ctx). - Add a
render_rule_suggestions_togglemethod toAIFactWidgetfollowing the same structure asrender_warp_drive_context_toggle. - In
AIFactWidget::render, callrender_rule_suggestions_toggleconditionally:Insert this between the rules toggle + "Manage rules" button and the Warp Drive context toggle.if FeatureFlag::SuggestedRules.is_enabled() { column.add_child(self.render_rule_suggestions_toggle(view, ai_settings, app)); }
The toggle renders with is_any_ai_enabled as the is_toggleable argument (not is_active_ai_enabled), consistent with other Knowledge-section toggles like ToggleRules.
4. "Don't show again" button (app/src/ai/blocklist/block.rs, app/src/ai/blocklist/block/view_impl/output.rs, app/src/ai/blocklist/block/view_impl.rs)
A second dismiss button is added to the suggestions footer that permanently disables the setting in addition to clearing the chips.
block.rs:
- Add
disable_rule_suggestions_button: ViewHandle<ActionButton>field toAIBlock. - Create the button in
AIBlock::newwith label"Don't show again"and themeSuggestionDismissButtonTheme, dispatchingAIBlockAction::DisableRuleSuggestionson click. - Add
AIBlockAction::DisableRuleSuggestionsvariant. The handler:- Calls
conversation.dismiss_current_suggestions()on the history model (for persistence of the dismissal). - Sets
settings.rule_suggestions_enabled_internaltofalseviaset_value. - Calls
self.suggested_rules.clear()to immediately remove the chip views from the block, ensuring the footer disappears even ifconversation.existing_suggestionshas not yet been populated bymark_request_completed.
- Calls
output.rs (Props and render_suggested_rules_and_prompts_footer):
- Add
disable_rule_suggestions_button: &'a ViewHandle<ActionButton>toProps. - In
render_suggested_rules_and_prompts_footer, build aright_buttonsrow that conditionally prependsdisable_rule_suggestions_button(withmargin_right: 4.0) beforedismiss_suggestion_buttonwhenhas_suggested_rulesis true.
view_impl.rs:
- Pass
disable_rule_suggestions_button: &self.disable_rule_suggestions_buttonwhen constructingoutput::Props.
Testing and Validation
- Behavior 1–2 (toggle placement and default): Open Settings → Knowledge. Confirm the toggle appears under the Rules toggle and is on by default.
- Behavior 3 (on = chips appear): With the toggle on, run an agent interaction that returns rule suggestions. Verify chips appear as before.
- Behavior 4 (off = chips suppressed): Turn the toggle off. Run a new agent interaction. Verify no rule-suggestion chips appear. Existing chips from prior responses in the session remain visible.
- Behavior 5 (independence): Turn Rules off; verify Suggested Rules toggle state is unchanged and vice versa.
- Behavior 8 (greyed out when global AI off): Turn global AI off. Confirm the Suggested Rules toggle is visually disabled and non-interactive.
- Behavior 9 (hidden without feature flag): In a build without
SuggestedRulesenabled, confirm the toggle is absent from the settings UI.