Mikhail Kilin
3234607bcd
feat: add per-account lock file protection via fs2
...
Prevent running multiple tele-tui instances with the same account by
using advisory file locks (flock). Lock is acquired before raw mode so
errors print to normal terminal. Account switching acquires new lock
before releasing old. Also log set_tdlib_parameters errors via tracing
instead of silently discarding them.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-24 14:23:30 +03:00
Mikhail Kilin
8a467b6418
feat: complete Phase 12 — voice playback ticker, cache, config, and UI
...
Add playback position ticker in event loop with 1s UI refresh rate,
integrate VoiceCache for downloaded voice files, add [audio] config
section (cache_size_mb, auto_download_voice), and render progress bar
with waveform visualization in message bubbles.
Fix race conditions in AudioPlayer: add `starting` flag to prevent
false `is_stopped()` during ffplay startup, guard pid cleanup so old
threads don't overwrite newer process pids. Implement `resume_from()`
with ffplay `-ss` for real audio seek on unpause (-1s rewind).
Kill ffplay on app exit via `stop_playback()` in shutdown + Drop impl.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-09 16:37:02 +03:00
Mikhail Kilin
b0f1f9fdc2
feat: implement Phase 11 — inline photo viewing with ratatui-image
...
Add feature-gated (`images`) inline photo support:
- New types: MediaInfo, PhotoInfo, PhotoDownloadState, ImagesConfig
- Media module: ImageCache (LRU filesystem cache), ImageRenderer (terminal protocol detection)
- Photo metadata extraction from TDLib MessagePhoto with download_file() API
- ViewImage command (v/м) to toggle photo expand/collapse in message selection
- Two-pass UI rendering: placeholder lines in message bubbles + StatefulImage overlay
- Collapse all expanded photos on Esc (exit selection mode)
Dependencies: ratatui-image 8.1, image 0.25 (optional, behind `images` feature flag)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-06 21:25:17 +03:00
Mikhail Kilin
bea0bcbed0
feat: implement desktop notifications with comprehensive filtering
...
Implemented Phase 10 (Desktop Notifications) with three stages:
notify-rust integration, smart filtering, and production polish.
Stage 1 - Base Implementation:
- Add NotificationManager module (src/notifications.rs, 350+ lines)
- Integrate notify-rust 4.11 with feature flag "notifications"
- Implement NotificationsConfig in config.toml (enabled, only_mentions, show_preview)
- Add notification_manager field to TdClient
- Create configure_notifications() method for config integration
- Hook into handle_new_message_update() to send notifications
- Send notifications for messages outside current chat
- Format notification body with sender name and message preview
Stage 2 - Smart Filtering:
- Sync muted chats from Telegram (sync_muted_chats method)
- Filter muted chats from notifications automatically
- Add MessageInfo::has_mention() to detect @username mentions
- Implement only_mentions filter (notify only when mentioned)
- Beautify media labels with emojis (📷 📹 🎤 🎨 📎 etc.)
- Support 10+ media types in notification preview
Stage 3 - Production Polish:
- Add graceful error handling (no panics on notification failure)
- Implement comprehensive logging (tracing::debug!/warn!)
- Add timeout_ms configuration (0 = system default)
- Add urgency configuration (low/normal/critical, Linux only)
- Platform-specific #[cfg] for urgency support
- Log all notification skip reasons at debug level
Hotkey Change:
- Move profile view from 'i' to Ctrl+i to avoid conflicts
Technical Details:
- Cross-platform support (macOS, Linux, Windows)
- Feature flag for optional notifications support
- Graceful fallback when notifications unavailable
- LRU-friendly muted chats sync
- Test coverage for all core notification logic
- All 75 tests passing
Files Changed:
- NEW: src/notifications.rs - Complete NotificationManager
- NEW: config.example.toml - Example configuration with notifications
- Modified: Cargo.toml - Add notify-rust 4.11 dependency
- Modified: src/config/mod.rs - Add NotificationsConfig struct
- Modified: src/tdlib/types.rs - Add has_mention() method
- Modified: src/tdlib/client.rs - Add notification integration
- Modified: src/tdlib/update_handlers.rs - Hook notifications
- Modified: src/config/keybindings.rs - Change profile to Ctrl+i
- Modified: tests/* - Add notification config to tests
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-05 01:27:44 +03:00
Mikhail Kilin
3edbaf2c2b
refactor: extract input handlers into separate functions
...
Упрощение функции handle() в main_input.rs путём извлечения
обработчиков режимов в отдельные функции.
Извлечённые функции:
- handle_profile_mode() - режим профиля с модалкой выхода (~114 строк)
- handle_message_search_mode() - поиск по сообщениям (~73 строки)
- handle_pinned_mode() - закреплённые сообщения (~34 строки)
- handle_reaction_picker_mode() - выбор реакции (~79 строк)
- handle_delete_confirmation() - подтверждение удаления (~53 строки)
- handle_forward_mode() - выбор чата для пересылки (~48 строк)
- handle_chat_search_mode() - поиск по чатам (~32 строки)
- handle_escape_key() - обработка Esc (~25 строк)
- handle_message_selection() - выбор сообщения (~85 строк)
Итого извлечено: ~543 строки из основной функции handle()
Результат:
- handle() сократилась с 891 до ~350 строк (на 61%)
- Каждый режим теперь изолирован и легко тестируется
- Улучшена читаемость и maintainability кода
- Все тесты проходят успешно
Также:
- Обновлён tdlib-rs с 1.1 на 1.2.0
2026-02-03 16:32:26 +03:00
Mikhail Kilin
8e48d076de
refactor: implement trait-based DI for TdClient and fix stack overflow
...
Implement complete trait-based dependency injection pattern for TdClient
to enable testing with FakeTdClient mock. Fix critical stack overflow bugs
caused by infinite recursion in trait implementations.
Breaking Changes:
- App is now generic: App<T: TdClientTrait = TdClient>
- All UI and input handlers are generic over TdClientTrait
- TdClient methods now accessed through trait interface
New Files:
- src/tdlib/trait.rs: TdClientTrait definition with 40+ methods
- src/tdlib/client_impl.rs: TdClientTrait impl for TdClient
- tests/helpers/fake_tdclient_impl.rs: TdClientTrait impl for FakeTdClient
Critical Fixes:
- Fix stack overflow in send_message, edit_message, delete_messages
- Fix stack overflow in forward_messages, current_chat_messages
- Fix stack overflow in current_pinned_message
- All methods now call message_manager directly to avoid recursion
Testing:
- FakeTdClient supports configurable auth_state for auth screen tests
- Added pinned message support in FakeTdClient
- All 196+ tests passing (188 tests + 8 benchmarks)
Dependencies:
- Added async-trait = "0.1"
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-02 05:42:19 +03:00
Mikhail Kilin
e690acfb09
test: complete Phase 4 testing - utils tests and performance benchmarks
...
Added 9 new unit tests for utils/formatting.rs functions:
- format_date: 4 tests (today, yesterday, old, epoch)
- format_was_online: 5 tests (just now, minutes/hours/days ago, very old)
Created 3 performance benchmark files using criterion:
- benches/group_messages.rs - message grouping benchmarks
- benches/formatting.rs - timestamp/date formatting benchmarks
- benches/format_markdown.rs - markdown parsing benchmarks
Updated documentation:
- CONTEXT.md: added Phase 4.1 (Utils) and 4.2 (Benchmarks) completion
- Total coverage: 188 tests + 8 benchmarks = 196 tests (100%)
All 565 tests passing with 100% success rate.
2026-02-01 23:04:43 +03:00
Mikhail Kilin
09c5c5674e
feat: add structured logging with tracing (P5.17)
...
CI / Check (pull_request) Has been cancelled
CI / Format (pull_request) Has been cancelled
CI / Clippy (pull_request) Has been cancelled
CI / Build (macos-latest) (pull_request) Has been cancelled
CI / Build (ubuntu-latest) (pull_request) Has been cancelled
CI / Build (windows-latest) (pull_request) Has been cancelled
Replaced eprintln! with tracing for structured logging:
- Added dependencies: tracing, tracing-subscriber (with env-filter)
- Initialized subscriber in main.rs with default warn level
- Replaced all eprintln! calls in src/config.rs with tracing macros:
* warn!() for warnings (4 occurrences)
* error!() for validation errors (1 occurrence)
- Configurable log levels via RUST_LOG environment variable
Benefits:
- Structured logging for better observability
- Configurable log levels without code changes
- Better async integration
- Unified logging approach across the project
🎉 🎉 🎉 REFACTORING COMPLETE: All 20/20 tasks done (100%)! 🎉 🎉 🎉
Priority 5: 3/3 tasks ✅ COMPLETE
Total progress: 20/20 tasks (100%) ✅ COMPLETE
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-01 02:29:08 +03:00
Mikhail Kilin
38e73befc1
fixes
2026-01-31 01:00:43 +03:00
Mikhail Kilin
68a2b7a982
fixes
2026-01-28 11:39:21 +03:00
Mikhail Kilin
051c4a0265
fixes
CI / Check (pull_request) Has been cancelled
CI / Format (pull_request) Has been cancelled
CI / Clippy (pull_request) Has been cancelled
CI / Build (macos-latest) (pull_request) Has been cancelled
CI / Build (ubuntu-latest) (pull_request) Has been cancelled
CI / Build (windows-latest) (pull_request) Has been cancelled
2026-01-28 01:29:03 +03:00
Mikhail Kilin
f291191577
fixes
2026-01-27 23:29:00 +03:00
Mikhail Kilin
356d2d3064
add account profile
2026-01-27 13:41:29 +03:00
Mikhail Kilin
1ef341d907
commit
2026-01-21 21:20:18 +03:00
Mikhail Kilin
b6d9291864
fixes
2026-01-20 01:00:12 +03:00
Mikhail Kilin
d701464fde
init
2026-01-18 11:49:41 +03:00