Skip to content

Add direct bar quote reaction via keyword matching - #216

Merged
shimpeiws merged 1 commit into
mainfrom
issue-212-add-bar-quote-reaction
Mar 15, 2026
Merged

shimpeiws merged 1 commit into
mainfrom
issue-212-add-bar-quote-reaction

Conversation

@shimpeiws

@shimpeiws shimpeiws commented Mar 15, 2026

Copy link
Copy Markdown
Owner

Summary

Implements issue #212 by adding a keyword-matching path that returns bar text as reactions without going through the LLM. Fires before the LLM call and is gated behind the existing barQuote feature flag (default: OFF).

  • Build inverted index from bars for O(k) keyword lookups
  • Add probability gate (40% skip) and dedup checking
  • Integrate into reaction service before LLM path

Changes

  • src/services/llm/bar-index.ts: New inverted index mapping non-stopword tokens to bars (>100 chars). Threshold: ja=1 match, en=2 matches.
  • src/services/llm/bar-quote.ts: Orchestrates bar quote attempts with probability gate and dedup via isDuplicate().
  • src/services/reaction-service.ts: Added setFeatures() method, bar index build in setVocabulary(), bar quote check before LLM call in generateReaction().
  • src/index.tsx: Pass initial features to reaction service at startup.
  • src/ui/context/ConfigContext.tsx: Propagate feature toggle to reaction service on change.
  • src/services/llm/bar-index.test.ts: 10 tests covering index construction, thresholds, stopword filtering, edge cases.
  • src/services/llm/bar-quote.test.ts: 8 tests covering probability gate, dedup, no-match, boundary cases.

Test plan

  • Feature flag OFF (default): bar quote never fires, LLM path only
  • Feature flag ON via config UI (c -> f -> toggle): bar quotes appear for keyword matches
  • Bar quotes are deduplicated against recent reactions
  • Probability gate prevents bar quotes from being too frequent
  • All existing tests continue to pass

Resolves #212

@shimpeiws shimpeiws changed the title (#212) Add direct bar quote reaction via keyword matching Mar 15, 2026
@shimpeiws
shimpeiws merged commit 64935dc into main Mar 15, 2026
6 checks passed
@shimpeiws
shimpeiws deleted the issue-212-add-bar-quote-reaction branch March 15, 2026 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add direct bar quote reaction via keyword matching (trial feature)

1 participant