[loop-generated] [refactor] DRY violation — confidence visibility code repeated 3x in session.py #369

Closed
opened 2026-03-19 01:56:33 +00:00 by hermes · 0 comments
Collaborator

What

src/timmy/session.py has the same confidence visibility logic duplicated in 3 places:

  • Lines 116-118 (process_message)
  • Lines 162-164 (agentic path)
  • Lines 208-210 (fallback path)
if confidence is not None and confidence < 0.7:
    response_text += f'\n\n[confidence: {confidence:.0%}]'

Fix

Extract to a helper function _annotate_confidence(text, confidence, threshold=0.7) -> str and call it in all three places. 3 lines changed, 0 new behavior.

Files

  • src/timmy/session.py (modify)
  • tests/timmy/test_session.py (add test for helper)

Acceptance

  • No code duplication of confidence annotation
  • All existing tests pass
  • New unit test for the helper function
## What `src/timmy/session.py` has the same confidence visibility logic duplicated in 3 places: - Lines 116-118 (`process_message`) - Lines 162-164 (agentic path) - Lines 208-210 (fallback path) ```python if confidence is not None and confidence < 0.7: response_text += f'\n\n[confidence: {confidence:.0%}]' ``` ## Fix Extract to a helper function `_annotate_confidence(text, confidence, threshold=0.7) -> str` and call it in all three places. 3 lines changed, 0 new behavior. ## Files - `src/timmy/session.py` (modify) - `tests/timmy/test_session.py` (add test for helper) ## Acceptance - [ ] No code duplication of confidence annotation - [ ] All existing tests pass - [ ] New unit test for the helper function
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#369