Commit Graph

14 Commits

Author SHA1 Message Date
MarekWo
e9e04fb22d docs: Add comprehensive API diagnostic commands cheatsheet
Added technotes/API-Diagnostic-Commands.md with:
- Complete curl examples for all API endpoints
- SSH + docker exec one-liners for easy testing
- Organized by category (health, contacts, device, channels, messages, DM, settings, archives)
- Example JSON responses for each endpoint
- Useful one-liners with jq for advanced queries
- Quick troubleshooting section with logs and health checks
- Notes on ports, methods, and response times

This serves as a quick reference for debugging and testing the mc-webui API.
2025-12-29 16:09:00 +01:00
MarekWo
fec851c631 docs: Update documentation for 'Last Seen' feature
Updated documentation to reflect Contact Management v2 enhancements:

README.md:
- Added "Last Seen" feature description in Existing Contacts section
- Documented activity indicators (🟢 active, 🟡 recent, 🔴 inactive,  unknown)
- Explained relative time format ("5 minutes ago", "2 hours ago", etc.)
- Activity thresholds: < 5min active, < 1hr recent, > 1hr inactive

technotes/UI-Contact-Management-MVP-v2-completed.md:
- Added comprehensive "Last Seen Feature Implementation" section
- Documented data source discovery (apply_to contact_info command)
- Explained NDJSON format and parsing challenges
- Detailed debugging journey (3 problems and solutions):
  1. Comma-separated types don't work through bridge
  2. NDJSON format not recognized (prettified multi-line JSON)
  3. Timestamp accuracy question (last_advert vs lastmod)
- Documented brace-matching parser algorithm
- Test results: 263 contacts parsed with timestamps
- Complete commit history (5 commits for Last Seen feature)
- Updated Conclusion section with Last Seen enhancements

Note: .claude/instructions.md was also updated locally but is not tracked in git (in .gitignore)
2025-12-29 15:13:23 +01:00
MarekWo
8b709b9136 feat(ui): Contact Management v2 - existing contacts display and delete
Implements MVP v2 requirements from docs/UI-Contact-Management-MVP-v2.md:
- Display all contact types (CLI, REP, ROOM, SENS)
- Delete contacts with confirmation modal
- Capacity counter with color-coded warnings (green/yellow/red)
- Search by name or public key
- Filter by contact type
- Mobile-first responsive design

Backend changes:
- Add get_all_contacts_detailed() parser for meshcli contacts output
  - Handles Unicode characters, emoji, spaces in names
  - Backward parsing strategy using public_key_prefix as anchor
  - Returns detailed metadata for all contact types
- Add delete_contact() wrapper for remove_contact command
- Add GET /api/contacts/detailed endpoint
- Add POST /api/contacts/delete endpoint

Frontend changes:
- Add Existing Contacts section to contacts.html
  - Real-time search input
  - Type filter dropdown (All/CLI/REP/ROOM/SENS)
  - Color-coded type badges
  - Capacity counter with pulse animation for critical levels
- Add delete confirmation modal with danger styling
- Add complete contact management logic to contacts.js
  - loadExistingContacts(), applyFilters(), confirmDelete()
  - Copy public key to clipboard functionality

Documentation:
- Update README.md with usage instructions
- Add technotes/UI-Contact-Management-MVP-v2-completed.md
- Add docs/UI-Contact-Management-MVP-v2.md (specification)
- Add technotes/UI-Contact-Management-MVP-v1-completed.md (retroactive)

Tested with 263 real contacts including Unicode and edge cases.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-29 11:45:47 +01:00
MarekWo
9967980521 docs(technotes): Document contact type differences in add_pending behavior
Added comprehensive documentation of discovered differences between CLI and ROOM
contact types when using the add_pending command.

Key findings from real-world testing (2025-12-29):

CLI Contacts (flexible matching):
-  Full name works: "StNMobile T1000e"
-  Name prefix works: "StN"
-  Public key prefix works: "2ce5514"
-  Full public key works

