fix(tui): per-section overrides escape global details_mode: hidden

Copilot review on #14968 caught that the early returns gated on the
global `detailsMode === 'hidden'` short-circuited every render path
before sectionMode() got a chance to apply per-section overrides — so
`details_mode: hidden` + `sections.tools: expanded` was silently a no-op.

Three call sites had the same bug shape; all now key off the resolved
section modes:

- ToolTrail: replace the `detailsMode === 'hidden'` early return with
  an `allHidden = every section resolved to hidden` check.  When that's
  true, fall back to the floating-alert backstop (errors/warnings) so
  quiet-mode users aren't blind to ambient failures, and update the
  comment block to match the actual condition.

- messageLine.tsx: drop the same `detailsMode === 'hidden'` pre-check
  on `msg.kind === 'trail'`; only skip rendering the wrapper when every
  section resolves to hidden (`SECTION_NAMES.some(...) !== 'hidden'`).

- useMainApp.ts: rebuild `showProgressArea` around `anyPanelVisible`
  instead of branching on the global mode.  This also fixes the
  suppressed Copilot concern about an empty wrapper Box rendering above
  the streaming area when ToolTrail returns null.

Regression test in details.test.ts pins the override-escapes-hidden
behaviour for tools/thinking/activity.  271/271 vitest, lints clean.
This commit is contained in:
Brooklyn Nicholson
2026-04-24 02:49:58 -05:00
parent 005cc29e98
commit 70925363b6
6 changed files with 57 additions and 32 deletions

View File

@@ -1,5 +1,5 @@
import { Box, NoSelect, Text } from '@hermes/ink'
import { memo, type ReactNode, useEffect, useMemo, useState } from 'react'
import { memo, useEffect, useMemo, useState, type ReactNode } from 'react'
import spinners, { type BrailleSpinnerName } from 'unicode-animations'
import { THINKING_COT_MAX } from '../config/limits.js'
@@ -874,18 +874,22 @@ export const ToolTrail = memo(function ToolTrail({
const delegateGroups = groups.filter(g => g.label.startsWith('Delegate Task'))
const inlineDelegateKey = hasSubagents && delegateGroups.length === 1 ? delegateGroups[0]!.key : null
// ── Hidden: errors/warnings only ──────────────────────────────
// ── Backstop: floating alerts when every panel is hidden ─────────
//
// When the global details_mode is 'hidden' (or all sections are individually
// hidden), the accordion collapses entirely. Errors/warnings still float
// as inline alerts UNLESS the activity section is explicitly hidden — that
// override means "I don't want to see meta at all", so respect it.
// Per-section overrides win over the global details_mode (they're computed
// by sectionMode), so we only collapse to nothing when EVERY section is
// resolved to hidden — that way `details_mode: hidden` + `sections.tools:
// expanded` still renders the tools panel. When all panels are hidden
// AND ambient errors/warnings exist, surface them as a compact inline
// backstop so quiet-mode users aren't blind to failures.
if (detailsMode === 'hidden') {
if (visible.activity === 'hidden') {
return null
}
const allHidden =
visible.thinking === 'hidden' &&
visible.tools === 'hidden' &&
visible.subagents === 'hidden' &&
visible.activity === 'hidden'
if (allHidden) {
const alerts = activity.filter(i => i.tone !== 'info').slice(-2)
return alerts.length ? (