fix(ruflo-console): Dev Tools field entries say which field to fill when empty

Co-Authored-By: RuFlo <ruv@ruv.net>
This commit is contained in:
ruv committed 2026-10-04 00:32:26 -04:00
1 parent d9a6258895
commit 0d968d6ecc
2 files changed
+18 -2

No files matched your search

+6 -1
View File
@@ -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()
+12 -1
View File
@@ -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