Transient optimization tips #48

Closed
opened 2026-02-15 04:44:38 +03:00 by NiXTheDev · 1 comment
NiXTheDev commented 2026-02-15 04:44:38 +03:00 (Migrated from github.com)

Description

Show optimization tips after substitutions that auto-delete after 10 seconds.

Use Case

Help users write better regex without being intrusive. Tips disappear quickly so they don't clutter the chat.

Implementation Plan

  1. Static analysis rules (no AI)

    • [0-9] → Use \d instead
    • [a-zA-Z0-9_] → Use \w instead
    • (.) capturing group not referenced → Use (?:.) non-capturing
    • [\s\S] → Use . with s flag instead
    • Unnecessary escaping: \. when not needed
    • Greedy quantifier where lazy would suffice: ._ vs ._?
  2. Detection logic

    • Parse pattern after successful execution
    • Check against optimization rules
    • Generate tip if applicable
  3. Transient message

    • Send tip as separate message
    • Schedule delete after 10 seconds using Telegram API
    • If user misses it, they miss it
  4. Tip format

    Tip: [0-9] can be written as \\d (shorter)
    
  5. Rate limiting tips

    • Only show tip if pattern is significantly improvable
    • Max one tip per substitution chain
    • Skip if user recently received same tip

Acceptance Criteria

  • Detects common inefficiencies
  • Messages auto-delete after 10s
  • Static analysis only (no AI)
  • Respects rate limits
  • Tests for detection accuracy

Example

User: s/[0-9]+/X/
Bot: (Result message)
Bot: Tip: [0-9] can be written as \d (deletes in 10s)

Part of Epic #38

## Description Show optimization tips after substitutions that auto-delete after 10 seconds. ## Use Case Help users write better regex without being intrusive. Tips disappear quickly so they don't clutter the chat. ## Implementation Plan 1. **Static analysis rules** (no AI) - [0-9] → Use \\d instead - [a-zA-Z0-9_] → Use \\w instead - (.) capturing group not referenced → Use (?:.) non-capturing - [\s\S] → Use . with s flag instead - Unnecessary escaping: \\. when not needed - Greedy quantifier where lazy would suffice: ._ vs ._? 2. **Detection logic** - Parse pattern after successful execution - Check against optimization rules - Generate tip if applicable 3. **Transient message** - Send tip as separate message - Schedule delete after 10 seconds using Telegram API - If user misses it, they miss it 4. **Tip format** ``` Tip: [0-9] can be written as \\d (shorter) ``` 5. **Rate limiting tips** - Only show tip if pattern is significantly improvable - Max one tip per substitution chain - Skip if user recently received same tip ## Acceptance Criteria - [ ] Detects common inefficiencies - [ ] Messages auto-delete after 10s - [ ] Static analysis only (no AI) - [ ] Respects rate limits - [ ] Tests for detection accuracy ## Example User: s/[0-9]+/X/ Bot: (Result message) Bot: Tip: [0-9] can be written as \\d (deletes in 10s) ## Related Part of Epic #38
NiXTheDev commented 2026-02-17 06:34:10 +03:00 (Migrated from github.com)

Completed as part of #53 (0.1.10 Release). Transient optimization tips feature has been merged.

Completed as part of #53 (0.1.10 Release). Transient optimization tips feature has been merged.
Sign in to join this conversation.
No description provided.