From 0d968d6ecce2204c5f561daa9011e281fb63bc85 Mon Sep 17 00:00:00 2001 From: ruv Date: Sun, 4 Oct 2026 00:32:26 -0400 Subject: [PATCH] fix(ruflo-console): Dev Tools field entries say which field to fill when empty Co-Authored-By: RuFlo --- plugins/ruflo-console/hooks/devtools.ts | 7 ++++++- plugins/ruflo-console/tests/devtools.spec.ts | 13 ++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/plugins/ruflo-console/hooks/devtools.ts b/plugins/ruflo-console/hooks/devtools.ts index e12ac021ba..672f572e9e 100644 --- a/plugins/ruflo-console/hooks/devtools.ts +++ b/plugins/ruflo-console/hooks/devtools.ts @@ -203,7 +203,10 @@ export function devWhy(entry: DevEntry, fields: DevFields): string { const filled = (except: DevField | null): DevFields => ({ ...fields, ...Object.fromEntries(failing.filter(field => field !== except).map(field => [field, SAMPLE[field]])) }) const broken = entry.args === undefined || entry.args(filled(null)) === null ? undefined : failing.find(field => entry.args?.(filled(field)) === null) - return broken === undefined ? 'nothing to run' : `${broken} field: ${fieldRule(broken)}` + if (broken === undefined) return 'nothing to run' + + // An empty field is the common case: say where to type, not only the rule. + return `${broken} field${fields[broken].trim() === '' ? ' is empty: type it in the field above, then ▶ run' : ''}: ${fieldRule(broken)}` } /** A value each field accepts, to find which field kept an entry from running. */ @@ -228,6 +231,8 @@ export function devPalette(state: State): PaletteEntry[] { run: { kind: 'text', keyword: entry.id, + // Said when nothing builds: the field to fill and its rule, not a generic palette hint. + why: text => devWhy(entry, text.trim() === '' ? fields : { ...fields, [input]: text.trim() }), make: text => { if (text.trim() !== '') fields[input] = text.trim() diff --git a/plugins/ruflo-console/tests/devtools.spec.ts b/plugins/ruflo-console/tests/devtools.spec.ts index a92f0c458c..3c06851e55 100644 --- a/plugins/ruflo-console/tests/devtools.spec.ts +++ b/plugins/ruflo-console/tests/devtools.spec.ts @@ -180,7 +180,7 @@ describe('the Dev Tools catalog', () => { const checkpoint = DEV.find(entry => entry.id === 'dt-cow-checkpoint')! expect(devSpec(checkpoint, fields)).toBeNull() - expect(devWhy(checkpoint, fields)).toMatch(/^path field: /) + expect(devWhy(checkpoint, fields)).toMatch(/^path field( is empty: type it in the field above, then ▶ run)?: /) expect(devSpec(DEV.find(entry => entry.id === 'dt-diff-stats')!, fields)?.args).toEqual(['mcp', 'exec', '-t', 'analyze_diff-stats', '-p', '{"ref":"HEAD"}']) }) }) @@ -274,6 +274,17 @@ describe('headless and the fields', () => { expect(entries.find(entry => entry.id === 'dt-prov-list')?.run).toMatchObject({ kind: 'spec', spec: { args: ['providers', 'list'], isReadOnly: true } }) }) + it('a field entry with nothing to run says which field to fill, not a palette hint', () => { + const entry = devPalette(newState({})).find(candidate => candidate.id === 'dt-brain') + + expect(entry?.run.kind).toBe('text') + if (entry?.run.kind !== 'text') return + expect(entry.run.make('')).toBeNull() + expect(entry.run.why?.('')).toMatch(/^task field is empty: type it in the field above, then ▶ run: what you want to do/) + expect(entry.run.why?.('-x')).toMatch(/^task field: what you want to do/) + expect(entry.run.why?.('review my PR')).toBe('nothing to run') + }) + it('Enter in a field keeps its text and runs its entry, or says the rule; a field with no entry only keeps it', () => { const state = newState({}) const host = { invalidate: vi.fn() } as unknown as Host