From 25a512c7e02a5ae9e7cf2fee7acdf236b06a0cbc Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Fri, 14 Aug 2026 21:04:19 -0700 Subject: [PATCH] fix(browse): duplicate config keys read last-wins, matching gstack-config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit readGstackConfigYamlKey took the FIRST match while gstack-config's get takes the LAST — a duplicated pair_agent or telemetry line made the two consent surfaces disagree about what the user chose. --- browse/src/config.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/browse/src/config.ts b/browse/src/config.ts index 09acf0790..0369e9c0a 100644 --- a/browse/src/config.ts +++ b/browse/src/config.ts @@ -180,8 +180,10 @@ export function readGstackConfigYamlKey(key: string): string | null { const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); try { const yaml = fs.readFileSync(path.join(resolveGstackHome(), 'config.yaml'), 'utf-8'); - const m = yaml.match(new RegExp(`^\\s*${escaped}\\s*:\\s*['"]?([^'"#\\n]*?)['"]?\\s*(?:#.*)?$`, 'm')); - return m ? m[1] : null; + // Last match wins: bin/gstack-config's `get` reads duplicates with + // `tail -1`, and both surfaces must agree on the same line. + const all = [...yaml.matchAll(new RegExp(`^\\s*${escaped}\\s*:\\s*['"]?([^'"#\\n]*?)['"]?\\s*(?:#.*)?$`, 'gm'))]; + return all.length > 0 ? all[all.length - 1][1] : null; } catch { return null; }