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

@@ -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",