ROOM Contacts (strict matching):
-  Full name fails: "TK room cwiczebny🔆" (UTF-8 issues)
-  Name prefix fails: "TK room"
-  Public key prefix fails: "b3fec489"
-  ONLY full public key works

Root cause: meshcli uses different matching logic for different contact types,
likely to prevent accidental approval of group rooms which have different
security/privacy implications.

Recommendation: UI should always send full public_key (not name) when calling
POST /add_pending to ensure compatibility with all contact types.

Updated sections:
- Selector formats with CLI/ROOM compatibility notes
- New "Important Discovery: Contact Type Differences" section
- Updated test commands with real-world results
- JavaScript code examples for UI implementation
- Best practices for UI design

This documentation will guide the next phase: UI implementation for pending
contact management.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-29 08:57:16 +01:00
MarekWo
c0f6fd7dfc feat(bridge): Enable manual_add_contacts mode in session init
Enabled manual contact approval mode in meshcli session initialization.
This requires explicit approval for new contacts attempting to connect,
providing enhanced security and network access control.

Changes:
- Added 'set manual_add_contacts on' to _init_session_settings()
- Updates session init log message to include manual_add_contacts status
- Created comprehensive technical documentation (technotes/pending-contacts-api.md)

Benefits:
- DoS prevention - blocks flooding with fake contact requests
- Network privacy - control who can see your node
- Trust model - explicit approval for all new contacts
- Spam filtering - reject unwanted connection attempts

Technical notes document includes:
- Problem statement and solution overview
- API endpoint specifications and examples
- Testing procedures and expected workflows
- Future UI integration plans
- Security considerations and recommendations
- Meshcli command reference

When manual approval is enabled, new contacts appear in pending list
(accessible via GET /pending_contacts) and must be approved via
POST /add_pending before they can communicate with the node.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-29 08:20:49 +01:00
MarekWo
ff0d52e281 docs: Update documentation for persistent meshcli session architecture
Updated documentation to reflect the fundamental architectural change from
per-request subprocess spawning to a persistent meshcli session in meshcore-bridge.

Changes:
- Updated README.md with detailed bridge session architecture section
- Added TZ environment variable to configuration table
- Created comprehensive technical note (technotes/persistent-meshcli-session.md)
  documenting the refactor, implementation details, and benefits

Key architectural changes documented:
- Single subprocess.Popen with stdin/stdout pipes (not subprocess.run per request)
- Multiplexing: JSON adverts → .adverts.jsonl log, CLI responses → HTTP
- Real-time message reception via msgs_subscribe (no polling required)
- Thread-safe command queue with event-based synchronization
- Watchdog thread for automatic crash recovery
- Timeout-based response detection (300ms idle threshold)

This persistent session enables:
 Real-time message reception without polling
 Network advertisement logging
 Advanced interactive features (manual_add_contacts, etc.)
 Better stability and lower latency

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-28 18:10:32 +01:00
MarekWo
739c10c748 add: meshcore-cli documentation 2025-12-24 11:03:01 +01:00
MarekWo
78c59f6bc7 chore: Remove outdated documentation files for channels, limits, meshcore-cli, and smart refresh feature 2025-12-24 11:02:42 +01:00
MarekWo
76134b133a feat: Implement intelligent refresh and multi-channel notifications
Replaces the blind 60-second refresh with a smart polling system that only updates the UI when new messages actually arrive.

Key improvements:
- Lightweight update checks every 10 seconds (vs full refresh every 60s)
- Chat view refreshes only when new messages appear on active channel
- Notification bell with global unread count across all channels
- Per-channel unread badges in channel selector (e.g., "Malopolska (3)")
- Last-seen timestamp tracking per channel with localStorage persistence
- Bell ring animation when new messages arrive

Backend changes:
- New /api/messages/updates endpoint for efficient update polling
- Returns per-channel update status and unread counts

