Skip to content
01
Repos

mologram

public custom580.2 KB

mologram

A Telegram Desktop clone for the terminal: three panes, mouse and keyboard, floating and torn-off chats, Premium features, media. One static binary for the UI (mologram) and one for the daemon (mologramd) that owns the Telegram session. C++20 on rgui (UI) and tapi (Telegram), no other dependencies.

This file says what the program does today. Requirements and their tests: SPEC.md (section 10). Classes, threads and owners: DESIGN.md. Decisions: docs/adr/. Status per milestone: BUILD-TRACK.md. Runbooks: docs/runbooks/. Every markdown file is listed in docs/DOC-REGISTER.md.

Install, run, configure

make build            # configure and build everything (needs ../rgui, ../grrbackupclankertelegram/tapi built with make deps, libwolfssl.a)
make test             # all offline tests
make check            # tests, --help/--version/--dump-config, both binaries are static
make run              # build/mologram

Setup of the credentials is done by the owner once (the agent never touches them, D-11):

cp ../grrbackupclankertelegram/.env.json ./.env.json && chmod 600 .env.json

mologram starts the daemon itself when none answers on socket_path and the daemon stops when the last window leaves (keep_daemon keeps it). Command line: --config PATH, --dump-config (secrets redacted), --no-daemon, --fake (in-memory demo service), --chat KEY (one conversation in this terminal), --socket PATH, --auth-tsv PATH (development only: an exported auth key, only while the Python userbot is not running). Config keys, their types and defaults: SPEC.md section 6.1; unknown keys warn, wrong types fall back per key, bad JSON reports line and column.

First start and login

.env.json holds your API credentials and phone number; it is not a login. A new session on this computer always needs one Telegram login code (a Telegram rule, not a mologram choice). After that the session file (session_path, mode 0600) keeps you signed in and no code is asked again.

  1. Start ./build/mologram. With phone in the config the code is requested by itself; without it the dialog asks for the number.
  2. By default Telegram sends the code to the Telegram app on your other devices (a message from the chat named "Telegram"), not by SMS. The dialog says where it went; Resend switches to SMS when Telegram offers it.
  3. Type the code (and the 2FA password if you have one). The chat list loads.

To skip the code on a machine that already has an exported auth key (development only): stop the Python userbot, then run ./build/mologramd --import-auth /tmp/probe_auth.tsv --i-stopped-the-userbot once. Two clients must never use the same key at the same time.

If login does not work, the answer is in the log: ~/.local/share/mologram/log/mologram-YYYY-MM-DD.log (the daemon and the UI both write to it; secrets are replaced by <redacted>).

Keys

Generated from the action registry (SPEC.md section 6.3); tests/test_docs.cpp keeps this table equal to it. F1 lists the effective keys, F2 opens settings where they can be rebound. Every action also has a menu entry.

Action Default key Menu
search Ctrl+K Chat/Search
search_chat Ctrl+F Chat/Search in chat
chat_prev Ctrl+Up Go/Previous chat
chat_next Ctrl+Down Go/Next chat
chat_prev_alt Alt+Up Go/Previous chat
chat_next_alt Alt+Down Go/Next chat
folder_prev Ctrl+PgUp Go/Previous folder
folder_next Ctrl+PgDn Go/Next folder
back Escape Go/Back
send Enter Message/Send
newline Shift+Enter Message/New line
edit_last Up Message/Edit last
fmt_bold Ctrl+B Format/Bold
fmt_italic Alt+I Format/Italic
fmt_underline Ctrl+U Format/Underline
fmt_link Ctrl+K Format/Link
fmt_code Alt+E Format/Code
fmt_spoiler Alt+H Format/Spoiler
emoji Ctrl+E Message/Emoji
attach Ctrl+O Message/Attach
reply Ctrl+R Message/Reply
delete Ctrl+D Message/Delete
forward Ctrl+G Message/Forward
pin Ctrl+P Message/Pin
info F3 View/Info pane
transfers F4 View/Transfers
stories F5 View/Stories
story_post F6 View/Post story
close_window Ctrl+W Window/Close
tear_off Ctrl+T Window/Open in new window
settings F2 App/Settings
help F1 Help/Keys
quit Ctrl+Q App/Quit
float_chat Alt+T Window/Open floating window
react Alt+R Message/React
select Alt+S Message/Select
poll Alt+O Message/Create poll
schedule Alt+D Message/Schedule
contacts Alt+C App/Contacts
new_chat Alt+N App/New chat
profile Alt+P View/Profile
accounts Alt+A App/Accounts
mute Alt+M Chat/Mute
archive Alt+V Chat/Archive
mark_read Alt+K Chat/Mark as read
search_in_chat Alt+F Chat/Search messages
pinned_next Alt+J Message/Next pinned
call F7 Chat/Call
secret_chat F8 Chat/Secret chat
gifts Alt+G App/Gifts
business Alt+B App/Business

