feat(coding-agent): add warnings.anthropicExtraUsage opt-out

closes #3808
This commit is contained in:
Mario Zechner
2026-04-27 20:35:48 +02:00
parent e4f847ff68
commit aefb0fedfe
5 changed files with 133 additions and 0 deletions

View File

@@ -52,6 +52,10 @@ export interface MarkdownSettings {
codeBlockIndent?: string; // default: " "
}
export interface WarningSettings {
anthropicExtraUsage?: boolean; // default: true
}
export type TransportSetting = Transport;
/**
@@ -104,6 +108,7 @@ export interface Settings {
autocompleteMaxVisible?: number; // Max visible items in autocomplete dropdown (default: 5)
showHardwareCursor?: boolean; // Show terminal cursor while still positioning it for IME
markdown?: MarkdownSettings;
warnings?: WarningSettings;
sessionDir?: string; // Custom session storage directory (same format as --session-dir CLI flag)
}
@@ -1049,4 +1054,14 @@ export class SettingsManager {
getCodeBlockIndent(): string {
return this.settings.markdown?.codeBlockIndent ?? " ";
}
getWarnings(): WarningSettings {
return { ...(this.settings.warnings ?? {}) };
}
setWarnings(warnings: WarningSettings): void {
this.globalSettings.warnings = { ...warnings };
this.markModified("warnings");
this.save();
}
}

View File

@@ -11,6 +11,7 @@ import {
Spacer,
Text,
} from "@mariozechner/pi-tui";
import type { WarningSettings } from "../../../core/settings-manager.js";
import { getSelectListTheme, getSettingsListTheme, theme } from "../theme/theme.js";
import { DynamicBorder } from "./dynamic-border.js";
@@ -53,6 +54,7 @@ export interface SettingsConfig {
quietStartup: boolean;
clearOnShrink: boolean;
showTerminalProgress: boolean;
warnings: WarningSettings;
}
export interface SettingsCallbacks {
@@ -79,12 +81,55 @@ export interface SettingsCallbacks {
onQuietStartupChange: (enabled: boolean) => void;
onClearOnShrinkChange: (enabled: boolean) => void;
onShowTerminalProgressChange: (enabled: boolean) => void;
onWarningsChange: (warnings: WarningSettings) => void;
onCancel: () => void;
}
/**
* A submenu component for selecting from a list of options.
*/
class WarningSettingsSubmenu extends Container {
private settingsList: SettingsList;
private state: WarningSettings;
constructor(warnings: WarningSettings, onChange: (warnings: WarningSettings) => void, onCancel: () => void) {
super();
this.state = { ...warnings };
const items: SettingItem[] = [
{
id: "anthropic-extra-usage",
label: "Anthropic extra usage",
description: "Warn when Anthropic subscription auth may use paid extra usage",
currentValue: (this.state.anthropicExtraUsage ?? true) ? "true" : "false",
values: ["true", "false"],
},
];
this.settingsList = new SettingsList(
items,
Math.min(items.length, 10),
getSettingsListTheme(),
(id, newValue) => {
switch (id) {
case "anthropic-extra-usage":
this.state = { ...this.state, anthropicExtraUsage: newValue === "true" };
onChange({ ...this.state });
break;
}
},
onCancel,
);
this.addChild(this.settingsList);
}
handleInput(data: string): void {
this.settingsList.handleInput(data);
}
}
class SelectSubmenu extends Container {
private selectList: SelectList;
@@ -159,6 +204,7 @@ export class SettingsSelectorComponent extends Container {
super();
const supportsImages = getCapabilities().images;
let currentWarnings = { ...config.warnings };
const items: SettingItem[] = [
{
@@ -233,6 +279,21 @@ export class SettingsSelectorComponent extends Container {
currentValue: config.treeFilterMode,
values: ["default", "no-tools", "user-only", "labeled-only", "all"],
},
{
id: "warnings",
label: "Warnings",
description: "Enable or disable individual warnings",
currentValue: "configure",
submenu: (_currentValue, done) =>
new WarningSettingsSubmenu(
currentWarnings,
(warnings) => {
currentWarnings = warnings;
callbacks.onWarningsChange(warnings);
},
() => done(),
),
},
{
id: "thinking",
label: "Thinking level",

View File

@@ -3788,6 +3788,7 @@ export class InteractiveMode {
quietStartup: this.settingsManager.getQuietStartup(),
clearOnShrink: this.settingsManager.getClearOnShrink(),
showTerminalProgress: this.settingsManager.getShowTerminalProgress(),
warnings: this.settingsManager.getWarnings(),
},
{
onAutoCompactChange: (enabled) => {
@@ -3901,6 +3902,9 @@ export class InteractiveMode {
onShowTerminalProgressChange: (enabled) => {
this.settingsManager.setShowTerminalProgress(enabled);
},
onWarningsChange: (warnings) => {
this.settingsManager.setWarnings(warnings);
},
onCancel: () => {
done();
this.ui.requestRender();
@@ -3963,6 +3967,9 @@ export class InteractiveMode {
private async maybeWarnAboutAnthropicSubscriptionAuth(
model: Model<any> | undefined = this.session.model,
): Promise<void> {
if (this.settingsManager.getWarnings().anthropicExtraUsage === false) {
return;
}
if (this.anthropicSubscriptionWarningShown) {
return;
}