Repository navigation
feat: add next commands to paged reads and an empty chat cache - #176
Merged
neoromantic merged 1 commit intoNov 18, 2026
Merged
Conversation
A success answer can carry next: complete tg command lines, each with a reason, that continue the read. Paged lists (messages list and search, chats list, contacts list, messages wait on one chat) suggest the next page, and a chat search that finds nothing suggests the refresh. Each command is built from the parsed arguments, so it keeps the account and every filter, quoted for a POSIX shell. Existing fields are unchanged; pretty output prints the suggestions on stderr. Refs neoromantic#160 Co-Authored-By: Claude Fable 5.2 <[email protected]>
This was referenced Nov 18, 2026
Merged
3 tasks done
neoromantic
added a commit
that referenced
this pull request
Nov 18, 2026
Lands #176 on current main. Refs #160 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 18, 2026
ertembiyik
pushed a commit
to ertembiyik/telegram-sync-cli
that referenced
this pull request
Nov 18, 2026
Resolves the conflicts with neoromantic#176/neoromantic#177 in CHANGELOG.md (both sections kept) and src/commands/messages/search.ts (success(data, next) from main, the snippet from the rendered item text from neoromantic#178). Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
Point 1 of #160. A success answer can now carry
next: completetgcommand lines, each with a reason, so an agent runs the next page or the cache refresh as written instead of rebuilding it from cursors or from advice inside amessagestring. As you asked, each command keeps the account and every filter the original was given. Refs #160Before (
tg chats search --query 'nothing like it', nothing cached matches):{ "success": true, "data": { "query": "nothing like it", "results": [], "total": 0, "source": "cache", "stale": false, "message": "No results in cache. Run \"tg chats list --fresh\" to populate cache first." } }After: the same
data, plusPaging.
tg messages list --chat -1001234567890 --limit 3 --account 'Work Phone'now adds:All of the above is real output from the e2e fixtures.
What gets
next:messages list--beforeor--after)messages search--offset)chats list,contacts listhasMore--offset)messages wait --chatchats searchchats list --fresh, then the same searchHow it is built:
nextsits besidedata, not inside it, sodatais exactly what it was. Every existing field (message,nextBefore,nextAfter,hasMore,offset) is unchanged.tgCommandinsrc/commands/next.tswalks the command's own declared arguments with their defaults, so a flag added to one of these commands later is carried without touching the builder. Flags at their default are left out.--name=value, so a negative chat ID or a query that starts with-stays a value, and anything the shell would change is single-quoted.jsonaddsnext;prettykeeps stdout the bare data and prints each suggestion on stderr;quietprints nothing. The global-f,-vand-qare not carried.allowedChats: the builder refuses any command that isn't a read inCOMMAND_ACCESS, and a suggestion reads the same chat the original already passed the check for.Most of the line count in the six command files is their
argsmoving into a named constant, one indent level out, so the builder can read the defaults;git diff -wshows the real change.Decisions you may want to change:
--accountthe suggestion has none and follows the active account. Pinning the resolved ID would survive an account switch between pages, but adds--account=1to every single-account setup.--freshis carried onchats listandcontacts list, so the next page slices the same list the first page came from. The cost is one dialog fetch per page.messages wait --chatis included, although it isn't a list, because it has a real cursor.next:messages unread(its continuation is a different read),messages waitwithout--chat(no single cursor),messages watch(a stream), and the "not signed in" answers (tg auth loginis a write and needs a person).How I checked it
E2E in
src/__e2e__/next-commands.e2e.test.ts: for each paged command the test takesnext[0].commandfrom the answer, runs that exact string throughsh -c, and gets the following page. One case uses a phrase query with quotes,$and a leading--, a negative chat ID and an account label with a space. The empty-cache cases and theprettyandquietformats are covered too.Unit tests in
src/__tests__/next-command.test.ts: each quoted value goes through a realshand comes back unchanged; defaults are left out; a write is refused.Not checked against Telegram: suggestions that need a connection (
chats list --fresh, a forward page past the cache) are only checked to be well-formed, since the fixtures have no credentials.bun run check: clean.bun run test: 2319 pass, 0 fail.bun run test:e2e: 443 pass, 0 fail.Tests pass locally and use made-up data only
README, docs and affected demos follow the product content standard (
docs/api-design.md,docs/cli-commands.md, README, CHANGELOG)Title follows the repo's commit style: Conventional Commits (
feat: …,fix: …) unlessAGENTS.mdsays otherwise🤖 Generated with Claude Code