Frontend changes:
- Smart auto-refresh mechanism with conditional UI updates
- Unread message tracking system with localStorage
- Notification bell UI component with badge
- Channel selector badges for unread messages
- CSS animations for bell ring effect

This dramatically reduces network traffic and server load while providing better UX through instant notifications about activity on other channels.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-23 18:12:53 +01:00
MarekWo
761e4eac25 feat: Implement full channel management functionality
Add comprehensive channel management features to mc-webui:
- Create new channels with auto-generated encryption keys
- Share channels via QR code or copy-to-clipboard
- Join existing channels with name and key
- Switch between channels in chat interface
- Filter messages by channel
- Persistent channel selection (localStorage)

Backend changes:
- Add CLI wrapper functions: get_channels, add_channel, set_channel, remove_channel
- Modify send_message() to support channel targeting
- Parametrize parser channel filtering (channel_idx parameter)
- Add QR code generation with qrcode + Pillow libraries

API endpoints:
- GET /api/channels - List all channels
- POST /api/channels - Create new channel
- POST /api/channels/join - Join existing channel (auto-detect free slot)
- DELETE /api/channels/<index> - Remove channel
- GET /api/channels/<index>/qr - Generate QR code (JSON or PNG)
- Modified GET /api/messages - Add channel_idx filtering
- Modified POST /api/messages - Add channel_idx targeting

Frontend changes:
- Add channel selector dropdown in navbar
- Add Channels Management modal (create, join, list)
- Add Share Channel modal (QR code, copy key)
- Implement JavaScript channel management logic
- Add event handlers for channel switching
- Persist selected channel in localStorage

QR code format:
{"type":"meshcore_channel","name":"...","key":"..."}

Protection:
- Block deletion of Public channel (index 0)
- Validate channel names (alphanumeric, _, - only)
- Validate encryption keys (32 hex chars)
- Auto-detect free channel slots (1-7)

Backward compatibility:
- Default channel_idx=0 (Public) in all functions
- Existing Public-only code continues to work

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-22 19:04:00 +01:00
MarekWo
8d9c2b241c Feature: Add message length limit with live character counter
Implemented 200-character limit for messages due to LoRa/MeshCore constraints:
- Added maxlength=200 to textarea
- Added live character counter (0 / 200)
- Visual warnings: orange at 75%, red at 90%
- Counter updates on input, reply, and send
- Backend validation with descriptive error message
- Added technotes/limity.md documentation about MeshCore limits

Based on MeshCore LoRa payload constraints (~180-200 bytes safe limit).
This prevents message fragmentation and improves transmission reliability.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-21 14:44:41 +01:00
MarekWo
a8393d5815 Refactor: Move Docker files to project root and update documentation
Moved Dockerfile and docker-compose.yml from docker/ to root directory for simpler workflow.
This allows running 'docker compose up' directly without -f flag.

Changes:
- Moved docker/Dockerfile -> Dockerfile
- Moved docker/docker-compose.yml -> docker-compose.yml
- Updated docker-compose.yml context and env_file paths
- Updated README.md with simplified Docker commands
- Updated CLAUDE_CODE_PROMPT.md project structure
- Moved .claude/instructions.md to root (from technotes/)
- Updated all documentation to reflect new structure

Now deployment is simpler:
  docker compose up -d --build

instead of:
  docker compose -f docker/docker-compose.yml up -d --build
2025-12-21 14:24:38 +01:00
MarekWo
6a455cb652 Phase 0: Environment setup - Docker infrastructure and project scaffolding
Created complete project structure for mc-webui MVP:
- Docker configuration (Dockerfile, docker-compose.yml)
- Environment configuration (.env.example)
- Python dependencies (requirements.txt)
- Project documentation (README.md)
- Git ignore rules (.gitignore)
- Directory structure for app, routes, templates, static files

Ready for Phase 1: Backend implementation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-21 13:39:06 +01:00
MarekWo
1b3c583e04 Initial commit 2025-12-21 12:31:28 +01:00