Repository navigation
fix(messages): show what a service message did (calls, pins, group changes) - #159
Merged
neoromantic merged 1 commit intoNov 17, 2026
Conversation
…anges) A call, a pin or a group change is cached as message_type 'service' with no text and the whole TL message in raw_json, but tg messages list, get and search printed nothing about it. Every item now has action, read from raw_json when the item is printed, the way attachment is, and null for any other message. A call gives video, duration and why it ended; a pin the pinned message; a group change the new title or the users added or removed; any other action its type name. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Merged
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
A call, a pin or a group change is a service message. The cache stores it with
message_type = 'service', no text, and the whole TL message inraw_json, buttg messages list,getandsearchprinted nothing about what it was. An agent reading a chat could not tell that a call had happened, so it skipped those rows.Every message item now has
action, read fromraw_jsonwhen the item is printed (the wayattachmentis), andnullfor any other message.Before (
tg messages geton a made-up answered call, from the e2e fixtures):{ "messageId": 1, "text": null, "messageType": "service", "hasMedia": false, "attachment": null }After, the same message:
{ "messageId": 1, "text": null, "messageType": "service", "hasMedia": false, "attachment": null, "action": { "type": "phone_call", "video": false, "duration": 1834, "reason": "hangup" } }(Both are the real output with the unchanged fields left out.)
The shape:
typephone_callvideo;durationin seconds,nullwhen nobody answered;reason:missed,busy(declined),hangup,disconnect, ornullgroup_callduration:nullwhen the video chat started, seconds when it endedpin_messagemessageId, the pinned messagechat_createtitle,userIdschannel_create,chat_edit_title,topic_createtitlechat_add_user,chat_delete_user,chat_joined_by_linkuserIds,userId,inviterIdtype: the TL name in snake case withoutmessageAction(chat_edit_photo,screenshot_taken…), so nothing is droppedDecisions you may want to change:
action: nullon ordinary messages, not a missing key: it matchesattachment: nulland gives every item one shape.type(the TL name in snake case), for mapped and unmapped actions alike, so mapping another action later only adds fields.tg messages searchstill finds a service message only by its text, which is empty. That can be a follow-up if you want calls to be searchable.No migration and no schema change: old caches get the field because it is read from
raw_json.raw_jsonis now read for service rows as well as media rows.How I checked it
Unit tests in
src/__tests__/service-action.test.tson made-up raw messages taken throughtoRawJson: an answered voice call, a video call, missed and busy calls, a call with no reason, pins with and without a reply header, group create, rename, add, remove and join by link, unmapped actions, and input that isn't a message.E2E in
src/__e2e__/messages.e2e.test.ts:messages liston a chat with three calls,messages get --contextaround a pin with a rename and an unmapped action next to it, andmessages search.Ran the extractor over the 124 service messages of a real cache, read-only and outside the repo: every one got a
type, and all 89 calls came out with a sensiblereasonandduration. No real data is in the PR.bun run check: clean.bun run test:e2e: 369 pass, 0 fail.bun run test: 2242 pass, 1 fail. The failure iscache database lock > lets several processes switch a new or folded cache to WAL at once(SQLITE_SCHEMAinconfigureSearchMerges); it fails the same way on an untouchedmainon my machine (macOS, Bun 1.4.4), and this change doesn't touch that code.Tests pass locally and use made-up data only (apart from the one failure above, which
mainhas too)README, docs and affected demos follow the product content standard (
docs/cli-commands.md,docs/database-schema.md, themessage_typeschema annotation, README and CHANGELOG)Title follows the repo's commit style: Conventional Commits (
feat: …,fix: …) unlessAGENTS.mdsays otherwise🤖 Generated with Claude Code