{"version":3,"file":"settings-selector.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/settings-selector.ts"],"names":[],"mappings":"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","sourcesContent":["import type { ThinkingLevel } from \"@kolisachint/hoocode-agent-core\";\nimport type { Transport } from \"@kolisachint/hoocode-ai\";\nimport {\n\tContainer,\n\tgetCapabilities,\n\tInput,\n\ttype SelectItem,\n\tSelectList,\n\ttype SelectListLayoutOptions,\n\ttype SettingItem,\n\tSettingsList,\n\tSpacer,\n\tText,\n} from \"@kolisachint/hoocode-tui\";\nimport type { MarketplacePlatform } from \"../../../core/extensions/plugins/formats/types.js\";\nimport type { ExternalToolStatus } from \"../../../core/external-tools.js\";\nimport { buildRowGates, statusLabel } from \"../../../core/external-tools.js\";\nimport type { PromptSurface } from \"../../../core/light.js\";\nimport type { LearnSettingKey, WarningSettings } from \"../../../core/settings-manager.js\";\nimport {\n\tTOOL_OUTPUT_VIEW_DESCRIPTIONS,\n\tTOOL_OUTPUT_VIEWS,\n\ttype ToolOutputView,\n} from \"../../../core/tool-output-view.js\";\nimport { getSelectListTheme, getSettingsListTheme, getThemeDescription, styleInput, theme } from \"../theme/theme.js\";\nimport { InputFrame } from \"./input-frame.js\";\nimport { keyDisplayText } from \"./keybinding-hints.js\";\n\nconst SETTINGS_SUBMENU_SELECT_LIST_LAYOUT: SelectListLayoutOptions = {\n\tminPrimaryColumnWidth: 12,\n\tmaxPrimaryColumnWidth: 32,\n};\n\nconst THINKING_DESCRIPTIONS: Record<ThinkingLevel, string> = {\n\toff: \"No reasoning\",\n\tminimal: \"Very brief reasoning (~1k tokens)\",\n\tlow: \"Light reasoning (~2k tokens)\",\n\tmedium: \"Moderate reasoning (~8k tokens)\",\n\thigh: \"Deep reasoning (~16k tokens)\",\n\txhigh: \"Maximum reasoning (~32k tokens)\",\n};\n\ninterface ToolToggleInfo {\n\t/** Tool name (e.g. \"read\", \"bash\"). */\n\tname: string;\n\t/** Whether the tool is currently enabled (not in the persisted disabled set). */\n\tenabled: boolean;\n\t/**\n\t * What this tool's serialized schema costs on every request. Priced whether or\n\t * not it is on: for a tool that is off, this is what turning it on will cost.\n\t * Undefined for a tool that was disabled before launch, whose schema this\n\t * session never built.\n\t */\n\ttokens?: number;\n}\n\ninterface FlagInfo {\n\t/** Flag name (without the leading --). */\n\tname: string;\n\tdescription?: string;\n\ttype: \"boolean\" | \"string\";\n\t/** Current effective value. */\n\tvalue: boolean | string;\n}\n\ninterface ToolGroupInfo {\n\t/** Group identifier (e.g. \"web\", \"embsearch\"). */\n\tid: string;\n\tlabel: string;\n\tdescription: string;\n\t/** Whether the group is currently enabled (its tools are available). */\n\tenabled: boolean;\n}\n\nexport interface SettingsConfig {\n\tautoCompact: boolean;\n\ttools: ToolToggleInfo[];\n\ttoolGroups: ToolGroupInfo[];\n\t/**\n\t * The external Rust binaries and whether each one is present. Rendered as\n\t * its own top-level category, and used to annotate the rows that are gated\n\t * on a binary that is not installed.\n\t */\n\texternalTools: ExternalToolStatus[];\n\tflags: FlagInfo[];\n\ttoolOutputView: ToolOutputView;\n\ttoolOutputMaxBytes: number;\n\ttoolOutputMaxLines: number;\n\tcontextGc: boolean;\n\tshowImages: boolean;\n\timageWidthCells: number;\n\tautoResizeImages: boolean;\n\tblockImages: boolean;\n\tenableSkillCommands: boolean;\n\tlight: boolean;\n\tpluginInstallScope: \"user\" | \"project\";\n\tenablePluginTools: boolean;\n\t/**\n\t * settings.json keys the project file sets. A pane row writes user scope, so\n\t * anything listed here wins again on the next session however the row is set.\n\t */\n\tprojectPinnedSettings: string[];\n\t/** Platform layouts in force this session (empty = unset, per-consumer defaults apply). */\n\tplatform: MarketplacePlatform[];\n\tsteeringMode: \"all\" | \"one-at-a-time\";\n\tfollowUpMode: \"all\" | \"one-at-a-time\";\n\ttransport: Transport;\n\tthinkingLevel: ThinkingLevel;\n\tavailableThinkingLevels: ThinkingLevel[];\n\tcurrentTheme: string;\n\tavailableThemes: string[];\n\thideThinkingBlock: boolean;\n\tcollapseChangelog: boolean;\n\tenableInstallTelemetry: boolean;\n\tdoubleEscapeAction: \"fork\" | \"tree\" | \"none\";\n\ttreeFilterMode: \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\";\n\tshowHardwareCursor: boolean;\n\teditorBorder: \"rule\" | \"box\";\n\teditorPaddingX: number;\n\tautocompleteMaxVisible: number;\n\tquietStartup: boolean;\n\ttipsEnabled: boolean;\n\tclearOnShrink: boolean;\n\tshowTerminalProgress: boolean;\n\twarnings: WarningSettings;\n\tvoiceSilenceMs: number;\n\twebtoolsTimeoutSecs: number;\n\tlearn: Record<LearnSettingKey, number>;\n\t/**\n\t * Re-measure the fixed per-turn surface (system prompt + active tool schemas).\n\t * Called on open and after every change, so a toggle that costs tokens shows\n\t * what it cost. Omitted by callers that have no session to measure.\n\t */\n\tmeasureTokenSurface?: () => PromptSurface;\n}\n\nexport interface SettingsCallbacks {\n\tonAutoCompactChange: (enabled: boolean) => void;\n\tonToolEnabledChange: (name: string, enabled: boolean) => void;\n\tonToolGroupChange: (id: string, enabled: boolean) => void;\n\tonToolOutputViewChange: (view: ToolOutputView) => void;\n\tonToolOutputMaxBytesChange: (bytes: number) => void;\n\tonToolOutputMaxLinesChange: (lines: number) => void;\n\tonContextGcChange: (enabled: boolean) => void;\n\tonFlagChange: (name: string, value: boolean | string) => void;\n\tonShowImagesChange: (enabled: boolean) => void;\n\tonImageWidthCellsChange: (width: number) => void;\n\tonAutoResizeImagesChange: (enabled: boolean) => void;\n\tonBlockImagesChange: (blocked: boolean) => void;\n\tonEnableSkillCommandsChange: (enabled: boolean) => void;\n\tonLightChange: (enabled: boolean) => void;\n\tonPluginInstallScopeChange: (scope: \"user\" | \"project\") => void;\n\tonEnablePluginToolsChange: (enabled: boolean) => void;\n\tonPlatformChange: (platforms: MarketplacePlatform[]) => void;\n\tonSteeringModeChange: (mode: \"all\" | \"one-at-a-time\") => void;\n\tonFollowUpModeChange: (mode: \"all\" | \"one-at-a-time\") => void;\n\tonTransportChange: (transport: Transport) => void;\n\tonThinkingLevelChange: (level: ThinkingLevel) => void;\n\tonThemeChange: (theme: string) => void;\n\tonThemePreview?: (theme: string) => void;\n\tonHideThinkingBlockChange: (hidden: boolean) => void;\n\tonCollapseChangelogChange: (collapsed: boolean) => void;\n\tonEnableInstallTelemetryChange: (enabled: boolean) => void;\n\tonDoubleEscapeActionChange: (action: \"fork\" | \"tree\" | \"none\") => void;\n\tonTreeFilterModeChange: (mode: \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\") => void;\n\tonShowHardwareCursorChange: (enabled: boolean) => void;\n\tonEditorBorderChange: (border: \"rule\" | \"box\") => void;\n\tonEditorPaddingXChange: (padding: number) => void;\n\tonAutocompleteMaxVisibleChange: (maxVisible: number) => void;\n\tonQuietStartupChange: (enabled: boolean) => void;\n\tonTipsEnabledChange: (enabled: boolean) => void;\n\tonClearOnShrinkChange: (enabled: boolean) => void;\n\tonShowTerminalProgressChange: (enabled: boolean) => void;\n\tonWarningsChange: (warnings: WarningSettings) => void;\n\tonVoiceSilenceMsChange: (ms: number) => void;\n\tonWebtoolsTimeoutSecsChange: (secs: number) => void;\n\tonLearnSettingChange: (key: LearnSettingKey, value: number) => void;\n\tonCancel: () => void;\n}\n\n/**\n * The `/learn` thresholds as pane rows: the presets to cycle through, and what\n * each one buys. Kept as a table because all five are the same shape — a\n * positive integer with a handful of sensible values — and the pane, the change\n * handler and the category row all read from it rather than repeating the list.\n */\nconst LEARN_SETTINGS: ReadonlyArray<{\n\tkey: LearnSettingKey;\n\tlabel: string;\n\tdescription: string;\n\tpresets: number[];\n}> = [\n\t{\n\t\tkey: \"learnMaxSessions\",\n\t\tlabel: \"Sessions scanned\",\n\t\tdescription: \"How many recent sessions in this directory /learn mines. Raise it on a repo you touch rarely.\",\n\t\tpresets: [10, 20, 30, 50, 100],\n\t},\n\t{\n\t\tkey: \"learnMaxAgeDays\",\n\t\tlabel: \"Session age limit\",\n\t\tdescription: \"Ignore sessions older than this many days. A pattern that stopped is not a rule.\",\n\t\tpresets: [7, 14, 30, 60, 90, 180],\n\t},\n\t{\n\t\tkey: \"learnMinRepeats\",\n\t\tlabel: \"Directive repeats\",\n\t\tdescription:\n\t\t\t\"Times a directive must recur before it is proposed. The signal/noise dial: raise it for fewer, better-evidenced proposals.\",\n\t\tpresets: [2, 3, 4, 5],\n\t},\n\t{\n\t\tkey: \"learnMinRequestRepeats\",\n\t\tlabel: \"Workflow repeats\",\n\t\tdescription: \"Non-overlapping repeats a tool sequence needs before it is proposed as a skill.\",\n\t\tpresets: [2, 3, 4, 5, 6],\n\t},\n\t{\n\t\tkey: \"learnMaxProposals\",\n\t\tlabel: \"Max proposals\",\n\t\tdescription: \"Cap on each list in the digest. Every proposal costs the model context.\",\n\t\tpresets: [3, 5, 8, 12, 20],\n\t},\n];\n\nconst LEARN_KEYS: ReadonlySet<string> = new Set(LEARN_SETTINGS.map((setting) => setting.key));\n\n/**\n * Preset list for a numeric row, guaranteed to contain the value in force.\n *\n * Without this a value set by hand in settings.json — say 45 days — is absent\n * from the cycle, so the first keypress silently snaps it to the first preset,\n * discarding a deliberate choice the pane never showed as unusual. Every numeric\n * cycle row goes through this for that reason.\n */\nfunction presetValues(presets: number[], current: number): string[] {\n\tconst all = presets.includes(current) ? presets : [...presets, current].sort((a, b) => a - b);\n\treturn all.map(String);\n}\n\n/**\n * A submenu component for selecting from a list of options.\n */\nclass WarningSettingsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate state: WarningSettings;\n\n\tconstructor(warnings: WarningSettings, onChange: (warnings: WarningSettings) => void, onCancel: () => void) {\n\t\tsuper();\n\n\t\tthis.state = { ...warnings };\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"anthropic-extra-usage\",\n\t\t\t\tlabel: \"Anthropic extra usage\",\n\t\t\t\tdescription: \"Warn when Anthropic subscription auth may use paid extra usage\",\n\t\t\t\tcurrentValue: (this.state.anthropicExtraUsage ?? true) ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"websearch-api-key\",\n\t\t\t\tlabel: \"Web search API key\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Warn when websearch is enabled with no search API key, so it falls back to keyless DuckDuckGo\",\n\t\t\t\tcurrentValue: (this.state.websearchApiKey ?? true) ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t];\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tswitch (id) {\n\t\t\t\t\tcase \"anthropic-extra-usage\":\n\t\t\t\t\t\tthis.state = { ...this.state, anthropicExtraUsage: newValue === \"true\" };\n\t\t\t\t\t\tonChange({ ...this.state });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"websearch-api-key\":\n\t\t\t\t\t\tthis.state = { ...this.state, websearchApiKey: newValue === \"true\" };\n\t\t\t\t\t\tonChange({ ...this.state });\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\tonCancel,\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\n/**\n * The artifact platform targets, in the order the pane shows them. Each row is an\n * independent on/off toggle because `--platform` (and the `platform` setting it\n * mirrors) takes a list: emitting for two platforms at once is a supported shape.\n * The tokens here are the canonical ones — the CLI aliases (`copilot`, `gh`,\n * `native`) fold into these before anything reads them.\n */\nconst PLATFORM_ROWS: ReadonlyArray<{\n\tplatform: MarketplacePlatform;\n\tlabel: string;\n\tdescription: string;\n}> = [\n\t{\n\t\tplatform: \"claude\",\n\t\tlabel: \"claude\",\n\t\tdescription:\n\t\t\t\"Claude Code layout: .claude/ scaffolds, and authored plugins drop into ~/.claude/skills/<id>/. The default when nothing is set.\",\n\t},\n\t{\n\t\tplatform: \"github\",\n\t\tlabel: \"github (copilot, gh)\",\n\t\tdescription:\n\t\t\t\"Copilot layout: .github/ scaffolds, and authored plugins are produced under ~/.agents/publish/github/<id>/.\",\n\t},\n\t{\n\t\tplatform: \"agents\",\n\t\tlabel: \"agents (native)\",\n\t\tdescription:\n\t\t\t\"Cross-vendor .agents/ layout. Scaffolds only - a plugin belongs to no marketplace in this layout, so plugin authoring ignores it.\",\n\t},\n];\n\n/** Row value for the platform setting: the selection, or the fallback when it is empty. */\nfunction platformSummary(platforms: readonly MarketplacePlatform[]): string {\n\treturn platforms.length > 0 ? platforms.join(\", \") : \"default (claude)\";\n}\n\n/**\n * Submenu for the session's artifact platform targets (the `platform` setting,\n * same knob as `--platform`).\n *\n * A list rather than a cycle: the setting is a list, and the three tokens are not\n * mutually exclusive. Turning everything off is legal and means \"unset\" — the\n * per-consumer defaults come back (claude for plugins, .hoocode/ for scaffolds).\n */\nclass PlatformSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate selected: Set<MarketplacePlatform>;\n\n\tconstructor(\n\t\tplatforms: readonly MarketplacePlatform[],\n\t\tonChange: (platforms: MarketplacePlatform[]) => void,\n\t\tonDone: (summary: string) => void,\n\t) {\n\t\tsuper();\n\n\t\tthis.selected = new Set(platforms);\n\n\t\tconst items: SettingItem[] = PLATFORM_ROWS.map(({ platform, label, description }) => ({\n\t\t\tid: platform,\n\t\t\tlabel,\n\t\t\tdescription,\n\t\t\tcurrentValue: this.selected.has(platform) ? \"on\" : \"off\",\n\t\t\tvalues: [\"on\", \"off\"],\n\t\t}));\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tconst platform = id as MarketplacePlatform;\n\t\t\t\tif (newValue === \"on\") this.selected.add(platform);\n\t\t\t\telse this.selected.delete(platform);\n\t\t\t\tonChange(this.ordered());\n\t\t\t},\n\t\t\t() => onDone(platformSummary(this.ordered())),\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\t/** Selection in the pane's order, so the persisted list does not depend on click order. */\n\tprivate ordered(): MarketplacePlatform[] {\n\t\treturn PLATFORM_ROWS.map((row) => row.platform).filter((platform) => this.selected.has(platform));\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\n/**\n * Trailing sentence for a row whose setting is inert until an external binary\n * shows up. The row is annotated rather than hidden: the binaries were invisible\n * precisely because nothing ever mentioned them, and a row that disappears when\n * its dependency is missing teaches the user nothing at all.\n */\nfunction gateNote(gate: ExternalToolStatus | undefined): string {\n\tif (!gate || gate.installed) return \"\";\n\treturn gate.downloadable\n\t\t? ` Needs the ${gate.tool} binary, which hoocode fetches the first time this is used. Until then: ${gate.fallback}`\n\t\t: ` Needs the ${gate.tool} binary, and this environment will not fetch it. Until then: ${gate.fallback}`;\n}\n\n/** \"3 of 5 installed\" - the one number that says whether this category needs attention. */\nfunction externalCount(statuses: readonly ExternalToolStatus[]): string {\n\tconst installed = statuses.filter((status) => status.installed).length;\n\treturn `${installed} of ${statuses.length} installed`;\n}\n\n/** The capability words, so the category row says what the binaries are for. */\nfunction externalSummary(statuses: readonly ExternalToolStatus[]): string {\n\treturn statuses.map((status) => status.tool).join(\", \");\n}\n\n/** Value-column marker for a gated row, so the list shows it without selecting. */\nfunction gateSuffix(gate: ExternalToolStatus | undefined): string | undefined {\n\tif (!gate || gate.installed) return undefined;\n\treturn `needs ${gate.tool}`;\n}\n\n/**\n * Submenu for tool availability. The first rows are group switches (web,\n * semantic search) that decide whether a group's tools\n * exist at all — this is the same master switch that governs, e.g., the\n * webfetch/websearch tools. Below them are per-tool on/off toggles for the\n * tools that are currently available.\n *\n * Group switches change tool availability and apply on the next session;\n * per-tool toggles apply live and persist. A minimum core (read/bash/edit/\n * write) is guarded so the agent can never be left with no way to act.\n */\nclass ToolsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate enabled: Map<string, boolean>;\n\tprivate static readonly CORE = new Set([\"read\", \"bash\", \"edit\", \"write\"]);\n\tprivate static readonly GROUP_PREFIX = \"group:\";\n\n\tconstructor(\n\t\ttools: ToolToggleInfo[],\n\t\tgroups: ToolGroupInfo[],\n\t\t/** Rows gated on an external binary, keyed by row id. See buildRowGates. */\n\t\tgates: ReadonlyMap<string, ExternalToolStatus>,\n\t\tonChange: (name: string, enabled: boolean) => void,\n\t\tonGroupChange: (id: string, enabled: boolean) => void,\n\t\tonCancel: () => void,\n\t) {\n\t\tsuper();\n\n\t\tthis.enabled = new Map(tools.map((t) => [t.name, t.enabled]));\n\n\t\tconst groupItems: SettingItem[] = groups.map((group) => {\n\t\t\tconst id = `${ToolsSubmenu.GROUP_PREFIX}${group.id}`;\n\t\t\tconst gate = gates.get(id);\n\t\t\treturn {\n\t\t\t\tid,\n\t\t\t\tlabel: `[group] ${group.label}`,\n\t\t\t\tdescription: `${group.description} Governs whether these tools exist; applies on the next session.${gateNote(gate)}`,\n\t\t\t\tcurrentValue: group.enabled ? \"on\" : \"off\",\n\t\t\t\t// The switch stays settable with the binary missing: the setting is\n\t\t\t\t// what makes hoocode fetch it, so refusing the toggle would make the\n\t\t\t\t// group unreachable forever.\n\t\t\t\tvalueSuffix: gateSuffix(gate),\n\t\t\t\tvalues: [\"on\", \"off\"],\n\t\t\t};\n\t\t});\n\n\t\tconst toolItems: SettingItem[] = tools.map((tool) => ({\n\t\t\tid: tool.name,\n\t\t\tlabel: tool.name,\n\t\t\tdescription: ToolsSubmenu.CORE.has(tool.name)\n\t\t\t\t? \"Core tool. Disabling leaves the agent unable to perform this action in every session.\"\n\t\t\t\t: \"Disable to remove this tool from the agent this session and every future session.\",\n\t\t\tcurrentValue: tool.enabled ? \"on\" : \"off\",\n\t\t\t// What the schema costs on every request, whether the tool is on or off:\n\t\t\t// off, it is the price of turning it back on. This is the number that\n\t\t\t// makes a tool worth disabling, so it belongs beside the switch.\n\t\t\tvalueSuffix: tool.tokens !== undefined ? `${tokenCount(tool.tokens)} tok/turn` : undefined,\n\t\t\tvalues: [\"on\", \"off\"],\n\t\t}));\n\n\t\tconst items = [...groupItems, ...toolItems];\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 12),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tconst wantEnabled = newValue === \"on\";\n\t\t\t\tif (id.startsWith(ToolsSubmenu.GROUP_PREFIX)) {\n\t\t\t\t\tonGroupChange(id.slice(ToolsSubmenu.GROUP_PREFIX.length), wantEnabled);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Guard: never let the last core tool be turned off.\n\t\t\t\tif (!wantEnabled && ToolsSubmenu.CORE.has(id)) {\n\t\t\t\t\tconst remainingCore = [...ToolsSubmenu.CORE].filter((n) => n !== id && this.enabled.get(n));\n\t\t\t\t\tif (remainingCore.length === 0) {\n\t\t\t\t\t\tthis.settingsList.updateValue(id, \"on\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.enabled.set(id, wantEnabled);\n\t\t\t\tonChange(id, wantEnabled);\n\t\t\t},\n\t\t\tonCancel,\n\t\t\t{ enableSearch: true },\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\n/**\n * Read-only detail for one external binary: what it is, whether it is here, what\n * it turns on, and what hoocode does without it.\n *\n * A submenu rather than a long `description` because the useful answer is five\n * or six lines and the pane shows descriptions on one. Nothing here is settable\n * - the binary is either on the machine or it is not - so the rows carry no\n * `values` and Enter does nothing but close.\n */\nclass ExternalToolDetailSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\n\tconstructor(status: ExternalToolStatus, onCancel: () => void) {\n\t\tsuper();\n\n\t\tconst acquisition =\n\t\t\tstatus.acquisition === \"startup\"\n\t\t\t\t? \"Downloaded in the background at startup.\"\n\t\t\t\t: status.acquisition === \"on-demand\"\n\t\t\t\t\t? \"Downloaded the first time the feature is used.\"\n\t\t\t\t\t: \"Never downloaded automatically; install it yourself.\";\n\n\t\tconst location = status.installed\n\t\t\t? status.source === \"path\"\n\t\t\t\t? `found on PATH as \\`${status.path}\\``\n\t\t\t\t: status.source === \"override\"\n\t\t\t\t\t? `${status.overrideEnv} points at ${status.path}`\n\t\t\t\t\t: `hoocode's own copy at ${status.path}`\n\t\t\t: status.downloadable\n\t\t\t\t? `${acquisition} Not on this machine yet.`\n\t\t\t\t: \"Not installed, and this environment will not download it (offline mode, or no published build for this platform).\";\n\n\t\tconst rows: ReadonlyArray<[label: string, value: string, description: string]> = [\n\t\t\t[\"Status\", statusLabel(status), location],\n\t\t\t[\n\t\t\t\t\"Enables\",\n\t\t\t\t`${status.enables.length} feature${status.enables.length === 1 ? \"\" : \"s\"}`,\n\t\t\t\tstatus.enables.join(\"; \"),\n\t\t\t],\n\t\t\t[\"Without it\", \"fallback\", status.fallback],\n\t\t\t[\"Source\", status.repo || \"-\", `Release archives come from github.com/${status.repo}. ${acquisition}`],\n\t\t\t[\"Env\", String(status.env.length), status.env.join(\"  |  \")],\n\t\t];\n\n\t\tconst items: SettingItem[] = rows.map(([label, value, description], index) => ({\n\t\t\tid: `detail-${index}`,\n\t\t\tlabel,\n\t\t\tcurrentValue: value,\n\t\t\tdescription,\n\t\t}));\n\n\t\tthis.settingsList = new SettingsList(items, items.length, getSettingsListTheme(), () => {}, onCancel);\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\n/**\n * The external-binary category: one row per managed Rust binary.\n *\n * These binaries were entirely invisible before this pane existed. hoocode works\n * without every one of them, which is the whole reason nobody found them: search\n * silently got slower, semantic ranking silently never happened, and web/voice\n * were simply features nobody knew were there. The row states presence; the\n * submenu states what presence buys.\n */\nclass ExternalToolsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\n\tconstructor(statuses: ExternalToolStatus[], onCancel: () => void) {\n\t\tsuper();\n\n\t\tconst items: SettingItem[] = statuses.map((status) => ({\n\t\t\tid: `ext-${status.tool}`,\n\t\t\tlabel: status.label,\n\t\t\tdescription: `${status.summary} Without it: ${status.fallback}`,\n\t\t\tcurrentValue: statusLabel(status),\n\t\t\t// The value column says whether it is here; the suffix says what it is\n\t\t\t// for, so the list reads without opening every row.\n\t\t\tvalueSuffix: status.installed ? undefined : status.downloadable ? \"auto-fetch\" : \"manual\",\n\t\t\tkeywords: [status.tool, status.repo, ...status.settingsKeys, ...status.enables].join(\" \"),\n\t\t\tsubmenu: (_currentValue, done) => new ExternalToolDetailSubmenu(status, () => done()),\n\t\t}));\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\t() => {},\n\t\t\tonCancel,\n\t\t\t{ enableSearch: true },\n\t\t);\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\n/** Byte-cap presets shown as human labels; mapped back to raw byte counts. */\nconst TOOL_OUTPUT_BYTE_PRESETS: ReadonlyArray<[label: string, bytes: number]> = [\n\t[\"8 KB\", 8 * 1024],\n\t[\"16 KB\", 16 * 1024],\n\t[\"32 KB\", 32 * 1024],\n\t[\"64 KB\", 64 * 1024],\n\t[\"128 KB\", 128 * 1024],\n];\n\nfunction bytesToLabel(bytes: number): string {\n\tconst match = TOOL_OUTPUT_BYTE_PRESETS.find(([, b]) => b === bytes);\n\treturn match ? match[0] : `${Math.round(bytes / 1024)} KB`;\n}\n\n/** Byte-cap labels to cycle through, including a hand-set cap that matches no preset. */\nfunction byteLabels(current: number): string[] {\n\tconst all: Array<[string, number]> = TOOL_OUTPUT_BYTE_PRESETS.some(([, bytes]) => bytes === current)\n\t\t? [...TOOL_OUTPUT_BYTE_PRESETS]\n\t\t: [...TOOL_OUTPUT_BYTE_PRESETS, [bytesToLabel(current), current]];\n\treturn all.sort((a, b) => a[1] - b[1]).map(([label]) => label);\n}\n\ninterface ToolSettingsConfig {\n\ttoolOutputView: ToolOutputView;\n\ttoolOutputMaxBytes: number;\n\ttoolOutputMaxLines: number;\n}\n\ninterface ToolSettingsCallbacks {\n\tonToolOutputViewChange: (view: ToolOutputView) => void;\n\tonToolOutputMaxBytesChange: (bytes: number) => void;\n\tonToolOutputMaxLinesChange: (lines: number) => void;\n}\n\n/**\n * Submenu for what a tool result looks like: how much of it is rendered, and\n * where it is truncated. The view applies to the whole transcript at once; the\n * caps feed the tool runtime, so they bind on future tool calls.\n *\n * Context GC is deliberately not here. It is not about a tool's output but about\n * what stays in the outgoing context, which is the Context category's subject.\n */\nclass ToolSettingsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\n\tconstructor(config: ToolSettingsConfig, callbacks: ToolSettingsCallbacks, onCancel: () => void) {\n\t\tsuper();\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"tool-output-view\",\n\t\t\t\tlabel: \"View\",\n\t\t\t\tdescription: `How much of a tool call the transcript shows, least to most. 'radar': ${TOOL_OUTPUT_VIEW_DESCRIPTIONS.radar}. 'peek': ${TOOL_OUTPUT_VIEW_DESCRIPTIONS.peek}. 'full': ${TOOL_OUTPUT_VIEW_DESCRIPTIONS.full}.`,\n\t\t\t\tcurrentValue: config.toolOutputView,\n\t\t\t\tvalues: [...TOOL_OUTPUT_VIEWS],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"output-max-bytes\",\n\t\t\t\tlabel: \"Max bytes\",\n\t\t\t\tdescription: \"Byte cap on a single read/bash result before truncation. Applies to future tool calls.\",\n\t\t\t\tcurrentValue: bytesToLabel(config.toolOutputMaxBytes),\n\t\t\t\tvalues: byteLabels(config.toolOutputMaxBytes),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"output-max-lines\",\n\t\t\t\tlabel: \"Max lines\",\n\t\t\t\tdescription: \"Line cap on a single read/bash result before truncation. Applies to future tool calls.\",\n\t\t\t\tcurrentValue: String(config.toolOutputMaxLines),\n\t\t\t\tvalues: presetValues([200, 400, 800, 1600, 3200], config.toolOutputMaxLines),\n\t\t\t},\n\t\t];\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tswitch (id) {\n\t\t\t\t\tcase \"tool-output-view\":\n\t\t\t\t\t\tcallbacks.onToolOutputViewChange(newValue as ToolOutputView);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"output-max-bytes\": {\n\t\t\t\t\t\tconst preset = TOOL_OUTPUT_BYTE_PRESETS.find(([label]) => label === newValue);\n\t\t\t\t\t\t// A hand-set cap has no preset entry; its label is \"<n> KB\" by\n\t\t\t\t\t\t// construction, so read the number back out of it.\n\t\t\t\t\t\tconst bytes = preset ? preset[1] : Math.round(parseFloat(newValue) * 1024);\n\t\t\t\t\t\tif (Number.isFinite(bytes) && bytes > 0) callbacks.onToolOutputMaxBytesChange(bytes);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"output-max-lines\":\n\t\t\t\t\t\tcallbacks.onToolOutputMaxLinesChange(parseInt(newValue, 10));\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\tonCancel,\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\n/** Single-line text editor for a string flag value. */\nclass FlagStringEditSubmenu extends Container {\n\tprivate input: Input;\n\n\tconstructor(flagName: string, currentValue: string, done: (value?: string) => void) {\n\t\tsuper();\n\n\t\tthis.addChild(new Text(theme.bold(theme.fg(\"accent\", `Flag: --${flagName}`)), 0, 0));\n\t\tthis.addChild(new Text(theme.fg(\"muted\", \"Enter a value · Enter to save · Esc to cancel\"), 0, 0));\n\t\tthis.addChild(new Spacer(1));\n\n\t\tthis.input = new Input();\n\t\tstyleInput(this.input);\n\t\tthis.input.setValue(currentValue);\n\t\tthis.input.onSubmit = (value: string) => done(value);\n\t\tthis.input.onEscape = () => done();\n\t\tthis.addChild(this.input);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.input.handleInput(data);\n\t}\n}\n\n/**\n * Submenu listing extension-registered flags. Boolean flags toggle on/off;\n * string flags open a text editor. Changes persist to settings.json and are\n * applied live best-effort — extensions that read a flag only at load time\n * pick up the new value on the next launch.\n */\nclass FlagsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\n\tconstructor(flags: FlagInfo[], onChange: (name: string, value: boolean | string) => void, onCancel: () => void) {\n\t\tsuper();\n\n\t\tconst items: SettingItem[] = flags.map((flag) => {\n\t\t\tconst baseDescription = flag.description ?? \"Extension-registered flag.\";\n\t\t\tconst description = `${baseDescription} Persists across sessions; some flags need a restart to fully apply.`;\n\t\t\tif (flag.type === \"boolean\") {\n\t\t\t\treturn {\n\t\t\t\t\tid: flag.name,\n\t\t\t\t\tlabel: flag.name,\n\t\t\t\t\tdescription,\n\t\t\t\t\tcurrentValue: flag.value ? \"on\" : \"off\",\n\t\t\t\t\tvalues: [\"on\", \"off\"],\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tid: flag.name,\n\t\t\t\tlabel: flag.name,\n\t\t\t\tdescription,\n\t\t\t\tcurrentValue: String(flag.value ?? \"\"),\n\t\t\t\tsubmenu: (currentValue, done) => new FlagStringEditSubmenu(flag.name, currentValue, done),\n\t\t\t};\n\t\t});\n\n\t\tconst typeByName = new Map(flags.map((f) => [f.name, f.type]));\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 12),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tif (typeByName.get(id) === \"boolean\") {\n\t\t\t\t\tonChange(id, newValue === \"on\");\n\t\t\t\t} else {\n\t\t\t\t\tonChange(id, newValue);\n\t\t\t\t}\n\t\t\t},\n\t\t\tonCancel,\n\t\t\t{ enableSearch: true },\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\n/**\n * Generic submenu holding a subset of leaf settings under a category label.\n * Shares the parent's change handler so cycle rows behave exactly as they did\n * when flat; nested submenu rows (theme, thinking, warnings) keep their own\n * factories.\n */\nclass CategorySubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\n\tconstructor(items: SettingItem[], onChange: (id: string, newValue: string) => void, onCancel: () => void) {\n\t\tsuper();\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\tonChange,\n\t\t\tonCancel,\n\t\t\t{\n\t\t\t\tenableSearch: true,\n\t\t\t},\n\t\t);\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\nclass SelectSubmenu extends Container {\n\tprivate selectList: SelectList;\n\n\tconstructor(\n\t\ttitle: string,\n\t\tdescription: string,\n\t\toptions: SelectItem[],\n\t\tcurrentValue: string,\n\t\tonSelect: (value: string) => void,\n\t\tonCancel: () => void,\n\t\tonSelectionChange?: (value: string) => void,\n\t) {\n\t\tsuper();\n\n\t\t// Title\n\t\tthis.addChild(new Text(theme.bold(theme.fg(\"accent\", title)), 0, 0));\n\n\t\t// Description\n\t\tif (description) {\n\t\t\tthis.addChild(new Text(theme.fg(\"muted\", description), 0, 0));\n\t\t}\n\n\t\t// Spacer\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Select list\n\t\tthis.selectList = new SelectList(\n\t\t\toptions,\n\t\t\tMath.min(options.length, 10),\n\t\t\tgetSelectListTheme(),\n\t\t\tSETTINGS_SUBMENU_SELECT_LIST_LAYOUT,\n\t\t);\n\n\t\t// Pre-select current value\n\t\tconst currentIndex = options.findIndex((o) => o.value === currentValue);\n\t\tif (currentIndex !== -1) {\n\t\t\tthis.selectList.setSelectedIndex(currentIndex);\n\t\t}\n\n\t\tthis.selectList.onSelect = (item) => {\n\t\t\tonSelect(item.value);\n\t\t};\n\n\t\tthis.selectList.onCancel = onCancel;\n\n\t\tif (onSelectionChange) {\n\t\t\tthis.selectList.onSelectionChange = (item) => {\n\t\t\t\tonSelectionChange(item.value);\n\t\t\t};\n\t\t}\n\n\t\tthis.addChild(this.selectList);\n\n\t\t// Hint\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new Text(theme.fg(\"dim\", \"  Enter to select · Esc to go back\"), 0, 0));\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.selectList.handleInput(data);\n\t}\n}\n\n/**\n * Token counts, grouped and exact.\n *\n * `formatTokens` (2.7k) exists for the fixed-width chrome, where a count must\n * never grow the box it sits in. This pane is the opposite case: the point of\n * showing a number here is to compare it with another one, and \"2.7k\" hides the\n * difference between the tool that costs 2,710 and the one that costs 2,749.\n */\nfunction tokenCount(tokens: number): string {\n\treturn tokens.toString().replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\");\n}\n\n/**\n * The fixed per-turn cost, as one line under the pane.\n *\n * Every byte of system prompt and active tool schema is re-sent on every\n * request, and the pane is where that number is decided - so the pane is where\n * it should be visible. It reports the *live* session: a tool toggle applies at\n * once and moves it, while a setting that only takes effect next session (a tool\n * group, the light preset) leaves it alone until then.\n */\nfunction formatSurfaceLine(surface: PromptSurface): string {\n\tconst tools = `${surface.tools.length} tool${surface.tools.length === 1 ? \"\" : \"s\"}`;\n\treturn (\n\t\t`  Per-turn surface: ${tokenCount(surface.totalTokens)} tokens  ` +\n\t\t`${theme.fg(\"dim\", `(${tokenCount(surface.systemPromptTokens)} system prompt + ${tokenCount(surface.toolSchemaTokens)} schemas, ${tools})`)}`\n\t);\n}\n\n/**\n * Main settings selector component.\n */\nexport class SettingsSelectorComponent extends InputFrame {\n\tprivate settingsList: SettingsList;\n\tprivate surfaceLine?: Text;\n\tprivate measureTokenSurface?: () => PromptSurface;\n\n\tconstructor(config: SettingsConfig, callbacks: SettingsCallbacks) {\n\t\tsuper();\n\n\t\tthis.measureTokenSurface = config.measureTokenSurface;\n\n\t\tconst supportsImages = getCapabilities().images;\n\t\tconst followUpKey = keyDisplayText(\"app.message.followUp\");\n\t\tlet currentWarnings = { ...config.warnings };\n\n\t\t// A row writes the user settings file; a key the project file also sets is\n\t\t// merged over it on the next session, so say so rather than letting the row\n\t\t// look like it took.\n\t\tconst projectPinned = new Set(config.projectPinnedSettings);\n\t\tconst pinnedNote = (key: string): string =>\n\t\t\tprojectPinned.has(key)\n\t\t\t\t? ` This repo's .hoocode/settings.json sets ${key}, which overrides this row from the next session on.`\n\t\t\t\t: \"\";\n\n\t\t// Which rows are gated on an external binary that is not on this machine.\n\t\t// Built once so every row that needs it reads the same answer.\n\t\tconst rowGates = buildRowGates(config.externalTools);\n\n\t\tconst initialSurface = config.measureTokenSurface?.();\n\n\t\tconst toolsOn = config.tools.filter((t) => t.enabled).length;\n\t\tconst toolsOff = config.tools.length - toolsOn;\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"autocompact\",\n\t\t\t\tlabel: \"Auto-compact\",\n\t\t\t\tdescription: \"Automatically compact context when it gets too large\",\n\t\t\t\tcurrentValue: config.autoCompact ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"steering-mode\",\n\t\t\t\tlabel: \"Steering mode\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Enter while streaming queues steering messages. 'one-at-a-time': deliver one, wait for response. 'all': deliver all at once.\",\n\t\t\t\tcurrentValue: config.steeringMode,\n\t\t\t\tvalues: [\"one-at-a-time\", \"all\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"follow-up-mode\",\n\t\t\t\tlabel: \"Follow-up mode\",\n\t\t\t\tdescription: `${followUpKey} queues follow-up messages until agent stops. 'one-at-a-time': deliver one, wait for response. 'all': deliver all at once.`,\n\t\t\t\tcurrentValue: config.followUpMode,\n\t\t\t\tvalues: [\"one-at-a-time\", \"all\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"transport\",\n\t\t\t\tlabel: \"Transport\",\n\t\t\t\tdescription: \"Preferred transport for providers that support multiple transports\",\n\t\t\t\tcurrentValue: config.transport,\n\t\t\t\tvalues: [\"sse\", \"websocket\", \"websocket-cached\", \"auto\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"hide-thinking\",\n\t\t\t\tlabel: \"Hide thinking\",\n\t\t\t\tdescription: \"Hide thinking blocks in assistant responses\",\n\t\t\t\tcurrentValue: config.hideThinkingBlock ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"collapse-changelog\",\n\t\t\t\tlabel: \"Collapse changelog\",\n\t\t\t\tdescription: \"Show condensed changelog after updates\",\n\t\t\t\tcurrentValue: config.collapseChangelog ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"quiet-startup\",\n\t\t\t\tlabel: \"Quiet startup\",\n\t\t\t\tdescription: \"Disable verbose printing at startup\",\n\t\t\t\tcurrentValue: config.quietStartup ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"tips\",\n\t\t\t\tlabel: \"Tips\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Show an occasional tip on the band above the prompt while idle or streaming. Never interrupts, never repeats until it has run out of things to say.\",\n\t\t\t\tcurrentValue: config.tipsEnabled ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"install-telemetry\",\n\t\t\t\tlabel: \"Install telemetry\",\n\t\t\t\tdescription: \"Send an anonymous version/update ping after changelog-detected updates\",\n\t\t\t\tcurrentValue: config.enableInstallTelemetry ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"double-escape-action\",\n\t\t\t\tlabel: \"Double-escape action\",\n\t\t\t\tdescription: \"Action when pressing Escape twice with empty editor\",\n\t\t\t\tcurrentValue: config.doubleEscapeAction,\n\t\t\t\tvalues: [\"tree\", \"fork\", \"none\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"tree-filter-mode\",\n\t\t\t\tlabel: \"Tree filter mode\",\n\t\t\t\tdescription: \"Default filter when opening /tree\",\n\t\t\t\tcurrentValue: config.treeFilterMode,\n\t\t\t\tvalues: [\"default\", \"no-tools\", \"user-only\", \"labeled-only\", \"all\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"warnings\",\n\t\t\t\tlabel: \"Warnings\",\n\t\t\t\tdescription: \"Enable or disable individual warnings\",\n\t\t\t\tcurrentValue: \"configure\",\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew WarningSettingsSubmenu(\n\t\t\t\t\t\tcurrentWarnings,\n\t\t\t\t\t\t(warnings) => {\n\t\t\t\t\t\t\tcurrentWarnings = warnings;\n\t\t\t\t\t\t\tcallbacks.onWarningsChange(warnings);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => done(),\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"thinking\",\n\t\t\t\tlabel: \"Thinking level\",\n\t\t\t\tdescription: \"Reasoning depth for thinking-capable models\",\n\t\t\t\tcurrentValue: config.thinkingLevel,\n\t\t\t\tsubmenu: (currentValue, done) =>\n\t\t\t\t\tnew SelectSubmenu(\n\t\t\t\t\t\t\"Thinking Level\",\n\t\t\t\t\t\t\"Select reasoning depth for thinking-capable models\",\n\t\t\t\t\t\tconfig.availableThinkingLevels.map((level) => ({\n\t\t\t\t\t\t\tvalue: level,\n\t\t\t\t\t\t\tlabel: level,\n\t\t\t\t\t\t\tdescription: THINKING_DESCRIPTIONS[level],\n\t\t\t\t\t\t})),\n\t\t\t\t\t\tcurrentValue,\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tcallbacks.onThinkingLevelChange(value as ThinkingLevel);\n\t\t\t\t\t\t\tdone(value);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => done(),\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"theme\",\n\t\t\t\tlabel: \"Theme\",\n\t\t\t\tdescription: \"Color theme for the interface\",\n\t\t\t\tcurrentValue: config.currentTheme,\n\t\t\t\tsubmenu: (currentValue, done) =>\n\t\t\t\t\tnew SelectSubmenu(\n\t\t\t\t\t\t\"Theme\",\n\t\t\t\t\t\t\"Select color theme\",\n\t\t\t\t\t\tconfig.availableThemes.map((t) => ({\n\t\t\t\t\t\t\tvalue: t,\n\t\t\t\t\t\t\tlabel: t,\n\t\t\t\t\t\t\tdescription: getThemeDescription(t),\n\t\t\t\t\t\t})),\n\t\t\t\t\t\tcurrentValue,\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tcallbacks.onThemeChange(value);\n\t\t\t\t\t\t\tdone(value);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t// Restore original theme on cancel\n\t\t\t\t\t\t\tcallbacks.onThemePreview?.(currentValue);\n\t\t\t\t\t\t\tdone();\n\t\t\t\t\t\t},\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\t// Preview theme on selection change\n\t\t\t\t\t\t\tcallbacks.onThemePreview?.(value);\n\t\t\t\t\t\t},\n\t\t\t\t\t),\n\t\t\t},\n\t\t];\n\n\t\t// Only show image toggle if terminal supports it\n\t\tif (supportsImages) {\n\t\t\t// Insert after autocompact\n\t\t\titems.splice(1, 0, {\n\t\t\t\tid: \"show-images\",\n\t\t\t\tlabel: \"Show images\",\n\t\t\t\tdescription: \"Render images inline in terminal\",\n\t\t\t\tcurrentValue: config.showImages ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t});\n\t\t\titems.splice(2, 0, {\n\t\t\t\tid: \"image-width-cells\",\n\t\t\t\tlabel: \"Image width\",\n\t\t\t\tdescription: \"Preferred inline image width in terminal cells\",\n\t\t\t\tcurrentValue: String(config.imageWidthCells),\n\t\t\t\tvalues: presetValues([60, 80, 120], config.imageWidthCells),\n\t\t\t});\n\t\t}\n\n\t\t// Image auto-resize toggle (always available, affects both attached and read images)\n\t\titems.splice(supportsImages ? 3 : 1, 0, {\n\t\t\tid: \"auto-resize-images\",\n\t\t\tlabel: \"Auto-resize images\",\n\t\t\tdescription: \"Resize large images to 2000x2000 max for better model compatibility\",\n\t\t\tcurrentValue: config.autoResizeImages ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Block images toggle (always available, insert after auto-resize-images)\n\t\tconst autoResizeIndex = items.findIndex((item) => item.id === \"auto-resize-images\");\n\t\titems.splice(autoResizeIndex + 1, 0, {\n\t\t\tid: \"block-images\",\n\t\t\tlabel: \"Block images\",\n\t\t\tdescription: \"Prevent images from being sent to LLM providers\",\n\t\t\tcurrentValue: config.blockImages ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Context GC (insert after block-images), a leaf the Context category picks up.\n\t\titems.splice(items.findIndex((item) => item.id === \"block-images\") + 1, 0, {\n\t\t\tid: \"context-gc\",\n\t\t\tlabel: \"Context GC\",\n\t\t\tdescription: \"Stub superseded read results (files later edited or re-read) out of the outgoing context.\",\n\t\t\tcurrentValue: config.contextGc ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// The light preset (insert after context GC). Read at startup to pick the\n\t\t// tool set and the system prompt, so it lands on the next session.\n\t\tconst blockImagesIdx = items.findIndex((item) => item.id === \"context-gc\");\n\t\titems.splice(blockImagesIdx + 1, 0, {\n\t\t\tid: \"light\",\n\t\t\tlabel: \"Light preset\",\n\t\t\tdescription:\n\t\t\t\t\"Low-token preset for small or local models: read/write/edit/bash only with stripped schemas, a terse system prompt, and no subagents/TodoWrite/skills/context files. Applies on the next session.\",\n\t\t\tcurrentValue: config.light ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Skill commands toggle (insert after the light preset)\n\t\tconst blockImagesIndex = items.findIndex((item) => item.id === \"light\");\n\t\titems.splice(blockImagesIndex + 1, 0, {\n\t\t\tid: \"skill-commands\",\n\t\t\tlabel: \"Skill commands\",\n\t\t\tdescription: \"Register skills as /skill:name commands\",\n\t\t\tcurrentValue: config.enableSkillCommands ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// The autonomous plugin system's master switch (insert after skill-commands).\n\t\t// One flag for the lifecycle tools and the reuse nudge, so both flip together.\n\t\tconst skillCommandsIdx = items.findIndex((item) => item.id === \"skill-commands\");\n\t\titems.splice(skillCommandsIdx + 1, 0, {\n\t\t\tid: \"plugin-tools\",\n\t\t\tlabel: \"Plugin system\",\n\t\t\tdescription: `Autonomous plugin system: the lifecycle tools (SearchPlugins, InstallPlugin, ...), ProposePlugin, and the plugin-reuse nudge. Tools arrive on the next session; the nudge follows at once.${pinnedNote(\"enablePluginTools\")}`,\n\t\t\tcurrentValue: config.enablePluginTools ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Plugin install scope (insert after the master switch). Governs the\n\t\t// autonomous InstallPlugin only — /plugin install asks per install.\n\t\tconst pluginToolsIdx = items.findIndex((item) => item.id === \"plugin-tools\");\n\t\titems.splice(pluginToolsIdx + 1, 0, {\n\t\t\tid: \"plugin-install-scope\",\n\t\t\tlabel: \"Plugin install scope\",\n\t\t\tdescription: \"Where autonomous plugin installs go: user (~/.agents) or project (this repo, shared)\",\n\t\t\tcurrentValue: config.pluginInstallScope,\n\t\t\tvalues: [\"user\", \"project\"],\n\t\t});\n\n\t\t// Artifact platform targets (insert after plugin-install-scope). Set once and\n\t\t// it holds for every later session: it is the `platform` setting, which\n\t\t// `--platform` overrides for a single run.\n\t\tconst pluginScopeIdx = items.findIndex((item) => item.id === \"plugin-install-scope\");\n\t\tlet currentPlatforms = [...config.platform];\n\t\titems.splice(pluginScopeIdx + 1, 0, {\n\t\t\tid: \"platform\",\n\t\t\tlabel: \"Platform\",\n\t\t\tdescription: `Vendor layout(s) hoocode writes artifacts in: authored plugins and the /new-skill //new-agent //new-command scaffolds.${pinnedNote(\"platform\")}`,\n\t\t\tcurrentValue: platformSummary(currentPlatforms),\n\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\tnew PlatformSubmenu(\n\t\t\t\t\tcurrentPlatforms,\n\t\t\t\t\t(platforms) => {\n\t\t\t\t\t\tcurrentPlatforms = platforms;\n\t\t\t\t\t\tcallbacks.onPlatformChange(platforms);\n\t\t\t\t\t},\n\t\t\t\t\t(summary) => done(summary),\n\t\t\t\t),\n\t\t});\n\n\t\t// Hardware cursor toggle (insert after the platform row)\n\t\tconst platformIndex = items.findIndex((item) => item.id === \"platform\");\n\t\titems.splice(platformIndex + 1, 0, {\n\t\t\tid: \"show-hardware-cursor\",\n\t\t\tlabel: \"Show hardware cursor\",\n\t\t\tdescription: \"Show the terminal cursor while still positioning it for IME support\",\n\t\t\tcurrentValue: config.showHardwareCursor ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Editor border toggle (insert after show-hardware-cursor)\n\t\tconst hardwareCursorIndex = items.findIndex((item) => item.id === \"show-hardware-cursor\");\n\t\titems.splice(hardwareCursorIndex + 1, 0, {\n\t\t\tid: \"editor-border\",\n\t\t\tlabel: \"Editor border\",\n\t\t\tdescription: \"Box draws side borders, rule draws horizontal lines only\",\n\t\t\tcurrentValue: config.editorBorder,\n\t\t\tvalues: [\"box\", \"rule\"],\n\t\t});\n\n\t\t// Editor padding toggle (insert after editor-border)\n\t\tconst editorBorderIndex = items.findIndex((item) => item.id === \"editor-border\");\n\t\titems.splice(editorBorderIndex + 1, 0, {\n\t\t\tid: \"editor-padding\",\n\t\t\tlabel: \"Editor padding\",\n\t\t\tdescription: \"Horizontal padding for input editor (0-3)\",\n\t\t\tcurrentValue: String(config.editorPaddingX),\n\t\t\tvalues: [\"0\", \"1\", \"2\", \"3\"],\n\t\t});\n\n\t\t// Autocomplete max visible toggle (insert after editor-padding)\n\t\tconst editorPaddingIndex = items.findIndex((item) => item.id === \"editor-padding\");\n\t\titems.splice(editorPaddingIndex + 1, 0, {\n\t\t\tid: \"autocomplete-max-visible\",\n\t\t\tlabel: \"Autocomplete max items\",\n\t\t\tdescription: \"Max visible items in autocomplete dropdown (3-20)\",\n\t\t\tcurrentValue: String(config.autocompleteMaxVisible),\n\t\t\tvalues: presetValues([3, 5, 7, 10, 15, 20], config.autocompleteMaxVisible),\n\t\t});\n\n\t\t// Clear on shrink toggle (insert after autocomplete-max-visible)\n\t\tconst autocompleteIndex = items.findIndex((item) => item.id === \"autocomplete-max-visible\");\n\t\titems.splice(autocompleteIndex + 1, 0, {\n\t\t\tid: \"clear-on-shrink\",\n\t\t\tlabel: \"Clear on shrink\",\n\t\t\tdescription: \"Clear empty rows when content shrinks (may cause flicker)\",\n\t\t\tcurrentValue: config.clearOnShrink ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Terminal progress toggle (insert after clear-on-shrink)\n\t\tconst clearOnShrinkIndex = items.findIndex((item) => item.id === \"clear-on-shrink\");\n\t\titems.splice(clearOnShrinkIndex + 1, 0, {\n\t\t\tid: \"terminal-progress\",\n\t\t\tlabel: \"Terminal progress\",\n\t\t\tdescription: \"Show OSC 9;4 progress indicators in the terminal tab bar\",\n\t\t\tcurrentValue: config.showTerminalProgress ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Voice silence window (insert after terminal-progress)\n\t\tconst terminalProgressIndex = items.findIndex((item) => item.id === \"terminal-progress\");\n\t\titems.splice(terminalProgressIndex + 1, 0, {\n\t\t\tid: \"voice-silence-ms\",\n\t\t\tlabel: \"Voice silence window\",\n\t\t\tdescription: `Trailing-silence (ms) before voice capture auto-stops (300-10000). Env: VOICETOOLS_SILENCE_MS.${gateNote(rowGates.get(\"voice-silence-ms\"))}`,\n\t\t\tcurrentValue: String(config.voiceSilenceMs),\n\t\t\tvalueSuffix: gateSuffix(rowGates.get(\"voice-silence-ms\")),\n\t\t\tvalues: presetValues([300, 500, 800, 1200, 2000, 3000, 5000, 8000, 10000], config.voiceSilenceMs),\n\t\t});\n\n\t\t// Webtools request timeout (insert after voice-silence-ms)\n\t\tconst voiceSilenceIndex = items.findIndex((item) => item.id === \"voice-silence-ms\");\n\t\titems.splice(voiceSilenceIndex + 1, 0, {\n\t\t\tid: \"webtools-timeout-secs\",\n\t\t\tlabel: \"Web tools timeout\",\n\t\t\tdescription: `Per-request timeout (secs) for webfetch/websearch (1-120). Env: HOOCODE_WEBTOOLS_TIMEOUT.${gateNote(rowGates.get(\"webtools-timeout-secs\"))}`,\n\t\t\tcurrentValue: String(config.webtoolsTimeoutSecs),\n\t\t\tvalueSuffix: gateSuffix(rowGates.get(\"webtools-timeout-secs\")),\n\t\t\tvalues: presetValues([5, 10, 15, 30, 60, 120], config.webtoolsTimeoutSecs),\n\t\t});\n\n\t\t// The /learn thresholds, appended as leaf rows and gathered into their own\n\t\t// category below. They are written to the user settings.json, which /learn\n\t\t// re-reads on every invocation, so a change here applies to the next run.\n\t\tconst webtoolsIndex = items.findIndex((item) => item.id === \"webtools-timeout-secs\");\n\t\titems.splice(\n\t\t\twebtoolsIndex + 1,\n\t\t\t0,\n\t\t\t...LEARN_SETTINGS.map(({ key, label, description, presets }) => ({\n\t\t\t\tid: key,\n\t\t\t\tlabel,\n\t\t\t\tdescription,\n\t\t\t\tcurrentValue: String(config.learn[key]),\n\t\t\t\tvalues: presetValues(presets, config.learn[key]),\n\t\t\t})),\n\t\t);\n\n\t\t// Keep the tool/flag controls together as one block near the top, inserted\n\t\t// after the image/terminal splices above so they aren't leapfrogged.\n\t\tconst toolFlagGroup: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"tools\",\n\t\t\t\tlabel: \"Tools\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Enable/disable tools and tool groups (web, semantic search), each priced by what its schema costs per turn. Changes persist across sessions.\",\n\t\t\t\tcurrentValue: toolsOff > 0 ? `${toolsOn} on · ${toolsOff} off` : `${toolsOn} on`,\n\t\t\t\tvalueSuffix: initialSurface ? `${tokenCount(initialSurface.toolSchemaTokens)} tok/turn` : undefined,\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew ToolsSubmenu(\n\t\t\t\t\t\tconfig.tools,\n\t\t\t\t\t\tconfig.toolGroups,\n\t\t\t\t\t\trowGates,\n\t\t\t\t\t\t(name, enabled) => {\n\t\t\t\t\t\t\tcallbacks.onToolEnabledChange(name, enabled);\n\t\t\t\t\t\t\t// Applied live by the host, so the surface below is already stale.\n\t\t\t\t\t\t\tthis.refreshTokenSurface();\n\t\t\t\t\t\t},\n\t\t\t\t\t\t(id, enabled) => callbacks.onToolGroupChange(id, enabled),\n\t\t\t\t\t\t() => done(),\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"tool-output\",\n\t\t\t\tlabel: \"Tool output\",\n\t\t\t\tdescription: \"How much of a tool result is rendered, and where it is truncated.\",\n\t\t\t\tcurrentValue: config.toolOutputView,\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew ToolSettingsSubmenu(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttoolOutputView: config.toolOutputView,\n\t\t\t\t\t\t\ttoolOutputMaxBytes: config.toolOutputMaxBytes,\n\t\t\t\t\t\t\ttoolOutputMaxLines: config.toolOutputMaxLines,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tonToolOutputViewChange: callbacks.onToolOutputViewChange,\n\t\t\t\t\t\t\tonToolOutputMaxBytesChange: callbacks.onToolOutputMaxBytesChange,\n\t\t\t\t\t\t\tonToolOutputMaxLinesChange: callbacks.onToolOutputMaxLinesChange,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => done(),\n\t\t\t\t\t),\n\t\t\t},\n\t\t];\n\t\tif (config.flags.length > 0) {\n\t\t\ttoolFlagGroup.push({\n\t\t\t\tid: \"flags\",\n\t\t\t\tlabel: \"Flags\",\n\t\t\t\tdescription: \"Set flags registered by extensions. Changes persist across sessions.\",\n\t\t\t\tcurrentValue: `${config.flags.length} flag${config.flags.length === 1 ? \"\" : \"s\"}`,\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew FlagsSubmenu(\n\t\t\t\t\t\tconfig.flags,\n\t\t\t\t\t\t(name, value) => callbacks.onFlagChange(name, value),\n\t\t\t\t\t\t() => done(),\n\t\t\t\t\t),\n\t\t\t});\n\t\t}\n\t\tthis.setTitle(\"settings\");\n\n\t\t// Shared change handler for every leaf (cycle) setting; used by the\n\t\t// top-level list and each category submenu.\n\t\tconst applyChange = (id: string, newValue: string): void => {\n\t\t\tswitch (id) {\n\t\t\t\tcase \"autocompact\":\n\t\t\t\t\tcallbacks.onAutoCompactChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"show-images\":\n\t\t\t\t\tcallbacks.onShowImagesChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"image-width-cells\":\n\t\t\t\t\tcallbacks.onImageWidthCellsChange(parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"auto-resize-images\":\n\t\t\t\t\tcallbacks.onAutoResizeImagesChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"block-images\":\n\t\t\t\t\tcallbacks.onBlockImagesChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"skill-commands\":\n\t\t\t\t\tcallbacks.onEnableSkillCommandsChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"light\":\n\t\t\t\t\tcallbacks.onLightChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"plugin-tools\":\n\t\t\t\t\tcallbacks.onEnablePluginToolsChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"plugin-install-scope\":\n\t\t\t\t\tcallbacks.onPluginInstallScopeChange(newValue as \"user\" | \"project\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"platform\":\n\t\t\t\t\t// Display only. Each toggle inside the submenu already applied itself;\n\t\t\t\t\t// closing it hands back the summary purely to refresh this row's value.\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"steering-mode\":\n\t\t\t\t\tcallbacks.onSteeringModeChange(newValue as \"all\" | \"one-at-a-time\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"follow-up-mode\":\n\t\t\t\t\tcallbacks.onFollowUpModeChange(newValue as \"all\" | \"one-at-a-time\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"transport\":\n\t\t\t\t\tcallbacks.onTransportChange(newValue as Transport);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"hide-thinking\":\n\t\t\t\t\tcallbacks.onHideThinkingBlockChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"collapse-changelog\":\n\t\t\t\t\tcallbacks.onCollapseChangelogChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"quiet-startup\":\n\t\t\t\t\tcallbacks.onQuietStartupChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tips\":\n\t\t\t\t\tcallbacks.onTipsEnabledChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"install-telemetry\":\n\t\t\t\t\tcallbacks.onEnableInstallTelemetryChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"double-escape-action\":\n\t\t\t\t\tcallbacks.onDoubleEscapeActionChange(newValue as \"fork\" | \"tree\" | \"none\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tree-filter-mode\":\n\t\t\t\t\tcallbacks.onTreeFilterModeChange(\n\t\t\t\t\t\tnewValue as \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\",\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"show-hardware-cursor\":\n\t\t\t\t\tcallbacks.onShowHardwareCursorChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"editor-border\":\n\t\t\t\t\tcallbacks.onEditorBorderChange(newValue as \"rule\" | \"box\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"editor-padding\":\n\t\t\t\t\tcallbacks.onEditorPaddingXChange(parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"autocomplete-max-visible\":\n\t\t\t\t\tcallbacks.onAutocompleteMaxVisibleChange(parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"clear-on-shrink\":\n\t\t\t\t\tcallbacks.onClearOnShrinkChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"terminal-progress\":\n\t\t\t\t\tcallbacks.onShowTerminalProgressChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"voice-silence-ms\":\n\t\t\t\t\tcallbacks.onVoiceSilenceMsChange(parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"webtools-timeout-secs\":\n\t\t\t\t\tcallbacks.onWebtoolsTimeoutSecsChange(parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t// The /learn rows are keyed by their settings.json name, so they need\n\t\t\t\t\t// no case of their own — the id is the key to write.\n\t\t\t\t\tif (LEARN_KEYS.has(id)) callbacks.onLearnSettingChange(id as LearnSettingKey, parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Most rows leave the per-turn surface alone; the ones that do not (a tool\n\t\t\t// toggle, anything that rebuilds the system prompt) move it immediately.\n\t\t\t// Re-measuring after every change is cheaper than knowing which is which.\n\t\t\tthis.refreshTokenSurface();\n\t\t};\n\n\t\t// Partition the flat leaf settings into named category submenus so the\n\t\t// top level stays short. `items` holds autocompact + every leaf setting.\n\t\tconst byId = new Map(items.map((item) => [item.id, item] as const));\n\t\tconst pick = (ids: string[]): SettingItem[] =>\n\t\t\tids.map((id) => byId.get(id)).filter((item): item is SettingItem => item !== undefined);\n\t\tconst categoryRow = (id: string, label: string, description: string, ids: string[]): SettingItem => {\n\t\t\tconst members = pick(ids);\n\t\t\treturn {\n\t\t\t\tid,\n\t\t\t\tlabel,\n\t\t\t\tdescription,\n\t\t\t\tcurrentValue: `${members.length} setting${members.length === 1 ? \"\" : \"s\"}`,\n\t\t\t\t// Categories shortened the top level but also hid every setting from\n\t\t\t\t// its search: searching \"theme\" matched no category label. The member\n\t\t\t\t// labels ride along as search text so the query lands on the category\n\t\t\t\t// that holds the setting.\n\t\t\t\tkeywords: members.map((member) => member.label).join(\" \"),\n\t\t\t\tsubmenu: (_currentValue, done) => new CategorySubmenu(members, applyChange, () => done()),\n\t\t\t};\n\t\t};\n\n\t\tconst topItems: SettingItem[] = [\n\t\t\t...toolFlagGroup,\n\t\t\t// What the model is sent, and how much of it. Auto-compact used to sit\n\t\t\t// alone at the top level and context GC was filed under tool settings,\n\t\t\t// which left the three settings that decide the token budget in three\n\t\t\t// different places - with the light preset in none of them.\n\t\t\tcategoryRow(\n\t\t\t\t\"cat-context\",\n\t\t\t\t\"Context\",\n\t\t\t\t\"What the model is sent and how much of it: compaction, superseded reads, and the low-token preset.\",\n\t\t\t\t[\"autocompact\", \"context-gc\", \"light\"],\n\t\t\t),\n\t\t\tcategoryRow(\n\t\t\t\t\"cat-behavior\",\n\t\t\t\t\"Behavior\",\n\t\t\t\t\"Agent and session behavior: steering, follow-up, thinking, escape, tree filter, transport.\",\n\t\t\t\t[\"steering-mode\", \"follow-up-mode\", \"thinking\", \"double-escape-action\", \"tree-filter-mode\", \"transport\"],\n\t\t\t),\n\t\t\tcategoryRow(\n\t\t\t\t\"cat-interface\",\n\t\t\t\t\"Interface\",\n\t\t\t\t\"Appearance and editor: theme, thinking visibility, cursor, border, padding, autocomplete, terminal.\",\n\t\t\t\t[\n\t\t\t\t\t\"theme\",\n\t\t\t\t\t\"hide-thinking\",\n\t\t\t\t\t\"show-hardware-cursor\",\n\t\t\t\t\t\"editor-border\",\n\t\t\t\t\t\"editor-padding\",\n\t\t\t\t\t\"autocomplete-max-visible\",\n\t\t\t\t\t\"clear-on-shrink\",\n\t\t\t\t\t\"terminal-progress\",\n\t\t\t\t],\n\t\t\t),\n\t\t\t// Artifact production. `plugin-install-scope` had no category and was\n\t\t\t// therefore unreachable from the pane despite having a live callback.\n\t\t\tcategoryRow(\n\t\t\t\t\"cat-plugins\",\n\t\t\t\t\"Plugins\",\n\t\t\t\t\"The autonomous plugin system's master switch, the vendor layout hoocode writes, and where autonomous installs land.\",\n\t\t\t\t[\"plugin-tools\", \"platform\", \"plugin-install-scope\"],\n\t\t\t),\n\t\t\tcategoryRow(\"cat-images\", \"Images\", \"Inline image rendering and resizing.\", [\n\t\t\t\t\"show-images\",\n\t\t\t\t\"image-width-cells\",\n\t\t\t\t\"auto-resize-images\",\n\t\t\t\t\"block-images\",\n\t\t\t]),\n\t\t\t// Top level rather than folded into Advanced: these are the thresholds\n\t\t\t// that decide whether /learn finds anything, and burying them is what\n\t\t\t// made them undiscoverable in the first place.\n\t\t\tcategoryRow(\n\t\t\t\t\"cat-learn\",\n\t\t\t\t\"Learning\",\n\t\t\t\t\"Thresholds /learn mines sessions with: how far back to look, and how often something must repeat.\",\n\t\t\t\tLEARN_SETTINGS.map((setting) => setting.key),\n\t\t\t),\n\t\t\t// The external binaries. Top level, not folded into Advanced: their whole\n\t\t\t// problem was that nothing in the product ever said they existed, and a\n\t\t\t// row two levels down would have been the same silence with extra steps.\n\t\t\t// This is the only category built from live machine state rather than\n\t\t\t// settings, so it is assembled here instead of going through categoryRow.\n\t\t\t{\n\t\t\t\tid: \"cat-external\",\n\t\t\t\tlabel: \"External tools\",\n\t\t\t\tdescription: `Optional Rust binaries that expand what hoocode can do: ${externalSummary(config.externalTools)}. hoocode runs without every one of them - each row says what it adds and what happens without it.`,\n\t\t\t\tcurrentValue: externalCount(config.externalTools),\n\t\t\t\tkeywords: config.externalTools\n\t\t\t\t\t.flatMap((status) => [status.tool, status.label, ...status.settingsKeys])\n\t\t\t\t\t.join(\" \"),\n\t\t\t\tsubmenu: (_currentValue, done) => new ExternalToolsSubmenu(config.externalTools, () => done()),\n\t\t\t},\n\t\t\tcategoryRow(\"cat-advanced\", \"Advanced\", \"Startup, tips, telemetry, skills, warnings, voice, and web tools.\", [\n\t\t\t\t\"quiet-startup\",\n\t\t\t\t\"tips\",\n\t\t\t\t\"collapse-changelog\",\n\t\t\t\t\"install-telemetry\",\n\t\t\t\t\"skill-commands\",\n\t\t\t\t\"warnings\",\n\t\t\t\t\"voice-silence-ms\",\n\t\t\t\t\"webtools-timeout-secs\",\n\t\t\t]),\n\t\t];\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\ttopItems,\n\t\t\tMath.min(topItems.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\tapplyChange,\n\t\t\tcallbacks.onCancel,\n\t\t\t{\n\t\t\t\tenableSearch: true,\n\t\t\t},\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t\tif (initialSurface) {\n\t\t\tthis.surfaceLine = new Text(formatSurfaceLine(initialSurface), 0, 0);\n\t\t\tthis.addChild(this.surfaceLine);\n\t\t}\n\t}\n\n\t/** Re-price the pane after a change that may have altered what each turn sends. */\n\tprivate refreshTokenSurface(): void {\n\t\tif (!this.surfaceLine || !this.measureTokenSurface) return;\n\t\tthis.surfaceLine.setText(formatSurfaceLine(this.measureTokenSurface()));\n\t}\n\n\tgetSettingsList(): SettingsList {\n\t\treturn this.settingsList;\n\t}\n}\n"]}