mirror of
https://github.com/garrytan/gstack.git
synced 2026-08-08 07:18:38 +02:00
test(harness): isProseAUQVisible — gate numbered path on tail, not full buffer
The numbered-options branch of isProseAUQVisible deferred to isNumberedOptionListVisible whenever a `❯ 1.` cursor was visible in the full buffer. But the boot trust dialog (`❯ 1. Yes, trust`) lives in scrollback for the entire run, so this gate suppressed prose-numbered detection for any session that had the trust prompt at startup — i.e., every E2E run after the first user-trust acceptance. Fix: check only the last 4KB tail. Native-UI deferral applies when the cursor list is CURRENTLY rendered, not historically present in scrollback. Adds a regression test that puts the trust dialog in early scrollback + 5KB filler + a current prose-AUQ render, asserts true. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
d28db46400
commit
05f480e1a9
@@ -519,10 +519,13 @@ export function isProseAUQVisible(visible: string): boolean {
|
|||||||
}
|
}
|
||||||
if (letteredHits.size >= 2) return true;
|
if (letteredHits.size >= 2) return true;
|
||||||
|
|
||||||
// Pattern 2: 3+ distinct numbered options at line starts, AND no `❯<spaces>1.`
|
// Pattern 2: 3+ distinct numbered options at line starts, AND no
|
||||||
// cursor anywhere in the FULL visible buffer (which would mean
|
// `❯<spaces>1.` cursor IN THE RECENT TAIL (not the full buffer — a
|
||||||
// isNumberedOptionListVisible already covers the case via the native UI).
|
// trust-dialog `❯ 1. Yes` at boot is in scrollback forever and
|
||||||
if (/❯\s*1\./.test(visible)) return false;
|
// would otherwise suppress this path for the rest of the run).
|
||||||
|
// The native-UI deferral only applies when the cursor list is
|
||||||
|
// currently rendered, not historically.
|
||||||
|
if (/❯\s*1\./.test(tail)) return false;
|
||||||
const numberedRe = /(?:^|\n)[ \t❯]*([1-9])\./g;
|
const numberedRe = /(?:^|\n)[ \t❯]*([1-9])\./g;
|
||||||
const numberedHits = new Set<string>();
|
const numberedHits = new Set<string>();
|
||||||
let nm: RegExpExecArray | null;
|
let nm: RegExpExecArray | null;
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ What's the task? A few options:
|
|||||||
expect(isProseAUQVisible(sample)).toBe(true);
|
expect(isProseAUQVisible(sample)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns false when ❯ 1. cursor is present (native UI handled by isNumberedOptionListVisible)', () => {
|
test('returns false when ❯ 1. cursor is present in the recent tail (native UI handled by isNumberedOptionListVisible)', () => {
|
||||||
const sample = `
|
const sample = `
|
||||||
❯ 1. First option
|
❯ 1. First option
|
||||||
2. Second option
|
2. Second option
|
||||||
@@ -235,6 +235,18 @@ What's the task? A few options:
|
|||||||
expect(isProseAUQVisible(sample)).toBe(false);
|
expect(isProseAUQVisible(sample)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('does NOT suppress numbered-prose detection when ❯ 1. is only in early scrollback (trust dialog)', () => {
|
||||||
|
// Boot trust dialog rendered ❯ 1. Yes at startup, then a long body of
|
||||||
|
// model output, then prose-rendered numbered options now. The historic
|
||||||
|
// ❯ 1. is in the full buffer but NOT in the recent tail. Should detect
|
||||||
|
// the prose AUQ.
|
||||||
|
const trustHeader = '❯ 1. Yes, trust\n 2. No\n';
|
||||||
|
const filler = 'x'.repeat(5000); // pushes trust dialog out of last 4KB tail
|
||||||
|
const proseAUQ = `\n 1. Review the docs\n 2. Investigate the code\n 3. Defer to next session\n❯ \n`;
|
||||||
|
const sample = trustHeader + filler + proseAUQ;
|
||||||
|
expect(isProseAUQVisible(sample)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
test('returns false on single lettered option', () => {
|
test('returns false on single lettered option', () => {
|
||||||
const sample = `
|
const sample = `
|
||||||
A) Only one option mentioned in passing.
|
A) Only one option mentioned in passing.
|
||||||
|
|||||||
Reference in New Issue
Block a user