fix: Keep agent group label formatting type-safe

The structured Agent fallback formatter used indexed string access to capitalize grouped result labels, which fails under the desktop TypeScript build because the first character may be undefined. Use charAt so the formatter remains equivalent while satisfying noUncheckedIndexedAccess.

Constraint: desktop build runs tsc with strict indexed access checks
Rejected: Non-null assertion on normalized[0] | keeps the fragile indexed access pattern
Confidence: high
Scope-risk: narrow
Directive: Prefer string helpers over indexed access in build-sensitive UI formatting code
Tested: cd desktop && bun run build
Not-tested: Full macOS packaging script after the frontend build failure point
This commit is contained in:
程序员阿江(Relakkes) 2026-05-19 04:10:44 +08:00
parent 3ce7b02fc2
commit c6bc51a9fd

View File

@ -989,7 +989,7 @@ function formatAgentStructuredNestedItem(item: unknown): string {
function formatAgentGroupLabel(label: string): string {
const normalized = label.trim()
if (!normalized) return 'Grouped results'
return normalized.length > 1 ? `${normalized[0].toUpperCase()}${normalized.slice(1)}` : normalized.toUpperCase()
return `${normalized.charAt(0).toUpperCase()}${normalized.slice(1)}`
}
function formatAgentResultLocation(record: Record<string, unknown>): string {