Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions web/filterAST/components/FilterConditionNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,17 @@ export const FilterConditionNode: React.FC<FilterConditionNodeProps> = ({
})();

// Create updated condition with new field and default operator
const needsKey = filterDef.subType === "property" || filterDef.subType === "score";
const updated: ConditionExpression = {
...condition,
field: {
column: fieldId as any, // Use 'any' to bypass type checking temporarily
column: (filterDef.column ?? fieldId) as any,
subtype: filterDef.subType,
table: filterDef.table,
...(needsKey && { key: fieldId, valueMode: "value" as const }),
},
operator: defaultOperator,
value: defaultValue, // Reset value since field changed
value: defaultValue,
};

filterStore.updateFilterExpression(path, updated);
Expand Down Expand Up @@ -239,8 +241,9 @@ export const FilterConditionNode: React.FC<FilterConditionNodeProps> = ({
filterStore.removeFilterExpression(path);
};

// Find the filter definition for this field
const filterDef = filterDefs.find((def) => def.id === condition.field.column);
// Find the filter definition - use key for properties/scores, column otherwise
const filterDefId = condition.field.key || condition.field.column;
const filterDef = filterDefs.find((def) => def.id === filterDefId);

// Get available operators
const operators = filterDef?.operators || [];
Expand Down Expand Up @@ -410,7 +413,7 @@ export const FilterConditionNode: React.FC<FilterConditionNodeProps> = ({
>
<SearchableSelect
options={fieldOptions}
value={condition.field.column}
value={filterDefId}
onValueChange={handleFieldChange}
placeholder="Select field"
searchPlaceholder="Search field..."
Expand Down
1 change: 1 addition & 0 deletions web/filterAST/filterUIDefinitions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface FilterUIDefinition {
id: string;
label: string;
table: FieldSpec["table"];
column?: string; // The actual DB column. Defaults to id if not set.
type: "string" | "number" | "boolean" | "datetime" | "select" | "searchable";
subType?: "property" | "score" | "sessions" | "user";
operators: FilterOperator[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const useFilterUIDefinitions = () => {
property.property.toLowerCase() as keyof typeof KNOWN_HELICONE_PROPERTIES
].label
: property.property,
column: "properties",
type: "searchable",
operators: ["contains", "not-contains", "eq", "neq", "like", "ilike", "in"],
onSearch: (searchTerm) => {
Expand Down
Loading