From db19c2e67ab6983430d46ad44f234c35640bb5b7 Mon Sep 17 00:00:00 2001 From: Tibsfox Date: Mon, 6 Apr 2026 19:33:55 -0700 Subject: [PATCH] fix(gsd): suppress repeated frontmatter YAML parse warnings logWarning fired on every preferences load when YAML was malformed, flooding the TUI. Now warns at most once per session with a suppression notice. Closes #3376 Co-Authored-By: Claude Opus 4.6 (1M context) --- src/resources/extensions/gsd/preferences.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/resources/extensions/gsd/preferences.ts b/src/resources/extensions/gsd/preferences.ts index ffd6b5878..be027f2bf 100644 --- a/src/resources/extensions/gsd/preferences.ts +++ b/src/resources/extensions/gsd/preferences.ts @@ -201,9 +201,10 @@ function loadPreferencesFile(path: string, scope: "global" | "project"): LoadedG let _warnedUnrecognizedFormat = false; -/** @internal Reset the warn-once flag — exported for testing only. */ +/** @internal Reset the warn-once flags — exported for testing only. */ export function _resetParseWarningFlag(): void { _warnedUnrecognizedFormat = false; + _warnedFrontmatterParse = false; } /** @internal Exported for testing only */ @@ -235,6 +236,7 @@ export function parsePreferencesMarkdown(content: string): GSDPreferences | null return null; } +let _warnedFrontmatterParse = false; function parseFrontmatterBlock(frontmatter: string): GSDPreferences { try { const parsed = parseYaml(frontmatter); @@ -243,7 +245,11 @@ function parseFrontmatterBlock(frontmatter: string): GSDPreferences { } return parsed as GSDPreferences; } catch (e) { - logWarning("guided", `YAML parse error in frontmatter block: ${(e as Error).message}`); + // Warn at most once per session to avoid flooding TUI (#3376) + if (!_warnedFrontmatterParse) { + _warnedFrontmatterParse = true; + logWarning("guided", `YAML parse error in preferences frontmatter (suppressing further): ${(e as Error).message}`); + } return {} as GSDPreferences; } }