The small − and + at the right end of each row remove that row or add one below itThe − and + at each row’s end remove or add a row
Rule Editor (Predicate Editor)
/ NSPredicateEditor · NSRuleEditor /
also called predicate editor, smart folder rules, smart mailbox conditions, query builder (web term)
“The rows of dropdowns with a − and + at the end” are a rule editor, AppKit's NSPredicateEditor. You see these rows in Finder's search and Smart Folders, Mail's Smart Mailboxes and Music's Smart Playlists: each row is one condition (what to check, how to compare, a value), − removes the row and + adds one below. A compound row (“All of the following are true”) groups the rows indented under it; in Music, holding Option turns + into a button that starts a group. It is not a stepper, the up and down pair on one number; Mail's Rules window uses the same rows for automations, and the web calls it a query builder.
If you called it…
…you meant Rule Editor (Predicate Editor).
Anatomy — every part, named
- 1Compound row (All / Any of the following)
NSRuleEditor.RowType.compound“All of the following are true” is a compound row: its pop-up switches the rows under it between All, Any and None.
- 3Criteria row (condition)
NSPredicateEditorRowTemplate“Several search criteria in pulldown menus” are criteria rows: each one is a left pop-up for what to check, an operator pop-up such as “contains”, and a value.
- 4Nested rows (indented group)
NSRuleEditor.NestingMode.compound“The rows pushed in under Any of the following” are a nested group: conditions that belong to the compound row above them, shifted right one step.
Prompt — paste into your agent
Add a rule editor, an NSPredicateEditor (an NSRuleEditor subclass; SwiftUI has none, so wrap it in NSViewRepresentable): one row per condition with a left pop-up, an operator pop-up and a value field, and a − and a + at the right end of every row that remove it or add one below. Describe the rows with NSPredicateEditorRowTemplate and read the result from objectValue. Never assemble the rows by hand from loose pop-up buttons.
Debug prompt — when it misbehaves
Paste this, then describe what you’re seeing — it hands your agent the classic failure modes to rule out first.
Debug my rule editor (NSPredicateEditor, NSRuleEditor, NSPredicateEditorRowTemplate). Rule out: a predicate that no row template matches, so the row stays blank and the console logs "unable to find template matching predicate"; no compound row template while the predicate uses AND or OR; a key path that is also a predicate keyword (size), which NSPredicate(format:) uppercases so nothing matches; nestingMode set to .single, which hides the − and + buttons; canRemoveAllRows false, so the last row's − stays dimmed; a rowHeight too small for the pop-ups; an operator or value type that doesn't fit the attribute; a plain NSRuleEditor with no delegate. The symptom:
In code
The exact names this thing goes by in code — each row is one framework’s word for it. Use the row that matches your project (or paste it into your prompt).
| AppKit | NSPredicateEditor | macOS 10.5+; its rows come from an NSPredicate |
| AppKit | NSRuleEditor | the base class; a delegate supplies the rows |
| AppKit | NSPredicateEditorRowTemplate | what one kind of row offers: its pop-ups and its value view |
| AppKit | NSRuleEditor.NestingMode.compound | the default; allows groups inside groups |
| SwiftUI | NSViewRepresentable | no direct SwiftUI equivalent; wrap NSPredicateEditor |
| react-querybuilder | <QueryBuilder> | the web's version, called a query builder |