Skip to content

feat: SQLite message tracking, tmux windows, tool call display#12

Open
MichaelC001 wants to merge 3 commits intokidandcat:mainfrom
MichaelC001:dev
Open

feat: SQLite message tracking, tmux windows, tool call display#12
MichaelC001 wants to merge 3 commits intokidandcat:mainfrom
MichaelC001:dev

Conversation

@MichaelC001
Copy link
Copy Markdown
Contributor

Summary

Major reliability and architecture improvements for the Claude Code ↔ Telegram bridge.

1. SQLite message database (replaces JSONL ledger)

  • All message delivery state tracked in ~/Library/Caches/ccc/ccc.db
  • INSERT ... ON CONFLICT UPDATE for atomic dedup — fixes parallel hook race condition where the same message was sent multiple times
  • Tool state (blockquote message) also stored in DB instead of JSON files
  • Telegram→terminal delivery confirmation: if Claude doesn't acknowledge a forwarded message within 10s, auto-retry and notify user

2. Tool call display in Telegram

  • Each tool call shown as ⚙️ ToolName: summary in a blockquote
  • Assistant text interleaved by timestamp order (💬 prefix)
  • Blockquote message edited in-place as new tools are called
  • Markdown parse errors fall back to plain text with ⚠️ indicator

3. Tmux windows instead of sessions

  • Each Claude instance runs in a tmux window (within one shared session) instead of a separate tmux session
  • Window ID tracking for reliable targeting even after renames
  • Cleaner resource management

4. Other improvements

  • Config migrated to ~/.config/ccc/config.json, runtime state to ~/Library/Caches/ccc/
  • Transcript tail-read (last 512KB) instead of full file scan — fixes 74s delay on large transcripts
  • Background retry process for stop hook transcript flush race condition
  • Typing indicator while Claude is thinking
  • OTP permission mode for secure remote sessions
  • Voice/photo/document message support from Telegram
  • Transcript parser tool (parse_transcript.py) for debugging

Test plan

  • Send message from Telegram → verify DB records and terminal delivery
  • Claude responds → verify single delivery to Telegram (no duplicates)
  • Parallel tool calls → verify dedup (same message not sent twice)
  • Restart listener → verify undelivered message recovery
  • sqlite3 ~/Library/Caches/ccc/ccc.db "SELECT * FROM messages" to inspect state

🤖 Generated with Claude Code

MichaelC001 and others added 3 commits February 27, 2026 08:18
Python script to parse Claude Code transcript JSONL into CSV
or terminal table format for debugging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- New db.go: SQLite-backed message tracking and tool state
- INSERT OR IGNORE for atomic dedup (fixes parallel hook race)
- Telegram→terminal delivery confirmation with 10s auto-retry
- Delete ledger.go (JSONL implementation)
- Update tests to use temp SQLite DB

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
INSERT OR IGNORE caused delivery flags to stay at 0 when the first
insert had telegram_delivered=false. Subsequent inserts were ignored,
so the message was never marked as delivered and got resent repeatedly.

Use ON CONFLICT DO UPDATE SET with MAX() to only upgrade flags
(false→true), never downgrade.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant