Add Boolean param kind that is always present true/false (ticket 018)

MetricPrimitiveKind gains Boolean, serialized as "boolean". A param
declared with kind Boolean skips capture-group validation and, instead
of being omitted when message_match_regex doesn't match, is present on
every log line as true/false based purely on whether the regex matches
(case-insensitively or per the regex's own flags). Params.tsx lets you
pick boolean as a kind and disables the now-unused capture group input.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XFUNZwCvz3kcod3352ZR2o
This commit is contained in:
Hugh Kaznowski
2026-09-05 19:35:02 +01:00
co-authored by Claude Sonnet 5
parent e6e5bc8f50
commit a9855de3ad
6 changed files with 78 additions and 8 deletions
+12 -5
View File
@@ -14,12 +14,15 @@ export function Params({ params, onDeclared }: { params: ParamDeclaration[]; onD
const [submitting, setSubmitting] = useState(false)
const [collapsed, setCollapsed] = useSectionCollapsed('params')
const isBoolean = kind === 'boolean'
async function handleSubmit(e: React.FormEvent) {
e.preventDefault()
setSubmitError(null)
setSubmitting(true)
try {
await declareParam({ name, message_match_regex: regex, capture_group: captureGroup, kind })
// A boolean-kind param never uses a capture group — its value is just whether the regex matched.
await declareParam({ name, message_match_regex: regex, capture_group: isBoolean ? '' : captureGroup, kind })
setName('')
setRegex('')
setCaptureGroup('')
@@ -68,13 +71,16 @@ export function Params({ params, onDeclared }: { params: ParamDeclaration[]; onD
</div>
<div className="flex items-end gap-1">
<div className="min-w-0 flex-1">
<label className="mb-1 block text-xs text-text-subtle">Capture group</label>
<label className="mb-1 block text-xs text-text-subtle">
Capture group{isBoolean && ' (unused for boolean)'}
</label>
<input
className="w-full min-w-0 rounded border border-border-soft bg-surface-1 px-1.5 py-1 text-xs text-text placeholder:text-text-subtle focus:border-border-strong focus:outline-none"
className="w-full min-w-0 rounded border border-border-soft bg-surface-1 px-1.5 py-1 text-xs text-text placeholder:text-text-subtle focus:border-border-strong focus:outline-none disabled:opacity-50"
value={captureGroup}
onChange={(e) => setCaptureGroup(e.target.value)}
placeholder="path"
required
required={!isBoolean}
disabled={isBoolean}
/>
</div>
<select
@@ -86,6 +92,7 @@ export function Params({ params, onDeclared }: { params: ParamDeclaration[]; onD
<option value="number">number</option>
<option value="timestamp">timestamp</option>
<option value="duration">duration</option>
<option value="boolean">boolean</option>
</select>
</div>
{submitError && <div className="rounded border border-danger-border bg-danger-bg/50 px-2 py-1 text-xs text-danger-text">{submitError}</div>}
@@ -108,7 +115,7 @@ export function Params({ params, onDeclared }: { params: ParamDeclaration[]; onD
className="rounded border border-border-soft px-2 py-1 text-xs text-text-secondary"
title={p.message_match_regex}
>
{p.name} ({p.kind}, group {p.capture_group})
{p.name} ({p.kind}{p.kind === 'boolean' ? '' : `, group ${p.capture_group}`})
</span>
))}
</div>
+3 -1
View File
@@ -4,11 +4,13 @@ export type MetricPrimitive =
| { Number: { Int: number } | { Float: number } }
| { Timestamp: number }
| { Duration: number }
| { Boolean: boolean }
export function metricPrimitiveToDisplayString(value: MetricPrimitive): string {
if ('String' in value) return value.String
if ('Timestamp' in value) return String(value.Timestamp)
if ('Duration' in value) return `${value.Duration}ms`
if ('Boolean' in value) return String(value.Boolean)
if ('Int' in value.Number) return String(value.Number.Int)
return String(value.Number.Float)
}
@@ -25,7 +27,7 @@ export interface ParamDeclaration {
name: string
message_match_regex: string
capture_group: string
kind: 'string' | 'number' | 'timestamp' | 'duration'
kind: 'string' | 'number' | 'timestamp' | 'duration' | 'boolean'
}
export interface TimelineBucket {