FrankenTerm

Pattern Detection

218 words1 min read3 subsectionsFrom the README at ft 0.15.21

On this page3
Pattern IDsAgent pane state detectionRule drift workflow

ft detects state transitions across multiple AI coding agents:

Agent Pattern examples
Codex codex.usage.reached, codex.rate_limit.detected, codex.session.resume_hint
Claude Code claude_code.usage.reached, claude_code.approval_needed, claude_code.session.end
Gemini gemini.usage.reached, gemini.rate_limit.detected
Terminal runtime wezterm.mux.connection_lost, wezterm.pane.exited

Pattern IDs

Every detection has a stable rule_id like codex.usage.reached. Use these in:

  • ft robot events --rule-id <rule_id> to filter detections for a specific condition
  • Workflow triggers that automatically react to patterns
  • Allowlists to suppress false positives
  • ft rules test "text" to validate patterns against sample text

Agent pane state detection

Separately from pattern matching, ft continuously classifies each agent pane into a visual state:

State Color Condition
Active Green Output received within 5 seconds
Thinking Yellow Input sent, no output for 5–30 seconds
Stuck Red No output for 30+ seconds after input, or flagged by watchdog
Idle Gray No input or output for 60+ seconds
Human Default Pane is not agent-controlled

These states drive GUI pane border colors and enable mass operations like "kill all stuck agents."

Rule drift workflow

When agent output patterns change (new versions, updated prompts), follow this fixture-first workflow:

  1. Capture the new output that isn't matching:
    bash
    ft robot get-text <pane_id> --tail 500 > /tmp/new_output.txt
    
  2. Add fixture:
    bash
    cp /tmp/new_output.txt crates/frankenterm-core/tests/corpus/<agent>/<event>.txt
    echo "[]" > crates/frankenterm-core/tests/corpus/<agent>/<event>.expect.json
    
  3. Test and iterate: cargo test corpus_fixtures_match_expected
  4. Update rule: modify anchors/regex in the pack definition until the test passes
  5. Validate: ft robot rules lint --fixtures --strict
  6. Ship: commit the fixture and rule changes together