Mouse

Where What
Chat list row click opens; double click opens it in a new terminal window; drag the row (or the chat header) to the window edge and release to tear it off; right click: pin, mute, archive, mark read, delete
Message right click: reply, forward, copy, edit, delete (asks for me or everyone); click a reaction or a bot button; click media to open the viewer
Composer attach, emoji and send buttons; pasting a file path asks before sending
Menu bar, tabs, dialogs every dialog is made of real widgets: click works as much as the keyboard
Panes and lists wheel scrolls; folder tabs collapse to a dropdown on narrow terminals

Dragging a file from a file manager into a terminal pastes its path; mologram treats that as attach (a terminal cannot receive a dropped widget or file itself).

What works today (0.1.11)

  • Accounts: login with phone, code, 2FA password (with the server's hint), QR; resend; accounts switch and log out.
  • Chats: chat list with folders and archive, pin, mute, mark read, delete, leave; search (global, in chat, with type filters); drafts that follow to other windows; scheduled send; unread divider; history paging both ways.
  • Messages: send with formatting, reply, edit, delete for me or everyone, forward, copy, multi-select, pin and pinned bar, reactions (free and Premium), polls (create, vote), bot commands, inline bots, bot buttons, stickers, emoji picker.
  • Media: thumbnails then full files from a checksum-verified cache, images in bubbles (halfblock, kitty, sixel), GIF, animated stickers (Lottie), WebP, voice with its waveform, albums, send with progress and cancel (F4 transfers), save as, open with the system, profile media tabs, stories slideshow (F5) and posting (F6).
  • Windows: three panes down to 40x15, floating chat windows (move, resize, snap, task list), tear-off into new terminals that stay in sync, state restored after a restart, terminal restored after quit, SIGTERM, SIGHUP or a crash.
  • Premium: all 21 features in SPEC.md 6.5 in the service layer, three ways tested (Premium, NotPremium, Premium lost midway); the UI keeps controls visible with a lock mark and explains instead of failing.
  • Daemon: one per session, unix socket 0600, stale socket detection, reconnect every second, bad frames rejected and counted.
  • Service layer beyond the UI: Business, stories read and write, gifts catalogue, payments display, Passport read, secret chat and call signaling (no call audio).
  • Calls, secret chats, Business, gifts, Passport, payments, stories (UI): a call panel (start, accept, decline, hang up, key fingerprint; it says plainly that audio is not available), secret chat windows with timer and fingerprint, Business settings, a gifts catalogue that spends nothing until the explicit confirm button, read-only Passport and payment forms, story posting with audience and duration and a viewer with views, stealth, react and link.
  • Composer: @ offers people, # hashtags seen in the chat, / bot commands; a pasted file path opens the media send dialog.
  • Process: --no-daemon runs the real service inside the UI; a supervisor relaunches a lost daemon every second without losing drafts, the open chat or windows.

Verified live

All on 2026-11-05, machine devplace (Linux 7.0.0-42-generic), the owner's real account with Premium, Python userbot not running, serialized with flock /tmp/mologram-live.lock. The programs print only pass or fail, never chat content or secrets, touch only Saved Messages and entities they create themselves, and delete what they create.

Latest round on the merged tree (v0.1.11):

Program Result Scope
live_tapi (service layer, with a story image and a generated voice note) 62 passed, 0 failed, 9 skipped hello, dialogs (220, paged, no duplicates), folders, history paging, send/edit/delete in plain and html, search, drafts and the draft event, pin, forward, scheduled messages, reactions and tags, translate, voice-to-text on a real voice note, polls, files with progress and cancel, stickers and premium stickers, bot.commands, contacts, sessions, privacy (unchanged write-back of keys without exception lists), Business round trips, a story visible to nobody (sent, read, pinned, deleted, none left), channel created and deleted
make live-media 13 passed, 0 failed previews and full photos, byte-identical document download, voice waveform, video and GIF classification, album, upload progress and cancel, search filters
make live-ui-write 13 passed, 0 failed the UI classes on the real service: send, edit, react, pin, unpin, poll create and vote, search, delete
live_ui --sizes 21 passed, 0 failed the real mologram in a pty at 40x15, 80x24, 160x50 and a live resize; Settings and help fit; read only
mologram in a 120x30 pty, daemon mode and --no-daemon connected, Premium detected, All and Archive tabs, exit 0 the UI started mologramd itself, the daemon and its socket went away with the last window

Earlier rounds (tapi library 21 of 21 with Premium after 19 of 20 without; service layer 28, 47 and 60 passed with 0 failed; live_ui 18 of 18) are in BUILD-TRACK.md and CHANGELOG.md.

Skipped, with the reason (unverified live): events that need a second sender (message.new/edited/deleted/read/typing/presence from other people); custom emoji reactions and message effects (the server refuses them in Saved Messages); stories.stealth (server cooldown); gifts and payments (they spend Stars); secret chat and call acceptance (need a second session); emoji.custom (no installed set); bot.inline and bot.inline_send (@gif not found); auth.resend_code and the 2FA hint (would send a real login code).

Not verified live at all (offline against the fake service only): the phone, code and password login flow and QR login, logout, the write paths of the contacts-add, privacy and profile dialogs, join and leave of other people's chats, the tear-off edge gesture on a real xterm or kitty.

Incident: a first version of the privacy write-back test changed the exception list of phone_number; the old list is unknown. tapi now refuses to write when an exception cannot be kept (UPSTREAM.md). A test story was probably visible to everyone for a few minutes (docs/postmortems/2026-11-05-story-privacy.md).

Measured

Author machine devplace, 2026-11-05.

What Value
make test (this tree) 227 tests, 227 passed, 0 failed, about 18 s wall (stable over repeated runs), including the real-process tests (pty, signals, two daemons) and 9 documentation gates
rgui suite (../rgui, merged tracks A and C) 272 run, 256 passed, 0 failed, 16 skipped (opt-in fuzz and pty tiers, not run); goldens unchanged
tapi suite (ctest in ../grrbackupclankertelegram/tapi/build) 17 of 17 pass, offline
Binary sizes as built mologram 74,521,520 B, mologramd 70,714,920 B (the generated TL classes of tapi dominate; mologram links the service for --no-daemon)
Binary sizes stripped (make dist) mologram 36,624,616 B (-51%), mologramd 33,433,320 B (-53%)
Static gate ldd on all four binaries: "not a dynamic executable"; make image-check runs --version and --help of both in a FROM scratch image
Image (make image, podman 5.7.0) 39.1 MB
Daemon in the image a host client got hello (proto_version 1) and the dialog list through the mounted socket; stopping the container removed socket and lock
Not measured cold build time, memory use of a long session, startup latency of the UI, human review effort
--no-daemon quit 0.2 to 0.3 s in about half of 6 runs, 8 to 15 s in the others (blocked socket read inside tapi, UPSTREAM.md); accepted by the owner; daemon mode exits at once
Dialog load, real account 220 dialogs in 0.4 s, none duplicated, in pages with cancel checks

Open gaps

Requirements that are not (fully) built. The list is checked against SPEC.md section 10: every open requirement appears here and in BUILD-TRACK.md.

Requirement Gap Work
FR-14 Forum topics: list, open, create, edit, close, delete. No protocol method and no UI. SPEC 7.1: 1 to 1.5 PW with FR-15
FR-15 Channel comments and thread replies. No protocol method and no UI. with FR-14
FR-13 Saved dialogs view (tags work). small
FR-22 List view for scheduled messages (service method exists). small
FR-23 Link previews provided by the service. small
FR-24 Dice, location, contact and venue cards (shown as a text tag). small
FR-25 Via-bot and sponsored message marks. small
FR-33 Animated WebP is not decoded; video and WebM stickers need host ffmpeg; Lottie gradients, trim paths, masks, mattes and dashes are not rendered (none occur in 6 of 6 real stickers). rgui
FR-40 Slow mode, admin log and permissions dialogs. 1 PW
FR-52 Call audio (measured: no static Opus or audio libraries, PIN-03): 6 to 10 PW; secret chats were never tested against a real second party and show the key as hex. SPEC 7.1
FR-70 Resizing the panes by mouse or keyboard. rgui SplitPane glue
FR-74 Tests for text selection, tooltips and scrollbars (rgui widgets). tests
NFR-05 RTL reordering (UAX #9). rgui, 1 to 2 PW
NFR-06 A mologram level test of the 16 colour fallback (rgui chooses). tests
Transfers Big uploads stream from disk but are not parallel; fast Premium download is not done (tapi's invoke_many runs requests one after another). tapi
Stories Video stories are not built. small
Other --no-daemon quits in 0.2 s or after 8 to 15 s (tapi, UPSTREAM.md); accepted by the owner on 2026-11-05, daemon mode is not affected. Unlimited in-memory image caches (ADR 0007) grow with long sessions: derived data, rebuilt on demand. rgui's MenuBar still caps a dropdown at 24 rows and tapi keeps an entity cache limit (UPSTREAM.md, D-02).

Comparison with other terminal Telegram clients

Research of 2026-11-05. Sources are each project's own GitHub README, read that day (links below). "n/s" means the README does not state it, which is not the same as "absent": I did not install or run any competitor. Last-commit and release dates were not shown by the pages, so activity is only what the READMEs and listings say. Two GitHub topic pages returned 404, so a client I could not find may be missing. The nchat and tgx pages were only partly read (the rest came from a model summary); those cells are marked (s) and are unverified.

For mologram, every cell says how it was checked: live (run on a real account, README "Verified live"), offline (tests against the fake service only), no.

The field

Client Language, Telegram library, UI Stars (page) Platforms Binary
mologram C++20, own tapi (Telethon port, MTProto), rgui 0 (private, one machine) Linux only static, ldd checked
nchat C++ and Go, TDLib, ncurses; also WhatsApp and Signal 2.0k Linux, macOS prebuilt "experimental"; runtime deps n/s
tg Python, TDLib 1.2k macOS, Linux (implied), Docker Python package, optional ffmpeg etc.
tgt (FedericoBruzzone) Rust, TDLib 1.0k Linux, macOS, Windows (CI badges) static tdjson optional
telegram-tui (SpechtLabs) Rust, TDLib, ratatui 0 macOS, Linux (glibc 2.39+) TDLib as a shared object beside it
tele Go, gotd/td (MTProto), bubbletea 238 Linux, macOS, Windows, BSDs "one static binary"
tuilegram Go, gotd/td, bubbletea 31 macOS, Linux "single static binary"; author says "don't trust it with your only account yet"
tgx Python, Telethon, Textual 1 n/s Python venv
telegramtui (k4dy) Java 21, TDLib, Lanterna 22 macOS, Linux, WSL JVM and TDLib needed
tg-tui (ApollieKastro) Rust, grammers (MTProto), ratatui 0 n/s native Rust
tttc Python, Telethon, curses 8 n/s Python
telegram-cli C, own tgl, readline 7.2k Linux, BSD, macOS, Cygwin needs libreadline, libssl, libevent and more; packaging notes call upstream inactive
Telegram-TUI (Petingo) JavaScript, airgram and TDLib, blessed 6 n/s author "has no time for developing this"

Features

Legend: yes = stated by the README; n/s = not stated; no = README says it is missing. For mologram: L live, O offline only, - no.

Feature mologram nchat tg tgt (Fed.) Specht tele tuilegram tgx
Login phone, code, 2FA O (live runs reuse an exported key) QR by default n/s n/s wizard asks api_id/hash QR or phone+code+2FA yes yes
QR login O yes n/s n/s n/s yes n/s n/s
Folders L n/s n/s n/s yes yes yes yes
Archive L yes n/s n/s yes n/s n/s folder exclusion only
Send, edit, delete, reply, forward L yes yes n/s yes (forward as chip) yes yes yes
Reactions L (incl. Premium extras) yes n/s n/s yes yes display only yes
Polls (create, vote) L n/s n/s n/s n/s backlog n/s CLI only
Send files, photos, albums L n/s (view and save) yes n/s yes (upload) yes no yes
Inline image preview L decode, kitty, sixel, half-block n/s n/s (mailcap) chafa kitty, iTerm2, sixel kitty, Ghostty, iTerm2 or block art no yes (s)
Voice L play via host player + waveform; send a voice file; cannot record n/s record and play play (rodio) n/s play, no record no transcribe
Animated stickers L (own Lottie renderer, 6 of 6 real ones) n/s needs external handler n/s n/s n/s first emoji only n/s
GIF and video L via host ffmpeg n/s via mailcap n/s n/s inline previews no n/s
Secret chats O (never tested against a real second party) n/s yes n/s no backlog n/s n/s
Stories L (private story: post, view, delete) WhatsApp status only n/s n/s n/s n/s n/s CLI only
Calls signaling only, no audio opens a tel:// link externally n/s n/s no no n/s CLI, no audio
Premium features L (21; three ways tested) n/s n/s n/s n/s n/s n/s partly (stealth view, Stars)
Business features L (round trips) n/s n/s n/s n/s n/s n/s yes
Bots, inline, buttons L buttons and commands; inline partly n/s bot keyboard n/s n/s backlog n/s yes
Search L in chat yes n/s yes chats only yes yes
Mouse L n/s n/s n/s yes optional partly click only
Several chats side by side L floating windows and tear-off into new terminals n/s n/s n/s n/s many windows, a second instance joins n/s no
Emoji and CJK width L (rgui tables + terminal probe, 30 tests) emoji toggle n/s n/s n/s planned n/s n/s
Themes, rebindable keys L yes colors only n/s TOML themes yes yes themes
Notifications L bell and toast yes yes n/s OSC 777 daemon n/s yes
Tests in the repo 227 offline + live suites n/s n/s n/s n/s n/s n/s n/s

Honest verdict

Where mologram is ahead, by what the READMEs state:

  • Breadth of Telegram features. No other client in this list states Premium, Business, stories, secret chats, Lottie stickers, polls, reactions and side-by-side windows together. Only tgx covers Business and some Premium, mostly as a CLI, and tele has the closest multi-window design.
  • No TDLib. mologram, tele, tuilegram and tg-tui avoid TDLib; mologram and tele ship one static binary, which most of the TDLib clients cannot.
  • Evidence. The live results, the 227 tests, the spec with traceability and the doc gates are rare in this category; no competitor README mentions tests.

Where mologram is behind:

  • Maturity and users. Zero outside users, one machine, one account, built in days. nchat (2.0k stars), tg (1.2k), tgt (1.0k) and telegram-cli (7.2k) have years of field use. Treat the live results as one owner's account, not as field testing.
  • Platforms and install. Linux only, built from source; nchat, tele and tgt ship Homebrew, AUR, packages or install scripts and run on macOS (tele and tgt also on Windows).
  • Voice recording. tg records voice messages; mologram only plays and sends voice files.
  • Call audio. None, like every other client here; tgx at least starts calls from its CLI.
  • Other messengers. nchat also speaks WhatsApp and Signal; mologram is Telegram only.
  • Binary size. About 36 MB (UI) and 33 MB (daemon) stripped, against a few MB for the Rust and Go clients.
  • Unverified claims. Real login with a code, secret chats with a real second party, message events from other people, and the edge-drag tear-off on a real xterm or kitty were never exercised.

Net: for someone who needs the widest Telegram coverage in a terminal, mologram targets more than any listed competitor, and its design (daemon, tear-off windows, no TDLib, static binary) is distinctive. For someone who wants something proven, portable and packaged today, nchat, tg or tele are the safer choices. This table says what each README claims, not how well each works.

Sources, all read on 2026-11-05: the GitHub pages linked in the field table; the listings used to find clients and activity (https://github.com/SpechtLabs/telegram-tui, https://www.linuxlinks.com/nchat-terminal-based-chat-client/, https://www.linuxlinks.com/tg-telegram-terminal-client/, https://awesome.ecosyste.ms/projects/github.com%2Fpaul-nameless%2Ftg, https://freshports.org/net-im/telegram-cli). Stars are as shown on each page that day.

Packaging

make dist writes stripped binaries to dist/; make image builds a FROM scratch image with only those two (Containerfile, ADR 0014); make image-check runs both binaries in that image; make up runs the daemon in a container (credentials mounted read-only from .env.json, never baked in) and the UI on the host attaches with build/mologram --socket <data dir>/run/mologram.sock; make down and make logs stop and show it. make lint runs the documentation gates and rejects U+2014 in sources and documents.

Documents

File What
SPEC.md requirements, tables, protocol, decisions, acceptance criteria and traceability
DESIGN.md every class: responsibility, owner, lifetime, thread
BUILD-TRACK.md status per milestone and gate, session history
CHANGELOG.md one row per version
UPSTREAM.md requests to rgui and tapi
docs/adr/ decisions (index in docs/adr/README.md)
docs/runbooks/ daemon start, stale socket, Premium lapse, lost session, cache corruption, live-test hygiene (each with its last drill)
docs/postmortems/ incidents
docs/DOC-REGISTER.md owner, trigger and staleness of every document
120.8ms